diff --git a/src/main/java/com/onarandombox/MultiverseCore/MVWorld.java b/src/main/java/com/onarandombox/MultiverseCore/MVWorld.java index 01dd6cce..28208d9b 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/MVWorld.java +++ b/src/main/java/com/onarandombox/MultiverseCore/MVWorld.java @@ -60,23 +60,23 @@ public class MVWorld extends SerializationConfig implements MultiverseWorld { private static final int SPAWN_LOCATION_SEARCH_TOLERANCE = 16; private static final int SPAWN_LOCATION_SEARCH_RADIUS = 16; - private static final Map propertyAliases; + private static final Map PROPERTY_ALIASES; static { - propertyAliases = new HashMap(); - propertyAliases.put("curr", "currency"); - propertyAliases.put("scaling", "scale"); - propertyAliases.put("aliascolor", "color"); - propertyAliases.put("heal", "autoHeal"); - propertyAliases.put("storm", "allowWeather"); - propertyAliases.put("weather", "allowWeather"); - propertyAliases.put("spawnmemory", "keepSpawnInMemory"); - propertyAliases.put("memory", "keepSpawnInMemory"); - propertyAliases.put("mode", "gameMode"); - propertyAliases.put("diff", "difficulty"); - propertyAliases.put("spawnlocation", "spawn"); - propertyAliases.put("animals", "spawning.animals.spawn"); - propertyAliases.put("monsters", "spawning.monsters.spawn"); + PROPERTY_ALIASES = new HashMap(); + PROPERTY_ALIASES.put("curr", "currency"); + PROPERTY_ALIASES.put("scaling", "scale"); + PROPERTY_ALIASES.put("aliascolor", "color"); + PROPERTY_ALIASES.put("heal", "autoHeal"); + PROPERTY_ALIASES.put("storm", "allowWeather"); + PROPERTY_ALIASES.put("weather", "allowWeather"); + PROPERTY_ALIASES.put("spawnmemory", "keepSpawnInMemory"); + PROPERTY_ALIASES.put("memory", "keepSpawnInMemory"); + PROPERTY_ALIASES.put("mode", "gameMode"); + PROPERTY_ALIASES.put("diff", "difficulty"); + PROPERTY_ALIASES.put("spawnlocation", "spawn"); + PROPERTY_ALIASES.put("animals", "spawning.animals.spawn"); + PROPERTY_ALIASES.put("monsters", "spawning.monsters.spawn"); } /* * We have to use setCBWorld(), setPlugin() and initPerms() to prepare this object for use. @@ -447,7 +447,6 @@ public class MVWorld extends SerializationConfig implements MultiverseWorld { private boolean bedRespawn; @Property private List worldBlacklist; - @SuppressWarnings("unused") // it IS used! @Property(serializor = TimePropertySerializor.class, virtualType = Long.class, description = "Set the time to whatever you want! (Will NOT freeze time)") private VirtualProperty time = new VirtualProperty() { @@ -666,7 +665,7 @@ public class MVWorld extends SerializationConfig implements MultiverseWorld { * @see SerializationConfig */ protected static Map getAliases() { - return propertyAliases; + return PROPERTY_ALIASES; } private static double getDefaultScale(Environment environment) { diff --git a/src/main/java/com/onarandombox/MultiverseCore/MultiverseCore.java b/src/main/java/com/onarandombox/MultiverseCore/MultiverseCore.java index 4273ccf8..8180dcd0 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/MultiverseCore.java +++ b/src/main/java/com/onarandombox/MultiverseCore/MultiverseCore.java @@ -17,7 +17,6 @@ import com.onarandombox.MultiverseCore.api.MVPlugin; import com.onarandombox.MultiverseCore.api.MVWorldManager; import com.onarandombox.MultiverseCore.api.MultiverseCoreConfig; import com.onarandombox.MultiverseCore.api.MultiverseMessaging; -import com.onarandombox.MultiverseCore.api.MultiverseWorld; import com.onarandombox.MultiverseCore.api.SafeTTeleporter; import com.onarandombox.MultiverseCore.commands.AnchorCommand; import com.onarandombox.MultiverseCore.commands.CheckCommand; @@ -97,7 +96,6 @@ import java.util.HashMap; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; -import java.util.Random; import java.util.logging.Level; import java.util.logging.Logger; @@ -312,7 +310,7 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core { } /** - * Initializes the buscript javascript library + * Initializes the buscript javascript library. */ private void initializeBuscript() { buscript = new Buscript(this); @@ -435,11 +433,11 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core { /** * Migrate the worlds.yml to SerializationConfig. */ - private void migrateWorldConfig() { + private void migrateWorldConfig() { // SUPPRESS CHECKSTYLE: MethodLength FileConfiguration wconf = YamlConfiguration .loadConfiguration(new File(getDataFolder(), "worlds.yml")); - if (!wconf.isConfigurationSection("worlds")) {// empty config + if (!wconf.isConfigurationSection("worlds")) { // empty config this.log(Level.FINE, "No worlds to migrate!"); return; } diff --git a/src/main/java/com/onarandombox/MultiverseCore/api/MVWorldManager.java b/src/main/java/com/onarandombox/MultiverseCore/api/MVWorldManager.java index 9fbacbb5..597ee32b 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/api/MVWorldManager.java +++ b/src/main/java/com/onarandombox/MultiverseCore/api/MVWorldManager.java @@ -65,7 +65,6 @@ public interface MVWorldManager { * * @param oldName Name of world to be copied * @param newName Name of world to be created - * @param env Environment Type * @param generator The Custom generator plugin to use. * @return True if the world is copied successfully, false if not. */ diff --git a/src/main/java/com/onarandombox/MultiverseCore/commands/CloneCommand.java b/src/main/java/com/onarandombox/MultiverseCore/commands/CloneCommand.java index 325e77f8..9dce1d69 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/commands/CloneCommand.java +++ b/src/main/java/com/onarandombox/MultiverseCore/commands/CloneCommand.java @@ -35,7 +35,8 @@ public class CloneCommand extends MultiverseCommand { this.addCommandExample("/mv clone " + ChatColor.GOLD + "world" + ChatColor.GREEN + " world_backup"); this.addCommandExample("/mv clone " + ChatColor.GOLD + "skyblock_pristine" + ChatColor.GREEN + " skyblock"); this.addCommandExample("To clone a world that uses a generator:"); - this.addCommandExample("/mv clone " + ChatColor.GOLD + "CleanRoom" + ChatColor.GREEN + " CleanRoomCopy" + ChatColor.DARK_AQUA + " -g CleanRoomGenerator"); + this.addCommandExample("/mv clone " + ChatColor.GOLD + "CleanRoom" + + ChatColor.GREEN + " CleanRoomCopy" + ChatColor.DARK_AQUA + " -g CleanRoomGenerator"); this.setPermission("multiverse.core.clone", "Clones a world.", PermissionDefault.OP); this.worldManager = this.plugin.getMVWorldManager(); } diff --git a/src/main/java/com/onarandombox/MultiverseCore/commands/ScriptCommand.java b/src/main/java/com/onarandombox/MultiverseCore/commands/ScriptCommand.java index 65491ef4..2896a8e7 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/commands/ScriptCommand.java +++ b/src/main/java/com/onarandombox/MultiverseCore/commands/ScriptCommand.java @@ -8,8 +8,6 @@ package com.onarandombox.MultiverseCore.commands; import com.onarandombox.MultiverseCore.MultiverseCore; -import com.onarandombox.MultiverseCore.api.MVWorldManager; -import com.onarandombox.MultiverseCore.api.MultiverseWorld; import org.bukkit.ChatColor; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; diff --git a/src/main/java/com/onarandombox/MultiverseCore/listeners/MVPlayerListener.java b/src/main/java/com/onarandombox/MultiverseCore/listeners/MVPlayerListener.java index 3c41ae08..fdefa809 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/listeners/MVPlayerListener.java +++ b/src/main/java/com/onarandombox/MultiverseCore/listeners/MVPlayerListener.java @@ -22,7 +22,6 @@ import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; import org.bukkit.event.player.AsyncPlayerChatEvent; import org.bukkit.event.player.PlayerChangedWorldEvent; -import org.bukkit.event.player.PlayerChatEvent; import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerPortalEvent; import org.bukkit.event.player.PlayerQuitEvent; diff --git a/src/main/java/com/onarandombox/MultiverseCore/utils/FileUtils.java b/src/main/java/com/onarandombox/MultiverseCore/utils/FileUtils.java index f04e9745..161ff38e 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/utils/FileUtils.java +++ b/src/main/java/com/onarandombox/MultiverseCore/utils/FileUtils.java @@ -45,10 +45,15 @@ public class FileUtils { } } + private static final int COPY_BLOCK_SIZE = 1024; + /** - * Helper method to copy the world-folder + * Helper method to copy the world-folder. + * @param source Source-File + * @param target Target-File + * @param log A logger that logs the operation * - * @returns if it had success + * @return if it had success */ public static boolean copyFolder(File source, File target, Logger log) { InputStream in = null; @@ -64,26 +69,22 @@ public class FileUtils { for (String child : children) { copyFolder(new File(source, child), new File(target, child), log); } - } - else { + } else { in = new FileInputStream(source); out = new FileOutputStream(target); - byte[] buf = new byte[1024]; + byte[] buf = new byte[COPY_BLOCK_SIZE]; int len; while ((len = in.read(buf)) > 0) { out.write(buf, 0, len); } } return true; - } - catch (FileNotFoundException e) { + } catch (FileNotFoundException e) { log.warning("Exception while copying file: " + e.getMessage()); - } - catch (IOException e) { + } catch (IOException e) { log.warning("Exception while copying file: " + e.getMessage()); - } - finally { + } finally { if (in != null) { try { in.close(); diff --git a/src/main/java/com/onarandombox/MultiverseCore/utils/WorldManager.java b/src/main/java/com/onarandombox/MultiverseCore/utils/WorldManager.java index 75955c1a..317eaf44 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/utils/WorldManager.java +++ b/src/main/java/com/onarandombox/MultiverseCore/utils/WorldManager.java @@ -158,10 +158,10 @@ public class WorldManager implements MVWorldManager { try { // don't keep the alias the same -- that would be useless newWorld.setPropertyValue("alias", newName); - } catch (PropertyDoesNotExistException e) { - // this should never happen - throw new RuntimeException(e); - } + } catch (PropertyDoesNotExistException e) { + // this should never happen + throw new RuntimeException(e); + } return true; } }