diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitChunkManager.java b/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitChunkManager.java index 932024a87..4a1deba72 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitChunkManager.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitChunkManager.java @@ -2,63 +2,19 @@ package com.plotsquared.bukkit.util; import com.intellectualcrafters.plot.PS; import com.intellectualcrafters.plot.generator.AugmentedUtils; -import com.intellectualcrafters.plot.object.BlockLoc; -import com.intellectualcrafters.plot.object.ChunkLoc; +import com.intellectualcrafters.plot.object.*; import com.intellectualcrafters.plot.object.Location; -import com.intellectualcrafters.plot.object.Plot; -import com.intellectualcrafters.plot.object.PlotArea; -import com.intellectualcrafters.plot.object.PlotBlock; -import com.intellectualcrafters.plot.object.PlotLoc; -import com.intellectualcrafters.plot.object.PlotPlayer; -import com.intellectualcrafters.plot.object.RegionWrapper; -import com.intellectualcrafters.plot.object.RunnableVal; -import com.intellectualcrafters.plot.util.ChunkManager; -import com.intellectualcrafters.plot.util.PlotChunk; -import com.intellectualcrafters.plot.util.SetQueue; -import com.intellectualcrafters.plot.util.TaskManager; -import com.intellectualcrafters.plot.util.UUIDHandler; -import com.intellectualcrafters.plot.util.WorldUtil; +import com.intellectualcrafters.plot.util.*; import com.plotsquared.bukkit.object.entity.EntityWrapper; -import org.bukkit.Bukkit; -import org.bukkit.Chunk; -import org.bukkit.DyeColor; -import org.bukkit.Material; -import org.bukkit.Note; -import org.bukkit.SkullType; -import org.bukkit.World; -import org.bukkit.block.Banner; -import org.bukkit.block.Beacon; -import org.bukkit.block.Block; -import org.bukkit.block.BlockFace; -import org.bukkit.block.BlockState; -import org.bukkit.block.BrewingStand; -import org.bukkit.block.Chest; -import org.bukkit.block.CommandBlock; -import org.bukkit.block.CreatureSpawner; -import org.bukkit.block.Dispenser; -import org.bukkit.block.Dropper; -import org.bukkit.block.Furnace; -import org.bukkit.block.Hopper; -import org.bukkit.block.Jukebox; -import org.bukkit.block.NoteBlock; -import org.bukkit.block.Sign; -import org.bukkit.block.Skull; +import org.bukkit.*; +import org.bukkit.block.*; import org.bukkit.block.banner.Pattern; -import org.bukkit.entity.Animals; -import org.bukkit.entity.Creature; -import org.bukkit.entity.Entity; -import org.bukkit.entity.EntityType; -import org.bukkit.entity.Player; +import org.bukkit.entity.*; import org.bukkit.inventory.InventoryHolder; import org.bukkit.inventory.ItemStack; -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; +import java.util.*; import java.util.Map.Entry; -import java.util.Set; public class BukkitChunkManager extends ChunkManager { @@ -665,7 +621,7 @@ public class BukkitChunkManager extends ChunkManager { for (Entry entry : UUIDHandler.getPlayers().entrySet()) { PlotPlayer pp = entry.getValue(); Location pLoc = pp.getLocation(); - if (!pLoc.getChunkLoc().equals(loc)) { + if (!StringMan.isEqual(world, pLoc.getWorld()) || !pLoc.getChunkLoc().equals(loc)) { continue; } pLoc.setY(WorldUtil.IMP.getHighestBlock(world, pLoc.getX(), pLoc.getZ())); diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitSchematicHandler.java b/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitSchematicHandler.java index eaa63d6a7..76a08dd65 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitSchematicHandler.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitSchematicHandler.java @@ -20,27 +20,7 @@ //////////////////////////////////////////////////////////////////////////////////////////////////// package com.plotsquared.bukkit.util; -import java.util.ArrayDeque; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Set; - -import org.bukkit.Bukkit; -import org.bukkit.Chunk; -import org.bukkit.World; -import org.bukkit.block.Block; -import org.bukkit.block.BlockState; - -import com.intellectualcrafters.jnbt.ByteArrayTag; -import com.intellectualcrafters.jnbt.CompoundTag; -import com.intellectualcrafters.jnbt.IntTag; -import com.intellectualcrafters.jnbt.ListTag; -import com.intellectualcrafters.jnbt.ShortTag; -import com.intellectualcrafters.jnbt.StringTag; -import com.intellectualcrafters.jnbt.Tag; +import com.intellectualcrafters.jnbt.*; import com.intellectualcrafters.plot.object.ChunkLoc; import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.RegionWrapper; @@ -49,6 +29,14 @@ import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.SchematicHandler; import com.intellectualcrafters.plot.util.TaskManager; import com.plotsquared.bukkit.object.schematic.StateWrapper; +import org.bukkit.Bukkit; +import org.bukkit.Chunk; +import org.bukkit.World; +import org.bukkit.block.Block; +import org.bukkit.block.BlockState; + +import java.util.*; +import java.util.Map.Entry; /** * Schematic Handler diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/util/SendChunk.java b/Bukkit/src/main/java/com/plotsquared/bukkit/util/SendChunk.java index 89abaf630..780fabeb8 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/util/SendChunk.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/util/SendChunk.java @@ -125,7 +125,7 @@ public class SendChunk { } } - public void sendChunk(final String worldname, final List locs) { + public void sendChunk(final String worldname, final Collection locs) { final World myworld = Bukkit.getWorld(worldname); final ArrayList chunks = new ArrayList<>(); for (final ChunkLoc loc : locs) { diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/util/block/FastQueue_1_7.java b/Bukkit/src/main/java/com/plotsquared/bukkit/util/block/FastQueue_1_7.java index 1fa2b00c0..fc2fb1614 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/util/block/FastQueue_1_7.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/util/block/FastQueue_1_7.java @@ -1,7 +1,5 @@ package com.plotsquared.bukkit.util.block; -import static com.intellectualcrafters.plot.util.ReflectionUtils.getRefClass; - import com.intellectualcrafters.plot.object.ChunkLoc; import com.intellectualcrafters.plot.object.PlotBlock; import com.intellectualcrafters.plot.util.MainUtil; @@ -23,6 +21,8 @@ import java.util.HashMap; import java.util.Iterator; import java.util.Map.Entry; +import static com.intellectualcrafters.plot.util.ReflectionUtils.getRefClass; + public class FastQueue_1_7 extends SlowQueue { private final RefClass classBlock = getRefClass("{nms}.Block"); @@ -173,9 +173,8 @@ public class FastQueue_1_7 extends SlowQueue { World worldObj = BukkitUtil.getWorld(world); for (ChunkLoc loc : locs) { ChunkWrapper wrapper = SetQueue.IMP.new ChunkWrapper(world, loc.x, loc.z); - if (!toUpdate.containsKey(wrapper)) { - toUpdate.put(wrapper, worldObj.getChunkAt(loc.x, loc.z)); - } + toUpdate.remove(wrapper); } + chunksender.sendChunk(world, locs); } } diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/util/block/FastQueue_1_8.java b/Bukkit/src/main/java/com/plotsquared/bukkit/util/block/FastQueue_1_8.java index 79e4e6dce..906745bcd 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/util/block/FastQueue_1_8.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/util/block/FastQueue_1_8.java @@ -1,7 +1,5 @@ package com.plotsquared.bukkit.util.block; -import static com.intellectualcrafters.plot.util.ReflectionUtils.getRefClass; - import com.intellectualcrafters.plot.object.ChunkLoc; import com.intellectualcrafters.plot.object.PlotBlock; import com.intellectualcrafters.plot.util.MainUtil; @@ -25,6 +23,8 @@ import java.util.HashMap; import java.util.Iterator; import java.util.Map.Entry; +import static com.intellectualcrafters.plot.util.ReflectionUtils.getRefClass; + public class FastQueue_1_8 extends SlowQueue { private final RefMethod methodInitLighting; @@ -376,9 +376,8 @@ public class FastQueue_1_8 extends SlowQueue { World worldObj = BukkitUtil.getWorld(world); for (ChunkLoc loc : locs) { ChunkWrapper wrapper = SetQueue.IMP.new ChunkWrapper(world, loc.x, loc.z); - if (!toUpdate.containsKey(wrapper)) { - toUpdate.put(wrapper, worldObj.getChunkAt(loc.x, loc.z)); - } + toUpdate.remove(wrapper); } + chunksender.sendChunk(world, locs); } } diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/util/block/FastQueue_1_8_3.java b/Bukkit/src/main/java/com/plotsquared/bukkit/util/block/FastQueue_1_8_3.java index 1003d9d4c..90e006849 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/util/block/FastQueue_1_8_3.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/util/block/FastQueue_1_8_3.java @@ -1,20 +1,14 @@ package com.plotsquared.bukkit.util.block; -import static com.intellectualcrafters.plot.util.ReflectionUtils.getRefClass; - import com.intellectualcrafters.plot.object.ChunkLoc; import com.intellectualcrafters.plot.object.PseudoRandom; -import com.intellectualcrafters.plot.util.ChunkManager; -import com.intellectualcrafters.plot.util.MainUtil; -import com.intellectualcrafters.plot.util.PlotChunk; +import com.intellectualcrafters.plot.util.*; import com.intellectualcrafters.plot.util.ReflectionUtils.RefClass; import com.intellectualcrafters.plot.util.ReflectionUtils.RefConstructor; import com.intellectualcrafters.plot.util.ReflectionUtils.RefField; import com.intellectualcrafters.plot.util.ReflectionUtils.RefMethod; import com.intellectualcrafters.plot.util.ReflectionUtils.RefMethod.RefExecutor; -import com.intellectualcrafters.plot.util.SetQueue; import com.intellectualcrafters.plot.util.SetQueue.ChunkWrapper; -import com.intellectualcrafters.plot.util.TaskManager; import com.plotsquared.bukkit.util.BukkitUtil; import com.plotsquared.bukkit.util.SendChunk; import org.bukkit.Chunk; @@ -26,13 +20,10 @@ import org.bukkit.block.Biome; import java.lang.reflect.Field; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; +import java.util.*; import java.util.Map.Entry; -import java.util.Set; + +import static com.intellectualcrafters.plot.util.ReflectionUtils.getRefClass; public class FastQueue_1_8_3 extends SlowQueue { @@ -407,9 +398,8 @@ public class FastQueue_1_8_3 extends SlowQueue { World worldObj = BukkitUtil.getWorld(world); for (ChunkLoc loc : locs) { ChunkWrapper wrapper = SetQueue.IMP.new ChunkWrapper(world, loc.x, loc.z); - if (!toUpdate.containsKey(wrapper)) { - toUpdate.put(wrapper, worldObj.getChunkAt(loc.x, loc.z)); - } + toUpdate.remove(wrapper); } + chunksender.sendChunk(world, locs); } } diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/util/block/FastQueue_1_9.java b/Bukkit/src/main/java/com/plotsquared/bukkit/util/block/FastQueue_1_9.java index ec19fece4..3834797a6 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/util/block/FastQueue_1_9.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/util/block/FastQueue_1_9.java @@ -1,20 +1,14 @@ package com.plotsquared.bukkit.util.block; -import static com.intellectualcrafters.plot.util.ReflectionUtils.getRefClass; - import com.intellectualcrafters.plot.object.ChunkLoc; import com.intellectualcrafters.plot.object.PseudoRandom; -import com.intellectualcrafters.plot.util.ChunkManager; -import com.intellectualcrafters.plot.util.MainUtil; -import com.intellectualcrafters.plot.util.PlotChunk; +import com.intellectualcrafters.plot.util.*; import com.intellectualcrafters.plot.util.ReflectionUtils.RefClass; import com.intellectualcrafters.plot.util.ReflectionUtils.RefConstructor; import com.intellectualcrafters.plot.util.ReflectionUtils.RefField; import com.intellectualcrafters.plot.util.ReflectionUtils.RefMethod; import com.intellectualcrafters.plot.util.ReflectionUtils.RefMethod.RefExecutor; -import com.intellectualcrafters.plot.util.SetQueue; import com.intellectualcrafters.plot.util.SetQueue.ChunkWrapper; -import com.intellectualcrafters.plot.util.TaskManager; import com.plotsquared.bukkit.util.BukkitUtil; import com.plotsquared.bukkit.util.SendChunk; import org.bukkit.Chunk; @@ -26,13 +20,10 @@ import org.bukkit.block.Biome; import java.lang.reflect.Field; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; +import java.util.*; import java.util.Map.Entry; -import java.util.Set; + +import static com.intellectualcrafters.plot.util.ReflectionUtils.getRefClass; public class FastQueue_1_9 extends SlowQueue { @@ -456,13 +447,17 @@ public class FastQueue_1_9 extends SlowQueue { * @param locs */ @Override - public void sendChunk(String world, Collection locs) { + public void sendChunk(final String world, final Collection locs) { World worldObj = BukkitUtil.getWorld(world); for (ChunkLoc loc : locs) { ChunkWrapper wrapper = SetQueue.IMP.new ChunkWrapper(world, loc.x, loc.z); - if (!toUpdate.containsKey(wrapper)) { - toUpdate.put(wrapper, worldObj.getChunkAt(loc.x, loc.z)); - } + toUpdate.remove(wrapper); } + TaskManager.runTaskLater(new Runnable() { + @Override + public void run() { + chunksender.sendChunk(world, locs); + } + }, 1); } } diff --git a/Core/src/main/java/com/intellectualcrafters/plot/PS.java b/Core/src/main/java/com/intellectualcrafters/plot/PS.java index 869d19b8d..0c51aaacb 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/PS.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/PS.java @@ -356,16 +356,6 @@ public class PS { return database; } - /** - * Update the global reference - * to a plot object - * - * @param plot Plot Object to update - */ - public boolean updatePlot(final Plot plot) { - return plot.getArea().addPlot(plot); - } - /** * Get the relevant plot area for a location.
* - If there is only one plot area globally that will be returned
@@ -705,12 +695,14 @@ public class PS { public void run(PlotArea value) { for (final PlotFilter filter : filters) { if (!filter.allowsArea(value)) { + continue; } } for (Entry entry2 : value.getPlotEntries()) { Plot plot = entry2.getValue(); for (final PlotFilter filter : filters) { if (!filter.allowsPlot(plot)) { + continue; } } set.add(plot); @@ -771,7 +763,7 @@ public class PS { @Override public void run(PlotArea value) { for (Plot plot : value.getPlots()) { - if (plot.getMerged(0) || plot.getMerged(3)) { + if (!plot.isBasePlot()) { continue; } result.add(plot); diff --git a/Core/src/main/java/com/intellectualcrafters/plot/commands/Auto.java b/Core/src/main/java/com/intellectualcrafters/plot/commands/Auto.java index 106640c2b..e723c08bd 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/commands/Auto.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/commands/Auto.java @@ -171,7 +171,7 @@ public class Auto extends SubCommand { final PlotId currentId = new PlotId(origin.x + id.x, origin.y + id.y); Plot current = plotarea.getPlotAbs(currentId); if (current.canClaim(plr)) { - Claim.claimPlot(plr, current, true, true); + current.claim(plr, true, null); return true; } id = getNextPlotId(id, 1); @@ -185,7 +185,7 @@ public class Auto extends SubCommand { while (!br) { Plot plot = plotarea.getPlotAbs(getLastPlotId(plotarea)); if (plot.canClaim(plr)) { - Claim.claimPlot(plr, plot, true, true); + plot.claim(plr, true, null); br = true; } plotarea.setMeta("lastPlot", getNextPlotId(plot.getId(), 1)); @@ -200,7 +200,7 @@ public class Auto extends SubCommand { for (int j = start.y; j <= end.y; j++) { Plot plot = plotarea.getPlotAbs(new PlotId(i, j)); final boolean teleport = ((i == end.x) && (j == end.y)); - Claim.claimPlot(plr, plot, teleport, true); + plot.claim(plr, teleport, null); } } if (!plotarea.mergePlots(MainUtil.getPlotSelectionIds(start, end), Settings.MERGE_REMOVES_ROADS, true)) { diff --git a/Core/src/main/java/com/intellectualcrafters/plot/commands/Claim.java b/Core/src/main/java/com/intellectualcrafters/plot/commands/Claim.java index 33b881030..0dff579b2 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/commands/Claim.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/commands/Claim.java @@ -22,9 +22,13 @@ package com.intellectualcrafters.plot.commands; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.config.Settings; -import com.intellectualcrafters.plot.object.*; -import com.intellectualcrafters.plot.util.*; -import com.intellectualcrafters.plot.util.SchematicHandler.Schematic; +import com.intellectualcrafters.plot.object.Location; +import com.intellectualcrafters.plot.object.Plot; +import com.intellectualcrafters.plot.object.PlotArea; +import com.intellectualcrafters.plot.object.PlotPlayer; +import com.intellectualcrafters.plot.util.ByteArrayUtilities; +import com.intellectualcrafters.plot.util.EconHandler; +import com.intellectualcrafters.plot.util.Permissions; import com.plotsquared.general.commands.CommandDeclaration; @CommandDeclaration( @@ -36,50 +40,6 @@ requiredType = RequiredType.NONE, permission = "plots.claim", usage = "/plot claim") public class Claim extends SubCommand { - - public static boolean claimPlot(final PlotPlayer player, final Plot plot, final boolean teleport, final boolean auto) { - return claimPlot(player, plot, teleport, "", auto); - } - - public static boolean claimPlot(final PlotPlayer player, final Plot plot, final boolean teleport, final String schematic, final boolean auto) { - if (plot.hasOwner() || plot.isMerged()) { - return false; - } - final boolean result = EventUtil.manager.callClaim(player, plot, false); - if (result) { - plot.create(player.getUUID(), true); - plot.setSign(player.getName()); - MainUtil.sendMessage(player, C.CLAIMED); - if (teleport) { - plot.teleportPlayer(player); - } - final PlotArea plotworld = plot.getArea(); - if (plotworld.SCHEMATIC_ON_CLAIM) { - Schematic sch; - if (schematic.isEmpty()) { - sch = SchematicHandler.manager.getSchematic(plotworld.SCHEMATIC_FILE); - } else { - sch = SchematicHandler.manager.getSchematic(schematic); - if (sch == null) { - sch = SchematicHandler.manager.getSchematic(plotworld.SCHEMATIC_FILE); - } - } - SchematicHandler.manager.paste(sch, plot, 0, 0, 0, true, new RunnableVal() { - @Override - public void run(Boolean value) { - if (value) { - MainUtil.sendMessage(player, C.SCHEMATIC_PASTE_SUCCESS); - } else { - MainUtil.sendMessage(player, C.SCHEMATIC_PASTE_FAILED); - } - } - }); - } - plotworld.getPlotManager().claimPlot(plotworld, plot); - } - return result; - } - @Override public boolean onCommand(final PlotPlayer plr, final String... args) { String schematic = ""; @@ -137,6 +97,6 @@ public class Claim extends SubCommand { } } } - return claimPlot(plr, plot, false, schematic, false) || sendMessage(plr, C.PLOT_NOT_CLAIMED); + return plot.claim(plr, false, schematic) || sendMessage(plr, C.PLOT_NOT_CLAIMED); } } diff --git a/Core/src/main/java/com/intellectualcrafters/plot/commands/Database.java b/Core/src/main/java/com/intellectualcrafters/plot/commands/Database.java index 9d914b527..396a8e8da 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/commands/Database.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/commands/Database.java @@ -105,7 +105,7 @@ public class Database extends SubCommand { MainUtil.sendMessage(player, "Skipping duplicate plot: " + plot + " | id=" + plot.temp); continue; } - PS.get().updatePlot(plot); + plot.create(); plots.add(entry2.getValue()); } } else { diff --git a/Core/src/main/java/com/intellectualcrafters/plot/commands/DebugClaimTest.java b/Core/src/main/java/com/intellectualcrafters/plot/commands/DebugClaimTest.java index 5a81f37d8..63c4e992b 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/commands/DebugClaimTest.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/commands/DebugClaimTest.java @@ -119,7 +119,7 @@ public class DebugClaimTest extends SubCommand { } }); for (final Plot plot : plots) { - PS.get().updatePlot(plot); + plot.create(); } MainUtil.sendMessage(plr, "&3Sign Block&8->&3PlotSquared&8: &7Complete!"); } else { diff --git a/Core/src/main/java/com/intellectualcrafters/plot/commands/DebugExec.java b/Core/src/main/java/com/intellectualcrafters/plot/commands/DebugExec.java index ccdf868ab..f0f6f16d7 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/commands/DebugExec.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/commands/DebugExec.java @@ -31,6 +31,7 @@ import com.intellectualcrafters.plot.object.*; import com.intellectualcrafters.plot.util.*; import com.plotsquared.general.commands.Command; import com.plotsquared.general.commands.CommandDeclaration; +import com.plotsquared.listener.WEManager; import javax.script.*; import java.io.File; @@ -100,6 +101,11 @@ public class DebugExec extends SubCommand { // Instances scope.put("PS", PS.get()); + scope.put("SetQueue", SetQueue.IMP); + scope.put("ExpireManager", ExpireManager.IMP); + if (PS.get().worldedit != null) { + scope.put("WEManager", new WEManager()); + } scope.put("TaskManager", PS.get().TASK); scope.put("TitleManager", AbstractTitle.TITLE_CLASS); scope.put("ConsolePlayer", ConsolePlayer.getConsole()); diff --git a/Core/src/main/java/com/intellectualcrafters/plot/commands/Download.java b/Core/src/main/java/com/intellectualcrafters/plot/commands/Download.java index 8650d610f..5f9c6064b 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/commands/Download.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/commands/Download.java @@ -1,7 +1,5 @@ package com.intellectualcrafters.plot.commands; -import java.net.URL; - import com.intellectualcrafters.jnbt.CompoundTag; import com.intellectualcrafters.plot.PS; import com.intellectualcrafters.plot.config.C; @@ -16,16 +14,13 @@ import com.intellectualcrafters.plot.util.SchematicHandler; import com.intellectualcrafters.plot.util.TaskManager; import com.plotsquared.general.commands.CommandDeclaration; +import java.net.URL; + @CommandDeclaration(command = "download", aliases = { "dl" }, category = CommandCategory.SCHEMATIC, requiredType = RequiredType.NONE, description = "Download your plot", permission = "plots.download") public class Download extends SubCommand { @Override public boolean onCommand(final PlotPlayer plr, final String[] args) { - - if (!Settings.METRICS) { - MainUtil.sendMessage(plr, "&cPlease enable metrics in order to use this command.\n&7 - Or host it yourself if you don't like the free service"); - return false; - } final String world = plr.getLocation().getWorld(); if (!PS.get().hasPlotArea(world)) { return !sendMessage(plr, C.NOT_IN_PLOT_WORLD); diff --git a/Core/src/main/java/com/intellectualcrafters/plot/commands/plugin.java b/Core/src/main/java/com/intellectualcrafters/plot/commands/plugin.java index 7ccb632d7..b750a7e6f 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/commands/plugin.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/commands/plugin.java @@ -21,18 +21,25 @@ package com.intellectualcrafters.plot.commands; import com.intellectualcrafters.plot.PS; +import com.intellectualcrafters.plot.object.ChunkLoc; import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.PlotPlayer; -import com.intellectualcrafters.plot.util.ChunkManager; import com.intellectualcrafters.plot.util.MainUtil; +import com.intellectualcrafters.plot.util.SetQueue; import com.intellectualcrafters.plot.util.StringMan; import com.plotsquared.general.commands.CommandDeclaration; +import java.util.Collections; + @CommandDeclaration(command = "plugin", permission = "plots.use", description = "Show plugin information", aliases = { "version" }, category = CommandCategory.INFO) public class plugin extends SubCommand { @Override public boolean onCommand(final PlotPlayer plr, final String[] args) { + Location loc = plr.getLocation(); + ChunkLoc cl = loc.getChunkLoc(); + SetQueue.IMP.queue.sendChunk(loc.getWorld(), Collections.singletonList(cl)); + MainUtil.sendMessage(plr, String.format("$2>> $1&lPlotSquared $2($1Version$2: $1%s$2)", StringMan.join(PS.get().IMP.getPluginVersion(), "."))); MainUtil.sendMessage(plr, "$2>> $1&lAuthors$2: $1Citymonstret $2& $1Empire92"); MainUtil.sendMessage(plr, "$2>> $1&lWiki$2: $1https://github.com/IntellectualCrafters/PlotSquared/wiki"); diff --git a/Core/src/main/java/com/intellectualcrafters/plot/object/Plot.java b/Core/src/main/java/com/intellectualcrafters/plot/object/Plot.java index 857c12c88..5f0952587 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/object/Plot.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/object/Plot.java @@ -431,6 +431,9 @@ public class Plot { } public void setArea(final PlotArea area) { + if (this.getArea() == area) { + return; + } if (this.getArea() != null) { this.area.removePlot(this.id); } @@ -1167,8 +1170,9 @@ public class Plot { if (baseSettings.getRatings().containsKey(uuid)) { return false; } - baseSettings.getRatings().put(uuid, rating.getAggregate()); - DBFunc.setRating(base, uuid, this.temp); + int aggregate = rating.getAggregate(); + baseSettings.getRatings().put(uuid, aggregate); + DBFunc.setRating(base, uuid, aggregate); return true; } @@ -1259,6 +1263,45 @@ public class Plot { public boolean create() { return this.create(this.owner, true); } + + public boolean claim(final PlotPlayer pp, boolean teleport, String schematic) { + if (!canClaim(pp)) { + return false; + } + final boolean result = EventUtil.manager.callClaim(pp, this, false); + if (!result || !create(pp.getUUID(), true)) { + return false; + } + setSign(pp.getName()); + MainUtil.sendMessage(pp, C.CLAIMED); + if (teleport) { + teleportPlayer(pp); + } + final PlotArea plotworld = getArea(); + if (plotworld.SCHEMATIC_ON_CLAIM) { + SchematicHandler.Schematic sch; + if (schematic.isEmpty()) { + sch = SchematicHandler.manager.getSchematic(plotworld.SCHEMATIC_FILE); + } else { + sch = SchematicHandler.manager.getSchematic(schematic); + if (sch == null) { + sch = SchematicHandler.manager.getSchematic(plotworld.SCHEMATIC_FILE); + } + } + SchematicHandler.manager.paste(sch, this, 0, 0, 0, true, new RunnableVal() { + @Override + public void run(Boolean value) { + if (value) { + MainUtil.sendMessage(pp, C.SCHEMATIC_PASTE_SUCCESS); + } else { + MainUtil.sendMessage(pp, C.SCHEMATIC_PASTE_FAILED); + } + } + }); + } + plotworld.getPlotManager().claimPlot(plotworld, this); + return true; + } /** * Register a plot and create it in the database
@@ -2697,7 +2740,6 @@ public class Plot { DBFunc.setDenied(other, denied); } } - PS.get().updatePlot(other); } // copy terrain final ArrayDeque regions = new ArrayDeque<>(this.getRegions()); diff --git a/Core/src/main/java/com/intellectualcrafters/plot/object/PlotArea.java b/Core/src/main/java/com/intellectualcrafters/plot/object/PlotArea.java index 4750c774a..4c5b1cf58 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/object/PlotArea.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/object/PlotArea.java @@ -414,28 +414,28 @@ public abstract class PlotArea { } public Set getPlotsAbs(final UUID uuid) { - final HashSet plots = new HashSet<>(); + final HashSet myplots = new HashSet<>(); foreachPlotAbs(new RunnableVal() { @Override public void run(Plot value) { if (value.owner.equals(uuid)) { - plots.add(value); + myplots.add(value); } } }); - return plots; + return myplots; } public Set getPlots(UUID uuid) { - HashSet plots = new HashSet<>(); + HashSet myplots = new HashSet<>(); for (Plot plot : getPlots()) { if (plot.isBasePlot()) { if (plot.isOwner(uuid)) { - plots.add(plot); + myplots.add(plot); } } } - return plots; + return myplots; } public Set getPlots(PlotPlayer player) { @@ -558,14 +558,14 @@ public abstract class PlotArea { } public Set getBasePlots() { - HashSet plots = new HashSet<>(getPlots()); - Iterator iter = plots.iterator(); + HashSet myplots = new HashSet<>(getPlots()); + Iterator iter = myplots.iterator(); while (iter.hasNext()) { if (!iter.next().isBasePlot()) { iter.remove(); } } - return plots; + return myplots; } public void foreachPlotAbs(RunnableVal run) { diff --git a/Core/src/main/java/com/intellectualcrafters/plot/util/SchematicHandler.java b/Core/src/main/java/com/intellectualcrafters/plot/util/SchematicHandler.java index 892da8296..1471e284b 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/util/SchematicHandler.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/util/SchematicHandler.java @@ -671,8 +671,8 @@ public abstract class SchematicHandler { HashMap map = new HashMap(value.getValue()); map.put("Flags", tag); value.setValue(map); - whenDone.run(value); } + whenDone.run(value); } }); } diff --git a/target/PlotSquared-Bukkit.jar b/target/PlotSquared-Bukkit.jar index c150b91a5..d15f64105 100644 Binary files a/target/PlotSquared-Bukkit.jar and b/target/PlotSquared-Bukkit.jar differ