mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-29 13:05:41 +01:00
Merge branch 'master' of https://github.com/IntellectualSites/PlotSquared
# Conflicts: # Bukkit/src/main/java/com/plotsquared/bukkit/listeners/PlayerEvents.java # Bukkit/src/main/java/com/plotsquared/bukkit/util/block/FastQueue_1_9.java
This commit is contained in:
commit
dee8072d83
@ -54,8 +54,7 @@ public class PlotAPI {
|
|||||||
* @deprecated Not needed
|
* @deprecated Not needed
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public PlotAPI(JavaPlugin plugin) {
|
public PlotAPI(JavaPlugin plugin) {}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get all plots.
|
* Get all plots.
|
||||||
|
@ -141,9 +141,7 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
|
|||||||
}
|
}
|
||||||
this.getServer().getConsoleSender().sendMessage(message);
|
this.getServer().getConsoleSender().sendMessage(message);
|
||||||
return;
|
return;
|
||||||
} catch (Throwable ignored) {
|
} catch (Throwable ignored) {}
|
||||||
//ignored
|
|
||||||
}
|
|
||||||
System.out.println(ConsoleColors.fromString(message));
|
System.out.println(ConsoleColors.fromString(message));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -401,14 +399,14 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
|
|||||||
try {
|
try {
|
||||||
new SendChunk();
|
new SendChunk();
|
||||||
MainUtil.canSendChunk = true;
|
MainUtil.canSendChunk = true;
|
||||||
} catch (Throwable e) {
|
} catch (ClassNotFoundException | NoSuchFieldException | NoSuchMethodException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
MainUtil.canSendChunk = false;
|
MainUtil.canSendChunk = false;
|
||||||
}
|
}
|
||||||
if (PS.get().checkVersion(getServerVersion(), 1, 9, 0)) {
|
if (PS.get().checkVersion(getServerVersion(), 1, 9, 0)) {
|
||||||
try {
|
try {
|
||||||
return new FastQueue_1_9();
|
return new FastQueue_1_9();
|
||||||
} catch (Throwable e) {
|
} catch (ClassNotFoundException | NoSuchFieldException | NoSuchMethodException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
return new SlowQueue();
|
return new SlowQueue();
|
||||||
}
|
}
|
||||||
@ -416,11 +414,11 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
|
|||||||
if (PS.get().checkVersion(getServerVersion(), 1, 8, 0)) {
|
if (PS.get().checkVersion(getServerVersion(), 1, 8, 0)) {
|
||||||
try {
|
try {
|
||||||
return new FastQueue_1_8_3();
|
return new FastQueue_1_8_3();
|
||||||
} catch (Throwable e) {
|
} catch (NoSuchMethodException | ClassNotFoundException | NoSuchFieldException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
try {
|
try {
|
||||||
return new FastQueue_1_8();
|
return new FastQueue_1_8();
|
||||||
} catch (Throwable e2) {
|
} catch (NoSuchMethodException | NoSuchFieldException | ClassNotFoundException e2) {
|
||||||
e2.printStackTrace();
|
e2.printStackTrace();
|
||||||
return new SlowQueue();
|
return new SlowQueue();
|
||||||
}
|
}
|
||||||
@ -428,7 +426,7 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
|
|||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
return new FastQueue_1_7();
|
return new FastQueue_1_7();
|
||||||
} catch (Throwable e) {
|
} catch (ClassNotFoundException | NoSuchFieldException | NoSuchMethodException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
return new SlowQueue();
|
return new SlowQueue();
|
||||||
}
|
}
|
||||||
@ -620,11 +618,14 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
|
|||||||
public PlotPlayer wrapPlayer(Object player) {
|
public PlotPlayer wrapPlayer(Object player) {
|
||||||
if (player instanceof Player) {
|
if (player instanceof Player) {
|
||||||
return BukkitUtil.getPlayer((Player) player);
|
return BukkitUtil.getPlayer((Player) player);
|
||||||
} else if (player instanceof OfflinePlayer) {
|
}
|
||||||
|
if (player instanceof OfflinePlayer) {
|
||||||
return BukkitUtil.getPlayer((OfflinePlayer) player);
|
return BukkitUtil.getPlayer((OfflinePlayer) player);
|
||||||
} else if (player instanceof String) {
|
}
|
||||||
|
if (player instanceof String) {
|
||||||
return UUIDHandler.getPlayer((String) player);
|
return UUIDHandler.getPlayer((String) player);
|
||||||
} else if (player instanceof UUID) {
|
}
|
||||||
|
if (player instanceof UUID) {
|
||||||
return UUIDHandler.getPlayer((UUID) player);
|
return UUIDHandler.getPlayer((UUID) player);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
@ -654,7 +655,7 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
|
|||||||
public List<String> getPluginIds() {
|
public List<String> getPluginIds() {
|
||||||
ArrayList<String> names = new ArrayList<>();
|
ArrayList<String> names = new ArrayList<>();
|
||||||
for (Plugin plugin : Bukkit.getPluginManager().getPlugins()) {
|
for (Plugin plugin : Bukkit.getPluginManager().getPlugins()) {
|
||||||
names.add(plugin.getName() + ";" + plugin.getDescription().getVersion() + ":" + plugin.isEnabled());
|
names.add(plugin.getName() + ';' + plugin.getDescription().getVersion() + ':' + plugin.isEnabled());
|
||||||
}
|
}
|
||||||
return names;
|
return names;
|
||||||
}
|
}
|
||||||
|
@ -192,7 +192,7 @@ public abstract class TextualComponent implements Cloneable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TextualComponent clone() throws CloneNotSupportedException {
|
public TextualComponent clone() {
|
||||||
// Since this is a private and final class, we can just reinstantiate this class instead of casting super.clone
|
// Since this is a private and final class, we can just reinstantiate this class instead of casting super.clone
|
||||||
return new ArbitraryTextTypeComponent(getKey(), getValue());
|
return new ArbitraryTextTypeComponent(getKey(), getValue());
|
||||||
}
|
}
|
||||||
@ -266,7 +266,7 @@ public abstract class TextualComponent implements Cloneable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TextualComponent clone() throws CloneNotSupportedException {
|
public TextualComponent clone() {
|
||||||
// Since this is a private and final class, we can just reinstantiate this class instead of casting super.clone
|
// Since this is a private and final class, we can just reinstantiate this class instead of casting super.clone
|
||||||
return new ComplexTextTypeComponent(getKey(), getValue());
|
return new ComplexTextTypeComponent(getKey(), getValue());
|
||||||
}
|
}
|
||||||
|
@ -285,7 +285,7 @@ public class DebugUUID extends SubCommand {
|
|||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
PS.get().config.save(PS.get().configFile);
|
PS.get().config.save(PS.get().configFile);
|
||||||
} catch (IOException e) {
|
} catch (IOException ignored) {
|
||||||
MainUtil.sendMessage(player, "Could not save configuration. It will need to be manual set!");
|
MainUtil.sendMessage(player, "Could not save configuration. It will need to be manual set!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -42,9 +42,8 @@ public class ClassicPlotMeConnector extends APlotMeConnector {
|
|||||||
} else {
|
} else {
|
||||||
return new SQLite(dataFolder + File.separator + "plots.db").openConnection();
|
return new SQLite(dataFolder + File.separator + "plots.db").openConnection();
|
||||||
}
|
}
|
||||||
} catch (SQLException | ClassNotFoundException ignored) {
|
} catch (SQLException | ClassNotFoundException e) {
|
||||||
//ignored
|
e.printStackTrace();
|
||||||
ignored.printStackTrace();
|
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -229,9 +228,7 @@ public class ClassicPlotMeConnector extends APlotMeConnector {
|
|||||||
resultSet.close();
|
resultSet.close();
|
||||||
statement.close();
|
statement.close();
|
||||||
|
|
||||||
} catch (SQLException ignored) {
|
} catch (SQLException ignored) {}
|
||||||
//ignored
|
|
||||||
}
|
|
||||||
return plots;
|
return plots;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -200,9 +200,7 @@ public class LikePlotMeConverter {
|
|||||||
PS.get().config.set("worlds." + actualWorldName + ".wall.height", height);
|
PS.get().config.set("worlds." + actualWorldName + ".wall.height", height);
|
||||||
PS.get().config.save(PS.get().configFile);
|
PS.get().config.save(PS.get().configFile);
|
||||||
}
|
}
|
||||||
} catch (IOException ignored) {
|
} catch (IOException ignored) {}
|
||||||
//ignored
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
for (Entry<String, HashMap<PlotId, Plot>> entry : plots.entrySet()) {
|
for (Entry<String, HashMap<PlotId, Plot>> entry : plots.entrySet()) {
|
||||||
String world = entry.getKey();
|
String world = entry.getKey();
|
||||||
@ -264,7 +262,7 @@ public class LikePlotMeConverter {
|
|||||||
sendMessage("Saving configuration...");
|
sendMessage("Saving configuration...");
|
||||||
try {
|
try {
|
||||||
PS.get().config.save(PS.get().configFile);
|
PS.get().config.save(PS.get().configFile);
|
||||||
} catch (IOException e) {
|
} catch (IOException ignored) {
|
||||||
sendMessage(" - &cFailed to save configuration.");
|
sendMessage(" - &cFailed to save configuration.");
|
||||||
}
|
}
|
||||||
TaskManager.runTask(new Runnable() {
|
TaskManager.runTask(new Runnable() {
|
||||||
@ -293,7 +291,7 @@ public class LikePlotMeConverter {
|
|||||||
Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "mv unload " + actualWorldName);
|
Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "mv unload " + actualWorldName);
|
||||||
try {
|
try {
|
||||||
Thread.sleep(1000);
|
Thread.sleep(1000);
|
||||||
} catch (InterruptedException ex) {
|
} catch (InterruptedException ignored) {
|
||||||
Thread.currentThread().interrupt();
|
Thread.currentThread().interrupt();
|
||||||
}
|
}
|
||||||
// load world with MV
|
// load world with MV
|
||||||
@ -304,7 +302,7 @@ public class LikePlotMeConverter {
|
|||||||
Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "mw unload " + actualWorldName);
|
Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "mw unload " + actualWorldName);
|
||||||
try {
|
try {
|
||||||
Thread.sleep(1000);
|
Thread.sleep(1000);
|
||||||
} catch (InterruptedException ex) {
|
} catch (InterruptedException ignored) {
|
||||||
Thread.currentThread().interrupt();
|
Thread.currentThread().interrupt();
|
||||||
}
|
}
|
||||||
// load world with MW
|
// load world with MW
|
||||||
|
@ -233,7 +233,7 @@ public class BukkitPlotGenerator extends ChunkGenerator implements GeneratorWrap
|
|||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
ArrayList<BlockPopulator> toAdd = new ArrayList<BlockPopulator>();
|
ArrayList<BlockPopulator> toAdd = new ArrayList<>();
|
||||||
List<BlockPopulator> existing = world.getPopulators();
|
List<BlockPopulator> existing = world.getPopulators();
|
||||||
for (BlockPopulator populator : this.populators) {
|
for (BlockPopulator populator : this.populators) {
|
||||||
if (!existing.contains(populator)) {
|
if (!existing.contains(populator)) {
|
||||||
|
@ -320,7 +320,8 @@ public class PlayerEvents extends PlotListener implements Listener {
|
|||||||
}
|
}
|
||||||
entity.remove();
|
entity.remove();
|
||||||
return false;
|
return false;
|
||||||
} else if (!(shooter instanceof Entity) && shooter != null) {
|
}
|
||||||
|
if (!(shooter instanceof Entity) && shooter != null) {
|
||||||
if (plot == null) {
|
if (plot == null) {
|
||||||
entity.remove();
|
entity.remove();
|
||||||
return false;
|
return false;
|
||||||
@ -372,7 +373,7 @@ public class PlayerEvents extends PlotListener implements Listener {
|
|||||||
String c = parts[0];
|
String c = parts[0];
|
||||||
if (parts[0].contains(":")) {
|
if (parts[0].contains(":")) {
|
||||||
c = parts[0].split(":")[1];
|
c = parts[0].split(":")[1];
|
||||||
msg = msg.replace(parts[0].split(":")[0] + ":", "");
|
msg = msg.replace(parts[0].split(":")[0] + ':', "");
|
||||||
}
|
}
|
||||||
String l = c;
|
String l = c;
|
||||||
List<String> aliases = new ArrayList<>();
|
List<String> aliases = new ArrayList<>();
|
||||||
@ -511,7 +512,8 @@ public class PlayerEvents extends PlotListener implements Listener {
|
|||||||
player.teleport(event.getTo());
|
player.teleport(event.getTo());
|
||||||
MainUtil.sendMessage(pp, C.BORDER);
|
MainUtil.sendMessage(pp, C.BORDER);
|
||||||
return;
|
return;
|
||||||
} else if (x2 < -border) {
|
}
|
||||||
|
if (x2 < -border) {
|
||||||
to.setX(-border + 4);
|
to.setX(-border + 4);
|
||||||
player.teleport(event.getTo());
|
player.teleport(event.getTo());
|
||||||
MainUtil.sendMessage(pp, C.BORDER);
|
MainUtil.sendMessage(pp, C.BORDER);
|
||||||
@ -631,7 +633,8 @@ public class PlayerEvents extends PlotListener implements Listener {
|
|||||||
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_DESTROY_UNOWNED);
|
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_DESTROY_UNOWNED);
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
} else if (!plot.isAdded(pp.getUUID())) {
|
}
|
||||||
|
if (!plot.isAdded(pp.getUUID())) {
|
||||||
Optional<HashSet<PlotBlock>> destroy = plot.getFlag(Flags.BREAK);
|
Optional<HashSet<PlotBlock>> destroy = plot.getFlag(Flags.BREAK);
|
||||||
Block block = event.getBlock();
|
Block block = event.getBlock();
|
||||||
if (destroy.isPresent() && destroy.get()
|
if (destroy.isPresent() && destroy.get()
|
||||||
@ -778,6 +781,7 @@ public class PlayerEvents extends PlotListener implements Listener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Plot plot = area.getOwnedPlot(location);
|
Plot plot = area.getOwnedPlot(location);
|
||||||
|
Optional<Boolean> flag;
|
||||||
switch (block.getType()) {
|
switch (block.getType()) {
|
||||||
case GRASS:
|
case GRASS:
|
||||||
if (Flags.GRASS_GROW.isFalse(plot)) {
|
if (Flags.GRASS_GROW.isFalse(plot)) {
|
||||||
@ -829,10 +833,8 @@ public class PlayerEvents extends PlotListener implements Listener {
|
|||||||
if (!plot.isAdded(pp.getUUID())) {
|
if (!plot.isAdded(pp.getUUID())) {
|
||||||
Optional<HashSet<PlotBlock>> destroy = plot.getFlag(Flags.BREAK);
|
Optional<HashSet<PlotBlock>> destroy = plot.getFlag(Flags.BREAK);
|
||||||
Block block = event.getBlock();
|
Block block = event.getBlock();
|
||||||
if (destroy.isPresent() && destroy.get().contains(new PlotBlock((short) block.getTypeId(), block.getData()))) {
|
if (destroy.isPresent() && destroy.get().contains(new PlotBlock((short) block.getTypeId(), block.getData())) || Permissions
|
||||||
return;
|
.hasPermission(pp, C.PERMISSION_ADMIN_DESTROY_OTHER)) {
|
||||||
}
|
|
||||||
if (Permissions.hasPermission(pp, C.PERMISSION_ADMIN_DESTROY_OTHER)) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
@ -848,8 +850,8 @@ public class PlayerEvents extends PlotListener implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||||
public void onFade(BlockFadeEvent e) {
|
public void onFade(BlockFadeEvent event) {
|
||||||
Block b = e.getBlock();
|
Block b = event.getBlock();
|
||||||
Location location = BukkitUtil.getLocation(b.getLocation());
|
Location location = BukkitUtil.getLocation(b.getLocation());
|
||||||
PlotArea area = location.getPlotArea();
|
PlotArea area = location.getPlotArea();
|
||||||
if (area == null) {
|
if (area == null) {
|
||||||
@ -857,23 +859,23 @@ public class PlayerEvents extends PlotListener implements Listener {
|
|||||||
}
|
}
|
||||||
Plot plot = area.getOwnedPlot(location);
|
Plot plot = area.getOwnedPlot(location);
|
||||||
if (plot == null) {
|
if (plot == null) {
|
||||||
e.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
switch (b.getType()) {
|
switch (b.getType()) {
|
||||||
case ICE:
|
case ICE:
|
||||||
if (Flags.ICE_MELT.isFalse(plot)) {
|
if (Flags.ICE_MELT.isFalse(plot)) {
|
||||||
e.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case SNOW:
|
case SNOW:
|
||||||
if (Flags.SNOW_MELT.isFalse(plot)) {
|
if (Flags.SNOW_MELT.isFalse(plot)) {
|
||||||
e.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case SOIL:
|
case SOIL:
|
||||||
if (Flags.SOIL_DRY.isFalse(plot)) {
|
if (Flags.SOIL_DRY.isFalse(plot)) {
|
||||||
e.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -891,7 +893,7 @@ public class PlayerEvents extends PlotListener implements Listener {
|
|||||||
Plot plot = area.getOwnedPlot(tLocation);
|
Plot plot = area.getOwnedPlot(tLocation);
|
||||||
Location fLocation = BukkitUtil.getLocation(from.getLocation());
|
Location fLocation = BukkitUtil.getLocation(from.getLocation());
|
||||||
if (plot != null) {
|
if (plot != null) {
|
||||||
if (plot.getFlag(Flags.DISABLE_PHYSICS, false)) {
|
if (Flags.DISABLE_PHYSICS.isFalse(plot)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
} else if (!area.contains(fLocation.getX(), fLocation.getZ()) || !Objects.equals(plot, area.getOwnedPlot(fLocation))) {
|
} else if (!area.contains(fLocation.getX(), fLocation.getZ()) || !Objects.equals(plot, area.getOwnedPlot(fLocation))) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
@ -966,7 +968,7 @@ public class PlayerEvents extends PlotListener implements Listener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Throwable e) {
|
} catch (Throwable ignored) {
|
||||||
this.pistonBlocks = false;
|
this.pistonBlocks = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -995,7 +997,7 @@ public class PlayerEvents extends PlotListener implements Listener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Throwable e) {
|
} catch (Throwable ignored) {
|
||||||
this.pistonBlocks = false;
|
this.pistonBlocks = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1172,7 +1174,8 @@ public class PlayerEvents extends PlotListener implements Listener {
|
|||||||
eventType = PlayerBlockEventType.INTERACT_BLOCK;
|
eventType = PlayerBlockEventType.INTERACT_BLOCK;
|
||||||
lb = new BukkitLazyBlock(0, block);
|
lb = new BukkitLazyBlock(0, block);
|
||||||
break;
|
break;
|
||||||
} else if (id < 198) {
|
}
|
||||||
|
if (id < 198) {
|
||||||
location = BukkitUtil.getLocation(block.getRelative(event.getBlockFace()).getLocation());
|
location = BukkitUtil.getLocation(block.getRelative(event.getBlockFace()).getLocation());
|
||||||
eventType = PlayerBlockEventType.PLACE_BLOCK;
|
eventType = PlayerBlockEventType.PLACE_BLOCK;
|
||||||
lb = new BukkitLazyBlock(id, block);
|
lb = new BukkitLazyBlock(id, block);
|
||||||
@ -1330,11 +1333,7 @@ public class PlayerEvents extends PlotListener implements Listener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Plot plot = area.getOwnedPlotAbs(location);
|
Plot plot = area.getOwnedPlotAbs(location);
|
||||||
if (plot == null) {
|
if (plot == null || plot.getFlag(Flags.DISABLE_PHYSICS, false)) {
|
||||||
event.setCancelled(true);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (plot.getFlag(Flags.DISABLE_PHYSICS, false)) {
|
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -1400,7 +1399,7 @@ public class PlayerEvents extends PlotListener implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean checkEntity(Entity entity, Plot plot) {
|
public boolean checkEntity(Entity entity, Plot plot) {
|
||||||
if (plot == null || plot.owner == null || plot.getFlags().isEmpty() && plot.getArea().DEFAULT_FLAGS.isEmpty()) {
|
if (plot == null || !plot.hasOwner() || plot.getFlags().isEmpty() && plot.getArea().DEFAULT_FLAGS.isEmpty()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
switch (entity.getType()) {
|
switch (entity.getType()) {
|
||||||
@ -1498,9 +1497,11 @@ public class PlayerEvents extends PlotListener implements Listener {
|
|||||||
} else {
|
} else {
|
||||||
return checkEntity(plot, Flags.ENTITY_CAP, Flags.MOB_CAP);
|
return checkEntity(plot, Flags.ENTITY_CAP, Flags.MOB_CAP);
|
||||||
}
|
}
|
||||||
} else if (entity instanceof Vehicle) {
|
}
|
||||||
|
if (entity instanceof Vehicle) {
|
||||||
return checkEntity(plot, Flags.ENTITY_CAP, Flags.VEHICLE_CAP);
|
return checkEntity(plot, Flags.ENTITY_CAP, Flags.VEHICLE_CAP);
|
||||||
} else if (entity instanceof Hanging) {
|
}
|
||||||
|
if (entity instanceof Hanging) {
|
||||||
return checkEntity(plot, Flags.ENTITY_CAP, Flags.MISC_CAP);
|
return checkEntity(plot, Flags.ENTITY_CAP, Flags.MISC_CAP);
|
||||||
}
|
}
|
||||||
return checkEntity(plot, Flags.ENTITY_CAP);
|
return checkEntity(plot, Flags.ENTITY_CAP);
|
||||||
@ -1508,8 +1509,8 @@ public class PlayerEvents extends PlotListener implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||||
public void onBlockBurn(BlockBurnEvent e) {
|
public void onBlockBurn(BlockBurnEvent event) {
|
||||||
Block b = e.getBlock();
|
Block b = event.getBlock();
|
||||||
Location location = BukkitUtil.getLocation(b.getLocation());
|
Location location = BukkitUtil.getLocation(b.getLocation());
|
||||||
|
|
||||||
PlotArea area = location.getPlotArea();
|
PlotArea area = location.getPlotArea();
|
||||||
@ -1519,7 +1520,7 @@ public class PlayerEvents extends PlotListener implements Listener {
|
|||||||
|
|
||||||
Plot plot = location.getOwnedPlot();
|
Plot plot = location.getOwnedPlot();
|
||||||
if (plot == null || !plot.getFlag(Flags.BLOCK_BURN, false)) {
|
if (plot == null || !plot.getFlag(Flags.BLOCK_BURN, false)) {
|
||||||
e.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1568,11 +1569,16 @@ public class PlayerEvents extends PlotListener implements Listener {
|
|||||||
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_BUILD_OTHER);
|
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_BUILD_OTHER);
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
} else if (!plot.getFlag(Flags.BLOCK_IGNITION, false)) {
|
} else if (Flags.BLOCK_IGNITION.isFalse(plot)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
} else if (ignitingEntity != null) {
|
} else {
|
||||||
if (plot == null || !plot.getFlag(Flags.BLOCK_IGNITION, false)) {
|
if (plot == null) {
|
||||||
|
event.setCancelled(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (ignitingEntity != null) {
|
||||||
|
if (!plot.getFlag(Flags.BLOCK_IGNITION,false)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -1587,7 +1593,7 @@ public class PlayerEvents extends PlotListener implements Listener {
|
|||||||
Block shooter = ((BlockProjectileSource) fireball.getShooter()).getBlock();
|
Block shooter = ((BlockProjectileSource) fireball.getShooter()).getBlock();
|
||||||
location = BukkitUtil.getLocation(shooter.getLocation());
|
location = BukkitUtil.getLocation(shooter.getLocation());
|
||||||
}
|
}
|
||||||
if (location != null && (location.getPlot() == null || !location.getPlot().equals(plot))) {
|
if (location != null && !plot.equals(location.getPlot())) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1595,32 +1601,12 @@ public class PlayerEvents extends PlotListener implements Listener {
|
|||||||
|
|
||||||
} else if (event.getIgnitingBlock() != null) {
|
} else if (event.getIgnitingBlock() != null) {
|
||||||
Block ignitingBlock = event.getIgnitingBlock();
|
Block ignitingBlock = event.getIgnitingBlock();
|
||||||
if (igniteCause == BlockIgniteEvent.IgniteCause.FLINT_AND_STEEL) {
|
Plot plotIgnited = BukkitUtil.getLocation(ignitingBlock.getLocation()).getPlot();
|
||||||
if (plot == null || !plot.getFlag(Flags.BLOCK_IGNITION, false)) {
|
if (igniteCause == BlockIgniteEvent.IgniteCause.FLINT_AND_STEEL && (!plot.getFlag(Flags.BLOCK_IGNITION,false)
|
||||||
|
|| plotIgnited == null || !plotIgnited.equals(plot))
|
||||||
|
|| (igniteCause == BlockIgniteEvent.IgniteCause.SPREAD || igniteCause == BlockIgniteEvent.IgniteCause.LAVA) && (
|
||||||
|
!plot.getFlag(Flags.BLOCK_IGNITION).or(false) || plotIgnited == null || !plotIgnited.equals(plot))) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (BukkitUtil.getLocation(ignitingBlock.getLocation()).getPlot() == null) {
|
|
||||||
event.setCancelled(true);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (!BukkitUtil.getLocation(ignitingBlock.getLocation()).getPlot().equals(plot)) {
|
|
||||||
event.setCancelled(true);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (igniteCause == BlockIgniteEvent.IgniteCause.SPREAD || igniteCause == BlockIgniteEvent.IgniteCause.LAVA) {
|
|
||||||
if (plot == null || !plot.getFlag(Flags.BLOCK_IGNITION, false)) {
|
|
||||||
event.setCancelled(true);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (BukkitUtil.getLocation(ignitingBlock.getLocation()).getPlot() == null) {
|
|
||||||
event.setCancelled(true);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (!BukkitUtil.getLocation(ignitingBlock.getLocation()).getPlot().equals(plot)) {
|
|
||||||
event.setCancelled(true);
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1920,7 +1906,8 @@ public class PlayerEvents extends PlotListener implements Listener {
|
|||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
} else if (!plot.isAdded(pp.getUUID())) {
|
}
|
||||||
|
if (!plot.isAdded(pp.getUUID())) {
|
||||||
if (!plot.getFlag(Flags.HANGING_PLACE,false)) {
|
if (!plot.getFlag(Flags.HANGING_PLACE,false)) {
|
||||||
if (!Permissions.hasPermission(pp, C.PERMISSION_ADMIN_BUILD_OTHER)) {
|
if (!Permissions.hasPermission(pp, C.PERMISSION_ADMIN_BUILD_OTHER)) {
|
||||||
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_BUILD_OTHER);
|
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_BUILD_OTHER);
|
||||||
@ -2044,13 +2031,13 @@ public class PlayerEvents extends PlotListener implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||||
public void onVehicleDestroy(VehicleDestroyEvent e) {
|
public void onVehicleDestroy(VehicleDestroyEvent event) {
|
||||||
Location l = BukkitUtil.getLocation(e.getVehicle());
|
Location l = BukkitUtil.getLocation(event.getVehicle());
|
||||||
PlotArea area = l.getPlotArea();
|
PlotArea area = l.getPlotArea();
|
||||||
if (area == null) {
|
if (area == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Entity d = e.getAttacker();
|
Entity d = event.getAttacker();
|
||||||
if (d instanceof Player) {
|
if (d instanceof Player) {
|
||||||
Player p = (Player) d;
|
Player p = (Player) d;
|
||||||
PlotPlayer pp = BukkitUtil.getPlayer(p);
|
PlotPlayer pp = BukkitUtil.getPlayer(p);
|
||||||
@ -2058,13 +2045,13 @@ public class PlayerEvents extends PlotListener implements Listener {
|
|||||||
if (plot == null) {
|
if (plot == null) {
|
||||||
if (!Permissions.hasPermission(pp, "plots.admin.vehicle.break.road")) {
|
if (!Permissions.hasPermission(pp, "plots.admin.vehicle.break.road")) {
|
||||||
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, "plots.admin.vehicle.break.road");
|
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, "plots.admin.vehicle.break.road");
|
||||||
e.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!plot.hasOwner()) {
|
if (!plot.hasOwner()) {
|
||||||
if (!Permissions.hasPermission(pp, "plots.admin.vehicle.break.unowned")) {
|
if (!Permissions.hasPermission(pp, "plots.admin.vehicle.break.unowned")) {
|
||||||
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, "plots.admin.vehicle.break.unowned");
|
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, "plots.admin.vehicle.break.unowned");
|
||||||
e.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
@ -2075,7 +2062,7 @@ public class PlayerEvents extends PlotListener implements Listener {
|
|||||||
}
|
}
|
||||||
if (!Permissions.hasPermission(pp, "plots.admin.vehicle.break.other")) {
|
if (!Permissions.hasPermission(pp, "plots.admin.vehicle.break.other")) {
|
||||||
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, "plots.admin.vehicle.break.other");
|
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, "plots.admin.vehicle.break.other");
|
||||||
e.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2102,15 +2089,15 @@ public class PlayerEvents extends PlotListener implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||||
public void onEntityDamageByEntityEvent(EntityDamageByEntityEvent e) {
|
public void onEntityDamageByEntityEvent(EntityDamageByEntityEvent event) {
|
||||||
Entity damager = e.getDamager();
|
Entity damager = event.getDamager();
|
||||||
Location l = BukkitUtil.getLocation(damager);
|
Location l = BukkitUtil.getLocation(damager);
|
||||||
if (!PS.get().hasPlotArea(l.getWorld())) {
|
if (!PS.get().hasPlotArea(l.getWorld())) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Entity victim = e.getEntity();
|
Entity victim = event.getEntity();
|
||||||
if (!entityDamage(damager, victim)) {
|
if (!entityDamage(damager, victim)) {
|
||||||
e.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2253,29 +2240,29 @@ public class PlayerEvents extends PlotListener implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||||
public void onPlayerEggThrow(PlayerEggThrowEvent e) {
|
public void onPlayerEggThrow(PlayerEggThrowEvent event) {
|
||||||
Location l = BukkitUtil.getLocation(e.getEgg().getLocation());
|
Location l = BukkitUtil.getLocation(event.getEgg().getLocation());
|
||||||
PlotArea area = l.getPlotArea();
|
PlotArea area = l.getPlotArea();
|
||||||
if (area == null) {
|
if (area == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Player p = e.getPlayer();
|
Player p = event.getPlayer();
|
||||||
PlotPlayer pp = BukkitUtil.getPlayer(p);
|
PlotPlayer pp = BukkitUtil.getPlayer(p);
|
||||||
Plot plot = area.getPlot(l);
|
Plot plot = area.getPlot(l);
|
||||||
if (plot == null) {
|
if (plot == null) {
|
||||||
if (!Permissions.hasPermission(pp, "plots.admin.projectile.road")) {
|
if (!Permissions.hasPermission(pp, "plots.admin.projectile.road")) {
|
||||||
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, "plots.admin.projectile.road");
|
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, "plots.admin.projectile.road");
|
||||||
e.setHatching(false);
|
event.setHatching(false);
|
||||||
}
|
}
|
||||||
} else if (!plot.hasOwner()) {
|
} else if (!plot.hasOwner()) {
|
||||||
if (!Permissions.hasPermission(pp, "plots.admin.projectile.unowned")) {
|
if (!Permissions.hasPermission(pp, "plots.admin.projectile.unowned")) {
|
||||||
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, "plots.admin.projectile.unowned");
|
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, "plots.admin.projectile.unowned");
|
||||||
e.setHatching(false);
|
event.setHatching(false);
|
||||||
}
|
}
|
||||||
} else if (!plot.isAdded(pp.getUUID())) {
|
} else if (!plot.isAdded(pp.getUUID())) {
|
||||||
if (!Permissions.hasPermission(pp, "plots.admin.projectile.other")) {
|
if (!Permissions.hasPermission(pp, "plots.admin.projectile.other")) {
|
||||||
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, "plots.admin.projectile.other");
|
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, "plots.admin.projectile.other");
|
||||||
e.setHatching(false);
|
event.setHatching(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2326,7 +2313,7 @@ public class PlayerEvents extends PlotListener implements Listener {
|
|||||||
if (loc.getY() > area.MAX_BUILD_HEIGHT && loc.getY() < area.MIN_BUILD_HEIGHT && !Permissions
|
if (loc.getY() > area.MAX_BUILD_HEIGHT && loc.getY() < area.MIN_BUILD_HEIGHT && !Permissions
|
||||||
.hasPermission(pp, C.PERMISSION_ADMIN_BUILD_HEIGHTLIMIT)) {
|
.hasPermission(pp, C.PERMISSION_ADMIN_BUILD_HEIGHTLIMIT)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
MainUtil.sendMessage(pp, C.HEIGHT_LIMIT.s().replace("{limit}", "" + area.MAX_BUILD_HEIGHT));
|
MainUtil.sendMessage(pp, C.HEIGHT_LIMIT.s().replace("{limit}", String.valueOf(area.MAX_BUILD_HEIGHT)));
|
||||||
}
|
}
|
||||||
} else if (!Permissions.hasPermission(pp, C.PERMISSION_ADMIN_BUILD_OTHER)) {
|
} else if (!Permissions.hasPermission(pp, C.PERMISSION_ADMIN_BUILD_OTHER)) {
|
||||||
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_BUILD_ROAD);
|
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_BUILD_ROAD);
|
||||||
|
@ -9,9 +9,6 @@ import org.bukkit.event.EventPriority;
|
|||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.entity.LingeringPotionSplashEvent;
|
import org.bukkit.event.entity.LingeringPotionSplashEvent;
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by Jesse on 3/30/2016.
|
|
||||||
*/
|
|
||||||
public class PlayerEvents_1_9 implements Listener {
|
public class PlayerEvents_1_9 implements Listener {
|
||||||
|
|
||||||
private final PlayerEvents parent;
|
private final PlayerEvents parent;
|
||||||
|
@ -131,10 +131,13 @@ public class PlotPlusListener extends PlotListener implements Listener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
UUID uuid = pp.getUUID();
|
UUID uuid = pp.getUUID();
|
||||||
if (plot.isAdded(uuid) && plot.getFlag(Flags.ITEM_DROP).or(false)) {
|
if (plot.isAdded(uuid)) {
|
||||||
|
Optional<Boolean> flag = plot.getFlag(Flags.ITEM_DROP);
|
||||||
|
if (flag.isPresent() && !flag.get()) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPlotEnter(PlayerEnterPlotEvent event) {
|
public void onPlotEnter(PlayerEnterPlotEvent event) {
|
||||||
|
@ -27,25 +27,25 @@ import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
|||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
public class WEListener implements Listener {
|
public class WEListener implements Listener {
|
||||||
|
|
||||||
public final HashSet<String> rad1 = new HashSet<>(
|
public final Set<String> other = new HashSet<>(Arrays.asList("undo", "redo"));
|
||||||
|
private final Set<String> rad1 = new HashSet<>(
|
||||||
Arrays.asList("forestgen", "pumpkins", "drain", "fixwater", "fixlava", "replacenear", "snow", "thaw", "ex", "butcher", "size"));
|
Arrays.asList("forestgen", "pumpkins", "drain", "fixwater", "fixlava", "replacenear", "snow", "thaw", "ex", "butcher", "size"));
|
||||||
public final HashSet<String> rad2 = new HashSet<>(Arrays.asList("fill", "fillr", "removenear", "remove"));
|
private final Set<String> rad2 = new HashSet<>(Arrays.asList("fill", "fillr", "removenear", "remove"));
|
||||||
public final HashSet<String> rad2_1 = new HashSet<>(Arrays.asList("hcyl", "cyl"));
|
private final Set<String> rad2_1 = new HashSet<>(Arrays.asList("hcyl", "cyl"));
|
||||||
public final HashSet<String> rad2_2 = new HashSet<>(Arrays.asList("sphere", "pyramid"));
|
private final Set<String> rad2_2 = new HashSet<>(Arrays.asList("sphere", "pyramid"));
|
||||||
public final HashSet<String> rad2_3 = new HashSet<>(Collections.singletonList("brush smooth"));
|
private final Set<String> rad2_3 = Collections.singleton("brush smooth");
|
||||||
public final HashSet<String> rad3_1 = new HashSet<>(Collections.singletonList("brush gravity"));
|
private final Set<String> rad3_1 = Collections.singleton("brush gravity");
|
||||||
public final HashSet<String> rad3_2 = new HashSet<>(Arrays.asList("brush sphere", "brush cylinder"));
|
private final Set<String> rad3_2 = new HashSet<>(Arrays.asList("brush sphere", "brush cylinder"));
|
||||||
|
private final Set<String> region = new HashSet<>(
|
||||||
public final HashSet<String> region = new HashSet<>(
|
|
||||||
Arrays.asList("move", "set", "replace", "overlay", "walls", "outline", "deform", "hollow", "smooth", "naturalize", "paste", "count",
|
Arrays.asList("move", "set", "replace", "overlay", "walls", "outline", "deform", "hollow", "smooth", "naturalize", "paste", "count",
|
||||||
"distr",
|
"distr",
|
||||||
"regen", "copy", "cut", "green", "setbiome"));
|
"regen", "copy", "cut", "green", "setbiome"));
|
||||||
public final HashSet<String> regionExtend = new HashSet<>(Collections.singletonList("stack"));
|
private final Set<String> regionExtend = Collections.singleton("stack");
|
||||||
public final HashSet<String> restricted = new HashSet<>(Collections.singletonList("up"));
|
private final Set<String> restricted = Collections.singleton("up");
|
||||||
public final HashSet<String> other = new HashSet<>(Arrays.asList("undo", "redo"));
|
|
||||||
|
|
||||||
public String reduceCmd(String cmd, boolean single) {
|
public String reduceCmd(String cmd, boolean single) {
|
||||||
if (cmd.startsWith("/worldedit:/")) {
|
if (cmd.startsWith("/worldedit:/")) {
|
||||||
@ -74,14 +74,14 @@ public class WEListener implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return max;
|
return max;
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException ignored) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean checkVolume(PlotPlayer player, long volume, long max, Cancellable e) {
|
public boolean checkVolume(PlotPlayer player, long volume, long max, Cancellable e) {
|
||||||
if (volume > max) {
|
if (volume > max) {
|
||||||
MainUtil.sendMessage(player, C.WORLDEDIT_VOLUME.s().replaceAll("%current%", volume + "").replaceAll("%max%", max + ""));
|
MainUtil.sendMessage(player, C.WORLDEDIT_VOLUME.s().replaceAll("%current%", String.valueOf(volume)).replaceAll("%max%", String.valueOf(max)));
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
}
|
}
|
||||||
if (Permissions.hasPermission(player, "plots.worldedit.bypass")) {
|
if (Permissions.hasPermission(player, "plots.worldedit.bypass")) {
|
||||||
@ -180,7 +180,7 @@ public class WEListener implements Listener {
|
|||||||
boolean single = true;
|
boolean single = true;
|
||||||
if (split.length >= 2) {
|
if (split.length >= 2) {
|
||||||
String reduced = reduceCmd(split[0], single);
|
String reduced = reduceCmd(split[0], single);
|
||||||
String reduced2 = reduceCmd(split[0] + " " + split[1], single);
|
String reduced2 = reduceCmd(split[0] + ' ' + split[1], single);
|
||||||
if (this.rad1.contains(reduced)) {
|
if (this.rad1.contains(reduced)) {
|
||||||
if (delay(p, message, false)) {
|
if (delay(p, message, false)) {
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
@ -233,7 +233,8 @@ public class WEListener implements Listener {
|
|||||||
int iterations = getInt(split[3]);
|
int iterations = getInt(split[3]);
|
||||||
if (iterations > maxIterations) {
|
if (iterations > maxIterations) {
|
||||||
MainUtil.sendMessage(pp,
|
MainUtil.sendMessage(pp,
|
||||||
C.WORLDEDIT_ITERATIONS.s().replaceAll("%current%", iterations + "").replaceAll("%max%", maxIterations + ""));
|
C.WORLDEDIT_ITERATIONS.s().replaceAll("%current%", String.valueOf(iterations)).replaceAll("%max%",
|
||||||
|
String.valueOf(maxIterations)));
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
if (Permissions.hasPermission(pp, "plots.worldedit.bypass")) {
|
if (Permissions.hasPermission(pp, "plots.worldedit.bypass")) {
|
||||||
MainUtil.sendMessage(pp, C.WORLDEDIT_BYPASS);
|
MainUtil.sendMessage(pp, C.WORLDEDIT_BYPASS);
|
||||||
|
@ -465,8 +465,7 @@ public class EntityWrapper {
|
|||||||
if (this.base.passenger != null) {
|
if (this.base.passenger != null) {
|
||||||
try {
|
try {
|
||||||
entity.setPassenger(this.base.passenger.spawn(world, x_offset, z_offset));
|
entity.setPassenger(this.base.passenger.spawn(world, x_offset, z_offset));
|
||||||
} catch (Exception ignored) {
|
} catch (Exception ignored) {}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (this.base.fall != 0) {
|
if (this.base.fall != 0) {
|
||||||
entity.setFallDistance(this.base.fall);
|
entity.setFallDistance(this.base.fall);
|
||||||
|
@ -57,14 +57,14 @@ public class DefaultTitleManager extends TitleManager {
|
|||||||
// Send title
|
// Send title
|
||||||
Object serialized = getMethod(this.nmsChatSerializer, "a", String.class).invoke(null,
|
Object serialized = getMethod(this.nmsChatSerializer, "a", String.class).invoke(null,
|
||||||
"{text:\"" + ChatColor.translateAlternateColorCodes('&', this.getTitle()) + "\",color:" + this.titleColor.name().toLowerCase()
|
"{text:\"" + ChatColor.translateAlternateColorCodes('&', this.getTitle()) + "\",color:" + this.titleColor.name().toLowerCase()
|
||||||
+ "}");
|
+ '}');
|
||||||
packet = this.packetTitle.getConstructor(this.packetActions, this.chatBaseComponent).newInstance(actions[0], serialized);
|
packet = this.packetTitle.getConstructor(this.packetActions, this.chatBaseComponent).newInstance(actions[0], serialized);
|
||||||
sendPacket.invoke(connection, packet);
|
sendPacket.invoke(connection, packet);
|
||||||
if (!this.getSubtitle().isEmpty()) {
|
if (!this.getSubtitle().isEmpty()) {
|
||||||
// Send subtitle if present
|
// Send subtitle if present
|
||||||
serialized = getMethod(this.nmsChatSerializer, "a", String.class).invoke(null,
|
serialized = getMethod(this.nmsChatSerializer, "a", String.class).invoke(null,
|
||||||
"{text:\"" + ChatColor.translateAlternateColorCodes('&', this.getSubtitle()) + "\",color:" + this.subtitleColor.name()
|
"{text:\"" + ChatColor.translateAlternateColorCodes('&', this.getSubtitle()) + "\",color:" + this.subtitleColor.name()
|
||||||
.toLowerCase() + "}");
|
.toLowerCase() + '}');
|
||||||
packet = this.packetTitle.getConstructor(this.packetActions, this.chatBaseComponent).newInstance(actions[1], serialized);
|
packet = this.packetTitle.getConstructor(this.packetActions, this.chatBaseComponent).newInstance(actions[1], serialized);
|
||||||
sendPacket.invoke(connection, packet);
|
sendPacket.invoke(connection, packet);
|
||||||
}
|
}
|
||||||
|
@ -143,12 +143,11 @@ public class HackTitleManager extends TitleManager {
|
|||||||
private Class<?> getClass(String namespace) {
|
private Class<?> getClass(String namespace) {
|
||||||
try {
|
try {
|
||||||
return Class.forName(namespace);
|
return Class.forName(namespace);
|
||||||
} catch (ClassNotFoundException ignored) {
|
} catch (ClassNotFoundException ignored) {}
|
||||||
}
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Field getField(String name, Class<?> clazz) throws Exception {
|
private Field getField(String name, Class<?> clazz) throws NoSuchFieldException, SecurityException {
|
||||||
return clazz.getDeclaredField(name);
|
return clazz.getDeclaredField(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,6 +58,7 @@ import java.util.Collections;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
@ -616,25 +617,25 @@ public class BukkitChunkManager extends ChunkManager {
|
|||||||
|
|
||||||
public static class ContentMap {
|
public static class ContentMap {
|
||||||
|
|
||||||
public final HashMap<BlockLoc, ItemStack[]> chestContents;
|
public final Map<BlockLoc, ItemStack[]> chestContents;
|
||||||
public final HashMap<BlockLoc, ItemStack[]> furnaceContents;
|
public final Map<BlockLoc, ItemStack[]> furnaceContents;
|
||||||
public final HashMap<BlockLoc, ItemStack[]> dispenserContents;
|
public final Map<BlockLoc, ItemStack[]> dispenserContents;
|
||||||
public final HashMap<BlockLoc, ItemStack[]> dropperContents;
|
public final Map<BlockLoc, ItemStack[]> dropperContents;
|
||||||
public final HashMap<BlockLoc, ItemStack[]> brewingStandContents;
|
public final Map<BlockLoc, ItemStack[]> brewingStandContents;
|
||||||
public final HashMap<BlockLoc, ItemStack[]> beaconContents;
|
public final Map<BlockLoc, ItemStack[]> beaconContents;
|
||||||
public final HashMap<BlockLoc, ItemStack[]> hopperContents;
|
public final Map<BlockLoc, ItemStack[]> hopperContents;
|
||||||
public final HashMap<BlockLoc, Short[]> furnaceTime;
|
public final Map<BlockLoc, Short[]> furnaceTime;
|
||||||
public final HashMap<BlockLoc, Object[]> skullData;
|
public final Map<BlockLoc, Object[]> skullData;
|
||||||
public final HashMap<BlockLoc, Material> jukeboxDisc;
|
public final Map<BlockLoc, Material> jukeboxDisc;
|
||||||
public final HashMap<BlockLoc, Short> brewTime;
|
public final Map<BlockLoc, Short> brewTime;
|
||||||
public final HashMap<BlockLoc, EntityType> spawnerData;
|
public final Map<BlockLoc, EntityType> spawnerData;
|
||||||
public final HashMap<BlockLoc, String> cmdData;
|
public final Map<BlockLoc, String> cmdData;
|
||||||
public final HashMap<BlockLoc, String[]> signContents;
|
public final Map<BlockLoc, String[]> signContents;
|
||||||
public final HashMap<BlockLoc, Note> noteBlockContents;
|
public final Map<BlockLoc, Note> noteBlockContents;
|
||||||
public final HashMap<BlockLoc, List<Pattern>> bannerPatterns;
|
public final Map<BlockLoc, List<Pattern>> bannerPatterns;
|
||||||
public final HashMap<BlockLoc, DyeColor> bannerBase;
|
public final Map<BlockLoc, DyeColor> bannerBase;
|
||||||
public final HashSet<EntityWrapper> entities;
|
public final Set<EntityWrapper> entities;
|
||||||
public final HashMap<PlotLoc, PlotBlock[]> allBlocks;
|
public final Map<PlotLoc, PlotBlock[]> allBlocks;
|
||||||
|
|
||||||
public ContentMap() {
|
public ContentMap() {
|
||||||
this.chestContents = new HashMap<>();
|
this.chestContents = new HashMap<>();
|
||||||
@ -742,12 +743,12 @@ public class BukkitChunkManager extends ChunkManager {
|
|||||||
chest.getInventory().setContents(blockLocEntry.getValue());
|
chest.getInventory().setContents(blockLocEntry.getValue());
|
||||||
state.update(true);
|
state.update(true);
|
||||||
} else {
|
} else {
|
||||||
PS.debug("&c[WARN] Plot clear failed to regenerate chest: " + (blockLocEntry.getKey().x + xOffset) + "," + blockLocEntry
|
PS.debug("&c[WARN] Plot clear failed to regenerate chest: " + (blockLocEntry.getKey().x + xOffset) + ',' + blockLocEntry
|
||||||
.getKey().y + "," + (blockLocEntry.getKey().z + zOffset));
|
.getKey().y + ',' + (blockLocEntry.getKey().z + zOffset));
|
||||||
}
|
}
|
||||||
} catch (IllegalArgumentException ignored) {
|
} catch (IllegalArgumentException ignored) {
|
||||||
PS.debug("&c[WARN] Plot clear failed to regenerate chest (e): " + (blockLocEntry.getKey().x + xOffset) + "," + blockLocEntry
|
PS.debug("&c[WARN] Plot clear failed to regenerate chest (e): " + (blockLocEntry.getKey().x + xOffset) + ',' + blockLocEntry
|
||||||
.getKey().y + "," + (blockLocEntry.getKey().z + zOffset));
|
.getKey().y + ',' + (blockLocEntry.getKey().z + zOffset));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (Entry<BlockLoc, String[]> blockLocEntry : this.signContents.entrySet()) {
|
for (Entry<BlockLoc, String[]> blockLocEntry : this.signContents.entrySet()) {
|
||||||
@ -765,14 +766,14 @@ public class BukkitChunkManager extends ChunkManager {
|
|||||||
state.update(true);
|
state.update(true);
|
||||||
} else {
|
} else {
|
||||||
PS.debug(
|
PS.debug(
|
||||||
"&c[WARN] Plot clear failed to regenerate sign: " + (blockLocEntry.getKey().x + xOffset) + "," + blockLocEntry
|
"&c[WARN] Plot clear failed to regenerate sign: " + (blockLocEntry.getKey().x + xOffset) + ',' + blockLocEntry
|
||||||
.getKey().y
|
.getKey().y
|
||||||
+ "," + (
|
+ ',' + (
|
||||||
blockLocEntry.getKey().z + zOffset));
|
blockLocEntry.getKey().z + zOffset));
|
||||||
}
|
}
|
||||||
} catch (IndexOutOfBoundsException e) {
|
} catch (IndexOutOfBoundsException ignored) {
|
||||||
PS.debug("&c[WARN] Plot clear failed to regenerate sign: " + (blockLocEntry.getKey().x + xOffset) + "," + blockLocEntry.getKey().y
|
PS.debug("&c[WARN] Plot clear failed to regenerate sign: " + (blockLocEntry.getKey().x + xOffset) + ',' + blockLocEntry.getKey().y
|
||||||
+ "," + (
|
+ ',' + (
|
||||||
blockLocEntry.getKey().z + zOffset));
|
blockLocEntry.getKey().z + zOffset));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -785,12 +786,12 @@ public class BukkitChunkManager extends ChunkManager {
|
|||||||
((InventoryHolder) state).getInventory().setContents(blockLocEntry.getValue());
|
((InventoryHolder) state).getInventory().setContents(blockLocEntry.getValue());
|
||||||
state.update(true);
|
state.update(true);
|
||||||
} else {
|
} else {
|
||||||
PS.debug("&c[WARN] Plot clear failed to regenerate dispenser: " + (blockLocEntry.getKey().x + xOffset) + "," + blockLocEntry
|
PS.debug("&c[WARN] Plot clear failed to regenerate dispenser: " + (blockLocEntry.getKey().x + xOffset) + ',' + blockLocEntry
|
||||||
.getKey().y + "," + (blockLocEntry.getKey().z + zOffset));
|
.getKey().y + ',' + (blockLocEntry.getKey().z + zOffset));
|
||||||
}
|
}
|
||||||
} catch (IllegalArgumentException ignored) {
|
} catch (IllegalArgumentException ignored) {
|
||||||
PS.debug("&c[WARN] Plot clear failed to regenerate dispenser (e): " + (blockLocEntry.getKey().x + xOffset) + "," + blockLocEntry
|
PS.debug("&c[WARN] Plot clear failed to regenerate dispenser (e): " + (blockLocEntry.getKey().x + xOffset) + ',' + blockLocEntry
|
||||||
.getKey().y + "," + (blockLocEntry.getKey().z + zOffset));
|
.getKey().y + ',' + (blockLocEntry.getKey().z + zOffset));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (Entry<BlockLoc, ItemStack[]> blockLocEntry : this.dropperContents.entrySet()) {
|
for (Entry<BlockLoc, ItemStack[]> blockLocEntry : this.dropperContents.entrySet()) {
|
||||||
@ -802,12 +803,12 @@ public class BukkitChunkManager extends ChunkManager {
|
|||||||
((InventoryHolder) state).getInventory().setContents(blockLocEntry.getValue());
|
((InventoryHolder) state).getInventory().setContents(blockLocEntry.getValue());
|
||||||
state.update(true);
|
state.update(true);
|
||||||
} else {
|
} else {
|
||||||
PS.debug("&c[WARN] Plot clear failed to regenerate dispenser: " + (blockLocEntry.getKey().x + xOffset) + "," + blockLocEntry
|
PS.debug("&c[WARN] Plot clear failed to regenerate dispenser: " + (blockLocEntry.getKey().x + xOffset) + ',' + blockLocEntry
|
||||||
.getKey().y + "," + (blockLocEntry.getKey().z + zOffset));
|
.getKey().y + ',' + (blockLocEntry.getKey().z + zOffset));
|
||||||
}
|
}
|
||||||
} catch (IllegalArgumentException ignored) {
|
} catch (IllegalArgumentException ignored) {
|
||||||
PS.debug("&c[WARN] Plot clear failed to regenerate dispenser (e): " + (blockLocEntry.getKey().x + xOffset) + "," + blockLocEntry
|
PS.debug("&c[WARN] Plot clear failed to regenerate dispenser (e): " + (blockLocEntry.getKey().x + xOffset) + ',' + blockLocEntry
|
||||||
.getKey().y + "," + (blockLocEntry.getKey().z + zOffset));
|
.getKey().y + ',' + (blockLocEntry.getKey().z + zOffset));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (Entry<BlockLoc, ItemStack[]> blockLocEntry : this.beaconContents.entrySet()) {
|
for (Entry<BlockLoc, ItemStack[]> blockLocEntry : this.beaconContents.entrySet()) {
|
||||||
@ -819,12 +820,12 @@ public class BukkitChunkManager extends ChunkManager {
|
|||||||
((InventoryHolder) state).getInventory().setContents(blockLocEntry.getValue());
|
((InventoryHolder) state).getInventory().setContents(blockLocEntry.getValue());
|
||||||
state.update(true);
|
state.update(true);
|
||||||
} else {
|
} else {
|
||||||
PS.debug("&c[WARN] Plot clear failed to regenerate beacon: " + (blockLocEntry.getKey().x + xOffset) + "," + blockLocEntry
|
PS.debug("&c[WARN] Plot clear failed to regenerate beacon: " + (blockLocEntry.getKey().x + xOffset) + ',' + blockLocEntry
|
||||||
.getKey().y + "," + (blockLocEntry.getKey().z + zOffset));
|
.getKey().y + ',' + (blockLocEntry.getKey().z + zOffset));
|
||||||
}
|
}
|
||||||
} catch (IllegalArgumentException ignored) {
|
} catch (IllegalArgumentException ignored) {
|
||||||
PS.debug("&c[WARN] Plot clear failed to regenerate beacon (e): " + (blockLocEntry.getKey().x + xOffset) + "," + blockLocEntry
|
PS.debug("&c[WARN] Plot clear failed to regenerate beacon (e): " + (blockLocEntry.getKey().x + xOffset) + ',' + blockLocEntry
|
||||||
.getKey().y + "," + (blockLocEntry.getKey().z + zOffset));
|
.getKey().y + ',' + (blockLocEntry.getKey().z + zOffset));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (Entry<BlockLoc, Material> blockLocMaterialEntry : this.jukeboxDisc.entrySet()) {
|
for (Entry<BlockLoc, Material> blockLocMaterialEntry : this.jukeboxDisc.entrySet()) {
|
||||||
@ -837,15 +838,15 @@ public class BukkitChunkManager extends ChunkManager {
|
|||||||
((Jukebox) state).setPlaying(blockLocMaterialEntry.getValue());
|
((Jukebox) state).setPlaying(blockLocMaterialEntry.getValue());
|
||||||
state.update(true);
|
state.update(true);
|
||||||
} else {
|
} else {
|
||||||
PS.debug("&c[WARN] Plot clear failed to restore jukebox: " + (blockLocMaterialEntry.getKey().x + xOffset) + ","
|
PS.debug("&c[WARN] Plot clear failed to restore jukebox: " + (blockLocMaterialEntry.getKey().x + xOffset) + ','
|
||||||
+ blockLocMaterialEntry
|
+ blockLocMaterialEntry
|
||||||
.getKey().y + "," + (
|
.getKey().y + ',' + (
|
||||||
blockLocMaterialEntry.getKey().z + zOffset));
|
blockLocMaterialEntry.getKey().z + zOffset));
|
||||||
}
|
}
|
||||||
} catch (Exception ignored) {
|
} catch (Exception ignored) {
|
||||||
PS.debug("&c[WARN] Plot clear failed to regenerate jukebox (e): " + (blockLocMaterialEntry.getKey().x + xOffset) + ","
|
PS.debug("&c[WARN] Plot clear failed to regenerate jukebox (e): " + (blockLocMaterialEntry.getKey().x + xOffset) + ','
|
||||||
+ blockLocMaterialEntry
|
+ blockLocMaterialEntry
|
||||||
.getKey().y + "," + (
|
.getKey().y + ',' + (
|
||||||
blockLocMaterialEntry.getKey().z + zOffset));
|
blockLocMaterialEntry.getKey().z + zOffset));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -863,12 +864,12 @@ public class BukkitChunkManager extends ChunkManager {
|
|||||||
((Skull) state).setSkullType((SkullType) data[3]);
|
((Skull) state).setSkullType((SkullType) data[3]);
|
||||||
state.update(true);
|
state.update(true);
|
||||||
} else {
|
} else {
|
||||||
PS.debug("&c[WARN] Plot clear failed to restore skull: " + (blockLocEntry.getKey().x + xOffset) + "," + blockLocEntry
|
PS.debug("&c[WARN] Plot clear failed to restore skull: " + (blockLocEntry.getKey().x + xOffset) + ',' + blockLocEntry
|
||||||
.getKey().y + "," + (blockLocEntry.getKey().z + zOffset));
|
.getKey().y + ',' + (blockLocEntry.getKey().z + zOffset));
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
PS.debug("&c[WARN] Plot clear failed to regenerate skull (e): " + (blockLocEntry.getKey().x + xOffset) + "," + blockLocEntry
|
PS.debug("&c[WARN] Plot clear failed to regenerate skull (e): " + (blockLocEntry.getKey().x + xOffset) + ',' + blockLocEntry
|
||||||
.getKey().y + "," + (blockLocEntry.getKey().z + zOffset));
|
.getKey().y + ',' + (blockLocEntry.getKey().z + zOffset));
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -881,12 +882,12 @@ public class BukkitChunkManager extends ChunkManager {
|
|||||||
((InventoryHolder) state).getInventory().setContents(blockLocEntry.getValue());
|
((InventoryHolder) state).getInventory().setContents(blockLocEntry.getValue());
|
||||||
state.update(true);
|
state.update(true);
|
||||||
} else {
|
} else {
|
||||||
PS.debug("&c[WARN] Plot clear failed to regenerate hopper: " + (blockLocEntry.getKey().x + xOffset) + "," + blockLocEntry
|
PS.debug("&c[WARN] Plot clear failed to regenerate hopper: " + (blockLocEntry.getKey().x + xOffset) + ',' + blockLocEntry
|
||||||
.getKey().y + "," + (blockLocEntry.getKey().z + zOffset));
|
.getKey().y + ',' + (blockLocEntry.getKey().z + zOffset));
|
||||||
}
|
}
|
||||||
} catch (IllegalArgumentException ignored) {
|
} catch (IllegalArgumentException ignored) {
|
||||||
PS.debug("&c[WARN] Plot clear failed to regenerate hopper (e): " + (blockLocEntry.getKey().x + xOffset) + "," + blockLocEntry
|
PS.debug("&c[WARN] Plot clear failed to regenerate hopper (e): " + (blockLocEntry.getKey().x + xOffset) + ',' + blockLocEntry
|
||||||
.getKey().y + "," + (blockLocEntry.getKey().z + zOffset));
|
.getKey().y + ',' + (blockLocEntry.getKey().z + zOffset));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (Entry<BlockLoc, Note> blockLocNoteEntry : this.noteBlockContents.entrySet()) {
|
for (Entry<BlockLoc, Note> blockLocNoteEntry : this.noteBlockContents.entrySet()) {
|
||||||
@ -898,15 +899,15 @@ public class BukkitChunkManager extends ChunkManager {
|
|||||||
((NoteBlock) state).setNote(blockLocNoteEntry.getValue());
|
((NoteBlock) state).setNote(blockLocNoteEntry.getValue());
|
||||||
state.update(true);
|
state.update(true);
|
||||||
} else {
|
} else {
|
||||||
PS.debug("&c[WARN] Plot clear failed to regenerate note block: " + (blockLocNoteEntry.getKey().x + xOffset) + ","
|
PS.debug("&c[WARN] Plot clear failed to regenerate note block: " + (blockLocNoteEntry.getKey().x + xOffset) + ','
|
||||||
+ blockLocNoteEntry
|
+ blockLocNoteEntry
|
||||||
.getKey().y + "," + (
|
.getKey().y + ',' + (
|
||||||
blockLocNoteEntry.getKey().z + zOffset));
|
blockLocNoteEntry.getKey().z + zOffset));
|
||||||
}
|
}
|
||||||
} catch (Exception ignored) {
|
} catch (Exception ignored) {
|
||||||
PS.debug("&c[WARN] Plot clear failed to regenerate note block (e): " + (blockLocNoteEntry.getKey().x + xOffset) + ","
|
PS.debug("&c[WARN] Plot clear failed to regenerate note block (e): " + (blockLocNoteEntry.getKey().x + xOffset) + ','
|
||||||
+ blockLocNoteEntry
|
+ blockLocNoteEntry
|
||||||
.getKey().y + "," + (
|
.getKey().y + ',' + (
|
||||||
blockLocNoteEntry.getKey().z + zOffset));
|
blockLocNoteEntry.getKey().z + zOffset));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -918,14 +919,14 @@ public class BukkitChunkManager extends ChunkManager {
|
|||||||
if (state instanceof BrewingStand) {
|
if (state instanceof BrewingStand) {
|
||||||
((BrewingStand) state).setBrewingTime(blockLocShortEntry.getValue());
|
((BrewingStand) state).setBrewingTime(blockLocShortEntry.getValue());
|
||||||
} else {
|
} else {
|
||||||
PS.debug("&c[WARN] Plot clear failed to restore brewing stand cooking: " + (blockLocShortEntry.getKey().x + xOffset) + ","
|
PS.debug("&c[WARN] Plot clear failed to restore brewing stand cooking: " + (blockLocShortEntry.getKey().x + xOffset) + ','
|
||||||
+ blockLocShortEntry
|
+ blockLocShortEntry
|
||||||
.getKey().y + "," + (
|
.getKey().y + ',' + (
|
||||||
blockLocShortEntry.getKey().z + zOffset));
|
blockLocShortEntry.getKey().z + zOffset));
|
||||||
}
|
}
|
||||||
} catch (Exception ignored) {
|
} catch (Exception ignored) {
|
||||||
PS.debug("&c[WARN] Plot clear failed to restore brewing stand cooking (e): " + (blockLocShortEntry.getKey().x + xOffset) + ","
|
PS.debug("&c[WARN] Plot clear failed to restore brewing stand cooking (e): " + (blockLocShortEntry.getKey().x + xOffset) + ','
|
||||||
+ blockLocShortEntry.getKey().y + "," + (blockLocShortEntry.getKey().z + zOffset));
|
+ blockLocShortEntry.getKey().y + ',' + (blockLocShortEntry.getKey().z + zOffset));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (Entry<BlockLoc, EntityType> blockLocEntityTypeEntry : this.spawnerData.entrySet()) {
|
for (Entry<BlockLoc, EntityType> blockLocEntityTypeEntry : this.spawnerData.entrySet()) {
|
||||||
@ -938,14 +939,14 @@ public class BukkitChunkManager extends ChunkManager {
|
|||||||
((CreatureSpawner) state).setSpawnedType(blockLocEntityTypeEntry.getValue());
|
((CreatureSpawner) state).setSpawnedType(blockLocEntityTypeEntry.getValue());
|
||||||
state.update(true);
|
state.update(true);
|
||||||
} else {
|
} else {
|
||||||
PS.debug("&c[WARN] Plot clear failed to restore spawner type: " + (blockLocEntityTypeEntry.getKey().x + xOffset) + ","
|
PS.debug("&c[WARN] Plot clear failed to restore spawner type: " + (blockLocEntityTypeEntry.getKey().x + xOffset) + ','
|
||||||
+ blockLocEntityTypeEntry
|
+ blockLocEntityTypeEntry
|
||||||
.getKey().y + "," + (
|
.getKey().y + ',' + (
|
||||||
blockLocEntityTypeEntry.getKey().z + zOffset));
|
blockLocEntityTypeEntry.getKey().z + zOffset));
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception ignored) {
|
||||||
PS.debug("&c[WARN] Plot clear failed to restore spawner type (e): " + (blockLocEntityTypeEntry.getKey().x + xOffset) + ","
|
PS.debug("&c[WARN] Plot clear failed to restore spawner type (e): " + (blockLocEntityTypeEntry.getKey().x + xOffset) + ','
|
||||||
+ blockLocEntityTypeEntry.getKey().y + "," + (blockLocEntityTypeEntry.getKey().z + zOffset));
|
+ blockLocEntityTypeEntry.getKey().y + ',' + (blockLocEntityTypeEntry.getKey().z + zOffset));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (Entry<BlockLoc, String> blockLocStringEntry : this.cmdData.entrySet()) {
|
for (Entry<BlockLoc, String> blockLocStringEntry : this.cmdData.entrySet()) {
|
||||||
@ -957,15 +958,15 @@ public class BukkitChunkManager extends ChunkManager {
|
|||||||
((CommandBlock) state).setCommand(blockLocStringEntry.getValue());
|
((CommandBlock) state).setCommand(blockLocStringEntry.getValue());
|
||||||
state.update(true);
|
state.update(true);
|
||||||
} else {
|
} else {
|
||||||
PS.debug("&c[WARN] Plot clear failed to restore command block: " + (blockLocStringEntry.getKey().x + xOffset) + ","
|
PS.debug("&c[WARN] Plot clear failed to restore command block: " + (blockLocStringEntry.getKey().x + xOffset) + ','
|
||||||
+ blockLocStringEntry
|
+ blockLocStringEntry
|
||||||
.getKey().y + "," + (
|
.getKey().y + ',' + (
|
||||||
blockLocStringEntry.getKey().z + zOffset));
|
blockLocStringEntry.getKey().z + zOffset));
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception ignored) {
|
||||||
PS.debug("&c[WARN] Plot clear failed to restore command block (e): " + (blockLocStringEntry.getKey().x + xOffset) + ","
|
PS.debug("&c[WARN] Plot clear failed to restore command block (e): " + (blockLocStringEntry.getKey().x + xOffset) + ','
|
||||||
+ blockLocStringEntry
|
+ blockLocStringEntry
|
||||||
.getKey().y + "," + (
|
.getKey().y + ',' + (
|
||||||
blockLocStringEntry.getKey().z + zOffset));
|
blockLocStringEntry.getKey().z + zOffset));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -978,15 +979,15 @@ public class BukkitChunkManager extends ChunkManager {
|
|||||||
((InventoryHolder) state).getInventory().setContents(blockLocEntry.getValue());
|
((InventoryHolder) state).getInventory().setContents(blockLocEntry.getValue());
|
||||||
state.update(true);
|
state.update(true);
|
||||||
} else {
|
} else {
|
||||||
PS.debug("&c[WARN] Plot clear failed to regenerate brewing stand: " + (blockLocEntry.getKey().x + xOffset) + ","
|
PS.debug("&c[WARN] Plot clear failed to regenerate brewing stand: " + (blockLocEntry.getKey().x + xOffset) + ','
|
||||||
+ blockLocEntry
|
+ blockLocEntry
|
||||||
.getKey().y + "," + (
|
.getKey().y + ',' + (
|
||||||
blockLocEntry.getKey().z
|
blockLocEntry.getKey().z
|
||||||
+ zOffset));
|
+ zOffset));
|
||||||
}
|
}
|
||||||
} catch (IllegalArgumentException e) {
|
} catch (IllegalArgumentException ignored) {
|
||||||
PS.debug("&c[WARN] Plot clear failed to regenerate brewing stand (e): " + (blockLocEntry.getKey().x + xOffset) + ","
|
PS.debug("&c[WARN] Plot clear failed to regenerate brewing stand (e): " + (blockLocEntry.getKey().x + xOffset) + ','
|
||||||
+ blockLocEntry.getKey().y + "," + (blockLocEntry.getKey().z + zOffset));
|
+ blockLocEntry.getKey().y + ',' + (blockLocEntry.getKey().z + zOffset));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (Entry<BlockLoc, Short[]> blockLocEntry : this.furnaceTime.entrySet()) {
|
for (Entry<BlockLoc, Short[]> blockLocEntry : this.furnaceTime.entrySet()) {
|
||||||
@ -1000,13 +1001,13 @@ public class BukkitChunkManager extends ChunkManager {
|
|||||||
((Furnace) state).setCookTime(time[1]);
|
((Furnace) state).setCookTime(time[1]);
|
||||||
} else {
|
} else {
|
||||||
PS.debug(
|
PS.debug(
|
||||||
"&c[WARN] Plot clear failed to restore furnace cooking: " + (blockLocEntry.getKey().x + xOffset) + "," + blockLocEntry
|
"&c[WARN] Plot clear failed to restore furnace cooking: " + (blockLocEntry.getKey().x + xOffset) + ',' + blockLocEntry
|
||||||
.getKey().y + "," + (blockLocEntry.getKey().z + zOffset));
|
.getKey().y + ',' + (blockLocEntry.getKey().z + zOffset));
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception ignored) {
|
||||||
PS.debug(
|
PS.debug(
|
||||||
"&c[WARN] Plot clear failed to restore furnace cooking (e): " + (blockLocEntry.getKey().x + xOffset) + "," + blockLocEntry
|
"&c[WARN] Plot clear failed to restore furnace cooking (e): " + (blockLocEntry.getKey().x + xOffset) + ',' + blockLocEntry
|
||||||
.getKey().y + "," + (blockLocEntry.getKey().z + zOffset));
|
.getKey().y + ',' + (blockLocEntry.getKey().z + zOffset));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (Entry<BlockLoc, ItemStack[]> blockLocEntry : this.furnaceContents.entrySet()) {
|
for (Entry<BlockLoc, ItemStack[]> blockLocEntry : this.furnaceContents.entrySet()) {
|
||||||
@ -1018,12 +1019,12 @@ public class BukkitChunkManager extends ChunkManager {
|
|||||||
((InventoryHolder) state).getInventory().setContents(blockLocEntry.getValue());
|
((InventoryHolder) state).getInventory().setContents(blockLocEntry.getValue());
|
||||||
state.update(true);
|
state.update(true);
|
||||||
} else {
|
} else {
|
||||||
PS.debug("&c[WARN] Plot clear failed to regenerate furnace: " + (blockLocEntry.getKey().x + xOffset) + "," + blockLocEntry
|
PS.debug("&c[WARN] Plot clear failed to regenerate furnace: " + (blockLocEntry.getKey().x + xOffset) + ',' + blockLocEntry
|
||||||
.getKey().y + "," + (blockLocEntry.getKey().z + zOffset));
|
.getKey().y + ',' + (blockLocEntry.getKey().z + zOffset));
|
||||||
}
|
}
|
||||||
} catch (IllegalArgumentException e) {
|
} catch (IllegalArgumentException ignored) {
|
||||||
PS.debug("&c[WARN] Plot clear failed to regenerate furnace (e): " + (blockLocEntry.getKey().x + xOffset) + "," + blockLocEntry
|
PS.debug("&c[WARN] Plot clear failed to regenerate furnace (e): " + (blockLocEntry.getKey().x + xOffset) + ',' + blockLocEntry
|
||||||
.getKey().y + "," + (blockLocEntry.getKey().z + zOffset));
|
.getKey().y + ',' + (blockLocEntry.getKey().z + zOffset));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (Entry<BlockLoc, DyeColor> blockLocByteEntry : this.bannerBase.entrySet()) {
|
for (Entry<BlockLoc, DyeColor> blockLocByteEntry : this.bannerBase.entrySet()) {
|
||||||
@ -1039,12 +1040,12 @@ public class BukkitChunkManager extends ChunkManager {
|
|||||||
banner.setPatterns(patterns);
|
banner.setPatterns(patterns);
|
||||||
state.update(true);
|
state.update(true);
|
||||||
} else {
|
} else {
|
||||||
PS.debug("&c[WARN] Plot clear failed to regenerate banner: " + (blockLocByteEntry.getKey().x + xOffset) + ","
|
PS.debug("&c[WARN] Plot clear failed to regenerate banner: " + (blockLocByteEntry.getKey().x + xOffset) + ','
|
||||||
+ blockLocByteEntry.getKey().y + "," + (blockLocByteEntry.getKey().z + zOffset));
|
+ blockLocByteEntry.getKey().y + ',' + (blockLocByteEntry.getKey().z + zOffset));
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception ignored) {
|
||||||
PS.debug("&c[WARN] Plot clear failed to regenerate banner (e): " + (blockLocByteEntry.getKey().x + xOffset) + ","
|
PS.debug("&c[WARN] Plot clear failed to regenerate banner (e): " + (blockLocByteEntry.getKey().x + xOffset) + ','
|
||||||
+ blockLocByteEntry.getKey().y + "," + (blockLocByteEntry.getKey().z + zOffset));
|
+ blockLocByteEntry.getKey().y + ',' + (blockLocByteEntry.getKey().z + zOffset));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1074,17 +1075,23 @@ public class BukkitChunkManager extends ChunkManager {
|
|||||||
if (block.getState() instanceof InventoryHolder) {
|
if (block.getState() instanceof InventoryHolder) {
|
||||||
InventoryHolder inventoryHolder = (InventoryHolder) block.getState();
|
InventoryHolder inventoryHolder = (InventoryHolder) block.getState();
|
||||||
ItemStack[] inventory = inventoryHolder.getInventory().getContents().clone();
|
ItemStack[] inventory = inventoryHolder.getInventory().getContents().clone();
|
||||||
if (id == Material.CHEST) {
|
switch (id) {
|
||||||
|
case CHEST:
|
||||||
this.chestContents.put(bl, inventory);
|
this.chestContents.put(bl, inventory);
|
||||||
} else if (id == Material.DISPENSER) {
|
break;
|
||||||
|
case DISPENSER:
|
||||||
this.dispenserContents.put(bl, inventory);
|
this.dispenserContents.put(bl, inventory);
|
||||||
} else if (id == Material.BEACON) {
|
break;
|
||||||
|
case BEACON:
|
||||||
this.beaconContents.put(bl, inventory);
|
this.beaconContents.put(bl, inventory);
|
||||||
} else if (id == Material.DROPPER) {
|
break;
|
||||||
|
case DROPPER:
|
||||||
this.dropperContents.put(bl, inventory);
|
this.dropperContents.put(bl, inventory);
|
||||||
} else if (id == Material.HOPPER) {
|
break;
|
||||||
|
case HOPPER:
|
||||||
this.hopperContents.put(bl, inventory);
|
this.hopperContents.put(bl, inventory);
|
||||||
} else if (id == Material.BREWING_STAND) {
|
break;
|
||||||
|
case BREWING_STAND:
|
||||||
BrewingStand brewingStand = (BrewingStand) inventoryHolder;
|
BrewingStand brewingStand = (BrewingStand) inventoryHolder;
|
||||||
short time = (short) brewingStand.getBrewingTime();
|
short time = (short) brewingStand.getBrewingTime();
|
||||||
if (time > 0) {
|
if (time > 0) {
|
||||||
@ -1092,7 +1099,9 @@ public class BukkitChunkManager extends ChunkManager {
|
|||||||
}
|
}
|
||||||
ItemStack[] invBre = brewingStand.getInventory().getContents().clone();
|
ItemStack[] invBre = brewingStand.getInventory().getContents().clone();
|
||||||
this.brewingStandContents.put(bl, invBre);
|
this.brewingStandContents.put(bl, invBre);
|
||||||
} else if (id == Material.FURNACE || id == Material.BURNING_FURNACE) {
|
break;
|
||||||
|
case FURNACE:
|
||||||
|
case BURNING_FURNACE:
|
||||||
Furnace furnace = (Furnace) inventoryHolder;
|
Furnace furnace = (Furnace) inventoryHolder;
|
||||||
short burn = furnace.getBurnTime();
|
short burn = furnace.getBurnTime();
|
||||||
short cook = furnace.getCookTime();
|
short cook = furnace.getCookTime();
|
||||||
@ -1101,6 +1110,7 @@ public class BukkitChunkManager extends ChunkManager {
|
|||||||
if (cook != 0) {
|
if (cook != 0) {
|
||||||
this.furnaceTime.put(bl, new Short[]{burn, cook});
|
this.furnaceTime.put(bl, new Short[]{burn, cook});
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
} else if (block.getState() instanceof CreatureSpawner) {
|
} else if (block.getState() instanceof CreatureSpawner) {
|
||||||
CreatureSpawner spawner = (CreatureSpawner) block.getState();
|
CreatureSpawner spawner = (CreatureSpawner) block.getState();
|
||||||
|
@ -49,8 +49,7 @@ public class BukkitHybridUtils extends HybridUtils {
|
|||||||
}
|
}
|
||||||
final BiomeGrid nullBiomeGrid = new BiomeGrid() {
|
final BiomeGrid nullBiomeGrid = new BiomeGrid() {
|
||||||
@Override
|
@Override
|
||||||
public void setBiome(int a, int b, Biome c) {
|
public void setBiome(int a, int b, Biome c) {}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Biome getBiome(int a, int b) {
|
public Biome getBiome(int a, int b) {
|
||||||
|
@ -22,12 +22,10 @@ public class BukkitPlainChatManager extends ChatManager<List<StringBuilder>> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void tooltip(PlotMessage message, PlotMessage... tooltips) {
|
public void tooltip(PlotMessage message, PlotMessage... tooltips) {}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void command(PlotMessage message, String command) {
|
public void command(PlotMessage message, String command) {}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void text(PlotMessage message, String text) {
|
public void text(PlotMessage message, String text) {
|
||||||
@ -44,7 +42,6 @@ public class BukkitPlainChatManager extends ChatManager<List<StringBuilder>> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void suggest(PlotMessage plotMessage, String command) {
|
public void suggest(PlotMessage plotMessage, String command) {}
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -194,7 +194,7 @@ public class BukkitUtil extends WorldUtil {
|
|||||||
try {
|
try {
|
||||||
Biome biome = Biome.valueOf(biomeStr.toUpperCase());
|
Biome biome = Biome.valueOf(biomeStr.toUpperCase());
|
||||||
return Arrays.asList(Biome.values()).indexOf(biome);
|
return Arrays.asList(Biome.values()).indexOf(biome);
|
||||||
} catch (IllegalArgumentException e) {
|
} catch (IllegalArgumentException ignored) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -252,7 +252,7 @@ public class BukkitUtil extends WorldUtil {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
} catch (Exception e) {
|
} catch (Exception ignored) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -271,9 +271,7 @@ public class BukkitUtil extends WorldUtil {
|
|||||||
try {
|
try {
|
||||||
Material material = Material.valueOf(name.toUpperCase());
|
Material material = Material.valueOf(name.toUpperCase());
|
||||||
return new StringComparison<PlotBlock>().new ComparisonResult(0, new PlotBlock((short) material.getId(), (byte) 0));
|
return new StringComparison<PlotBlock>().new ComparisonResult(0, new PlotBlock((short) material.getId(), (byte) 0));
|
||||||
} catch (IllegalArgumentException e) {
|
} catch (IllegalArgumentException ignored) {}
|
||||||
//ignored
|
|
||||||
}
|
|
||||||
try {
|
try {
|
||||||
byte data;
|
byte data;
|
||||||
String[] split = name.split(":");
|
String[] split = name.split(":");
|
||||||
@ -297,9 +295,7 @@ public class BukkitUtil extends WorldUtil {
|
|||||||
StringComparison<PlotBlock> outer = new StringComparison<>();
|
StringComparison<PlotBlock> outer = new StringComparison<>();
|
||||||
return outer.new ComparisonResult(match, block);
|
return outer.new ComparisonResult(match, block);
|
||||||
|
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException ignored) {}
|
||||||
//ignored
|
|
||||||
}
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -95,8 +95,7 @@ public class Metrics {
|
|||||||
if (gzos != null) {
|
if (gzos != null) {
|
||||||
try {
|
try {
|
||||||
gzos.close();
|
gzos.close();
|
||||||
} catch (IOException ignore) {
|
} catch (IOException ignore) {}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return baos.toByteArray();
|
return baos.toByteArray();
|
||||||
@ -117,7 +116,7 @@ public class Metrics {
|
|||||||
Double.parseDouble(value);
|
Double.parseDouble(value);
|
||||||
isValueNumeric = true;
|
isValueNumeric = true;
|
||||||
}
|
}
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException ignored) {
|
||||||
isValueNumeric = false;
|
isValueNumeric = false;
|
||||||
}
|
}
|
||||||
if (json.charAt(json.length() - 1) != '{') {
|
if (json.charAt(json.length() - 1) != '{') {
|
||||||
@ -446,7 +445,7 @@ public class Metrics {
|
|||||||
try {
|
try {
|
||||||
Class.forName("mineshafter.MineServer");
|
Class.forName("mineshafter.MineServer");
|
||||||
return true;
|
return true;
|
||||||
} catch (ClassNotFoundException e) {
|
} catch (ClassNotFoundException ignored) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -520,11 +519,6 @@ public class Metrics {
|
|||||||
return graph.name.equals(this.name);
|
return graph.name.equals(this.name);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Called when the server owner decides to opt-out of BukkitMetrics while the server is running.
|
|
||||||
*/
|
|
||||||
protected void onOptOut() {
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -574,8 +568,7 @@ public class Metrics {
|
|||||||
/**
|
/**
|
||||||
* Called after the website graphs have been updated
|
* Called after the website graphs have been updated
|
||||||
*/
|
*/
|
||||||
public void reset() {
|
public void reset() {}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
|
@ -42,7 +42,7 @@ public class SendChunk {
|
|||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*/
|
*/
|
||||||
public SendChunk() {
|
public SendChunk() throws ClassNotFoundException, NoSuchMethodException, NoSuchFieldException {
|
||||||
RefClass classCraftPlayer = getRefClass("{cb}.entity.CraftPlayer");
|
RefClass classCraftPlayer = getRefClass("{cb}.entity.CraftPlayer");
|
||||||
this.methodGetHandlePlayer = classCraftPlayer.getMethod("getHandle");
|
this.methodGetHandlePlayer = classCraftPlayer.getMethod("getHandle");
|
||||||
RefClass classCraftChunk = getRefClass("{cb}.CraftChunk");
|
RefClass classCraftChunk = getRefClass("{cb}.CraftChunk");
|
||||||
|
@ -38,7 +38,7 @@ public class FastQueue_1_7 extends SlowQueue {
|
|||||||
|
|
||||||
private final HashMap<ChunkWrapper, Chunk> toUpdate = new HashMap<>();
|
private final HashMap<ChunkWrapper, Chunk> toUpdate = new HashMap<>();
|
||||||
|
|
||||||
public FastQueue_1_7() throws RuntimeException {
|
public FastQueue_1_7() throws NoSuchMethodException, ClassNotFoundException, NoSuchFieldException {
|
||||||
this.methodGetHandle = this.classCraftWorld.getMethod("getHandle");
|
this.methodGetHandle = this.classCraftWorld.getMethod("getHandle");
|
||||||
this.methodGetChunkAt = this.classWorld.getMethod("getChunkAt", int.class, int.class);
|
this.methodGetChunkAt = this.classWorld.getMethod("getChunkAt", int.class, int.class);
|
||||||
this.methodA = this.classChunk.getMethod("a", int.class, int.class, int.class, this.classBlock, int.class);
|
this.methodA = this.classChunk.getMethod("a", int.class, int.class, int.class, this.classBlock, int.class);
|
||||||
|
@ -41,7 +41,7 @@ public class FastQueue_1_8 extends SlowQueue {
|
|||||||
private final RefConstructor constructorBlockPosition;
|
private final RefConstructor constructorBlockPosition;
|
||||||
private final SendChunk sendChunk;
|
private final SendChunk sendChunk;
|
||||||
|
|
||||||
public FastQueue_1_8() throws RuntimeException {
|
public FastQueue_1_8() throws NoSuchMethodException, ClassNotFoundException, NoSuchFieldException {
|
||||||
this.methodInitLighting = this.classChunk.getMethod("initLighting");
|
this.methodInitLighting = this.classChunk.getMethod("initLighting");
|
||||||
this.constructorBlockPosition = this.classBlockPosition.getConstructor(int.class, int.class, int.class);
|
this.constructorBlockPosition = this.classBlockPosition.getConstructor(int.class, int.class, int.class);
|
||||||
this.methodGetByCombinedId = this.classBlock.getMethod("getByCombinedId", int.class);
|
this.methodGetByCombinedId = this.classBlock.getMethod("getByCombinedId", int.class);
|
||||||
@ -56,7 +56,7 @@ public class FastQueue_1_8 extends SlowQueue {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
int count = 0;
|
int count = 0;
|
||||||
ArrayList<Chunk> chunks = new ArrayList<Chunk>();
|
ArrayList<Chunk> chunks = new ArrayList<>();
|
||||||
Iterator<Entry<ChunkWrapper, Chunk>> i = FastQueue_1_8.this.toUpdate.entrySet().iterator();
|
Iterator<Entry<ChunkWrapper, Chunk>> i = FastQueue_1_8.this.toUpdate.entrySet().iterator();
|
||||||
while (i.hasNext() && count < 128) {
|
while (i.hasNext() && count < 128) {
|
||||||
chunks.add(i.next().getValue());
|
chunks.add(i.next().getValue());
|
||||||
|
@ -49,7 +49,7 @@ public class FastQueue_1_8_3 extends SlowQueue {
|
|||||||
private final RefMethod methodGetWorld;
|
private final RefMethod methodGetWorld;
|
||||||
private final RefField tileEntityListTick;
|
private final RefField tileEntityListTick;
|
||||||
|
|
||||||
public FastQueue_1_8_3() throws RuntimeException {
|
public FastQueue_1_8_3() throws NoSuchMethodException, ClassNotFoundException, NoSuchFieldException {
|
||||||
RefClass classCraftChunk = getRefClass("{cb}.CraftChunk");
|
RefClass classCraftChunk = getRefClass("{cb}.CraftChunk");
|
||||||
RefClass classCraftWorld = getRefClass("{cb}.CraftWorld");
|
RefClass classCraftWorld = getRefClass("{cb}.CraftWorld");
|
||||||
this.methodGetHandleChunk = classCraftChunk.getMethod("getHandle");
|
this.methodGetHandleChunk = classCraftChunk.getMethod("getHandle");
|
||||||
|
@ -51,7 +51,7 @@ public class FastQueue_1_9 extends SlowQueue {
|
|||||||
private final RefField tileEntityListTick;
|
private final RefField tileEntityListTick;
|
||||||
|
|
||||||
|
|
||||||
public FastQueue_1_9() throws RuntimeException {
|
public FastQueue_1_9() throws NoSuchFieldException, NoSuchMethodException, ClassNotFoundException {
|
||||||
RefClass classCraftChunk = getRefClass("{cb}.CraftChunk");
|
RefClass classCraftChunk = getRefClass("{cb}.CraftChunk");
|
||||||
this.methodGetHandleChunk = classCraftChunk.getMethod("getHandle");
|
this.methodGetHandleChunk = classCraftChunk.getMethod("getHandle");
|
||||||
RefClass classChunk = getRefClass("{nms}.Chunk");
|
RefClass classChunk = getRefClass("{nms}.Chunk");
|
||||||
|
@ -114,7 +114,7 @@ public class FileUUIDHandler extends UUIDHandlerImplementation {
|
|||||||
}
|
}
|
||||||
toAdd.put(new StringWrapper(name), uuid);
|
toAdd.put(new StringWrapper(name), uuid);
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
PS.debug(C.PREFIX + "Invalid playerdata: " + current);
|
PS.debug(C.PREFIX + "Invalid playerdata: " + current);
|
||||||
}
|
}
|
||||||
@ -153,7 +153,7 @@ public class FileUUIDHandler extends UUIDHandlerImplementation {
|
|||||||
try {
|
try {
|
||||||
UUID uuid = UUID.fromString(s);
|
UUID uuid = UUID.fromString(s);
|
||||||
uuids.add(uuid);
|
uuids.add(uuid);
|
||||||
} catch (Exception e) {
|
} catch (Exception ignored) {
|
||||||
PS.debug(C.PREFIX + "Invalid PlayerData: " + current);
|
PS.debug(C.PREFIX + "Invalid PlayerData: " + current);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -198,7 +198,7 @@ public class FileUUIDHandler extends UUIDHandlerImplementation {
|
|||||||
ExpireManager.IMP.storeDate(uuid, last);
|
ExpireManager.IMP.storeDate(uuid, last);
|
||||||
}
|
}
|
||||||
toAdd.put(new StringWrapper(name), uuid);
|
toAdd.put(new StringWrapper(name), uuid);
|
||||||
} catch (Throwable e) {
|
} catch (IOException ignored) {
|
||||||
PS.debug(C.PREFIX + "&6Invalid PlayerData: " + uuid.toString() + ".dat");
|
PS.debug(C.PREFIX + "&6Invalid PlayerData: " + uuid.toString() + ".dat");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,6 +14,7 @@ import org.bukkit.OfflinePlayer;
|
|||||||
import org.bukkit.Server;
|
import org.bukkit.Server;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
@ -48,11 +49,9 @@ public class OfflineUUIDWrapper extends UUIDWrapper {
|
|||||||
@Override
|
@Override
|
||||||
public OfflinePlotPlayer getOfflinePlayer(UUID uuid) {
|
public OfflinePlotPlayer getOfflinePlayer(UUID uuid) {
|
||||||
BiMap<UUID, StringWrapper> map = UUIDHandler.getUuidMap().inverse();
|
BiMap<UUID, StringWrapper> map = UUIDHandler.getUuidMap().inverse();
|
||||||
String name;
|
String name = null;
|
||||||
try {
|
if (map.containsKey(uuid)) {
|
||||||
name = map.get(uuid).value;
|
name = map.get(uuid).value;
|
||||||
} catch (NullPointerException e) {
|
|
||||||
name = null;
|
|
||||||
}
|
}
|
||||||
if (name != null) {
|
if (name != null) {
|
||||||
OfflinePlayer op = Bukkit.getOfflinePlayer(name);
|
OfflinePlayer op = Bukkit.getOfflinePlayer(name);
|
||||||
@ -81,7 +80,7 @@ public class OfflineUUIDWrapper extends UUIDWrapper {
|
|||||||
@SuppressWarnings("unchecked") Collection<? extends Player> p = (Collection<? extends Player>) players;
|
@SuppressWarnings("unchecked") Collection<? extends Player> p = (Collection<? extends Player>) players;
|
||||||
return p.toArray(new Player[p.size()]);
|
return p.toArray(new Player[p.size()]);
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (IllegalAccessException | InvocationTargetException | IllegalArgumentException ignored) {
|
||||||
PS.debug("Failed to resolve online players");
|
PS.debug("Failed to resolve online players");
|
||||||
this.getOnline = null;
|
this.getOnline = null;
|
||||||
Collection<? extends Player> onlinePlayers = Bukkit.getOnlinePlayers();
|
Collection<? extends Player> onlinePlayers = Bukkit.getOnlinePlayers();
|
||||||
|
@ -4,10 +4,10 @@ package com.intellectualcrafters.configuration;
|
|||||||
* Various settings for controlling the input and output of a {@link
|
* Various settings for controlling the input and output of a {@link
|
||||||
* Configuration}
|
* Configuration}
|
||||||
*/
|
*/
|
||||||
public class ConfigurationOptions {
|
class ConfigurationOptions {
|
||||||
|
private final Configuration configuration;
|
||||||
private char pathSeparator = '.';
|
private char pathSeparator = '.';
|
||||||
private boolean copyDefaults = false;
|
private boolean copyDefaults = false;
|
||||||
private final Configuration configuration;
|
|
||||||
|
|
||||||
protected ConfigurationOptions(final Configuration configuration) {
|
protected ConfigurationOptions(final Configuration configuration) {
|
||||||
this.configuration = configuration;
|
this.configuration = configuration;
|
||||||
|
@ -76,8 +76,7 @@ public class MemorySection implements ConfigurationSection {
|
|||||||
if (obj instanceof String) {
|
if (obj instanceof String) {
|
||||||
try {
|
try {
|
||||||
return Double.parseDouble((String) obj);
|
return Double.parseDouble((String) obj);
|
||||||
} catch (NumberFormatException ignored) {
|
} catch (NumberFormatException ignored) {}
|
||||||
}
|
|
||||||
} else if (obj instanceof List) {
|
} else if (obj instanceof List) {
|
||||||
List<?> val = (List<?>) obj;
|
List<?> val = (List<?>) obj;
|
||||||
if (!val.isEmpty()) {
|
if (!val.isEmpty()) {
|
||||||
@ -94,8 +93,7 @@ public class MemorySection implements ConfigurationSection {
|
|||||||
if (obj instanceof String) {
|
if (obj instanceof String) {
|
||||||
try {
|
try {
|
||||||
return Integer.parseInt((String) obj);
|
return Integer.parseInt((String) obj);
|
||||||
} catch (NumberFormatException ignored) {
|
} catch (NumberFormatException ignored) {}
|
||||||
}
|
|
||||||
} else if (obj instanceof List) {
|
} else if (obj instanceof List) {
|
||||||
List<?> val = (List<?>) obj;
|
List<?> val = (List<?>) obj;
|
||||||
if (!val.isEmpty()) {
|
if (!val.isEmpty()) {
|
||||||
@ -112,8 +110,7 @@ public class MemorySection implements ConfigurationSection {
|
|||||||
if (obj instanceof String) {
|
if (obj instanceof String) {
|
||||||
try {
|
try {
|
||||||
return Long.parseLong((String) obj);
|
return Long.parseLong((String) obj);
|
||||||
} catch (NumberFormatException ignored) {
|
} catch (NumberFormatException ignored) {}
|
||||||
}
|
|
||||||
} else if (obj instanceof List) {
|
} else if (obj instanceof List) {
|
||||||
List<?> val = (List<?>) obj;
|
List<?> val = (List<?>) obj;
|
||||||
if (!val.isEmpty()) {
|
if (!val.isEmpty()) {
|
||||||
@ -569,8 +566,7 @@ public class MemorySection implements ConfigurationSection {
|
|||||||
} else if (object instanceof String) {
|
} else if (object instanceof String) {
|
||||||
try {
|
try {
|
||||||
result.add(Integer.valueOf((String) object));
|
result.add(Integer.valueOf((String) object));
|
||||||
} catch (NumberFormatException ignored) {
|
} catch (NumberFormatException ignored) {}
|
||||||
}
|
|
||||||
} else if (object instanceof Character) {
|
} else if (object instanceof Character) {
|
||||||
result.add((int) (Character) object);
|
result.add((int) (Character) object);
|
||||||
} else if (object instanceof Number) {
|
} else if (object instanceof Number) {
|
||||||
@ -614,8 +610,7 @@ public class MemorySection implements ConfigurationSection {
|
|||||||
} else if (object instanceof String) {
|
} else if (object instanceof String) {
|
||||||
try {
|
try {
|
||||||
result.add(Double.valueOf((String) object));
|
result.add(Double.valueOf((String) object));
|
||||||
} catch (NumberFormatException ignored) {
|
} catch (NumberFormatException ignored) {}
|
||||||
}
|
|
||||||
} else if (object instanceof Character) {
|
} else if (object instanceof Character) {
|
||||||
result.add((double) (Character) object);
|
result.add((double) (Character) object);
|
||||||
} else if (object instanceof Number) {
|
} else if (object instanceof Number) {
|
||||||
@ -638,8 +633,7 @@ public class MemorySection implements ConfigurationSection {
|
|||||||
} else if (object instanceof String) {
|
} else if (object instanceof String) {
|
||||||
try {
|
try {
|
||||||
result.add(Float.valueOf((String) object));
|
result.add(Float.valueOf((String) object));
|
||||||
} catch (NumberFormatException ignored) {
|
} catch (NumberFormatException ignored) {}
|
||||||
}
|
|
||||||
} else if (object instanceof Character) {
|
} else if (object instanceof Character) {
|
||||||
result.add((float) (Character) object);
|
result.add((float) (Character) object);
|
||||||
} else if (object instanceof Number) {
|
} else if (object instanceof Number) {
|
||||||
@ -662,8 +656,7 @@ public class MemorySection implements ConfigurationSection {
|
|||||||
} else if (object instanceof String) {
|
} else if (object instanceof String) {
|
||||||
try {
|
try {
|
||||||
result.add(Long.valueOf((String) object));
|
result.add(Long.valueOf((String) object));
|
||||||
} catch (NumberFormatException ignored) {
|
} catch (NumberFormatException ignored) {}
|
||||||
}
|
|
||||||
} else if (object instanceof Character) {
|
} else if (object instanceof Character) {
|
||||||
result.add((long) (Character) object);
|
result.add((long) (Character) object);
|
||||||
} else if (object instanceof Number) {
|
} else if (object instanceof Number) {
|
||||||
@ -686,8 +679,7 @@ public class MemorySection implements ConfigurationSection {
|
|||||||
} else if (object instanceof String) {
|
} else if (object instanceof String) {
|
||||||
try {
|
try {
|
||||||
result.add(Byte.valueOf((String) object));
|
result.add(Byte.valueOf((String) object));
|
||||||
} catch (NumberFormatException ignored) {
|
} catch (NumberFormatException ignored) {}
|
||||||
}
|
|
||||||
} else if (object instanceof Character) {
|
} else if (object instanceof Character) {
|
||||||
result.add((byte) ((Character) object).charValue());
|
result.add((byte) ((Character) object).charValue());
|
||||||
} else if (object instanceof Number) {
|
} else if (object instanceof Number) {
|
||||||
@ -733,8 +725,7 @@ public class MemorySection implements ConfigurationSection {
|
|||||||
} else if (object instanceof String) {
|
} else if (object instanceof String) {
|
||||||
try {
|
try {
|
||||||
result.add(Short.valueOf((String) object));
|
result.add(Short.valueOf((String) object));
|
||||||
} catch (NumberFormatException ignored) {
|
} catch (NumberFormatException ignored) {}
|
||||||
}
|
|
||||||
} else if (object instanceof Character) {
|
} else if (object instanceof Character) {
|
||||||
result.add((short) ((Character) object).charValue());
|
result.add((short) ((Character) object).charValue());
|
||||||
} else if (object instanceof Number) {
|
} else if (object instanceof Number) {
|
||||||
|
@ -25,8 +25,7 @@ public abstract class FileConfiguration extends MemoryConfiguration {
|
|||||||
/**
|
/**
|
||||||
* Creates an empty {@link FileConfiguration} with no default values.
|
* Creates an empty {@link FileConfiguration} with no default values.
|
||||||
*/
|
*/
|
||||||
public FileConfiguration() {
|
FileConfiguration() {}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates an empty {@link FileConfiguration} using the specified {@link
|
* Creates an empty {@link FileConfiguration} using the specified {@link
|
||||||
@ -54,9 +53,6 @@ public abstract class FileConfiguration extends MemoryConfiguration {
|
|||||||
* @throws IllegalArgumentException Thrown when file is null.
|
* @throws IllegalArgumentException Thrown when file is null.
|
||||||
*/
|
*/
|
||||||
public void save(File file) throws IOException {
|
public void save(File file) throws IOException {
|
||||||
if (file == null) {
|
|
||||||
throw new NullPointerException("File cannot be null");
|
|
||||||
}
|
|
||||||
file.getParentFile().mkdirs();
|
file.getParentFile().mkdirs();
|
||||||
|
|
||||||
String data = saveToString();
|
String data = saveToString();
|
||||||
@ -66,29 +62,6 @@ public abstract class FileConfiguration extends MemoryConfiguration {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Saves this {@link FileConfiguration} to the specified location.
|
|
||||||
* <p>
|
|
||||||
* If the file does not exist, it will be created. If already exists, it
|
|
||||||
* will be overwritten. If it cannot be overwritten or created, an
|
|
||||||
* exception will be thrown.
|
|
||||||
* <p>
|
|
||||||
* This method will save using the system default encoding, or possibly
|
|
||||||
* using UTF8.
|
|
||||||
*
|
|
||||||
* @param file File to save to.
|
|
||||||
* @throws IOException Thrown when the given file cannot be written to for
|
|
||||||
* any reason.
|
|
||||||
* @throws IllegalArgumentException Thrown when file is null.
|
|
||||||
*/
|
|
||||||
public void save(String file) throws IOException {
|
|
||||||
if (file == null) {
|
|
||||||
throw new NullPointerException("File cannot be null");
|
|
||||||
}
|
|
||||||
|
|
||||||
save(new File(file));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Saves this {@link FileConfiguration} to a string, and returns it.
|
* Saves this {@link FileConfiguration} to a string, and returns it.
|
||||||
*
|
*
|
||||||
|
@ -21,8 +21,8 @@ import java.util.Map;
|
|||||||
* Note that this implementation is not synchronized.
|
* Note that this implementation is not synchronized.
|
||||||
*/
|
*/
|
||||||
public class YamlConfiguration extends FileConfiguration {
|
public class YamlConfiguration extends FileConfiguration {
|
||||||
protected static final String COMMENT_PREFIX = "# ";
|
private static final String COMMENT_PREFIX = "# ";
|
||||||
protected static final String BLANK_CONFIG = "{}\n";
|
private static final String BLANK_CONFIG = "{}\n";
|
||||||
private final DumperOptions yamlOptions = new DumperOptions();
|
private final DumperOptions yamlOptions = new DumperOptions();
|
||||||
private final Representer yamlRepresenter = new YamlRepresenter();
|
private final Representer yamlRepresenter = new YamlRepresenter();
|
||||||
private final Yaml yaml = new Yaml(new YamlConstructor(), yamlRepresenter, yamlOptions);
|
private final Yaml yaml = new Yaml(new YamlConstructor(), yamlRepresenter, yamlOptions);
|
||||||
@ -40,7 +40,7 @@ public class YamlConfiguration extends FileConfiguration {
|
|||||||
* @return Resulting configuration
|
* @return Resulting configuration
|
||||||
* @throws IllegalArgumentException Thrown if file is null
|
* @throws IllegalArgumentException Thrown if file is null
|
||||||
*/
|
*/
|
||||||
public static YamlConfiguration loadConfiguration(final File file) {
|
public static YamlConfiguration loadConfiguration(File file) {
|
||||||
if (file == null) {
|
if (file == null) {
|
||||||
throw new NullPointerException("File cannot be null");
|
throw new NullPointerException("File cannot be null");
|
||||||
}
|
}
|
||||||
@ -51,7 +51,6 @@ public class YamlConfiguration extends FileConfiguration {
|
|||||||
config.load(file);
|
config.load(file);
|
||||||
} catch (InvalidConfigurationException | IOException ex) {
|
} catch (InvalidConfigurationException | IOException ex) {
|
||||||
try {
|
try {
|
||||||
file.getAbsolutePath();
|
|
||||||
File dest = new File(file.getAbsolutePath() + "_broken");
|
File dest = new File(file.getAbsolutePath() + "_broken");
|
||||||
int i = 0;
|
int i = 0;
|
||||||
while (dest.exists()) {
|
while (dest.exists()) {
|
||||||
@ -126,7 +125,7 @@ public class YamlConfiguration extends FileConfiguration {
|
|||||||
input = (Map<?, ?>) yaml.load(contents);
|
input = (Map<?, ?>) yaml.load(contents);
|
||||||
} catch (final YAMLException e) {
|
} catch (final YAMLException e) {
|
||||||
throw new InvalidConfigurationException(e);
|
throw new InvalidConfigurationException(e);
|
||||||
} catch (final ClassCastException e) {
|
} catch (final ClassCastException ignored) {
|
||||||
throw new InvalidConfigurationException("Top level is not a Map.");
|
throw new InvalidConfigurationException("Top level is not a Map.");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -164,7 +163,7 @@ public class YamlConfiguration extends FileConfiguration {
|
|||||||
|
|
||||||
if (line.startsWith(COMMENT_PREFIX)) {
|
if (line.startsWith(COMMENT_PREFIX)) {
|
||||||
if (i > 0) {
|
if (i > 0) {
|
||||||
result.append("\n");
|
result.append('\n');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (line.length() > COMMENT_PREFIX.length()) {
|
if (line.length() > COMMENT_PREFIX.length()) {
|
||||||
@ -173,7 +172,7 @@ public class YamlConfiguration extends FileConfiguration {
|
|||||||
|
|
||||||
foundHeader = true;
|
foundHeader = true;
|
||||||
} else if (foundHeader && line.isEmpty()) {
|
} else if (foundHeader && line.isEmpty()) {
|
||||||
result.append("\n");
|
result.append('\n');
|
||||||
} else if (foundHeader) {
|
} else if (foundHeader) {
|
||||||
readingHeader = false;
|
readingHeader = false;
|
||||||
}
|
}
|
||||||
@ -189,9 +188,9 @@ public class YamlConfiguration extends FileConfiguration {
|
|||||||
if (options().copyHeader()) {
|
if (options().copyHeader()) {
|
||||||
final Configuration def = getDefaults();
|
final Configuration def = getDefaults();
|
||||||
|
|
||||||
if (def != null && def instanceof FileConfiguration) {
|
if (def instanceof FileConfiguration) {
|
||||||
final FileConfiguration filedefaults = (FileConfiguration) def;
|
final FileConfiguration fileDefaults = (FileConfiguration) def;
|
||||||
final String defaultsHeader = filedefaults.buildHeader();
|
final String defaultsHeader = fileDefaults.buildHeader();
|
||||||
|
|
||||||
if ((defaultsHeader != null) && !defaultsHeader.isEmpty()) {
|
if ((defaultsHeader != null) && !defaultsHeader.isEmpty()) {
|
||||||
return defaultsHeader;
|
return defaultsHeader;
|
||||||
@ -208,7 +207,7 @@ public class YamlConfiguration extends FileConfiguration {
|
|||||||
boolean startedHeader = false;
|
boolean startedHeader = false;
|
||||||
|
|
||||||
for (int i = lines.length - 1; i >= 0; i--) {
|
for (int i = lines.length - 1; i >= 0; i--) {
|
||||||
builder.insert(0, "\n");
|
builder.insert(0, '\n');
|
||||||
|
|
||||||
if (startedHeader || !lines[i].isEmpty()) {
|
if (startedHeader || !lines[i].isEmpty()) {
|
||||||
builder.insert(0, lines[i]);
|
builder.insert(0, lines[i]);
|
||||||
|
@ -7,7 +7,7 @@ package com.intellectualcrafters.configuration.file;
|
|||||||
public class YamlConfigurationOptions extends FileConfigurationOptions {
|
public class YamlConfigurationOptions extends FileConfigurationOptions {
|
||||||
private int indent = 2;
|
private int indent = 2;
|
||||||
|
|
||||||
protected YamlConfigurationOptions(final YamlConfiguration configuration) {
|
YamlConfigurationOptions(final YamlConfiguration configuration) {
|
||||||
super(configuration);
|
super(configuration);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@ import java.util.Map;
|
|||||||
|
|
||||||
public class YamlConstructor extends SafeConstructor {
|
public class YamlConstructor extends SafeConstructor {
|
||||||
|
|
||||||
public YamlConstructor() {
|
YamlConstructor() {
|
||||||
yamlConstructors.put(Tag.MAP, new ConstructCustomObject());
|
yamlConstructors.put(Tag.MAP, new ConstructCustomObject());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@ import org.yaml.snakeyaml.representer.Representer;
|
|||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public class YamlRepresenter extends Representer {
|
class YamlRepresenter extends Representer {
|
||||||
|
|
||||||
public YamlRepresenter() {
|
public YamlRepresenter() {
|
||||||
this.multiRepresenters.put(ConfigurationSection.class, new RepresentConfigurationSection());
|
this.multiRepresenters.put(ConfigurationSection.class, new RepresentConfigurationSection());
|
||||||
|
@ -17,8 +17,7 @@ import java.util.logging.Logger;
|
|||||||
public class ConfigurationSerialization {
|
public class ConfigurationSerialization {
|
||||||
|
|
||||||
public static final String SERIALIZED_TYPE_KEY = "==";
|
public static final String SERIALIZED_TYPE_KEY = "==";
|
||||||
private static final Map<String, Class<? extends ConfigurationSerializable>> aliases =
|
private static final Map<String, Class<? extends ConfigurationSerializable>> aliases = new HashMap<>();
|
||||||
new HashMap<String, Class<? extends ConfigurationSerializable>>();
|
|
||||||
private final Class<? extends ConfigurationSerializable> clazz;
|
private final Class<? extends ConfigurationSerializable> clazz;
|
||||||
|
|
||||||
protected ConfigurationSerialization(Class<? extends ConfigurationSerializable> clazz) {
|
protected ConfigurationSerialization(Class<? extends ConfigurationSerializable> clazz) {
|
||||||
@ -128,8 +127,7 @@ public class ConfigurationSerialization {
|
|||||||
* @param clazz Class to unregister
|
* @param clazz Class to unregister
|
||||||
*/
|
*/
|
||||||
public static void unregisterClass(Class<? extends ConfigurationSerializable> clazz) {
|
public static void unregisterClass(Class<? extends ConfigurationSerializable> clazz) {
|
||||||
while (aliases.values().remove(clazz)) {
|
while (aliases.values().remove(clazz)) {}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -154,7 +152,7 @@ public class ConfigurationSerialization {
|
|||||||
DelegateDeserialization delegate = clazz.getAnnotation(DelegateDeserialization.class);
|
DelegateDeserialization delegate = clazz.getAnnotation(DelegateDeserialization.class);
|
||||||
|
|
||||||
if (delegate != null) {
|
if (delegate != null) {
|
||||||
if ((delegate.value() == null) || (delegate.value() == clazz)) {
|
if (delegate.value() == clazz) {
|
||||||
delegate = null;
|
delegate = null;
|
||||||
} else {
|
} else {
|
||||||
return getAlias(delegate.value());
|
return getAlias(delegate.value());
|
||||||
@ -182,9 +180,7 @@ public class ConfigurationSerialization {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return method;
|
return method;
|
||||||
} catch (NoSuchMethodException ex) {
|
} catch (NoSuchMethodException | SecurityException ignored) {
|
||||||
return null;
|
|
||||||
} catch (SecurityException ex) {
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -192,9 +188,7 @@ public class ConfigurationSerialization {
|
|||||||
protected Constructor<? extends ConfigurationSerializable> getConstructor() {
|
protected Constructor<? extends ConfigurationSerializable> getConstructor() {
|
||||||
try {
|
try {
|
||||||
return this.clazz.getConstructor(Map.class);
|
return this.clazz.getConstructor(Map.class);
|
||||||
} catch (NoSuchMethodException ex) {
|
} catch (NoSuchMethodException | SecurityException ignored) {
|
||||||
return null;
|
|
||||||
} catch (SecurityException ex) {
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -209,7 +203,7 @@ public class ConfigurationSerialization {
|
|||||||
} else {
|
} else {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
} catch (Throwable ex) {
|
} catch (IllegalAccessException | InvocationTargetException | IllegalArgumentException ex) {
|
||||||
Logger.getLogger(ConfigurationSerialization.class.getName())
|
Logger.getLogger(ConfigurationSerialization.class.getName())
|
||||||
.log(Level.SEVERE, "Could not call method '" + method.toString() + "' of " + this.clazz
|
.log(Level.SEVERE, "Could not call method '" + method.toString() + "' of " + this.clazz
|
||||||
+ " for deserialization",
|
+ " for deserialization",
|
||||||
@ -222,7 +216,7 @@ public class ConfigurationSerialization {
|
|||||||
protected ConfigurationSerializable deserializeViaCtor(Constructor<? extends ConfigurationSerializable> ctor, Map<String, ?> args) {
|
protected ConfigurationSerializable deserializeViaCtor(Constructor<? extends ConfigurationSerializable> ctor, Map<String, ?> args) {
|
||||||
try {
|
try {
|
||||||
return ctor.newInstance(args);
|
return ctor.newInstance(args);
|
||||||
} catch (Throwable ex) {
|
} catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException | InstantiationException ex) {
|
||||||
Logger.getLogger(ConfigurationSerialization.class.getName())
|
Logger.getLogger(ConfigurationSerialization.class.getName())
|
||||||
.log(Level.SEVERE, "Could not call constructor '" + ctor.toString() + "' of " + this.clazz
|
.log(Level.SEVERE, "Could not call constructor '" + ctor.toString() + "' of " + this.clazz
|
||||||
+ " for deserialization",
|
+ " for deserialization",
|
||||||
@ -238,22 +232,17 @@ public class ConfigurationSerialization {
|
|||||||
}
|
}
|
||||||
ConfigurationSerializable result = null;
|
ConfigurationSerializable result = null;
|
||||||
Method method = getMethod("deserialize", true);
|
Method method = getMethod("deserialize", true);
|
||||||
|
|
||||||
if (method != null) {
|
if (method != null) {
|
||||||
result = deserializeViaMethod(method, args);
|
result = deserializeViaMethod(method, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (result == null) {
|
if (result == null) {
|
||||||
method = getMethod("valueOf", true);
|
method = getMethod("valueOf", true);
|
||||||
|
|
||||||
if (method != null) {
|
if (method != null) {
|
||||||
result = deserializeViaMethod(method, args);
|
result = deserializeViaMethod(method, args);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (result == null) {
|
if (result == null) {
|
||||||
Constructor<? extends ConfigurationSerializable> constructor = getConstructor();
|
Constructor<? extends ConfigurationSerializable> constructor = getConstructor();
|
||||||
|
|
||||||
if (constructor != null) {
|
if (constructor != null) {
|
||||||
result = deserializeViaCtor(constructor, args);
|
result = deserializeViaCtor(constructor, args);
|
||||||
}
|
}
|
||||||
|
@ -44,7 +44,7 @@ public final class ByteArrayTag extends Tag {
|
|||||||
}
|
}
|
||||||
String name = getName();
|
String name = getName();
|
||||||
String append = "";
|
String append = "";
|
||||||
if (name != null && !name.equals("")) {
|
if (name != null && !name.isEmpty()) {
|
||||||
append = "(\"" + getName() + "\")";
|
append = "(\"" + getName() + "\")";
|
||||||
}
|
}
|
||||||
return "TAG_Byte_Array" + append + ": " + hex;
|
return "TAG_Byte_Array" + append + ": " + hex;
|
||||||
|
@ -36,7 +36,7 @@ public final class ByteTag extends Tag {
|
|||||||
public String toString() {
|
public String toString() {
|
||||||
String name = getName();
|
String name = getName();
|
||||||
String append = "";
|
String append = "";
|
||||||
if (name != null && !name.equals("")) {
|
if (name != null && !name.isEmpty()) {
|
||||||
append = "(\"" + getName() + "\")";
|
append = "(\"" + getName() + "\")";
|
||||||
}
|
}
|
||||||
return "TAG_Byte" + append + ": " + this.value;
|
return "TAG_Byte" + append + ": " + this.value;
|
||||||
|
@ -373,7 +373,7 @@ public final class CompoundTag extends Tag {
|
|||||||
public String toString() {
|
public String toString() {
|
||||||
String name = getName();
|
String name = getName();
|
||||||
String append = "";
|
String append = "";
|
||||||
if (name != null && !name.equals("")) {
|
if (name != null && !name.isEmpty()) {
|
||||||
append = "(\"" + getName() + "\")";
|
append = "(\"" + getName() + "\")";
|
||||||
}
|
}
|
||||||
StringBuilder bldr = new StringBuilder();
|
StringBuilder bldr = new StringBuilder();
|
||||||
|
@ -16,7 +16,7 @@ public class CompoundTagBuilder {
|
|||||||
* Create a new instance.
|
* Create a new instance.
|
||||||
*/
|
*/
|
||||||
CompoundTagBuilder() {
|
CompoundTagBuilder() {
|
||||||
this.entries = new HashMap<String, Tag>();
|
this.entries = new HashMap<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -36,7 +36,7 @@ public final class DoubleTag extends Tag {
|
|||||||
public String toString() {
|
public String toString() {
|
||||||
String name = getName();
|
String name = getName();
|
||||||
String append = "";
|
String append = "";
|
||||||
if (name != null && !name.equals("")) {
|
if (name != null && !name.isEmpty()) {
|
||||||
append = "(\"" + getName() + "\")";
|
append = "(\"" + getName() + "\")";
|
||||||
}
|
}
|
||||||
return "TAG_Double" + append + ": " + this.value;
|
return "TAG_Double" + append + ": " + this.value;
|
||||||
|
@ -8,8 +8,7 @@ public final class EndTag extends Tag {
|
|||||||
/**
|
/**
|
||||||
* Creates the tag.
|
* Creates the tag.
|
||||||
*/
|
*/
|
||||||
public EndTag() {
|
public EndTag() {}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object getValue() {
|
public Object getValue() {
|
||||||
|
@ -36,7 +36,7 @@ public final class FloatTag extends Tag {
|
|||||||
public String toString() {
|
public String toString() {
|
||||||
String name = getName();
|
String name = getName();
|
||||||
String append = "";
|
String append = "";
|
||||||
if (name != null && !name.equals("")) {
|
if (name != null && !name.isEmpty()) {
|
||||||
append = "(\"" + getName() + "\")";
|
append = "(\"" + getName() + "\")";
|
||||||
}
|
}
|
||||||
return "TAG_Float" + append + ": " + this.value;
|
return "TAG_Float" + append + ": " + this.value;
|
||||||
|
@ -48,7 +48,7 @@ public final class IntArrayTag extends Tag {
|
|||||||
}
|
}
|
||||||
String name = getName();
|
String name = getName();
|
||||||
String append = "";
|
String append = "";
|
||||||
if (name != null && !name.equals("")) {
|
if (name != null && !name.isEmpty()) {
|
||||||
append = "(\"" + getName() + "\")";
|
append = "(\"" + getName() + "\")";
|
||||||
}
|
}
|
||||||
return "TAG_Int_Array" + append + ": " + hex;
|
return "TAG_Int_Array" + append + ": " + hex;
|
||||||
|
@ -36,7 +36,7 @@ public final class IntTag extends Tag {
|
|||||||
public String toString() {
|
public String toString() {
|
||||||
String name = getName();
|
String name = getName();
|
||||||
String append = "";
|
String append = "";
|
||||||
if (name != null && !name.equals("")) {
|
if (name != null && !name.isEmpty()) {
|
||||||
append = "(\"" + getName() + "\")";
|
append = "(\"" + getName() + "\")";
|
||||||
}
|
}
|
||||||
return "TAG_Int" + append + ": " + this.value;
|
return "TAG_Int" + append + ": " + this.value;
|
||||||
|
@ -378,7 +378,7 @@ public final class ListTag extends Tag {
|
|||||||
public String toString() {
|
public String toString() {
|
||||||
String name = getName();
|
String name = getName();
|
||||||
String append = "";
|
String append = "";
|
||||||
if (name != null && !name.equals("")) {
|
if (name != null && !name.isEmpty()) {
|
||||||
append = "(\"" + getName() + "\")";
|
append = "(\"" + getName() + "\")";
|
||||||
}
|
}
|
||||||
StringBuilder bldr = new StringBuilder();
|
StringBuilder bldr = new StringBuilder();
|
||||||
|
@ -23,7 +23,7 @@ public class ListTagBuilder {
|
|||||||
ListTagBuilder(Class<? extends Tag> type) {
|
ListTagBuilder(Class<? extends Tag> type) {
|
||||||
checkNotNull(type);
|
checkNotNull(type);
|
||||||
this.type = type;
|
this.type = type;
|
||||||
this.entries = new ArrayList<Tag>();
|
this.entries = new ArrayList<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -36,7 +36,7 @@ public final class LongTag extends Tag {
|
|||||||
public String toString() {
|
public String toString() {
|
||||||
String name = getName();
|
String name = getName();
|
||||||
String append = "";
|
String append = "";
|
||||||
if (name != null && !name.equals("")) {
|
if (name != null && !name.isEmpty()) {
|
||||||
append = "(\"" + getName() + "\")";
|
append = "(\"" + getName() + "\")";
|
||||||
}
|
}
|
||||||
return "TAG_Long" + append + ": " + this.value;
|
return "TAG_Long" + append + ": " + this.value;
|
||||||
|
@ -16,8 +16,7 @@ public final class NBTConstants {
|
|||||||
/**
|
/**
|
||||||
* Default private constructor.
|
* Default private constructor.
|
||||||
*/
|
*/
|
||||||
private NBTConstants() {
|
private NBTConstants() {}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convert a type ID to its corresponding {@link Tag} class.
|
* Convert a type ID to its corresponding {@link Tag} class.
|
||||||
|
@ -10,8 +10,7 @@ public final class NBTUtils {
|
|||||||
/**
|
/**
|
||||||
* Default private constructor.
|
* Default private constructor.
|
||||||
*/
|
*/
|
||||||
private NBTUtils() {
|
private NBTUtils() {}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the type name of a tag.
|
* Gets the type name of a tag.
|
||||||
|
@ -36,7 +36,7 @@ public final class ShortTag extends Tag {
|
|||||||
public String toString() {
|
public String toString() {
|
||||||
String name = getName();
|
String name = getName();
|
||||||
String append = "";
|
String append = "";
|
||||||
if (name != null && !name.equals("")) {
|
if (name != null && !name.isEmpty()) {
|
||||||
append = "(\"" + getName() + "\")";
|
append = "(\"" + getName() + "\")";
|
||||||
}
|
}
|
||||||
return "TAG_Short" + append + ": " + this.value;
|
return "TAG_Short" + append + ": " + this.value;
|
||||||
|
@ -40,7 +40,7 @@ public final class StringTag extends Tag {
|
|||||||
public String toString() {
|
public String toString() {
|
||||||
String name = getName();
|
String name = getName();
|
||||||
String append = "";
|
String append = "";
|
||||||
if (name != null && !name.equals("")) {
|
if (name != null && !name.isEmpty()) {
|
||||||
append = "(\"" + getName() + "\")";
|
append = "(\"" + getName() + "\")";
|
||||||
}
|
}
|
||||||
return "TAG_String" + append + ": " + this.value;
|
return "TAG_String" + append + ": " + this.value;
|
||||||
|
@ -88,8 +88,7 @@ public class JSONObject {
|
|||||||
for (String name : names) {
|
for (String name : names) {
|
||||||
try {
|
try {
|
||||||
putOnce(name, jo.opt(name));
|
putOnce(name, jo.opt(name));
|
||||||
} catch (JSONException ignore) {
|
} catch (JSONException ignore) {}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -194,8 +193,7 @@ public class JSONObject {
|
|||||||
for (String name : names) {
|
for (String name : names) {
|
||||||
try {
|
try {
|
||||||
putOpt(name, c.getField(name).get(object));
|
putOpt(name, c.getField(name).get(object));
|
||||||
} catch (JSONException | SecurityException | NoSuchFieldException | IllegalArgumentException | IllegalAccessException ignore) {
|
} catch (JSONException | SecurityException | NoSuchFieldException | IllegalArgumentException | IllegalAccessException ignore) {}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -461,8 +459,7 @@ public class JSONObject {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (NumberFormatException ignore) {
|
} catch (NumberFormatException ignore) {}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return string;
|
return string;
|
||||||
}
|
}
|
||||||
@ -586,7 +583,7 @@ public class JSONObject {
|
|||||||
return object.toString();
|
return object.toString();
|
||||||
}
|
}
|
||||||
return new JSONObject(object);
|
return new JSONObject(object);
|
||||||
} catch (JSONException exception) {
|
} catch (JSONException ignored) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -734,7 +731,7 @@ public class JSONObject {
|
|||||||
Object object = get(key);
|
Object object = get(key);
|
||||||
try {
|
try {
|
||||||
return object instanceof Number ? ((Number) object).doubleValue() : Double.parseDouble((String) object);
|
return object instanceof Number ? ((Number) object).doubleValue() : Double.parseDouble((String) object);
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException ignored) {
|
||||||
throw new JSONException("JSONObject[" + quote(key) + "] is not a number.");
|
throw new JSONException("JSONObject[" + quote(key) + "] is not a number.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -752,7 +749,7 @@ public class JSONObject {
|
|||||||
Object object = get(key);
|
Object object = get(key);
|
||||||
try {
|
try {
|
||||||
return object instanceof Number ? ((Number) object).intValue() : Integer.parseInt((String) object);
|
return object instanceof Number ? ((Number) object).intValue() : Integer.parseInt((String) object);
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException ignored) {
|
||||||
throw new JSONException("JSONObject[" + quote(key) + "] is not an int.");
|
throw new JSONException("JSONObject[" + quote(key) + "] is not an int.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -804,7 +801,7 @@ public class JSONObject {
|
|||||||
Object object = get(key);
|
Object object = get(key);
|
||||||
try {
|
try {
|
||||||
return object instanceof Number ? ((Number) object).longValue() : Long.parseLong((String) object);
|
return object instanceof Number ? ((Number) object).longValue() : Long.parseLong((String) object);
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException ignored) {
|
||||||
throw new JSONException("JSONObject[" + quote(key) + "] is not a long.");
|
throw new JSONException("JSONObject[" + quote(key) + "] is not a long.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -953,7 +950,7 @@ public class JSONObject {
|
|||||||
public boolean optBoolean(String key, boolean defaultValue) {
|
public boolean optBoolean(String key, boolean defaultValue) {
|
||||||
try {
|
try {
|
||||||
return getBoolean(key);
|
return getBoolean(key);
|
||||||
} catch (JSONException e) {
|
} catch (JSONException ignored) {
|
||||||
return defaultValue;
|
return defaultValue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -982,7 +979,7 @@ public class JSONObject {
|
|||||||
public double optDouble(String key, double defaultValue) {
|
public double optDouble(String key, double defaultValue) {
|
||||||
try {
|
try {
|
||||||
return getDouble(key);
|
return getDouble(key);
|
||||||
} catch (JSONException e) {
|
} catch (JSONException ignored) {
|
||||||
return defaultValue;
|
return defaultValue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1011,7 +1008,7 @@ public class JSONObject {
|
|||||||
public int optInt(String key, int defaultValue) {
|
public int optInt(String key, int defaultValue) {
|
||||||
try {
|
try {
|
||||||
return getInt(key);
|
return getInt(key);
|
||||||
} catch (JSONException e) {
|
} catch (JSONException ignored) {
|
||||||
return defaultValue;
|
return defaultValue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1066,7 +1063,7 @@ public class JSONObject {
|
|||||||
public long optLong(String key, long defaultValue) {
|
public long optLong(String key, long defaultValue) {
|
||||||
try {
|
try {
|
||||||
return getLong(key);
|
return getLong(key);
|
||||||
} catch (JSONException e) {
|
} catch (JSONException ignored) {
|
||||||
return defaultValue;
|
return defaultValue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1127,8 +1124,7 @@ public class JSONObject {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException ignore) {
|
} catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException ignore) {}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1330,7 +1326,7 @@ public class JSONObject {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
} catch (Throwable exception) {
|
} catch (JSONException ignored) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1370,7 +1366,7 @@ public class JSONObject {
|
|||||||
public String toString() {
|
public String toString() {
|
||||||
try {
|
try {
|
||||||
return this.toString(0);
|
return this.toString(0);
|
||||||
} catch (JSONException e) {
|
} catch (JSONException ignored) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1476,7 +1472,7 @@ public class JSONObject {
|
|||||||
protected final Object clone() {
|
protected final Object clone() {
|
||||||
try {
|
try {
|
||||||
return super.clone();
|
return super.clone();
|
||||||
} catch (CloneNotSupportedException e) {
|
} catch (CloneNotSupportedException ignored) {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,5 +12,5 @@ public interface JSONString {
|
|||||||
*
|
*
|
||||||
* @return A strictly syntactically correct JSON text.
|
* @return A strictly syntactically correct JSON text.
|
||||||
*/
|
*/
|
||||||
public String toJSONString();
|
String toJSONString();
|
||||||
}
|
}
|
||||||
|
@ -342,7 +342,7 @@ public class JSONTokener {
|
|||||||
}
|
}
|
||||||
back();
|
back();
|
||||||
string = sb.toString().trim();
|
string = sb.toString().trim();
|
||||||
if (string != null && string.isEmpty()) {
|
if (string.isEmpty()) {
|
||||||
throw syntaxError("Missing value");
|
throw syntaxError("Missing value");
|
||||||
}
|
}
|
||||||
return JSONObject.stringToValue(string);
|
return JSONObject.stringToValue(string);
|
||||||
@ -370,7 +370,7 @@ public class JSONTokener {
|
|||||||
index = startIndex;
|
index = startIndex;
|
||||||
character = startCharacter;
|
character = startCharacter;
|
||||||
line = startLine;
|
line = startLine;
|
||||||
return c;
|
return 0;
|
||||||
}
|
}
|
||||||
} while (c != to);
|
} while (c != to);
|
||||||
} catch (final IOException exception) {
|
} catch (final IOException exception) {
|
||||||
|
@ -245,8 +245,7 @@ class XML {
|
|||||||
if (value.toString().equals(string)) {
|
if (value.toString().equals(string)) {
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
} catch (NumberFormatException ignored) {
|
} catch (NumberFormatException ignored) {}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return string;
|
return string;
|
||||||
}
|
}
|
||||||
|
@ -137,7 +137,7 @@ public class PS {
|
|||||||
try {
|
try {
|
||||||
URL url = PS.class.getProtectionDomain().getCodeSource().getLocation();
|
URL url = PS.class.getProtectionDomain().getCodeSource().getLocation();
|
||||||
this.file = new File(new URL(url.toURI().toString().split("\\!")[0].replaceAll("jar:file", "file")).toURI().getPath());
|
this.file = new File(new URL(url.toURI().toString().split("\\!")[0].replaceAll("jar:file", "file")).toURI().getPath());
|
||||||
} catch (MalformedURLException | URISyntaxException | SecurityException | NullPointerException e) {
|
} catch (MalformedURLException | URISyntaxException | SecurityException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
this.file = new File(this.IMP.getDirectory().getParentFile(), "PlotSquared.jar");
|
this.file = new File(this.IMP.getDirectory().getParentFile(), "PlotSquared.jar");
|
||||||
if (!this.file.exists()) {
|
if (!this.file.exists()) {
|
||||||
@ -489,13 +489,12 @@ public class PS {
|
|||||||
return areas[0];
|
return areas[0];
|
||||||
} else if (id == null) {
|
} else if (id == null) {
|
||||||
return null;
|
return null;
|
||||||
} else {
|
}
|
||||||
for (PlotArea area : areas) {
|
for (PlotArea area : areas) {
|
||||||
if (StringMan.isEqual(id, area.id)) {
|
if (StringMan.isEqual(id, area.id)) {
|
||||||
return area;
|
return area;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -830,7 +829,7 @@ public class PS {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ArrayList<Plot> sortPlotsByTemp(Collection<Plot> plots) {
|
public List<Plot> sortPlotsByTemp(Collection<Plot> plots) {
|
||||||
int max = 0;
|
int max = 0;
|
||||||
int overflowCount = 0;
|
int overflowCount = 0;
|
||||||
for (Plot plot : plots) {
|
for (Plot plot : plots) {
|
||||||
@ -1474,7 +1473,7 @@ public class PS {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (type == 1) {
|
if (type == 1) {
|
||||||
throw new IllegalArgumentException("Invalid type for multi-area world. Expected `2`, got `" + type + "`");
|
throw new IllegalArgumentException("Invalid type for multi-area world. Expected `2`, got `" + 1 + "`");
|
||||||
}
|
}
|
||||||
for (String areaId : areasSection.getKeys(false)) {
|
for (String areaId : areasSection.getKeys(false)) {
|
||||||
PS.log(C.PREFIX + "&3 - " + areaId);
|
PS.log(C.PREFIX + "&3 - " + areaId);
|
||||||
@ -1762,7 +1761,7 @@ public class PS {
|
|||||||
// Close the connection
|
// Close the connection
|
||||||
DBFunc.close();
|
DBFunc.close();
|
||||||
UUIDHandler.handleShutdown();
|
UUIDHandler.handleShutdown();
|
||||||
} catch (NullPointerException e) {
|
} catch (NullPointerException ignored) {
|
||||||
PS.log("&cCould not close database connection!");
|
PS.log("&cCould not close database connection!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2100,7 +2099,7 @@ public class PS {
|
|||||||
}
|
}
|
||||||
this.config = YamlConfiguration.loadConfiguration(this.configFile);
|
this.config = YamlConfiguration.loadConfiguration(this.configFile);
|
||||||
setupConfig();
|
setupConfig();
|
||||||
} catch (IOException err_trans) {
|
} catch (IOException ignored) {
|
||||||
PS.log("Failed to save settings.yml");
|
PS.log("Failed to save settings.yml");
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
@ -2112,7 +2111,7 @@ public class PS {
|
|||||||
}
|
}
|
||||||
this.storage = YamlConfiguration.loadConfiguration(this.storageFile);
|
this.storage = YamlConfiguration.loadConfiguration(this.storageFile);
|
||||||
setupStorage();
|
setupStorage();
|
||||||
} catch (IOException err_trans) {
|
} catch (IOException ignored) {
|
||||||
PS.log("Failed to save storage.yml");
|
PS.log("Failed to save storage.yml");
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
@ -2124,7 +2123,7 @@ public class PS {
|
|||||||
}
|
}
|
||||||
this.commands = YamlConfiguration.loadConfiguration(this.commandsFile);
|
this.commands = YamlConfiguration.loadConfiguration(this.commandsFile);
|
||||||
setupStorage();
|
setupStorage();
|
||||||
} catch (IOException err_trans) {
|
} catch (IOException ignored) {
|
||||||
PS.log("Failed to save commands.yml");
|
PS.log("Failed to save commands.yml");
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
@ -112,7 +112,7 @@ public class Area extends SubCommand {
|
|||||||
object.plotManager = "PlotSquared";
|
object.plotManager = "PlotSquared";
|
||||||
object.setupGenerator = "PlotSquared";
|
object.setupGenerator = "PlotSquared";
|
||||||
object.step = area.getSettingNodes();
|
object.step = area.getSettingNodes();
|
||||||
final String path = "worlds." + area.worldname + ".areas." + area.id + "-" + object.min + "-" + object.max;
|
final String path = "worlds." + area.worldname + ".areas." + area.id + '-' + object.min + '-' + object.max;
|
||||||
Runnable run = new Runnable() {
|
Runnable run = new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
@ -254,7 +254,7 @@ public class Area extends SubCommand {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
if (hasConfirmation(player)) {
|
if (hasConfirmation(player)) {
|
||||||
CmdConfirm.addPending(player, getCommandString() + " " + StringMan.join(args, " "), run);
|
CmdConfirm.addPending(player, getCommandString() + ' ' + StringMan.join(args, " "), run);
|
||||||
} else {
|
} else {
|
||||||
run.run();
|
run.run();
|
||||||
}
|
}
|
||||||
@ -310,11 +310,11 @@ public class Area extends SubCommand {
|
|||||||
int claimed = area.getPlotCount();
|
int claimed = area.getPlotCount();
|
||||||
int clusters = area.getClusters().size();
|
int clusters = area.getClusters().size();
|
||||||
String region;
|
String region;
|
||||||
String generator = area.getGenerator() + "";
|
String generator = String.valueOf(area.getGenerator());
|
||||||
if (area.TYPE == 2) {
|
if (area.TYPE == 2) {
|
||||||
PlotId min = area.getMin();
|
PlotId min = area.getMin();
|
||||||
PlotId max = area.getMax();
|
PlotId max = area.getMax();
|
||||||
name = area.worldname + ";" + area.id + ";" + min + ";" + max;
|
name = area.worldname + ';' + area.id + ';' + min + ';' + max;
|
||||||
int size = (max.x - min.x + 1) * (max.y - min.y + 1);
|
int size = (max.x - min.x + 1) * (max.y - min.y + 1);
|
||||||
percent = claimed == 0 ? 0 : size / (double) claimed;
|
percent = claimed == 0 ? 0 : size / (double) claimed;
|
||||||
region = area.getRegion().toString();
|
region = area.getRegion().toString();
|
||||||
@ -326,7 +326,7 @@ public class Area extends SubCommand {
|
|||||||
String value = "&r$1NAME: " + name
|
String value = "&r$1NAME: " + name
|
||||||
+ "\n$1Type: $2" + area.TYPE
|
+ "\n$1Type: $2" + area.TYPE
|
||||||
+ "\n$1Terrain: $2" + area.TERRAIN
|
+ "\n$1Terrain: $2" + area.TERRAIN
|
||||||
+ "\n$1Usage: $2" + String.format("%.2f", percent) + "%"
|
+ "\n$1Usage: $2" + String.format("%.2f", percent) + '%'
|
||||||
+ "\n$1Claimed: $2" + claimed
|
+ "\n$1Claimed: $2" + claimed
|
||||||
+ "\n$1Clusters: $2" + clusters
|
+ "\n$1Clusters: $2" + clusters
|
||||||
+ "\n$1Region: $2" + region
|
+ "\n$1Region: $2" + region
|
||||||
@ -363,11 +363,11 @@ public class Area extends SubCommand {
|
|||||||
int claimed = area.getPlotCount();
|
int claimed = area.getPlotCount();
|
||||||
int clusters = area.getClusters().size();
|
int clusters = area.getClusters().size();
|
||||||
String region;
|
String region;
|
||||||
String generator = area.getGenerator() + "";
|
String generator = String.valueOf(area.getGenerator());
|
||||||
if (area.TYPE == 2) {
|
if (area.TYPE == 2) {
|
||||||
PlotId min = area.getMin();
|
PlotId min = area.getMin();
|
||||||
PlotId max = area.getMax();
|
PlotId max = area.getMax();
|
||||||
name = area.worldname + ";" + area.id + ";" + min + ";" + max;
|
name = area.worldname + ';' + area.id + ';' + min + ';' + max;
|
||||||
int size = (max.x - min.x + 1) * (max.y - min.y + 1);
|
int size = (max.x - min.x + 1) * (max.y - min.y + 1);
|
||||||
percent = claimed == 0 ? 0 : size / (double) claimed;
|
percent = claimed == 0 ? 0 : size / (double) claimed;
|
||||||
region = area.getRegion().toString();
|
region = area.getRegion().toString();
|
||||||
@ -377,18 +377,18 @@ public class Area extends SubCommand {
|
|||||||
region = "N/A";
|
region = "N/A";
|
||||||
}
|
}
|
||||||
PlotMessage tooltip = new PlotMessage()
|
PlotMessage tooltip = new PlotMessage()
|
||||||
.text("Claimed=").color("$1").text("" + claimed).color("$2")
|
.text("Claimed=").color("$1").text(String.valueOf(claimed)).color("$2")
|
||||||
.text("\nUsage=").color("$1").text(String.format("%.2f", percent) + "%").color("$2")
|
.text("\nUsage=").color("$1").text(String.format("%.2f", percent) + '%').color("$2")
|
||||||
.text("\nClusters=").color("$1").text("" + clusters).color("$2")
|
.text("\nClusters=").color("$1").text(String.valueOf(clusters)).color("$2")
|
||||||
.text("\nRegion=").color("$1").text(region).color("$2")
|
.text("\nRegion=").color("$1").text(region).color("$2")
|
||||||
.text("\nGenerator=").color("$1").text(generator).color("$2");
|
.text("\nGenerator=").color("$1").text(generator).color("$2");
|
||||||
|
|
||||||
// type / terrain
|
// type / terrain
|
||||||
String visit = "/plot area tp " + area.toString();
|
String visit = "/plot area tp " + area.toString();
|
||||||
message.text("[").color("$3")
|
message.text("[").color("$3")
|
||||||
.text(i + "").command(visit).tooltip(visit).color("$1")
|
.text(String.valueOf(i)).command(visit).tooltip(visit).color("$1")
|
||||||
.text("]").color("$3")
|
.text("]").color("$3")
|
||||||
.text(" " + name).tooltip(tooltip).command(getCommandString() + " info " + area).color("$1").text(" - ")
|
.text(' ' + name).tooltip(tooltip).command(getCommandString() + " info " + area).color("$1").text(" - ")
|
||||||
.color("$2")
|
.color("$2")
|
||||||
.text(area.TYPE + ":" + area.TERRAIN).color("$3");
|
.text(area.TYPE + ":" + area.TERRAIN).color("$3");
|
||||||
}
|
}
|
||||||
|
@ -72,7 +72,7 @@ public class Auto extends SubCommand {
|
|||||||
if (args.length > 1) {
|
if (args.length > 1) {
|
||||||
schematic = args[1];
|
schematic = args[1];
|
||||||
}
|
}
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException ignored) {
|
||||||
size_x = 1;
|
size_x = 1;
|
||||||
size_z = 1;
|
size_z = 1;
|
||||||
schematic = args[0];
|
schematic = args[0];
|
||||||
|
@ -43,7 +43,7 @@ public class Buy extends SubCommand {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
plots = plot.getConnectedPlots();
|
plots = plot.getConnectedPlots();
|
||||||
} catch (Exception e) {
|
} catch (Exception ignored) {
|
||||||
return sendMessage(plr, C.NOT_VALID_PLOT_ID);
|
return sendMessage(plr, C.NOT_VALID_PLOT_ID);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -27,7 +27,7 @@ public class Continue extends SubCommand {
|
|||||||
MainUtil.sendMessage(plr, C.NO_PLOT_PERMS);
|
MainUtil.sendMessage(plr, C.NO_PLOT_PERMS);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!plot.getFlags().containsKey("done")) {
|
if (!plot.hasFlag(Flags.DONE)) {
|
||||||
MainUtil.sendMessage(plr, C.DONE_NOT_DONE);
|
MainUtil.sendMessage(plr, C.DONE_NOT_DONE);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -18,6 +18,7 @@ import java.sql.SQLException;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
@CommandDeclaration(
|
@CommandDeclaration(
|
||||||
@ -30,7 +31,7 @@ import java.util.Map.Entry;
|
|||||||
usage = "/plots database [area] <sqlite|mysql|import>")
|
usage = "/plots database [area] <sqlite|mysql|import>")
|
||||||
public class Database extends SubCommand {
|
public class Database extends SubCommand {
|
||||||
|
|
||||||
public static void insertPlots(final SQLManager manager, final ArrayList<Plot> plots, final PlotPlayer player) {
|
public static void insertPlots(final SQLManager manager, final List<Plot> plots, final PlotPlayer player) {
|
||||||
TaskManager.runTaskAsync(new Runnable() {
|
TaskManager.runTaskAsync(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
@ -61,7 +62,7 @@ public class Database extends SubCommand {
|
|||||||
MainUtil.sendMessage(player, "/plot database [area] <sqlite|mysql|import>");
|
MainUtil.sendMessage(player, "/plot database [area] <sqlite|mysql|import>");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
ArrayList<Plot> plots;
|
List<Plot> plots;
|
||||||
PlotArea area = PS.get().getPlotAreaByString(args[0]);
|
PlotArea area = PS.get().getPlotAreaByString(args[0]);
|
||||||
if (area != null) {
|
if (area != null) {
|
||||||
plots = PS.get().sortPlotsByTemp(area.getPlots());
|
plots = PS.get().sortPlotsByTemp(area.getPlots());
|
||||||
|
@ -92,7 +92,7 @@ public class DebugClaimTest extends SubCommand {
|
|||||||
}
|
}
|
||||||
if (uuid != null) {
|
if (uuid != null) {
|
||||||
MainUtil.sendMessage(plr, " - &aFound plot: " + plot.getId() + " : " + line);
|
MainUtil.sendMessage(plr, " - &aFound plot: " + plot.getId() + " : " + line);
|
||||||
plot.owner = uuid;
|
plot.setOwner(uuid);
|
||||||
plots.add(plot);
|
plots.add(plot);
|
||||||
} else {
|
} else {
|
||||||
MainUtil.sendMessage(plr, " - &cInvalid PlayerName: " + plot.getId() + " : " + line);
|
MainUtil.sendMessage(plr, " - &cInvalid PlayerName: " + plot.getId() + " : " + line);
|
||||||
|
@ -80,8 +80,7 @@ public class DebugExec extends SubCommand {
|
|||||||
this.engine.eval(script, this.scope);
|
this.engine.eval(script, this.scope);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (IOException | ScriptException ignored) {
|
} catch (IOException | ScriptException ignored) {}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ScriptEngine getEngine() {
|
public ScriptEngine getEngine() {
|
||||||
@ -360,12 +359,7 @@ public class DebugExec extends SubCommand {
|
|||||||
@Override
|
@Override
|
||||||
public void run(Integer i, File file, PlotMessage message) {
|
public void run(Integer i, File file, PlotMessage message) {
|
||||||
String name = file.getName();
|
String name = file.getName();
|
||||||
|
message.text("[").color("$3").text(String.valueOf(i)).color("$1").text("]").color("$3").text(' ' + name).color("$1");
|
||||||
message.text("[").color("$3")
|
|
||||||
.text(i + "").color("$1")
|
|
||||||
.text("]").color("$3")
|
|
||||||
.text(" " + name).color("$1");
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}, "/plot debugexec list-scripts", "List of scripts");
|
}, "/plot debugexec list-scripts", "List of scripts");
|
||||||
return true;
|
return true;
|
||||||
|
@ -12,8 +12,6 @@ import com.intellectualcrafters.plot.util.Permissions;
|
|||||||
import com.intellectualcrafters.plot.util.TaskManager;
|
import com.intellectualcrafters.plot.util.TaskManager;
|
||||||
import com.plotsquared.general.commands.CommandDeclaration;
|
import com.plotsquared.general.commands.CommandDeclaration;
|
||||||
|
|
||||||
import java.util.HashSet;
|
|
||||||
|
|
||||||
@CommandDeclaration(
|
@CommandDeclaration(
|
||||||
command = "delete",
|
command = "delete",
|
||||||
permission = "plots.delete",
|
permission = "plots.delete",
|
||||||
@ -40,7 +38,7 @@ public class Delete extends SubCommand {
|
|||||||
return !sendMessage(plr, C.NO_PLOT_PERMS);
|
return !sendMessage(plr, C.NO_PLOT_PERMS);
|
||||||
}
|
}
|
||||||
final PlotArea plotworld = plot.getArea();
|
final PlotArea plotworld = plot.getArea();
|
||||||
final HashSet<Plot> plots = plot.getConnectedPlots();
|
final java.util.Set<Plot> plots = plot.getConnectedPlots();
|
||||||
Runnable run = new Runnable() {
|
Runnable run = new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
@ -57,7 +55,7 @@ public class Delete extends SubCommand {
|
|||||||
double value = plotworld.PRICES.get("sell") * plots.size();
|
double value = plotworld.PRICES.get("sell") * plots.size();
|
||||||
if (value > 0d) {
|
if (value > 0d) {
|
||||||
EconHandler.manager.depositMoney(plr, value);
|
EconHandler.manager.depositMoney(plr, value);
|
||||||
sendMessage(plr, C.ADDED_BALANCE, value + "");
|
sendMessage(plr, C.ADDED_BALANCE, String.valueOf(value));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
MainUtil.sendMessage(plr, C.CLEARING_DONE, System.currentTimeMillis() - start);
|
MainUtil.sendMessage(plr, C.CLEARING_DONE, System.currentTimeMillis() - start);
|
||||||
|
@ -2,8 +2,6 @@ package com.intellectualcrafters.plot.commands;
|
|||||||
|
|
||||||
import com.intellectualcrafters.plot.config.C;
|
import com.intellectualcrafters.plot.config.C;
|
||||||
import com.intellectualcrafters.plot.config.Settings;
|
import com.intellectualcrafters.plot.config.Settings;
|
||||||
import com.intellectualcrafters.plot.flag.Flag;
|
|
||||||
import com.intellectualcrafters.plot.flag.FlagManager;
|
|
||||||
import com.intellectualcrafters.plot.flag.Flags;
|
import com.intellectualcrafters.plot.flag.Flags;
|
||||||
import com.intellectualcrafters.plot.generator.HybridUtils;
|
import com.intellectualcrafters.plot.generator.HybridUtils;
|
||||||
import com.intellectualcrafters.plot.object.Location;
|
import com.intellectualcrafters.plot.object.Location;
|
||||||
@ -34,7 +32,7 @@ public class Done extends SubCommand {
|
|||||||
MainUtil.sendMessage(plr, C.NO_PLOT_PERMS);
|
MainUtil.sendMessage(plr, C.NO_PLOT_PERMS);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (plot.getFlags().containsKey("done")) {
|
if (plot.hasFlag(Flags.DONE)) {
|
||||||
MainUtil.sendMessage(plr, C.DONE_ALREADY_DONE);
|
MainUtil.sendMessage(plr, C.DONE_ALREADY_DONE);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -50,8 +48,7 @@ public class Done extends SubCommand {
|
|||||||
plot.removeRunning();
|
plot.removeRunning();
|
||||||
if ((value == null) || (value.getComplexity() >= Settings.CLEAR_THRESHOLD)) {
|
if ((value == null) || (value.getComplexity() >= Settings.CLEAR_THRESHOLD)) {
|
||||||
long flagValue = System.currentTimeMillis() / 1000;
|
long flagValue = System.currentTimeMillis() / 1000;
|
||||||
Flag flag = Flags.DONE;
|
plot.setFlag(Flags.DONE,flagValue);
|
||||||
FlagManager.addPlotFlag(plot, flag, flagValue);
|
|
||||||
MainUtil.sendMessage(plr, C.DONE_SUCCESS);
|
MainUtil.sendMessage(plr, C.DONE_SUCCESS);
|
||||||
} else {
|
} else {
|
||||||
MainUtil.sendMessage(plr, C.DONE_INSUFFICIENT_COMPLEXITY);
|
MainUtil.sendMessage(plr, C.DONE_INSUFFICIENT_COMPLEXITY);
|
||||||
|
@ -31,11 +31,6 @@ import java.util.Map;
|
|||||||
permission = "plots.flag")
|
permission = "plots.flag")
|
||||||
public class FlagCmd extends SubCommand {
|
public class FlagCmd extends SubCommand {
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getUsage() {
|
|
||||||
return super.getUsage();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(PlotPlayer player, String[] args) {
|
public boolean onCommand(PlotPlayer player, String[] args) {
|
||||||
|
|
||||||
|
@ -5,6 +5,7 @@ import com.intellectualcrafters.plot.util.StringMan;
|
|||||||
import com.plotsquared.general.commands.Command;
|
import com.plotsquared.general.commands.Command;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -58,7 +59,7 @@ public class GenerateDocs {
|
|||||||
String comment = GenerateDocs.getComments(lines);
|
String comment = GenerateDocs.getComments(lines);
|
||||||
|
|
||||||
GenerateDocs.log("#### Description");
|
GenerateDocs.log("#### Description");
|
||||||
GenerateDocs.log("`" + command.getDescription() + "`");
|
GenerateDocs.log('`' + command.getDescription() + '`');
|
||||||
if (!comment.isEmpty()) {
|
if (!comment.isEmpty()) {
|
||||||
GenerateDocs.log("##### Comments");
|
GenerateDocs.log("##### Comments");
|
||||||
GenerateDocs.log("``` java");
|
GenerateDocs.log("``` java");
|
||||||
@ -76,18 +77,18 @@ public class GenerateDocs {
|
|||||||
GenerateDocs.log(" - `" + StringMan.join(usages, "`\n - `") + "` ");
|
GenerateDocs.log(" - `" + StringMan.join(usages, "`\n - `") + "` ");
|
||||||
GenerateDocs.log("");
|
GenerateDocs.log("");
|
||||||
} else {
|
} else {
|
||||||
GenerateDocs.log("`" + mainUsage + "` ");
|
GenerateDocs.log('`' + mainUsage + "` ");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (command.getRequiredType() != RequiredType.NONE) {
|
if (command.getRequiredType() != RequiredType.NONE) {
|
||||||
GenerateDocs.log("#### Required callers");
|
GenerateDocs.log("#### Required callers");
|
||||||
GenerateDocs.log("`" + command.getRequiredType().name() + "`");
|
GenerateDocs.log('`' + command.getRequiredType().name() + '`');
|
||||||
}
|
}
|
||||||
|
|
||||||
List<String> aliases = command.getAliases();
|
List<String> aliases = command.getAliases();
|
||||||
if (!aliases.isEmpty()) {
|
if (!aliases.isEmpty()) {
|
||||||
GenerateDocs.log("#### Aliases");
|
GenerateDocs.log("#### Aliases");
|
||||||
GenerateDocs.log("`" + StringMan.getString(command.getAliases()) + "`");
|
GenerateDocs.log('`' + StringMan.getString(command.getAliases()) + '`');
|
||||||
}
|
}
|
||||||
|
|
||||||
GenerateDocs.log("#### Permissions");
|
GenerateDocs.log("#### Permissions");
|
||||||
@ -96,21 +97,21 @@ public class GenerateDocs {
|
|||||||
GenerateDocs.log(" - `" + command.getPermission() + "` ");
|
GenerateDocs.log(" - `" + command.getPermission() + "` ");
|
||||||
GenerateDocs.log("");
|
GenerateDocs.log("");
|
||||||
GenerateDocs.log("##### Other");
|
GenerateDocs.log("##### Other");
|
||||||
GenerateDocs.log(" - `" + StringMan.join(perms, "`\n - `") + "`");
|
GenerateDocs.log(" - `" + StringMan.join(perms, "`\n - `") + '`');
|
||||||
GenerateDocs.log("");
|
GenerateDocs.log("");
|
||||||
} else {
|
} else {
|
||||||
GenerateDocs.log("`" + command.getPermission() + "` ");
|
GenerateDocs.log('`' + command.getPermission() + "` ");
|
||||||
}
|
}
|
||||||
GenerateDocs.log("***");
|
GenerateDocs.log("***");
|
||||||
GenerateDocs.log("");
|
GenerateDocs.log("");
|
||||||
} catch (Exception e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<String> getUsage(String cmd, List<String> lines) {
|
public static List<String> getUsage(String cmd, List<String> lines) {
|
||||||
Pattern p = Pattern.compile("\"([^\"]*)\"");
|
Pattern p = Pattern.compile("\"([^\"]*)\"");
|
||||||
HashSet<String> usages = new HashSet<String>();
|
HashSet<String> usages = new HashSet<>();
|
||||||
for (String line : lines) {
|
for (String line : lines) {
|
||||||
if (line.contains("COMMAND_SYNTAX") && !line.contains("getUsage()")) {
|
if (line.contains("COMMAND_SYNTAX") && !line.contains("getUsage()")) {
|
||||||
Matcher m = p.matcher(line);
|
Matcher m = p.matcher(line);
|
||||||
@ -203,7 +204,7 @@ public class GenerateDocs {
|
|||||||
line = line.trim();
|
line = line.trim();
|
||||||
if (line.startsWith("/** ") || line.startsWith("*/ ") || line.startsWith("* ")) {
|
if (line.startsWith("/** ") || line.startsWith("*/ ") || line.startsWith("* ")) {
|
||||||
line = line.replaceAll("/[*][*] ", "").replaceAll("[*]/ ", "").replaceAll("[*] ", "").trim();
|
line = line.replaceAll("/[*][*] ", "").replaceAll("[*]/ ", "").replaceAll("[*] ", "").trim();
|
||||||
result.append(line + "\n");
|
result.append(line + '\n');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result.toString().trim();
|
return result.toString().trim();
|
||||||
|
@ -101,7 +101,7 @@ public class ListCmd extends SubCommand {
|
|||||||
if (page < 0) {
|
if (page < 0) {
|
||||||
page = 0;
|
page = 0;
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (NumberFormatException ignored) {
|
||||||
page = -1;
|
page = -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -245,12 +245,10 @@ public class ListCmd extends SubCommand {
|
|||||||
}
|
}
|
||||||
plots = new ArrayList<>();
|
plots = new ArrayList<>();
|
||||||
for (Plot plot : PS.get().getPlots()) {
|
for (Plot plot : PS.get().getPlots()) {
|
||||||
/*
|
Optional<Double> price = plot.getFlag(Flags.PRICE);
|
||||||
Flag price = FlagManager.getPlotFlagRaw(plot, "price");
|
if (price.isPresent()) {
|
||||||
if (price != null) {
|
|
||||||
plots.add(plot);
|
plots.add(plot);
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "unowned":
|
case "unowned":
|
||||||
@ -315,8 +313,7 @@ public class ListCmd extends SubCommand {
|
|||||||
if (uuid == null) {
|
if (uuid == null) {
|
||||||
try {
|
try {
|
||||||
uuid = UUID.fromString(args[0]);
|
uuid = UUID.fromString(args[0]);
|
||||||
} catch (Exception ignored) {
|
} catch (Exception ignored) {}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (uuid != null) {
|
if (uuid != null) {
|
||||||
if (!Permissions.hasPermission(plr, "plots.list.player")) {
|
if (!Permissions.hasPermission(plr, "plots.list.player")) {
|
||||||
|
@ -68,14 +68,14 @@ public class Load extends SubCommand {
|
|||||||
String schematic;
|
String schematic;
|
||||||
try {
|
try {
|
||||||
schematic = schematics.get(Integer.parseInt(args[0]) - 1);
|
schematic = schematics.get(Integer.parseInt(args[0]) - 1);
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException ignored) {
|
||||||
// use /plot load <index>
|
// use /plot load <index>
|
||||||
MainUtil.sendMessage(plr, C.NOT_VALID_NUMBER, "(1, " + schematics.size() + ")");
|
MainUtil.sendMessage(plr, C.NOT_VALID_NUMBER, "(1, " + schematics.size() + ')');
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
final URL url;
|
final URL url;
|
||||||
try {
|
try {
|
||||||
url = new URL(Settings.WEB_URL + "saves/" + plr.getUUID() + "/" + schematic + ".schematic");
|
url = new URL(Settings.WEB_URL + "saves/" + plr.getUUID() + '/' + schematic + ".schematic");
|
||||||
} catch (MalformedURLException e) {
|
} catch (MalformedURLException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
MainUtil.sendMessage(plr, C.LOAD_FAILED);
|
MainUtil.sendMessage(plr, C.LOAD_FAILED);
|
||||||
@ -147,7 +147,7 @@ public class Load extends SubCommand {
|
|||||||
}
|
}
|
||||||
String time = secToTime((System.currentTimeMillis() / 1000) - Long.parseLong(split[0]));
|
String time = secToTime((System.currentTimeMillis() / 1000) - Long.parseLong(split[0]));
|
||||||
String world = split[1];
|
String world = split[1];
|
||||||
PlotId id = PlotId.fromString(split[2] + ";" + split[3]);
|
PlotId id = PlotId.fromString(split[2] + ';' + split[3]);
|
||||||
String size = split[4];
|
String size = split[4];
|
||||||
String server = split[5].replaceAll(".schematic", "");
|
String server = split[5].replaceAll(".schematic", "");
|
||||||
String color;
|
String color;
|
||||||
@ -157,7 +157,7 @@ public class Load extends SubCommand {
|
|||||||
color = "$1";
|
color = "$1";
|
||||||
}
|
}
|
||||||
MainUtil.sendMessage(player,
|
MainUtil.sendMessage(player,
|
||||||
"$3[$2" + (i + 1) + "$3] " + color + time + "$3 | " + color + world + ";" + id + "$3 | " + color + size + "x" + size);
|
"$3[$2" + (i + 1) + "$3] " + color + time + "$3 | " + color + world + ';' + id + "$3 | " + color + size + 'x' + size);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,6 @@ import com.intellectualcrafters.plot.util.StringMan;
|
|||||||
import com.intellectualcrafters.plot.util.UUIDHandler;
|
import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||||
import com.plotsquared.general.commands.CommandDeclaration;
|
import com.plotsquared.general.commands.CommandDeclaration;
|
||||||
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
@CommandDeclaration(command = "merge",
|
@CommandDeclaration(command = "merge",
|
||||||
@ -74,7 +73,7 @@ public class Merge extends SubCommand {
|
|||||||
final PlotArea plotworld = plot.getArea();
|
final PlotArea plotworld = plot.getArea();
|
||||||
final double price = plotworld.PRICES.containsKey("merge") ? plotworld.PRICES.get("merge") : 0;
|
final double price = plotworld.PRICES.containsKey("merge") ? plotworld.PRICES.get("merge") : 0;
|
||||||
if (EconHandler.manager != null && plotworld.USE_ECONOMY && price > 0d && EconHandler.manager.getMoney(plr) < price) {
|
if (EconHandler.manager != null && plotworld.USE_ECONOMY && price > 0d && EconHandler.manager.getMoney(plr) < price) {
|
||||||
sendMessage(plr, C.CANNOT_AFFORD_MERGE, price + "");
|
sendMessage(plr, C.CANNOT_AFFORD_MERGE, String.valueOf(price));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
final int size = plot.getConnectedPlots().size();
|
final int size = plot.getConnectedPlots().size();
|
||||||
@ -108,7 +107,7 @@ public class Merge extends SubCommand {
|
|||||||
if (plot.autoMerge(-1, maxSize, uuid, terrain)) {
|
if (plot.autoMerge(-1, maxSize, uuid, terrain)) {
|
||||||
if (EconHandler.manager != null && plotworld.USE_ECONOMY && price > 0d) {
|
if (EconHandler.manager != null && plotworld.USE_ECONOMY && price > 0d) {
|
||||||
EconHandler.manager.withdrawMoney(plr, price);
|
EconHandler.manager.withdrawMoney(plr, price);
|
||||||
sendMessage(plr, C.REMOVED_BALANCE, price + "");
|
sendMessage(plr, C.REMOVED_BALANCE, String.valueOf(price));
|
||||||
}
|
}
|
||||||
MainUtil.sendMessage(plr, C.SUCCESS_MERGE);
|
MainUtil.sendMessage(plr, C.SUCCESS_MERGE);
|
||||||
return true;
|
return true;
|
||||||
@ -138,7 +137,7 @@ public class Merge extends SubCommand {
|
|||||||
if (plot.autoMerge(direction, maxSize - size, uuid, terrain)) {
|
if (plot.autoMerge(direction, maxSize - size, uuid, terrain)) {
|
||||||
if (EconHandler.manager != null && plotworld.USE_ECONOMY && price > 0d) {
|
if (EconHandler.manager != null && plotworld.USE_ECONOMY && price > 0d) {
|
||||||
EconHandler.manager.withdrawMoney(plr, price);
|
EconHandler.manager.withdrawMoney(plr, price);
|
||||||
sendMessage(plr, C.REMOVED_BALANCE, price + "");
|
sendMessage(plr, C.REMOVED_BALANCE, String.valueOf(price));
|
||||||
}
|
}
|
||||||
MainUtil.sendMessage(plr, C.SUCCESS_MERGE);
|
MainUtil.sendMessage(plr, C.SUCCESS_MERGE);
|
||||||
return true;
|
return true;
|
||||||
@ -152,7 +151,7 @@ public class Merge extends SubCommand {
|
|||||||
MainUtil.sendMessage(plr, C.NO_PERMISSION, C.PERMISSION_MERGE_OTHER);
|
MainUtil.sendMessage(plr, C.NO_PERMISSION, C.PERMISSION_MERGE_OTHER);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
HashSet<UUID> uuids = adjacent.getOwners();
|
java.util.Set<UUID> uuids = adjacent.getOwners();
|
||||||
boolean isOnline = false;
|
boolean isOnline = false;
|
||||||
for (final UUID owner : uuids) {
|
for (final UUID owner : uuids) {
|
||||||
final PlotPlayer accepter = UUIDHandler.getPlayer(owner);
|
final PlotPlayer accepter = UUIDHandler.getPlayer(owner);
|
||||||
@ -173,11 +172,11 @@ public class Merge extends SubCommand {
|
|||||||
}
|
}
|
||||||
if (EconHandler.manager != null && plotworld.USE_ECONOMY && price > 0d) {
|
if (EconHandler.manager != null && plotworld.USE_ECONOMY && price > 0d) {
|
||||||
if (EconHandler.manager.getMoney(plr) < price) {
|
if (EconHandler.manager.getMoney(plr) < price) {
|
||||||
sendMessage(plr, C.CANNOT_AFFORD_MERGE, price + "");
|
sendMessage(plr, C.CANNOT_AFFORD_MERGE, String.valueOf(price));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
EconHandler.manager.withdrawMoney(plr, price);
|
EconHandler.manager.withdrawMoney(plr, price);
|
||||||
sendMessage(plr, C.REMOVED_BALANCE, price + "");
|
sendMessage(plr, C.REMOVED_BALANCE, String.valueOf(price));
|
||||||
}
|
}
|
||||||
MainUtil.sendMessage(plr, C.SUCCESS_MERGE);
|
MainUtil.sendMessage(plr, C.SUCCESS_MERGE);
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,7 @@ import com.intellectualcrafters.plot.util.TaskManager;
|
|||||||
import com.intellectualcrafters.plot.util.UUIDHandler;
|
import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||||
import com.plotsquared.general.commands.CommandDeclaration;
|
import com.plotsquared.general.commands.CommandDeclaration;
|
||||||
|
|
||||||
import java.util.HashSet;
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
@CommandDeclaration(
|
@CommandDeclaration(
|
||||||
@ -27,15 +27,14 @@ public class Owner extends SetCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean set(final PlotPlayer plr, final Plot plot, String value) {
|
public boolean set(final PlotPlayer plr, final Plot plot, String value) {
|
||||||
HashSet<Plot> plots = plot.getConnectedPlots();
|
Set<Plot> plots = plot.getConnectedPlots();
|
||||||
UUID uuid = null;
|
UUID uuid = null;
|
||||||
String name = null;
|
String name = null;
|
||||||
if (value.length() == 36) {
|
if (value.length() == 36) {
|
||||||
try {
|
try {
|
||||||
uuid = UUID.fromString(value);
|
uuid = UUID.fromString(value);
|
||||||
name = MainUtil.getName(uuid);
|
name = MainUtil.getName(uuid);
|
||||||
} catch (Exception ignored) {
|
} catch (Exception ignored) {}
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
uuid = UUIDHandler.getUUID(value, null);
|
uuid = UUIDHandler.getUUID(value, null);
|
||||||
name = UUIDHandler.getName(uuid);
|
name = UUIDHandler.getName(uuid);
|
||||||
@ -43,7 +42,7 @@ public class Owner extends SetCommand {
|
|||||||
}
|
}
|
||||||
if (uuid == null) {
|
if (uuid == null) {
|
||||||
if (value.equalsIgnoreCase("none")) {
|
if (value.equalsIgnoreCase("none")) {
|
||||||
HashSet<Plot> connected = plot.getConnectedPlots();
|
Set<Plot> connected = plot.getConnectedPlots();
|
||||||
plot.unlinkPlot(false, false);
|
plot.unlinkPlot(false, false);
|
||||||
for (Plot current : connected) {
|
for (Plot current : connected) {
|
||||||
current.unclaim();
|
current.unclaim();
|
||||||
|
@ -4,6 +4,7 @@ import com.intellectualcrafters.plot.PS;
|
|||||||
import com.intellectualcrafters.plot.config.C;
|
import com.intellectualcrafters.plot.config.C;
|
||||||
import com.intellectualcrafters.plot.config.Settings;
|
import com.intellectualcrafters.plot.config.Settings;
|
||||||
import com.intellectualcrafters.plot.database.DBFunc;
|
import com.intellectualcrafters.plot.database.DBFunc;
|
||||||
|
import com.intellectualcrafters.plot.flag.Flags;
|
||||||
import com.intellectualcrafters.plot.object.Plot;
|
import com.intellectualcrafters.plot.object.Plot;
|
||||||
import com.intellectualcrafters.plot.object.PlotInventory;
|
import com.intellectualcrafters.plot.object.PlotInventory;
|
||||||
import com.intellectualcrafters.plot.object.PlotItemStack;
|
import com.intellectualcrafters.plot.object.PlotItemStack;
|
||||||
@ -61,7 +62,7 @@ public class Rate extends SubCommand {
|
|||||||
});
|
});
|
||||||
UUID uuid = player.getUUID();
|
UUID uuid = player.getUUID();
|
||||||
for (Plot p : plots) {
|
for (Plot p : plots) {
|
||||||
if ((!Settings.REQUIRE_DONE || p.getFlags().containsKey("done")) && p.isBasePlot() && (p.hasRatings() || !p.getRatings()
|
if ((!Settings.REQUIRE_DONE || p.hasFlag(Flags.DONE)) && p.isBasePlot() && (p.hasRatings() || !p.getRatings()
|
||||||
.containsKey(uuid)) && !p.isAdded(uuid)) {
|
.containsKey(uuid)) && !p.isAdded(uuid)) {
|
||||||
p.teleportPlayer(player);
|
p.teleportPlayer(player);
|
||||||
MainUtil.sendMessage(player, C.RATE_THIS);
|
MainUtil.sendMessage(player, C.RATE_THIS);
|
||||||
@ -84,7 +85,7 @@ public class Rate extends SubCommand {
|
|||||||
sendMessage(player, C.RATING_NOT_YOUR_OWN);
|
sendMessage(player, C.RATING_NOT_YOUR_OWN);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (Settings.REQUIRE_DONE && !plot.getFlags().containsKey("done")) {
|
if (Settings.REQUIRE_DONE && !plot.hasFlag(Flags.DONE)) {
|
||||||
sendMessage(player, C.RATING_NOT_DONE);
|
sendMessage(player, C.RATING_NOT_DONE);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -47,7 +47,7 @@ public class RegenAllRoads extends SubCommand {
|
|||||||
}
|
}
|
||||||
String name = args[0];
|
String name = args[0];
|
||||||
PlotManager manager = area.getPlotManager();
|
PlotManager manager = area.getPlotManager();
|
||||||
if ((manager == null) || !(manager instanceof HybridPlotManager)) {
|
if (!(manager instanceof HybridPlotManager)) {
|
||||||
MainUtil.sendMessage(plr, C.NOT_VALID_PLOT_WORLD);
|
MainUtil.sendMessage(plr, C.NOT_VALID_PLOT_WORLD);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package com.intellectualcrafters.plot.commands;
|
package com.intellectualcrafters.plot.commands;
|
||||||
|
|
||||||
import com.intellectualcrafters.configuration.ConfigurationSection;
|
import com.intellectualcrafters.configuration.ConfigurationSection;
|
||||||
|
import com.intellectualcrafters.configuration.InvalidConfigurationException;
|
||||||
import com.intellectualcrafters.configuration.MemorySection;
|
import com.intellectualcrafters.configuration.MemorySection;
|
||||||
import com.intellectualcrafters.configuration.file.YamlConfiguration;
|
import com.intellectualcrafters.configuration.file.YamlConfiguration;
|
||||||
import com.intellectualcrafters.plot.PS;
|
import com.intellectualcrafters.plot.PS;
|
||||||
@ -11,6 +12,7 @@ import com.intellectualcrafters.plot.object.RunnableVal;
|
|||||||
import com.intellectualcrafters.plot.util.MainUtil;
|
import com.intellectualcrafters.plot.util.MainUtil;
|
||||||
import com.plotsquared.general.commands.CommandDeclaration;
|
import com.plotsquared.general.commands.CommandDeclaration;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
@CommandDeclaration(command = "reload",
|
@CommandDeclaration(command = "reload",
|
||||||
@ -77,7 +79,7 @@ public class Reload extends SubCommand {
|
|||||||
});
|
});
|
||||||
PS.get().config.save(PS.get().configFile);
|
PS.get().config.save(PS.get().configFile);
|
||||||
MainUtil.sendMessage(plr, C.RELOADED_CONFIGS);
|
MainUtil.sendMessage(plr, C.RELOADED_CONFIGS);
|
||||||
} catch (Exception e) {
|
} catch (InvalidConfigurationException | IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
MainUtil.sendMessage(plr, C.RELOAD_FAILED);
|
MainUtil.sendMessage(plr, C.RELOAD_FAILED);
|
||||||
}
|
}
|
||||||
|
@ -65,8 +65,8 @@ public class Setup extends SubCommand {
|
|||||||
if (object.setup_index > 0) {
|
if (object.setup_index > 0) {
|
||||||
object.setup_index--;
|
object.setup_index--;
|
||||||
ConfigurationNode node = object.step[object.setup_index];
|
ConfigurationNode node = object.step[object.setup_index];
|
||||||
sendMessage(plr, C.SETUP_STEP, object.setup_index + 1 + "", node.getDescription(), node.getType().getType(),
|
sendMessage(plr, C.SETUP_STEP, object.setup_index + 1, node.getDescription(), node.getType().getType(),
|
||||||
node.getDefaultValue() + "");
|
String.valueOf(node.getDefaultValue()));
|
||||||
return false;
|
return false;
|
||||||
} else if (object.current > 0) {
|
} else if (object.current > 0) {
|
||||||
object.current--;
|
object.current--;
|
||||||
@ -127,8 +127,8 @@ public class Setup extends SubCommand {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
ConfigurationNode step = object.step[object.setup_index];
|
ConfigurationNode step = object.step[object.setup_index];
|
||||||
sendMessage(plr, C.SETUP_STEP, object.setup_index + 1 + "", step.getDescription(), step.getType().getType(),
|
sendMessage(plr, C.SETUP_STEP, object.setup_index + 1, step.getDescription(), step.getType().getType(),
|
||||||
step.getDefaultValue() + "");
|
String.valueOf(step.getDefaultValue()));
|
||||||
} else {
|
} else {
|
||||||
if (gen.isFull()) {
|
if (gen.isFull()) {
|
||||||
object.plotManager = object.setupGenerator;
|
object.plotManager = object.setupGenerator;
|
||||||
@ -216,8 +216,8 @@ public class Setup extends SubCommand {
|
|||||||
.getNewPlotArea("CheckingPlotSquaredGenerator", null, null, null).getSettingNodes();
|
.getNewPlotArea("CheckingPlotSquaredGenerator", null, null, null).getSettingNodes();
|
||||||
}
|
}
|
||||||
ConfigurationNode step = object.step[object.setup_index];
|
ConfigurationNode step = object.step[object.setup_index];
|
||||||
sendMessage(plr, C.SETUP_STEP, object.setup_index + 1 + "", step.getDescription(), step.getType().getType(),
|
sendMessage(plr, C.SETUP_STEP, object.setup_index + 1, step.getDescription(), step.getType().getType(),
|
||||||
step.getDefaultValue() + "");
|
String.valueOf(step.getDefaultValue()));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 6: // world setup
|
case 6: // world setup
|
||||||
@ -229,8 +229,8 @@ public class Setup extends SubCommand {
|
|||||||
}
|
}
|
||||||
ConfigurationNode step = object.step[object.setup_index];
|
ConfigurationNode step = object.step[object.setup_index];
|
||||||
if (args.length < 1) {
|
if (args.length < 1) {
|
||||||
sendMessage(plr, C.SETUP_STEP, object.setup_index + 1 + "", step.getDescription(), step.getType().getType(),
|
sendMessage(plr, C.SETUP_STEP, object.setup_index + 1, step.getDescription(), step.getType().getType(),
|
||||||
step.getDefaultValue() + "");
|
String.valueOf(step.getDefaultValue()));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
boolean valid = step.isValid(args[0]);
|
boolean valid = step.isValid(args[0]);
|
||||||
@ -243,13 +243,13 @@ public class Setup extends SubCommand {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
step = object.step[object.setup_index];
|
step = object.step[object.setup_index];
|
||||||
sendMessage(plr, C.SETUP_STEP, object.setup_index + 1 + "", step.getDescription(), step.getType().getType(),
|
sendMessage(plr, C.SETUP_STEP, object.setup_index + 1, step.getDescription(), step.getType().getType(),
|
||||||
step.getDefaultValue() + "");
|
String.valueOf(step.getDefaultValue()));
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
sendMessage(plr, C.SETUP_INVALID_ARG, args[0], step.getConstant());
|
sendMessage(plr, C.SETUP_INVALID_ARG, args[0], step.getConstant());
|
||||||
sendMessage(plr, C.SETUP_STEP, object.setup_index + 1 + "", step.getDescription(), step.getType().getType(),
|
sendMessage(plr, C.SETUP_STEP, object.setup_index + 1, step.getDescription(), step.getType().getType(),
|
||||||
step.getDefaultValue() + "");
|
String.valueOf(step.getDefaultValue()));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
case 7:
|
case 7:
|
||||||
|
@ -52,15 +52,7 @@ public class Trim extends SubCommand {
|
|||||||
String name = file.getName();
|
String name = file.getName();
|
||||||
if (name.endsWith("mca")) {
|
if (name.endsWith("mca")) {
|
||||||
if (file.getTotalSpace() <= 8192) {
|
if (file.getTotalSpace() <= 8192) {
|
||||||
try {
|
checkMca(name);
|
||||||
String[] split = name.split("\\.");
|
|
||||||
int x = Integer.parseInt(split[1]);
|
|
||||||
int z = Integer.parseInt(split[2]);
|
|
||||||
ChunkLoc loc = new ChunkLoc(x, z);
|
|
||||||
empty.add(loc);
|
|
||||||
} catch (NumberFormatException e) {
|
|
||||||
PS.debug("INVALID MCA: " + name);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
Path path = Paths.get(file.getPath());
|
Path path = Paths.get(file.getPath());
|
||||||
try {
|
try {
|
||||||
@ -69,24 +61,26 @@ public class Trim extends SubCommand {
|
|||||||
long modification = file.lastModified();
|
long modification = file.lastModified();
|
||||||
long diff = Math.abs(creation - modification);
|
long diff = Math.abs(creation - modification);
|
||||||
if (diff < 10000) {
|
if (diff < 10000) {
|
||||||
|
checkMca(name);
|
||||||
|
}
|
||||||
|
} catch (IOException ignored) {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Trim.TASK = false;
|
||||||
|
TaskManager.runTaskAsync(whenDone);
|
||||||
|
}
|
||||||
|
private void checkMca(String name) {
|
||||||
try {
|
try {
|
||||||
String[] split = name.split("\\.");
|
String[] split = name.split("\\.");
|
||||||
int x = Integer.parseInt(split[1]);
|
int x = Integer.parseInt(split[1]);
|
||||||
int z = Integer.parseInt(split[2]);
|
int z = Integer.parseInt(split[2]);
|
||||||
ChunkLoc loc = new ChunkLoc(x, z);
|
ChunkLoc loc = new ChunkLoc(x, z);
|
||||||
empty.add(loc);
|
empty.add(loc);
|
||||||
} catch (Exception e) {
|
} catch (NumberFormatException ignored) {
|
||||||
PS.debug("INVALID MCA: " + name);
|
PS.debug("INVALID MCA: " + name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (IOException ignored) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Trim.TASK = false;
|
|
||||||
TaskManager.runTaskAsync(whenDone);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
Trim.TASK = true;
|
Trim.TASK = true;
|
||||||
return true;
|
return true;
|
||||||
|
@ -41,7 +41,7 @@ public class Update extends SubCommand {
|
|||||||
MainUtil.sendMessage(plr, "&cTo manually specify an update URL: /plot update <url>");
|
MainUtil.sendMessage(plr, "&cTo manually specify an update URL: /plot update <url>");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (PS.get().update(null, url) && (url == PS.get().update)) {
|
if (PS.get().update(plr, url) && (url == PS.get().update)) {
|
||||||
PS.get().update = null;
|
PS.get().update = null;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -92,7 +92,7 @@ public class Visit extends SubCommand {
|
|||||||
sendMessage(player, C.NOT_VALID_NUMBER, "(1, " + unsorted.size() + ")");
|
sendMessage(player, C.NOT_VALID_NUMBER, "(1, " + unsorted.size() + ")");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
ArrayList<Plot> plots = PS.get().sortPlotsByTemp(unsorted);
|
List<Plot> plots = PS.get().sortPlotsByTemp(unsorted);
|
||||||
Plot plot = plots.get(page - 1);
|
Plot plot = plots.get(page - 1);
|
||||||
if (!plot.hasOwner()) {
|
if (!plot.hasOwner()) {
|
||||||
if (!Permissions.hasPermission(player, "plots.visit.unowned")) {
|
if (!Permissions.hasPermission(player, "plots.visit.unowned")) {
|
||||||
|
@ -7,6 +7,7 @@ import com.intellectualcrafters.plot.util.StringMan;
|
|||||||
import com.plotsquared.general.commands.CommandCaller;
|
import com.plotsquared.general.commands.CommandCaller;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
import java.util.EnumSet;
|
import java.util.EnumSet;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
@ -730,7 +731,7 @@ public enum C {
|
|||||||
if (!split[0].equalsIgnoreCase(caption.category)) {
|
if (!split[0].equalsIgnoreCase(caption.category)) {
|
||||||
changed = true;
|
changed = true;
|
||||||
yml.set(key, null);
|
yml.set(key, null);
|
||||||
yml.set(caption.category + "." + caption.name().toLowerCase(), value);
|
yml.set(caption.category + '.' + caption.name().toLowerCase(), value);
|
||||||
}
|
}
|
||||||
captions.add(caption);
|
captions.add(caption);
|
||||||
caption.s = value;
|
caption.s = value;
|
||||||
@ -747,7 +748,7 @@ public enum C {
|
|||||||
// HashMap<String, String> replacements = new HashMap<>();
|
// HashMap<String, String> replacements = new HashMap<>();
|
||||||
replacements.clear();
|
replacements.clear();
|
||||||
for (String style : styles) {
|
for (String style : styles) {
|
||||||
replacements.put("$" + style, "\u00a7" + config.getString(style));
|
replacements.put('$' + style, '§' + config.getString(style));
|
||||||
}
|
}
|
||||||
for (char letter : "1234567890abcdefklmnor".toCharArray()) {
|
for (char letter : "1234567890abcdefklmnor".toCharArray()) {
|
||||||
replacements.put("&" + letter, "\u00a7" + letter);
|
replacements.put("&" + letter, "\u00a7" + letter);
|
||||||
@ -761,14 +762,14 @@ public enum C {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
changed = true;
|
changed = true;
|
||||||
yml.set(caption.category + "." + caption.name().toLowerCase(), caption.def);
|
yml.set(caption.category + '.' + caption.name().toLowerCase(), caption.def);
|
||||||
}
|
}
|
||||||
caption.s = StringMan.replaceFromMap(caption.s, replacements);
|
caption.s = StringMan.replaceFromMap(caption.s, replacements);
|
||||||
}
|
}
|
||||||
if (changed) {
|
if (changed) {
|
||||||
yml.save(file);
|
yml.save(file);
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (IOException | IllegalArgumentException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -41,7 +41,7 @@ public class Configuration {
|
|||||||
try {
|
try {
|
||||||
Integer.parseInt(string);
|
Integer.parseInt(string);
|
||||||
return true;
|
return true;
|
||||||
} catch (Exception e) {
|
} catch (NumberFormatException ignored) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -54,12 +54,8 @@ public class Configuration {
|
|||||||
public static final SettingValue<Boolean> BOOLEAN = new SettingValue<Boolean>("BOOLEAN") {
|
public static final SettingValue<Boolean> BOOLEAN = new SettingValue<Boolean>("BOOLEAN") {
|
||||||
@Override
|
@Override
|
||||||
public boolean validateValue(String string) {
|
public boolean validateValue(String string) {
|
||||||
try {
|
|
||||||
Boolean.parseBoolean(string);
|
Boolean.parseBoolean(string);
|
||||||
return true;
|
return true;
|
||||||
} catch (Exception e) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -73,7 +69,7 @@ public class Configuration {
|
|||||||
try {
|
try {
|
||||||
Double.parseDouble(string);
|
Double.parseDouble(string);
|
||||||
return true;
|
return true;
|
||||||
} catch (Exception e) {
|
} catch (NumberFormatException ignored) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -89,7 +85,7 @@ public class Configuration {
|
|||||||
try {
|
try {
|
||||||
int biome = WorldUtil.IMP.getBiomeFromString(string.toUpperCase());
|
int biome = WorldUtil.IMP.getBiomeFromString(string.toUpperCase());
|
||||||
return biome != -1;
|
return biome != -1;
|
||||||
} catch (Exception e) {
|
} catch (Exception ignored) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -134,7 +130,7 @@ public class Configuration {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException ignored) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -166,8 +162,7 @@ public class Configuration {
|
|||||||
if (result != null && result.match < 2) {
|
if (result != null && result.match < 2) {
|
||||||
values[i] = result.best;
|
values[i] = result.best;
|
||||||
}
|
}
|
||||||
} catch (NumberFormatException ignored) {
|
} catch (NumberFormatException ignored) {}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
int gcd = gcd(counts);
|
int gcd = gcd(counts);
|
||||||
for (int i = 0; i < counts.length; i++) {
|
for (int i = 0; i < counts.length; i++) {
|
||||||
|
@ -36,7 +36,7 @@ public interface AbstractDB {
|
|||||||
* @param plots Plots for which the default table entries should be created
|
* @param plots Plots for which the default table entries should be created
|
||||||
* @param whenDone
|
* @param whenDone
|
||||||
*/
|
*/
|
||||||
void createPlotsAndData(ArrayList<Plot> plots, Runnable whenDone);
|
void createPlotsAndData(List<Plot> plots, Runnable whenDone);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a plot
|
* Create a plot
|
||||||
|
@ -81,7 +81,7 @@ public class DBFunc {
|
|||||||
*
|
*
|
||||||
* @param plots List containing all plot objects
|
* @param plots List containing all plot objects
|
||||||
*/
|
*/
|
||||||
public static void createPlotsAndData(ArrayList<Plot> plots, Runnable whenDone) {
|
public static void createPlotsAndData(List<Plot> plots, Runnable whenDone) {
|
||||||
DBFunc.dbManager.createPlotsAndData(plots, whenDone);
|
DBFunc.dbManager.createPlotsAndData(plots, whenDone);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,6 +40,7 @@ import java.util.concurrent.ConcurrentLinkedQueue;
|
|||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
|
|
||||||
|
@SuppressWarnings("SqlDialectInspection")
|
||||||
public class SQLManager implements AbstractDB {
|
public class SQLManager implements AbstractDB {
|
||||||
|
|
||||||
// Public final
|
// Public final
|
||||||
@ -173,7 +174,7 @@ public class SQLManager implements AbstractDB {
|
|||||||
this.plotTasks.put(plot, tasks);
|
this.plotTasks.put(plot, tasks);
|
||||||
}
|
}
|
||||||
if (task == null) {
|
if (task == null) {
|
||||||
task = new UniqueStatement(plot.hashCode() + "") {
|
task = new UniqueStatement(String.valueOf(plot.hashCode())) {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PreparedStatement get() {
|
public PreparedStatement get() {
|
||||||
@ -181,16 +182,13 @@ public class SQLManager implements AbstractDB {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void set(PreparedStatement stmt) {
|
public void set(PreparedStatement stmt) {}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addBatch(PreparedStatement statement) {
|
public void addBatch(PreparedStatement statement) {}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(PreparedStatement statement) {
|
public void execute(PreparedStatement statement) {}
|
||||||
}
|
|
||||||
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -207,7 +205,7 @@ public class SQLManager implements AbstractDB {
|
|||||||
this.playerTasks.put(uuid, tasks);
|
this.playerTasks.put(uuid, tasks);
|
||||||
}
|
}
|
||||||
if (task == null) {
|
if (task == null) {
|
||||||
task = new UniqueStatement(uuid.hashCode() + "") {
|
task = new UniqueStatement(String.valueOf(uuid.hashCode())) {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PreparedStatement get() {
|
public PreparedStatement get() {
|
||||||
@ -215,16 +213,13 @@ public class SQLManager implements AbstractDB {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void set(PreparedStatement stmt) {
|
public void set(PreparedStatement stmt) {}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addBatch(PreparedStatement statement) {
|
public void addBatch(PreparedStatement statement) {}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(PreparedStatement statement) {
|
public void execute(PreparedStatement statement) {}
|
||||||
}
|
|
||||||
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -238,7 +233,7 @@ public class SQLManager implements AbstractDB {
|
|||||||
this.clusterTasks.put(cluster, tasks);
|
this.clusterTasks.put(cluster, tasks);
|
||||||
}
|
}
|
||||||
if (task == null) {
|
if (task == null) {
|
||||||
task = new UniqueStatement(cluster.hashCode() + "") {
|
task = new UniqueStatement(String.valueOf(cluster.hashCode())) {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PreparedStatement get() {
|
public PreparedStatement get() {
|
||||||
@ -246,16 +241,13 @@ public class SQLManager implements AbstractDB {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void set(PreparedStatement stmt) {
|
public void set(PreparedStatement stmt) {}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addBatch(PreparedStatement statement) {
|
public void addBatch(PreparedStatement statement) {}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(PreparedStatement statement) {
|
public void execute(PreparedStatement statement) {}
|
||||||
}
|
|
||||||
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -397,7 +389,8 @@ public class SQLManager implements AbstractDB {
|
|||||||
if (count > 0) {
|
if (count > 0) {
|
||||||
commit();
|
commit();
|
||||||
return true;
|
return true;
|
||||||
} else if (count != -1) {
|
}
|
||||||
|
if (count != -1) {
|
||||||
if (!this.connection.getAutoCommit()) {
|
if (!this.connection.getAutoCommit()) {
|
||||||
this.connection.setAutoCommit(true);
|
this.connection.setAutoCommit(true);
|
||||||
}
|
}
|
||||||
@ -443,7 +436,7 @@ public class SQLManager implements AbstractDB {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void createPlotsAndData(final ArrayList<Plot> myList, final Runnable whenDone) {
|
public void createPlotsAndData(final List<Plot> myList, final Runnable whenDone) {
|
||||||
addGlobalTask(new Runnable() {
|
addGlobalTask(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
@ -587,7 +580,7 @@ public class SQLManager implements AbstractDB {
|
|||||||
*
|
*
|
||||||
* @param myList list of plots to be created
|
* @param myList list of plots to be created
|
||||||
*/
|
*/
|
||||||
public void createPlots(ArrayList<Plot> myList, Runnable whenDone) {
|
public void createPlots(List<Plot> myList, Runnable whenDone) {
|
||||||
StmtMod<Plot> mod = new StmtMod<Plot>() {
|
StmtMod<Plot> mod = new StmtMod<Plot>() {
|
||||||
@Override
|
@Override
|
||||||
public String getCreateMySQL(int size) {
|
public String getCreateMySQL(int size) {
|
||||||
@ -611,7 +604,7 @@ public class SQLManager implements AbstractDB {
|
|||||||
stmt.setInt(i * 5 + 2, plot.getId().y);
|
stmt.setInt(i * 5 + 2, plot.getId().y);
|
||||||
try {
|
try {
|
||||||
stmt.setString(i * 5 + 3, plot.owner.toString());
|
stmt.setString(i * 5 + 3, plot.owner.toString());
|
||||||
} catch (SQLException e) {
|
} catch (SQLException ignored) {
|
||||||
stmt.setString(i * 5 + 3, AbstractDB.everyone.toString());
|
stmt.setString(i * 5 + 3, AbstractDB.everyone.toString());
|
||||||
}
|
}
|
||||||
stmt.setString(i * 5 + 4, plot.getArea().toString());
|
stmt.setString(i * 5 + 4, plot.getArea().toString());
|
||||||
@ -625,7 +618,7 @@ public class SQLManager implements AbstractDB {
|
|||||||
stmt.setInt(i * 6 + 3, plot.getId().y);
|
stmt.setInt(i * 6 + 3, plot.getId().y);
|
||||||
try {
|
try {
|
||||||
stmt.setString(i * 6 + 4, plot.owner.toString());
|
stmt.setString(i * 6 + 4, plot.owner.toString());
|
||||||
} catch (SQLException e1) {
|
} catch (SQLException ignored) {
|
||||||
stmt.setString(i * 6 + 4, AbstractDB.everyone.toString());
|
stmt.setString(i * 6 + 4, AbstractDB.everyone.toString());
|
||||||
}
|
}
|
||||||
stmt.setString(i * 6 + 5, plot.getArea().toString());
|
stmt.setString(i * 6 + 5, plot.getArea().toString());
|
||||||
@ -645,7 +638,7 @@ public class SQLManager implements AbstractDB {
|
|||||||
setBulk(myList, mod, whenDone);
|
setBulk(myList, mod, whenDone);
|
||||||
}
|
}
|
||||||
|
|
||||||
public <T> void setBulk(ArrayList<T> objList, StmtMod<T> mod, Runnable whenDone) {
|
public <T> void setBulk(List<T> objList, StmtMod<T> mod, Runnable whenDone) {
|
||||||
int size = objList.size();
|
int size = objList.size();
|
||||||
if (size == 0) {
|
if (size == 0) {
|
||||||
if (whenDone != null) {
|
if (whenDone != null) {
|
||||||
@ -740,20 +733,13 @@ public class SQLManager implements AbstractDB {
|
|||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
PS.debug("&cERROR 2: | " + objList.get(0).getClass().getCanonicalName());
|
PS.debug("&cERROR 2: | " + objList.get(0).getClass().getCanonicalName());
|
||||||
PS.debug("&6[WARN] Could not bulk save!");
|
PS.debug("&6[WARN] Could not bulk save!");
|
||||||
try {
|
try (PreparedStatement preparedStmt = this.connection.prepareStatement(mod.getCreateSQL())) {
|
||||||
String nonBulk = mod.getCreateSQL();
|
|
||||||
PreparedStatement preparedStmt = this.connection.prepareStatement(nonBulk);
|
|
||||||
for (T obj : objList) {
|
for (T obj : objList) {
|
||||||
try {
|
|
||||||
mod.setSQL(preparedStmt, obj);
|
mod.setSQL(preparedStmt, obj);
|
||||||
preparedStmt.addBatch();
|
preparedStmt.addBatch();
|
||||||
} catch (SQLException e3) {
|
|
||||||
PS.debug("&c[ERROR] Failed to save " + obj + "!");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
PS.debug("&aBatch 3");
|
PS.debug("&aBatch 3");
|
||||||
preparedStmt.executeBatch();
|
preparedStmt.executeBatch();
|
||||||
preparedStmt.close();
|
|
||||||
} catch (SQLException e3) {
|
} catch (SQLException e3) {
|
||||||
e3.printStackTrace();
|
e3.printStackTrace();
|
||||||
PS.debug("&c[ERROR] Failed to save all!");
|
PS.debug("&c[ERROR] Failed to save all!");
|
||||||
@ -807,9 +793,9 @@ public class SQLManager implements AbstractDB {
|
|||||||
int k = 0;
|
int k = 0;
|
||||||
for (Entry<Flag<?>, ?> flag : pair.settings.flags.entrySet()) {
|
for (Entry<Flag<?>, ?> flag : pair.settings.flags.entrySet()) {
|
||||||
if (k != 0) {
|
if (k != 0) {
|
||||||
flag_string.append(",");
|
flag_string.append(',');
|
||||||
}
|
}
|
||||||
flag_string.append(flag.getKey().getName() + ":" + flag.getKey().valueToString(flag.getValue()).replaceAll(":", "¯")
|
flag_string.append(flag.getKey().getName() + ':' + flag.getKey().valueToString(flag.getValue()).replaceAll(":", "¯")
|
||||||
.replaceAll(",", "´"));
|
.replaceAll(",", "´"));
|
||||||
k++;
|
k++;
|
||||||
}
|
}
|
||||||
@ -822,7 +808,7 @@ public class SQLManager implements AbstractDB {
|
|||||||
if (loc.y == 0) {
|
if (loc.y == 0) {
|
||||||
position = "DEFAULT";
|
position = "DEFAULT";
|
||||||
} else {
|
} else {
|
||||||
position = loc.x + "," + loc.y + "," + loc.z;
|
position = loc.x + "," + loc.y + ',' + loc.z;
|
||||||
}
|
}
|
||||||
statement.setString(i * 10 + 10, position);
|
statement.setString(i * 10 + 10, position);
|
||||||
}
|
}
|
||||||
@ -844,9 +830,9 @@ public class SQLManager implements AbstractDB {
|
|||||||
int k = 0;
|
int k = 0;
|
||||||
for (Entry<Flag<?>, ?> flag : pair.settings.flags.entrySet()) {
|
for (Entry<Flag<?>, ?> flag : pair.settings.flags.entrySet()) {
|
||||||
if (k != 0) {
|
if (k != 0) {
|
||||||
flag_string.append(",");
|
flag_string.append(',');
|
||||||
}
|
}
|
||||||
flag_string.append(flag.getKey().getName() + ":" + flag.getKey().valueToString(flag.getValue()).replaceAll(":", "¯")
|
flag_string.append(flag.getKey().getName() + ':' + flag.getKey().valueToString(flag.getValue()).replaceAll(":", "¯")
|
||||||
.replaceAll(",", "´"));
|
.replaceAll(",", "´"));
|
||||||
k++;
|
k++;
|
||||||
}
|
}
|
||||||
@ -862,7 +848,7 @@ public class SQLManager implements AbstractDB {
|
|||||||
if (loc.y == 0) {
|
if (loc.y == 0) {
|
||||||
position = "DEFAULT";
|
position = "DEFAULT";
|
||||||
} else {
|
} else {
|
||||||
position = loc.x + "," + loc.y + "," + loc.z;
|
position = loc.x + "," + loc.y + ',' + loc.z;
|
||||||
}
|
}
|
||||||
stmt.setString(i * 10 + 10, position);
|
stmt.setString(i * 10 + 10, position);
|
||||||
}
|
}
|
||||||
@ -960,10 +946,10 @@ public class SQLManager implements AbstractDB {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void commit() {
|
public void commit() {
|
||||||
try {
|
|
||||||
if (this.closed) {
|
if (this.closed) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
try {
|
||||||
if (!this.connection.getAutoCommit()) {
|
if (!this.connection.getAutoCommit()) {
|
||||||
this.connection.commit();
|
this.connection.commit();
|
||||||
this.connection.setAutoCommit(true);
|
this.connection.setAutoCommit(true);
|
||||||
@ -991,9 +977,7 @@ public class SQLManager implements AbstractDB {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(PreparedStatement statement) {
|
public void execute(PreparedStatement statement) {}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addBatch(PreparedStatement statement) throws SQLException {
|
public void addBatch(PreparedStatement statement) throws SQLException {
|
||||||
@ -1181,7 +1165,7 @@ public class SQLManager implements AbstractDB {
|
|||||||
+ "`comment` VARCHAR(40) NOT NULL,"
|
+ "`comment` VARCHAR(40) NOT NULL,"
|
||||||
+ "`inbox` VARCHAR(40) NOT NULL, `timestamp` INT(11) NOT NULL,"
|
+ "`inbox` VARCHAR(40) NOT NULL, `timestamp` INT(11) NOT NULL,"
|
||||||
+ "`sender` VARCHAR(40) NOT NULL"
|
+ "`sender` VARCHAR(40) NOT NULL"
|
||||||
+ ")");
|
+ ')');
|
||||||
stmt.addBatch("CREATE TABLE IF NOT EXISTS `"
|
stmt.addBatch("CREATE TABLE IF NOT EXISTS `"
|
||||||
+ this.prefix
|
+ this.prefix
|
||||||
+ "plot_settings` ("
|
+ "plot_settings` ("
|
||||||
@ -1196,7 +1180,7 @@ public class SQLManager implements AbstractDB {
|
|||||||
+ " `merged` INT(11) DEFAULT NULL,"
|
+ " `merged` INT(11) DEFAULT NULL,"
|
||||||
+ " `position` VARCHAR(50) NOT NULL DEFAULT 'DEFAULT',"
|
+ " `position` VARCHAR(50) NOT NULL DEFAULT 'DEFAULT',"
|
||||||
+ " PRIMARY KEY (`plot_plot_id`)"
|
+ " PRIMARY KEY (`plot_plot_id`)"
|
||||||
+ ")");
|
+ ')');
|
||||||
stmt.addBatch("CREATE TABLE IF NOT EXISTS `" + this.prefix
|
stmt.addBatch("CREATE TABLE IF NOT EXISTS `" + this.prefix
|
||||||
+ "plot_rating` (`plot_plot_id` INT(11) NOT NULL, `rating` INT(2) NOT NULL, `player` VARCHAR(40) NOT NULL)");
|
+ "plot_rating` (`plot_plot_id` INT(11) NOT NULL, `rating` INT(2) NOT NULL, `player` VARCHAR(40) NOT NULL)");
|
||||||
stmt.addBatch("CREATE TABLE IF NOT EXISTS `"
|
stmt.addBatch("CREATE TABLE IF NOT EXISTS `"
|
||||||
@ -1210,7 +1194,7 @@ public class SQLManager implements AbstractDB {
|
|||||||
+ "`owner` VARCHAR(40) NOT NULL,"
|
+ "`owner` VARCHAR(40) NOT NULL,"
|
||||||
+ "`world` VARCHAR(45) NOT NULL,"
|
+ "`world` VARCHAR(45) NOT NULL,"
|
||||||
+ "`timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP"
|
+ "`timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP"
|
||||||
+ ")");
|
+ ')');
|
||||||
stmt.addBatch("CREATE TABLE IF NOT EXISTS `" + this.prefix + "cluster_helpers` (`cluster_id` INT(11) NOT NULL,"
|
stmt.addBatch("CREATE TABLE IF NOT EXISTS `" + this.prefix + "cluster_helpers` (`cluster_id` INT(11) NOT NULL,"
|
||||||
+ "`user_uuid` VARCHAR(40) NOT NULL)");
|
+ "`user_uuid` VARCHAR(40) NOT NULL)");
|
||||||
stmt.addBatch("CREATE TABLE IF NOT EXISTS `" + this.prefix + "cluster_invited` (`cluster_id` INT(11) NOT NULL,"
|
stmt.addBatch("CREATE TABLE IF NOT EXISTS `" + this.prefix + "cluster_invited` (`cluster_id` INT(11) NOT NULL,"
|
||||||
@ -1229,7 +1213,7 @@ public class SQLManager implements AbstractDB {
|
|||||||
+ " `merged` INT(11) DEFAULT NULL,"
|
+ " `merged` INT(11) DEFAULT NULL,"
|
||||||
+ " `position` VARCHAR(50) NOT NULL DEFAULT 'DEFAULT',"
|
+ " `position` VARCHAR(50) NOT NULL DEFAULT 'DEFAULT',"
|
||||||
+ " PRIMARY KEY (`cluster_id`)"
|
+ " PRIMARY KEY (`cluster_id`)"
|
||||||
+ ")");
|
+ ')');
|
||||||
stmt.addBatch("CREATE TABLE IF NOT EXISTS `"
|
stmt.addBatch("CREATE TABLE IF NOT EXISTS `"
|
||||||
+ this.prefix
|
+ this.prefix
|
||||||
+ "player_meta` ("
|
+ "player_meta` ("
|
||||||
@ -1237,7 +1221,7 @@ public class SQLManager implements AbstractDB {
|
|||||||
+ " `uuid` VARCHAR(40) NOT NULL,"
|
+ " `uuid` VARCHAR(40) NOT NULL,"
|
||||||
+ " `key` VARCHAR(32) NOT NULL,"
|
+ " `key` VARCHAR(32) NOT NULL,"
|
||||||
+ " `value` blob NOT NULL"
|
+ " `value` blob NOT NULL"
|
||||||
+ ")");
|
+ ')');
|
||||||
}
|
}
|
||||||
stmt.executeBatch();
|
stmt.executeBatch();
|
||||||
stmt.clearBatch();
|
stmt.clearBatch();
|
||||||
@ -1411,21 +1395,22 @@ public class SQLManager implements AbstractDB {
|
|||||||
if (cluster.temp > 0) {
|
if (cluster.temp > 0) {
|
||||||
return cluster.temp;
|
return cluster.temp;
|
||||||
}
|
}
|
||||||
PreparedStatement stmt = this.connection.prepareStatement("SELECT `id` FROM `"
|
int c_id;
|
||||||
|
try (PreparedStatement stmt = this.connection.prepareStatement("SELECT `id` FROM `"
|
||||||
+ this.prefix
|
+ this.prefix
|
||||||
+ "cluster` WHERE `pos1_x` = ? AND `pos1_z` = ? AND `pos2_x` = ? AND `pos2_z` = ? AND `world` = ? ORDER BY `timestamp` ASC");
|
+ "cluster` WHERE `pos1_x` = ? AND `pos1_z` = ? AND `pos2_x` = ? AND `pos2_z` = ? AND `world` = ? ORDER BY `timestamp` ASC")) {
|
||||||
stmt.setInt(1, cluster.getP1().x);
|
stmt.setInt(1, cluster.getP1().x);
|
||||||
stmt.setInt(2, cluster.getP1().y);
|
stmt.setInt(2, cluster.getP1().y);
|
||||||
stmt.setInt(3, cluster.getP2().x);
|
stmt.setInt(3, cluster.getP2().x);
|
||||||
stmt.setInt(4, cluster.getP2().y);
|
stmt.setInt(4, cluster.getP2().y);
|
||||||
stmt.setString(5, cluster.area.toString());
|
stmt.setString(5, cluster.area.toString());
|
||||||
ResultSet r = stmt.executeQuery();
|
try (ResultSet resultSet = stmt.executeQuery()) {
|
||||||
int c_id = Integer.MAX_VALUE;
|
c_id = Integer.MAX_VALUE;
|
||||||
while (r.next()) {
|
while (resultSet.next()) {
|
||||||
c_id = r.getInt("id");
|
c_id = resultSet.getInt("id");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
stmt.close();
|
|
||||||
r.close();
|
|
||||||
if (c_id == Integer.MAX_VALUE || c_id == 0) {
|
if (c_id == Integer.MAX_VALUE || c_id == 0) {
|
||||||
if (cluster.temp > 0) {
|
if (cluster.temp > 0) {
|
||||||
return cluster.temp;
|
return cluster.temp;
|
||||||
@ -1493,8 +1478,7 @@ public class SQLManager implements AbstractDB {
|
|||||||
rs = data.getColumns(null, null, this.prefix + "plot_comments", "hashcode");
|
rs = data.getColumns(null, null, this.prefix + "plot_comments", "hashcode");
|
||||||
if (!rs.next()) {
|
if (!rs.next()) {
|
||||||
rs.close();
|
rs.close();
|
||||||
try {
|
try (Statement statement = this.connection.createStatement()) {
|
||||||
Statement statement = this.connection.createStatement();
|
|
||||||
statement.addBatch("DROP TABLE `" + this.prefix + "plot_comments`");
|
statement.addBatch("DROP TABLE `" + this.prefix + "plot_comments`");
|
||||||
if (Settings.DB.USE_MYSQL) {
|
if (Settings.DB.USE_MYSQL) {
|
||||||
statement.addBatch("CREATE TABLE IF NOT EXISTS `"
|
statement.addBatch("CREATE TABLE IF NOT EXISTS `"
|
||||||
@ -1514,17 +1498,16 @@ public class SQLManager implements AbstractDB {
|
|||||||
+ "`comment` VARCHAR(40) NOT NULL,"
|
+ "`comment` VARCHAR(40) NOT NULL,"
|
||||||
+ "`inbox` VARCHAR(40) NOT NULL, `timestamp` INT(11) NOT NULL,"
|
+ "`inbox` VARCHAR(40) NOT NULL, `timestamp` INT(11) NOT NULL,"
|
||||||
+ "`sender` VARCHAR(40) NOT NULL"
|
+ "`sender` VARCHAR(40) NOT NULL"
|
||||||
+ ")");
|
+ ')');
|
||||||
}
|
}
|
||||||
statement.executeBatch();
|
statement.executeBatch();
|
||||||
statement.close();
|
} catch (SQLException ignored) {
|
||||||
} catch (SQLException e) {
|
try (Statement statement = this.connection.createStatement()) {
|
||||||
Statement statement = this.connection.createStatement();
|
|
||||||
statement.addBatch("ALTER IGNORE TABLE `" + this.prefix + "plot_comments` ADD `inbox` VARCHAR(11) DEFAULT `public`");
|
statement.addBatch("ALTER IGNORE TABLE `" + this.prefix + "plot_comments` ADD `inbox` VARCHAR(11) DEFAULT `public`");
|
||||||
statement.addBatch("ALTER IGNORE TABLE `" + this.prefix + "plot_comments` ADD `timestamp` INT(11) DEFAULT 0");
|
statement.addBatch("ALTER IGNORE TABLE `" + this.prefix + "plot_comments` ADD `timestamp` INT(11) DEFAULT 0");
|
||||||
statement.addBatch("ALTER TABLE `" + this.prefix + "plot` DROP `tier`");
|
statement.addBatch("ALTER TABLE `" + this.prefix + "plot` DROP `tier`");
|
||||||
statement.executeBatch();
|
statement.executeBatch();
|
||||||
statement.close();
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1534,7 +1517,6 @@ public class SQLManager implements AbstractDB {
|
|||||||
try (Statement statement = this.connection.createStatement()) {
|
try (Statement statement = this.connection.createStatement()) {
|
||||||
statement.executeUpdate(
|
statement.executeUpdate(
|
||||||
"DELETE FROM `" + this.prefix + "plot_denied` WHERE `plot_plot_id` NOT IN (SELECT `id` FROM `" + this.prefix + "plot`)");
|
"DELETE FROM `" + this.prefix + "plot_denied` WHERE `plot_plot_id` NOT IN (SELECT `id` FROM `" + this.prefix + "plot`)");
|
||||||
statement.close();
|
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
@ -1555,7 +1537,6 @@ public class SQLManager implements AbstractDB {
|
|||||||
PS.debug("RESTORING: " + this.prefix + table);
|
PS.debug("RESTORING: " + this.prefix + table);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
statement.close();
|
|
||||||
} catch (SQLException e2) {
|
} catch (SQLException e2) {
|
||||||
e2.printStackTrace();
|
e2.printStackTrace();
|
||||||
}
|
}
|
||||||
@ -1620,7 +1601,7 @@ public class SQLManager implements AbstractDB {
|
|||||||
for (String areaKey : areaSection.getKeys(false)) {
|
for (String areaKey : areaSection.getKeys(false)) {
|
||||||
String[] split = areaKey.split("(?<![;])-");
|
String[] split = areaKey.split("(?<![;])-");
|
||||||
if (split.length == 3) {
|
if (split.length == 3) {
|
||||||
areas.add(worldKey + ";" + split[0]);
|
areas.add(worldKey + ';' + split[0]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1633,7 +1614,7 @@ public class SQLManager implements AbstractDB {
|
|||||||
/*
|
/*
|
||||||
* Getting plots
|
* Getting plots
|
||||||
*/
|
*/
|
||||||
Statement statement = this.connection.createStatement();
|
try (Statement statement = this.connection.createStatement()) {
|
||||||
int id;
|
int id;
|
||||||
String o;
|
String o;
|
||||||
UUID user;
|
UUID user;
|
||||||
@ -1813,8 +1794,7 @@ public class SQLManager implements AbstractDB {
|
|||||||
default:
|
default:
|
||||||
try {
|
try {
|
||||||
plot.getSettings().setPosition(BlockLoc.fromString(pos));
|
plot.getSettings().setPosition(BlockLoc.fromString(pos));
|
||||||
} catch (Exception ignored) {
|
} catch (Exception ignored) {}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
Integer m = resultSet.getInt("merged");
|
Integer m = resultSet.getInt("merged");
|
||||||
boolean[] merged = new boolean[4];
|
boolean[] merged = new boolean[4];
|
||||||
@ -1824,14 +1804,10 @@ public class SQLManager implements AbstractDB {
|
|||||||
plot.getSettings().setMerged(merged);
|
plot.getSettings().setMerged(merged);
|
||||||
String[] flags_string;
|
String[] flags_string;
|
||||||
String myflags = resultSet.getString("flags");
|
String myflags = resultSet.getString("flags");
|
||||||
if (myflags == null) {
|
if (myflags == null || myflags.isEmpty()) {
|
||||||
flags_string = new String[]{};
|
flags_string = new String[]{};
|
||||||
} else {
|
} else {
|
||||||
if (!myflags.isEmpty()) {
|
|
||||||
flags_string = myflags.split(",");
|
flags_string = myflags.split(",");
|
||||||
} else {
|
|
||||||
flags_string = new String[]{};
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
HashMap<Flag<?>, Object> flags = new HashMap<>();
|
HashMap<Flag<?>, Object> flags = new HashMap<>();
|
||||||
boolean exception = false;
|
boolean exception = false;
|
||||||
@ -1839,9 +1815,13 @@ public class SQLManager implements AbstractDB {
|
|||||||
if (element.contains(":")) {
|
if (element.contains(":")) {
|
||||||
String[] split = element.split(":");
|
String[] split = element.split(":");
|
||||||
try {
|
try {
|
||||||
String flag_str = split[1].replaceAll("\u00AF", ":").replaceAll("\u00B4", ",");
|
String flag_str = split[1].replaceAll("¯", ":").replaceAll("\u00B4", ",");
|
||||||
Flag<?> flag = FlagManager.getFlag(split[0]);
|
Flag<?> flag = FlagManager.getFlag(split[0],false);
|
||||||
|
if (flag == null) {
|
||||||
|
PS.debug(String.format("No flag found for string value of: %s", split[0]));
|
||||||
|
} else {
|
||||||
flags.put(flag, flag.parseValue(flag_str));
|
flags.put(flag, flag.parseValue(flag_str));
|
||||||
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
exception = true;
|
exception = true;
|
||||||
@ -1849,8 +1829,12 @@ public class SQLManager implements AbstractDB {
|
|||||||
} else {
|
} else {
|
||||||
element = element.replaceAll("\u00AF", ":").replaceAll("\u00B4", ",");
|
element = element.replaceAll("\u00AF", ":").replaceAll("\u00B4", ",");
|
||||||
if (StringMan.isAlpha(element.replaceAll("_", "").replaceAll("-", ""))) {
|
if (StringMan.isAlpha(element.replaceAll("_", "").replaceAll("-", ""))) {
|
||||||
Flag flag = FlagManager.getFlag(element);
|
Flag flag = FlagManager.getFlag(element,false);
|
||||||
|
if (flag == null) {
|
||||||
|
PS.debug(String.format("No flag found for string value of: %s", element));
|
||||||
|
} else {
|
||||||
flags.put(flag, flag.parseValue(""));
|
flags.put(flag, flag.parseValue(""));
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
PS.debug("INVALID FLAG: " + element);
|
PS.debug("INVALID FLAG: " + element);
|
||||||
}
|
}
|
||||||
@ -1865,13 +1849,14 @@ public class SQLManager implements AbstractDB {
|
|||||||
} else if (Settings.AUTO_PURGE) {
|
} else if (Settings.AUTO_PURGE) {
|
||||||
toDelete.add(id);
|
toDelete.add(id);
|
||||||
} else {
|
} else {
|
||||||
PS.debug("&cENTRY " + id + " in `plot_settings` does not exist. Create this plot or set `auto-purge: true` in the settings"
|
PS.debug(
|
||||||
|
"&cENTRY " + id + " in `plot_settings` does not exist. Create this plot or set `auto-purge: true` in the settings"
|
||||||
+ ".yml.");
|
+ ".yml.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
statement.close();
|
|
||||||
deleteRows(toDelete, this.prefix + "plot_settings", "plot_plot_id");
|
deleteRows(toDelete, this.prefix + "plot_settings", "plot_plot_id");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (!plots.entrySet().isEmpty()) {
|
if (!plots.entrySet().isEmpty()) {
|
||||||
createEmptySettings(new ArrayList<>(plots.keySet()), null);
|
createEmptySettings(new ArrayList<>(plots.keySet()), null);
|
||||||
for (Entry<Integer, Plot> entry : plots.entrySet()) {
|
for (Entry<Integer, Plot> entry : plots.entrySet()) {
|
||||||
@ -1971,7 +1956,7 @@ public class SQLManager implements AbstractDB {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setFlags(final Plot plot, HashMap<Flag<?>, Object> flags) {
|
public void setFlags(final Plot plot, HashMap<Flag<?>, Object> flags) {
|
||||||
final String flag_string = FlagManager.toString(flags); //todo MattBDev: Fix this for flags to work.
|
final String flag_string = FlagManager.toString(flags);
|
||||||
addPlotTask(plot, new UniqueStatement("setFlags") {
|
addPlotTask(plot, new UniqueStatement("setFlags") {
|
||||||
@Override
|
@Override
|
||||||
public void set(PreparedStatement stmt) throws SQLException {
|
public void set(PreparedStatement stmt) throws SQLException {
|
||||||
@ -2027,23 +2012,23 @@ public class SQLManager implements AbstractDB {
|
|||||||
stmt_prefix = " OR `plot_plot_id` = ";
|
stmt_prefix = " OR `plot_plot_id` = ";
|
||||||
}
|
}
|
||||||
PreparedStatement stmt = SQLManager.this.connection
|
PreparedStatement stmt = SQLManager.this.connection
|
||||||
.prepareStatement("DELETE FROM `" + SQLManager.this.prefix + "plot_helpers` WHERE `plot_plot_id` = " + idstr + "");
|
.prepareStatement("DELETE FROM `" + SQLManager.this.prefix + "plot_helpers` WHERE `plot_plot_id` = " + idstr);
|
||||||
stmt.executeUpdate();
|
stmt.executeUpdate();
|
||||||
stmt.close();
|
stmt.close();
|
||||||
stmt = SQLManager.this.connection
|
stmt = SQLManager.this.connection
|
||||||
.prepareStatement("DELETE FROM `" + SQLManager.this.prefix + "plot_denied` WHERE `plot_plot_id` = " + idstr + "");
|
.prepareStatement("DELETE FROM `" + SQLManager.this.prefix + "plot_denied` WHERE `plot_plot_id` = " + idstr);
|
||||||
stmt.executeUpdate();
|
stmt.executeUpdate();
|
||||||
stmt.close();
|
stmt.close();
|
||||||
stmt = SQLManager.this.connection
|
stmt = SQLManager.this.connection
|
||||||
.prepareStatement("DELETE FROM `" + SQLManager.this.prefix + "plot_settings` WHERE `plot_plot_id` = " + idstr + "");
|
.prepareStatement("DELETE FROM `" + SQLManager.this.prefix + "plot_settings` WHERE `plot_plot_id` = " + idstr);
|
||||||
stmt.executeUpdate();
|
stmt.executeUpdate();
|
||||||
stmt.close();
|
stmt.close();
|
||||||
stmt = SQLManager.this.connection
|
stmt = SQLManager.this.connection
|
||||||
.prepareStatement("DELETE FROM `" + SQLManager.this.prefix + "plot_trusted` WHERE `plot_plot_id` = " + idstr + "");
|
.prepareStatement("DELETE FROM `" + SQLManager.this.prefix + "plot_trusted` WHERE `plot_plot_id` = " + idstr);
|
||||||
stmt.executeUpdate();
|
stmt.executeUpdate();
|
||||||
stmt.close();
|
stmt.close();
|
||||||
stmt = SQLManager.this.connection
|
stmt = SQLManager.this.connection
|
||||||
.prepareStatement("DELETE FROM `" + SQLManager.this.prefix + "plot` WHERE `id` = " + idstr2 + "");
|
.prepareStatement("DELETE FROM `" + SQLManager.this.prefix + "plot` WHERE `id` = " + idstr2);
|
||||||
stmt.executeUpdate();
|
stmt.executeUpdate();
|
||||||
stmt.close();
|
stmt.close();
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
@ -2186,8 +2171,7 @@ public class SQLManager implements AbstractDB {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(PreparedStatement statement) {
|
public void execute(PreparedStatement statement) {}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addBatch(PreparedStatement statement) throws SQLException {
|
public void addBatch(PreparedStatement statement) throws SQLException {
|
||||||
@ -2344,10 +2328,10 @@ public class SQLManager implements AbstractDB {
|
|||||||
try (PreparedStatement statement = this.connection
|
try (PreparedStatement statement = this.connection
|
||||||
.prepareStatement("SELECT `rating`, `player` FROM `" + this.prefix + "plot_rating` WHERE `plot_plot_id` = ? ")) {
|
.prepareStatement("SELECT `rating`, `player` FROM `" + this.prefix + "plot_rating` WHERE `plot_plot_id` = ? ")) {
|
||||||
statement.setInt(1, getId(plot));
|
statement.setInt(1, getId(plot));
|
||||||
try (ResultSet set = statement.executeQuery()) {
|
try (ResultSet resultSet = statement.executeQuery()) {
|
||||||
while (set.next()) {
|
while (resultSet.next()) {
|
||||||
UUID uuid = UUID.fromString(set.getString("player"));
|
UUID uuid = UUID.fromString(resultSet.getString("player"));
|
||||||
int rating = set.getInt("rating");
|
int rating = resultSet.getInt("rating");
|
||||||
map.put(uuid, rating);
|
map.put(uuid, rating);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2488,8 +2472,7 @@ public class SQLManager implements AbstractDB {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(PreparedStatement statement) {
|
public void execute(PreparedStatement statement) {}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addBatch(PreparedStatement statement) throws SQLException {
|
public void addBatch(PreparedStatement statement) throws SQLException {
|
||||||
@ -2526,7 +2509,7 @@ public class SQLManager implements AbstractDB {
|
|||||||
for (String areaKey : areaSection.getKeys(false)) {
|
for (String areaKey : areaSection.getKeys(false)) {
|
||||||
String[] split = areaKey.split("(?<![;])-");
|
String[] split = areaKey.split("(?<![;])-");
|
||||||
if (split.length == 3) {
|
if (split.length == 3) {
|
||||||
areas.add(worldKey + ";" + split[0]);
|
areas.add(worldKey + ';' + split[0]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2538,17 +2521,17 @@ public class SQLManager implements AbstractDB {
|
|||||||
/*
|
/*
|
||||||
* Getting clusters
|
* Getting clusters
|
||||||
*/
|
*/
|
||||||
Statement stmt = this.connection.createStatement();
|
try (Statement stmt = this.connection.createStatement()) {
|
||||||
ResultSet r = stmt.executeQuery("SELECT * FROM `" + this.prefix + "cluster`");
|
ResultSet resultSet = stmt.executeQuery("SELECT * FROM `" + this.prefix + "cluster`");
|
||||||
PlotCluster cluster;
|
PlotCluster cluster;
|
||||||
String owner;
|
String owner;
|
||||||
UUID user;
|
UUID user;
|
||||||
int id;
|
int id;
|
||||||
while (r.next()) {
|
while (resultSet.next()) {
|
||||||
PlotId pos1 = new PlotId(r.getInt("pos1_x"), r.getInt("pos1_z"));
|
PlotId pos1 = new PlotId(resultSet.getInt("pos1_x"), resultSet.getInt("pos1_z"));
|
||||||
PlotId pos2 = new PlotId(r.getInt("pos2_x"), r.getInt("pos2_z"));
|
PlotId pos2 = new PlotId(resultSet.getInt("pos2_x"), resultSet.getInt("pos2_z"));
|
||||||
id = r.getInt("id");
|
id = resultSet.getInt("id");
|
||||||
String areaid = r.getString("world");
|
String areaid = resultSet.getString("world");
|
||||||
if (!areas.contains(areaid)) {
|
if (!areas.contains(areaid)) {
|
||||||
if (noExist.containsKey(areaid)) {
|
if (noExist.containsKey(areaid)) {
|
||||||
noExist.put(areaid, noExist.get(areaid) + 1);
|
noExist.put(areaid, noExist.get(areaid) + 1);
|
||||||
@ -2556,7 +2539,7 @@ public class SQLManager implements AbstractDB {
|
|||||||
noExist.put(areaid, 1);
|
noExist.put(areaid, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
owner = r.getString("owner");
|
owner = resultSet.getString("owner");
|
||||||
user = uuids.get(owner);
|
user = uuids.get(owner);
|
||||||
if (user == null) {
|
if (user == null) {
|
||||||
user = UUID.fromString(owner);
|
user = UUID.fromString(owner);
|
||||||
@ -2574,10 +2557,10 @@ public class SQLManager implements AbstractDB {
|
|||||||
/*
|
/*
|
||||||
* Getting helpers
|
* Getting helpers
|
||||||
*/
|
*/
|
||||||
r = stmt.executeQuery("SELECT `user_uuid`, `cluster_id` FROM `" + this.prefix + "cluster_helpers`");
|
resultSet = stmt.executeQuery("SELECT `user_uuid`, `cluster_id` FROM `" + this.prefix + "cluster_helpers`");
|
||||||
while (r.next()) {
|
while (resultSet.next()) {
|
||||||
id = r.getInt("cluster_id");
|
id = resultSet.getInt("cluster_id");
|
||||||
owner = r.getString("user_uuid");
|
owner = resultSet.getString("user_uuid");
|
||||||
user = uuids.get(owner);
|
user = uuids.get(owner);
|
||||||
if (user == null) {
|
if (user == null) {
|
||||||
user = UUID.fromString(owner);
|
user = UUID.fromString(owner);
|
||||||
@ -2593,10 +2576,10 @@ public class SQLManager implements AbstractDB {
|
|||||||
/*
|
/*
|
||||||
* Getting invited
|
* Getting invited
|
||||||
*/
|
*/
|
||||||
r = stmt.executeQuery("SELECT `user_uuid`, `cluster_id` FROM `" + this.prefix + "cluster_invited`");
|
resultSet = stmt.executeQuery("SELECT `user_uuid`, `cluster_id` FROM `" + this.prefix + "cluster_invited`");
|
||||||
while (r.next()) {
|
while (resultSet.next()) {
|
||||||
id = r.getInt("cluster_id");
|
id = resultSet.getInt("cluster_id");
|
||||||
owner = r.getString("user_uuid");
|
owner = resultSet.getString("user_uuid");
|
||||||
user = uuids.get(owner);
|
user = uuids.get(owner);
|
||||||
if (user == null) {
|
if (user == null) {
|
||||||
user = UUID.fromString(owner);
|
user = UUID.fromString(owner);
|
||||||
@ -2609,16 +2592,16 @@ public class SQLManager implements AbstractDB {
|
|||||||
PS.debug("&cCluster " + id + " in cluster_invited does not exist. Please create the cluster or remove this entry.");
|
PS.debug("&cCluster " + id + " in cluster_invited does not exist. Please create the cluster or remove this entry.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
r = stmt.executeQuery("SELECT * FROM `" + this.prefix + "cluster_settings`");
|
resultSet = stmt.executeQuery("SELECT * FROM `" + this.prefix + "cluster_settings`");
|
||||||
while (r.next()) {
|
while (resultSet.next()) {
|
||||||
id = r.getInt("cluster_id");
|
id = resultSet.getInt("cluster_id");
|
||||||
cluster = clusters.get(id);
|
cluster = clusters.get(id);
|
||||||
if (cluster != null) {
|
if (cluster != null) {
|
||||||
String alias = r.getString("alias");
|
String alias = resultSet.getString("alias");
|
||||||
if (alias != null) {
|
if (alias != null) {
|
||||||
cluster.settings.setAlias(alias);
|
cluster.settings.setAlias(alias);
|
||||||
}
|
}
|
||||||
String pos = r.getString("position");
|
String pos = resultSet.getString("position");
|
||||||
switch (pos.toLowerCase()) {
|
switch (pos.toLowerCase()) {
|
||||||
case "":
|
case "":
|
||||||
case "default":
|
case "default":
|
||||||
@ -2629,55 +2612,48 @@ public class SQLManager implements AbstractDB {
|
|||||||
try {
|
try {
|
||||||
BlockLoc loc = BlockLoc.fromString(pos);
|
BlockLoc loc = BlockLoc.fromString(pos);
|
||||||
cluster.settings.setPosition(loc);
|
cluster.settings.setPosition(loc);
|
||||||
} catch (Exception ignored) {
|
} catch (Exception ignored) {}
|
||||||
}
|
}
|
||||||
}
|
Integer m = resultSet.getInt("merged");
|
||||||
Integer m = r.getInt("merged");
|
|
||||||
boolean[] merged = new boolean[4];
|
boolean[] merged = new boolean[4];
|
||||||
for (int i = 0; i < 4; i++) {
|
for (int i = 0; i < 4; i++) {
|
||||||
merged[3 - i] = (m & 1 << i) != 0;
|
merged[3 - i] = (m & 1 << i) != 0;
|
||||||
}
|
}
|
||||||
cluster.settings.setMerged(merged);
|
cluster.settings.setMerged(merged);
|
||||||
String[] flags_string;
|
String[] flags_string;
|
||||||
String myflags = r.getString("flags");
|
String myflags = resultSet.getString("flags");
|
||||||
if (myflags == null) {
|
if (myflags == null || myflags.isEmpty()) {
|
||||||
flags_string = new String[]{};
|
flags_string = new String[]{};
|
||||||
} else {
|
} else {
|
||||||
if (!myflags.isEmpty()) {
|
|
||||||
flags_string = myflags.split(",");
|
flags_string = myflags.split(",");
|
||||||
} else {
|
|
||||||
flags_string = new String[]{};
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
HashMap<Flag<?>, Object> flags = new HashMap<>();
|
HashMap<Flag<?>, Object> flags = new HashMap<>();
|
||||||
boolean exception = false;
|
|
||||||
for (String element : flags_string) {
|
for (String element : flags_string) {
|
||||||
if (element.contains(":")) {
|
if (element.contains(":")) {
|
||||||
String[] split = element.split(":");
|
String[] split = element.split(":");
|
||||||
try {
|
|
||||||
String flag_str = split[1].replaceAll("\u00AF", ":").replaceAll("<EFBFBD>", ",");
|
String flag_str = split[1].replaceAll("\u00AF", ":").replaceAll("<EFBFBD>", ",");
|
||||||
Flag flag = FlagManager.getFlag(split[0]);
|
Flag flag = FlagManager.getFlag(split[0],false);
|
||||||
flags.put(flag, flag_str);
|
if (flag == null) {
|
||||||
} catch (Exception e) {
|
PS.debug(String.format("No flag found for string value of: %s", split[0]));
|
||||||
e.printStackTrace();
|
} else {
|
||||||
exception = true;
|
flags.put(flag, flag.parseValue(flag_str));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Flag flag = FlagManager.getFlag(element);
|
Flag flag = FlagManager.getFlag(element,false);
|
||||||
flags.put(flag, "");
|
if (flag == null) {
|
||||||
|
PS.debug(String.format("No flag found for string value of: %s", element));
|
||||||
|
} else {
|
||||||
|
flags.put(flag, flag.parseValue(""));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (exception) {
|
|
||||||
PS.debug("&cCluster " + id + " had an invalid flag. A fix has been attempted.");
|
|
||||||
PS.debug("&c" + myflags);
|
|
||||||
}
|
}
|
||||||
cluster.settings.flags = flags;
|
cluster.settings.flags = flags;
|
||||||
} else {
|
} else {
|
||||||
PS.debug("&cCluster " + id + " in cluster_settings does not exist. Please create the cluster or remove this entry.");
|
PS.debug("&cCluster " + id + " in cluster_settings does not exist. Please create the cluster or remove this entry.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
stmt.close();
|
resultSet.close();
|
||||||
r.close();
|
}
|
||||||
boolean invalidPlot = false;
|
boolean invalidPlot = false;
|
||||||
for (Entry<String, Integer> entry : noExist.entrySet()) {
|
for (Entry<String, Integer> entry : noExist.entrySet()) {
|
||||||
String a = entry.getKey();
|
String a = entry.getKey();
|
||||||
@ -2700,10 +2676,10 @@ public class SQLManager implements AbstractDB {
|
|||||||
int i = 0;
|
int i = 0;
|
||||||
for (Entry<Flag<?>, Object> flag : flags.entrySet()) {
|
for (Entry<Flag<?>, Object> flag : flags.entrySet()) {
|
||||||
if (i != 0) {
|
if (i != 0) {
|
||||||
flag_string.append(",");
|
flag_string.append(',');
|
||||||
}
|
}
|
||||||
flag_string.append(flag.getKey().getName() + ":" + flag.getKey().valueToString(flag.getValue()).replaceAll(":", "¯").replaceAll(",",
|
flag_string.append(flag.getKey().getName()).append(':')
|
||||||
"´"));
|
.append(flag.getKey().valueToString(flag.getValue()).replaceAll(":", "¯").replaceAll(",", "´"));
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
addClusterTask(cluster, new UniqueStatement("setFlags") {
|
addClusterTask(cluster, new UniqueStatement("setFlags") {
|
||||||
@ -2792,18 +2768,17 @@ public class SQLManager implements AbstractDB {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(PreparedStatement statement) {
|
public void execute(PreparedStatement statement) {}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addBatch(PreparedStatement statement) throws SQLException {
|
public void addBatch(PreparedStatement statement) throws SQLException {
|
||||||
statement.executeUpdate();
|
statement.executeUpdate();
|
||||||
ResultSet keys = statement.getGeneratedKeys();
|
try (ResultSet keys = statement.getGeneratedKeys()) {
|
||||||
if (keys.next()) {
|
if (keys.next()) {
|
||||||
cluster.temp = keys.getInt(1);
|
cluster.temp = keys.getInt(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
addClusterTask(cluster, new UniqueStatement("createCluster_settings_" + cluster.hashCode()) {
|
addClusterTask(cluster, new UniqueStatement("createCluster_settings_" + cluster.hashCode()) {
|
||||||
@Override
|
@Override
|
||||||
@ -3038,12 +3013,10 @@ public class SQLManager implements AbstractDB {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (Entry<String, HashMap<PlotId, Plot>> entry : database.entrySet()) {
|
for (Entry<String, HashMap<PlotId, Plot>> entry : database.entrySet()) {
|
||||||
String worldname = entry.getKey();
|
|
||||||
HashMap<PlotId, Plot> map = entry.getValue();
|
HashMap<PlotId, Plot> map = entry.getValue();
|
||||||
if (!map.isEmpty()) {
|
if (!map.isEmpty()) {
|
||||||
for (Entry<PlotId, Plot> entry2 : map.entrySet()) {
|
for (Entry<PlotId, Plot> entry2 : map.entrySet()) {
|
||||||
Plot plot = entry2.getValue();
|
PS.debug("$1Plot was deleted: " + entry2.getValue().toString() + "// TODO implement this when sure safe");
|
||||||
PS.debug("$1Plot was deleted: " + entry2.getValue() + "// TODO implement this when sure safe");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3112,30 +3085,30 @@ public class SQLManager implements AbstractDB {
|
|||||||
try (Statement stmt = SQLManager.this.connection.createStatement()) {
|
try (Statement stmt = SQLManager.this.connection.createStatement()) {
|
||||||
stmt.executeUpdate(
|
stmt.executeUpdate(
|
||||||
"UPDATE `" + SQLManager.this.prefix + "cluster` SET `owner` = '" + now.toString() + "' WHERE `owner` = '" + old.toString()
|
"UPDATE `" + SQLManager.this.prefix + "cluster` SET `owner` = '" + now.toString() + "' WHERE `owner` = '" + old.toString()
|
||||||
+ "'");
|
+ '\'');
|
||||||
stmt.executeUpdate(
|
stmt.executeUpdate(
|
||||||
"UPDATE `" + SQLManager.this.prefix + "cluster_helpers` SET `user_uuid` = '" + now.toString() + "' WHERE `user_uuid` = '"
|
"UPDATE `" + SQLManager.this.prefix + "cluster_helpers` SET `user_uuid` = '" + now.toString() + "' WHERE `user_uuid` = '"
|
||||||
+ old.toString()
|
+ old.toString()
|
||||||
+ "'");
|
+ '\'');
|
||||||
stmt.executeUpdate(
|
stmt.executeUpdate(
|
||||||
"UPDATE `" + SQLManager.this.prefix + "cluster_invited` SET `user_uuid` = '" + now.toString() + "' WHERE `user_uuid` = '"
|
"UPDATE `" + SQLManager.this.prefix + "cluster_invited` SET `user_uuid` = '" + now.toString() + "' WHERE `user_uuid` = '"
|
||||||
+ old.toString()
|
+ old.toString()
|
||||||
+ "'");
|
+ '\'');
|
||||||
stmt.executeUpdate(
|
stmt.executeUpdate(
|
||||||
"UPDATE `" + SQLManager.this.prefix + "plot` SET `owner` = '" + now.toString() + "' WHERE `owner` = '" + old.toString()
|
"UPDATE `" + SQLManager.this.prefix + "plot` SET `owner` = '" + now.toString() + "' WHERE `owner` = '" + old.toString()
|
||||||
+ "'");
|
+ '\'');
|
||||||
stmt.executeUpdate(
|
stmt.executeUpdate(
|
||||||
"UPDATE `" + SQLManager.this.prefix + "plot_denied` SET `user_uuid` = '" + now.toString() + "' WHERE `user_uuid` = '"
|
"UPDATE `" + SQLManager.this.prefix + "plot_denied` SET `user_uuid` = '" + now.toString() + "' WHERE `user_uuid` = '"
|
||||||
+ old.toString()
|
+ old.toString()
|
||||||
+ "'");
|
+ '\'');
|
||||||
stmt.executeUpdate(
|
stmt.executeUpdate(
|
||||||
"UPDATE `" + SQLManager.this.prefix + "plot_helpers` SET `user_uuid` = '" + now.toString() + "' WHERE `user_uuid` = '"
|
"UPDATE `" + SQLManager.this.prefix + "plot_helpers` SET `user_uuid` = '" + now.toString() + "' WHERE `user_uuid` = '"
|
||||||
+ old.toString()
|
+ old.toString()
|
||||||
+ "'");
|
+ '\'');
|
||||||
stmt.executeUpdate(
|
stmt.executeUpdate(
|
||||||
"UPDATE `" + SQLManager.this.prefix + "plot_trusted` SET `user_uuid` = '" + now.toString() + "' WHERE `user_uuid` = '"
|
"UPDATE `" + SQLManager.this.prefix + "plot_trusted` SET `user_uuid` = '" + now.toString() + "' WHERE `user_uuid` = '"
|
||||||
+ old.toString()
|
+ old.toString()
|
||||||
+ "'");
|
+ '\'');
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
@ -39,7 +39,7 @@ public class SQLite extends Database {
|
|||||||
if (!file.exists()) {
|
if (!file.exists()) {
|
||||||
try {
|
try {
|
||||||
file.createNewFile();
|
file.createNewFile();
|
||||||
} catch (IOException e) {
|
} catch (IOException ignored) {
|
||||||
PS.debug("&cUnable to create database!");
|
PS.debug("&cUnable to create database!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,9 +12,9 @@ public abstract class StmtMod<T> {
|
|||||||
public String getCreateMySQL(int size, String query, int params) {
|
public String getCreateMySQL(int size, String query, int params) {
|
||||||
StringBuilder statement = new StringBuilder(query);
|
StringBuilder statement = new StringBuilder(query);
|
||||||
for (int i = 0; i < size - 1; i++) {
|
for (int i = 0; i < size - 1; i++) {
|
||||||
statement.append("(").append(StringMan.repeat(",?", params).substring(1)).append("),");
|
statement.append('(').append(StringMan.repeat(",?", params).substring(1)).append("),");
|
||||||
}
|
}
|
||||||
statement.append("(").append(StringMan.repeat(",?", params).substring(1)).append(")");
|
statement.append('(').append(StringMan.repeat(",?", params).substring(1)).append(')');
|
||||||
return statement.toString();
|
return statement.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -22,7 +22,7 @@ public abstract class StmtMod<T> {
|
|||||||
StringBuilder statement = new StringBuilder(query);
|
StringBuilder statement = new StringBuilder(query);
|
||||||
String modParams = StringMan.repeat(",?", params).substring(1);
|
String modParams = StringMan.repeat(",?", params).substring(1);
|
||||||
for (int i = 0; i < size - 1; i++) {
|
for (int i = 0; i < size - 1; i++) {
|
||||||
statement.append("UNION SELECT ").append(modParams).append(" ");
|
statement.append("UNION SELECT ").append(modParams).append(' ');
|
||||||
}
|
}
|
||||||
return statement.toString();
|
return statement.toString();
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,7 @@ import com.intellectualcrafters.plot.object.Plot;
|
|||||||
|
|
||||||
public class Flag<V> {
|
public class Flag<V> {
|
||||||
|
|
||||||
private String name;
|
private final String name;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Flag object used to store basic information for a Plot. Flags are a
|
* Flag object used to store basic information for a Plot. Flags are a
|
||||||
|
@ -94,9 +94,8 @@ public class FlagManager {
|
|||||||
public static String toString(HashMap<Flag<?>, Object> flags) {
|
public static String toString(HashMap<Flag<?>, Object> flags) {
|
||||||
StringBuilder flag_string = new StringBuilder();
|
StringBuilder flag_string = new StringBuilder();
|
||||||
int i = 0;
|
int i = 0;
|
||||||
Flag<?> flag;
|
|
||||||
for (Map.Entry<Flag<?>, Object> entry : flags.entrySet()) {
|
for (Map.Entry<Flag<?>, Object> entry : flags.entrySet()) {
|
||||||
flag = entry.getKey();
|
Flag<?> flag = entry.getKey();
|
||||||
if (i != 0) {
|
if (i != 0) {
|
||||||
flag_string.append(",");
|
flag_string.append(",");
|
||||||
}
|
}
|
||||||
@ -163,7 +162,7 @@ public class FlagManager {
|
|||||||
* @param plot
|
* @param plot
|
||||||
* @return set of flags
|
* @return set of flags
|
||||||
*/
|
*/
|
||||||
public static HashMap<Flag<?>, Object> getPlotFlags(Plot plot) {
|
public static Map<Flag<?>, Object> getPlotFlags(Plot plot) {
|
||||||
if (!plot.hasOwner()) {
|
if (!plot.hasOwner()) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -189,7 +188,7 @@ public class FlagManager {
|
|||||||
return flags;
|
return flags;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static HashMap<Flag<?>, Object> getSettingFlags(PlotArea area, PlotSettings settings) {
|
public static Map<Flag<?>, Object> getSettingFlags(PlotArea area, PlotSettings settings) {
|
||||||
return getPlotFlags(area, settings, false);
|
return getPlotFlags(area, settings, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -258,7 +257,7 @@ public class FlagManager {
|
|||||||
*
|
*
|
||||||
* @param player with permissions
|
* @param player with permissions
|
||||||
*
|
*
|
||||||
* @return List (AbstractFlag)
|
* @return List (Flag)
|
||||||
*/
|
*/
|
||||||
public static List<Flag> getFlags(PlotPlayer player) {
|
public static List<Flag> getFlags(PlotPlayer player) {
|
||||||
List<Flag> returnFlags = new ArrayList<>();
|
List<Flag> returnFlags = new ArrayList<>();
|
||||||
@ -271,11 +270,11 @@ public class FlagManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get an AbstractFlag by a string Returns null if flag does not exist
|
* Get an Flag by a String
|
||||||
*
|
*
|
||||||
* @param string Flag Key
|
* @param string the flag name
|
||||||
*
|
*
|
||||||
* @return AbstractFlag
|
* @return the flag or null if the flag the provided name does not exist
|
||||||
*/
|
*/
|
||||||
public static Flag<?> getFlag(String string) {
|
public static Flag<?> getFlag(String string) {
|
||||||
for (Flag flag : Flags.getFlags()) {
|
for (Flag flag : Flags.getFlags()) {
|
||||||
@ -289,7 +288,22 @@ public class FlagManager {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static HashMap<Flag<?>, Object> parseFlags(List<String> flagstrings) {
|
public static Flag<?> getFlag(String string, boolean ignoreReserved) {
|
||||||
|
for (Flag flag : Flags.getFlags()) {
|
||||||
|
if (flag.getName().equalsIgnoreCase(string)) {
|
||||||
|
if (!ignoreReserved) {
|
||||||
|
if (isReserved(flag)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return flag;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static Map<Flag<?>, Object> parseFlags(List<String> flagstrings) {
|
||||||
HashMap<Flag<?>, Object> map = new HashMap<>();
|
HashMap<Flag<?>, Object> map = new HashMap<>();
|
||||||
|
|
||||||
for (String key : flagstrings) {
|
for (String key : flagstrings) {
|
||||||
|
@ -127,9 +127,8 @@ public class AugmentedUtils {
|
|||||||
}
|
}
|
||||||
if (!has) {
|
if (!has) {
|
||||||
continue;
|
continue;
|
||||||
} else {
|
|
||||||
toReturn = true;
|
|
||||||
}
|
}
|
||||||
|
toReturn = true;
|
||||||
secondaryMask = new PlotChunk<Object>(wrap) {
|
secondaryMask = new PlotChunk<Object>(wrap) {
|
||||||
@Override
|
@Override
|
||||||
public Object getChunkAbs() {
|
public Object getChunkAbs() {
|
||||||
@ -144,8 +143,7 @@ public class AugmentedUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setBiome(int x, int z, int biome) {
|
public void setBiome(int x, int z, int biome) {}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PlotChunk clone() {
|
public PlotChunk clone() {
|
||||||
|
@ -158,7 +158,7 @@ public class HybridPlotWorld extends ClassicPlotWorld {
|
|||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
setupSchematics();
|
setupSchematics();
|
||||||
} catch (Exception e) {
|
} catch (Exception ignored) {
|
||||||
PS.debug("&c - road schematics are disabled for this world.");
|
PS.debug("&c - road schematics are disabled for this world.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -55,8 +55,7 @@ public abstract class IndependentPlotGenerator {
|
|||||||
* - e.g. If setup doesn't support some standard options
|
* - e.g. If setup doesn't support some standard options
|
||||||
* @param setup
|
* @param setup
|
||||||
*/
|
*/
|
||||||
public void processSetup(SetupObject setup) {
|
public void processSetup(SetupObject setup) {}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* It is preferred for the PlotArea object to do most of the initialization necessary.
|
* It is preferred for the PlotArea object to do most of the initialization necessary.
|
||||||
|
@ -176,7 +176,7 @@ public abstract class SquarePlotManager extends GridPlotManager {
|
|||||||
return plot.getMerged(7) ? id : null;
|
return plot.getMerged(7) ? id : null;
|
||||||
}
|
}
|
||||||
PS.debug("invalid location: " + Arrays.toString(merged));
|
PS.debug("invalid location: " + Arrays.toString(merged));
|
||||||
} catch (Exception e) {
|
} catch (Exception ignored) {
|
||||||
PS.debug("Invalid plot / road width in settings.yml for world: " + plotworld.worldname);
|
PS.debug("Invalid plot / road width in settings.yml for world: " + plotworld.worldname);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
@ -74,7 +74,7 @@ public class BlockLoc {
|
|||||||
if (this.x == 0 && this.y == 0 && this.z == 0) {
|
if (this.x == 0 && this.y == 0 && this.z == 0) {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
return this.x + "," + this.y + "," + this.z + "," + this.yaw + "," + this.pitch;
|
return this.x + "," + this.y + ',' + this.z + ',' + this.yaw + ',' + this.pitch;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -87,12 +87,10 @@ public class ConsolePlayer extends PlotPlayer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setCompassTarget(Location location) {
|
public void setCompassTarget(Location location) {}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setAttribute(String key) {
|
public void setAttribute(String key) {}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean getAttribute(String key) {
|
public boolean getAttribute(String key) {
|
||||||
@ -100,8 +98,7 @@ public class ConsolePlayer extends PlotPlayer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void removeAttribute(String key) {
|
public void removeAttribute(String key) {}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setMeta(String key, Object value) {
|
public void setMeta(String key, Object value) {
|
||||||
@ -124,8 +121,7 @@ public class ConsolePlayer extends PlotPlayer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setWeather(PlotWeather weather) {
|
public void setWeather(PlotWeather weather) {}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PlotGameMode getGameMode() {
|
public PlotGameMode getGameMode() {
|
||||||
@ -133,24 +129,19 @@ public class ConsolePlayer extends PlotPlayer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setGameMode(PlotGameMode gameMode) {
|
public void setGameMode(PlotGameMode gameMode) {}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setTime(long time) {
|
public void setTime(long time) {}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setFlight(boolean fly) {
|
public void setFlight(boolean fly) {}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void playMusic(Location location, int id) {
|
public void playMusic(Location location, int id) {}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void kick(String message) {
|
public void kick(String message) {}
|
||||||
}
|
|
||||||
|
|
||||||
@Override public void stopSpectating() {}
|
@Override public void stopSpectating() {}
|
||||||
|
|
||||||
|
@ -2,6 +2,7 @@ package com.intellectualcrafters.plot.object;
|
|||||||
|
|
||||||
import com.google.common.base.Optional;
|
import com.google.common.base.Optional;
|
||||||
import com.google.common.collect.BiMap;
|
import com.google.common.collect.BiMap;
|
||||||
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.intellectualcrafters.jnbt.CompoundTag;
|
import com.intellectualcrafters.jnbt.CompoundTag;
|
||||||
import com.intellectualcrafters.plot.PS;
|
import com.intellectualcrafters.plot.PS;
|
||||||
import com.intellectualcrafters.plot.config.C;
|
import com.intellectualcrafters.plot.config.C;
|
||||||
@ -212,19 +213,19 @@ public class Plot {
|
|||||||
String[] split = string.split(";|,");
|
String[] split = string.split(";|,");
|
||||||
if (split.length == 2) {
|
if (split.length == 2) {
|
||||||
if (defaultArea != null) {
|
if (defaultArea != null) {
|
||||||
PlotId id = PlotId.fromString(split[0] + ";" + split[1]);
|
PlotId id = PlotId.fromString(split[0] + ';' + split[1]);
|
||||||
return id != null ? defaultArea.getPlotAbs(id) : null;
|
return id != null ? defaultArea.getPlotAbs(id) : null;
|
||||||
}
|
}
|
||||||
} else if (split.length == 3) {
|
} else if (split.length == 3) {
|
||||||
PlotArea pa = PS.get().getPlotArea(split[0], null);
|
PlotArea pa = PS.get().getPlotArea(split[0], null);
|
||||||
if (pa != null) {
|
if (pa != null) {
|
||||||
PlotId id = PlotId.fromString(split[1] + ";" + split[2]);
|
PlotId id = PlotId.fromString(split[1] + ';' + split[2]);
|
||||||
return pa.getPlotAbs(id);
|
return pa.getPlotAbs(id);
|
||||||
}
|
}
|
||||||
} else if (split.length == 4) {
|
} else if (split.length == 4) {
|
||||||
PlotArea pa = PS.get().getPlotArea(split[0], split[1]);
|
PlotArea pa = PS.get().getPlotArea(split[0], split[1]);
|
||||||
if (pa != null) {
|
if (pa != null) {
|
||||||
PlotId id = PlotId.fromString(split[1] + ";" + split[2]);
|
PlotId id = PlotId.fromString(split[1] + ';' + split[2]);
|
||||||
return pa.getPlotAbs(id);
|
return pa.getPlotAbs(id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -334,7 +335,7 @@ public class Plot {
|
|||||||
if (!isMerged()) {
|
if (!isMerged()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
HashSet<Plot> connected = getConnectedPlots();
|
Set<Plot> connected = getConnectedPlots();
|
||||||
for (Plot current : connected) {
|
for (Plot current : connected) {
|
||||||
if (uuid.equals(current.owner)) {
|
if (uuid.equals(current.owner)) {
|
||||||
return true;
|
return true;
|
||||||
@ -348,17 +349,17 @@ public class Plot {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a list of owner UUIDs for a plot (supports multi-owner mega-plots).
|
* Get a immutable set of owner UUIDs for a plot (supports multi-owner mega-plots).
|
||||||
* @return
|
* @return the Plot owners
|
||||||
*/
|
*/
|
||||||
public HashSet<UUID> getOwners() {
|
public Set<UUID> getOwners() {
|
||||||
if (this.owner == null) {
|
if (this.owner == null) {
|
||||||
return new HashSet<>();
|
return Collections.emptySet();
|
||||||
}
|
}
|
||||||
if (isMerged()) {
|
if (isMerged()) {
|
||||||
HashSet<Plot> plots = getConnectedPlots();
|
Set<Plot> plots = getConnectedPlots();
|
||||||
Plot[] array = plots.toArray(new Plot[plots.size()]);
|
Plot[] array = plots.toArray(new Plot[plots.size()]);
|
||||||
HashSet<UUID> owners = new HashSet<UUID>(1);
|
ImmutableSet.Builder<UUID> owners = ImmutableSet.builder();
|
||||||
UUID last = this.owner;
|
UUID last = this.owner;
|
||||||
owners.add(this.owner);
|
owners.add(this.owner);
|
||||||
for (Plot current : array) {
|
for (Plot current : array) {
|
||||||
@ -367,9 +368,9 @@ public class Plot {
|
|||||||
last = current.owner;
|
last = current.owner;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return owners;
|
return owners.build();
|
||||||
}
|
}
|
||||||
return new HashSet<>(Collections.singletonList(this.owner));
|
return ImmutableSet.of(this.owner);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -380,10 +381,7 @@ public class Plot {
|
|||||||
* @return true if the player is added/trusted or is the owner
|
* @return true if the player is added/trusted or is the owner
|
||||||
*/
|
*/
|
||||||
public boolean isAdded(UUID uuid) {
|
public boolean isAdded(UUID uuid) {
|
||||||
if (this.owner == null) {
|
if (this.owner == null || getDenied().contains(uuid)) {
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (getDenied().contains(uuid)) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (getTrusted().contains(uuid) || getTrusted().contains(DBFunc.everyone)) {
|
if (getTrusted().contains(uuid) || getTrusted().contains(DBFunc.everyone)) {
|
||||||
@ -749,14 +747,11 @@ public class Plot {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean clear(boolean checkRunning, final boolean isDelete, final Runnable whenDone) {
|
public boolean clear(boolean checkRunning, final boolean isDelete, final Runnable whenDone) {
|
||||||
if (checkRunning && this.getRunning() != 0) {
|
if (checkRunning && this.getRunning() != 0 || !EventUtil.manager.callClear(this)) {
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (!EventUtil.manager.callClear(this)) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
final HashSet<RegionWrapper> regions = this.getRegions();
|
final HashSet<RegionWrapper> regions = this.getRegions();
|
||||||
final HashSet<Plot> plots = this.getConnectedPlots();
|
final Set<Plot> plots = this.getConnectedPlots();
|
||||||
final ArrayDeque<Plot> queue = new ArrayDeque<>(plots);
|
final ArrayDeque<Plot> queue = new ArrayDeque<>(plots);
|
||||||
if (isDelete) {
|
if (isDelete) {
|
||||||
this.removeSign();
|
this.removeSign();
|
||||||
@ -843,7 +838,7 @@ public class Plot {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Unlink the plot and all connected plots
|
* Unlink the plot and all connected plots.
|
||||||
* @param createSign
|
* @param createSign
|
||||||
* @param createRoad
|
* @param createRoad
|
||||||
* @return
|
* @return
|
||||||
@ -852,7 +847,7 @@ public class Plot {
|
|||||||
if (!this.isMerged()) {
|
if (!this.isMerged()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
HashSet<Plot> plots = this.getConnectedPlots();
|
Set<Plot> plots = this.getConnectedPlots();
|
||||||
ArrayList<PlotId> ids = new ArrayList<>(plots.size());
|
ArrayList<PlotId> ids = new ArrayList<>(plots.size());
|
||||||
for (Plot current : plots) {
|
for (Plot current : plots) {
|
||||||
current.setHome(null);
|
current.setHome(null);
|
||||||
@ -984,7 +979,7 @@ public class Plot {
|
|||||||
if (!this.hasOwner()) {
|
if (!this.hasOwner()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
final HashSet<Plot> plots = this.getConnectedPlots();
|
final Set<Plot> plots = this.getConnectedPlots();
|
||||||
this.clear(false, true, new Runnable() {
|
this.clear(false, true, new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
@ -1064,9 +1059,8 @@ public class Plot {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Unclaim the plot (does not modify terrain)<br>
|
* Unclaim the plot (does not modify terrain). Changes made to this plot will not be reflected in unclaimed plot objects.
|
||||||
* - Changes made to this plot will not be reflected in unclaimed plot objects<br>
|
* @return false if the Plot has no owner, otherwise true.
|
||||||
* @return
|
|
||||||
*/
|
*/
|
||||||
public boolean unclaim() {
|
public boolean unclaim() {
|
||||||
if (this.owner == null) {
|
if (this.owner == null) {
|
||||||
@ -1266,9 +1260,7 @@ public class Plot {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/** Remove the plot sign if it is set. */
|
||||||
* Remove the plot sign if it is set
|
|
||||||
*/
|
|
||||||
public void removeSign() {
|
public void removeSign() {
|
||||||
PlotManager manager = this.area.getPlotManager();
|
PlotManager manager = this.area.getPlotManager();
|
||||||
if (!this.area.ALLOW_SIGNS) {
|
if (!this.area.ALLOW_SIGNS) {
|
||||||
@ -1278,9 +1270,7 @@ public class Plot {
|
|||||||
SetQueue.IMP.setBlock(this.area.worldname, loc.getX(), loc.getY(), loc.getZ(), 0);
|
SetQueue.IMP.setBlock(this.area.worldname, loc.getX(), loc.getY(), loc.getZ(), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/** Set the plot sign if plot signs are enabled. */
|
||||||
* Set the plot sign if plot signs are enabled.
|
|
||||||
*/
|
|
||||||
public void setSign() {
|
public void setSign() {
|
||||||
if (this.owner == null) {
|
if (this.owner == null) {
|
||||||
this.setSign("unknown");
|
this.setSign("unknown");
|
||||||
@ -1742,7 +1732,7 @@ public class Plot {
|
|||||||
TaskManager.runTaskAsync(new Runnable() {
|
TaskManager.runTaskAsync(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
String name = Plot.this.id + "," + Plot.this.area + "," + MainUtil.getName(Plot.this.owner);
|
String name = Plot.this.id + "," + Plot.this.area + ',' + MainUtil.getName(Plot.this.owner);
|
||||||
boolean result =
|
boolean result =
|
||||||
SchematicHandler.manager.save(value, Settings.SCHEMATIC_SAVE_PATH + File.separator + name + ".schematic");
|
SchematicHandler.manager.save(value, Settings.SCHEMATIC_SAVE_PATH + File.separator + name + ".schematic");
|
||||||
if (whenDone != null) {
|
if (whenDone != null) {
|
||||||
@ -2034,7 +2024,7 @@ public class Plot {
|
|||||||
this.create();
|
this.create();
|
||||||
}
|
}
|
||||||
return this.owner;
|
return this.owner;
|
||||||
} catch (IllegalArgumentException e) {
|
} catch (IllegalArgumentException ignored) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2078,7 +2068,7 @@ public class Plot {
|
|||||||
}
|
}
|
||||||
HashSet<Plot> visited = new HashSet<>();
|
HashSet<Plot> visited = new HashSet<>();
|
||||||
HashSet<PlotId> merged = new HashSet<>();
|
HashSet<PlotId> merged = new HashSet<>();
|
||||||
HashSet<Plot> connected = this.getConnectedPlots();
|
Set<Plot> connected = this.getConnectedPlots();
|
||||||
for (Plot current : connected) {
|
for (Plot current : connected) {
|
||||||
merged.add(current.getId());
|
merged.add(current.getId());
|
||||||
}
|
}
|
||||||
@ -2093,8 +2083,7 @@ public class Plot {
|
|||||||
Set<Plot> plots;
|
Set<Plot> plots;
|
||||||
if ((dir == -1 || dir == 0) && !current.getMerged(0)) {
|
if ((dir == -1 || dir == 0) && !current.getMerged(0)) {
|
||||||
Plot other = current.getRelative(0);
|
Plot other = current.getRelative(0);
|
||||||
if (other != null
|
if (other != null && other.isOwner(uuid)
|
||||||
&& other.isOwner(uuid)
|
|
||||||
&& (other.getBasePlot(false).equals(current.getBasePlot(false))
|
&& (other.getBasePlot(false).equals(current.getBasePlot(false))
|
||||||
|| (plots = other.getConnectedPlots()).size() <= max && frontier.addAll(plots) && (max -= plots.size()) != -1)) {
|
|| (plots = other.getConnectedPlots()).size() <= max && frontier.addAll(plots) && (max -= plots.size()) != -1)) {
|
||||||
current.mergePlot(other, removeRoads);
|
current.mergePlot(other, removeRoads);
|
||||||
@ -2105,12 +2094,9 @@ public class Plot {
|
|||||||
}
|
}
|
||||||
if (max >= 0 && (dir == -1 || dir == 1) && !current.getMerged(1)) {
|
if (max >= 0 && (dir == -1 || dir == 1) && !current.getMerged(1)) {
|
||||||
Plot other = current.getRelative(1);
|
Plot other = current.getRelative(1);
|
||||||
if (other != null
|
if (other != null && other.isOwner(uuid)
|
||||||
&& other.isOwner(uuid)
|
|
||||||
&& (other.getBasePlot(false).equals(current.getBasePlot(false))
|
&& (other.getBasePlot(false).equals(current.getBasePlot(false))
|
||||||
|| (plots = other.getConnectedPlots()).size() <= max && frontier.addAll(plots) &&
|
|| (plots = other.getConnectedPlots()).size() <= max && frontier.addAll(plots) && (max -= plots.size()) != -1)) {
|
||||||
|
|
||||||
(max -= plots.size()) != -1)) {
|
|
||||||
current.mergePlot(other, removeRoads);
|
current.mergePlot(other, removeRoads);
|
||||||
merged.add(current.getId());
|
merged.add(current.getId());
|
||||||
merged.add(other.getId());
|
merged.add(other.getId());
|
||||||
@ -2245,14 +2231,14 @@ public class Plot {
|
|||||||
* - This result is cached globally
|
* - This result is cached globally
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public HashSet<Plot> getConnectedPlots() {
|
public Set<Plot> getConnectedPlots() {
|
||||||
if (this.settings == null) {
|
if (this.settings == null) {
|
||||||
return new HashSet<>(Collections.singletonList(this));
|
return Collections.singleton(this);
|
||||||
}
|
}
|
||||||
boolean[] merged = this.getMerged();
|
boolean[] merged = this.getMerged();
|
||||||
int hash = MainUtil.hash(merged);
|
int hash = MainUtil.hash(merged);
|
||||||
if (hash == 0) {
|
if (hash == 0) {
|
||||||
return new HashSet<>(Collections.singletonList(this));
|
return Collections.singleton(this);
|
||||||
}
|
}
|
||||||
if (connected_cache != null && connected_cache.contains(this)) {
|
if (connected_cache != null && connected_cache.contains(this)) {
|
||||||
return connected_cache;
|
return connected_cache;
|
||||||
@ -2388,7 +2374,7 @@ public class Plot {
|
|||||||
regions_cache.add(new RegionWrapper(pos1.getX(), pos2.getX(), pos1.getY(), pos2.getY(), pos1.getZ(), pos2.getZ()));
|
regions_cache.add(new RegionWrapper(pos1.getX(), pos2.getX(), pos1.getY(), pos2.getY(), pos1.getZ(), pos2.getZ()));
|
||||||
return regions_cache;
|
return regions_cache;
|
||||||
}
|
}
|
||||||
HashSet<Plot> plots = this.getConnectedPlots();
|
Set<Plot> plots = this.getConnectedPlots();
|
||||||
HashSet<RegionWrapper> regions = regions_cache = new HashSet<>();
|
HashSet<RegionWrapper> regions = regions_cache = new HashSet<>();
|
||||||
HashSet<PlotId> visited = new HashSet<>();
|
HashSet<PlotId> visited = new HashSet<>();
|
||||||
for (Plot current : plots) {
|
for (Plot current : plots) {
|
||||||
@ -2576,16 +2562,15 @@ public class Plot {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
TaskManager.TELEPORT_QUEUE.remove(name);
|
TaskManager.TELEPORT_QUEUE.remove(name);
|
||||||
if (!player.isOnline()) {
|
if (player.isOnline()) {
|
||||||
return;
|
|
||||||
}
|
|
||||||
MainUtil.sendMessage(player, C.TELEPORTED_TO_PLOT);
|
MainUtil.sendMessage(player, C.TELEPORTED_TO_PLOT);
|
||||||
player.teleport(location);
|
player.teleport(location);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}, Settings.TELEPORT_DELAY * 20);
|
}, Settings.TELEPORT_DELAY * 20);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return result;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isOnline() {
|
public boolean isOnline() {
|
||||||
@ -2715,7 +2700,7 @@ public class Plot {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
boolean occupied = false;
|
boolean occupied = false;
|
||||||
HashSet<Plot> plots = this.getConnectedPlots();
|
Set<Plot> plots = this.getConnectedPlots();
|
||||||
for (Plot plot : plots) {
|
for (Plot plot : plots) {
|
||||||
Plot other = plot.getRelative(destination.getArea(), offset.x, offset.y);
|
Plot other = plot.getRelative(destination.getArea(), offset.x, offset.y);
|
||||||
if (other.hasOwner()) {
|
if (other.hasOwner()) {
|
||||||
@ -2809,7 +2794,7 @@ public class Plot {
|
|||||||
TaskManager.runTaskLater(whenDone, 1);
|
TaskManager.runTaskLater(whenDone, 1);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
HashSet<Plot> plots = this.getConnectedPlots();
|
Set<Plot> plots = this.getConnectedPlots();
|
||||||
for (Plot plot : plots) {
|
for (Plot plot : plots) {
|
||||||
Plot other = plot.getRelative(destination.getArea(), offset.x, offset.y);
|
Plot other = plot.getRelative(destination.getArea(), offset.x, offset.y);
|
||||||
if (other.hasOwner()) {
|
if (other.hasOwner()) {
|
||||||
@ -2876,6 +2861,6 @@ public class Plot {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasFlag(Flag<?> flag) {
|
public boolean hasFlag(Flag<?> flag) {
|
||||||
return false;
|
return getFlags().containsKey(flag);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -515,7 +515,7 @@ public class PlotAnalysis {
|
|||||||
int SIZE = 10;
|
int SIZE = 10;
|
||||||
List<Integer>[] bucket = new ArrayList[SIZE];
|
List<Integer>[] bucket = new ArrayList[SIZE];
|
||||||
for (int i = 0; i < bucket.length; i++) {
|
for (int i = 0; i < bucket.length; i++) {
|
||||||
bucket[i] = new ArrayList<Integer>();
|
bucket[i] = new ArrayList<>();
|
||||||
}
|
}
|
||||||
boolean maxLength = false;
|
boolean maxLength = false;
|
||||||
int placement = 1;
|
int placement = 1;
|
||||||
|
@ -7,6 +7,7 @@ import com.intellectualcrafters.plot.config.ConfigurationNode;
|
|||||||
import com.intellectualcrafters.plot.config.Settings;
|
import com.intellectualcrafters.plot.config.Settings;
|
||||||
import com.intellectualcrafters.plot.flag.Flag;
|
import com.intellectualcrafters.plot.flag.Flag;
|
||||||
import com.intellectualcrafters.plot.flag.FlagManager;
|
import com.intellectualcrafters.plot.flag.FlagManager;
|
||||||
|
import com.intellectualcrafters.plot.flag.Flags;
|
||||||
import com.intellectualcrafters.plot.generator.GridPlotWorld;
|
import com.intellectualcrafters.plot.generator.GridPlotWorld;
|
||||||
import com.intellectualcrafters.plot.generator.IndependentPlotGenerator;
|
import com.intellectualcrafters.plot.generator.IndependentPlotGenerator;
|
||||||
import com.intellectualcrafters.plot.util.EconHandler;
|
import com.intellectualcrafters.plot.util.EconHandler;
|
||||||
@ -53,9 +54,9 @@ public abstract class PlotArea {
|
|||||||
public boolean SCHEMATIC_ON_CLAIM = false;
|
public boolean SCHEMATIC_ON_CLAIM = false;
|
||||||
public String SCHEMATIC_FILE = "null";
|
public String SCHEMATIC_FILE = "null";
|
||||||
public List<String> SCHEMATICS = null;
|
public List<String> SCHEMATICS = null;
|
||||||
public HashMap<Flag<?>, Object> DEFAULT_FLAGS;
|
public Map<Flag<?>, Object> DEFAULT_FLAGS;
|
||||||
public boolean USE_ECONOMY = false;
|
public boolean USE_ECONOMY = false;
|
||||||
public HashMap<String, Double> PRICES = new HashMap<>();
|
public Map<String, Double> PRICES = new HashMap<>();
|
||||||
public boolean SPAWN_EGGS = false;
|
public boolean SPAWN_EGGS = false;
|
||||||
public boolean SPAWN_CUSTOM = true;
|
public boolean SPAWN_CUSTOM = true;
|
||||||
public boolean SPAWN_BREEDING = false;
|
public boolean SPAWN_BREEDING = false;
|
||||||
@ -165,10 +166,7 @@ public abstract class PlotArea {
|
|||||||
if (this == obj) {
|
if (this == obj) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (obj == null) {
|
if (obj == null || getClass() != obj.getClass()) {
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (getClass() != obj.getClass()) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
PlotArea plotarea = (PlotArea) obj;
|
PlotArea plotarea = (PlotArea) obj;
|
||||||
@ -187,11 +185,8 @@ public abstract class PlotArea {
|
|||||||
public boolean isCompatible(PlotArea plotArea) {
|
public boolean isCompatible(PlotArea plotArea) {
|
||||||
ConfigurationSection section = PS.get().config.getConfigurationSection("worlds");
|
ConfigurationSection section = PS.get().config.getConfigurationSection("worlds");
|
||||||
for (ConfigurationNode setting : plotArea.getSettingNodes()) {
|
for (ConfigurationNode setting : plotArea.getSettingNodes()) {
|
||||||
Object constant = section.get(plotArea.worldname + "." + setting.getConstant());
|
Object constant = section.get(plotArea.worldname + '.' + setting.getConstant());
|
||||||
if (constant == null) {
|
if (constant == null || !constant.equals(section.get(this.worldname + '.' + setting.getConstant()))) {
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (!constant.equals(section.get(this.worldname + "." + setting.getConstant()))) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -269,7 +264,7 @@ public abstract class PlotArea {
|
|||||||
try {
|
try {
|
||||||
String[] split = homeDefault.split(",");
|
String[] split = homeDefault.split(",");
|
||||||
this.DEFAULT_HOME = new PlotLoc(Integer.parseInt(split[0]), Integer.parseInt(split[1]));
|
this.DEFAULT_HOME = new PlotLoc(Integer.parseInt(split[0]), Integer.parseInt(split[1]));
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException ignored) {
|
||||||
this.DEFAULT_HOME = null;
|
this.DEFAULT_HOME = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -283,7 +278,7 @@ public abstract class PlotArea {
|
|||||||
Set<String> keys = section.getKeys(false);
|
Set<String> keys = section.getKeys(false);
|
||||||
for (String key : keys) {
|
for (String key : keys) {
|
||||||
if (!"default".equals(key)) {
|
if (!"default".equals(key)) {
|
||||||
flags.add(key + ";" + section.get(key));
|
flags.add(key + ';' + section.get(key));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -475,8 +470,8 @@ public abstract class PlotArea {
|
|||||||
return myPlots;
|
return myPlots;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Set<Plot> getPlots(UUID uuid) {
|
public Set<Plot> getPlots(final UUID uuid) {
|
||||||
HashSet<Plot> myplots = new HashSet<>();
|
final HashSet<Plot> myplots = new HashSet<>();
|
||||||
for (Plot plot : getPlots()) {
|
for (Plot plot : getPlots()) {
|
||||||
if (plot.isBasePlot()) {
|
if (plot.isBasePlot()) {
|
||||||
if (plot.isOwner(uuid)) {
|
if (plot.isOwner(uuid)) {
|
||||||
@ -488,7 +483,7 @@ public abstract class PlotArea {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Set<Plot> getPlots(PlotPlayer player) {
|
public Set<Plot> getPlots(PlotPlayer player) {
|
||||||
return player != null ? getPlots(player.getUUID()) : new HashSet<Plot>();
|
return getPlots(player.getUUID());
|
||||||
}
|
}
|
||||||
|
|
||||||
public Set<Plot> getPlotsAbs(PlotPlayer player) {
|
public Set<Plot> getPlotsAbs(PlotPlayer player) {
|
||||||
@ -499,7 +494,7 @@ public abstract class PlotArea {
|
|||||||
int count = 0;
|
int count = 0;
|
||||||
if (!Settings.DONE_COUNTS_TOWARDS_LIMIT) {
|
if (!Settings.DONE_COUNTS_TOWARDS_LIMIT) {
|
||||||
for (Plot plot : getPlotsAbs(uuid)) {
|
for (Plot plot : getPlotsAbs(uuid)) {
|
||||||
if (!plot.getFlags().containsKey("done")) {
|
if (!plot.hasFlag(Flags.DONE)) {
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package com.intellectualcrafters.plot.object;
|
package com.intellectualcrafters.plot.object;
|
||||||
|
|
||||||
import java.util.HashSet;
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public class PlotHandler {
|
public class PlotHandler {
|
||||||
@ -8,7 +8,7 @@ public class PlotHandler {
|
|||||||
if ((plot1.owner == null) || (plot2.owner == null)) {
|
if ((plot1.owner == null) || (plot2.owner == null)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
final HashSet<UUID> owners = plot1.getOwners();
|
final Set<UUID> owners = plot1.getOwners();
|
||||||
owners.retainAll(plot2.getOwners());
|
owners.retainAll(plot2.getOwners());
|
||||||
return !owners.isEmpty();
|
return !owners.isEmpty();
|
||||||
}
|
}
|
||||||
|
@ -42,7 +42,7 @@ public class PlotId {
|
|||||||
try {
|
try {
|
||||||
x = Integer.parseInt(parts[0]);
|
x = Integer.parseInt(parts[0]);
|
||||||
y = Integer.parseInt(parts[1]);
|
y = Integer.parseInt(parts[1]);
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException ignored) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return new PlotId(x, y);
|
return new PlotId(x, y);
|
||||||
|
@ -4,6 +4,7 @@ import com.intellectualcrafters.plot.PS;
|
|||||||
import com.intellectualcrafters.plot.commands.RequiredType;
|
import com.intellectualcrafters.plot.commands.RequiredType;
|
||||||
import com.intellectualcrafters.plot.config.Settings;
|
import com.intellectualcrafters.plot.config.Settings;
|
||||||
import com.intellectualcrafters.plot.database.DBFunc;
|
import com.intellectualcrafters.plot.database.DBFunc;
|
||||||
|
import com.intellectualcrafters.plot.flag.Flags;
|
||||||
import com.intellectualcrafters.plot.util.EventUtil;
|
import com.intellectualcrafters.plot.util.EventUtil;
|
||||||
import com.intellectualcrafters.plot.util.ExpireManager;
|
import com.intellectualcrafters.plot.util.ExpireManager;
|
||||||
import com.intellectualcrafters.plot.util.Permissions;
|
import com.intellectualcrafters.plot.util.Permissions;
|
||||||
@ -145,7 +146,7 @@ public abstract class PlotPlayer implements CommandCaller {
|
|||||||
public void run(PlotArea value) {
|
public void run(PlotArea value) {
|
||||||
if (!Settings.DONE_COUNTS_TOWARDS_LIMIT) {
|
if (!Settings.DONE_COUNTS_TOWARDS_LIMIT) {
|
||||||
for (Plot plot : value.getPlotsAbs(uuid)) {
|
for (Plot plot : value.getPlotsAbs(uuid)) {
|
||||||
if (!plot.getFlags().containsKey("done")) {
|
if (!plot.hasFlag(Flags.DONE)) {
|
||||||
count.incrementAndGet();
|
count.incrementAndGet();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -245,19 +246,6 @@ public abstract class PlotPlayer implements CommandCaller {
|
|||||||
*/
|
*/
|
||||||
public abstract UUID getUUID();
|
public abstract UUID getUUID();
|
||||||
|
|
||||||
/**
|
|
||||||
* Check the player's permissions<br>
|
|
||||||
* - Will be cached if permission caching is enabled
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public abstract boolean hasPermission(String permission);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Send the player a message
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public abstract void sendMessage(String message);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Teleport the player to a location
|
* Teleport the player to a location
|
||||||
* @param location
|
* @param location
|
||||||
|
@ -254,7 +254,7 @@ public class BO3Handler {
|
|||||||
try (FileOutputStream fos = new FileOutputStream(bo3File)) {
|
try (FileOutputStream fos = new FileOutputStream(bo3File)) {
|
||||||
write(fos, plot, bo3);
|
write(fos, plot, bo3);
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -222,8 +222,7 @@ public abstract class ChunkManager {
|
|||||||
int z = Integer.parseInt(split[2]);
|
int z = Integer.parseInt(split[2]);
|
||||||
ChunkLoc loc = new ChunkLoc(x, z);
|
ChunkLoc loc = new ChunkLoc(x, z);
|
||||||
chunks.add(loc);
|
chunks.add(loc);
|
||||||
} catch (NumberFormatException ignored) {
|
} catch (NumberFormatException ignored) {}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return chunks;
|
return chunks;
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user