Check out PlotWorld.java

This commit is contained in:
Sauilitired 2014-11-21 23:55:30 +01:00
parent 75a5a76fe9
commit 5885badc23
4 changed files with 84 additions and 42 deletions

View File

@ -110,11 +110,13 @@ public class PlotMain extends JavaPlugin {
/**
* All loaded plot worlds
*/
private final static HashMap<String, PlotWorld> worlds = new HashMap<>();
private final static HashMap<String, PlotWorld> worlds =
new HashMap<>();
/**
* All world managers
*/
private final static HashMap<String, PlotManager> managers = new HashMap<>();
private final static HashMap<String, PlotManager> 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<String, Object> 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<String, HashMap<PlotId, Plot>> plots) {
PlotMain.plots = new LinkedHashMap<>(plots);
// PlotMain.plots.putAll(plots);
public static void setAllPlotsRaw(final LinkedHashMap<String, HashMap<PlotId, Plot>> plots) {
PlotMain.plots = plots;
}
/**
* Set all plots
*
* @param plots New Plot LinkedHashMap
* @param plots New Plot HashMap
*/
public static void setAllPlotsRaw(final LinkedHashMap<String, HashMap<PlotId, Plot>> plots) {
PlotMain.plots = plots;
public static void setAllPlotsRaw(final HashMap<String, HashMap<PlotId, Plot>> 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);
}
}
/**

View File

@ -36,8 +36,6 @@ public enum Command {
// (Rating system) (ratings can be stored as the average, and number of
// ratings)
// - /plot rate <number out of 10>
// - /plot list <some parameter to list the most popular, and highest rated
// plots>
/**
*
*/

View File

@ -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();

View File

@ -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<Material> 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<Material> 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;