mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2025-07-03 06:04:43 +02:00
restructure a couple things.
This commit is contained in:
@ -59,7 +59,6 @@ import com.plotsquared.bukkit.listeners.PlayerEvents;
|
||||
import com.plotsquared.bukkit.listeners.PlayerEvents_1_8;
|
||||
import com.plotsquared.bukkit.listeners.PlayerEvents_1_8_3;
|
||||
import com.plotsquared.bukkit.listeners.PlotPlusListener;
|
||||
import com.plotsquared.bukkit.listeners.TNTListener;
|
||||
import com.plotsquared.bukkit.listeners.WorldEvents;
|
||||
import com.plotsquared.bukkit.listeners.worldedit.WEListener;
|
||||
import com.plotsquared.bukkit.titles.DefaultTitle;
|
||||
@ -520,7 +519,7 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
|
||||
|
||||
@Override
|
||||
public void registerTNTListener() {
|
||||
getServer().getPluginManager().registerEvents(new TNTListener(), this);
|
||||
// No longer here
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -161,7 +161,7 @@ public class ClassicPlotMeConnector extends APlotMeConnector {
|
||||
final HashMap<PlotId, Plot> newplots = plots.get(world);
|
||||
final Plot plot = newplots.get(entry2.getKey());
|
||||
if (plot != null) {
|
||||
plot.getSettings().setMerged(entry2.getValue());
|
||||
plot.setMerged(entry2.getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -129,7 +129,7 @@ public class PlotMeConnector_017 extends APlotMeConnector {
|
||||
final HashMap<PlotId, boolean[]> mergeMap = merges.get(plot.world);
|
||||
if (mergeMap != null) {
|
||||
if (mergeMap.containsKey(plot.id)) {
|
||||
plot.getSettings().setMerged(mergeMap.get(plot.id));
|
||||
plot.setMerged(mergeMap.get(plot.id));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ public class AugmentedPopulator extends BlockPopulator {
|
||||
o = (plotworld.TERRAIN == 1) || (plotworld.TERRAIN == 2);
|
||||
final World bukkitWorld = Bukkit.getWorld(world);
|
||||
if (cluster != null) {
|
||||
final Location bl = manager.getPlotBottomLocAbs(plotworld, cluster.getP1());
|
||||
final Location bl = manager.getPlotBottomLocAbs(plotworld, cluster.getP1()).subtract(1, 0, 1);
|
||||
final Location tl = manager.getPlotTopLocAbs(plotworld, cluster.getP2()).add(1, 0, 1);
|
||||
bx = bl.getX();
|
||||
bz = bl.getZ();
|
||||
|
@ -143,23 +143,23 @@ public class ChunkListener implements Listener {
|
||||
final int x2 = x + 15;
|
||||
final int z2 = z + 15;
|
||||
Plot plot;
|
||||
plot = MainUtil.getPlot(new Location(world, x, 1, z));
|
||||
plot = MainUtil.getPlotAbs(new Location(world, x, 1, z));
|
||||
if ((plot != null) && (plot.owner != null)) {
|
||||
return false;
|
||||
}
|
||||
plot = MainUtil.getPlot(new Location(world, x2, 1, z2));
|
||||
plot = MainUtil.getPlotAbs(new Location(world, x2, 1, z2));
|
||||
if ((plot != null) && (plot.owner != null)) {
|
||||
return false;
|
||||
}
|
||||
plot = MainUtil.getPlot(new Location(world, x2, 1, z));
|
||||
plot = MainUtil.getPlotAbs(new Location(world, x2, 1, z));
|
||||
if ((plot != null) && (plot.owner != null)) {
|
||||
return false;
|
||||
}
|
||||
plot = MainUtil.getPlot(new Location(world, x, 1, z2));
|
||||
plot = MainUtil.getPlotAbs(new Location(world, x, 1, z2));
|
||||
if ((plot != null) && (plot.owner != null)) {
|
||||
return false;
|
||||
}
|
||||
plot = MainUtil.getPlot(new Location(world, x + 7, 1, z + 7));
|
||||
plot = MainUtil.getPlotAbs(new Location(world, x + 7, 1, z + 7));
|
||||
if ((plot != null) && (plot.owner != null)) {
|
||||
return false;
|
||||
}
|
||||
|
@ -31,48 +31,46 @@ import org.bukkit.event.Listener;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import com.intellectualcrafters.plot.flag.FlagManager;
|
||||
import com.intellectualcrafters.plot.object.Location;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||
import com.plotsquared.bukkit.events.PlayerEnterPlotEvent;
|
||||
import com.plotsquared.bukkit.util.BukkitPlayerFunctions;
|
||||
import com.plotsquared.bukkit.object.BukkitPlayer;
|
||||
import com.plotsquared.bukkit.util.BukkitUtil;
|
||||
|
||||
/**
|
||||
|
||||
*/
|
||||
public class ForceFieldListener implements Listener {
|
||||
private Set<Player> getNearbyPlayers(final Player player, final Plot plot) {
|
||||
final Set<Player> players = new HashSet<>();
|
||||
public class ForceFieldListener implements Listener {
|
||||
private Set<PlotPlayer> getNearbyPlayers(final Player player, final Plot plot) {
|
||||
final Set<PlotPlayer> players = new HashSet<>();
|
||||
PlotPlayer pp;
|
||||
for (final Entity entity : player.getNearbyEntities(5d, 5d, 5d)) {
|
||||
for (final Entity entity : player.getNearbyEntities(5d, 5d, 5d)) {
|
||||
if (!(entity instanceof Player) || ((pp = BukkitUtil.getPlayer((Player) entity)) == null) || !plot.equals(pp.getCurrentPlot())) {
|
||||
continue;
|
||||
}
|
||||
final UUID uuid = UUIDHandler.getUUID(BukkitUtil.getPlayer(oPlayer));
|
||||
if (!plot.isAdded(uuid)) {
|
||||
}
|
||||
if (!plot.isAdded(pp.getUUID())) {
|
||||
players.add(pp);
|
||||
}
|
||||
}
|
||||
return players;
|
||||
}
|
||||
|
||||
private Player hasNearbyPermitted(final Player player, final Plot plot) {
|
||||
|
||||
private PlotPlayer hasNearbyPermitted(final Player player, final Plot plot) {
|
||||
PlotPlayer pp;
|
||||
for (final Entity entity : player.getNearbyEntities(5d, 5d, 5d)) {
|
||||
for (final Entity entity : player.getNearbyEntities(5d, 5d, 5d)) {
|
||||
if (!(entity instanceof Player) || ((pp = BukkitUtil.getPlayer((Player) entity)) == null) || !plot.equals(pp.getCurrentPlot())) {
|
||||
continue;
|
||||
}
|
||||
final UUID uuid = UUIDHandler.getUUID(BukkitUtil.getPlayer(oPlayer));
|
||||
if (plot.isAdded(uuid)) {
|
||||
}
|
||||
if (plot.isAdded(pp.getUUID())) {
|
||||
return pp;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public Vector calculateVelocity(final Player p, final Player e) {
|
||||
final org.bukkit.Location playerLocation = p.getLocation();
|
||||
|
||||
public Vector calculateVelocity(final PlotPlayer pp, final PlotPlayer e) {
|
||||
Location playerLocation = pp.getLocationFull();
|
||||
Location oPlayerLocation = e.getLocation();
|
||||
final double playerX = playerLocation.getX(), playerY = playerLocation.getY(), playerZ = playerLocation.getZ(), oPlayerX = oPlayerLocation.getX(), oPlayerY = oPlayerLocation.getY(), oPlayerZ = oPlayerLocation
|
||||
.getZ();
|
||||
@ -98,7 +96,6 @@ public class ForceFieldListener implements Listener {
|
||||
@EventHandler
|
||||
public void onPlotEntry(final PlayerEnterPlotEvent event) {
|
||||
final Player player = event.getPlayer();
|
||||
final PlotPlayer pp = BukkitUtil.getPlayer(player);
|
||||
final PlotPlayer pp = BukkitUtil.getPlayer(player);
|
||||
final Plot plot = event.getPlot();
|
||||
if (plot == null) {
|
||||
@ -107,16 +104,16 @@ public class ForceFieldListener implements Listener {
|
||||
if ((FlagManager.getPlotFlag(plot, "forcefield") != null) && FlagManager.getPlotFlag(plot, "forcefield").getValue().equals("true")) {
|
||||
if (!FlagManager.isBooleanFlag(plot, "forcefield", false)) {
|
||||
final UUID uuid = pp.getUUID();
|
||||
if (plot.isAdded(uuid)) {
|
||||
final Set<Player> players = getNearbyPlayers(player, plot);
|
||||
for (final Player oPlayer : players) {
|
||||
if (plot.isAdded(uuid)) {
|
||||
final Set<PlotPlayer> players = getNearbyPlayers(player, plot);
|
||||
for (final PlotPlayer oPlayer : players) {
|
||||
((BukkitPlayer) oPlayer).player.setVelocity(calculateVelocity(pp, oPlayer));
|
||||
}
|
||||
} else {
|
||||
} else {
|
||||
final PlotPlayer oPlayer = hasNearbyPermitted(player, plot);
|
||||
if (oPlayer == null) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
player.setVelocity(calculateVelocity(oPlayer, pp));
|
||||
}
|
||||
}
|
||||
|
@ -32,6 +32,7 @@ import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Monster;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Projectile;
|
||||
import org.bukkit.entity.TNTPrimed;
|
||||
import org.bukkit.entity.Tameable;
|
||||
import org.bukkit.entity.ThrownPotion;
|
||||
import org.bukkit.entity.Vehicle;
|
||||
@ -41,6 +42,8 @@ import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.event.block.BlockDamageEvent;
|
||||
import org.bukkit.event.block.BlockDispenseEvent;
|
||||
import org.bukkit.event.block.BlockExplodeEvent;
|
||||
import org.bukkit.event.block.BlockFadeEvent;
|
||||
import org.bukkit.event.block.BlockFormEvent;
|
||||
import org.bukkit.event.block.BlockFromToEvent;
|
||||
@ -57,6 +60,7 @@ import org.bukkit.event.entity.CreatureSpawnEvent;
|
||||
import org.bukkit.event.entity.EntityChangeBlockEvent;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.entity.EntityExplodeEvent;
|
||||
import org.bukkit.event.entity.ExplosionPrimeEvent;
|
||||
import org.bukkit.event.entity.PotionSplashEvent;
|
||||
import org.bukkit.event.entity.ProjectileHitEvent;
|
||||
import org.bukkit.event.hanging.HangingBreakByEntityEvent;
|
||||
@ -83,6 +87,10 @@ import org.bukkit.event.world.ChunkLoadEvent;
|
||||
import org.bukkit.event.world.StructureGrowEvent;
|
||||
import org.bukkit.help.HelpTopic;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.metadata.FixedMetadataValue;
|
||||
import org.bukkit.metadata.LazyMetadataValue;
|
||||
import org.bukkit.metadata.MetadataValue;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.projectiles.BlockProjectileSource;
|
||||
import org.bukkit.projectiles.ProjectileSource;
|
||||
import org.bukkit.util.Vector;
|
||||
@ -476,17 +484,17 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
|
||||
if (MathMan.roundInt(from.getX()) != (x2 = MathMan.roundInt(to.getX()))) {
|
||||
final Player player = event.getPlayer();
|
||||
final PlotPlayer pp = BukkitUtil.getPlayer(player);
|
||||
|
||||
|
||||
// Set last location
|
||||
Location loc = BukkitUtil.getLocation(to);
|
||||
pp.setMeta("location", loc);
|
||||
|
||||
final String worldname = to.getWorld().getName();
|
||||
final PlotWorld plotworld = PS.get().getPlotWorld(worldname);
|
||||
if (plotworld == null) {
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
final PlotId id = plotManager.getPlotId(plotworld, x2, 0, MathMan.roundInt(to.getZ()));
|
||||
Plot now = MainUtil.getPlot(loc);
|
||||
final Plot lastPlot = (Plot) pp.getMeta("lastplot");
|
||||
if (now == null) {
|
||||
if ((lastPlot != null) && !plotExit(pp, lastPlot)) {
|
||||
@ -497,13 +505,12 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
|
||||
player.teleport(player.getWorld().getSpawnLocation());
|
||||
}
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
return;
|
||||
}
|
||||
} else if ((lastPlot != null) && now.equals(lastPlot)) {
|
||||
return;
|
||||
} else {
|
||||
return;
|
||||
} else {
|
||||
if (!plotEntry(pp, plot)) {
|
||||
if (!plotEntry(pp, now)) {
|
||||
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_ENTRY_DENIED);
|
||||
if (!now.equals(lastPlot)) {
|
||||
player.teleport(from);
|
||||
@ -534,17 +541,17 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
|
||||
if (MathMan.roundInt(from.getZ()) != (z2 = MathMan.roundInt(to.getZ()))) {
|
||||
final Player player = event.getPlayer();
|
||||
final PlotPlayer pp = BukkitUtil.getPlayer(player);
|
||||
|
||||
|
||||
// Set last location
|
||||
Location loc = BukkitUtil.getLocation(to);
|
||||
pp.setMeta("location", loc);
|
||||
|
||||
final String worldname = to.getWorld().getName();
|
||||
final PlotWorld plotworld = PS.get().getPlotWorld(worldname);
|
||||
if (plotworld == null) {
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
final PlotId id = plotManager.getPlotId(plotworld, x2, 0, z2);
|
||||
Plot now = MainUtil.getPlot(loc);
|
||||
final Plot lastPlot = (Plot) pp.getMeta("lastplot");
|
||||
if (now == null) {
|
||||
if ((lastPlot != null) && !plotExit(pp, lastPlot)) {
|
||||
@ -555,13 +562,12 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
|
||||
player.teleport(player.getWorld().getSpawnLocation());
|
||||
}
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
return;
|
||||
}
|
||||
} else if ((lastPlot != null) && now.equals(lastPlot)) {
|
||||
return;
|
||||
} else {
|
||||
return;
|
||||
} else {
|
||||
if (!plotEntry(pp, plot)) {
|
||||
if (!plotEntry(pp, now)) {
|
||||
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_ENTRY_DENIED);
|
||||
if (!now.equals(lastPlot)) {
|
||||
player.teleport(from);
|
||||
@ -656,7 +662,7 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
|
||||
if (Permissions.hasPermission(pp, C.PERMISSION_ADMIN_DESTROY_OTHER)) {
|
||||
return;
|
||||
}
|
||||
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_DESTROY_OTHER);
|
||||
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_DESTROY_OTHER);
|
||||
event.setCancelled(true);
|
||||
} else if (Settings.DONE_RESTRICTS_BUILDING && plot.getFlags().containsKey("done")) {
|
||||
if (!Permissions.hasPermission(pp, C.PERMISSION_ADMIN_BUILD_OTHER)) {
|
||||
@ -682,13 +688,32 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
|
||||
final Location loc = BukkitUtil.getLocation(event.getLocation());
|
||||
final String world = loc.getWorld();
|
||||
if (!PS.get().isPlotWorld(world)) {
|
||||
return;
|
||||
return;
|
||||
}
|
||||
Plot plot = MainUtil.getPlot(loc);
|
||||
if ((plot != null) && plot.hasOwner()) {
|
||||
if (FlagManager.isPlotFlagTrue(plot, "explosion")) {
|
||||
List<MetadataValue> meta = event.getEntity().getMetadata("plot");
|
||||
Plot origin;
|
||||
if (meta.size() == 0) {
|
||||
origin = plot;
|
||||
}
|
||||
else {
|
||||
origin = (Plot) meta.get(0).value();
|
||||
}
|
||||
if (lastRadius != 0) {
|
||||
final List<Entity> nearby = event.getEntity().getNearbyEntities(lastRadius, lastRadius, lastRadius);
|
||||
for (final Entity near : nearby) {
|
||||
if ((near instanceof TNTPrimed) || (near.getType() == EntityType.MINECART_TNT)) {
|
||||
if (!near.hasMetadata("plot")) {
|
||||
near.setMetadata("plot", new FixedMetadataValue((Plugin) PS.get().IMP, plot));
|
||||
}
|
||||
}
|
||||
}
|
||||
lastRadius = 0;
|
||||
}
|
||||
final Iterator<Block> iter = event.blockList().iterator();
|
||||
while (iter.hasNext()) {
|
||||
while (iter.hasNext()) {
|
||||
final Block b = iter.next();
|
||||
if (!origin.equals(MainUtil.getPlot(BukkitUtil.getLocation(b.getLocation())))) {
|
||||
iter.remove();
|
||||
@ -714,8 +739,8 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
|
||||
public void onWorldChanged(final PlayerChangedWorldEvent event) {
|
||||
final Player player = event.getPlayer();
|
||||
final PlotPlayer pp = BukkitUtil.getPlayer(player);
|
||||
|
||||
// Delete last location
|
||||
|
||||
// Delete last location
|
||||
pp.deleteMeta("location");
|
||||
pp.deleteMeta("lastplot");
|
||||
|
||||
@ -941,25 +966,6 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
|
||||
if (!Objects.equals(plot, newPlot)) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (!Settings.PISTON_FALLING_BLOCK_CHECK) {
|
||||
return;
|
||||
}
|
||||
org.bukkit.Location lastLoc;
|
||||
if (blocks.size() > 0) {
|
||||
lastLoc = blocks.get(blocks.size() - 1).getLocation().add(relative);
|
||||
} else {
|
||||
lastLoc = event.getBlock().getLocation().add(relative);
|
||||
}
|
||||
final Entity[] ents = lastLoc.getChunk().getEntities();
|
||||
for (final Entity entity : ents) {
|
||||
if (entity instanceof FallingBlock) {
|
||||
final org.bukkit.Location eloc = entity.getLocation();
|
||||
if (eloc.distanceSquared(lastLoc) < 2) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -998,6 +1004,20 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onBlockDispense(final BlockDispenseEvent e) {
|
||||
Material type = e.getItem().getType();
|
||||
if (type != Material.WATER_BUCKET && type != Material.LAVA_BUCKET) {
|
||||
return;
|
||||
}
|
||||
final Location loc = BukkitUtil.getLocation(e.getVelocity().toLocation(e.getBlock().getWorld()));
|
||||
if (PS.get().isPlotWorld(loc.getWorld())) {
|
||||
if (MainUtil.isPlotRoad(loc)) {
|
||||
e.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
@ -1113,9 +1133,6 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
|
||||
if ((hand == null) || (hand.getType() == Material.AIR) || hand.getType().isBlock()) {
|
||||
eventType = PlayerBlockEventType.INTERACT_BLOCK;
|
||||
lb = new BukkitLazyBlock(block);
|
||||
break;
|
||||
}
|
||||
// TODO calls both:
|
||||
break;
|
||||
}
|
||||
lb = new BukkitLazyBlock(new PlotBlock((short) hand.getTypeId(), (byte) hand.getDurability()));
|
||||
@ -1205,21 +1222,21 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
|
||||
if (entity instanceof Player) {
|
||||
return;
|
||||
}
|
||||
final Location loc = BukkitUtil.getLocation(event.getLocation());
|
||||
final Location loc = BukkitUtil.getLocation(event.getLocation());
|
||||
final String world = loc.getWorld();
|
||||
final PlotWorld plotworld = PS.get().getPlotWorld(world);
|
||||
if (plotworld == null) {
|
||||
return;
|
||||
}
|
||||
if (!MainUtil.isPlotArea(loc)) {
|
||||
return;
|
||||
return;
|
||||
final PlotWorld pW = PS.get().getPlotWorld(world);
|
||||
}
|
||||
final CreatureSpawnEvent.SpawnReason reason = event.getSpawnReason();
|
||||
if (((reason == CreatureSpawnEvent.SpawnReason.SPAWNER_EGG) || (reason == CreatureSpawnEvent.SpawnReason.DISPENSE_EGG)) && !plotworld.SPAWN_EGGS) {
|
||||
event.setCancelled(true);
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
} else if ((reason == CreatureSpawnEvent.SpawnReason.BREEDING) && !plotworld.SPAWN_BREEDING) {
|
||||
event.setCancelled(true);
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
} else if ((reason == CreatureSpawnEvent.SpawnReason.CUSTOM) && !plotworld.SPAWN_CUSTOM && !(event.getEntityType().getTypeId() == 30)) {
|
||||
event.setCancelled(true);
|
||||
@ -1227,6 +1244,7 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
|
||||
}
|
||||
|
||||
final Plot plot = MainUtil.getPlot(loc);
|
||||
if (checkEntity(entity, plot)) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
@ -1248,7 +1266,30 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
|
||||
if (plot == null) {
|
||||
return;
|
||||
}
|
||||
if (FlagManager.isPlotFlagTrue(plot, "disable-physics")) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
if (event.getTo().hasGravity()) {
|
||||
Entity entity = event.getEntity();
|
||||
List<MetadataValue> meta = entity.getMetadata("plot");
|
||||
if (meta.size() == 0) {
|
||||
return;
|
||||
}
|
||||
Plot origin = (Plot) meta.get(0).value();
|
||||
if (origin != null && !origin.equals(plot)) {
|
||||
event.setCancelled(true);
|
||||
entity.remove();
|
||||
}
|
||||
}
|
||||
else if (event.getTo() == Material.AIR) {
|
||||
event.getEntity().setMetadata("plot", new FixedMetadataValue((Plugin) PS.get().IMP, plot));
|
||||
}
|
||||
}
|
||||
|
||||
private float lastRadius;
|
||||
|
||||
@EventHandler
|
||||
public void onPrime(final ExplosionPrimeEvent event) {
|
||||
lastRadius = event.getRadius() + 1;
|
||||
}
|
||||
@ -1260,7 +1301,7 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
|
||||
if (entityFlag != null) {
|
||||
final int cap = ((Integer) entityFlag.getValue());
|
||||
if (cap == 0) {
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
mobs = MainUtil.countEntities(plot);
|
||||
if (mobs[0] >= cap) {
|
||||
@ -1273,7 +1314,7 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
|
||||
final int cap = ((Integer) mobFlag.getValue());
|
||||
if (cap == 0) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (mobs == null) {
|
||||
mobs = MainUtil.countEntities(plot);
|
||||
}
|
||||
@ -1287,7 +1328,7 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
|
||||
final int cap = ((Integer) animalFlag.getValue());
|
||||
if (cap == 0) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (mobs == null) {
|
||||
mobs = MainUtil.countEntities(plot);
|
||||
}
|
||||
@ -1301,7 +1342,7 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
|
||||
final int cap = ((Integer) monsterFlag.getValue());
|
||||
if (cap == 0) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (mobs == null) {
|
||||
mobs = MainUtil.countEntities(plot);
|
||||
}
|
||||
@ -1316,7 +1357,7 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
|
||||
final int cap = ((Integer) vehicleFlag.getValue());
|
||||
if (cap == 0) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (mobs == null) {
|
||||
mobs = MainUtil.countEntities(plot);
|
||||
}
|
||||
@ -1401,6 +1442,9 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// To prevent recursion
|
||||
private boolean tmp_teleport = true;
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
@ -1414,54 +1458,68 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
|
||||
final org.bukkit.Location to = event.getTo();
|
||||
int x2;
|
||||
if (MathMan.roundInt(from.getX()) != (x2 = MathMan.roundInt(to.getX()))) {
|
||||
final Player player = event.getPlayer();
|
||||
final PlotPlayer pp = BukkitUtil.getPlayer(player);
|
||||
|
||||
// Set last location
|
||||
final Player player = event.getPlayer();
|
||||
final PlotPlayer pp = BukkitUtil.getPlayer(player);
|
||||
Location loc = BukkitUtil.getLocation(to);
|
||||
pp.setMeta("location", loc);
|
||||
final String worldname = to.getWorld().getName();
|
||||
final PlotWorld plotworld = PS.get().getPlotWorld(worldname);
|
||||
if (plotworld == null) {
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
final PlotId id = plotManager.getPlotId(plotworld, x2, 0, MathMan.roundInt(to.getZ()));
|
||||
final Plot lastPlot = (Plot) pp.getMeta("lastplot");
|
||||
Plot now = MainUtil.getPlot(loc);
|
||||
final Plot lastPlot = (Plot) pp.getMeta("lastplot");
|
||||
if (now == null) {
|
||||
if ((lastPlot != null) && !plotExit(pp, lastPlot) && tmp_teleport) {
|
||||
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_EXIT_DENIED);
|
||||
if (lastPlot.equals(MainUtil.getPlot(BukkitUtil.getLocation(from)))) {
|
||||
tmp_teleport = false;
|
||||
player.teleport(from);
|
||||
player.teleport(from);
|
||||
tmp_teleport = true;
|
||||
} else {
|
||||
Location spawn = BukkitUtil.getLocation(player.getWorld().getSpawnLocation());
|
||||
if (spawn.getEuclideanDistanceSquared(pp.getLocation()) > 2) {
|
||||
tmp_teleport = false;
|
||||
player.teleport(player.getWorld().getSpawnLocation());
|
||||
tmp_teleport = true;
|
||||
}
|
||||
}
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
return;
|
||||
}
|
||||
} else if ((lastPlot != null) && now.equals(lastPlot)) {
|
||||
return;
|
||||
} else {
|
||||
return;
|
||||
} else {
|
||||
if (!plotEntry(pp, plot)) {
|
||||
if (!plotEntry(pp, now) && tmp_teleport) {
|
||||
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_ENTRY_DENIED);
|
||||
if (!now.equals(MainUtil.getPlot(BukkitUtil.getLocation(from)))) {
|
||||
tmp_teleport = false;
|
||||
player.teleport(from);
|
||||
player.teleport(from);
|
||||
tmp_teleport = true;
|
||||
} else {
|
||||
Location spawn = BukkitUtil.getLocation(player.getWorld().getSpawnLocation());
|
||||
if (spawn.getEuclideanDistanceSquared(pp.getLocation()) > 2) {
|
||||
tmp_teleport = false;
|
||||
player.teleport(player.getWorld().getSpawnLocation());
|
||||
tmp_teleport = true;
|
||||
}
|
||||
}
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
final Integer border = MainUtil.worldBorder.get(worldname);
|
||||
if (border != null && tmp_teleport) {
|
||||
if (x2 > border) {
|
||||
to.setX(border - 4);
|
||||
tmp_teleport = false;
|
||||
player.teleport(event.getTo());
|
||||
tmp_teleport = true;
|
||||
MainUtil.sendMessage(pp, C.BORDER);
|
||||
return;
|
||||
} else if (x2 < -border) {
|
||||
to.setX(-border + 4);
|
||||
tmp_teleport = false;
|
||||
player.teleport(event.getTo());
|
||||
tmp_teleport = true;
|
||||
MainUtil.sendMessage(pp, C.BORDER);
|
||||
@ -1472,19 +1530,17 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
|
||||
}
|
||||
int z2;
|
||||
if (MathMan.roundInt(from.getZ()) != (z2 = MathMan.roundInt(to.getZ()))) {
|
||||
final Player player = event.getPlayer();
|
||||
final Player player = event.getPlayer();
|
||||
|
||||
// Set last location
|
||||
final PlotPlayer pp = BukkitUtil.getPlayer(player);
|
||||
// Set last location
|
||||
Location loc = BukkitUtil.getLocation(to);
|
||||
pp.setMeta("location", loc);
|
||||
final String worldname = to.getWorld().getName();
|
||||
final PlotWorld plotworld = PS.get().getPlotWorld(worldname);
|
||||
if (plotworld == null) {
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
final PlotId id = plotManager.getPlotId(plotworld, x2, 0, z2);
|
||||
Plot now = MainUtil.getPlot(loc);
|
||||
final Plot lastPlot = (Plot) pp.getMeta("lastplot");
|
||||
if (now == null) {
|
||||
if ((lastPlot != null) && !plotExit(pp, lastPlot)) {
|
||||
@ -1495,13 +1551,12 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
|
||||
player.teleport(player.getWorld().getSpawnLocation());
|
||||
}
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
return;
|
||||
}
|
||||
} else if ((lastPlot != null) && now.equals(lastPlot)) {
|
||||
return;
|
||||
} else {
|
||||
return;
|
||||
} else {
|
||||
if (!plotEntry(pp, plot)) {
|
||||
if (!plotEntry(pp, now)) {
|
||||
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_ENTRY_DENIED);
|
||||
if (!now.equals(lastPlot)) {
|
||||
player.teleport(from);
|
||||
@ -2056,7 +2111,7 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
|
||||
&& !Permissions.hasPermission(pp, C.PERMISSION_ADMIN_BUILD_OTHER)) {
|
||||
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_BUILD_OTHER);
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
return;
|
||||
}
|
||||
} else if (Settings.DONE_RESTRICTS_BUILDING && plot.getFlags().containsKey("done")) {
|
||||
if (!Permissions.hasPermission(pp, C.PERMISSION_ADMIN_BUILD_OTHER)) {
|
||||
|
@ -78,7 +78,7 @@ public class PlayerEvents_1_8 extends PlotListener implements Listener {
|
||||
return;
|
||||
}
|
||||
final Location l = BukkitUtil.getLocation(state.getLocation());
|
||||
final Plot plot = MainUtil.getPlot(l);
|
||||
final Plot plot = MainUtil.getPlotAbs(l);
|
||||
final PlotPlayer pp = BukkitUtil.getPlayer(player);
|
||||
boolean cancelled = false;
|
||||
if (plot == null) {
|
||||
@ -126,7 +126,7 @@ public class PlayerEvents_1_8 extends PlotListener implements Listener {
|
||||
if (!PS.get().isPlotWorld(world)) {
|
||||
return;
|
||||
}
|
||||
final Plot plot = MainUtil.getPlot(l);
|
||||
final Plot plot = MainUtil.getPlotAbs(l);
|
||||
final PlotPlayer pp = BukkitUtil.getPlayer(e.getPlayer());
|
||||
if (plot == null) {
|
||||
if (!MainUtil.isPlotArea(l)) {
|
||||
|
@ -24,13 +24,13 @@ public class PlayerEvents_1_8_3 implements Listener {
|
||||
if (!PS.get().isPlotWorld(world)) {
|
||||
return;
|
||||
}
|
||||
final Plot plot = MainUtil.getPlot(loc);
|
||||
final Plot plot = MainUtil.getPlotAbs(loc);
|
||||
if ((plot != null) && plot.hasOwner()) {
|
||||
if (FlagManager.isPlotFlagTrue(plot, "explosion")) {
|
||||
final Iterator<Block> iter = event.blockList().iterator();
|
||||
while (iter.hasNext()) {
|
||||
final Block b = iter.next();
|
||||
if (!plot.equals(MainUtil.getPlot(BukkitUtil.getLocation(b.getLocation())))) {
|
||||
if (!plot.equals(MainUtil.getPlotAbs(BukkitUtil.getLocation(b.getLocation())))) {
|
||||
iter.remove();
|
||||
}
|
||||
}
|
||||
|
@ -109,7 +109,7 @@ public class PlotPlusListener extends PlotListener implements Listener {
|
||||
final Player player = event.getPlayer();
|
||||
if (player.getGameMode() != GameMode.SURVIVAL) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
final Plot plot = MainUtil.getPlotAbs(BukkitUtil.getLocation(player));
|
||||
if (plot == null) {
|
||||
return;
|
||||
@ -124,7 +124,7 @@ public class PlotPlusListener extends PlotListener implements Listener {
|
||||
if (event.getEntityType() != EntityType.PLAYER) {
|
||||
return;
|
||||
}
|
||||
final Player player = (Player) event.getEntity();
|
||||
final Player player = (Player) event.getEntity();
|
||||
final Plot plot = MainUtil.getPlotAbs(BukkitUtil.getLocation(player));
|
||||
if (plot == null) {
|
||||
return;
|
||||
@ -137,7 +137,7 @@ public class PlotPlusListener extends PlotListener implements Listener {
|
||||
@EventHandler
|
||||
public void onItemPickup(final PlayerPickupItemEvent event) {
|
||||
final Player player = event.getPlayer();
|
||||
final PlotPlayer pp = BukkitUtil.getPlayer(player);
|
||||
final PlotPlayer pp = BukkitUtil.getPlayer(player);
|
||||
final Plot plot = MainUtil.getPlotAbs(pp.getLocation());
|
||||
if (plot == null) {
|
||||
return;
|
||||
@ -151,7 +151,7 @@ public class PlotPlusListener extends PlotListener implements Listener {
|
||||
@EventHandler
|
||||
public void onItemDrop(final PlayerDropItemEvent event) {
|
||||
final Player player = event.getPlayer();
|
||||
final PlotPlayer pp = BukkitUtil.getPlayer(player);
|
||||
final PlotPlayer pp = BukkitUtil.getPlayer(player);
|
||||
final Plot plot = MainUtil.getPlotAbs(pp.getLocation());
|
||||
if (plot == null) {
|
||||
return;
|
||||
|
@ -1,120 +0,0 @@
|
||||
package com.plotsquared.bukkit.listeners;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.TNTPrimed;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.EntityExplodeEvent;
|
||||
import org.bukkit.event.entity.ExplosionPrimeEvent;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.flag.FlagManager;
|
||||
import com.intellectualcrafters.plot.object.Location;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.plotsquared.bukkit.util.BukkitUtil;
|
||||
|
||||
public class TNTListener implements Listener {
|
||||
private double lastRadius;
|
||||
|
||||
@EventHandler
|
||||
public void onPrime(final ExplosionPrimeEvent event) {
|
||||
lastRadius = event.getRadius() + 1;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onExplode(final EntityExplodeEvent event) {
|
||||
final Entity entity = event.getEntity();
|
||||
if (entity == null) {
|
||||
return;
|
||||
}
|
||||
final World world = entity.getWorld();
|
||||
final String worldname = world.getName();
|
||||
if (!PS.get().isPlotWorld(worldname)) {
|
||||
return;
|
||||
}
|
||||
final Plot plot = MainUtil.getPlot(BukkitUtil.getLocation(entity));
|
||||
if (plot == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!FlagManager.isPlotFlagTrue(plot, "explosion")) {
|
||||
return;
|
||||
}
|
||||
|
||||
final Location bot = MainUtil.getPlotBottomLoc(plot.world, plot.id);
|
||||
final Location top = MainUtil.getPlotTopLoc(plot.world, plot.id);
|
||||
|
||||
final List<Entity> nearby = entity.getNearbyEntities(lastRadius, lastRadius, lastRadius);
|
||||
for (final Entity near : nearby) {
|
||||
if ((near instanceof TNTPrimed) || (near.getType() == EntityType.MINECART_TNT)) {
|
||||
final Vector velocity = near.getVelocity();
|
||||
final Location loc = BukkitUtil.getLocation(near);
|
||||
final Plot nearPlot = MainUtil.getPlot(loc);
|
||||
if (!plot.equals(nearPlot)) {
|
||||
near.setVelocity(new Vector(0, 0, 0));
|
||||
continue;
|
||||
}
|
||||
final double vx = velocity.getX();
|
||||
velocity.getX();
|
||||
final double vz = velocity.getX();
|
||||
|
||||
int dx;
|
||||
int dz;
|
||||
|
||||
if (vx > 0) {
|
||||
dx = top.getX() - loc.getX();
|
||||
} else {
|
||||
dx = bot.getX() - loc.getX();
|
||||
}
|
||||
if (vz > 0) {
|
||||
dz = top.getZ() - loc.getZ();
|
||||
} else {
|
||||
dz = bot.getZ() - loc.getZ();
|
||||
}
|
||||
|
||||
final double s1 = dx / vx;
|
||||
final double s2 = dz / vz;
|
||||
final Vector v1 = new Vector(dx, 0, vz * s1);
|
||||
final Vector v2 = new Vector(vx * s2, 0, dz);
|
||||
|
||||
Vector shortest;
|
||||
if (v1.length() < v2.length()) {
|
||||
shortest = v1;
|
||||
} else {
|
||||
shortest = v2;
|
||||
}
|
||||
|
||||
final Location landing = loc.add(shortest.getBlockX() + 1, 0, shortest.getBlockZ() + 1);
|
||||
final int ty = MainUtil.getHeighestBlock(worldname, landing.getX(), landing.getZ());
|
||||
final int diff = ty - loc.getY();
|
||||
final double calcDiff = getY(velocity, Math.sqrt((shortest.getBlockX() * shortest.getBlockX()) + (shortest.getBlockZ() * shortest.getBlockZ())));
|
||||
if (calcDiff > diff) {
|
||||
near.setVelocity(new Vector(0, 0, 0));
|
||||
}
|
||||
}
|
||||
}
|
||||
event.getEntity().setVelocity(new Vector(0, 0, 0));
|
||||
}
|
||||
|
||||
public double getY(final Vector velocity, final double x) {
|
||||
|
||||
final double g = 16;
|
||||
final double l1 = velocity.length();
|
||||
final double l2 = Math.sqrt((velocity.getX() * velocity.getX()) + (velocity.getZ() * velocity.getZ()));
|
||||
|
||||
final double v = l1 * 20;
|
||||
double theta = Math.acos(l2 / l1);
|
||||
if (velocity.getY() < 0) {
|
||||
theta = -theta;
|
||||
}
|
||||
final double cos = Math.cos(theta);
|
||||
final double yDiff = (x * Math.tan(theta)) - ((g * x * x) / (2 * (v * v * cos * cos)));
|
||||
return yDiff;
|
||||
}
|
||||
}
|
@ -305,7 +305,7 @@ public class WEListener implements Listener {
|
||||
}
|
||||
}
|
||||
if (restricted.contains(reduced)) {
|
||||
final Plot plot = MainUtil.getPlot(pp.getLocation());
|
||||
final Plot plot = MainUtil.getPlotAbs(pp.getLocation());
|
||||
if ((plot != null) && plot.isAdded(pp.getUUID())) {
|
||||
if (delay(p, message, false)) {
|
||||
e.setCancelled(true);
|
||||
|
@ -177,9 +177,14 @@ public class BukkitPlayer extends PlotPlayer {
|
||||
}
|
||||
Permission perm = Bukkit.getServer().getPluginManager().getPermission(key);
|
||||
if (perm == null) {
|
||||
perm = new Permission(key, PermissionDefault.FALSE);
|
||||
Bukkit.getServer().getPluginManager().addPermission(perm);
|
||||
Bukkit.getServer().getPluginManager().recalculatePermissionDefaults(perm);
|
||||
try {
|
||||
perm = new Permission(key, PermissionDefault.FALSE);
|
||||
Bukkit.getServer().getPluginManager().addPermission(perm);
|
||||
Bukkit.getServer().getPluginManager().recalculatePermissionDefaults(perm);
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return player.hasPermission(key);
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Chunk;
|
||||
@ -67,11 +68,11 @@ import com.plotsquared.bukkit.object.entity.EntityWrapper;
|
||||
|
||||
public class BukkitChunkManager extends ChunkManager {
|
||||
@Override
|
||||
public ArrayList<ChunkLoc> getChunkChunks(final String world) {
|
||||
public Set<ChunkLoc> getChunkChunks(final String world) {
|
||||
final String directory = Bukkit.getWorldContainer() + File.separator + world + File.separator + "region";
|
||||
final File folder = new File(directory);
|
||||
final File[] regionFiles = folder.listFiles();
|
||||
final ArrayList<ChunkLoc> chunks = new ArrayList<>();
|
||||
final HashSet<ChunkLoc> chunks = new HashSet<>();
|
||||
if (regionFiles == null) {
|
||||
throw new RuntimeException("Could not find worlds folder.");
|
||||
}
|
||||
@ -107,7 +108,7 @@ public class BukkitChunkManager extends ChunkManager {
|
||||
for (final Player player : worldObj.getPlayers()) {
|
||||
final org.bukkit.Location locObj = player.getLocation();
|
||||
if (((locObj.getBlockX() >> 4) == loc.x) && ((locObj.getBlockZ() >> 4) == loc.z) && !locObj.getBlock().isEmpty()) {
|
||||
final Plot plot = MainUtil.getPlot(BukkitUtil.getLocation(locObj));
|
||||
final Plot plot = MainUtil.getPlotAbs(BukkitUtil.getLocation(locObj));
|
||||
if (plot != null) {
|
||||
final PlotPlayer pp = BukkitUtil.getPlayer(player);
|
||||
pp.teleport(MainUtil.getDefaultHome(plot));
|
||||
@ -167,12 +168,12 @@ public class BukkitChunkManager extends ChunkManager {
|
||||
final int z2 = z1 + 15;
|
||||
final Location bot = new Location(world, x1, 0, z1);
|
||||
Plot plot;
|
||||
plot = MainUtil.getPlot(bot);
|
||||
plot = MainUtil.getPlotAbs(bot);
|
||||
if ((plot != null) && (plot.owner != null)) {
|
||||
return plot;
|
||||
}
|
||||
final Location top = new Location(world, x2, 0, z2);
|
||||
plot = MainUtil.getPlot(top);
|
||||
plot = MainUtil.getPlotAbs(top);
|
||||
if ((plot != null) && (plot.owner != null)) {
|
||||
return plot;
|
||||
}
|
||||
@ -198,9 +199,6 @@ public class BukkitChunkManager extends ChunkManager {
|
||||
private static HashMap<BlockLoc, Byte> bannerBase;
|
||||
private static HashSet<EntityWrapper> entities;
|
||||
|
||||
/**
|
||||
* Copy a region to a new location (in the same world)
|
||||
*/
|
||||
@Override
|
||||
public boolean copyRegion(final Location pos1, final Location pos2, final Location newPos, final Runnable whenDone) {
|
||||
final int relX = newPos.getX() - pos1.getX();
|
||||
@ -254,7 +252,6 @@ public class BukkitChunkManager extends ChunkManager {
|
||||
}, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
// TODO whenDone
|
||||
TaskManager.runTask(whenDone);
|
||||
}
|
||||
}, 5);
|
||||
@ -947,7 +944,7 @@ public class BukkitChunkManager extends ChunkManager {
|
||||
return BukkitUtil.getWorld(world).unloadChunk(loc.x, loc.z, save, safe);
|
||||
}
|
||||
|
||||
public static void swapChunk(final World world, final Chunk pos1, final Chunk pos2, final RegionWrapper r1, final RegionWrapper r2) {
|
||||
public static void swapChunk(final World world1, final World world2, final Chunk pos1, final Chunk pos2, final RegionWrapper r1, final RegionWrapper r2) {
|
||||
initMaps();
|
||||
final int relX = (r2.minX - r1.minX);
|
||||
final int relZ = (r2.minZ - r1.minZ);
|
||||
@ -958,29 +955,27 @@ public class BukkitChunkManager extends ChunkManager {
|
||||
final int sx = pos1.getX() << 4;
|
||||
final int sz = pos1.getZ() << 4;
|
||||
|
||||
final int maxY = world.getMaxHeight();
|
||||
|
||||
for (int x = Math.max(r1.minX, sx); x <= Math.min(r1.maxX, sx + 15); x++) {
|
||||
for (int z = Math.max(r1.minZ, sz); z <= Math.min(r1.maxZ, sz + 15); z++) {
|
||||
saveBlocks(world, maxY, sx, sz, relX, relZ);
|
||||
for (int y = 0; y < maxY; y++) {
|
||||
final Block block1 = world.getBlockAt(x, y, z);
|
||||
saveBlocks(world1, 256, sx, sz, relX, relZ);
|
||||
for (int y = 0; y < 256; y++) {
|
||||
final Block block1 = world1.getBlockAt(x, y, z);
|
||||
final int id1 = block1.getTypeId();
|
||||
final byte data1 = block1.getData();
|
||||
final int xx = x + relX;
|
||||
final int zz = z + relZ;
|
||||
final Block block2 = world.getBlockAt(xx, y, zz);
|
||||
final Block block2 = world2.getBlockAt(xx, y, zz);
|
||||
final int id2 = block2.getTypeId();
|
||||
final byte data2 = block2.getData();
|
||||
if (id1 == 0) {
|
||||
if (id2 != 0) {
|
||||
BukkitSetBlockManager.setBlockManager.set(world, x, y, z, id2, data2);
|
||||
BukkitSetBlockManager.setBlockManager.set(world, xx, y, zz, 0, (byte) 0);
|
||||
BukkitSetBlockManager.setBlockManager.set(world1, x, y, z, id2, data2);
|
||||
BukkitSetBlockManager.setBlockManager.set(world2, xx, y, zz, 0, (byte) 0);
|
||||
}
|
||||
} else if (id2 == 0) {
|
||||
if (id1 != 0) {
|
||||
BukkitSetBlockManager.setBlockManager.set(world, xx, y, zz, id1, data1);
|
||||
BukkitSetBlockManager.setBlockManager.set(world, x, y, z, 0, (byte) 0);
|
||||
BukkitSetBlockManager.setBlockManager.set(world1, x, y, z, 0, (byte) 0);
|
||||
BukkitSetBlockManager.setBlockManager.set(world2, xx, y, zz, id1, data1);
|
||||
}
|
||||
} else if (id1 == id2) {
|
||||
if (data1 != data2) {
|
||||
@ -988,52 +983,35 @@ public class BukkitChunkManager extends ChunkManager {
|
||||
block2.setData(data1);
|
||||
}
|
||||
} else {
|
||||
BukkitSetBlockManager.setBlockManager.set(world, x, y, z, id2, data2);
|
||||
BukkitSetBlockManager.setBlockManager.set(world, xx, y, zz, id1, data1);
|
||||
BukkitSetBlockManager.setBlockManager.set(world1, x, y, z, id2, data2);
|
||||
BukkitSetBlockManager.setBlockManager.set(world2, xx, y, zz, id1, data1);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
restoreBlocks(world, 0, 0);
|
||||
restoreEntities(world, 0, 0);
|
||||
restoreBlocks(world1, 0, 0);
|
||||
restoreEntities(world1, 0, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void swap(final String worldname, final PlotId pos1, final PlotId pos2) {
|
||||
final Location bot1 = MainUtil.getPlotBottomLoc(worldname, pos1).add(1, 0, 1);
|
||||
final Location top1 = MainUtil.getPlotTopLoc(worldname, pos1);
|
||||
|
||||
final Location bot2 = MainUtil.getPlotBottomLoc(worldname, pos2).add(1, 0, 1);
|
||||
final Location top2 = MainUtil.getPlotTopLoc(worldname, pos2);
|
||||
swap(worldname, bot1, top1, bot2, top2);
|
||||
|
||||
final Plot plot1 = MainUtil.getPlot(worldname, pos1);
|
||||
final Plot plot2 = MainUtil.getPlot(worldname, pos2);
|
||||
|
||||
// TODO clear all entities
|
||||
|
||||
clearAllEntities(plot1.getBottom(), plot1.getTop());
|
||||
clearAllEntities(plot2.getBottom(), plot2.getTop());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void swap(final String worldname, final Location bot1, final Location top1, final Location bot2, final Location top2) {
|
||||
public void swap(final Location bot1, final Location top1, final Location bot2, final Location top2, final Runnable whenDone) {
|
||||
final RegionWrapper region1 = new RegionWrapper(bot1.getX(), top1.getX(), bot1.getZ(), top1.getZ());
|
||||
final RegionWrapper region2 = new RegionWrapper(bot2.getX(), top2.getX(), bot2.getZ(), top2.getZ());
|
||||
final World world = Bukkit.getWorld(bot1.getWorld());
|
||||
final World world1 = Bukkit.getWorld(bot1.getWorld());
|
||||
final World world2 = Bukkit.getWorld(bot2.getWorld());
|
||||
|
||||
final int relX = bot2.getX() - bot1.getX();
|
||||
final int relZ = bot2.getZ() - bot1.getZ();
|
||||
|
||||
for (int x = bot1.getX() >> 4; x <= (top1.getX() >> 4); x++) {
|
||||
for (int z = bot1.getZ() >> 4; z <= (top1.getZ() >> 4); z++) {
|
||||
final Chunk chunk1 = world.getChunkAt(x, z);
|
||||
final Chunk chunk2 = world.getChunkAt(x + (relX >> 4), z + (relZ >> 4));
|
||||
swapChunk(world, chunk1, chunk2, region1, region2);
|
||||
final Chunk chunk1 = world1.getChunkAt(x, z);
|
||||
final Chunk chunk2 = world2.getChunkAt(x + (relX >> 4), z + (relZ >> 4));
|
||||
swapChunk(world1, world2, chunk1, chunk2, region1, region2);
|
||||
}
|
||||
}
|
||||
// FIXME swap plots
|
||||
TaskManager.runTaskLater(whenDone, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -1041,8 +1019,8 @@ public class BukkitChunkManager extends ChunkManager {
|
||||
final int[] count = new int[5];
|
||||
final World world = BukkitUtil.getWorld(plot.world);
|
||||
|
||||
final Location bot = MainUtil.getPlotBottomLoc(plot.world, plot.id).add(1, 0, 1);
|
||||
final Location top = MainUtil.getPlotTopLoc(plot.world, plot.id);
|
||||
final Location bot = MainUtil.getPlotBottomLocAbs(plot.world, plot.id);
|
||||
final Location top = MainUtil.getPlotTopLocAbs(plot.world, plot.id);
|
||||
final int bx = bot.getX() >> 4;
|
||||
final int bz = bot.getZ() >> 4;
|
||||
|
||||
|
@ -22,6 +22,7 @@ import com.intellectualcrafters.plot.object.Location;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotAnalysis;
|
||||
import com.intellectualcrafters.plot.object.PlotBlock;
|
||||
import com.intellectualcrafters.plot.object.RegionWrapper;
|
||||
import com.intellectualcrafters.plot.object.RunnableVal;
|
||||
import com.intellectualcrafters.plot.util.ChunkManager;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
@ -31,7 +32,7 @@ import com.intellectualcrafters.plot.util.TaskManager;
|
||||
public class BukkitHybridUtils extends HybridUtils {
|
||||
|
||||
@Override
|
||||
public void analyzePlot(final Plot plot, final RunnableVal<PlotAnalysis> whenDone) {
|
||||
public void analyzeRegion(final String world, final RegionWrapper region, final RunnableVal<PlotAnalysis> whenDone) {
|
||||
// int diff, int variety, int verticies, int rotation, int height_sd
|
||||
/*
|
||||
* diff: compare to base by looping through all blocks
|
||||
@ -47,12 +48,12 @@ public class BukkitHybridUtils extends HybridUtils {
|
||||
TaskManager.runTaskAsync(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
final World world = Bukkit.getWorld(plot.world);
|
||||
final ChunkGenerator gen = world.getGenerator();
|
||||
final World worldObj = Bukkit.getWorld(world);
|
||||
final ChunkGenerator gen = worldObj.getGenerator();
|
||||
if (gen == null) {
|
||||
return;
|
||||
}
|
||||
final BiomeGrid base = new BiomeGrid() {
|
||||
final BiomeGrid nullBiomeGrid = new BiomeGrid() {
|
||||
@Override
|
||||
public void setBiome(final int a, final int b, final Biome c) {}
|
||||
|
||||
@ -61,8 +62,13 @@ public class BukkitHybridUtils extends HybridUtils {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
final Location bot = MainUtil.getPlotBottomLoc(plot.world, plot.id).add(1, 0, 1);
|
||||
final Location top = MainUtil.getPlotTopLoc(plot.world, plot.id);
|
||||
|
||||
final Location bot = new Location(world, region.minX, region.minY, region.minZ);
|
||||
final Location top = new Location(world, region.maxX, region.maxY, region.maxZ);
|
||||
|
||||
// final Location bot = MainUtil.getPlotBottomLoc(plot.world, plot.id).add(1, 0, 1);
|
||||
// final Location top = MainUtil.getPlotTopLoc(plot.world, plot.id);
|
||||
|
||||
final int bx = bot.getX();
|
||||
final int bz = bot.getZ();
|
||||
final int tx = top.getX();
|
||||
@ -87,10 +93,10 @@ public class BukkitHybridUtils extends HybridUtils {
|
||||
ChunkManager.chunkTask(bot, top, new RunnableVal<int[]>() {
|
||||
@Override
|
||||
public void run() {
|
||||
// TODO [chunkx, chunkz, pos1x, pos1z, pos2x, pos2z, isedge]
|
||||
// [chunkx, chunkz, pos1x, pos1z, pos2x, pos2z, isedge]
|
||||
final int X = value[0];
|
||||
final int Z = value[1];
|
||||
final short[][] result = gen.generateExtBlockSections(world, r, X, Z, base);
|
||||
final short[][] result = gen.generateExtBlockSections(worldObj, r, X, Z, nullBiomeGrid);
|
||||
final int xb = ((X) << 4) - bx;
|
||||
final int zb = ((Z) << 4) - bz;
|
||||
for (int i = 0; i < result.length; i++) {
|
||||
@ -202,21 +208,6 @@ public class BukkitHybridUtils extends HybridUtils {
|
||||
analysis.data_sd = (int) (MathMan.getSD(data, analysis.data));
|
||||
analysis.air_sd = (int) (MathMan.getSD(air, analysis.air));
|
||||
analysis.variety_sd = (int) (MathMan.getSD(variety, analysis.variety));
|
||||
|
||||
final List<Integer> result = new ArrayList<>();
|
||||
result.add(analysis.changes);
|
||||
result.add(analysis.faces);
|
||||
result.add(analysis.data);
|
||||
result.add(analysis.air);
|
||||
result.add(analysis.variety);
|
||||
|
||||
result.add(analysis.changes_sd);
|
||||
result.add(analysis.faces_sd);
|
||||
result.add(analysis.data_sd);
|
||||
result.add(analysis.air_sd);
|
||||
result.add(analysis.variety_sd);
|
||||
final Flag flag = new Flag(FlagManager.getFlag("analysis"), result);
|
||||
FlagManager.addPlotFlag(plot, flag);
|
||||
System.gc();
|
||||
System.gc();
|
||||
whenDone.value = analysis;
|
||||
@ -236,7 +227,7 @@ public class BukkitHybridUtils extends HybridUtils {
|
||||
public void run() {
|
||||
final int X = value[0];
|
||||
final int Z = value[1];
|
||||
world.loadChunk(X, Z);
|
||||
worldObj.loadChunk(X, Z);
|
||||
int minX;
|
||||
int minZ;
|
||||
int maxX;
|
||||
@ -272,14 +263,14 @@ public class BukkitHybridUtils extends HybridUtils {
|
||||
for (int z = minZ; z <= maxZ; z++) {
|
||||
final int zz = cbz + z;
|
||||
for (int y = 0; y < 256; y++) {
|
||||
final Block block = world.getBlockAt(xx, y, zz);
|
||||
final Block block = worldObj.getBlockAt(xx, y, zz);
|
||||
final int xr = xb + x;
|
||||
final int zr = zb + z;
|
||||
newblocks[y][xr][zr] = (short) block.getTypeId();
|
||||
}
|
||||
}
|
||||
}
|
||||
world.unloadChunkRequest(X, Z, true);
|
||||
worldObj.unloadChunkRequest(X, Z, true);
|
||||
}
|
||||
}, new Runnable() {
|
||||
@Override
|
||||
|
@ -1,140 +0,0 @@
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// PlotSquared - A plot manager and world generator for the Bukkit API /
|
||||
// Copyright (c) 2014 IntellectualSites/IntellectualCrafters /
|
||||
// /
|
||||
// This program is free software; you can redistribute it and/or modify /
|
||||
// it under the terms of the GNU General Public License as published by /
|
||||
// the Free Software Foundation; either version 3 of the License, or /
|
||||
// (at your option) any later version. /
|
||||
// /
|
||||
// This program is distributed in the hope that it will be useful, /
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of /
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /
|
||||
// GNU General Public License for more details. /
|
||||
// /
|
||||
// You should have received a copy of the GNU General Public License /
|
||||
// along with this program; if not, write to the Free Software Foundation, /
|
||||
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA /
|
||||
// /
|
||||
// You can contact us via: support@intellectualsites.com /
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
package com.plotsquared.bukkit.util;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotId;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||
|
||||
/**
|
||||
* Functions involving players, plots and locations.
|
||||
*/
|
||||
public class BukkitPlayerFunctions {
|
||||
|
||||
/*
|
||||
* =========== NOTICE ================
|
||||
* - We will try to move as many functions as we can out of this class and into the MainUtil class
|
||||
*/
|
||||
|
||||
/**
|
||||
* Clear a plot. Use null player if no player is present
|
||||
* @param player
|
||||
* @param world
|
||||
* @param plot
|
||||
* @param isDelete
|
||||
*/
|
||||
public static void clear(final Player player, final String world, final Plot plot, final boolean isDelete) {
|
||||
final long start = System.currentTimeMillis();
|
||||
final Runnable whenDone = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if ((player != null) && player.isOnline()) {
|
||||
MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.CLEARING_DONE, "" + (System.currentTimeMillis() - start));
|
||||
}
|
||||
}
|
||||
};
|
||||
if (!MainUtil.clearAsPlayer(plot, isDelete, whenDone)) {
|
||||
MainUtil.sendMessage(null, C.WAIT_FOR_TIMER);
|
||||
}
|
||||
}
|
||||
|
||||
public static String getPlayerName(final UUID uuid) {
|
||||
if (uuid == null) {
|
||||
return "unknown";
|
||||
}
|
||||
final String name = UUIDHandler.getName(uuid);
|
||||
if (name == null) {
|
||||
return "unknown";
|
||||
}
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param player player
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public static boolean isInPlot(final Player player) {
|
||||
return getCurrentPlot(player) != null;
|
||||
}
|
||||
|
||||
public static ArrayList<PlotId> getMaxPlotSelectionIds(final String world, PlotId pos1, PlotId pos2) {
|
||||
final Plot plot1 = PS.get().getPlot(world, pos1);
|
||||
final Plot plot2 = PS.get().getPlot(world, pos2);
|
||||
if (plot1 != null) {
|
||||
pos1 = MainUtil.getBottomPlot(plot1).id;
|
||||
}
|
||||
if (plot2 != null) {
|
||||
pos2 = MainUtil.getTopPlot(plot2).id;
|
||||
}
|
||||
final ArrayList<PlotId> myplots = new ArrayList<>();
|
||||
for (int x = pos1.x; x <= pos2.x; x++) {
|
||||
for (int y = pos1.y; y <= pos2.y; y++) {
|
||||
myplots.add(new PlotId(x, y));
|
||||
}
|
||||
}
|
||||
return myplots;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the plot a player is currently in.
|
||||
*
|
||||
* @param player
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public static Plot getCurrentPlot(final Player player) {
|
||||
if (!PS.get().isPlotWorld(player.getWorld().getName())) {
|
||||
return null;
|
||||
}
|
||||
final PlotId id = MainUtil.getPlotId(BukkitUtil.getLocation(player));
|
||||
final String world = player.getWorld().getName();
|
||||
if (id == null) {
|
||||
return null;
|
||||
}
|
||||
return MainUtil.getPlot(world, id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the plots for a player
|
||||
*
|
||||
* @param plr
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public static Set<Plot> getPlayerPlots(final String world, final Player plr) {
|
||||
final Set<Plot> p = PS.get().getPlots(world, plr.getName());
|
||||
if (p == null) {
|
||||
return new HashSet<>();
|
||||
}
|
||||
return p;
|
||||
}
|
||||
}
|
@ -20,11 +20,14 @@
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
package com.plotsquared.bukkit.util;
|
||||
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
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;
|
||||
@ -41,8 +44,13 @@ import com.intellectualcrafters.jnbt.StringTag;
|
||||
import com.intellectualcrafters.jnbt.Tag;
|
||||
import com.intellectualcrafters.plot.object.ChunkLoc;
|
||||
import com.intellectualcrafters.plot.object.Location;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotId;
|
||||
import com.intellectualcrafters.plot.object.RegionWrapper;
|
||||
import com.intellectualcrafters.plot.object.RunnableVal;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.SchematicHandler;
|
||||
import com.intellectualcrafters.plot.util.StringMan;
|
||||
import com.intellectualcrafters.plot.util.TaskManager;
|
||||
import com.plotsquared.object.schematic.StateWrapper;
|
||||
|
||||
@ -53,32 +61,21 @@ import com.plotsquared.object.schematic.StateWrapper;
|
||||
|
||||
*/
|
||||
public class BukkitSchematicHandler extends SchematicHandler {
|
||||
|
||||
@Override
|
||||
|
||||
@Override
|
||||
public void getCompoundTag(final String world, final Set<RegionWrapper> regions, final RunnableVal<CompoundTag> whenDone) {
|
||||
// async
|
||||
// async
|
||||
TaskManager.runTaskAsync(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
// Main positions
|
||||
final int p1x = pos1.getX();
|
||||
final int p1z = pos1.getZ();
|
||||
final int p2x = pos2.getX();
|
||||
final int p2z = pos2.getZ();
|
||||
final int bcx = p1x >> 4;
|
||||
final int bcz = p1z >> 4;
|
||||
final int tcx = p2x >> 4;
|
||||
final int tcz = p2z >> 4;
|
||||
final int sy = pos1.getY();
|
||||
final int ey = pos2.getY();
|
||||
|
||||
final int width = (pos2.getX() - pos1.getX()) + 1;
|
||||
public void run() {
|
||||
// Main positions
|
||||
Location[] corners = MainUtil.getCorners(world, regions);
|
||||
final Location bot = corners[0];
|
||||
final Location top = corners[1];
|
||||
|
||||
final int width = (top.getX() - bot.getX()) + 1;
|
||||
final int height = (top.getY() - bot.getY()) + 1;
|
||||
final int length = (top.getZ() - bot.getZ()) + 1;
|
||||
// Main Schematic tag
|
||||
// Main Schematic tag
|
||||
final HashMap<String, Tag> schematic = new HashMap<>();
|
||||
schematic.put("Width", new ShortTag("Width", (short) width));
|
||||
@ -89,214 +86,16 @@ public class BukkitSchematicHandler extends SchematicHandler {
|
||||
schematic.put("WEOriginY", new IntTag("WEOriginY", 0));
|
||||
schematic.put("WEOriginZ", new IntTag("WEOriginZ", 0));
|
||||
schematic.put("WEOffsetX", new IntTag("WEOffsetX", 0));
|
||||
schematic.put("WEOffsetY", new IntTag("WEOffsetY", 0));
|
||||
schematic.put("WEOffsetY", new IntTag("WEOffsetY", 0));
|
||||
schematic.put("WEOffsetZ", new IntTag("WEOffsetZ", 0));
|
||||
// Arrays of data types
|
||||
final List<Tag> tileEntities = new ArrayList<Tag>();
|
||||
final byte[] blocks = new byte[width * height * length];
|
||||
final byte[] blockData = new byte[width * height * length];
|
||||
|
||||
// Generate list of chunks
|
||||
final ArrayList<ChunkLoc> chunks = new ArrayList<ChunkLoc>();
|
||||
for (int x = bcx; x <= tcx; x++) {
|
||||
for (int z = bcz; z <= tcz; z++) {
|
||||
chunks.add(new ChunkLoc(x, z));
|
||||
}
|
||||
}
|
||||
|
||||
final byte[] blocks = new byte[width * height * length];
|
||||
final byte[] blockData = new byte[width * height * length];
|
||||
// Queue
|
||||
final ArrayDeque<RegionWrapper> queue = new ArrayDeque<>(regions);
|
||||
TaskManager.runTask(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
final long start = System.currentTimeMillis();
|
||||
while ((chunks.size() > 0) && ((System.currentTimeMillis() - start) < 20)) {
|
||||
// save schematics
|
||||
final ChunkLoc chunk = chunks.remove(0);
|
||||
|
||||
final Chunk bc = worldObj.getChunkAt(chunk.x, chunk.z);
|
||||
if (!bc.load(false)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
final int X = chunk.x;
|
||||
final int Z = chunk.z;
|
||||
int xxb = X << 4;
|
||||
int zzb = Z << 4;
|
||||
int xxt = xxb + 15;
|
||||
int zzt = zzb + 15;
|
||||
|
||||
if (X == bcx) {
|
||||
xxb = p1x;
|
||||
}
|
||||
if (X == tcx) {
|
||||
xxt = p2x;
|
||||
}
|
||||
if (Z == bcz) {
|
||||
zzb = p1z;
|
||||
}
|
||||
if (Z == tcz) {
|
||||
zzt = p2z;
|
||||
}
|
||||
for (int y = sy; y <= Math.min(255, ey); y++) {
|
||||
final int ry = y - sy;
|
||||
final int i1 = (ry * width * length);
|
||||
for (int z = zzb; z <= zzt; z++) {
|
||||
final int rz = z - p1z;
|
||||
final int i2 = i1 + (rz * width);
|
||||
for (int x = xxb; x <= xxt; x++) {
|
||||
final int rx = x - p1x;
|
||||
final int index = i2 + rx;
|
||||
final Block block = worldObj.getBlockAt(x, y, z);
|
||||
final int id = block.getTypeId();
|
||||
switch (id) {
|
||||
case 0:
|
||||
case 2:
|
||||
case 4:
|
||||
case 13:
|
||||
case 14:
|
||||
case 15:
|
||||
case 20:
|
||||
case 21:
|
||||
case 22:
|
||||
case 24:
|
||||
case 30:
|
||||
case 32:
|
||||
case 37:
|
||||
case 39:
|
||||
case 40:
|
||||
case 41:
|
||||
case 42:
|
||||
case 45:
|
||||
case 46:
|
||||
case 47:
|
||||
case 48:
|
||||
case 49:
|
||||
case 50:
|
||||
case 51:
|
||||
case 55:
|
||||
case 56:
|
||||
case 57:
|
||||
case 58:
|
||||
case 60:
|
||||
case 7:
|
||||
case 8:
|
||||
case 9:
|
||||
case 10:
|
||||
case 11:
|
||||
case 73:
|
||||
case 74:
|
||||
case 75:
|
||||
case 76:
|
||||
case 78:
|
||||
case 79:
|
||||
case 80:
|
||||
case 81:
|
||||
case 82:
|
||||
case 83:
|
||||
case 85:
|
||||
case 87:
|
||||
case 88:
|
||||
case 101:
|
||||
case 102:
|
||||
case 103:
|
||||
case 110:
|
||||
case 112:
|
||||
case 113:
|
||||
case 121:
|
||||
case 122:
|
||||
case 129:
|
||||
case 133:
|
||||
case 165:
|
||||
case 166:
|
||||
case 169:
|
||||
case 170:
|
||||
case 172:
|
||||
case 173:
|
||||
case 174:
|
||||
case 181:
|
||||
case 182:
|
||||
case 188:
|
||||
case 189:
|
||||
case 190:
|
||||
case 191:
|
||||
case 192: {
|
||||
break;
|
||||
}
|
||||
case 54:
|
||||
case 130:
|
||||
case 142:
|
||||
case 27:
|
||||
case 137:
|
||||
case 52:
|
||||
case 154:
|
||||
case 84:
|
||||
case 25:
|
||||
case 144:
|
||||
case 138:
|
||||
case 176:
|
||||
case 177:
|
||||
case 63:
|
||||
case 68:
|
||||
case 323:
|
||||
case 117:
|
||||
case 116:
|
||||
case 28:
|
||||
case 66:
|
||||
case 157:
|
||||
case 61:
|
||||
case 62:
|
||||
case 140:
|
||||
case 146:
|
||||
case 149:
|
||||
case 150:
|
||||
case 158:
|
||||
case 23:
|
||||
case 123:
|
||||
case 124:
|
||||
case 29:
|
||||
case 33:
|
||||
case 151:
|
||||
case 178: {
|
||||
// TODO implement fully
|
||||
final BlockState state = block.getState();
|
||||
if (state != null) {
|
||||
final StateWrapper wrapper = new StateWrapper(state);
|
||||
final CompoundTag rawTag = wrapper.getTag();
|
||||
if (rawTag != null) {
|
||||
final Map<String, Tag> values = new HashMap<String, Tag>();
|
||||
for (final Entry<String, Tag> entry : rawTag.getValue().entrySet()) {
|
||||
values.put(entry.getKey(), entry.getValue());
|
||||
}
|
||||
values.put("id", new StringTag("id", wrapper.getId()));
|
||||
values.put("x", new IntTag("x", x));
|
||||
values.put("y", new IntTag("y", y));
|
||||
values.put("z", new IntTag("z", z));
|
||||
final CompoundTag tileEntityTag = new CompoundTag(values);
|
||||
tileEntities.add(tileEntityTag);
|
||||
}
|
||||
}
|
||||
}
|
||||
default: {
|
||||
blockData[index] = block.getData();
|
||||
}
|
||||
}
|
||||
// For optimization reasons, we are not supporting custom data types
|
||||
// Especially since the most likely reason beyond this range is modded servers in which the blocks have NBT
|
||||
// if (id > 255) {
|
||||
// if (addBlocks == null) {
|
||||
// addBlocks = new byte[(blocks.length >> 1) + 1];
|
||||
// }
|
||||
// addBlocks[index >> 1] = (byte) (((index & 1) == 0) ? (addBlocks[index >> 1] & 0xF0) | ((id >> 8) & 0xF) : (addBlocks[index >> 1] & 0xF) | (((id >> 8) & 0xF) << 4));
|
||||
// }
|
||||
blocks[index] = (byte) id;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
if (chunks.size() != 0) {
|
||||
@Override
|
||||
public void run() {
|
||||
if (queue.size() == 0) {
|
||||
TaskManager.runTaskAsync(new Runnable() {
|
||||
@ -310,7 +109,226 @@ public class BukkitSchematicHandler extends SchematicHandler {
|
||||
TaskManager.runTask(whenDone);
|
||||
System.gc();
|
||||
System.gc();
|
||||
}
|
||||
});
|
||||
return;
|
||||
}
|
||||
final Runnable regionTask = this;
|
||||
RegionWrapper region = queue.poll();
|
||||
Location pos1 = new Location(world, region.minX, region.minY, region.minZ);
|
||||
Location pos2 = new Location(world, region.maxX, region.maxY, region.maxZ);
|
||||
final int bx = bot.getX();
|
||||
final int bz = bot.getZ();
|
||||
final int p1x = pos1.getX();
|
||||
final int p1z = pos1.getZ();
|
||||
final int p2x = pos2.getX();
|
||||
final int p2z = pos2.getZ();
|
||||
final int bcx = p1x >> 4;
|
||||
final int bcz = p1z >> 4;
|
||||
final int tcx = p2x >> 4;
|
||||
final int tcz = p2z >> 4;
|
||||
final int sy = pos1.getY();
|
||||
final int ey = pos2.getY();
|
||||
// Generate list of chunks
|
||||
final ArrayList<ChunkLoc> chunks = new ArrayList<ChunkLoc>();
|
||||
for (int x = bcx; x <= tcx; x++) {
|
||||
for (int z = bcz; z <= tcz; z++) {
|
||||
chunks.add(new ChunkLoc(x, z));
|
||||
}
|
||||
}
|
||||
final World worldObj = Bukkit.getWorld(world);
|
||||
// Main thread
|
||||
TaskManager.runTask(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
final long start = System.currentTimeMillis();
|
||||
while ((chunks.size() > 0) && ((System.currentTimeMillis() - start) < 20)) {
|
||||
// save schematics
|
||||
final ChunkLoc chunk = chunks.remove(0);
|
||||
final Chunk bc = worldObj.getChunkAt(chunk.x, chunk.z);
|
||||
if (!bc.load(false)) {
|
||||
continue;
|
||||
}
|
||||
final int X = chunk.x;
|
||||
final int Z = chunk.z;
|
||||
int xxb = X << 4;
|
||||
int zzb = Z << 4;
|
||||
int xxt = xxb + 15;
|
||||
int zzt = zzb + 15;
|
||||
|
||||
if (X == bcx) {
|
||||
xxb = p1x;
|
||||
}
|
||||
if (X == tcx) {
|
||||
xxt = p2x;
|
||||
}
|
||||
if (Z == bcz) {
|
||||
zzb = p1z;
|
||||
}
|
||||
if (Z == tcz) {
|
||||
zzt = p2z;
|
||||
}
|
||||
for (int y = sy; y <= Math.min(255, ey); y++) {
|
||||
final int ry = y - sy;
|
||||
final int i1 = (ry * width * length);
|
||||
for (int z = zzb; z <= zzt; z++) {
|
||||
final int rz = z - bz;
|
||||
final int i2 = i1 + (rz * width);
|
||||
for (int x = xxb; x <= xxt; x++) {
|
||||
final int rx = x - bx;
|
||||
final int index = i2 + rx;
|
||||
final Block block = worldObj.getBlockAt(x, y, z);
|
||||
final int id = block.getTypeId();
|
||||
switch (id) {
|
||||
case 0:
|
||||
case 2:
|
||||
case 4:
|
||||
case 13:
|
||||
case 14:
|
||||
case 15:
|
||||
case 20:
|
||||
case 21:
|
||||
case 22:
|
||||
case 24:
|
||||
case 30:
|
||||
case 32:
|
||||
case 37:
|
||||
case 39:
|
||||
case 40:
|
||||
case 41:
|
||||
case 42:
|
||||
case 45:
|
||||
case 46:
|
||||
case 47:
|
||||
case 48:
|
||||
case 49:
|
||||
case 50:
|
||||
case 51:
|
||||
case 55:
|
||||
case 56:
|
||||
case 57:
|
||||
case 58:
|
||||
case 60:
|
||||
case 7:
|
||||
case 8:
|
||||
case 9:
|
||||
case 10:
|
||||
case 11:
|
||||
case 73:
|
||||
case 74:
|
||||
case 75:
|
||||
case 76:
|
||||
case 78:
|
||||
case 79:
|
||||
case 80:
|
||||
case 81:
|
||||
case 82:
|
||||
case 83:
|
||||
case 85:
|
||||
case 87:
|
||||
case 88:
|
||||
case 101:
|
||||
case 102:
|
||||
case 103:
|
||||
case 110:
|
||||
case 112:
|
||||
case 113:
|
||||
case 121:
|
||||
case 122:
|
||||
case 129:
|
||||
case 133:
|
||||
case 165:
|
||||
case 166:
|
||||
case 169:
|
||||
case 170:
|
||||
case 172:
|
||||
case 173:
|
||||
case 174:
|
||||
case 181:
|
||||
case 182:
|
||||
case 188:
|
||||
case 189:
|
||||
case 190:
|
||||
case 191:
|
||||
case 192: {
|
||||
break;
|
||||
}
|
||||
case 54:
|
||||
case 130:
|
||||
case 142:
|
||||
case 27:
|
||||
case 137:
|
||||
case 52:
|
||||
case 154:
|
||||
case 84:
|
||||
case 25:
|
||||
case 144:
|
||||
case 138:
|
||||
case 176:
|
||||
case 177:
|
||||
case 63:
|
||||
case 68:
|
||||
case 323:
|
||||
case 117:
|
||||
case 116:
|
||||
case 28:
|
||||
case 66:
|
||||
case 157:
|
||||
case 61:
|
||||
case 62:
|
||||
case 140:
|
||||
case 146:
|
||||
case 149:
|
||||
case 150:
|
||||
case 158:
|
||||
case 23:
|
||||
case 123:
|
||||
case 124:
|
||||
case 29:
|
||||
case 33:
|
||||
case 151:
|
||||
case 178: {
|
||||
// TODO implement fully
|
||||
final BlockState state = block.getState();
|
||||
if (state != null) {
|
||||
final StateWrapper wrapper = new StateWrapper(state);
|
||||
final CompoundTag rawTag = wrapper.getTag();
|
||||
if (rawTag != null) {
|
||||
final Map<String, Tag> values = new HashMap<String, Tag>();
|
||||
for (final Entry<String, Tag> entry : rawTag.getValue().entrySet()) {
|
||||
values.put(entry.getKey(), entry.getValue());
|
||||
}
|
||||
values.put("id", new StringTag("id", wrapper.getId()));
|
||||
values.put("x", new IntTag("x", x));
|
||||
values.put("y", new IntTag("y", y));
|
||||
values.put("z", new IntTag("z", z));
|
||||
final CompoundTag tileEntityTag = new CompoundTag(values);
|
||||
tileEntities.add(tileEntityTag);
|
||||
}
|
||||
}
|
||||
}
|
||||
default: {
|
||||
blockData[index] = block.getData();
|
||||
}
|
||||
}
|
||||
// For optimization reasons, we are not supporting custom data types
|
||||
// Especially since the most likely reason beyond this range is modded servers in which the blocks have NBT
|
||||
// if (id > 255) {
|
||||
// if (addBlocks == null) {
|
||||
// addBlocks = new byte[(blocks.length >> 1) + 1];
|
||||
// }
|
||||
// addBlocks[index >> 1] = (byte) (((index & 1) == 0) ? (addBlocks[index >> 1] & 0xF0) | ((id >> 8) & 0xF) : (addBlocks[index >> 1] & 0xF) | (((id >> 8) & 0xF) << 4));
|
||||
// }
|
||||
blocks[index] = (byte) id;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (chunks.size() != 0) {
|
||||
TaskManager.runTaskLater(this, 1);
|
||||
} else {
|
||||
regionTask.run();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -64,7 +64,6 @@ public class SetBlockFast extends BukkitSetBlockManager {
|
||||
TaskManager.runTaskRepeat(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
public void run() {
|
||||
update(toUpdate.values());
|
||||
toUpdate = new HashMap<>();
|
||||
|
@ -29,6 +29,6 @@ public class SetBlockSlow extends BukkitSetBlockManager {
|
||||
|
||||
@Override
|
||||
public void update(final Collection<Chunk> chunks) {
|
||||
// TODO nothing
|
||||
// nothing
|
||||
}
|
||||
}
|
||||
|
@ -1,35 +0,0 @@
|
||||
package com.plotsquared.bukkit.util;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
import com.intellectualcrafters.plot.object.Location;
|
||||
import com.intellectualcrafters.plot.object.PlotId;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.plotsquared.bukkit.BukkitMain;
|
||||
import com.sk89q.worldedit.CuboidClipboard;
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.bukkit.BukkitWorld;
|
||||
|
||||
public class WorldEditSchematic {
|
||||
public void saveSchematic(final String file, final String world, final PlotId id) {
|
||||
final Location bot = MainUtil.getPlotBottomLoc(world, id).add(1, 0, 1);
|
||||
final Location top = MainUtil.getPlotTopLoc(world, id);
|
||||
final Vector size = new Vector((top.getX() - bot.getX()) + 1, top.getY() - bot.getY() - 1, (top.getZ() - bot.getZ()) + 1);
|
||||
final Vector origin = new Vector(bot.getX(), bot.getY(), bot.getZ());
|
||||
final CuboidClipboard clipboard = new CuboidClipboard(size, origin);
|
||||
new Vector(bot.getX(), bot.getY(), bot.getZ());
|
||||
new Vector(top.getX(), top.getY(), top.getZ());
|
||||
final EditSession session = BukkitMain.worldEdit.getWorldEdit().getEditSessionFactory().getEditSession(new BukkitWorld(Bukkit.getWorld(world)), 999999999);
|
||||
clipboard.copy(session);
|
||||
try {
|
||||
clipboard.saveSchematic(new File(file));
|
||||
MainUtil.sendMessage(null, "&7 - &a success: " + id);
|
||||
} catch (final Exception e) {
|
||||
e.printStackTrace();
|
||||
MainUtil.sendMessage(null, "&7 - Failed to save &c" + id);
|
||||
}
|
||||
}
|
||||
}
|
@ -60,7 +60,7 @@ public class PlotListener {
|
||||
}
|
||||
final Plot last = (Plot) pp.getMeta("lastplot");
|
||||
if ((last != null) && !last.id.equals(plot.id)) {
|
||||
plotExit(pp, last);
|
||||
plotExit(pp, last);
|
||||
}
|
||||
pp.setMeta("lastplot", MainUtil.getPlot(plot));
|
||||
EventUtil.manager.callEntry(pp, plot);
|
||||
|
@ -47,9 +47,7 @@ public class WEManager {
|
||||
continue;
|
||||
}
|
||||
if (Settings.WE_ALLOW_HELPER ? plot.isAdded(uuid) : (plot.isOwner(uuid) || plot.getTrusted().contains(uuid))) {
|
||||
final Location pos1 = MainUtil.getPlotBottomLoc(plot.world, plot.id).add(1, 0, 1);
|
||||
final Location pos2 = MainUtil.getPlotTopLoc(plot.world, plot.id);
|
||||
regions.add(new RegionWrapper(pos1.getX(), pos2.getX(), pos1.getY(), pos2.getY(), pos1.getZ(), pos2.getZ()));
|
||||
regions.addAll(MainUtil.getRegions(plot));
|
||||
}
|
||||
}
|
||||
return regions;
|
||||
|
@ -61,7 +61,7 @@ public class AugmentedPopulator implements Populator {
|
||||
this.b = b;
|
||||
o = (plotworld.TERRAIN == 1) || (plotworld.TERRAIN == 2);
|
||||
if (cluster != null) {
|
||||
final Location bl = manager.getPlotBottomLocAbs(plotworld, cluster.getP1());
|
||||
final Location bl = manager.getPlotBottomLocAbs(plotworld, cluster.getP1()).subtract(1, 0, 1);
|
||||
final Location tl = manager.getPlotTopLocAbs(plotworld, cluster.getP2()).add(1, 0, 1);
|
||||
bx = bl.getX();
|
||||
bz = bl.getZ();
|
||||
|
@ -27,9 +27,6 @@ public class SpongeBasicGen extends SpongePlotGenerator {
|
||||
|
||||
/**
|
||||
* Some generator specific variables (implementation dependent)
|
||||
*
|
||||
* TODO USE THESE
|
||||
*
|
||||
*/
|
||||
public int plotsize;
|
||||
public int pathsize;
|
||||
|
@ -93,6 +93,7 @@ public class MainListener {
|
||||
* - HangingBreakEvent
|
||||
* - Liquid flow
|
||||
* - PVP
|
||||
* - block dispense
|
||||
* - PVE
|
||||
* - VehicleDestroy
|
||||
* - Projectile
|
||||
@ -164,7 +165,7 @@ public class MainListener {
|
||||
return;
|
||||
}
|
||||
if (mobs == null) {
|
||||
mobs = ChunkManager.manager.countEntities(plot);
|
||||
mobs = MainUtil.countEntities(plot);
|
||||
}
|
||||
if (mobs[3] >= cap) {
|
||||
event.setCancelled(true);
|
||||
@ -180,7 +181,7 @@ public class MainListener {
|
||||
return;
|
||||
}
|
||||
if (mobs == null) {
|
||||
mobs = ChunkManager.manager.countEntities(plot);
|
||||
mobs = MainUtil.countEntities(plot);
|
||||
}
|
||||
if (mobs[1] >= cap) {
|
||||
event.setCancelled(true);
|
||||
@ -197,7 +198,7 @@ public class MainListener {
|
||||
return;
|
||||
}
|
||||
if (mobs == null) {
|
||||
mobs = ChunkManager.manager.countEntities(plot);
|
||||
mobs = MainUtil.countEntities(plot);
|
||||
}
|
||||
if (mobs[2] >= cap) {
|
||||
event.setCancelled(true);
|
||||
@ -216,7 +217,7 @@ public class MainListener {
|
||||
return;
|
||||
}
|
||||
if (mobs == null) {
|
||||
mobs = ChunkManager.manager.countEntities(plot);
|
||||
mobs = MainUtil.countEntities(plot);
|
||||
}
|
||||
if (mobs[4] >= cap) {
|
||||
event.setCancelled(true);
|
||||
@ -232,7 +233,7 @@ public class MainListener {
|
||||
return;
|
||||
}
|
||||
if (mobs == null) {
|
||||
mobs = ChunkManager.manager.countEntities(plot);
|
||||
mobs = MainUtil.countEntities(plot);
|
||||
}
|
||||
if (mobs[0] >= cap) {
|
||||
event.setCancelled(true);
|
||||
@ -266,7 +267,6 @@ public class MainListener {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
// TODO
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
@ -519,7 +519,7 @@ public class MainListener {
|
||||
}
|
||||
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_DESTROY_OTHER);
|
||||
event.setCancelled(true);
|
||||
} else if (Settings.DONE_RESTRICTS_BUILDING && plot.getSettings().flags.containsKey("done")) {
|
||||
} else if (Settings.DONE_RESTRICTS_BUILDING && plot.getFlags().containsKey("done")) {
|
||||
if (!Permissions.hasPermission(pp, C.PERMISSION_ADMIN_BUILD_OTHER)) {
|
||||
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_BUILD_OTHER);
|
||||
event.setCancelled(true);
|
||||
@ -570,7 +570,7 @@ public class MainListener {
|
||||
}
|
||||
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_DESTROY_OTHER);
|
||||
event.setCancelled(true);
|
||||
} else if (Settings.DONE_RESTRICTS_BUILDING && plot.getSettings().flags.containsKey("done")) {
|
||||
} else if (Settings.DONE_RESTRICTS_BUILDING && plot.getFlags().containsKey("done")) {
|
||||
if (!Permissions.hasPermission(pp, C.PERMISSION_ADMIN_BUILD_OTHER)) {
|
||||
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_BUILD_OTHER);
|
||||
event.setCancelled(true);
|
||||
@ -658,9 +658,6 @@ public class MainListener {
|
||||
final UUID uuid = pp.getUUID();
|
||||
UUIDHandler.add(name, uuid);
|
||||
ExpireManager.dates.put(uuid, System.currentTimeMillis());
|
||||
|
||||
// TODO worldedit bypass
|
||||
|
||||
if ((PS.get().update != null) && pp.hasPermission("plots.admin")) {
|
||||
TaskManager.runTaskLater(new Runnable() {
|
||||
@Override
|
||||
@ -740,7 +737,7 @@ public class MainListener {
|
||||
final Plot plot = MainUtil.getPlot(worldname, id);
|
||||
if (!PlotListener.plotEntry(pp, plot)) {
|
||||
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_ENTRY_DENIED);
|
||||
if (!plot.equals(MainUtil.getPlot(SpongeUtil.getLocation(worldname, from)))) {
|
||||
if (!plot.getBasePlot(false).equals(MainUtil.getPlot(SpongeUtil.getLocation(worldname, from)))) {
|
||||
event.setNewLocation(from);
|
||||
} else {
|
||||
event.setNewLocation(world.getSpawnLocation());
|
||||
@ -964,9 +961,6 @@ public class MainListener {
|
||||
|
||||
player.deleteMeta("location");
|
||||
player.deleteMeta("lastplot");
|
||||
|
||||
// TODO worldedit mask
|
||||
|
||||
if (Settings.PERMISSION_CACHING) {
|
||||
((SpongePlayer) player).hasPerm = new HashSet<>();
|
||||
((SpongePlayer) player).noPerm = new HashSet<>();
|
||||
|
@ -1,7 +1,9 @@
|
||||
package com.plotsquared.sponge.util;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.spongepowered.api.entity.Entity;
|
||||
import org.spongepowered.api.entity.living.Living;
|
||||
@ -32,8 +34,8 @@ public class SpongeChunkManager extends ChunkManager {
|
||||
|
||||
@Override
|
||||
public int[] countEntities(final Plot plot) {
|
||||
final Location pos1 = plot.getBottom();
|
||||
final Location pos2 = plot.getTop();
|
||||
final Location pos1 = plot.getBottomAbs();
|
||||
final Location pos2 = plot.getTopAbs();
|
||||
|
||||
final String worldname = pos1.getWorld();
|
||||
final World world = SpongeUtil.getWorld(worldname);
|
||||
@ -87,8 +89,8 @@ public class SpongeChunkManager extends ChunkManager {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ChunkLoc> getChunkChunks(final String world) {
|
||||
final ArrayList<ChunkLoc> chunks = new ArrayList<ChunkLoc>();
|
||||
public Set<ChunkLoc> getChunkChunks(final String world) {
|
||||
final HashSet<ChunkLoc> chunks = new HashSet<ChunkLoc>();
|
||||
final World worldObj = SpongeUtil.getWorld(world);
|
||||
final ChunkDataStream storage = worldObj.getWorldStorage().getGeneratedChunks();
|
||||
while (storage.hasNext()) {
|
||||
|
Reference in New Issue
Block a user