public MVChatListener(MultiverseCore plugin, MVPlayerListener playerListener) { this.plugin = plugin; this.worldManager = plugin.getMVWorldManager(); this.playerListener = playerListener; }
@Override public void runCommand(CommandSender sender, List<String> args) { sender.sendMessage(ChatColor.GOLD + "Reloading all Multiverse Plugin configs..."); this.plugin.loadConfigs(); this.plugin.getAnchorManager().loadAnchors(); this.plugin.getMVWorldManager().loadWorlds(true); List<String> configsLoaded = new ArrayList<String>(); configsLoaded.add("Multiverse-Core - config.yml"); configsLoaded.add("Multiverse-Core - worlds.yml"); configsLoaded.add("Multiverse-Core - anchors.yml"); // Create the event MVConfigReloadEvent configReload = new MVConfigReloadEvent(configsLoaded); // Fire it off this.plugin.getServer().getPluginManager().callEvent(configReload); for (String s : configReload.getAllConfigsLoaded()) { sender.sendMessage(s); } sender.sendMessage(ChatColor.GREEN + "Reload Complete!"); }
@Override public Location validateChange(String property, Location newValue, Location oldValue, MVWorld object) throws ChangeDeniedException { if (newValue == null) throw new ChangeDeniedException(); if (props.getAdjustSpawn()) { BlockSafety bs = plugin.getBlockSafety(); // verify that the location is safe if (!bs.playerCanSpawnHereSafely(newValue)) { // it's not ==> find a better one! plugin.log(Level.WARNING, String.format("Somebody tried to set the spawn location for '%s' to an unsafe value! Adjusting...", getAlias())); plugin.log(Level.WARNING, "Old Location: " + plugin.getLocationManipulation().strCoordsRaw(oldValue)); plugin.log(Level.WARNING, "New (unsafe) Location: " + plugin.getLocationManipulation().strCoordsRaw(newValue)); SafeTTeleporter teleporter = plugin.getSafeTTeleporter(); newValue = teleporter.getSafeLocation(newValue, SPAWN_LOCATION_SEARCH_TOLERANCE, SPAWN_LOCATION_SEARCH_RADIUS); if (newValue == null) { plugin.log(Level.WARNING, "Couldn't fix the location. I have to abort the spawn location-change :/"); throw new ChangeDeniedException(); } plugin.log(Level.WARNING, "New (safe) Location: " + plugin.getLocationManipulation().strCoordsRaw(newValue)); } } return super.validateChange(property, newValue, oldValue, object); } }
/** * Saves all anchors. * @return True if all anchors were successfully saved. */ public boolean saveAnchors() { try { this.anchorConfig.save(new File(this.plugin.getDataFolder(), "anchors.yml")); return true; } catch (IOException e) { this.plugin.log(Level.SEVERE, "Failed to save anchors.yml. Please check your file permissions."); return false; } }
/** * Saves the Multiverse-Config. * * @return Whether the Multiverse-Config was successfully saved */ public boolean saveMVConfig() { try { this.multiverseConfig.set("multiverse-configuration", getMVConfig()); this.multiverseConfig.save(new File(getDataFolder(), "config.yml")); return true; } catch (IOException e) { this.log(Level.SEVERE, "Could not save Multiverse config.yml config. Please check your file permissions."); return false; } }
@Override public int getValue() { int count = 0; for (MultiverseWorld w : core.getMVWorldManager().getMVWorlds()) if (gen.equals(w.getGenerator())) count++; core.log(Level.FINE, String.format("Tracking %d worlds of type %s", count, gen)); return count; } }
getServer().getPluginManager().registerEvents(new MVWorldInitListener(this), this); this.registerEvents(); this.registerCommands(); this.initializeDestinationFactory(); loadConfigs(); if (this.multiverseConfig != null) { Logging.setDebugLevel(getMVConfig().getGlobalDebug()); Logging.setShowingConfig(!getMVConfig().getSilentStart()); this.worldManager.loadDefaultWorlds(); this.worldManager.loadWorlds(true); } else { this.log(Level.SEVERE, "Your configs were not loaded. Very little will function in Multiverse."); this.worldManager.setFirstSpawnWorld(getMVConfig().getFirstSpawnWorld()); try { getMVConfig().setFirstSpawnWorld(this.worldManager.getFirstSpawnWorld().getName()); } catch (NullPointerException e) { this.saveMVConfig(); getMVConfig().setUseAsyncChat(false); if (getMVConfig().getUseAsyncChat()) { this.chatListener = new MVAsyncPlayerChatListener(this, this.playerListener); } else {
private String getLegacyString() { StringBuilder legacyFile = new StringBuilder(); legacyFile.append("[Multiverse-Core] Multiverse-Core Version: ").append(this.plugin.getDescription().getVersion()).append('\n'); legacyFile.append("[Multiverse-Core] Bukkit Version: ").append(this.plugin.getServer().getVersion()).append('\n'); legacyFile.append("[Multiverse-Core] Loaded Worlds: ").append(this.plugin.getMVWorldManager().getMVWorlds()).append('\n'); legacyFile.append("[Multiverse-Core] Multiverse Plugins Loaded: ").append(this.plugin.getPluginCount()).append('\n'); legacyFile.append("[Multiverse-Core] Economy being used: ").append(plugin.getEconomist().getEconomyName()).append('\n'); legacyFile.append("[Multiverse-Core] Permissions Plugin: ").append(this.plugin.getMVPerms().getType()).append('\n'); legacyFile.append("[Multiverse-Core] Dumping Config Values: (version ") .append(this.plugin.getMVConfig().getVersion()).append(")").append('\n'); legacyFile.append("[Multiverse-Core] messagecooldown: ").append(plugin.getMessaging().getCooldown()).append('\n'); legacyFile.append("[Multiverse-Core] teleportcooldown: ").append(plugin.getMVConfig().getTeleportCooldown()).append('\n'); legacyFile.append("[Multiverse-Core] worldnameprefix: ").append(plugin.getMVConfig().getPrefixChat()).append('\n'); legacyFile.append("[Multiverse-Core] worldnameprefixFormat: ").append(plugin.getMVConfig().getPrefixChatFormat()).append('\n'); legacyFile.append("[Multiverse-Core] enforceaccess: ").append(plugin.getMVConfig().getEnforceAccess()).append('\n'); legacyFile.append("[Multiverse-Core] displaypermerrors: ").append(plugin.getMVConfig().getDisplayPermErrors()).append('\n'); legacyFile.append("[Multiverse-Core] teleportintercept: ").append(plugin.getMVConfig().getTeleportIntercept()).append('\n'); legacyFile.append("[Multiverse-Core] firstspawnoverride: ").append(plugin.getMVConfig().getFirstSpawnOverride()).append('\n'); legacyFile.append("[Multiverse-Core] firstspawnworld: ").append(plugin.getMVConfig().getFirstSpawnWorld()).append('\n'); legacyFile.append("[Multiverse-Core] debug: ").append(plugin.getMVConfig().getGlobalDebug()).append('\n'); legacyFile.append("[Multiverse-Core] Special Code: FRN002").append('\n'); return legacyFile.toString(); }
teleportee = this.plugin.getServer().getPlayer(args.get(0)); if (teleportee == null) { this.messaging.sendMessage(sender, String.format("Sorry, I couldn't find player: %s%s", DestinationFactory df = this.plugin.getDestFactory(); MVDestination d = df.getDestination(destinationName); this.plugin.getServer().getPluginManager().callEvent(teleportEvent); if (teleportEvent.isCancelled()) { this.plugin.log(Level.FINE, "Someone else cancelled the MVTeleport Event!!!"); return; if (plugin.getMVConfig().getEnforceAccess() && teleporter != null && !this.plugin.getMVPerms().canEnterDestination(teleporter, d)) { if (teleportee.equals(teleporter)) { teleporter.sendMessage("Doesn't look like you're allowed to go " + ChatColor.RED + "there..."); } else if (teleporter != null && !this.plugin.getMVPerms().canTravelFromLocation(teleporter, d.getLocation(teleportee))) { if (teleportee.equals(teleporter)) { this.messaging.sendMessage(teleporter, String.format("DOH! Doesn't look like you can get to %s%s %sfrom where you are...", if (teleportee.getWorld().equals(w)) { if (teleporter.equals(teleportee)) { if (!this.plugin.getMVPerms().hasPermission(teleporter, "multiverse.core.spawn.self", true)) { this.messaging.sendMessages(teleporter, new String[]{ String.format("Sorry you don't have permission to go to the world spawn!"), if (!this.plugin.getMVPerms().hasPermission(teleporter, "multiverse.core.spawn.other", true)) { this.messaging.sendMessages(teleporter, new String[]{ String.format("Sorry you don't have permission to send %s to the world spawn!",
if (args.size() <= 1) { StringBuilder builder = new StringBuilder(); Map<String, Object> serializedConfig = this.plugin.getMVConfig().serialize(); for (Map.Entry<String, Object> entry : serializedConfig.entrySet()) { builder.append(ChatColor.GREEN); return; if (!this.plugin.getMVConfig().setConfigProperty(args.get(0).toLowerCase(), args.get(1))) { sender.sendMessage(String.format("%sSetting '%s' to '%s' failed!", ChatColor.RED, args.get(0).toLowerCase(), args.get(1))); return; this.plugin.getMVWorldManager().setFirstSpawnWorld(args.get(1)); if (this.plugin.saveMVConfigs()) { sender.sendMessage(ChatColor.GREEN + "SUCCESS!" + ChatColor.WHITE + " Values were updated successfully!"); this.plugin.loadConfigs(); } else { sender.sendMessage(ChatColor.RED + "FAIL!" + ChatColor.WHITE + " Check your console for details!");
Location l = p.getLocation(); World w = p.getWorld(); MultiverseWorld foundWorld = this.plugin.getMVWorldManager().getMVWorld(w.getName()); if (foundWorld != null) { foundWorld.setSpawnLocation(p.getLocation()); BlockSafety bs = this.plugin.getBlockSafety(); if (!bs.playerCanSpawnHereSafely(p.getLocation()) && foundWorld.getAdjustSpawn()) { sender.sendMessage("It looks like that location would normally be unsafe. But I trust you."); foundWorld.setAdjustSpawn(false); sender.sendMessage("Spawn was set to: " + plugin.getLocationManipulation().strCoords(p.getLocation())); if (!plugin.saveWorldConfig()) { sender.sendMessage(ChatColor.RED + "There was an issue saving worlds.yml! Your changes will only be temporary!");
public void loadConfigs() { this.multiverseConfig = YamlConfiguration.loadConfiguration(new File(getDataFolder(), "config.yml")); InputStream resourceURL = this.getClass().getResourceAsStream("/defaults/config.yml"); config = ((wantedConfig == null) ? new MultiverseCoreConfiguration() : wantedConfig); this.migrateWorldConfig(); this.worldManager.loadWorldConfig(new File(getDataFolder(), "worlds.yml")); this.messaging.setCooldown(getMVConfig().getMessageCooldown()); this.migrate22Values(); this.saveMVConfigs();
private List<String> getFancyWorldList(Player p) { List<String> worldList = new ArrayList<String>(); for (MultiverseWorld world : this.plugin.getMVWorldManager().getMVWorlds()) { if (p != null && (!this.plugin.getMVPerms().canEnterWorld(p, world))) { continue; builder.append(" - ").append(color).append(world.getEnvironment()); if (world.isHidden()) { if (p == null || this.plugin.getMVPerms().hasPermission(p, "multiverse.core.modify", true)) { for (String name : this.plugin.getMVWorldManager().getUnloadedWorlds()) { if (p == null || this.plugin.getMVPerms().hasPermission(p, "multiverse.access." + name, true)) { worldList.add(ChatColor.GRAY + name + " - UNLOADED");
private void spawnAccurately(Player player) { MultiverseWorld world = this.plugin.getMVWorldManager().getMVWorld(player.getWorld().getName()); Location spawnLocation; if (world != null) { spawnLocation = world.getSpawnLocation(); } else { spawnLocation = player.getWorld().getSpawnLocation(); } this.plugin.getSafeTTeleporter().safelyTeleport(player, player, spawnLocation, false); } }
@Override public void runCommand(CommandSender sender, List<String> args) { Player p = this.plugin.getServer().getPlayer(args.get(0)); if (p == null) { sender.sendMessage("Could not find player " + ChatColor.GREEN + args.get(0)); sender.sendMessage("Are they online?"); return; } MVDestination dest = this.plugin.getDestFactory().getDestination(args.get(1)); if (dest instanceof InvalidDestination) { sender.sendMessage(String.format("You asked if '%s' could go to %s%s%s,", args.get(0), ChatColor.GREEN, args.get(0), ChatColor.WHITE)); sender.sendMessage("but I couldn't find a Destination of that name? Did you type it correctly?"); return; } MVPermissions perms = this.plugin.getMVPerms(); perms.tellMeWhyICantDoThis(sender, p, dest); } }
public Location getSafeLocation(Entity e, MVDestination d) { Location l = d.getLocation(e); if (plugin.getBlockSafety().playerCanSpawnHereSafely(l)) { plugin.log(Level.FINE, "The first location you gave me was safe."); return l; if (!plugin.getBlockSafety().canSpawnCartSafely(m)) { return null; if (!plugin.getBlockSafety().canSpawnVehicleSafely(v)) { return null; if (e instanceof Minecart && !plugin.getBlockSafety().isEntitiyOnTrack(safeLocation)) { safeLocation.setY(safeLocation.getBlockY() + .5); this.plugin.log(Level.FINER, "Player was inside a minecart. Offsetting Y location."); this.plugin.log(Level.FINE, "Had to look for a bit, but I found a safe place for ya!"); return safeLocation; this.plugin.getMessaging().sendMessage(p, "No safe locations found!", false); this.plugin.log(Level.FINER, "No safe location found for " + p.getName()); } else if (e.getPassenger() instanceof Player) { Player p = (Player) e.getPassenger(); this.plugin.getMessaging().sendMessage(p, "No safe locations found!", false); this.plugin.log(Level.FINER, "No safe location found for " + p.getName()); this.plugin.log(Level.FINE, "Sorry champ, you're basically trying to teleport into a minefield. I should just kill you now."); return null;
@Override public void runCommand(CommandSender sender, List<String> args) { Class<?>[] paramTypes = {String.class}; List<Object> objectArgs = new ArrayList<Object>(args); this.plugin.getCommandHandler().queueCommand(sender, "mvdelete", "deleteWorld", objectArgs, paramTypes, ChatColor.GREEN + "World Deleted!", ChatColor.RED + "World could NOT be deleted!"); } }
/** * Loads all anchors. */ public void loadAnchors() { this.anchors = new HashMap<String, Location>(); this.anchorConfig = YamlConfiguration.loadConfiguration(new File(this.plugin.getDataFolder(), "anchors.yml")); this.ensureConfigIsPrepared(); ConfigurationSection anchorsSection = this.anchorConfig.getConfigurationSection("anchors"); Set<String> anchorKeys = anchorsSection.getKeys(false); for (String key : anchorKeys) { //world:x,y,z:pitch:yaw Location anchorLocation = plugin.getLocationManipulation().stringToLocation(anchorsSection.getString(key, "")); if (anchorLocation != null) { Logging.config("Loading anchor: '%s'...", key); this.anchors.put(key, anchorLocation); } else { Logging.warning("The location for anchor '%s' is INVALID.", key); } } }
if (!this.plugin.getMVPerms().hasPermission(sender, "multiverse.core.anchor.delete", true)) { sender.sendMessage(ChatColor.RED + "You don't have the permission to delete anchors!"); } else { if (this.plugin.getAnchorManager().deleteAnchor(args.get(0))) { sender.sendMessage("Anchor '" + args.get(0) + "' was successfully " + ChatColor.RED + "deleted!"); } else { if (!this.plugin.getMVPerms().hasPermission(sender, "multiverse.core.anchor.create", true)) { sender.sendMessage(ChatColor.RED + "You don't have the permission to create anchors!"); } else { Player player = (Player) sender; if (this.plugin.getAnchorManager().saveAnchorLocation(args.get(0), player.getLocation())) { sender.sendMessage("Anchor '" + args.get(0) + "' was successfully " + ChatColor.GREEN + "created!"); } else {
public TeleportResult safelyTeleport(CommandSender teleporter, Entity teleportee, MVDestination d) { if (d instanceof InvalidDestination) { this.plugin.log(Level.FINER, "Entity tried to teleport to an invalid destination"); return TeleportResult.FAIL_INVALID; return TeleportResult.FAIL_INVALID; MultiverseCore.addPlayerToTeleportQueue(teleporter.getName(), teleporteePlayer.getName());