Fix for @Htgan / clear

Possibly fixes #932
This commit is contained in:
Jesse Boyd 2016-03-07 17:34:57 +11:00
parent 05caa2ca8d
commit 62531a42c7
19 changed files with 130 additions and 201 deletions

View File

@ -2,63 +2,19 @@ package com.plotsquared.bukkit.util;
import com.intellectualcrafters.plot.PS; import com.intellectualcrafters.plot.PS;
import com.intellectualcrafters.plot.generator.AugmentedUtils; import com.intellectualcrafters.plot.generator.AugmentedUtils;
import com.intellectualcrafters.plot.object.BlockLoc; import com.intellectualcrafters.plot.object.*;
import com.intellectualcrafters.plot.object.ChunkLoc;
import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Location;
import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.util.*;
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.plotsquared.bukkit.object.entity.EntityWrapper; import com.plotsquared.bukkit.object.entity.EntityWrapper;
import org.bukkit.Bukkit; import org.bukkit.*;
import org.bukkit.Chunk; import org.bukkit.block.*;
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.block.banner.Pattern; import org.bukkit.block.banner.Pattern;
import org.bukkit.entity.Animals; import org.bukkit.entity.*;
import org.bukkit.entity.Creature;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.inventory.InventoryHolder; import org.bukkit.inventory.InventoryHolder;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import java.util.ArrayList; import java.util.*;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map.Entry; import java.util.Map.Entry;
import java.util.Set;
public class BukkitChunkManager extends ChunkManager { public class BukkitChunkManager extends ChunkManager {
@ -665,7 +621,7 @@ public class BukkitChunkManager extends ChunkManager {
for (Entry<String, PlotPlayer> entry : UUIDHandler.getPlayers().entrySet()) { for (Entry<String, PlotPlayer> entry : UUIDHandler.getPlayers().entrySet()) {
PlotPlayer pp = entry.getValue(); PlotPlayer pp = entry.getValue();
Location pLoc = pp.getLocation(); Location pLoc = pp.getLocation();
if (!pLoc.getChunkLoc().equals(loc)) { if (!StringMan.isEqual(world, pLoc.getWorld()) || !pLoc.getChunkLoc().equals(loc)) {
continue; continue;
} }
pLoc.setY(WorldUtil.IMP.getHighestBlock(world, pLoc.getX(), pLoc.getZ())); pLoc.setY(WorldUtil.IMP.getHighestBlock(world, pLoc.getX(), pLoc.getZ()));

View File

@ -20,27 +20,7 @@
//////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////
package com.plotsquared.bukkit.util; package com.plotsquared.bukkit.util;
import java.util.ArrayDeque; import com.intellectualcrafters.jnbt.*;
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.plot.object.ChunkLoc; import com.intellectualcrafters.plot.object.ChunkLoc;
import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Location;
import com.intellectualcrafters.plot.object.RegionWrapper; 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.SchematicHandler;
import com.intellectualcrafters.plot.util.TaskManager; import com.intellectualcrafters.plot.util.TaskManager;
import com.plotsquared.bukkit.object.schematic.StateWrapper; 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 * Schematic Handler

View File

@ -125,7 +125,7 @@ public class SendChunk {
} }
} }
public void sendChunk(final String worldname, final List<ChunkLoc> locs) { public void sendChunk(final String worldname, final Collection<ChunkLoc> locs) {
final World myworld = Bukkit.getWorld(worldname); final World myworld = Bukkit.getWorld(worldname);
final ArrayList<Chunk> chunks = new ArrayList<>(); final ArrayList<Chunk> chunks = new ArrayList<>();
for (final ChunkLoc loc : locs) { for (final ChunkLoc loc : locs) {

View File

@ -1,7 +1,5 @@
package com.plotsquared.bukkit.util.block; 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.ChunkLoc;
import com.intellectualcrafters.plot.object.PlotBlock; import com.intellectualcrafters.plot.object.PlotBlock;
import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.MainUtil;
@ -23,6 +21,8 @@ import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
import java.util.Map.Entry; import java.util.Map.Entry;
import static com.intellectualcrafters.plot.util.ReflectionUtils.getRefClass;
public class FastQueue_1_7 extends SlowQueue { public class FastQueue_1_7 extends SlowQueue {
private final RefClass classBlock = getRefClass("{nms}.Block"); private final RefClass classBlock = getRefClass("{nms}.Block");
@ -173,9 +173,8 @@ public class FastQueue_1_7 extends SlowQueue {
World worldObj = BukkitUtil.getWorld(world); World worldObj = BukkitUtil.getWorld(world);
for (ChunkLoc loc : locs) { for (ChunkLoc loc : locs) {
ChunkWrapper wrapper = SetQueue.IMP.new ChunkWrapper(world, loc.x, loc.z); ChunkWrapper wrapper = SetQueue.IMP.new ChunkWrapper(world, loc.x, loc.z);
if (!toUpdate.containsKey(wrapper)) { toUpdate.remove(wrapper);
toUpdate.put(wrapper, worldObj.getChunkAt(loc.x, loc.z)); }
} chunksender.sendChunk(world, locs);
}
} }
} }

View File

@ -1,7 +1,5 @@
package com.plotsquared.bukkit.util.block; 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.ChunkLoc;
import com.intellectualcrafters.plot.object.PlotBlock; import com.intellectualcrafters.plot.object.PlotBlock;
import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.MainUtil;
@ -25,6 +23,8 @@ import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
import java.util.Map.Entry; import java.util.Map.Entry;
import static com.intellectualcrafters.plot.util.ReflectionUtils.getRefClass;
public class FastQueue_1_8 extends SlowQueue { public class FastQueue_1_8 extends SlowQueue {
private final RefMethod methodInitLighting; private final RefMethod methodInitLighting;
@ -376,9 +376,8 @@ public class FastQueue_1_8 extends SlowQueue {
World worldObj = BukkitUtil.getWorld(world); World worldObj = BukkitUtil.getWorld(world);
for (ChunkLoc loc : locs) { for (ChunkLoc loc : locs) {
ChunkWrapper wrapper = SetQueue.IMP.new ChunkWrapper(world, loc.x, loc.z); ChunkWrapper wrapper = SetQueue.IMP.new ChunkWrapper(world, loc.x, loc.z);
if (!toUpdate.containsKey(wrapper)) { toUpdate.remove(wrapper);
toUpdate.put(wrapper, worldObj.getChunkAt(loc.x, loc.z)); }
} chunksender.sendChunk(world, locs);
}
} }
} }

View File

@ -1,20 +1,14 @@
package com.plotsquared.bukkit.util.block; 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.ChunkLoc;
import com.intellectualcrafters.plot.object.PseudoRandom; import com.intellectualcrafters.plot.object.PseudoRandom;
import com.intellectualcrafters.plot.util.ChunkManager; import com.intellectualcrafters.plot.util.*;
import com.intellectualcrafters.plot.util.MainUtil;
import com.intellectualcrafters.plot.util.PlotChunk;
import com.intellectualcrafters.plot.util.ReflectionUtils.RefClass; import com.intellectualcrafters.plot.util.ReflectionUtils.RefClass;
import com.intellectualcrafters.plot.util.ReflectionUtils.RefConstructor; import com.intellectualcrafters.plot.util.ReflectionUtils.RefConstructor;
import com.intellectualcrafters.plot.util.ReflectionUtils.RefField; import com.intellectualcrafters.plot.util.ReflectionUtils.RefField;
import com.intellectualcrafters.plot.util.ReflectionUtils.RefMethod; import com.intellectualcrafters.plot.util.ReflectionUtils.RefMethod;
import com.intellectualcrafters.plot.util.ReflectionUtils.RefMethod.RefExecutor; 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.SetQueue.ChunkWrapper;
import com.intellectualcrafters.plot.util.TaskManager;
import com.plotsquared.bukkit.util.BukkitUtil; import com.plotsquared.bukkit.util.BukkitUtil;
import com.plotsquared.bukkit.util.SendChunk; import com.plotsquared.bukkit.util.SendChunk;
import org.bukkit.Chunk; import org.bukkit.Chunk;
@ -26,13 +20,10 @@ import org.bukkit.block.Biome;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.util.ArrayList; import java.util.*;
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map.Entry; 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 { 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); World worldObj = BukkitUtil.getWorld(world);
for (ChunkLoc loc : locs) { for (ChunkLoc loc : locs) {
ChunkWrapper wrapper = SetQueue.IMP.new ChunkWrapper(world, loc.x, loc.z); ChunkWrapper wrapper = SetQueue.IMP.new ChunkWrapper(world, loc.x, loc.z);
if (!toUpdate.containsKey(wrapper)) { toUpdate.remove(wrapper);
toUpdate.put(wrapper, worldObj.getChunkAt(loc.x, loc.z)); }
} chunksender.sendChunk(world, locs);
}
} }
} }

View File

@ -1,20 +1,14 @@
package com.plotsquared.bukkit.util.block; 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.ChunkLoc;
import com.intellectualcrafters.plot.object.PseudoRandom; import com.intellectualcrafters.plot.object.PseudoRandom;
import com.intellectualcrafters.plot.util.ChunkManager; import com.intellectualcrafters.plot.util.*;
import com.intellectualcrafters.plot.util.MainUtil;
import com.intellectualcrafters.plot.util.PlotChunk;
import com.intellectualcrafters.plot.util.ReflectionUtils.RefClass; import com.intellectualcrafters.plot.util.ReflectionUtils.RefClass;
import com.intellectualcrafters.plot.util.ReflectionUtils.RefConstructor; import com.intellectualcrafters.plot.util.ReflectionUtils.RefConstructor;
import com.intellectualcrafters.plot.util.ReflectionUtils.RefField; import com.intellectualcrafters.plot.util.ReflectionUtils.RefField;
import com.intellectualcrafters.plot.util.ReflectionUtils.RefMethod; import com.intellectualcrafters.plot.util.ReflectionUtils.RefMethod;
import com.intellectualcrafters.plot.util.ReflectionUtils.RefMethod.RefExecutor; 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.SetQueue.ChunkWrapper;
import com.intellectualcrafters.plot.util.TaskManager;
import com.plotsquared.bukkit.util.BukkitUtil; import com.plotsquared.bukkit.util.BukkitUtil;
import com.plotsquared.bukkit.util.SendChunk; import com.plotsquared.bukkit.util.SendChunk;
import org.bukkit.Chunk; import org.bukkit.Chunk;
@ -26,13 +20,10 @@ import org.bukkit.block.Biome;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.util.ArrayList; import java.util.*;
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map.Entry; import java.util.Map.Entry;
import java.util.Set;
import static com.intellectualcrafters.plot.util.ReflectionUtils.getRefClass;
public class FastQueue_1_9 extends SlowQueue { public class FastQueue_1_9 extends SlowQueue {
@ -456,13 +447,17 @@ public class FastQueue_1_9 extends SlowQueue {
* @param locs * @param locs
*/ */
@Override @Override
public void sendChunk(String world, Collection<ChunkLoc> locs) { public void sendChunk(final String world, final Collection<ChunkLoc> locs) {
World worldObj = BukkitUtil.getWorld(world); World worldObj = BukkitUtil.getWorld(world);
for (ChunkLoc loc : locs) { for (ChunkLoc loc : locs) {
ChunkWrapper wrapper = SetQueue.IMP.new ChunkWrapper(world, loc.x, loc.z); ChunkWrapper wrapper = SetQueue.IMP.new ChunkWrapper(world, loc.x, loc.z);
if (!toUpdate.containsKey(wrapper)) { toUpdate.remove(wrapper);
toUpdate.put(wrapper, worldObj.getChunkAt(loc.x, loc.z)); }
} TaskManager.runTaskLater(new Runnable() {
} @Override
public void run() {
chunksender.sendChunk(world, locs);
}
}, 1);
} }
} }

View File

@ -356,16 +356,6 @@ public class PS {
return database; 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.<br> * Get the relevant plot area for a location.<br>
* - If there is only one plot area globally that will be returned<br> * - If there is only one plot area globally that will be returned<br>
@ -705,12 +695,14 @@ public class PS {
public void run(PlotArea value) { public void run(PlotArea value) {
for (final PlotFilter filter : filters) { for (final PlotFilter filter : filters) {
if (!filter.allowsArea(value)) { if (!filter.allowsArea(value)) {
continue;
} }
} }
for (Entry<PlotId, Plot> entry2 : value.getPlotEntries()) { for (Entry<PlotId, Plot> entry2 : value.getPlotEntries()) {
Plot plot = entry2.getValue(); Plot plot = entry2.getValue();
for (final PlotFilter filter : filters) { for (final PlotFilter filter : filters) {
if (!filter.allowsPlot(plot)) { if (!filter.allowsPlot(plot)) {
continue;
} }
} }
set.add(plot); set.add(plot);
@ -771,7 +763,7 @@ public class PS {
@Override @Override
public void run(PlotArea value) { public void run(PlotArea value) {
for (Plot plot : value.getPlots()) { for (Plot plot : value.getPlots()) {
if (plot.getMerged(0) || plot.getMerged(3)) { if (!plot.isBasePlot()) {
continue; continue;
} }
result.add(plot); result.add(plot);

View File

@ -171,7 +171,7 @@ public class Auto extends SubCommand {
final PlotId currentId = new PlotId(origin.x + id.x, origin.y + id.y); final PlotId currentId = new PlotId(origin.x + id.x, origin.y + id.y);
Plot current = plotarea.getPlotAbs(currentId); Plot current = plotarea.getPlotAbs(currentId);
if (current.canClaim(plr)) { if (current.canClaim(plr)) {
Claim.claimPlot(plr, current, true, true); current.claim(plr, true, null);
return true; return true;
} }
id = getNextPlotId(id, 1); id = getNextPlotId(id, 1);
@ -185,7 +185,7 @@ public class Auto extends SubCommand {
while (!br) { while (!br) {
Plot plot = plotarea.getPlotAbs(getLastPlotId(plotarea)); Plot plot = plotarea.getPlotAbs(getLastPlotId(plotarea));
if (plot.canClaim(plr)) { if (plot.canClaim(plr)) {
Claim.claimPlot(plr, plot, true, true); plot.claim(plr, true, null);
br = true; br = true;
} }
plotarea.setMeta("lastPlot", getNextPlotId(plot.getId(), 1)); 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++) { for (int j = start.y; j <= end.y; j++) {
Plot plot = plotarea.getPlotAbs(new PlotId(i, j)); Plot plot = plotarea.getPlotAbs(new PlotId(i, j));
final boolean teleport = ((i == end.x) && (j == end.y)); 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)) { if (!plotarea.mergePlots(MainUtil.getPlotSelectionIds(start, end), Settings.MERGE_REMOVES_ROADS, true)) {

View File

@ -22,9 +22,13 @@ package com.intellectualcrafters.plot.commands;
import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.config.Settings; import com.intellectualcrafters.plot.config.Settings;
import com.intellectualcrafters.plot.object.*; import com.intellectualcrafters.plot.object.Location;
import com.intellectualcrafters.plot.util.*; import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.util.SchematicHandler.Schematic; 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; import com.plotsquared.general.commands.CommandDeclaration;
@CommandDeclaration( @CommandDeclaration(
@ -36,50 +40,6 @@ requiredType = RequiredType.NONE,
permission = "plots.claim", permission = "plots.claim",
usage = "/plot claim") usage = "/plot claim")
public class Claim extends SubCommand { 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<Boolean>() {
@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 @Override
public boolean onCommand(final PlotPlayer plr, final String... args) { public boolean onCommand(final PlotPlayer plr, final String... args) {
String schematic = ""; 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);
} }
} }

View File

@ -105,7 +105,7 @@ public class Database extends SubCommand {
MainUtil.sendMessage(player, "Skipping duplicate plot: " + plot + " | id=" + plot.temp); MainUtil.sendMessage(player, "Skipping duplicate plot: " + plot + " | id=" + plot.temp);
continue; continue;
} }
PS.get().updatePlot(plot); plot.create();
plots.add(entry2.getValue()); plots.add(entry2.getValue());
} }
} else { } else {

View File

@ -119,7 +119,7 @@ public class DebugClaimTest extends SubCommand {
} }
}); });
for (final Plot plot : plots) { for (final Plot plot : plots) {
PS.get().updatePlot(plot); plot.create();
} }
MainUtil.sendMessage(plr, "&3Sign Block&8->&3PlotSquared&8: &7Complete!"); MainUtil.sendMessage(plr, "&3Sign Block&8->&3PlotSquared&8: &7Complete!");
} else { } else {

View File

@ -31,6 +31,7 @@ import com.intellectualcrafters.plot.object.*;
import com.intellectualcrafters.plot.util.*; import com.intellectualcrafters.plot.util.*;
import com.plotsquared.general.commands.Command; import com.plotsquared.general.commands.Command;
import com.plotsquared.general.commands.CommandDeclaration; import com.plotsquared.general.commands.CommandDeclaration;
import com.plotsquared.listener.WEManager;
import javax.script.*; import javax.script.*;
import java.io.File; import java.io.File;
@ -100,6 +101,11 @@ public class DebugExec extends SubCommand {
// Instances // Instances
scope.put("PS", PS.get()); 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("TaskManager", PS.get().TASK);
scope.put("TitleManager", AbstractTitle.TITLE_CLASS); scope.put("TitleManager", AbstractTitle.TITLE_CLASS);
scope.put("ConsolePlayer", ConsolePlayer.getConsole()); scope.put("ConsolePlayer", ConsolePlayer.getConsole());

View File

@ -1,7 +1,5 @@
package com.intellectualcrafters.plot.commands; package com.intellectualcrafters.plot.commands;
import java.net.URL;
import com.intellectualcrafters.jnbt.CompoundTag; import com.intellectualcrafters.jnbt.CompoundTag;
import com.intellectualcrafters.plot.PS; import com.intellectualcrafters.plot.PS;
import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.config.C;
@ -16,16 +14,13 @@ import com.intellectualcrafters.plot.util.SchematicHandler;
import com.intellectualcrafters.plot.util.TaskManager; import com.intellectualcrafters.plot.util.TaskManager;
import com.plotsquared.general.commands.CommandDeclaration; 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") @CommandDeclaration(command = "download", aliases = { "dl" }, category = CommandCategory.SCHEMATIC, requiredType = RequiredType.NONE, description = "Download your plot", permission = "plots.download")
public class Download extends SubCommand { public class Download extends SubCommand {
@Override @Override
public boolean onCommand(final PlotPlayer plr, final String[] args) { 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(); final String world = plr.getLocation().getWorld();
if (!PS.get().hasPlotArea(world)) { if (!PS.get().hasPlotArea(world)) {
return !sendMessage(plr, C.NOT_IN_PLOT_WORLD); return !sendMessage(plr, C.NOT_IN_PLOT_WORLD);

View File

@ -21,18 +21,25 @@
package com.intellectualcrafters.plot.commands; package com.intellectualcrafters.plot.commands;
import com.intellectualcrafters.plot.PS; import com.intellectualcrafters.plot.PS;
import com.intellectualcrafters.plot.object.ChunkLoc;
import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Location;
import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.object.PlotPlayer;
import com.intellectualcrafters.plot.util.ChunkManager;
import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.MainUtil;
import com.intellectualcrafters.plot.util.SetQueue;
import com.intellectualcrafters.plot.util.StringMan; import com.intellectualcrafters.plot.util.StringMan;
import com.plotsquared.general.commands.CommandDeclaration; 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) @CommandDeclaration(command = "plugin", permission = "plots.use", description = "Show plugin information", aliases = { "version" }, category = CommandCategory.INFO)
public class plugin extends SubCommand { public class plugin extends SubCommand {
@Override @Override
public boolean onCommand(final PlotPlayer plr, final String[] args) { 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, 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&lAuthors$2: $1Citymonstret $2& $1Empire92");
MainUtil.sendMessage(plr, "$2>> $1&lWiki$2: $1https://github.com/IntellectualCrafters/PlotSquared/wiki"); MainUtil.sendMessage(plr, "$2>> $1&lWiki$2: $1https://github.com/IntellectualCrafters/PlotSquared/wiki");

View File

@ -431,6 +431,9 @@ public class Plot {
} }
public void setArea(final PlotArea area) { public void setArea(final PlotArea area) {
if (this.getArea() == area) {
return;
}
if (this.getArea() != null) { if (this.getArea() != null) {
this.area.removePlot(this.id); this.area.removePlot(this.id);
} }
@ -1167,8 +1170,9 @@ public class Plot {
if (baseSettings.getRatings().containsKey(uuid)) { if (baseSettings.getRatings().containsKey(uuid)) {
return false; return false;
} }
baseSettings.getRatings().put(uuid, rating.getAggregate()); int aggregate = rating.getAggregate();
DBFunc.setRating(base, uuid, this.temp); baseSettings.getRatings().put(uuid, aggregate);
DBFunc.setRating(base, uuid, aggregate);
return true; return true;
} }
@ -1260,6 +1264,45 @@ public class Plot {
return this.create(this.owner, true); 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<Boolean>() {
@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<br> * Register a plot and create it in the database<br>
* - The plot will not be created if the owner is null<br> * - The plot will not be created if the owner is null<br>
@ -2697,7 +2740,6 @@ public class Plot {
DBFunc.setDenied(other, denied); DBFunc.setDenied(other, denied);
} }
} }
PS.get().updatePlot(other);
} }
// copy terrain // copy terrain
final ArrayDeque<RegionWrapper> regions = new ArrayDeque<>(this.getRegions()); final ArrayDeque<RegionWrapper> regions = new ArrayDeque<>(this.getRegions());

View File

@ -414,28 +414,28 @@ public abstract class PlotArea {
} }
public Set<Plot> getPlotsAbs(final UUID uuid) { public Set<Plot> getPlotsAbs(final UUID uuid) {
final HashSet<Plot> plots = new HashSet<>(); final HashSet<Plot> myplots = new HashSet<>();
foreachPlotAbs(new RunnableVal<Plot>() { foreachPlotAbs(new RunnableVal<Plot>() {
@Override @Override
public void run(Plot value) { public void run(Plot value) {
if (value.owner.equals(uuid)) { if (value.owner.equals(uuid)) {
plots.add(value); myplots.add(value);
} }
} }
}); });
return plots; return myplots;
} }
public Set<Plot> getPlots(UUID uuid) { public Set<Plot> getPlots(UUID uuid) {
HashSet<Plot> plots = new HashSet<>(); HashSet<Plot> myplots = new HashSet<>();
for (Plot plot : getPlots()) { for (Plot plot : getPlots()) {
if (plot.isBasePlot()) { if (plot.isBasePlot()) {
if (plot.isOwner(uuid)) { if (plot.isOwner(uuid)) {
plots.add(plot); myplots.add(plot);
} }
} }
} }
return plots; return myplots;
} }
public Set<Plot> getPlots(PlotPlayer player) { public Set<Plot> getPlots(PlotPlayer player) {
@ -558,14 +558,14 @@ public abstract class PlotArea {
} }
public Set<Plot> getBasePlots() { public Set<Plot> getBasePlots() {
HashSet<Plot> plots = new HashSet<>(getPlots()); HashSet<Plot> myplots = new HashSet<>(getPlots());
Iterator<Plot> iter = plots.iterator(); Iterator<Plot> iter = myplots.iterator();
while (iter.hasNext()) { while (iter.hasNext()) {
if (!iter.next().isBasePlot()) { if (!iter.next().isBasePlot()) {
iter.remove(); iter.remove();
} }
} }
return plots; return myplots;
} }
public void foreachPlotAbs(RunnableVal<Plot> run) { public void foreachPlotAbs(RunnableVal<Plot> run) {

View File

@ -671,8 +671,8 @@ public abstract class SchematicHandler {
HashMap<String, Tag> map = new HashMap<String, Tag>(value.getValue()); HashMap<String, Tag> map = new HashMap<String, Tag>(value.getValue());
map.put("Flags", tag); map.put("Flags", tag);
value.setValue(map); value.setValue(map);
whenDone.run(value);
} }
whenDone.run(value);
} }
}); });
} }

Binary file not shown.