mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-22 13:16:45 +01:00
last commit before 4.0.0
Signed-off-by: matt <4009945+MattBDev@users.noreply.github.com>
This commit is contained in:
parent
cf1764723f
commit
7f14e88c4c
@ -73,7 +73,7 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
|
|||||||
WorldEdit.getInstance().getPlatformManager().queryCapability(Capability.GAME_HOOKS);
|
WorldEdit.getInstance().getPlatformManager().queryCapability(Capability.GAME_HOOKS);
|
||||||
} catch (final Throwable throwable) {
|
} catch (final Throwable throwable) {
|
||||||
throw new IllegalStateException(
|
throw new IllegalStateException(
|
||||||
"Failed to force load WorldEdit." + " Road schematics will fail to generate",
|
"Failed to force load WorldEdit. Road schematics will fail to generate",
|
||||||
throwable);
|
throwable);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -181,13 +181,13 @@ public final class Reflection {
|
|||||||
*/
|
*/
|
||||||
public synchronized static Method getMethod(Class<?> clazz, String name, Class<?>... args) {
|
public synchronized static Method getMethod(Class<?> clazz, String name, Class<?>... args) {
|
||||||
if (!_loadedMethods.containsKey(clazz)) {
|
if (!_loadedMethods.containsKey(clazz)) {
|
||||||
_loadedMethods.put(clazz, new HashMap<String, Map<ArrayWrapper<Class<?>>, Method>>());
|
_loadedMethods.put(clazz, new HashMap<>());
|
||||||
}
|
}
|
||||||
|
|
||||||
Map<String, Map<ArrayWrapper<Class<?>>, Method>> loadedMethodNames =
|
Map<String, Map<ArrayWrapper<Class<?>>, Method>> loadedMethodNames =
|
||||||
_loadedMethods.get(clazz);
|
_loadedMethods.get(clazz);
|
||||||
if (!loadedMethodNames.containsKey(name)) {
|
if (!loadedMethodNames.containsKey(name)) {
|
||||||
loadedMethodNames.put(name, new HashMap<ArrayWrapper<Class<?>>, Method>());
|
loadedMethodNames.put(name, new HashMap<>());
|
||||||
}
|
}
|
||||||
|
|
||||||
Map<ArrayWrapper<Class<?>>, Method> loadedSignatures = loadedMethodNames.get(name);
|
Map<ArrayWrapper<Class<?>>, Method> loadedSignatures = loadedMethodNames.get(name);
|
||||||
|
@ -24,7 +24,7 @@ public class BukkitAugmentedGenerator extends BlockPopulator {
|
|||||||
return generator;
|
return generator;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public void populate(World world, Random r, Chunk chunk) {
|
@Override public void populate(World world, Random random, Chunk source) {
|
||||||
AugmentedUtils.generate(world.getName(), chunk.getX(), chunk.getZ(), null);
|
AugmentedUtils.generate(world.getName(), source.getX(), source.getZ(), null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -69,12 +69,10 @@ public class BukkitPlotGenerator extends ChunkGenerator
|
|||||||
+ " is already a BukkitPlotGenerator!");
|
+ " is already a BukkitPlotGenerator!");
|
||||||
}
|
}
|
||||||
this.full = false;
|
this.full = false;
|
||||||
PlotSquared.debug("BukkitPlotGenerator does not fully support: " + cg);
|
//todo figure out why this was put here in the first place:
|
||||||
|
//PlotSquared.debug("BukkitPlotGenerator does not fully support: " + cg);
|
||||||
this.platformGenerator = cg;
|
this.platformGenerator = cg;
|
||||||
this.plotGenerator = new IndependentPlotGenerator() {
|
this.plotGenerator = new IndependentPlotGenerator() {
|
||||||
@Override public void processSetup(SetupObject setup) {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public void initialize(PlotArea area) {
|
@Override public void initialize(PlotArea area) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -59,48 +59,45 @@ import static com.github.intellectualsites.plotsquared.plot.util.ReflectionUtils
|
|||||||
for (World world : Bukkit.getWorlds()) {
|
for (World world : Bukkit.getWorlds()) {
|
||||||
world.setAutoSave(false);
|
world.setAutoSave(false);
|
||||||
}
|
}
|
||||||
TaskManager.runTaskRepeat(new Runnable() {
|
TaskManager.runTaskRepeat(() -> {
|
||||||
@Override public void run() {
|
try {
|
||||||
try {
|
HashSet<Chunk> toUnload = new HashSet<>();
|
||||||
HashSet<Chunk> toUnload = new HashSet<>();
|
for (World world : Bukkit.getWorlds()) {
|
||||||
for (World world : Bukkit.getWorlds()) {
|
String worldName = world.getName();
|
||||||
String worldName = world.getName();
|
if (!PlotSquared.get().hasPlotArea(worldName)) {
|
||||||
if (!PlotSquared.get().hasPlotArea(worldName)) {
|
continue;
|
||||||
|
}
|
||||||
|
Object w = world.getClass().getDeclaredMethod("getHandle").invoke(world);
|
||||||
|
Object chunkMap = w.getClass().getDeclaredMethod("getPlayerChunkMap").invoke(w);
|
||||||
|
Method methodIsChunkInUse =
|
||||||
|
chunkMap.getClass().getDeclaredMethod("isChunkInUse", int.class, int.class);
|
||||||
|
Chunk[] chunks = world.getLoadedChunks();
|
||||||
|
for (Chunk chunk : chunks) {
|
||||||
|
if ((boolean) methodIsChunkInUse
|
||||||
|
.invoke(chunkMap, chunk.getX(), chunk.getZ())) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
Object w = world.getClass().getDeclaredMethod("getHandle").invoke(world);
|
int x = chunk.getX();
|
||||||
Object chunkMap =
|
int z = chunk.getZ();
|
||||||
w.getClass().getDeclaredMethod("getPlayerChunkMap").invoke(w);
|
if (!shouldSave(worldName, x, z)) {
|
||||||
Method methodIsChunkInUse = chunkMap.getClass()
|
unloadChunk(worldName, chunk, false);
|
||||||
.getDeclaredMethod("isChunkInUse", int.class, int.class);
|
continue;
|
||||||
Chunk[] chunks = world.getLoadedChunks();
|
|
||||||
for (Chunk chunk : chunks) {
|
|
||||||
if ((boolean) methodIsChunkInUse
|
|
||||||
.invoke(chunkMap, chunk.getX(), chunk.getZ())) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
int x = chunk.getX();
|
|
||||||
int z = chunk.getZ();
|
|
||||||
if (!shouldSave(worldName, x, z)) {
|
|
||||||
unloadChunk(worldName, chunk, false);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
toUnload.add(chunk);
|
|
||||||
}
|
}
|
||||||
|
toUnload.add(chunk);
|
||||||
}
|
}
|
||||||
if (toUnload.isEmpty()) {
|
}
|
||||||
|
if (toUnload.isEmpty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
long start = System.currentTimeMillis();
|
||||||
|
for (Chunk chunk : toUnload) {
|
||||||
|
if (System.currentTimeMillis() - start > 5) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
long start = System.currentTimeMillis();
|
chunk.unload(true, false);
|
||||||
for (Chunk chunk : toUnload) {
|
|
||||||
if (System.currentTimeMillis() - start > 5) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
chunk.unload(true, false);
|
|
||||||
}
|
|
||||||
} catch (Throwable e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
}
|
||||||
|
} catch (Throwable e) {
|
||||||
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}, 1);
|
}, 1);
|
||||||
}
|
}
|
||||||
@ -222,9 +219,28 @@ import static com.github.intellectualsites.plotsquared.plot.util.ReflectionUtils
|
|||||||
private void cleanChunk(final Chunk chunk) {
|
private void cleanChunk(final Chunk chunk) {
|
||||||
TaskManager.index.incrementAndGet();
|
TaskManager.index.incrementAndGet();
|
||||||
final Integer currentIndex = TaskManager.index.get();
|
final Integer currentIndex = TaskManager.index.get();
|
||||||
Integer task = TaskManager.runTaskRepeat(new Runnable() {
|
Integer task = TaskManager.runTaskRepeat(() -> {
|
||||||
@Override public void run() {
|
if (!chunk.isLoaded()) {
|
||||||
if (!chunk.isLoaded()) {
|
Bukkit.getScheduler().cancelTask(TaskManager.tasks.get(currentIndex));
|
||||||
|
TaskManager.tasks.remove(currentIndex);
|
||||||
|
PlotSquared
|
||||||
|
.debug(Captions.PREFIX.s() + "&aSuccessfully processed and unloaded chunk!");
|
||||||
|
chunk.unload(true, true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
BlockState[] tiles = chunk.getTileEntities();
|
||||||
|
if (tiles.length == 0) {
|
||||||
|
Bukkit.getScheduler().cancelTask(TaskManager.tasks.get(currentIndex));
|
||||||
|
TaskManager.tasks.remove(currentIndex);
|
||||||
|
PlotSquared
|
||||||
|
.debug(Captions.PREFIX.s() + "&aSuccessfully processed and unloaded chunk!");
|
||||||
|
chunk.unload(true, true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
long start = System.currentTimeMillis();
|
||||||
|
int i = 0;
|
||||||
|
while (System.currentTimeMillis() - start < 250) {
|
||||||
|
if (i >= tiles.length) {
|
||||||
Bukkit.getScheduler().cancelTask(TaskManager.tasks.get(currentIndex));
|
Bukkit.getScheduler().cancelTask(TaskManager.tasks.get(currentIndex));
|
||||||
TaskManager.tasks.remove(currentIndex);
|
TaskManager.tasks.remove(currentIndex);
|
||||||
PlotSquared.debug(
|
PlotSquared.debug(
|
||||||
@ -232,29 +248,8 @@ import static com.github.intellectualsites.plotsquared.plot.util.ReflectionUtils
|
|||||||
chunk.unload(true, true);
|
chunk.unload(true, true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
BlockState[] tiles = chunk.getTileEntities();
|
tiles[i].getBlock().setType(Material.AIR, false);
|
||||||
if (tiles.length == 0) {
|
i++;
|
||||||
Bukkit.getScheduler().cancelTask(TaskManager.tasks.get(currentIndex));
|
|
||||||
TaskManager.tasks.remove(currentIndex);
|
|
||||||
PlotSquared.debug(
|
|
||||||
Captions.PREFIX.s() + "&aSuccessfully processed and unloaded chunk!");
|
|
||||||
chunk.unload(true, true);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
long start = System.currentTimeMillis();
|
|
||||||
int i = 0;
|
|
||||||
while (System.currentTimeMillis() - start < 250) {
|
|
||||||
if (i >= tiles.length) {
|
|
||||||
Bukkit.getScheduler().cancelTask(TaskManager.tasks.get(currentIndex));
|
|
||||||
TaskManager.tasks.remove(currentIndex);
|
|
||||||
PlotSquared.debug(
|
|
||||||
Captions.PREFIX.s() + "&aSuccessfully processed and unloaded chunk!");
|
|
||||||
chunk.unload(true, true);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
tiles[i].getBlock().setType(Material.AIR, false);
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}, 5);
|
}, 5);
|
||||||
TaskManager.tasks.put(currentIndex, task);
|
TaskManager.tasks.put(currentIndex, task);
|
||||||
|
@ -65,10 +65,10 @@ public class EntitySpawnListener implements Listener {
|
|||||||
Entity entity = event.getEntity();
|
Entity entity = event.getEntity();
|
||||||
Location location = BukkitUtil.getLocation(entity.getLocation());
|
Location location = BukkitUtil.getLocation(entity.getLocation());
|
||||||
PlotArea area = location.getPlotArea();
|
PlotArea area = location.getPlotArea();
|
||||||
if (area == null) {
|
if (!location.isPlotArea()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Plot plot = area.getOwnedPlotAbs(location);
|
Plot plot = location.getOwnedPlotAbs();
|
||||||
if (plot == null) {
|
if (plot == null) {
|
||||||
if (!area.MOB_SPAWNING) {
|
if (!area.MOB_SPAWNING) {
|
||||||
EntityType type = entity.getType();
|
EntityType type = entity.getType();
|
||||||
|
@ -237,26 +237,24 @@ import java.util.regex.Pattern;
|
|||||||
@EventHandler public void onVehicleEntityCollision(VehicleEntityCollisionEvent e) {
|
@EventHandler public void onVehicleEntityCollision(VehicleEntityCollisionEvent e) {
|
||||||
if (e.getVehicle().getType() == EntityType.BOAT) {
|
if (e.getVehicle().getType() == EntityType.BOAT) {
|
||||||
Location location = BukkitUtil.getLocation(e.getEntity());
|
Location location = BukkitUtil.getLocation(e.getEntity());
|
||||||
if (location.getPlotArea() == null) {
|
if (location.isPlotArea()) {
|
||||||
//we don't care about events that happen outside of a plot area.
|
if (e.getEntity() instanceof Player) {
|
||||||
return;
|
PlotPlayer player = BukkitUtil.getPlayer((Player) e.getEntity());
|
||||||
}
|
Plot plot = player.getCurrentPlot();
|
||||||
if (e.getEntity() instanceof Player) {
|
if (plot != null) {
|
||||||
PlotPlayer player = BukkitUtil.getPlayer((Player) e.getEntity());
|
if (!plot.isAdded(player.getUUID())) {
|
||||||
Plot plot = player.getCurrentPlot();
|
//Here the event is only canceled if the player is not the owner
|
||||||
if (plot != null) {
|
//of the property on which he is located.
|
||||||
if (!plot.isAdded(player.getUUID())) {
|
e.setCancelled(true);
|
||||||
//Here the event is only canceled if the player is not the owner
|
}
|
||||||
//of the property on which he is located.
|
} else {
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
//Here the event is cancelled too, otherwise you can move the
|
||||||
|
//boat with EchoPets or other mobs running around on the plot.
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
//Here the event is cancelled too, otherwise you can move the
|
|
||||||
//boat with EchoPets or other mobs running around on the plot.
|
|
||||||
e.setCancelled(true);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -315,7 +313,7 @@ import java.util.regex.Pattern;
|
|||||||
if (area == null) {
|
if (area == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Plot plot = area.getOwnedPlot(loc);
|
Plot plot = loc.getOwnedPlot();
|
||||||
if (plot == null) {
|
if (plot == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -655,7 +653,7 @@ import java.util.regex.Pattern;
|
|||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
PlotPlayer pp = PlotPlayer.wrap(player);
|
PlotPlayer pp = PlotPlayer.wrap(player);
|
||||||
Location loc = BukkitUtil.getLocation(to);
|
Location loc = BukkitUtil.getLocation(to);
|
||||||
PlotArea area = PlotSquared.get().getPlotAreaAbs(loc);
|
PlotArea area = loc.getPlotArea();
|
||||||
if (area == null) {
|
if (area == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -1029,7 +1027,7 @@ import java.util.regex.Pattern;
|
|||||||
Iterator<Block> iterator = event.blockList().iterator();
|
Iterator<Block> iterator = event.blockList().iterator();
|
||||||
while (iterator.hasNext()) {
|
while (iterator.hasNext()) {
|
||||||
iterator.next();
|
iterator.next();
|
||||||
if (location.getPlotArea() != null) {
|
if (location.isPlotArea()) {
|
||||||
iterator.remove();
|
iterator.remove();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1095,13 +1093,12 @@ import java.util.regex.Pattern;
|
|||||||
pp.deleteMeta("perm");
|
pp.deleteMeta("perm");
|
||||||
}
|
}
|
||||||
Location loc = pp.getLocation();
|
Location loc = pp.getLocation();
|
||||||
PlotArea area = PlotSquared.get().getPlotAreaAbs(loc);
|
PlotArea area = loc.getPlotArea();
|
||||||
if (area == null) {
|
if (loc.isPlotArea()) {
|
||||||
return;
|
plot = loc.getPlot();
|
||||||
}
|
if (plot != null) {
|
||||||
plot = area.getPlot(loc);
|
plotEntry(pp, plot);
|
||||||
if (plot != null) {
|
}
|
||||||
plotEntry(pp, plot);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1372,8 +1369,7 @@ import java.util.regex.Pattern;
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for (Block block1 : event.getBlocks()) {
|
for (Block block1 : event.getBlocks()) {
|
||||||
if (BukkitUtil.getLocation(block1.getLocation().add(relative)).getPlotArea()
|
if (BukkitUtil.getLocation(block1.getLocation().add(relative)).isPlotArea()) {
|
||||||
!= null) {
|
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -1414,7 +1410,7 @@ import java.util.regex.Pattern;
|
|||||||
try {
|
try {
|
||||||
for (Block pulled : event.getBlocks()) {
|
for (Block pulled : event.getBlocks()) {
|
||||||
location = BukkitUtil.getLocation(pulled.getLocation());
|
location = BukkitUtil.getLocation(pulled.getLocation());
|
||||||
if (location.getPlotArea() != null) {
|
if (location.isPlotArea()) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -1427,7 +1423,7 @@ import java.util.regex.Pattern;
|
|||||||
BlockFace dir = event.getDirection();
|
BlockFace dir = event.getDirection();
|
||||||
location = BukkitUtil.getLocation(block.getLocation()
|
location = BukkitUtil.getLocation(block.getLocation()
|
||||||
.add(dir.getModX() * 2, dir.getModY() * 2, dir.getModZ() * 2));
|
.add(dir.getModX() * 2, dir.getModY() * 2, dir.getModZ() * 2));
|
||||||
if (location.getPlotArea() != null) {
|
if (location.isPlotArea()) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -1512,7 +1508,7 @@ import java.util.regex.Pattern;
|
|||||||
if (area == null) {
|
if (area == null) {
|
||||||
for (int i = blocks.size() - 1; i >= 0; i--) {
|
for (int i = blocks.size() - 1; i >= 0; i--) {
|
||||||
location = BukkitUtil.getLocation(blocks.get(i).getLocation());
|
location = BukkitUtil.getLocation(blocks.get(i).getLocation());
|
||||||
if (location.getPlotArea() != null) {
|
if (location.isPlotArea()) {
|
||||||
blocks.remove(i);
|
blocks.remove(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1746,7 +1742,7 @@ import java.util.regex.Pattern;
|
|||||||
Iterator<Block> iterator = event.blockList().iterator();
|
Iterator<Block> iterator = event.blockList().iterator();
|
||||||
while (iterator.hasNext()) {
|
while (iterator.hasNext()) {
|
||||||
location = BukkitUtil.getLocation(iterator.next().getLocation());
|
location = BukkitUtil.getLocation(iterator.next().getLocation());
|
||||||
if (location.getPlotArea() != null) {
|
if (location.isPlotArea()) {
|
||||||
iterator.remove();
|
iterator.remove();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2054,12 +2050,6 @@ import java.util.regex.Pattern;
|
|||||||
case TNT_MINECART:
|
case TNT_MINECART:
|
||||||
eventType = PlayerBlockEventType.PLACE_VEHICLE;
|
eventType = PlayerBlockEventType.PLACE_VEHICLE;
|
||||||
break;
|
break;
|
||||||
case ITEM_FRAME:
|
|
||||||
case PAINTING:
|
|
||||||
location = BukkitUtil
|
|
||||||
.getLocation(block.getRelative(event.getBlockFace()).getLocation());
|
|
||||||
eventType = PlayerBlockEventType.PLACE_HANGING;
|
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
eventType = PlayerBlockEventType.INTERACT_BLOCK;
|
eventType = PlayerBlockEventType.INTERACT_BLOCK;
|
||||||
break;
|
break;
|
||||||
|
@ -36,45 +36,43 @@ import java.util.UUID;
|
|||||||
private static final HashMap<UUID, Interval> healRunnable = new HashMap<>();
|
private static final HashMap<UUID, Interval> healRunnable = new HashMap<>();
|
||||||
|
|
||||||
public static void startRunnable(JavaPlugin plugin) {
|
public static void startRunnable(JavaPlugin plugin) {
|
||||||
plugin.getServer().getScheduler().scheduleSyncRepeatingTask(plugin, new Runnable() {
|
plugin.getServer().getScheduler().scheduleSyncRepeatingTask(plugin, () -> {
|
||||||
@Override public void run() {
|
if (!healRunnable.isEmpty()) {
|
||||||
if (!healRunnable.isEmpty()) {
|
for (Iterator<Entry<UUID, Interval>> iterator =
|
||||||
for (Iterator<Entry<UUID, Interval>> iterator =
|
healRunnable.entrySet().iterator(); iterator.hasNext(); ) {
|
||||||
healRunnable.entrySet().iterator(); iterator.hasNext(); ) {
|
Entry<UUID, Interval> entry = iterator.next();
|
||||||
Entry<UUID, Interval> entry = iterator.next();
|
Interval value = entry.getValue();
|
||||||
Interval value = entry.getValue();
|
++value.count;
|
||||||
++value.count;
|
if (value.count == value.interval) {
|
||||||
if (value.count == value.interval) {
|
value.count = 0;
|
||||||
value.count = 0;
|
Player player = Bukkit.getPlayer(entry.getKey());
|
||||||
Player player = Bukkit.getPlayer(entry.getKey());
|
if (player == null) {
|
||||||
if (player == null) {
|
iterator.remove();
|
||||||
iterator.remove();
|
continue;
|
||||||
continue;
|
}
|
||||||
}
|
double level = player.getHealth();
|
||||||
double level = player.getHealth();
|
if (level != value.max) {
|
||||||
if (level != value.max) {
|
player.setHealth(Math.min(level + value.amount, value.max));
|
||||||
player.setHealth(Math.min(level + value.amount, value.max));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!feedRunnable.isEmpty()) {
|
}
|
||||||
for (Iterator<Entry<UUID, Interval>> iterator =
|
if (!feedRunnable.isEmpty()) {
|
||||||
feedRunnable.entrySet().iterator(); iterator.hasNext(); ) {
|
for (Iterator<Entry<UUID, Interval>> iterator =
|
||||||
Entry<UUID, Interval> entry = iterator.next();
|
feedRunnable.entrySet().iterator(); iterator.hasNext(); ) {
|
||||||
Interval value = entry.getValue();
|
Entry<UUID, Interval> entry = iterator.next();
|
||||||
++value.count;
|
Interval value = entry.getValue();
|
||||||
if (value.count == value.interval) {
|
++value.count;
|
||||||
value.count = 0;
|
if (value.count == value.interval) {
|
||||||
Player player = Bukkit.getPlayer(entry.getKey());
|
value.count = 0;
|
||||||
if (player == null) {
|
Player player = Bukkit.getPlayer(entry.getKey());
|
||||||
iterator.remove();
|
if (player == null) {
|
||||||
continue;
|
iterator.remove();
|
||||||
}
|
continue;
|
||||||
int level = player.getFoodLevel();
|
}
|
||||||
if (level != value.max) {
|
int level = player.getFoodLevel();
|
||||||
player.setFoodLevel(Math.min(level + value.amount, value.max));
|
if (level != value.max) {
|
||||||
}
|
player.setFoodLevel(Math.min(level + value.amount, value.max));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -33,8 +33,8 @@ import static com.github.intellectualsites.plotsquared.plot.util.ReflectionUtils
|
|||||||
this.done = classChunk.getField("done").getRealField();
|
this.done = classChunk.getField("done").getRealField();
|
||||||
this.lit = classChunk.getField("lit").getRealField();
|
this.lit = classChunk.getField("lit").getRealField();
|
||||||
this.s = classChunk.getField("s").getRealField();
|
this.s = classChunk.getField("s").getRealField();
|
||||||
} catch (Throwable ignore) {
|
} catch (Exception e) {
|
||||||
ignore.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
Bukkit.getPluginManager().registerEvents(this, plugin);
|
Bukkit.getPluginManager().registerEvents(this, plugin);
|
||||||
}
|
}
|
||||||
|
@ -111,10 +111,82 @@ public class BukkitChunkManager extends ChunkManager {
|
|||||||
return chunks;
|
return chunks;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override public int[] countEntities(Plot plot) {
|
||||||
public boolean copyRegion(com.github.intellectualsites.plotsquared.plot.object.Location pos1,
|
int[] existing = (int[]) plot.getMeta("EntityCount");
|
||||||
com.github.intellectualsites.plotsquared.plot.object.Location pos2,
|
if (existing != null && (System.currentTimeMillis() - (long) plot.getMeta("EntityCountTime")
|
||||||
com.github.intellectualsites.plotsquared.plot.object.Location newPos,
|
< 1000)) {
|
||||||
|
return existing;
|
||||||
|
}
|
||||||
|
PlotArea area = plot.getArea();
|
||||||
|
World world = BukkitUtil.getWorld(area.worldname);
|
||||||
|
|
||||||
|
Location bot = plot.getBottomAbs();
|
||||||
|
Location top = plot.getTopAbs();
|
||||||
|
int bx = bot.getX() >> 4;
|
||||||
|
int bz = bot.getZ() >> 4;
|
||||||
|
|
||||||
|
int tx = top.getX() >> 4;
|
||||||
|
int tz = top.getZ() >> 4;
|
||||||
|
|
||||||
|
int size = tx - bx << 4;
|
||||||
|
|
||||||
|
Set<Chunk> chunks = new HashSet<>();
|
||||||
|
for (int X = bx; X <= tx; X++) {
|
||||||
|
for (int Z = bz; Z <= tz; Z++) {
|
||||||
|
if (world.isChunkLoaded(X, Z)) {
|
||||||
|
chunks.add(world.getChunkAt(X, Z));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean doWhole = false;
|
||||||
|
List<Entity> entities = null;
|
||||||
|
if (size > 200 && chunks.size() > 200) {
|
||||||
|
entities = world.getEntities();
|
||||||
|
if (entities.size() < 16 + size / 8) {
|
||||||
|
doWhole = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int[] count = new int[6];
|
||||||
|
if (doWhole) {
|
||||||
|
for (Entity entity : entities) {
|
||||||
|
org.bukkit.Location location = entity.getLocation();
|
||||||
|
Chunk chunk = location.getChunk();
|
||||||
|
if (chunks.contains(chunk)) {
|
||||||
|
int X = chunk.getX();
|
||||||
|
int Z = chunk.getZ();
|
||||||
|
if (X > bx && X < tx && Z > bz && Z < tz) {
|
||||||
|
count(count, entity);
|
||||||
|
} else {
|
||||||
|
Plot other = area.getPlot(BukkitUtil.getLocation(location));
|
||||||
|
if (plot.equals(other)) {
|
||||||
|
count(count, entity);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for (Chunk chunk : chunks) {
|
||||||
|
int X = chunk.getX();
|
||||||
|
int Z = chunk.getZ();
|
||||||
|
Entity[] entities1 = chunk.getEntities();
|
||||||
|
for (Entity entity : entities1) {
|
||||||
|
if (X == bx || X == tx || Z == bz || Z == tz) {
|
||||||
|
Plot other = area.getPlot(BukkitUtil.getLocation(entity));
|
||||||
|
if (plot.equals(other)) {
|
||||||
|
count(count, entity);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
count(count, entity);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public boolean copyRegion(Location pos1, Location pos2, Location newPos,
|
||||||
final Runnable whenDone) {
|
final Runnable whenDone) {
|
||||||
final int relX = newPos.getX() - pos1.getX();
|
final int relX = newPos.getX() - pos1.getX();
|
||||||
final int relZ = newPos.getZ() - pos1.getZ();
|
final int relZ = newPos.getZ() - pos1.getZ();
|
||||||
@ -140,7 +212,7 @@ public class BukkitChunkManager extends ChunkManager {
|
|||||||
map.saveEntitiesIn(chunk, region);
|
map.saveEntitiesIn(chunk, region);
|
||||||
for (int x = bx & 15; x <= (tx & 15); x++) {
|
for (int x = bx & 15; x <= (tx & 15); x++) {
|
||||||
for (int z = bz & 15; z <= (tz & 15); z++) {
|
for (int z = bz & 15; z <= (tz & 15); z++) {
|
||||||
map.saveBlocks(oldBukkitWorld, 256, cxx + x, czz + z, relX, relZ);
|
map.saveBlocks(oldBukkitWorld, cxx + x, czz + z, relX, relZ);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -165,9 +237,7 @@ public class BukkitChunkManager extends ChunkManager {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public boolean regenerateRegion(
|
@Override public boolean regenerateRegion(final Location pos1, final Location pos2,
|
||||||
final com.github.intellectualsites.plotsquared.plot.object.Location pos1,
|
|
||||||
final com.github.intellectualsites.plotsquared.plot.object.Location pos2,
|
|
||||||
final boolean ignoreAugment, final Runnable whenDone) {
|
final boolean ignoreAugment, final Runnable whenDone) {
|
||||||
final String world = pos1.getWorld();
|
final String world = pos1.getWorld();
|
||||||
|
|
||||||
@ -275,8 +345,7 @@ public class BukkitChunkManager extends ChunkManager {
|
|||||||
AugmentedUtils.bypass(ignoreAugment,
|
AugmentedUtils.bypass(ignoreAugment,
|
||||||
() -> setChunkInPlotArea(null, new RunnableVal<ScopedLocalBlockQueue>() {
|
() -> setChunkInPlotArea(null, new RunnableVal<ScopedLocalBlockQueue>() {
|
||||||
@Override public void run(ScopedLocalBlockQueue value) {
|
@Override public void run(ScopedLocalBlockQueue value) {
|
||||||
com.github.intellectualsites.plotsquared.plot.object.Location min =
|
Location min = value.getMin();
|
||||||
value.getMin();
|
|
||||||
int bx = min.getX();
|
int bx = min.getX();
|
||||||
int bz = min.getZ();
|
int bz = min.getZ();
|
||||||
for (int x1 = 0; x1 < 16; x1++) {
|
for (int x1 = 0; x1 < 16; x1++) {
|
||||||
@ -317,9 +386,22 @@ public class BukkitChunkManager extends ChunkManager {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override public boolean loadChunk(String world, ChunkLoc loc, boolean force) {
|
||||||
public void clearAllEntities(com.github.intellectualsites.plotsquared.plot.object.Location pos1,
|
return BukkitUtil.getWorld(world).getChunkAt(loc.x, loc.z).load(force);
|
||||||
com.github.intellectualsites.plotsquared.plot.object.Location pos2) {
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation") @Override
|
||||||
|
public void unloadChunk(final String world, final ChunkLoc loc, final boolean save,
|
||||||
|
final boolean safe) {
|
||||||
|
if (!PlotSquared.get().isMainThread(Thread.currentThread())) {
|
||||||
|
TaskManager
|
||||||
|
.runTask(() -> BukkitUtil.getWorld(world).unloadChunk(loc.x, loc.z, save, safe));
|
||||||
|
} else {
|
||||||
|
BukkitUtil.getWorld(world).unloadChunk(loc.x, loc.z, save, safe);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public void clearAllEntities(Location pos1, Location pos2) {
|
||||||
String world = pos1.getWorld();
|
String world = pos1.getWorld();
|
||||||
List<Entity> entities = BukkitUtil.getEntities(world);
|
List<Entity> entities = BukkitUtil.getEntities(world);
|
||||||
int bx = pos1.getX();
|
int bx = pos1.getX();
|
||||||
@ -340,25 +422,7 @@ public class BukkitChunkManager extends ChunkManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public boolean loadChunk(String world, ChunkLoc loc, boolean force) {
|
@Override public void swap(Location bot1, Location top1, Location bot2, Location top2,
|
||||||
return BukkitUtil.getWorld(world).getChunkAt(loc.x, loc.z).load(force);
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("deprecation") @Override
|
|
||||||
public void unloadChunk(final String world, final ChunkLoc loc, final boolean save,
|
|
||||||
final boolean safe) {
|
|
||||||
if (!PlotSquared.get().isMainThread(Thread.currentThread())) {
|
|
||||||
TaskManager
|
|
||||||
.runTask(() -> BukkitUtil.getWorld(world).unloadChunk(loc.x, loc.z, save, safe));
|
|
||||||
} else {
|
|
||||||
BukkitUtil.getWorld(world).unloadChunk(loc.x, loc.z, save, safe);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public void swap(com.github.intellectualsites.plotsquared.plot.object.Location bot1,
|
|
||||||
com.github.intellectualsites.plotsquared.plot.object.Location top1,
|
|
||||||
com.github.intellectualsites.plotsquared.plot.object.Location bot2,
|
|
||||||
com.github.intellectualsites.plotsquared.plot.object.Location top2,
|
|
||||||
final Runnable whenDone) {
|
final Runnable whenDone) {
|
||||||
RegionWrapper region1 =
|
RegionWrapper region1 =
|
||||||
new RegionWrapper(bot1.getX(), top1.getX(), bot1.getZ(), top1.getZ());
|
new RegionWrapper(bot1.getX(), top1.getX(), bot1.getZ(), top1.getZ());
|
||||||
@ -387,81 +451,6 @@ public class BukkitChunkManager extends ChunkManager {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public int[] countEntities(Plot plot) {
|
|
||||||
int[] existing = (int[]) plot.getMeta("EntityCount");
|
|
||||||
if (existing != null && (System.currentTimeMillis() - (long) plot.getMeta("EntityCountTime")
|
|
||||||
< 1000)) {
|
|
||||||
return existing;
|
|
||||||
}
|
|
||||||
PlotArea area = plot.getArea();
|
|
||||||
World world = BukkitUtil.getWorld(area.worldname);
|
|
||||||
|
|
||||||
com.github.intellectualsites.plotsquared.plot.object.Location bot = plot.getBottomAbs();
|
|
||||||
com.github.intellectualsites.plotsquared.plot.object.Location top = plot.getTopAbs();
|
|
||||||
int bx = bot.getX() >> 4;
|
|
||||||
int bz = bot.getZ() >> 4;
|
|
||||||
|
|
||||||
int tx = top.getX() >> 4;
|
|
||||||
int tz = top.getZ() >> 4;
|
|
||||||
|
|
||||||
int size = tx - bx << 4;
|
|
||||||
|
|
||||||
Set<Chunk> chunks = new HashSet<>();
|
|
||||||
for (int X = bx; X <= tx; X++) {
|
|
||||||
for (int Z = bz; Z <= tz; Z++) {
|
|
||||||
if (world.isChunkLoaded(X, Z)) {
|
|
||||||
chunks.add(world.getChunkAt(X, Z));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
boolean doWhole = false;
|
|
||||||
List<Entity> entities = null;
|
|
||||||
if (size > 200 && chunks.size() > 200) {
|
|
||||||
entities = world.getEntities();
|
|
||||||
if (entities.size() < 16 + size / 8) {
|
|
||||||
doWhole = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int[] count = new int[6];
|
|
||||||
if (doWhole) {
|
|
||||||
for (Entity entity : entities) {
|
|
||||||
org.bukkit.Location location = entity.getLocation();
|
|
||||||
Chunk chunk = location.getChunk();
|
|
||||||
if (chunks.contains(chunk)) {
|
|
||||||
int X = chunk.getX();
|
|
||||||
int Z = chunk.getZ();
|
|
||||||
if (X > bx && X < tx && Z > bz && Z < tz) {
|
|
||||||
count(count, entity);
|
|
||||||
} else {
|
|
||||||
Plot other = area.getPlot(BukkitUtil.getLocation(location));
|
|
||||||
if (plot.equals(other)) {
|
|
||||||
count(count, entity);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
for (Chunk chunk : chunks) {
|
|
||||||
int X = chunk.getX();
|
|
||||||
int Z = chunk.getZ();
|
|
||||||
Entity[] entities1 = chunk.getEntities();
|
|
||||||
for (Entity entity : entities1) {
|
|
||||||
if (X == bx || X == tx || Z == bz || Z == tz) {
|
|
||||||
Plot other = area.getPlot(BukkitUtil.getLocation(entity));
|
|
||||||
if (plot.equals(other)) {
|
|
||||||
count(count, entity);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
count(count, entity);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return count;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void count(int[] count, Entity entity) {
|
private void count(int[] count, Entity entity) {
|
||||||
switch (entity.getType()) {
|
switch (entity.getType()) {
|
||||||
case PLAYER:
|
case PLAYER:
|
||||||
@ -595,6 +584,7 @@ public class BukkitChunkManager extends ChunkManager {
|
|||||||
count[0]++;
|
count[0]++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static class ContentMap {
|
public static class ContentMap {
|
||||||
|
|
||||||
final Set<EntityWrapper> entities;
|
final Set<EntityWrapper> entities;
|
||||||
@ -629,8 +619,7 @@ public class BukkitChunkManager extends ChunkManager {
|
|||||||
|
|
||||||
public void saveEntitiesOut(Chunk chunk, RegionWrapper region) {
|
public void saveEntitiesOut(Chunk chunk, RegionWrapper region) {
|
||||||
for (Entity entity : chunk.getEntities()) {
|
for (Entity entity : chunk.getEntities()) {
|
||||||
com.github.intellectualsites.plotsquared.plot.object.Location loc =
|
Location loc = BukkitUtil.getLocation(entity);
|
||||||
BukkitUtil.getLocation(entity);
|
|
||||||
int x = loc.getX();
|
int x = loc.getX();
|
||||||
int z = loc.getZ();
|
int z = loc.getZ();
|
||||||
if (isIn(region, x, z)) {
|
if (isIn(region, x, z)) {
|
||||||
@ -648,8 +637,7 @@ public class BukkitChunkManager extends ChunkManager {
|
|||||||
public void saveEntitiesIn(Chunk chunk, RegionWrapper region, int offsetX, int offsetZ,
|
public void saveEntitiesIn(Chunk chunk, RegionWrapper region, int offsetX, int offsetZ,
|
||||||
boolean delete) {
|
boolean delete) {
|
||||||
for (Entity entity : chunk.getEntities()) {
|
for (Entity entity : chunk.getEntities()) {
|
||||||
com.github.intellectualsites.plotsquared.plot.object.Location loc =
|
Location loc = BukkitUtil.getLocation(entity);
|
||||||
BukkitUtil.getLocation(entity);
|
|
||||||
int x = loc.getX();
|
int x = loc.getX();
|
||||||
int z = loc.getZ();
|
int z = loc.getZ();
|
||||||
if (!isIn(region, x, z)) {
|
if (!isIn(region, x, z)) {
|
||||||
@ -683,6 +671,7 @@ public class BukkitChunkManager extends ChunkManager {
|
|||||||
this.entities.clear();
|
this.entities.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//todo optimize maxY
|
||||||
public void saveBlocks(BukkitWorld world, int maxY, int x, int z, int offsetX,
|
public void saveBlocks(BukkitWorld world, int maxY, int x, int z, int offsetX,
|
||||||
int offsetZ) {
|
int offsetZ) {
|
||||||
maxY = Math.min(255, maxY);
|
maxY = Math.min(255, maxY);
|
||||||
|
@ -192,8 +192,7 @@ public class BukkitLocalQueue<T> extends BasicLocalBlockQueue<T> {
|
|||||||
for (int x = 0; x < lc.biomes.length; x++) {
|
for (int x = 0; x < lc.biomes.length; x++) {
|
||||||
String[] biomes2 = lc.biomes[x];
|
String[] biomes2 = lc.biomes[x];
|
||||||
if (biomes2 != null) {
|
if (biomes2 != null) {
|
||||||
for (int y = 0; y < biomes2.length; y++) {
|
for (String biomeStr : biomes2) {
|
||||||
String biomeStr = biomes2[y];
|
|
||||||
if (biomeStr != null) {
|
if (biomeStr != null) {
|
||||||
if (last == null || !StringMan.isEqual(last, biomeStr)) {
|
if (last == null || !StringMan.isEqual(last, biomeStr)) {
|
||||||
biome = Biome.valueOf(biomeStr.toUpperCase());
|
biome = Biome.valueOf(biomeStr.toUpperCase());
|
||||||
@ -247,8 +246,8 @@ public class BukkitLocalQueue<T> extends BasicLocalBlockQueue<T> {
|
|||||||
if (disableResult != null) {
|
if (disableResult != null) {
|
||||||
try {
|
try {
|
||||||
fieldNeighbors.set(disableResult[0], disableResult[1]);
|
fieldNeighbors.set(disableResult[0], disableResult[1]);
|
||||||
} catch (Throwable ignore) {
|
} catch (Exception e) {
|
||||||
ignore.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -69,7 +69,15 @@ import java.util.*;
|
|||||||
if (this.engine != null) {
|
if (this.engine != null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.engine = new ScriptEngineManager(null).getEngineByName("nashorn");
|
//create script engine manager
|
||||||
|
ScriptEngineManager scriptEngineManager = new ScriptEngineManager();
|
||||||
|
//create nashorn engine
|
||||||
|
this.engine = scriptEngineManager.getEngineByName("nashorn");
|
||||||
|
try {
|
||||||
|
engine.eval("print('PlotSquared Scripting Test');");
|
||||||
|
} catch (ScriptException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
if (this.engine == null) {
|
if (this.engine == null) {
|
||||||
this.engine = new ScriptEngineManager(null).getEngineByName("JavaScript");
|
this.engine = new ScriptEngineManager(null).getEngineByName("JavaScript");
|
||||||
}
|
}
|
||||||
|
@ -11,8 +11,8 @@ import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
|
|||||||
import com.github.intellectualsites.plotsquared.plot.util.Permissions;
|
import com.github.intellectualsites.plotsquared.plot.util.Permissions;
|
||||||
|
|
||||||
@CommandDeclaration(usage = "/plot move <X;Z>", command = "move", description = "Move a plot",
|
@CommandDeclaration(usage = "/plot move <X;Z>", command = "move", description = "Move a plot",
|
||||||
aliases = {"debugmove"}, permission = "plots.move", category = CommandCategory.CLAIMING,
|
aliases = {"debugmove"}, permission = "plots.move", category = CommandCategory.CLAIMING, requiredType = RequiredType.PLAYER)
|
||||||
requiredType = RequiredType.NONE) public class Move extends SubCommand {
|
public class Move extends SubCommand {
|
||||||
|
|
||||||
@Override public boolean onCommand(final PlotPlayer player, String[] args) {
|
@Override public boolean onCommand(final PlotPlayer player, String[] args) {
|
||||||
Location loc = player.getLocation();
|
Location loc = player.getLocation();
|
||||||
|
@ -9,8 +9,8 @@ import com.github.intellectualsites.plotsquared.plot.object.RunnableVal2;
|
|||||||
import com.github.intellectualsites.plotsquared.plot.object.RunnableVal3;
|
import com.github.intellectualsites.plotsquared.plot.object.RunnableVal3;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.StringMan;
|
import com.github.intellectualsites.plotsquared.plot.util.StringMan;
|
||||||
|
|
||||||
@CommandDeclaration(command = "near", aliases = "n", description = "Display nearby players",
|
@CommandDeclaration(command = "near", aliases = "n", description = "Display nearby players", usage = "/plot near", category = CommandCategory.INFO, requiredType = RequiredType.PLAYER)
|
||||||
usage = "/plot near", category = CommandCategory.INFO) public class Near extends Command {
|
public class Near extends Command {
|
||||||
public Near() {
|
public Near() {
|
||||||
super(MainCommand.getInstance(), true);
|
super(MainCommand.getInstance(), true);
|
||||||
}
|
}
|
||||||
|
@ -107,8 +107,8 @@ import java.util.Set;
|
|||||||
MainUtil.sendMessage(null, " - TIME ESTIMATE: 12 Parsecs");
|
MainUtil.sendMessage(null, " - TIME ESTIMATE: 12 Parsecs");
|
||||||
TaskManager.objectTask(plots, new RunnableVal<Plot>() {
|
TaskManager.objectTask(plots, new RunnableVal<Plot>() {
|
||||||
@Override public void run(Plot plot) {
|
@Override public void run(Plot plot) {
|
||||||
Location pos1 = plot.getBottom();
|
Location pos1 = plot.getCorners()[0];
|
||||||
Location pos2 = plot.getTop();
|
Location pos2 = plot.getCorners()[1];
|
||||||
int ccx1 = pos1.getX() >> 9;
|
int ccx1 = pos1.getX() >> 9;
|
||||||
int ccz1 = pos1.getZ() >> 9;
|
int ccz1 = pos1.getZ() >> 9;
|
||||||
int ccx2 = pos2.getX() >> 9;
|
int ccx2 = pos2.getX() >> 9;
|
||||||
|
@ -44,7 +44,7 @@ public class ClassicPlotManager extends SquarePlotManager {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public boolean unclaimPlot(PlotArea plotArea, Plot plot, Runnable whenDone) {
|
@Override public boolean unClaimPlot(PlotArea plotArea, Plot plot, Runnable whenDone) {
|
||||||
ClassicPlotWorld dpw = (ClassicPlotWorld) plotArea;
|
ClassicPlotWorld dpw = (ClassicPlotWorld) plotArea;
|
||||||
setWallFilling(dpw, plot.getId(), dpw.WALL_FILLING);
|
setWallFilling(dpw, plot.getId(), dpw.WALL_FILLING);
|
||||||
setWall(dpw, plot.getId(), dpw.WALL_BLOCK);
|
setWall(dpw, plot.getId(), dpw.WALL_BLOCK);
|
||||||
|
@ -57,7 +57,11 @@ public class Location implements Cloneable, Comparable<Location> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override public Location clone() {
|
@Override public Location clone() {
|
||||||
return new Location(this.world, this.x, this.y, this.z, this.yaw, this.pitch);
|
try {
|
||||||
|
return (Location) super.clone();
|
||||||
|
} catch (CloneNotSupportedException e) {
|
||||||
|
throw new AssertionError(); //can't happen
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public PlotArea getPlotArea() {
|
public PlotArea getPlotArea() {
|
||||||
@ -65,7 +69,7 @@ public class Location implements Cloneable, Comparable<Location> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Plot getOwnedPlot() {
|
public Plot getOwnedPlot() {
|
||||||
PlotArea area = PlotSquared.get().getPlotAreaAbs(this);
|
PlotArea area = getPlotArea();
|
||||||
if (area != null) {
|
if (area != null) {
|
||||||
return area.getOwnedPlot(this);
|
return area.getOwnedPlot(this);
|
||||||
} else {
|
} else {
|
||||||
@ -74,7 +78,7 @@ public class Location implements Cloneable, Comparable<Location> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Plot getOwnedPlotAbs() {
|
public Plot getOwnedPlotAbs() {
|
||||||
PlotArea area = PlotSquared.get().getPlotAreaAbs(this);
|
PlotArea area = getPlotArea();
|
||||||
if (area != null) {
|
if (area != null) {
|
||||||
return area.getOwnedPlotAbs(this);
|
return area.getOwnedPlotAbs(this);
|
||||||
} else {
|
} else {
|
||||||
@ -83,16 +87,16 @@ public class Location implements Cloneable, Comparable<Location> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean isPlotArea() {
|
public boolean isPlotArea() {
|
||||||
return PlotSquared.get().getPlotAreaAbs(this) != null;
|
return getPlotArea() != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isPlotRoad() {
|
public boolean isPlotRoad() {
|
||||||
PlotArea area = PlotSquared.get().getPlotAreaAbs(this);
|
PlotArea area = getPlotArea();
|
||||||
return area != null && area.getPlotAbs(this) == null;
|
return area != null && area.getPlotAbs(this) == null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isUnownedPlotArea() {
|
public boolean isUnownedPlotArea() {
|
||||||
PlotArea area = PlotSquared.get().getPlotAreaAbs(this);
|
PlotArea area = getPlotArea();
|
||||||
return area != null && area.getOwnedPlotAbs(this) == null;
|
return area != null && area.getOwnedPlotAbs(this) == null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -106,7 +110,7 @@ public class Location implements Cloneable, Comparable<Location> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Plot getPlotAbs() {
|
public Plot getPlotAbs() {
|
||||||
PlotArea area = PlotSquared.get().getPlotAreaAbs(this);
|
PlotArea area = getPlotArea();
|
||||||
if (area != null) {
|
if (area != null) {
|
||||||
return area.getPlotAbs(this);
|
return area.getPlotAbs(this);
|
||||||
} else {
|
} else {
|
||||||
@ -115,7 +119,7 @@ public class Location implements Cloneable, Comparable<Location> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Plot getPlot() {
|
public Plot getPlot() {
|
||||||
PlotArea area = PlotSquared.get().getPlotAreaAbs(this);
|
PlotArea area = getPlotArea();
|
||||||
if (area != null) {
|
if (area != null) {
|
||||||
return area.getPlot(this);
|
return area.getPlot(this);
|
||||||
} else {
|
} else {
|
||||||
|
@ -226,7 +226,7 @@ public class Plot {
|
|||||||
* @see PlotPlayer#getCurrentPlot() if a player is expected here.
|
* @see PlotPlayer#getCurrentPlot() if a player is expected here.
|
||||||
*/
|
*/
|
||||||
public static Plot getPlot(Location location) {
|
public static Plot getPlot(Location location) {
|
||||||
PlotArea pa = PlotSquared.get().getPlotAreaAbs(location);
|
PlotArea pa = location.getPlotArea();
|
||||||
if (pa != null) {
|
if (pa != null) {
|
||||||
return pa.getPlot(location);
|
return pa.getPlot(location);
|
||||||
}
|
}
|
||||||
@ -457,7 +457,7 @@ public class Plot {
|
|||||||
* Gets or create plot settings.
|
* Gets or create plot settings.
|
||||||
*
|
*
|
||||||
* @return PlotSettings
|
* @return PlotSettings
|
||||||
* @deprecated use equivalent plot method;
|
* @deprecated use equivalent plot method; please file github issue if one does not exist.
|
||||||
*/
|
*/
|
||||||
@Deprecated public PlotSettings getSettings() {
|
@Deprecated public PlotSettings getSettings() {
|
||||||
if (this.settings == null) {
|
if (this.settings == null) {
|
||||||
@ -837,7 +837,7 @@ public class Plot {
|
|||||||
};
|
};
|
||||||
for (Plot current : plots) {
|
for (Plot current : plots) {
|
||||||
if (isDelete || current.owner == null) {
|
if (isDelete || current.owner == null) {
|
||||||
manager.unclaimPlot(Plot.this.area, current, null);
|
manager.unClaimPlot(Plot.this.area, current, null);
|
||||||
} else {
|
} else {
|
||||||
manager.claimPlot(Plot.this.area, current);
|
manager.claimPlot(Plot.this.area, current);
|
||||||
}
|
}
|
||||||
@ -1567,13 +1567,19 @@ public class Plot {
|
|||||||
*/
|
*/
|
||||||
public boolean swapData(Plot plot, Runnable whenDone) {
|
public boolean swapData(Plot plot, Runnable whenDone) {
|
||||||
if (this.owner == null) {
|
if (this.owner == null) {
|
||||||
if (plot != null && plot.hasOwner()) {
|
if (plot == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (plot.hasOwner()) {
|
||||||
plot.moveData(this, whenDone);
|
plot.moveData(this, whenDone);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (plot == null || plot.owner == null) {
|
if (plot == null) {
|
||||||
|
this.moveData(plot, whenDone);
|
||||||
|
return true;
|
||||||
|
} else if (plot.owner == null) {
|
||||||
this.moveData(plot, whenDone);
|
this.moveData(plot, whenDone);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -2900,7 +2906,7 @@ public class Plot {
|
|||||||
getManager().claimPlot(current.getArea(), current);
|
getManager().claimPlot(current.getArea(), current);
|
||||||
Plot originPlot = originArea.getPlotAbs(
|
Plot originPlot = originArea.getPlotAbs(
|
||||||
new PlotId(current.id.x - offset.x, current.id.y - offset.y));
|
new PlotId(current.id.x - offset.x, current.id.y - offset.y));
|
||||||
originPlot.getManager().unclaimPlot(originArea, originPlot, null);
|
originPlot.getManager().unClaimPlot(originArea, originPlot, null);
|
||||||
}
|
}
|
||||||
plot.setSign();
|
plot.setSign();
|
||||||
TaskManager.runTask(whenDone);
|
TaskManager.runTask(whenDone);
|
||||||
|
@ -31,7 +31,7 @@ public abstract class PlotManager {
|
|||||||
|
|
||||||
public abstract boolean claimPlot(PlotArea plotArea, Plot plot);
|
public abstract boolean claimPlot(PlotArea plotArea, Plot plot);
|
||||||
|
|
||||||
public abstract boolean unclaimPlot(PlotArea plotArea, Plot plot, Runnable whenDone);
|
public abstract boolean unClaimPlot(PlotArea plotArea, Plot plot, Runnable whenDone);
|
||||||
|
|
||||||
public abstract Location getSignLoc(PlotArea plotArea, Plot plot);
|
public abstract Location getSignLoc(PlotArea plotArea, Plot plot);
|
||||||
|
|
||||||
|
@ -83,10 +83,7 @@ public class StringPlotBlock extends PlotBlock {
|
|||||||
if (this == obj) {
|
if (this == obj) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (obj == null) {
|
if (obj == null || getClass() != obj.getClass()) {
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (getClass() != obj.getClass()) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
StringPlotBlock other = (StringPlotBlock) obj;
|
StringPlotBlock other = (StringPlotBlock) obj;
|
||||||
|
@ -46,7 +46,7 @@ public class SinglePlotManager extends PlotManager {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public boolean unclaimPlot(PlotArea plotArea, Plot plot, Runnable whenDone) {
|
@Override public boolean unClaimPlot(PlotArea plotArea, Plot plot, Runnable whenDone) {
|
||||||
if (whenDone != null) {
|
if (whenDone != null) {
|
||||||
whenDone.run();
|
whenDone.run();
|
||||||
}
|
}
|
||||||
|
@ -76,11 +76,7 @@ public abstract class EventUtil {
|
|||||||
}
|
}
|
||||||
final Plot plot = player.getCurrentPlot();
|
final Plot plot = player.getCurrentPlot();
|
||||||
if (Settings.Teleport.ON_LOGIN && plot != null) {
|
if (Settings.Teleport.ON_LOGIN && plot != null) {
|
||||||
TaskManager.runTask(new Runnable() {
|
TaskManager.runTask(() -> plot.teleportPlayer(player));
|
||||||
@Override public void run() {
|
|
||||||
plot.teleportPlayer(player);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
MainUtil.sendMessage(player,
|
MainUtil.sendMessage(player,
|
||||||
Captions.TELEPORTED_TO_ROAD.f() + " (on-login) " + "(" + plot.getId().x + ";" + plot
|
Captions.TELEPORTED_TO_ROAD.f() + " (on-login) " + "(" + plot.getId().x + ";" + plot
|
||||||
.getId().y + ")");
|
.getId().y + ")");
|
||||||
@ -97,19 +93,13 @@ public abstract class EventUtil {
|
|||||||
|
|
||||||
public boolean checkPlayerBlockEvent(PlotPlayer player, PlayerBlockEventType type,
|
public boolean checkPlayerBlockEvent(PlotPlayer player, PlayerBlockEventType type,
|
||||||
Location location, LazyBlock block, boolean notifyPerms) {
|
Location location, LazyBlock block, boolean notifyPerms) {
|
||||||
PlotArea area = PlotSquared.get().getPlotAreaAbs(location);
|
PlotArea area = location.getPlotArea();
|
||||||
Plot plot;
|
assert area != null;
|
||||||
if (area != null) {
|
Plot plot = area.getPlot(location);
|
||||||
plot = area.getPlot(location);
|
if (plot != null) {
|
||||||
} else {
|
if (plot.isAdded(player.getUUID())) {
|
||||||
plot = null;
|
|
||||||
}
|
|
||||||
if (plot == null) {
|
|
||||||
if (area == null) {
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} else if (plot.isAdded(player.getUUID())) {
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case TELEPORT_OBJECT:
|
case TELEPORT_OBJECT:
|
||||||
@ -400,8 +390,6 @@ public abstract class EventUtil {
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
case PLACE_HANGING: // Handled elsewhere
|
|
||||||
return true;
|
|
||||||
case PLACE_MISC: {
|
case PLACE_MISC: {
|
||||||
if (plot == null) {
|
if (plot == null) {
|
||||||
return Permissions
|
return Permissions
|
||||||
|
@ -70,8 +70,8 @@ public class DelegateLocalBlockQueue extends LocalBlockQueue {
|
|||||||
return parent.getBlock(x, y, z);
|
return parent.getBlock(x, y, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public boolean setBiome(int x, int y, String biome) {
|
@Override public boolean setBiome(int x, int z, String biome) {
|
||||||
return parent.setBiome(x, y, biome);
|
return parent.setBiome(x, z, biome);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public String getWorld() {
|
@Override public String getWorld() {
|
||||||
|
@ -0,0 +1,21 @@
|
|||||||
|
package com.github.intellectualsites.plotsquared.plot.object;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
public class LocationTest {
|
||||||
|
|
||||||
|
private static final Logger logger = Logger.getLogger(LocationTest.class.getName());
|
||||||
|
|
||||||
|
@Test public void cloning() {
|
||||||
|
String world = "plotworld";
|
||||||
|
Location location1 = new Location(world, 0, 0, 0);
|
||||||
|
logger.info(location1.toString());
|
||||||
|
Location clone = location1.clone();
|
||||||
|
world = "normal";
|
||||||
|
logger.info(clone.toString());
|
||||||
|
location1.getBlockVector3()
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user