Potential fixes

Fixes #712
Fixes #711
Fixes #707
Fixes #705
Fixes #702
Fixes #698
Fixes #697
Fixes #694
Fixes #717
This commit is contained in:
Jesse Boyd 2015-11-15 13:30:52 +11:00
parent c32edfe0ee
commit 93a7b2cace
23 changed files with 290 additions and 278 deletions

View File

@ -90,7 +90,7 @@ import com.sk89q.worldedit.WorldEdit;
public class PS {
// protected static:
public static PS instance;
private static PS instance;
// private final:
private final HashMap<String, PlotWorld> plotworlds = new HashMap<>();

View File

@ -20,7 +20,6 @@
////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.plot.commands;
import java.util.List;
import java.util.Set;
import com.intellectualcrafters.plot.PS;
@ -32,23 +31,18 @@ import com.intellectualcrafters.plot.object.PlotManager;
import com.intellectualcrafters.plot.object.PlotPlayer;
import com.intellectualcrafters.plot.util.ChunkManager;
import com.intellectualcrafters.plot.util.MainUtil;
import com.plotsquared.general.commands.Argument;
import com.plotsquared.general.commands.CommandDeclaration;
@CommandDeclaration(
command = "regenallroads",
description = "Regenerate all roads in the map using the set road schematic",
aliases = { "rgar" },
usage = "/plot regenallroads <world>",
usage = "/plot regenallroads <world> [height]",
category = CommandCategory.DEBUG,
requiredType = RequiredType.CONSOLE,
permission = "plots.regenallroads")
public class RegenAllRoads extends SubCommand {
public RegenAllRoads() {
requiredArguments = new Argument[] { Argument.String };
}
@Override
public boolean onCommand(final PlotPlayer plr, final String[] args) {
int height = 0;
@ -60,6 +54,9 @@ public class RegenAllRoads extends SubCommand {
MainUtil.sendMessage(plr, C.COMMAND_SYNTAX, "/plot regenallroads <world> [height]");
return false;
}
} else {
MainUtil.sendMessage(plr, C.COMMAND_SYNTAX, "/plot regenallroads <world> [height]");
return false;
}
final String name = args[0];
final PlotManager manager = PS.get().getPlotManager(name);

View File

@ -31,7 +31,7 @@ import com.plotsquared.general.commands.CommandDeclaration;
@CommandDeclaration(
command = "update",
permission = "plots.admin",
permission = "plots.admin.command.update",
description = "Update PlotSquared",
usage = "/plot update",
requiredType = RequiredType.NONE,

View File

@ -90,6 +90,7 @@ public enum C {
PERMISSION_ADMIN_INTERACT_UNOWNED("plots.admin.interact.unowned", "static.permissions"),
PERMISSION_ADMIN_INTERACT_OTHER("plots.admin.interact.other", "static.permissions"),
PERMISSION_ADMIN_BUILD_HEIGHTLIMIT("plots.admin.build.heightlimit", "static.permissions"),
PERMISSION_ADMIN_UPDATE("plots.admin.command.update", "static.permissions"),
/*
* Static console
*/

View File

@ -575,9 +575,9 @@ public class SQLManager implements AbstractDB {
stmt.setInt((i * 5) + 1, plot.id.x);
stmt.setInt((i * 5) + 2, plot.id.y);
try {
stmt.setString((i * 4) + 3, plot.owner.toString());
stmt.setString((i * 5) + 3, plot.owner.toString());
} catch (final Exception e) {
stmt.setString((i * 4) + 3, everyone.toString());
stmt.setString((i * 5) + 3, everyone.toString());
}
stmt.setString((i * 5) + 4, plot.world);
stmt.setTimestamp((i * 5) + 5, new Timestamp(plot.getTimestamp()));

View File

@ -11,7 +11,6 @@ import com.intellectualcrafters.plot.object.PlotWorld;
import com.intellectualcrafters.plot.object.RegionWrapper;
import com.intellectualcrafters.plot.util.ChunkManager;
import com.intellectualcrafters.plot.util.MainUtil;
import com.intellectualcrafters.plot.util.StringMan;
/**
* A plot manager with a square grid layout, with square shaped plots
@ -93,83 +92,87 @@ public abstract class SquarePlotManager extends GridPlotManager {
@Override
public PlotId getPlotId(final PlotWorld plotworld, int x, final int y, int z) {
final SquarePlotWorld dpw = ((SquarePlotWorld) plotworld);
if (plotworld == null) {
return null;
}
x -= dpw.ROAD_OFFSET_X;
z -= dpw.ROAD_OFFSET_Z;
final int size = dpw.PLOT_WIDTH + dpw.ROAD_WIDTH;
int pathWidthLower;
final int end;
if (dpw.ROAD_WIDTH == 0) {
pathWidthLower = -1;
end = dpw.PLOT_WIDTH;
} else {
if ((dpw.ROAD_WIDTH % 2) == 0) {
pathWidthLower = (dpw.ROAD_WIDTH / 2) - 1;
} else {
pathWidthLower = dpw.ROAD_WIDTH / 2;
try {
final SquarePlotWorld dpw = ((SquarePlotWorld) plotworld);
if (plotworld == null) {
return null;
}
end = pathWidthLower + dpw.PLOT_WIDTH;
x -= dpw.ROAD_OFFSET_X;
z -= dpw.ROAD_OFFSET_Z;
final int size = dpw.PLOT_WIDTH + dpw.ROAD_WIDTH;
int pathWidthLower;
final int end;
if (dpw.ROAD_WIDTH == 0) {
pathWidthLower = -1;
end = dpw.PLOT_WIDTH;
} else {
if ((dpw.ROAD_WIDTH % 2) == 0) {
pathWidthLower = (dpw.ROAD_WIDTH / 2) - 1;
} else {
pathWidthLower = dpw.ROAD_WIDTH / 2;
}
end = pathWidthLower + dpw.PLOT_WIDTH;
}
int dx;
int dz;
int rx;
int rz;
if (x < 0) {
dx = (x / size);
rx = size + (x % size);
} else {
dx = (x / size) + 1;
rx = (x % size);
}
if (z < 0) {
dz = (z / size);
rz = size + (z % size);
} else {
dz = (z / size) + 1;
rz = (z % size);
}
PlotId id = new PlotId(dx, dz);
boolean[] merged = new boolean[] { (rz <= pathWidthLower), (rx > end), (rz > end), (rx <= pathWidthLower) };
int hash = MainUtil.hash(merged);
// Not merged, and no need to check if it is
if (hash == 0) {
return id;
}
Plot plot = PS.get().getPlot(plotworld.worldname, id);
// Not merged, and standing on road
if (plot == null) {
return null;
}
switch (hash) {
case 8:
// north
return plot.getMerged(0) ? id : null;
case 4:
// east
return plot.getMerged(1) ? id : null;
case 2:
// south
return plot.getMerged(2) ? id : null;
case 1:
// west
return plot.getMerged(3) ? id : null;
case 12:
// northest
return plot.getMerged(4) ? id : null;
case 6:
// southeast
return plot.getMerged(5) ? id : null;
case 3:
// southwest
return plot.getMerged(6) ? id : null;
case 9:
// northwest
return plot.getMerged(7) ? id : null;
}
PS.debug("invalid location: " + merged);
} catch (Exception e) {
PS.debug("Invalid plot / road width in settings.yml for world: " + plotworld.worldname);
}
int dx;
int dz;
int rx;
int rz;
if (x < 0) {
dx = (x / size);
rx = size + (x % size);
} else {
dx = (x / size) + 1;
rx = (x % size);
}
if (z < 0) {
dz = (z / size);
rz = size + (z % size);
} else {
dz = (z / size) + 1;
rz = (z % size);
}
PlotId id = new PlotId(dx, dz);
boolean[] merged = new boolean[] {(rz <= pathWidthLower), (rx > end), (rz > end), (rx <= pathWidthLower)};
int hash = MainUtil.hash(merged);
// Not merged, and no need to check if it is
if (hash == 0) {
return id;
}
Plot plot = PS.get().getPlot(plotworld.worldname, id);
// Not merged, and standing on road
if (plot == null) {
return null;
}
switch (hash) {
case 8:
// north
return plot.getMerged(0) ? id : null;
case 4:
// east
return plot.getMerged(1) ? id : null;
case 2:
// south
return plot.getMerged(2) ? id : null;
case 1:
// west
return plot.getMerged(3) ? id : null;
case 12:
// northest
return plot.getMerged(4) ? id : null;
case 6:
// southeast
return plot.getMerged(5) ? id : null;
case 3:
// southwest
return plot.getMerged(6) ? id : null;
case 9:
// northwest
return plot.getMerged(7) ? id : null;
}
PS.debug("invalid location: " + merged);
return null;
}

View File

@ -129,8 +129,8 @@ public class ConsolePlayer extends PlotPlayer {
}
@Override
public void deleteMeta(final String key) {
meta.remove(key);
public Object deleteMeta(final String key) {
return meta.remove(key);
}
@Override

View File

@ -1013,7 +1013,7 @@ public class Plot {
public boolean removeDenied(final UUID uuid) {
if (uuid == DBFunc.everyone) {
boolean result = false;
for (UUID other : getDenied()) {
for (UUID other : new HashSet<>(getDenied())) {
result = result || PlotHandler.removeDenied(this, other);
}
return result;
@ -1029,7 +1029,7 @@ public class Plot {
public boolean removeTrusted(final UUID uuid) {
if (uuid == DBFunc.everyone) {
boolean result = false;
for (UUID other : getTrusted()) {
for (UUID other : new HashSet<>(getTrusted())) {
result = result || PlotHandler.removeTrusted(this, other);
}
return result;
@ -1045,7 +1045,7 @@ public class Plot {
public boolean removeMember(final UUID uuid) {
if (uuid == DBFunc.everyone) {
boolean result = false;
for (UUID other : getMembers()) {
for (UUID other : new HashSet<>(getMembers())) {
result = result || PlotHandler.removeMember(this, other);
}
return result;

View File

@ -80,10 +80,8 @@ public abstract class PlotPlayer implements CommandCaller {
* - deleting other plugin's metadata may cause issues
* @param key
*/
public void deleteMeta(final String key) {
if (meta != null) {
meta.remove(key);
}
public Object deleteMeta(final String key) {
return meta.remove(key);
}
/**

View File

@ -107,12 +107,11 @@ public abstract class ChunkManager {
public abstract void unloadChunk(final String world, final ChunkLoc loc, final boolean save, final boolean safe);
public Set<ChunkLoc> getChunkChunks(final String world) {
final String directory = PS.get().IMP.getWorldContainer() + File.separator + world + File.separator + "region";
final File folder = new File(directory);
final File folder = new File(PS.get().IMP.getWorldContainer(), world + File.separator + "region");
final File[] regionFiles = folder.listFiles();
final HashSet<ChunkLoc> chunks = new HashSet<>();
if (regionFiles == null) {
throw new RuntimeException("Could not find worlds folder.");
throw new RuntimeException("Could not find worlds folder: " + folder + " ? (no read access?)");
}
for (final File file : regionFiles) {
final String name = file.getName();

View File

@ -563,6 +563,9 @@ public class MainUtil {
}
public static boolean isPlotAreaAbs(final Location location) {
if (!Settings.ENABLE_CLUSTERS) {
return true;
}
final PlotWorld plotworld = PS.get().getPlotWorld(location.getWorld());
if (plotworld == null) {
return false;
@ -586,6 +589,9 @@ public class MainUtil {
}
public static boolean isPlotArea(final Plot plot) {
if (!Settings.ENABLE_CLUSTERS) {
return true;
}
final PlotWorld plotworld = PS.get().getPlotWorld(plot.world);
if (plotworld.TYPE == 2) {
return plot.getCluster() != null;

View File

@ -3,6 +3,7 @@ package com.plotsquared.bukkit;
import java.io.File;
import java.lang.reflect.Method;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import java.util.UUID;
@ -122,7 +123,7 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
@Override
public void onEnable() {
THIS = this;
PS.instance = new PS(this, "Bukkit");
new PS(this, "Bukkit");
}
@Override
@ -191,23 +192,19 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
public void runEntityTask() {
log(C.PREFIX.s() + "KillAllEntities started.");
TaskManager.runTaskRepeat(new Runnable() {
long ticked = 0l;
long error = 0l;
@Override
public void run() {
if (ticked > 36_000L) {
ticked = 0l;
if (error > 0) {
log(C.PREFIX.s() + "KillAllEntities has been running for 6 hours. Errors: " + error);
}
error = 0l;
}
World world;
for (final PlotWorld pw : PS.get().getPlotWorldObjects()) {
world = Bukkit.getWorld(pw.worldname);
try {
for (final Entity entity : world.getEntities()) {
if (world == null) {
continue;
}
List<Entity> entities = world.getEntities();
Iterator<Entity> iter = entities.iterator();
while (iter.hasNext()) {
Entity entity = iter.next();
switch (entity.getType()) {
case EGG:
case ENDER_CRYSTAL:
@ -251,19 +248,21 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
Plot plot = loc.getPlot();
if (plot == null) {
if (MainUtil.isPlotAreaAbs(loc)) {
iter.remove();
entity.remove();
}
return;
continue;
}
List<MetadataValue> meta = entity.getMetadata("plot");
if (meta.size() == 0) {
return;
continue;
}
Plot origin = (Plot) meta.get(0).value();
if (!plot.equals(origin.getBasePlot(false))) {
iter.remove();
entity.remove();
}
break;
continue;
}
case SMALL_FIREBALL:
case FIREBALL:
@ -317,18 +316,17 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
final Entity passenger = entity.getPassenger();
if (!(passenger instanceof Player)) {
if (entity.getMetadata("keep").size() == 0) {
iter.remove();
entity.remove();
}
}
}
break;
continue;
}
}
}
} catch (final Throwable e) {
++error;
} finally {
++ticked;
e.printStackTrace();
}
}
}

View File

@ -55,8 +55,17 @@ public class PlotMeConnector_017 extends APlotMeConnector {
final HashMap<String, Integer> roadWidth = new HashMap<>();
final HashMap<Integer, Plot> plots = new HashMap<>();
final HashMap<String, HashMap<PlotId, boolean[]>> merges = new HashMap<>();
stmt = connection.prepareStatement("SELECT * FROM `" + plugin + "core_plots`");
r = stmt.executeQuery();
try {
stmt = connection.prepareStatement("SELECT * FROM `" + plugin + "core_plots`");
r = stmt.executeQuery();
} catch (Exception e) {
PS.debug("========= Table does not exist =========");
e.printStackTrace();
PS.debug("=======================================");
PS.debug("&8 - &7The database does not match the version specified in the PlotMe config");
PS.debug("&8 - &7Please correct this, or if you are unsure, the most common is 0.16.3");
return null;
}
final boolean checkUUID = DBFunc.hasColumn(r, "ownerID");
final boolean merge = !plugin.equals("plotme") && Settings.CONVERT_PLOTME;
while (r.next()) {

View File

@ -92,7 +92,6 @@ import org.bukkit.plugin.Plugin;
import org.bukkit.projectiles.BlockProjectileSource;
import org.bukkit.projectiles.ProjectileSource;
import org.bukkit.util.Vector;
import org.spongepowered.api.entity.living.animal.Animal;
import com.intellectualcrafters.plot.PS;
import com.intellectualcrafters.plot.config.C;
@ -284,18 +283,9 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
if (!MainUtil.isPlotArea(loc)) {
return;
}
//
final ProjectileSource shooter = entity.getShooter();
if (shooter instanceof BlockProjectileSource) {
if (plot == null) {
entity.remove();
return;
}
final Location sLoc = BukkitUtil.getLocation(((BlockProjectileSource) shooter).getBlock().getLocation());
final Plot sPlot = MainUtil.getPlot(sLoc);
if ((sPlot == null) || !PlotHandler.sameOwners(plot, sPlot)) {
entity.remove();
}
} else if ((shooter instanceof Player)) {
if ((shooter instanceof Player)) {
final PlotPlayer pp = BukkitUtil.getPlayer((Player) shooter);
if (plot == null) {
if (!Permissions.hasPermission(pp, C.PERMISSION_PROJECTILE_UNOWNED)) {
@ -310,6 +300,16 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
return;
}
entity.remove();
} else if (!(shooter instanceof Entity) && shooter != null) {
if (plot == null) {
entity.remove();
return;
}
final Location sLoc = BukkitUtil.getLocation(((BlockProjectileSource) shooter).getBlock().getLocation());
final Plot sPlot = MainUtil.getPlot(sLoc);
if ((sPlot == null) || !PlotHandler.sameOwners(plot, sPlot)) {
entity.remove();
}
}
}
@ -453,7 +453,7 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
MainUtil.sendMessage(pp, C.WORLDEDIT_BYPASSED);
}
}
if ((PS.get().update != null) && Permissions.hasPermission(pp, C.PERMISSION_ADMIN) && Settings.UPDATE_NOTIFICATIONS) {
if ((PS.get().update != null) && Permissions.hasPermission(pp, C.PERMISSION_ADMIN_UPDATE) && Settings.UPDATE_NOTIFICATIONS) {
TaskManager.runTaskLater(new Runnable() {
@Override
public void run() {
@ -737,9 +737,13 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
final Player player = event.getPlayer();
final PlotPlayer pp = BukkitUtil.getPlayer(player);
// Delete last location
pp.deleteMeta("location");
pp.deleteMeta("lastplot");
Plot plot = (Plot) pp.deleteMeta("lastplot");
if (plot != null) {
plotExit(pp, plot);
}
if (BukkitMain.worldEdit != null) {
if (!Permissions.hasPermission(pp, C.PERMISSION_WORLDEDIT_BYPASS)) {
@ -1025,13 +1029,16 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
if (blocks.size() == 0) {
return;
}
final Plot origin = MainUtil.getPlot(BukkitUtil.getLocation(blocks.get(0).getLocation()));
if (origin == null) {
e.setCancelled(true);
return;
Location loc = BukkitUtil.getLocation(blocks.get(0).getLocation());
final Plot origin = MainUtil.getPlot(loc);
if (origin == null) {
if (MainUtil.isPlotAreaAbs(null)) {
e.setCancelled(true);
return;
}
}
for (int i = blocks.size() - 1; i >= 0; i--) {
final Location loc = BukkitUtil.getLocation(blocks.get(i).getLocation());
loc = BukkitUtil.getLocation(blocks.get(i).getLocation());
final Plot plot = MainUtil.getPlot(loc);
if (!Objects.equals(plot, origin)) {
e.getBlocks().remove(i);
@ -1438,7 +1445,7 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
default: {
String[] types;
if (entity instanceof LivingEntity) {
if (entity instanceof Animal) {
if (entity instanceof Animals) {
types = new String[] { "entity-cap", "mob-cap", "animal-cap" };
} else if (entity instanceof Monster) {
types = new String[] { "entity-cap", "mob-cap", "hostile-cap" };

View File

@ -262,7 +262,11 @@ public class BukkitPlayer extends PlotPlayer {
@Override
public void setTime(final long time) {
player.setPlayerTime(time, false);
if (time != Long.MAX_VALUE) {
player.setPlayerTime(time, false);
} else {
player.resetPlayerTime();
}
}
@Override

View File

@ -20,7 +20,6 @@
////////////////////////////////////////////////////////////////////////////////////////////////////
package com.plotsquared.listener;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
@ -228,7 +227,9 @@ public class PlotListener {
pp.setFlight(false);
}
}
System.out.print("CHECKING TIME");
if (FlagManager.getPlotFlagRaw(plot, "time") != null) {
System.out.print("RESETTING TIEM");
pp.setTime(Long.MAX_VALUE);
}
if (FlagManager.getPlotFlagRaw(plot, "weather") != null) {
@ -242,8 +243,4 @@ public class PlotListener {
}
return true;
}
public boolean getFlagValue(final String value) {
return Arrays.asList("true", "on", "enabled", "yes").contains(value.toLowerCase());
}
}

View File

@ -236,7 +236,7 @@ public class SpongeMain implements IPlotMain, PluginContainer {
server = game.getServer();
//
PS.instance = new PS(this, "Sponge");
new PS(this, "Sponge");
registerBlocks();

View File

@ -12,7 +12,7 @@ import java.util.function.Predicate;
import org.spongepowered.api.GameProfile;
import org.spongepowered.api.block.BlockSnapshot;
import org.spongepowered.api.block.BlockState;
import org.spongepowered.api.block.BlockTransaction;
import org.spongepowered.api.data.Transaction;
import org.spongepowered.api.entity.Entity;
import org.spongepowered.api.entity.EntityTypes;
import org.spongepowered.api.entity.Transform;
@ -159,7 +159,7 @@ public class MainListener {
}
return null;
}
@Listener
public void onCommand(final BreedEntityEvent.Breed event) {
final Location loc = SpongeUtil.getLocation(event.getTargetEntity());
@ -182,131 +182,126 @@ public class MainListener {
@Listener
public void onMobSpawn(final SpawnEntityEvent event) {
final Entity entity = event.getTargetEntity();
if (entity instanceof Player) {
return;
}
final Location loc = SpongeUtil.getLocation(entity);
final String world = loc.getWorld();
final PlotWorld plotworld = PS.get().getPlotWorld(world);
World world = event.getTargetWorld();
final PlotWorld plotworld = PS.get().getPlotWorld(world.getName());
if (plotworld == null) {
return;
}
final Plot plot = MainUtil.getPlot(loc);
if (plot == null) {
if (MainUtil.isPlotRoad(loc)) {
event.setCancelled(true);
}
return;
}
PS.get().getPlotWorld(world);
// Player player = this.<Player> getCause(event.getCause());
// TODO selectively cancel depending on spawn reason
// - Not sure if possible to get spawn reason (since there are no callbacks)
// if (player != null && !plotworld.SPAWN_EGGS) {
// event.setCancelled(true);
// return;
// }
if (entity.getType() == EntityTypes.ITEM) {
if (FlagManager.isPlotFlagFalse(plot, "item-drop")) {
event.setCancelled(true);
}
return;
}
int[] mobs = null;
if (entity instanceof Living) {
if (!plotworld.MOB_SPAWNING) {
event.setCancelled(true);
return;
}
final Flag mobCap = FlagManager.getPlotFlagRaw(plot, "mob-cap");
if (mobCap != null) {
final Integer cap = (Integer) mobCap.getValue();
if (cap == 0) {
event.setCancelled(true);
return;
List<Entity> entities = event.getEntities();
event.filterEntities(new Predicate<Entity>() {
@Override
public boolean test(Entity entity) {
if (entity instanceof Player) {
return true;
}
if (mobs == null) {
mobs = MainUtil.countEntities(plot);
final Location loc = SpongeUtil.getLocation(entity);
final Plot plot = MainUtil.getPlot(loc);
if (plot == null) {
if (MainUtil.isPlotRoad(loc)) {
return false;
}
return true;
}
if (mobs[3] >= cap) {
event.setCancelled(true);
return;
// Player player = this.<Player> getCause(event.getCause());
// TODO selectively cancel depending on spawn reason
// - Not sure if possible to get spawn reason (since there are no callbacks)
// if (player != null && !plotworld.SPAWN_EGGS) {
// return false;
// return true;
// }
if (entity.getType() == EntityTypes.ITEM) {
if (FlagManager.isPlotFlagFalse(plot, "item-drop")) {
return false;
}
return true;
}
}
if ((entity instanceof Ambient) || (entity instanceof Animal)) {
final Flag animalFlag = FlagManager.getPlotFlagRaw(plot, "animal-cap");
if (animalFlag != null) {
final int cap = ((Integer) animalFlag.getValue());
int[] mobs = null;
if (entity instanceof Living) {
if (!plotworld.MOB_SPAWNING) {
return false;
}
final Flag mobCap = FlagManager.getPlotFlagRaw(plot, "mob-cap");
if (mobCap != null) {
final Integer cap = (Integer) mobCap.getValue();
if (cap == 0) {
return false;
}
if (mobs == null) {
mobs = MainUtil.countEntities(plot);
}
if (mobs[3] >= cap) {
return false;
}
}
if ((entity instanceof Ambient) || (entity instanceof Animal)) {
final Flag animalFlag = FlagManager.getPlotFlagRaw(plot, "animal-cap");
if (animalFlag != null) {
final int cap = ((Integer) animalFlag.getValue());
if (cap == 0) {
return false;
}
if (mobs == null) {
mobs = MainUtil.countEntities(plot);
}
if (mobs[1] >= cap) {
return false;
}
}
}
if (entity instanceof Monster) {
final Flag monsterFlag = FlagManager.getPlotFlagRaw(plot, "hostile-cap");
if (monsterFlag != null) {
final int cap = ((Integer) monsterFlag.getValue());
if (cap == 0) {
return false;
}
if (mobs == null) {
mobs = MainUtil.countEntities(plot);
}
if (mobs[2] >= cap) {
return false;
}
}
}
return true;
}
if ((entity instanceof Minecart) || (entity instanceof Boat)) {
final Flag vehicleFlag = FlagManager.getPlotFlagRaw(plot, "vehicle-cap");
if (vehicleFlag != null) {
final int cap = ((Integer) vehicleFlag.getValue());
if (cap == 0) {
return false;
}
if (mobs == null) {
mobs = MainUtil.countEntities(plot);
}
if (mobs[4] >= cap) {
return false;
}
}
}
final Flag entityCap = FlagManager.getPlotFlagRaw(plot, "entity-cap");
if (entityCap != null) {
final Integer cap = (Integer) entityCap.getValue();
if (cap == 0) {
event.setCancelled(true);
return;
return false;
}
if (mobs == null) {
mobs = MainUtil.countEntities(plot);
}
if (mobs[1] >= cap) {
event.setCancelled(true);
return;
if (mobs[0] >= cap) {
return false;
}
}
}
if (entity instanceof Monster) {
final Flag monsterFlag = FlagManager.getPlotFlagRaw(plot, "hostile-cap");
if (monsterFlag != null) {
final int cap = ((Integer) monsterFlag.getValue());
if (cap == 0) {
event.setCancelled(true);
return;
}
if (mobs == null) {
mobs = MainUtil.countEntities(plot);
}
if (mobs[2] >= cap) {
event.setCancelled(true);
return;
}
if (entity instanceof PrimedTNT) {
Vector3d pos = entity.getLocation().getPosition();
entity.setRotation(new Vector3d(MathMan.roundInt(pos.getX()), MathMan.roundInt(pos.getY()), MathMan.roundInt(pos.getZ())));
}
return true;
}
return;
}
if ((entity instanceof Minecart) || (entity instanceof Boat)) {
final Flag vehicleFlag = FlagManager.getPlotFlagRaw(plot, "vehicle-cap");
if (vehicleFlag != null) {
final int cap = ((Integer) vehicleFlag.getValue());
if (cap == 0) {
event.setCancelled(true);
return;
}
if (mobs == null) {
mobs = MainUtil.countEntities(plot);
}
if (mobs[4] >= cap) {
event.setCancelled(true);
return;
}
}
}
final Flag entityCap = FlagManager.getPlotFlagRaw(plot, "entity-cap");
if (entityCap != null) {
final Integer cap = (Integer) entityCap.getValue();
if (cap == 0) {
event.setCancelled(true);
return;
}
if (mobs == null) {
mobs = MainUtil.countEntities(plot);
}
if (mobs[0] >= cap) {
event.setCancelled(true);
return;
}
}
if (entity instanceof PrimedTNT) {
Vector3d pos = entity.getLocation().getPosition();
entity.setRotation(new Vector3d(MathMan.roundInt(pos.getX()), MathMan.roundInt(pos.getY()), MathMan.roundInt(pos.getZ())));
}
});
}
@Listener
@ -333,8 +328,8 @@ public class MainListener {
if (!PS.get().isPlotWorld(worldname)) {
return;
}
List<BlockTransaction> transactions = event.getTransactions();
BlockTransaction first = transactions.get(0);
List<Transaction<BlockSnapshot>> transactions = event.getTransactions();
Transaction<BlockSnapshot> first = transactions.get(0);
Location loc = SpongeUtil.getLocation(worldname, first.getOriginal().getPosition());
Plot plot = MainUtil.getPlot(loc);
if (plot == null) {
@ -370,14 +365,13 @@ public class MainListener {
public void onLightning(final LightningEvent.Strike event) {
onBlockChange(event);
}
public void printCause(String method, Cause cause) {
System.out.println(method + ": " + cause.toString());
System.out.println(method + ": " + cause.getClass());
System.out.println(method + ": " + (cause.root().isPresent() ? cause.root().get() : null));
}
@Listener
public void onChat(final MessageEvent event) {
// TODO
@ -433,8 +427,7 @@ public class MainListener {
}
((SpongePlayer) user).player.sendMessage(Texts.join(components));
}
event.setMessage(Texts.of());
event.setCancelled(true);
event.setMessage(null);
}
@Listener
@ -529,8 +522,8 @@ public class MainListener {
if (!PS.get().isPlotWorld(worldname)) {
return;
}
List<BlockTransaction> transactions = event.getTransactions();
BlockTransaction first = transactions.get(0);
List<Transaction<BlockSnapshot>> transactions = event.getTransactions();
Transaction<BlockSnapshot> first = transactions.get(0);
BlockSnapshot pos = first.getOriginal();
Location loc = SpongeUtil.getLocation(worldname, pos.getPosition());
Plot plot = MainUtil.getPlot(loc);
@ -613,8 +606,8 @@ public class MainListener {
if (!PS.get().isPlotWorld(worldname)) {
return;
}
List<BlockTransaction> transactions = event.getTransactions();
BlockTransaction first = transactions.get(0);
List<Transaction<BlockSnapshot>> transactions = event.getTransactions();
Transaction<BlockSnapshot> first = transactions.get(0);
BlockSnapshot pos = first.getOriginal();
Location loc = SpongeUtil.getLocation(worldname, pos.getPosition());
Plot plot = MainUtil.getPlot(loc);
@ -683,7 +676,7 @@ public class MainListener {
}
});
}
@Listener
public void onBlockInteract(final InteractBlockEvent.Secondary event) {
final Player player = this.<Player> getCause(event.getCause(), Player.class);

View File

@ -225,6 +225,7 @@ public class SpongePlayer extends PlotPlayer {
@Override
public void setTime(final long time) {
// TODO Auto-generated method stub
if (time != Long.MAX_VALUE) {} else {}
throw new UnsupportedOperationException("NOT IMPLEMENTED YET");
}

View File

@ -1,7 +1,6 @@
package com.plotsquared.sponge.util;
import java.util.ArrayList;
import java.util.Locale;
import org.spongepowered.api.entity.living.player.Player;
import org.spongepowered.api.item.ItemType;
@ -105,7 +104,7 @@ public class SpongeInventoryUtil extends InventoryUtil {
final Player player = sp.player;
if (player.isViewingInventory()) {
final CarriedInventory<? extends Carrier> inventory = player.getInventory();
return inv.getTitle().equals(inventory.getName().getTranslation().get(Locale.ENGLISH));
return inv.getTitle().equals(inventory.getName().getId()); // TODO getId()
}
return false;
}

View File

@ -185,7 +185,7 @@ public class SpongeMetrics {
// Begin hitting the server with glorious data
final TaskBuilder builder = game.getScheduler().createTaskBuilder();
builder.async().interval(TimeUnit.MINUTES.toMillis(PING_INTERVAL)).execute(new Runnable() {
builder.async().interval(PING_INTERVAL, TimeUnit.MINUTES).execute(new Runnable() {
private boolean firstPost = true;

View File

@ -19,7 +19,7 @@ public class SpongeTaskManager extends TaskManager {
public int taskRepeat(final Runnable r, final int interval) {
final int val = i.incrementAndGet();
final TaskBuilder builder = SpongeMain.THIS.getGame().getScheduler().createTaskBuilder();
final TaskBuilder built = builder.delay(interval).interval(interval).execute(r);
final TaskBuilder built = builder.delayTicks(interval).intervalTicks(interval).execute(r);
final Task task = built.submit(SpongeMain.THIS.getPlugin());
tasks.put(val, task);
return val;
@ -29,7 +29,7 @@ public class SpongeTaskManager extends TaskManager {
public int taskRepeatAsync(final Runnable r, final int interval) {
final int val = i.incrementAndGet();
final TaskBuilder builder = SpongeMain.THIS.getGame().getScheduler().createTaskBuilder();
final TaskBuilder built = builder.delay(interval).async().interval(interval).execute(r);
final TaskBuilder built = builder.delayTicks(interval).async().intervalTicks(interval).execute(r);
final Task task = built.submit(SpongeMain.THIS.getPlugin());
tasks.put(val, task);
return val;
@ -50,13 +50,13 @@ public class SpongeTaskManager extends TaskManager {
@Override
public void taskLater(final Runnable r, final int delay) {
final TaskBuilder builder = SpongeMain.THIS.getGame().getScheduler().createTaskBuilder();
builder.delay(delay).execute(r).submit(SpongeMain.THIS.getPlugin());
builder.delayTicks(delay).execute(r).submit(SpongeMain.THIS.getPlugin());
}
@Override
public void taskLaterAsync(final Runnable r, final int delay) {
final TaskBuilder builder = SpongeMain.THIS.getGame().getScheduler().createTaskBuilder();
builder.async().delay(delay).execute(r).submit(SpongeMain.THIS.getPlugin());
builder.async().delayTicks(delay).execute(r).submit(SpongeMain.THIS.getPlugin());
}
@Override

Binary file not shown.