From ff05ef840bd43ea5a853424c5e65d3e741d1fd19 Mon Sep 17 00:00:00 2001 From: Sauilitired Date: Thu, 2 Oct 2014 17:00:34 +0200 Subject: [PATCH] Fixed some items on the to-do list. --- .idea/workspace.xml | 485 +++++++++++------- .../intellectualcrafters/plot/PlotHelper.java | 40 +- .../intellectualcrafters/plot/PlotMain.java | 5 - .../intellectualcrafters/plot/Settings.java | 2 +- .../plot/commands/Auto.java | 1 + .../plot/commands/Debug.java | 14 +- .../plot/commands/Info.java | 19 +- .../plot/database/DBFunc.java | 2 +- .../plot/database/PlotMeConverter.java | 29 +- 9 files changed, 371 insertions(+), 226 deletions(-) diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 16c2c68fe..787ba6c62 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -5,7 +5,7 @@ - + @@ -14,7 +14,13 @@ - + + + + + + + @@ -38,28 +44,42 @@ - - + + - - + + - - + + - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + @@ -67,49 +87,36 @@ - - + + - - + + - - - + + + + + - - + + - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + @@ -117,28 +124,68 @@ - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + - - - - - - - - - - - - + + @@ -172,15 +219,20 @@ @@ -454,12 +506,28 @@ - + + + + + + + + + + + + + + + + + @@ -614,7 +682,10 @@ - + + + + 1411382351159 @@ -680,15 +751,43 @@ 1411491737240 1411491737240 - - + + + + + + + + + + + + + + + + + + + - + @@ -701,8 +800,8 @@ - - + + @@ -713,7 +812,7 @@ - + @@ -746,7 +845,9 @@ - @@ -758,50 +859,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -838,14 +895,14 @@ + + + - - - @@ -908,7 +965,6 @@ - @@ -916,7 +972,6 @@ - @@ -970,19 +1025,10 @@ - - - - - - - - - @@ -997,7 +1043,6 @@ - @@ -1022,18 +1067,10 @@ - - - - - - - - @@ -1041,7 +1078,6 @@ - @@ -1056,7 +1092,6 @@ - @@ -1064,15 +1099,6 @@ - - - - - - - - - @@ -1080,7 +1106,6 @@ - @@ -1088,7 +1113,6 @@ - @@ -1116,14 +1140,6 @@ - - - - - - - - @@ -1132,17 +1148,138 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - + + + + + + + + + + + + + + + + + + + diff --git a/PlotSquared/src/com/intellectualcrafters/plot/PlotHelper.java b/PlotSquared/src/com/intellectualcrafters/plot/PlotHelper.java index f64b6acb0..a901f29af 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/PlotHelper.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/PlotHelper.java @@ -9,19 +9,17 @@ package com.intellectualcrafters.plot; -import com.google.common.collect.SetMultimap; import com.intellectualcrafters.plot.database.DBFunc; -import com.sk89q.worldedit.blocks.ClothColor.ID; - import org.bukkit.*; import org.bukkit.block.Biome; import org.bukkit.block.Block; import org.bukkit.block.BlockState; import org.bukkit.block.Sign; import org.bukkit.entity.Entity; +import org.bukkit.entity.EntityType; import org.bukkit.entity.Player; -import org.bukkit.material.MaterialData; +import java.io.File; import java.util.*; /** @@ -442,10 +440,10 @@ public class PlotHelper { return x; } - public static double getWorldFolderSize() { - // long size = - // FileUtils.sizeOfDirectory(Bukkit.getWorld(Settings.PLOT_WORLD).getWorldFolder()); - long size = 10; + public static double getWorldFolderSize(World world) { + //long size = FileUtil.sizeOfDirectory(world.getWorldFolder()); + File folder = world.getWorldFolder(); + long size = folder.length(); return (((size) / 1024) / 1024); } @@ -727,7 +725,23 @@ public class PlotHelper { } return new short[] { Short.parseShort(block), 0 }; } - + + public static void teleportPlayers(World world, Plot plot, boolean tile) { + final Location pos1 = getPlotBottomLoc(world, plot.id).add(1, 0, 1); + final Location pos2 = getPlotTopLoc(world, plot.id); + for (int i = (pos2.getBlockX() / 16) * 16; i < 16 + (pos2. getBlockX() / 16) * 16; i= 16) { + for (int j = (pos1. getBlockZ() / 16) * 16; j < 16 + (pos2.getBlockZ() / 16) * 16; j += 16) { + Chunk chunk = world.getChunkAt(i, j); + for (Entity entity : chunk.getEntities()) { + PlotId id = PlayerFunctions.getPlot(entity.getLocation()); + if(id != null && id.equals(plot.id) && entity.getType() == EntityType.PLAYER) { + entity.teleport(world.getSpawnLocation()); + // Should this teleport them to floor instead? + } + } + } + } + } public static void clearAllEntities(World world, Plot plot, boolean tile) { final Location pos1 = getPlotBottomLoc(world, plot.id).add(1, 0, 1); final Location pos2 = getPlotTopLoc(world, plot.id); @@ -755,15 +769,15 @@ public class PlotHelper { * @param plot */ public static void clear(final Player requester, final Plot plot) { - - // TODO teleport any players underground to the surface - + final long start = System.nanoTime(); final World world = requester.getWorld(); // clear entities: clearAllEntities(world, plot, false); - + //teleport players + teleportPlayers(world, plot, false); + final PlotWorld plotworld = PlotMain.getWorldSettings(world); PlotHelper.setBiome(requester.getWorld(), plot, Biome.FOREST); PlayerFunctions.sendMessage(requester, C.CLEARING_PLOT); diff --git a/PlotSquared/src/com/intellectualcrafters/plot/PlotMain.java b/PlotSquared/src/com/intellectualcrafters/plot/PlotMain.java index b77766482..0af961899 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/PlotMain.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/PlotMain.java @@ -110,10 +110,6 @@ public class PlotMain extends JavaPlugin { return new WorldGenerator(worldname); } - /** - * TODO: Implement better system - * - */ @SuppressWarnings("deprecation") public static void checkForExpiredPlots() { final JavaPlugin plugin = PlotMain.getMain(); @@ -488,7 +484,6 @@ public class PlotMain extends JavaPlugin { } } - // TODO make this configurable PlotWorld.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) })); if (Settings.KILL_ROAD_MOBS) { diff --git a/PlotSquared/src/com/intellectualcrafters/plot/Settings.java b/PlotSquared/src/com/intellectualcrafters/plot/Settings.java index 3154476ac..c7d9e1304 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/Settings.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/Settings.java @@ -81,7 +81,7 @@ public class Settings { * */ public static class DB { - public static boolean USE_MONGO = false; /* TODO: Implement Mongo */; + public static boolean USE_MONGO = false; /* TODO: Implement Mongo @Brandon */; public static boolean USE_SQLITE = false; public static boolean USE_MYSQL = true; /* NOTE: Fixed connector */ public static String SQLITE_DB = "storage"; diff --git a/PlotSquared/src/com/intellectualcrafters/plot/commands/Auto.java b/PlotSquared/src/com/intellectualcrafters/plot/commands/Auto.java index eb3d9adad..96a75ce9e 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/commands/Auto.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/commands/Auto.java @@ -93,6 +93,7 @@ public class Auto extends SubCommand { PlotId end = new PlotId(x+size_x-1, z+size_z-1); if (isUnowned(world, start, end)) { // TODO claim event + // Claim.claimPlot calls that event... for (int i = start.x; i <= end.x; i++) { for (int j = start.y; j <= end.y; j++) { Plot plot = PlotHelper.getPlot(world, new PlotId(i,j)); diff --git a/PlotSquared/src/com/intellectualcrafters/plot/commands/Debug.java b/PlotSquared/src/com/intellectualcrafters/plot/commands/Debug.java index ea0bcb94e..b63a518f3 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/commands/Debug.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/commands/Debug.java @@ -9,15 +9,10 @@ package com.intellectualcrafters.plot.commands; +import com.intellectualcrafters.plot.*; +import org.bukkit.Bukkit; import org.bukkit.entity.Player; -import com.intellectualcrafters.plot.C; -import com.intellectualcrafters.plot.Lag; -import com.intellectualcrafters.plot.PlayerFunctions; -import com.intellectualcrafters.plot.PlotHelper; -import com.intellectualcrafters.plot.PlotMain; -import com.intellectualcrafters.plot.RUtils; - /** * @author Citymonstret \\SuperCharged Compiler made by Citymonstret\\ * ||#Compiler:ALPHA-1.0######################### @@ -85,7 +80,10 @@ public class Debug extends SubCommand { information.append(getSection(section, "PlotWorld")); information.append(getLine(line, "Plot Worlds", worlds)); information.append(getLine(line, "Owned Plots", PlotMain.getPlots().size())); - information.append(getLine(line, "PlotWorld Size", PlotHelper.getWorldFolderSize() + "MB")); + //information.append(getLine(line, "PlotWorld Size", PlotHelper.getWorldFolderSize() + "MB")); + for(String world : PlotMain.getPlotWorlds()) { + information.append(getLine(line, "World: " + world + " size", PlotHelper.getWorldFolderSize(Bukkit.getWorld(world)))); + } information.append(getLine(line, "Entities", PlotHelper.getEntities(plr.getWorld()))); information.append(getLine(line, "Loaded Tile Entities", PlotHelper.getTileEntities(plr.getWorld()))); information.append(getLine(line, "Loaded Chunks", PlotHelper.getLoadedChunks(plr.getWorld()))); diff --git a/PlotSquared/src/com/intellectualcrafters/plot/commands/Info.java b/PlotSquared/src/com/intellectualcrafters/plot/commands/Info.java index 061b03741..1e5cf9ee5 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/commands/Info.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/commands/Info.java @@ -9,9 +9,11 @@ package com.intellectualcrafters.plot.commands; -import java.util.ArrayList; -import java.util.UUID; - +import com.intellectualcrafters.plot.C; +import com.intellectualcrafters.plot.PlayerFunctions; +import com.intellectualcrafters.plot.Plot; +import com.intellectualcrafters.plot.PlotHelper; +import com.intellectualcrafters.plot.database.DBFunc; import org.apache.commons.lang.StringUtils; import org.bukkit.Bukkit; import org.bukkit.Location; @@ -20,11 +22,8 @@ import org.bukkit.World; import org.bukkit.block.Biome; import org.bukkit.entity.Player; -import com.intellectualcrafters.plot.C; -import com.intellectualcrafters.plot.PlayerFunctions; -import com.intellectualcrafters.plot.Plot; -import com.intellectualcrafters.plot.PlotHelper; -import com.intellectualcrafters.plot.database.DBFunc; +import java.util.ArrayList; +import java.util.UUID; /** * @@ -92,8 +91,8 @@ public class Info extends SubCommand { info = info.replaceAll("%trusted%", getPlayerList(plot.trusted)); info = info.replaceAll("%denied%", getPlayerList(plot.denied)); info = info.replaceAll("%flags%", StringUtils.join(plot.settings.getFlags(), "").length() > 0 ? StringUtils.join(plot.settings.getFlags(), ",") : "none"); - PlayerFunctions.sendMessage(player, PlayerFunctions.getTopPlot(player.getWorld(), plot).id.toString()); - PlayerFunctions.sendMessage(player, PlayerFunctions.getBottomPlot(player.getWorld(), plot).id.toString()); + //PlayerFunctions.sendMessage(player, PlayerFunctions.getTopPlot(player.getWorld(), plot).id.toString()); + //PlayerFunctions.sendMessage(player, PlayerFunctions.getBottomPlot(player.getWorld(), plot).id.toString()); PlayerFunctions.sendMessage(player, info); return true; } diff --git a/PlotSquared/src/com/intellectualcrafters/plot/database/DBFunc.java b/PlotSquared/src/com/intellectualcrafters/plot/database/DBFunc.java index 7564b912f..1ecf08f61 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/database/DBFunc.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/database/DBFunc.java @@ -39,7 +39,7 @@ import com.intellectualcrafters.plot.PlotMain; */ public class DBFunc { - // TODO MongoDB + // TODO MongoDB @Brandon /** * Set Plot owner diff --git a/PlotSquared/src/com/intellectualcrafters/plot/database/PlotMeConverter.java b/PlotSquared/src/com/intellectualcrafters/plot/database/PlotMeConverter.java index f60311bca..43b56210b 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/database/PlotMeConverter.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/database/PlotMeConverter.java @@ -1,5 +1,14 @@ package com.intellectualcrafters.plot.database; +import com.intellectualcrafters.plot.PlotHomePosition; +import com.intellectualcrafters.plot.PlotId; +import com.intellectualcrafters.plot.PlotMain; +import com.worldcretornica.plotme.PlayerList; +import com.worldcretornica.plotme.Plot; +import com.worldcretornica.plotme.PlotManager; +import org.bukkit.Bukkit; +import org.bukkit.World; + import java.io.PrintStream; import java.lang.reflect.Field; import java.util.ArrayList; @@ -7,19 +16,6 @@ import java.util.HashMap; import java.util.Map; import java.util.UUID; -import org.bukkit.Bukkit; -import org.bukkit.World; - -import com.intellectualcrafters.plot.PlotHomePosition; -import com.intellectualcrafters.plot.PlotId; -import com.intellectualcrafters.plot.PlotMain; -import com.intellectualcrafters.plot.api.PlotAPI; -import com.sun.org.apache.xerces.internal.impl.dv.DVFactoryException; -import com.worldcretornica.plotme.PlayerList; -import com.worldcretornica.plotme.Plot; -import com.worldcretornica.plotme.PlotManager; -import com.worldcretornica.plotme.PlotMe; - /** * Created by Citymonstret on 2014-08-17. */ @@ -32,6 +28,10 @@ public class PlotMeConverter { } public void runAsync() throws Exception { + + /* TODO Fix this... */ + boolean offlineMode = Bukkit.getOnlineMode(); + final PrintStream stream = new PrintStream("converter_log.txt"); PlotMain.sendConsoleSenderMessage("PlotMe->PlotSquared Conversion has started"); @@ -174,7 +174,8 @@ public class PlotMeConverter { // TODO disable PlotMe -> Unload all plot worlds, change the generator, restart the server automatically // Possibly use multiverse / multiworld if it's to difficult modifying a world's generator while the server is running - + // Should really do that? Would seem pretty bad from our side + bukkit wouldn't approve + Bukkit.getPluginManager().disablePlugin(PlotMeConverter.this.plugin); } });