From 5885badc23fad408db354bf72356940cdf37ece4 Mon Sep 17 00:00:00 2001 From: Sauilitired Date: Fri, 21 Nov 2014 23:55:30 +0100 Subject: [PATCH] Check out PlotWorld.java --- .../intellectualcrafters/plot/PlotMain.java | 54 ++++++++------- .../plot/commands/Command.java | 2 - .../intellectualcrafters/plot/config/C.java | 4 -- .../plot/object/PlotWorld.java | 66 ++++++++++++++++--- 4 files changed, 84 insertions(+), 42 deletions(-) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotMain.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotMain.java index a04ff1298..552bdf16f 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotMain.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotMain.java @@ -110,11 +110,13 @@ public class PlotMain extends JavaPlugin { /** * All loaded plot worlds */ - private final static HashMap worlds = new HashMap<>(); + private final static HashMap worlds = + new HashMap<>(); /** * All world managers */ - private final static HashMap managers = new HashMap<>(); + private final static HashMap managers = + new HashMap<>(); /** * settings.properties */ @@ -962,7 +964,6 @@ public class PlotMain extends JavaPlugin { for (final ConfigurationNode setting : plotworld.getSettingNodes()) { options.put(setting.getConstant(), setting.getValue()); - //TODO: Make jesse explain wth was going on here } for (final Entry node : options.entrySet()) { @@ -1321,20 +1322,20 @@ public class PlotMain extends JavaPlugin { /** * Set all plots * - * @param plots New Plot HashMap + * @param plots New Plot LinkedHashMap */ - public static void setAllPlotsRaw(final HashMap> plots) { - PlotMain.plots = new LinkedHashMap<>(plots); - // PlotMain.plots.putAll(plots); + public static void setAllPlotsRaw(final LinkedHashMap> plots) { + PlotMain.plots = plots; } /** * Set all plots * - * @param plots New Plot LinkedHashMap + * @param plots New Plot HashMap */ - public static void setAllPlotsRaw(final LinkedHashMap> plots) { - PlotMain.plots = plots; + public static void setAllPlotsRaw(final HashMap> plots) { + PlotMain.plots = new LinkedHashMap<>(plots); + // PlotMain.plots.putAll(plots); } /** @@ -1377,26 +1378,22 @@ public class PlotMain extends JavaPlugin { @Override @SuppressWarnings("deprecation") final public void onEnable() { - // Pre-Steps - { - // Init the logger - setupLogger(); - - // Check for outdated java version. - if (getJavaVersion() < 1.7) { - sendConsoleSenderMessage(C.PREFIX.s() + "&cYour java version is outdated. Please update to at least 1.7."); - // Didn't know of any other link :D - sendConsoleSenderMessage(C.PREFIX.s() + "&cURL: &6https://java.com/en/download/index.jsp"); - Bukkit.getPluginManager().disablePlugin(this); - return; - } + // Setup the logger mechanics + setupLogger(); + // Check for outdated java version. + if (getJavaVersion() < 1.7) { + sendConsoleSenderMessage(C.PREFIX.s() + "&cYour java version is outdated. Please update to at least 1.7."); + // Didn't know of any other link :D + sendConsoleSenderMessage(C.PREFIX.s() + "&cURL: &6https://java.com/en/download/index.jsp"); + Bukkit.getPluginManager().disablePlugin(this); + return; + } else if (getJavaVersion() < 1.8) { + sendConsoleSenderMessage(C.PREFIX.s() + "&cIt's really recommended to run Java 1.8, as it increases performance"); } - // Setup configurations C.setupTranslations(); // Setup configuration configs(); - // Setup metrics if (Settings.METRICS) { try { @@ -1410,13 +1407,10 @@ public class PlotMain extends JavaPlugin { // We should at least make them feel bad. sendConsoleSenderMessage("Using metrics will allow us to improve the plugin\nPlease consider it :)"); } - // Kill mobs on roads? if (Settings.KILL_ROAD_MOBS) { killAllEntities(); } - - // Enabled<3 if (C.ENABLED.s().length() > 0) { Broadcast(C.ENABLED); } @@ -1602,6 +1596,10 @@ public class PlotMain extends JavaPlugin { // Looks really cool xD getUUIDSaver().globalPopulate(); } + // Now we're finished :D + if (C.ENABLED.s().length() > 0) { + Broadcast(C.ENABLED); + } } /** diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Command.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Command.java index dae1897d7..eda65bc73 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Command.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Command.java @@ -36,8 +36,6 @@ public enum Command { // (Rating system) (ratings can be stored as the average, and number of // ratings) // - /plot rate - // - /plot list /** * */ diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/C.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/C.java index b7ac340ba..7c75e32f9 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/C.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/C.java @@ -434,10 +434,6 @@ public enum C { if (manager == null) { manager = new TranslationManager(); } - - // FIXME: generating a blank file - // FIXME: translations aren't customizable - // FIXME: Some messages still have the %arg stuff in them if (defaultFile == null) { defaultFile = new YamlTranslationFile(BukkitTranslation.getParent(PlotMain.getPlugin(PlotMain.class)), lang, "PlotSquared", manager) .read(); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotWorld.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotWorld.java index 795abb3e6..44854fa71 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotWorld.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotWorld.java @@ -28,22 +28,14 @@ import org.bukkit.block.Biome; import org.bukkit.configuration.ConfigurationSection; import java.util.ArrayList; -import java.util.Arrays; import java.util.HashMap; import java.util.List; -import static org.bukkit.Material.*; - /** * @author Jesse Boyd */ public abstract class PlotWorld { - // TODO make this configurable - // make non static and static_default_valu + add config option - @SuppressWarnings("deprecation") - public final static ArrayList BLOCKS = new ArrayList<>(Arrays.asList(new Material[]{ACACIA_STAIRS, BEACON, BEDROCK, BIRCH_WOOD_STAIRS, BOOKSHELF, BREWING_STAND, BRICK, BRICK_STAIRS, BURNING_FURNACE, CAKE_BLOCK, CAULDRON, CLAY_BRICK, CLAY, COAL_BLOCK, COAL_ORE, COBBLE_WALL, COBBLESTONE, COBBLESTONE_STAIRS, COMMAND, DARK_OAK_STAIRS, DAYLIGHT_DETECTOR, DIAMOND_ORE, DIAMOND_BLOCK, DIRT, DISPENSER, DROPPER, EMERALD_BLOCK, EMERALD_ORE, ENCHANTMENT_TABLE, ENDER_PORTAL_FRAME, ENDER_STONE, FURNACE, GLOWSTONE, GOLD_ORE, GOLD_BLOCK, GRASS, GRAVEL, GLASS, HARD_CLAY, HAY_BLOCK, HUGE_MUSHROOM_1, HUGE_MUSHROOM_2, IRON_BLOCK, IRON_ORE, JACK_O_LANTERN, JUKEBOX, JUNGLE_WOOD_STAIRS, LAPIS_BLOCK, LAPIS_ORE, LEAVES, LEAVES_2, LOG, LOG_2, MELON_BLOCK, MOB_SPAWNER, MOSSY_COBBLESTONE, MYCEL, NETHER_BRICK, NETHER_BRICK_STAIRS, NETHERRACK, NOTE_BLOCK, OBSIDIAN, PACKED_ICE, PUMPKIN, QUARTZ_BLOCK, QUARTZ_ORE, QUARTZ_STAIRS, REDSTONE_BLOCK, SANDSTONE, SAND, - SANDSTONE_STAIRS, SMOOTH_BRICK, SMOOTH_STAIRS, SNOW_BLOCK, SOUL_SAND, SPONGE, SPRUCE_WOOD_STAIRS, STONE, WOOD, WOOD_STAIRS, WORKBENCH, WOOL, getMaterial(44), getMaterial(126)})); public final static boolean AUTO_MERGE_DEFAULT = false; public final static boolean MOB_SPAWNING_DEFAULT = false; public final static Biome PLOT_BIOME_DEFAULT = Biome.FOREST; @@ -62,6 +54,64 @@ public abstract class PlotWorld { public final static boolean SPAWN_EGGS_DEFAULT = false; public final static boolean SPAWN_CUSTOM_DEFAULT = true; public final static boolean SPAWN_BREEDING_DEFAULT = false; + // TODO make this configurable + // make non static and static_default_valu + add config option + @SuppressWarnings("deprecation") + public static List BLOCKS; /*= new ArrayList<>( + Arrays.asList( + new Material[]{ + ACACIA_STAIRS, BEACON, + BEDROCK, BIRCH_WOOD_STAIRS, + BOOKSHELF, BREWING_STAND, + BRICK, BRICK_STAIRS, + BURNING_FURNACE, CAKE_BLOCK, + CAULDRON, CLAY_BRICK, + CLAY, COAL_BLOCK, + COAL_ORE, COBBLE_WALL, + COBBLESTONE, COBBLESTONE_STAIRS, + COMMAND, DARK_OAK_STAIRS, + DAYLIGHT_DETECTOR, DIAMOND_ORE, + DIAMOND_BLOCK, DIRT, + DISPENSER, DROPPER, + EMERALD_BLOCK, EMERALD_ORE, + ENCHANTMENT_TABLE, ENDER_PORTAL_FRAME, + ENDER_STONE, FURNACE, + GLOWSTONE, GOLD_ORE, + GOLD_BLOCK, GRASS, GRAVEL, GLASS, + HARD_CLAY, HAY_BLOCK, + HUGE_MUSHROOM_1, HUGE_MUSHROOM_2, + IRON_BLOCK, IRON_ORE, + JACK_O_LANTERN, JUKEBOX, + JUNGLE_WOOD_STAIRS, LAPIS_BLOCK, + LAPIS_ORE, LEAVES, + LEAVES_2, LOG, LOG_2, + MELON_BLOCK, MOB_SPAWNER, + MOSSY_COBBLESTONE, MYCEL, + NETHER_BRICK, NETHER_BRICK_STAIRS, + NETHERRACK, NOTE_BLOCK, + OBSIDIAN, PACKED_ICE, + PUMPKIN, QUARTZ_BLOCK, + QUARTZ_ORE, QUARTZ_STAIRS, + REDSTONE_BLOCK, SANDSTONE, + SAND, SANDSTONE_STAIRS, + SMOOTH_BRICK, SMOOTH_STAIRS, + SNOW_BLOCK, SOUL_SAND, + SPONGE, SPRUCE_WOOD_STAIRS, + STONE, WOOD, + WOOD_STAIRS, WORKBENCH, + WOOL, getMaterial(44), getMaterial(126) + } + ) + );*/ + + static { + // TODO: Let jesse decide if this is stupid or not + BLOCKS = new ArrayList<>(); + for (Material material : Material.values()) { + if (material.isBlock() && material.isSolid()) + BLOCKS.add(material); + } + } public final String worldname; public boolean AUTO_MERGE; public boolean MOB_SPAWNING;