Pulled files from official repository

This commit is contained in:
zomb 2016-03-15 22:15:47 -10:00
commit a297d505f8
37 changed files with 602 additions and 527 deletions

View file

@ -12,23 +12,74 @@ import com.intellectualcrafters.plot.generator.GeneratorWrapper;
import com.intellectualcrafters.plot.generator.HybridGen;
import com.intellectualcrafters.plot.generator.HybridUtils;
import com.intellectualcrafters.plot.generator.IndependentPlotGenerator;
import com.intellectualcrafters.plot.object.*;
import com.intellectualcrafters.plot.util.*;
import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.object.PlotArea;
import com.intellectualcrafters.plot.object.PlotPlayer;
import com.intellectualcrafters.plot.object.RunnableVal;
import com.intellectualcrafters.plot.object.SetupObject;
import com.intellectualcrafters.plot.util.AbstractTitle;
import com.intellectualcrafters.plot.util.ChatManager;
import com.intellectualcrafters.plot.util.ChunkManager;
import com.intellectualcrafters.plot.util.ConsoleColors;
import com.intellectualcrafters.plot.util.EconHandler;
import com.intellectualcrafters.plot.util.EventUtil;
import com.intellectualcrafters.plot.util.InventoryUtil;
import com.intellectualcrafters.plot.util.MainUtil;
import com.intellectualcrafters.plot.util.PlotQueue;
import com.intellectualcrafters.plot.util.SchematicHandler;
import com.intellectualcrafters.plot.util.SetupUtils;
import com.intellectualcrafters.plot.util.StringMan;
import com.intellectualcrafters.plot.util.TaskManager;
import com.intellectualcrafters.plot.util.UUIDHandler;
import com.intellectualcrafters.plot.util.UUIDHandlerImplementation;
import com.intellectualcrafters.plot.util.WorldUtil;
import com.intellectualcrafters.plot.uuid.UUIDWrapper;
import com.plotsquared.bukkit.commands.DebugUUID;
import com.plotsquared.bukkit.database.plotme.ClassicPlotMeConnector;
import com.plotsquared.bukkit.database.plotme.LikePlotMeConverter;
import com.plotsquared.bukkit.database.plotme.PlotMeConnector_017;
import com.plotsquared.bukkit.generator.BukkitPlotGenerator;
import com.plotsquared.bukkit.listeners.*;
import com.plotsquared.bukkit.listeners.ChunkListener;
import com.plotsquared.bukkit.listeners.ForceFieldListener;
import com.plotsquared.bukkit.listeners.PlayerEvents;
import com.plotsquared.bukkit.listeners.PlayerEvents_1_8;
import com.plotsquared.bukkit.listeners.PlayerEvents_1_8_3;
import com.plotsquared.bukkit.listeners.PlotPlusListener;
import com.plotsquared.bukkit.listeners.WorldEvents;
import com.plotsquared.bukkit.listeners.worldedit.WEListener;
import com.plotsquared.bukkit.titles.DefaultTitle_19;
import com.plotsquared.bukkit.util.*;
import com.plotsquared.bukkit.util.block.*;
import com.plotsquared.bukkit.uuid.*;
import com.plotsquared.bukkit.util.BukkitChatManager;
import com.plotsquared.bukkit.util.BukkitChunkManager;
import com.plotsquared.bukkit.util.BukkitCommand;
import com.plotsquared.bukkit.util.BukkitEconHandler;
import com.plotsquared.bukkit.util.BukkitEventUtil;
import com.plotsquared.bukkit.util.BukkitHybridUtils;
import com.plotsquared.bukkit.util.BukkitInventoryUtil;
import com.plotsquared.bukkit.util.BukkitPlainChatManager;
import com.plotsquared.bukkit.util.BukkitSchematicHandler;
import com.plotsquared.bukkit.util.BukkitSetupUtils;
import com.plotsquared.bukkit.util.BukkitTaskManager;
import com.plotsquared.bukkit.util.BukkitUtil;
import com.plotsquared.bukkit.util.Metrics;
import com.plotsquared.bukkit.util.SendChunk;
import com.plotsquared.bukkit.util.SetGenCB;
import com.plotsquared.bukkit.util.block.FastQueue_1_7;
import com.plotsquared.bukkit.util.block.FastQueue_1_8;
import com.plotsquared.bukkit.util.block.FastQueue_1_8_3;
import com.plotsquared.bukkit.util.block.FastQueue_1_9;
import com.plotsquared.bukkit.util.block.SlowQueue;
import com.plotsquared.bukkit.uuid.DefaultUUIDWrapper;
import com.plotsquared.bukkit.uuid.FileUUIDHandler;
import com.plotsquared.bukkit.uuid.LowerOfflineUUIDWrapper;
import com.plotsquared.bukkit.uuid.OfflineUUIDWrapper;
import com.plotsquared.bukkit.uuid.SQLUUIDHandler;
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
import org.bukkit.*;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.OfflinePlayer;
import org.bukkit.Server;
import org.bukkit.World;
import org.bukkit.command.PluginCommand;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
@ -42,7 +93,11 @@ import java.io.File;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import java.util.UUID;
public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
@ -87,9 +142,6 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
@Override
public void log(String message) {
if (message == null) {
return;
}
if ((THIS != null) && (Bukkit.getServer().getConsoleSender() != null)) {
try {
message = C.color(message);
@ -571,10 +623,8 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
PS.get().loadWorld(worldname, (BukkitPlotGenerator) gen);
} else if (gen != null) {
PS.get().loadWorld(worldname, new BukkitPlotGenerator(worldname, gen));
} else {
if (PS.get().config.contains("worlds." + worldname)) {
PS.get().loadWorld(worldname, null);
}
} else if (PS.get().config.contains("worlds." + worldname)) {
PS.get().loadWorld(worldname, null);
}
}

View file

@ -51,12 +51,12 @@ final class MessagePart implements JsonRepresentedObject, ConfigurationSerializa
}
ChatColor color = ChatColor.WHITE;
ArrayList<ChatColor> styles = new ArrayList<ChatColor>();
ArrayList<ChatColor> styles = new ArrayList<>();
String clickActionName = null, clickActionData = null, hoverActionName = null;
JsonRepresentedObject hoverActionData = null;
TextualComponent text = null;
String insertionData = null;
ArrayList<JsonRepresentedObject> translationReplacements = new ArrayList<JsonRepresentedObject>();
ArrayList<JsonRepresentedObject> translationReplacements = new ArrayList<>();
MessagePart(final TextualComponent text) {
this.text = text;
@ -134,7 +134,7 @@ final class MessagePart implements JsonRepresentedObject, ConfigurationSerializa
@Override
public Map<String, Object> serialize() {
final HashMap<String, Object> map = new HashMap<String, Object>();
final HashMap<String, Object> map = new HashMap<>();
map.put("text", text);
map.put("styles", styles);
map.put("color", color.getChar());

View file

@ -1,18 +1,17 @@
package com.plotsquared.bukkit.database.plotme;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.Collections;
import java.util.HashMap;
import org.bukkit.Bukkit;
import org.bukkit.World;
import com.intellectualcrafters.configuration.file.FileConfiguration;
import com.intellectualcrafters.plot.PS;
import com.intellectualcrafters.plot.object.Location;
import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.object.PlotId;
import org.bukkit.Bukkit;
import org.bukkit.World;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.Collections;
import java.util.HashMap;
public abstract class APlotMeConnector {
public abstract Connection getPlotMeConnection(final String plugin, final FileConfiguration plotConfig, final String dataFolder);
@ -69,35 +68,14 @@ public abstract class APlotMeConnector {
public void setMerged(final HashMap<String, HashMap<PlotId, boolean[]>> merges, final String world, final PlotId id, final int direction) {
final HashMap<PlotId, boolean[]> plots = merges.get(world);
PlotId id2;
switch (direction) {
case 0: {
id2 = new PlotId(id.x, id.y);
break;
}
case 1: {
id2 = new PlotId(id.x, id.y);
break;
}
case 2: {
id2 = new PlotId(id.x, id.y);
break;
}
case 3: {
id2 = new PlotId(id.x, id.y);
break;
}
default: {
return;
}
}
PlotId id2 = new PlotId(id.x, id.y);
boolean[] merge1;
boolean[] merge2;
if (plots.containsKey(id)) {
merge1 = plots.get(id);
} else {
merge1 = new boolean[] { false, false, false, false };
}
boolean[] merge2;
if (plots.containsKey(id2)) {
merge2 = plots.get(id2);
} else {

View file

@ -24,7 +24,11 @@ import com.intellectualcrafters.plot.PS;
import com.intellectualcrafters.plot.generator.GeneratorWrapper;
import com.intellectualcrafters.plot.generator.HybridGen;
import com.intellectualcrafters.plot.generator.IndependentPlotGenerator;
import com.intellectualcrafters.plot.object.*;
import com.intellectualcrafters.plot.object.PlotArea;
import com.intellectualcrafters.plot.object.PlotId;
import com.intellectualcrafters.plot.object.PlotManager;
import com.intellectualcrafters.plot.object.PseudoRandom;
import com.intellectualcrafters.plot.object.SetupObject;
import com.intellectualcrafters.plot.util.ChunkManager;
import com.intellectualcrafters.plot.util.MainUtil;
import com.intellectualcrafters.plot.util.PlotChunk;
@ -48,9 +52,9 @@ public class BukkitPlotGenerator extends ChunkGenerator implements GeneratorWrap
private final PseudoRandom random = new PseudoRandom();
private final IndependentPlotGenerator plotGenerator;
private final List<BlockPopulator> populators = new ArrayList<>();
private final ChunkGenerator platformGenerator;
private final boolean full;
private boolean loaded = false;
private ChunkGenerator platformGenerator;
private boolean full;
public BukkitPlotGenerator(IndependentPlotGenerator generator) {
this.plotGenerator = generator;
@ -58,11 +62,6 @@ public class BukkitPlotGenerator extends ChunkGenerator implements GeneratorWrap
populators.add(new BlockPopulator() {
@Override
public void populate(World world, Random r, Chunk c) {
if (!(chunkSetter instanceof GenChunk)) {
PS.debug("Current PlotChunk is not relevant to population?");
PS.stacktrace();
return;
}
GenChunk result = (GenChunk) chunkSetter;
if (result.result_data != null) {
for (int i = 0; i < result.result_data.length; i++) {
@ -90,7 +89,7 @@ public class BukkitPlotGenerator extends ChunkGenerator implements GeneratorWrap
throw new IllegalArgumentException("ChunkGenerator: " + cg.getClass().getName() + " is already a BukkitPlotGenerator!");
}
this.full = false;
PS.get().debug("BukkitPlotGenerator does not fully support: " + cg);
PS.debug("BukkitPlotGenerator does not fully support: " + cg);
platformGenerator = cg;
plotGenerator = new IndependentPlotGenerator() {
@Override
@ -229,11 +228,6 @@ public class BukkitPlotGenerator extends ChunkGenerator implements GeneratorWrap
@Override
public ChunkData generateChunkData(World world, Random random, int cx, int cz, BiomeGrid grid) {
if (!(chunkSetter instanceof GenChunk)) {
PS.debug("Current PlotChunk is not relevant to generation?");
PS.stacktrace();
return null;
}
GenChunk result = (GenChunk) chunkSetter;
// Set the chunk location
result.setChunkWrapper(SetQueue.IMP.new ChunkWrapper(world.getName(), cx, cz));
@ -278,10 +272,6 @@ public class BukkitPlotGenerator extends ChunkGenerator implements GeneratorWrap
@Override
public short[][] generateExtBlockSections(final World world, final Random r, final int cx, final int cz, final BiomeGrid grid) {
if (!(chunkSetter instanceof GenChunk)) {
PS.stacktrace();
return new short[16][];
}
GenChunk result = (GenChunk) chunkSetter;
// Set the chunk location
result.setChunkWrapper(SetQueue.IMP.new ChunkWrapper(world.getName(), cx, cz));

View file

@ -27,16 +27,6 @@ import com.plotsquared.bukkit.object.BukkitLazyBlock;
import com.plotsquared.bukkit.object.BukkitPlayer;
import com.plotsquared.bukkit.util.BukkitUtil;
import com.plotsquared.listener.PlayerBlockEventType;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map.Entry;
import java.util.Objects;
import java.util.Set;
import java.util.UUID;
import java.util.regex.Pattern;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Material;
@ -117,11 +107,21 @@ import org.bukkit.projectiles.BlockProjectileSource;
import org.bukkit.projectiles.ProjectileSource;
import org.bukkit.util.Vector;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map.Entry;
import java.util.Objects;
import java.util.Set;
import java.util.UUID;
import java.util.regex.Pattern;
/**
* Player Events involving plots
*
*/
@SuppressWarnings({ "deprecation", "unchecked" })
public class PlayerEvents extends com.plotsquared.listener.PlotListener implements Listener {
private boolean pistonBlocks = true;
@ -355,11 +355,11 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
if (c.equals(cmdLabel.getName())) {
break;
}
PluginCommand p;
final String label = cmdLabel.getName().replaceFirst("/", "");
if (aliases.contains(label)) {
continue;
}
PluginCommand p;
if ((p = Bukkit.getPluginCommand(label)) != null) {
for (String a : p.getAliases()) {
if (aliases.contains(a)) {
@ -1309,9 +1309,7 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
}
public boolean checkEntity(final Entity entity, final Plot plot) {
if (plot == null || plot.owner == null || plot.settings == null || plot.getFlags().isEmpty() && plot.getArea().DEFAULT_FLAGS
.isEmpty
()) {
if (plot == null || plot.owner == null || plot.getFlags().isEmpty() && plot.getArea().DEFAULT_FLAGS.isEmpty()) {
return false;
}
switch (entity.getType()) {
@ -1326,6 +1324,10 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
case SNOWBALL:
case ENDER_PEARL:
case ARROW:
case TIPPED_ARROW:
case SPECTRAL_ARROW:
case SHULKER_BULLET:
case DRAGON_FIREBALL:
// projectile
case PRIMED_TNT:
case FALLING_BLOCK:
@ -1338,6 +1340,7 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
case LEASH_HITCH:
case FIREWORK:
case WEATHER:
case AREA_EFFECT_CLOUD:
case LIGHTNING:
case WITHER_SKULL:
case UNKNOWN:
@ -1362,7 +1365,6 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
case MUSHROOM_COW:
case OCELOT:
case PIG:
case HORSE:
case SQUID:
case VILLAGER:
case IRON_GOLEM:
@ -1371,6 +1373,7 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
case COW:
case SNOWMAN:
case BAT:
case HORSE:
// animal
return checkEntity(plot, "entity-cap", "mob-cap", "animal-cap");
case BLAZE:
@ -1391,26 +1394,24 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
case WITCH:
case WITHER:
case ZOMBIE:
case SHULKER:
// monster
return checkEntity(plot, "entity-cap", "mob-cap", "hostile-cap");
default:
String[] types;
if (entity instanceof LivingEntity) {
if (entity instanceof Animals) {
types = new String[] { "entity-cap", "mob-cap", "animal-cap" };
return checkEntity(plot, "entity-cap", "mob-cap", "animal-cap");
} else if (entity instanceof Monster) {
types = new String[] { "entity-cap", "mob-cap", "hostile-cap" };
return checkEntity(plot, "entity-cap", "mob-cap", "hostile-cap");
} else {
types = new String[] { "entity-cap", "mob-cap" };
return checkEntity(plot, "entity-cap", "mob-cap");
}
} else if (entity instanceof Vehicle) {
types = new String[] { "entity-cap", "vehicle-cap" };
return checkEntity(plot, "entity-cap", "vehicle-cap");
} else if (entity instanceof Hanging) {
types = new String[] { "entity-cap", "misc-cap" };
} else {
types = new String[] { "entity-cap" };
return checkEntity(plot, "entity-cap", "misc-cap");
}
return checkEntity(plot, types);
return checkEntity(plot, "entity-cap");
}
}
@ -1444,12 +1445,10 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
} else {
if (ent != null) {
loc = BukkitUtil.getLocation(ent);
} else if (player != null) {
loc = BukkitUtil.getLocation(player);
} else {
if (player != null) {
loc = BukkitUtil.getLocation(player);
} else {
return;
}
return;
}
}
PlotArea area = loc.getPlotArea();
@ -1594,24 +1593,22 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
}
} else if (lastPlot != null && now.equals(lastPlot)) {
return;
} else {
if (!plotEntry(pp, now) && tmp_teleport) {
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_ENTRY_DENIED);
if (!now.equals(area.getPlot(BukkitUtil.getLocation(from)))) {
} else if (!plotEntry(pp, now) && tmp_teleport) {
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_ENTRY_DENIED);
if (!now.equals(area.getPlot(BukkitUtil.getLocation(from)))) {
tmp_teleport = false;
player.teleport(from);
tmp_teleport = true;
} else {
Location spawn = BukkitUtil.getLocation(player.getWorld().getSpawnLocation());
if (spawn.getEuclideanDistanceSquared(pp.getLocation()) > 2) {
tmp_teleport = false;
player.teleport(from);
player.teleport(player.getWorld().getSpawnLocation());
tmp_teleport = true;
} else {
Location spawn = BukkitUtil.getLocation(player.getWorld().getSpawnLocation());
if (spawn.getEuclideanDistanceSquared(pp.getLocation()) > 2) {
tmp_teleport = false;
player.teleport(player.getWorld().getSpawnLocation());
tmp_teleport = true;
}
}
event.setCancelled(true);
return;
}
event.setCancelled(true);
return;
}
final Integer border = area.getBorder();
if (tmp_teleport) {
@ -1666,24 +1663,22 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
}
} else if (lastPlot != null && now.equals(lastPlot)) {
return;
} else {
if (!plotEntry(pp, now) && tmp_teleport) {
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_ENTRY_DENIED);
if (!now.equals(area.getPlot(BukkitUtil.getLocation(from)))) {
} else if (!plotEntry(pp, now) && tmp_teleport) {
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_ENTRY_DENIED);
if (!now.equals(area.getPlot(BukkitUtil.getLocation(from)))) {
tmp_teleport = false;
player.teleport(from);
tmp_teleport = true;
} else {
Location spawn = BukkitUtil.getLocation(player.getWorld().getSpawnLocation());
if (spawn.getEuclideanDistanceSquared(pp.getLocation()) > 2) {
tmp_teleport = false;
player.teleport(from);
player.teleport(player.getWorld().getSpawnLocation());
tmp_teleport = true;
} else {
Location spawn = BukkitUtil.getLocation(player.getWorld().getSpawnLocation());
if (spawn.getEuclideanDistanceSquared(pp.getLocation()) > 2) {
tmp_teleport = false;
player.teleport(player.getWorld().getSpawnLocation());
tmp_teleport = true;
}
}
event.setCancelled(true);
return;
}
event.setCancelled(true);
return;
}
final Integer border = area.getBorder();
if (tmp_teleport) {
@ -1721,24 +1716,22 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
}
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_BUILD_ROAD);
e.setCancelled(true);
} else {
if (!plot.hasOwner()) {
if (Permissions.hasPermission(pp, C.PERMISSION_ADMIN_BUILD_UNOWNED)) {
return;
}
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_BUILD_UNOWNED);
e.setCancelled(true);
} else if (!plot.isAdded(pp.getUUID())) {
final Flag use = FlagManager.getPlotFlagRaw(plot, C.FLAG_USE.s());
if (use != null && ((HashSet<PlotBlock>) use.getValue()).contains(new PlotBlock((short) e.getBucket().getId(), (byte) 0))) {
return;
}
if (Permissions.hasPermission(pp, C.PERMISSION_ADMIN_BUILD_OTHER)) {
return;
}
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_BUILD_OTHER);
e.setCancelled(true);
} else if (!plot.hasOwner()) {
if (Permissions.hasPermission(pp, C.PERMISSION_ADMIN_BUILD_UNOWNED)) {
return;
}
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_BUILD_UNOWNED);
e.setCancelled(true);
} else if (!plot.isAdded(pp.getUUID())) {
final Flag use = FlagManager.getPlotFlagRaw(plot, C.FLAG_USE.s());
if (use != null && ((HashSet<PlotBlock>) use.getValue()).contains(new PlotBlock((short) e.getBucket().getId(), (byte) 0))) {
return;
}
if (Permissions.hasPermission(pp, C.PERMISSION_ADMIN_BUILD_OTHER)) {
return;
}
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_BUILD_OTHER);
e.setCancelled(true);
}
}

View file

@ -57,7 +57,7 @@ import java.util.UUID;
*
*/
@SuppressWarnings({ "deprecation" })
@SuppressWarnings("deprecation")
public class PlotPlusListener extends PlotListener implements Listener {
private final static HashMap<String, Interval> feedRunnable = new HashMap<>();
private final static HashMap<String, Interval> healRunnable = new HashMap<>();
@ -122,6 +122,9 @@ public class PlotPlusListener extends PlotListener implements Listener {
if (!FlagManager.isBooleanFlag(plot, "ice-melt", false)) {
event.setCancelled(true);
}
if (FlagManager.isPlotFlagFalse(plot, "snow-melt")) {
event.setCancelled(true);
}
}
@EventHandler(priority = EventPriority.HIGH)

View file

@ -34,6 +34,7 @@ import org.bukkit.util.Vector;
public class EntityWrapper {
private final int hash;
public EntityType type;
public float yaw;
public float pitch;
@ -54,8 +55,6 @@ public class EntityWrapper {
private HorseStats horse;
private ArmorStandStats stand;
private int hash;
@SuppressWarnings("deprecation")
public EntityWrapper(final org.bukkit.entity.Entity entity, final short depth) {
hash = entity.getEntityId();
@ -153,10 +152,7 @@ public class EntityWrapper {
}
// END MISC //
// INVENTORY HOLDER //
case MINECART_CHEST: {
storeInventory((InventoryHolder) entity);
return;
}
case MINECART_CHEST:
case MINECART_HOPPER: {
storeInventory((InventoryHolder) entity);
return;
@ -508,10 +504,7 @@ public class EntityWrapper {
}
// END MISC //
// INVENTORY HOLDER //
case MINECART_CHEST: {
restoreInventory((InventoryHolder) entity);
return entity;
}
case MINECART_CHEST:
case MINECART_HOPPER: {
restoreInventory((InventoryHolder) entity);
return entity;

View file

@ -5,9 +5,17 @@ import com.intellectualcrafters.plot.object.PlotBlock;
import com.intellectualcrafters.plot.object.PlotPlayer;
import com.intellectualcrafters.plot.object.RegionWrapper;
import com.intellectualcrafters.plot.object.schematic.PlotItem;
import com.intellectualcrafters.plot.util.*;
import com.intellectualcrafters.plot.util.MathMan;
import com.intellectualcrafters.plot.util.StringComparison;
import com.intellectualcrafters.plot.util.StringMan;
import com.intellectualcrafters.plot.util.TaskManager;
import com.intellectualcrafters.plot.util.UUIDHandler;
import com.intellectualcrafters.plot.util.WorldUtil;
import com.plotsquared.bukkit.object.BukkitPlayer;
import org.bukkit.*;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.OfflinePlayer;
import org.bukkit.World;
import org.bukkit.block.Biome;
import org.bukkit.block.Block;
import org.bukkit.block.BlockState;
@ -17,7 +25,12 @@ import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.InventoryHolder;
import org.bukkit.inventory.ItemStack;
import org.bukkit.material.*;
import org.bukkit.material.MaterialData;
import org.bukkit.material.Sandstone;
import org.bukkit.material.Step;
import org.bukkit.material.Tree;
import org.bukkit.material.WoodenStep;
import org.bukkit.material.Wool;
import java.util.Arrays;
import java.util.List;
@ -282,7 +295,7 @@ public class BukkitUtil extends WorldUtil {
final World world = getWorld(loc.getWorld());
final Block block = world.getBlockAt(loc.getX(), loc.getY(), loc.getZ());
if (block == null) {
return new PlotBlock((short) 0, (byte) 0);
return PlotBlock.EVERYTHING;
}
return new PlotBlock((short) block.getTypeId(), block.getData());
}

View file

@ -558,7 +558,7 @@ public class JSONArray {
* @return this.
*/
public JSONArray put(final int value) {
this.put(new Integer(value));
this.put(Integer.valueOf(value));
return this;
}
@ -570,7 +570,7 @@ public class JSONArray {
* @return this.
*/
public JSONArray put(final long value) {
this.put(new Long(value));
this.put(Long.valueOf(value));
return this;
}
@ -658,7 +658,7 @@ public class JSONArray {
* @throws JSONException If the index is negative.
*/
public JSONArray put(final int index, final int value) throws JSONException {
this.put(index, new Integer(value));
this.put(index, Integer.valueOf(value));
return this;
}
@ -674,7 +674,7 @@ public class JSONArray {
* @throws JSONException If the index is negative.
*/
public JSONArray put(final int index, final long value) throws JSONException {
this.put(index, new Long(value));
this.put(index, Long.valueOf(value));
return this;
}

View file

@ -452,7 +452,7 @@ public class JSONObject {
return d;
}
} else {
final Long myLong = new Long(string);
final Long myLong = Long.valueOf(string);
if (string.equals(myLong.toString())) {
if (myLong == myLong.intValue()) {
return myLong.intValue();

View file

@ -8,18 +8,19 @@ import java.util.Iterator;
* @author JSON.org
* @version 2014-05-03
*/
public class XML {
public static final Character AMP = '&';
public static final Character APOS = '\'';
public static final Character BANG = '!';
public static final Character EQ = '=';
public static final Character GT = '>';
public static final Character LT = '<';
public static final Character QUEST = '?';
public static final Character QUOT = '"';
public static final Character SLASH = '/';
public static String escape(final String string) {
class XML {
static final Character AMP = '&';
static final Character APOS = '\'';
static final Character BANG = '!';
static final Character EQ = '=';
static final Character GT = '>';
static final Character LT = '<';
static final Character QUEST = '?';
static final Character QUOT = '"';
static final Character SLASH = '/';
static String escape(final String string) {
final StringBuilder sb = new StringBuilder(string.length());
for (int i = 0, length = string.length(); i < length; i++) {
final char c = string.charAt(i);
@ -53,14 +54,13 @@ public class XML {
*
* @throws JSONException
*/
public static void noSpace(final String string) throws JSONException {
int i;
static void noSpace(final String string) throws JSONException {
final int length = string.length();
if (length == 0) {
throw new JSONException("Empty string.");
}
for (i = 0; i < length; i += 1) {
if (Character.isWhitespace(string.charAt(i))) {
for (char c : string.toCharArray()) {
if (Character.isWhitespace(c)) {
throw new JSONException("'" + string + "' contains a space character.");
}
}
@ -78,12 +78,6 @@ public class XML {
* @throws JSONException
*/
private static boolean parse(final XMLTokener x, final JSONObject context, final String name) throws JSONException {
char c;
int i;
JSONObject jsonobject = null;
String string;
String tagName;
Object token;
// Test for and skip past these forms:
// <!-- ... -->
// <! ... >
@ -93,10 +87,11 @@ public class XML {
// <>
// <=
// <<
token = x.nextToken();
Object token = x.nextToken();
// <!
String string;
if (token == BANG) {
c = x.next();
char c = x.next();
if (c == '-') {
if (x.next() == '-') {
x.skipPast("-->");
@ -116,7 +111,7 @@ public class XML {
}
throw x.syntaxError("Expected 'CDATA['");
}
i = 1;
int i = 1;
do {
token = x.nextMeta();
if (token == null) {
@ -149,9 +144,9 @@ public class XML {
throw x.syntaxError("Misshaped tag");
// Open tag <
} else {
tagName = (String) token;
String tagName = (String) token;
token = null;
jsonobject = new JSONObject();
JSONObject jsonobject = new JSONObject();
for (;;) {
if (token == null) {
token = x.nextToken();
@ -225,7 +220,7 @@ public class XML {
*
* @return A simple JSON value.
*/
public static Object stringToValue(final String string) {
static Object stringToValue(final String string) {
if ("true".equalsIgnoreCase(string)) {
return Boolean.TRUE;
}
@ -292,12 +287,8 @@ public class XML {
final StringBuilder sb = new StringBuilder();
int i;
JSONArray ja;
JSONObject jo;
String key;
Iterator<String> keys;
int length;
String string;
Object value;
if (object instanceof JSONObject) {
// Emit <tagName>
if (tagName != null) {
@ -306,11 +297,11 @@ public class XML {
sb.append('>');
}
// Loop thru the keys.
jo = (JSONObject) object;
keys = jo.keys();
JSONObject jo = (JSONObject) object;
Iterator<String> keys = jo.keys();
while (keys.hasNext()) {
key = keys.next();
value = jo.opt(key);
String key = keys.next();
Object value = jo.opt(key);
if (value == null) {
value = "";
}
@ -378,7 +369,7 @@ public class XML {
}
return sb.toString();
} else {
string = (object == null) ? "null" : escape(object.toString());
string = escape(object.toString());
return (tagName == null) ? "\"" + string + "\"" :
(string.isEmpty()) ? "<" + tagName + "/>" : "<" + tagName + ">" + string + "</" + tagName + ">";
}

View file

@ -8,7 +8,11 @@ import com.intellectualcrafters.plot.commands.WE_Anywhere;
import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.config.Configuration;
import com.intellectualcrafters.plot.config.Settings;
import com.intellectualcrafters.plot.database.*;
import com.intellectualcrafters.plot.database.DBFunc;
import com.intellectualcrafters.plot.database.Database;
import com.intellectualcrafters.plot.database.MySQL;
import com.intellectualcrafters.plot.database.SQLManager;
import com.intellectualcrafters.plot.database.SQLite;
import com.intellectualcrafters.plot.flag.AbstractFlag;
import com.intellectualcrafters.plot.flag.FlagManager;
import com.intellectualcrafters.plot.flag.FlagValue;
@ -16,21 +20,67 @@ import com.intellectualcrafters.plot.generator.GeneratorWrapper;
import com.intellectualcrafters.plot.generator.HybridPlotWorld;
import com.intellectualcrafters.plot.generator.HybridUtils;
import com.intellectualcrafters.plot.generator.IndependentPlotGenerator;
import com.intellectualcrafters.plot.object.*;
import com.intellectualcrafters.plot.util.*;
import com.intellectualcrafters.plot.object.Location;
import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.object.PlotAnalysis;
import com.intellectualcrafters.plot.object.PlotArea;
import com.intellectualcrafters.plot.object.PlotCluster;
import com.intellectualcrafters.plot.object.PlotFilter;
import com.intellectualcrafters.plot.object.PlotId;
import com.intellectualcrafters.plot.object.PlotManager;
import com.intellectualcrafters.plot.object.PlotPlayer;
import com.intellectualcrafters.plot.object.RegionWrapper;
import com.intellectualcrafters.plot.object.RunnableVal;
import com.intellectualcrafters.plot.util.AbstractTitle;
import com.intellectualcrafters.plot.util.ChatManager;
import com.intellectualcrafters.plot.util.ChunkManager;
import com.intellectualcrafters.plot.util.CommentManager;
import com.intellectualcrafters.plot.util.EconHandler;
import com.intellectualcrafters.plot.util.EventUtil;
import com.intellectualcrafters.plot.util.ExpireManager;
import com.intellectualcrafters.plot.util.InventoryUtil;
import com.intellectualcrafters.plot.util.MainUtil;
import com.intellectualcrafters.plot.util.MathMan;
import com.intellectualcrafters.plot.util.PlotGamemode;
import com.intellectualcrafters.plot.util.PlotWeather;
import com.intellectualcrafters.plot.util.ReflectionUtils;
import com.intellectualcrafters.plot.util.SchematicHandler;
import com.intellectualcrafters.plot.util.SetQueue;
import com.intellectualcrafters.plot.util.SetupUtils;
import com.intellectualcrafters.plot.util.StringMan;
import com.intellectualcrafters.plot.util.TaskManager;
import com.intellectualcrafters.plot.util.UUIDHandler;
import com.intellectualcrafters.plot.util.WorldUtil;
import com.intellectualcrafters.plot.util.area.QuadMap;
import com.plotsquared.listener.WESubscriber;
import com.sk89q.worldedit.WorldEdit;
import java.io.*;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URISyntaxException;
import java.net.URL;
import java.net.URLConnection;
import java.nio.file.Files;
import java.sql.SQLException;
import java.util.*;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Objects;
import java.util.Set;
import java.util.UUID;
import java.util.regex.Pattern;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
@ -46,12 +96,7 @@ public class PS {
// protected static:
private static PS instance;
private HashSet<Integer> plotareaHashCheck = new HashSet<>();
private boolean plotareaHasCollision = false;
/**
* All plot areas (quick global access)
*/
private PlotArea[] plotareas = new PlotArea[0];
private final HashSet<Integer> plotareaHashCheck = new HashSet<>();
/**
* All plot areas mapped by world (quick world access)
*/
@ -73,6 +118,11 @@ public class PS {
public TaskManager TASK;
public WorldEdit worldedit;
public URL update;
private boolean plotareaHasCollision = false;
/**
* All plot areas (quick global access)
*/
private PlotArea[] plotareas = new PlotArea[0];
// private:
private File storageFile;
private File FILE = null; // This file
@ -1511,7 +1561,7 @@ public class PS {
}
for (String areaId : areasSection.getKeys(false)) {
log(C.PREFIX.s() + "&3 - " + areaId);
String[] split = areaId.split("(?<![;])-");
String[] split = areaId.split("([^\\-]+)(?:-{1})(-{0,1}\\d+\\;-{0,1}\\d+)(?:-{1})(-{0,1}\\d+\\;-{0,1}\\d+)");
if (split.length != 3) {
throw new IllegalArgumentException("Invalid Area identifier: " + areaId + ". Expected form `<name>-<pos1>-<pos2>`");
}
@ -1904,6 +1954,7 @@ public class PS {
FlagManager.addFlag(new AbstractFlag("block-ignition", new FlagValue.BooleanValue()));
FlagManager.addFlag(new AbstractFlag("block-burn", new FlagValue.BooleanValue()));
FlagManager.addFlag(new AbstractFlag("fire-spread", new FlagValue.BooleanValue()));
FlagManager.addFlag(new AbstractFlag("snow-melt", new FlagValue.BooleanValue()));
FlagManager.addFlag(new AbstractFlag("keep") {
@Override
public Object parseValueRaw(final String value) {
@ -2315,7 +2366,7 @@ public class PS {
*/
private void setupStorage() {
storage.set("version", StringMan.join(VERSION, "."));
final Map<String, Object> options = new HashMap<>();
final Map<String, Object> options = new HashMap<>(9);
options.put("mysql.use", false);
options.put("sqlite.use", true);
options.put("sqlite.db", "storage");
@ -2346,7 +2397,7 @@ public class PS {
*/
private void showDebug() {
if (Settings.DEBUG) {
final Map<String, String> settings = new HashMap<>();
final Map<String, String> settings = new HashMap<>(9);
settings.put("Kill Road Mobs", "" + Settings.KILL_ROAD_MOBS);
settings.put("Use Metrics", "" + Settings.METRICS);
settings.put("Delete Plots On Ban", "" + Settings.DELETE_PLOTS_ON_BAN);

View file

@ -7,8 +7,24 @@ import com.intellectualcrafters.plot.config.Configuration;
import com.intellectualcrafters.plot.generator.AugmentedUtils;
import com.intellectualcrafters.plot.generator.HybridGen;
import com.intellectualcrafters.plot.generator.HybridPlotWorld;
import com.intellectualcrafters.plot.object.*;
import com.intellectualcrafters.plot.util.*;
import com.intellectualcrafters.plot.object.ChunkLoc;
import com.intellectualcrafters.plot.object.Location;
import com.intellectualcrafters.plot.object.PlotArea;
import com.intellectualcrafters.plot.object.PlotId;
import com.intellectualcrafters.plot.object.PlotMessage;
import com.intellectualcrafters.plot.object.PlotPlayer;
import com.intellectualcrafters.plot.object.RegionWrapper;
import com.intellectualcrafters.plot.object.RunnableVal;
import com.intellectualcrafters.plot.object.RunnableVal3;
import com.intellectualcrafters.plot.object.SetupObject;
import com.intellectualcrafters.plot.util.ChunkManager;
import com.intellectualcrafters.plot.util.CmdConfirm;
import com.intellectualcrafters.plot.util.MainUtil;
import com.intellectualcrafters.plot.util.MathMan;
import com.intellectualcrafters.plot.util.Permissions;
import com.intellectualcrafters.plot.util.SetupUtils;
import com.intellectualcrafters.plot.util.StringMan;
import com.intellectualcrafters.plot.util.WorldUtil;
import com.plotsquared.general.commands.CommandDeclaration;
import java.io.IOException;
@ -16,14 +32,8 @@ import java.util.ArrayList;
import java.util.Objects;
import java.util.Set;
@CommandDeclaration(
command = "area",
permission = "plots.area",
category = CommandCategory.ADMINISTRATION,
requiredType = RequiredType.NONE,
description = "Create a new PlotArea",
aliases = { "world" },
usage = "/plot area <create|info|list|tp|regen>")
@CommandDeclaration(command = "area", permission = "plots.area", category = CommandCategory.ADMINISTRATION, requiredType = RequiredType.NONE,
description = "Create a new PlotArea", aliases = "world", usage = "/plot area <create|info|list|tp|regen>")
public class Area extends SubCommand {
@Override
@ -48,7 +58,7 @@ public class Area extends SubCommand {
case 2: {
switch (args[1].toLowerCase()) {
case "pos1": { // Set position 1
HybridPlotWorld area = plr.<HybridPlotWorld> getMeta("area_create_area");
HybridPlotWorld area = plr.getMeta("area_create_area");
if (area == null) {
C.COMMAND_SYNTAX.send(plr, "/plot area create [world[:id]] [<modifier>=<value>]...");
return false;
@ -61,13 +71,13 @@ public class Area extends SubCommand {
return true;
}
case "pos2": { // Set position 2 and finish creation for type=2 (partial)
final HybridPlotWorld area = plr.<HybridPlotWorld> getMeta("area_create_area");
final HybridPlotWorld area = plr.getMeta("area_create_area");
if (area == null) {
C.COMMAND_SYNTAX.send(plr, "/plot area create [world[:id]] [<modifier>=<value>]...");
return false;
}
Location pos1 = plr.getLocation();
Location pos2 = plr.<Location> getMeta("area_pos1");
Location pos2 = plr.getMeta("area_pos1");
int dx = Math.abs(pos1.getX() - pos2.getX());
int dz = Math.abs(pos1.getZ() - pos2.getZ());
int numx = Math.max(1, (dx + 1 + area.ROAD_WIDTH + (area.SIZE / 2)) / area.SIZE);

View file

@ -32,14 +32,8 @@ import com.intellectualcrafters.plot.util.MainUtil;
import com.intellectualcrafters.plot.util.Permissions;
import com.plotsquared.general.commands.CommandDeclaration;
@CommandDeclaration(
command = "auto",
permission = "plots.auto",
category = CommandCategory.CLAIMING,
requiredType = RequiredType.NONE,
description = "Claim the nearest plot",
aliases = { "a" },
usage = "/plot auto [length,width]")
@CommandDeclaration(command = "auto", permission = "plots.auto", category = CommandCategory.CLAIMING, requiredType = RequiredType.NONE,
description = "Claim the nearest plot", aliases = "a", usage = "/plot auto [length,width]")
public class Auto extends SubCommand {
public static PlotId getNextPlotId(final PlotId id, final int step) {
@ -149,7 +143,7 @@ public class Auto extends SubCommand {
sendMessage(plr, C.REMOVED_BALANCE, cost + "");
}
}
if (schematic != null && !schematic.equals("")) {
if (schematic != null && !schematic.isEmpty()) {
if (!plotarea.SCHEMATICS.contains(schematic.toLowerCase())) {
sendMessage(plr, C.SCHEMATIC_INVALID, "non-existent: " + schematic);
return true;

View file

@ -31,14 +31,8 @@ import com.intellectualcrafters.plot.util.EconHandler;
import com.intellectualcrafters.plot.util.Permissions;
import com.plotsquared.general.commands.CommandDeclaration;
@CommandDeclaration(
command = "claim",
aliases = { "c" },
description = "Claim the current plot you're standing on",
category = CommandCategory.CLAIMING,
requiredType = RequiredType.NONE,
permission = "plots.claim",
usage = "/plot claim")
@CommandDeclaration(command = "claim", aliases = "c", description = "Claim the current plot you're standing on", category = CommandCategory.CLAIMING,
requiredType = RequiredType.NONE, permission = "plots.claim", usage = "/plot claim")
public class Claim extends SubCommand {
@Override
public boolean onCommand(final PlotPlayer plr, final String... args) {
@ -87,7 +81,7 @@ public class Claim extends SubCommand {
}
sendMessage(plr, C.REMOVED_GRANTED_PLOT, "1", "" + (grants - 1));
}
if (!schematic.equals("")) {
if (!schematic.isEmpty()) {
if (world.SCHEMATIC_CLAIM_SPECIFY) {
if (!world.SCHEMATICS.contains(schematic.toLowerCase())) {
return sendMessage(plr, C.SCHEMATIC_INVALID, "non-existent: " + schematic);

View file

@ -24,7 +24,13 @@ import com.intellectualcrafters.plot.PS;
import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.config.Settings;
import com.intellectualcrafters.plot.database.DBFunc;
import com.intellectualcrafters.plot.object.*;
import com.intellectualcrafters.plot.object.BlockLoc;
import com.intellectualcrafters.plot.object.Location;
import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.object.PlotArea;
import com.intellectualcrafters.plot.object.PlotCluster;
import com.intellectualcrafters.plot.object.PlotId;
import com.intellectualcrafters.plot.object.PlotPlayer;
import com.intellectualcrafters.plot.util.MainUtil;
import com.intellectualcrafters.plot.util.Permissions;
import com.intellectualcrafters.plot.util.UUIDHandler;
@ -35,13 +41,8 @@ import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
@CommandDeclaration(
command = "cluster",
aliases = { "clusters" },
category = CommandCategory.ADMINISTRATION,
requiredType = RequiredType.NONE,
permission = "plots.cluster",
description = "Manage a plot cluster")
@CommandDeclaration(command = "cluster", aliases = "clusters", category = CommandCategory.ADMINISTRATION, requiredType = RequiredType.NONE,
permission = "plots.cluster", description = "Manage a plot cluster")
public class Cluster extends SubCommand {
@Override
@ -379,7 +380,6 @@ public class Cluster extends SubCommand {
for (final Plot plot : new ArrayList<>(PS.get().getPlots(plr.getLocation().getWorld(), uuid))) {
final PlotCluster current = plot.getCluster();
if ((current != null) && current.equals(cluster)) {
plr.getLocation().getWorld();
plot.unclaim();
}
}

View file

@ -94,12 +94,12 @@ public class Condense extends SubCommand {
int size = sizes.get(i);
ArrayList<Plot> array = buckets[size];
if (array == null) {
array = new ArrayList<Plot>();
array = new ArrayList<>();
buckets[size] = array;
}
array.add(plot);
}
final ArrayList<Plot> allPlots = new ArrayList<Plot>(plots.size());
final ArrayList<Plot> allPlots = new ArrayList<>(plots.size());
for (int i = buckets.length - 1; i >= 0; i--) {
ArrayList<Plot> array = buckets[i];
if (array != null) {

View file

@ -20,8 +20,6 @@
////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.plot.commands;
import java.util.UUID;
import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.database.DBFunc;
import com.intellectualcrafters.plot.object.Plot;
@ -32,8 +30,9 @@ import com.intellectualcrafters.plot.object.RunnableVal;
import com.intellectualcrafters.plot.util.MainUtil;
import com.plotsquared.general.commands.CommandDeclaration;
@CommandDeclaration(command = "info", aliases = { "i" }, description = "Display plot info", usage = "/plot info <id>",
category = CommandCategory.INFO)
import java.util.UUID;
@CommandDeclaration(command = "info", aliases = "i", description = "Display plot info", usage = "/plot info <id>", category = CommandCategory.INFO)
public class Info extends SubCommand {
@Override
@ -73,7 +72,7 @@ public class Info extends SubCommand {
plot = player.getCurrentPlot();
}
if (plot == null) {
MainUtil.sendMessage(player, C.NOT_IN_PLOT);
MainUtil.sendMessage(player, C.NOT_IN_PLOT.s());
return false;
}
if (arg != null) {
@ -116,8 +115,8 @@ public class Info extends SubCommand {
boolean trustedEveryone;
// Wildcard player {added}
{
containsEveryone = (plot.getTrusted() != null) && plot.getTrusted().contains(DBFunc.everyone);
trustedEveryone = (plot.getMembers() != null) && plot.getMembers().contains(DBFunc.everyone);
containsEveryone = plot.getTrusted().contains(DBFunc.everyone);
trustedEveryone = plot.getMembers().contains(DBFunc.everyone);
}
// Unclaimed?
if (!hasOwner && !containsEveryone && !trustedEveryone) {

View file

@ -41,7 +41,6 @@ import com.plotsquared.general.commands.CommandManager;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
@ -53,8 +52,7 @@ import java.util.List;
public class MainCommand extends CommandManager<PlotPlayer> {
private static MainCommand instance;
private HashMap<String, Command<PlotPlayer>> setCommands;
private MainCommand() {
super(null, new ArrayList<Command<PlotPlayer>>());
instance = this;
@ -282,8 +280,8 @@ public class MainCommand extends CommandManager<PlotPlayer> {
break;
}
// Save meta
loc = (Location) player.getMeta("location");
plot = (Plot) player.getMeta("lastplot");
loc = player.getMeta("location");
plot = player.getMeta("lastplot");
tp = true;
// Set loc
player.setMeta("location", newPlot.getBottomAbs());
@ -320,7 +318,7 @@ public class MainCommand extends CommandManager<PlotPlayer> {
public int getMatch(String[] args, Command<PlotPlayer> cmd) {
int count = 0;
String perm = cmd.getPermission();
HashSet<String> desc = new HashSet<String>();
HashSet<String> desc = new HashSet<>();
for (String alias : cmd.getAliases()) {
if (alias.startsWith(args[0])) {
count += 5;

View file

@ -89,8 +89,7 @@ public class Merge extends SubCommand {
}
final PlotArea plotworld = plot.getArea();
final double price = plotworld.PRICES.get("merge");
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 + "");
return false;
}
@ -123,7 +122,7 @@ public class Merge extends SubCommand {
terrain = "true".equalsIgnoreCase(args[1]);
}
if (plot.autoMerge(-1, maxSize, uuid, terrain)) {
if (EconHandler.manager != null && price > 0d) {
if (EconHandler.manager != null && plotworld.USE_ECONOMY && price > 0d) {
EconHandler.manager.withdrawMoney(plr, price);
sendMessage(plr, C.REMOVED_BALANCE, price + "");
}

View file

@ -44,14 +44,8 @@ import java.util.HashMap;
import java.util.Map.Entry;
import java.util.UUID;
@CommandDeclaration(
command = "rate",
permission = "plots.rate",
description = "Rate the plot",
usage = "/plot rate [#|next]",
aliases = {"rt"},
category = CommandCategory.INFO,
requiredType = RequiredType.NONE)
@CommandDeclaration(command = "rate", permission = "plots.rate", description = "Rate the plot", usage = "/plot rate [#|next]", aliases = "rt",
category = CommandCategory.INFO, requiredType = RequiredType.NONE)
public class Rate extends SubCommand {
@Override
@ -221,21 +215,23 @@ public class Rate extends SubCommand {
private int value;
public MutableInt(int i) {
MutableInt(int i) {
value = i;
}
public void increment() {
void increment() {
value++;
}
public void decrement() {
void decrement() {
value--;
}
public int getValue() {
int getValue() {
return value;
}
public void add(Number v) {
void add(Number v) {
this.value += v.intValue();
}
}

View file

@ -31,7 +31,14 @@ import com.intellectualcrafters.plot.object.PlotMessage;
import com.intellectualcrafters.plot.object.PlotPlayer;
import com.intellectualcrafters.plot.object.Rating;
import com.intellectualcrafters.plot.object.RunnableVal3;
import com.intellectualcrafters.plot.util.*;
import com.intellectualcrafters.plot.util.EconHandler;
import com.intellectualcrafters.plot.util.ExpireManager;
import com.intellectualcrafters.plot.util.MainUtil;
import com.intellectualcrafters.plot.util.MathMan;
import com.intellectualcrafters.plot.util.Permissions;
import com.intellectualcrafters.plot.util.StringComparison;
import com.intellectualcrafters.plot.util.StringMan;
import com.intellectualcrafters.plot.util.UUIDHandler;
import com.plotsquared.general.commands.CommandDeclaration;
import java.util.ArrayList;
@ -97,7 +104,7 @@ public class list extends SubCommand {
}
public void noArgs(final PlotPlayer plr) {
MainUtil.sendMessage(plr, C.SUBCOMMAND_SET_OPTIONS_HEADER.s() + getArgumentList(plr));
MainUtil.sendMessage(plr, C.SUBCOMMAND_SET_OPTIONS_HEADER.s() + Arrays.toString(getArgumentList(plr)));
}
@Override
@ -228,10 +235,9 @@ public class list extends SubCommand {
@Override
public int compare(final Plot p1, final Plot p2) {
double v1 = 0;
double v2 = 0;
final int p1s = p1.getSettings().ratings != null ? p1.getSettings().ratings.size() : 0;
final int p2s = p2.getSettings().ratings != null ? p2.getSettings().ratings.size() : 0;
if ((p1.getSettings().ratings != null) && (p1s > 0)) {
final int p1s = p1.getSettings().getRatings().size();
final int p2s = p2.getRatings().size();
if (!p1.getSettings().getRatings().isEmpty()) {
for (final Entry<UUID, Rating> entry : p1.getRatings().entrySet()) {
final double av = entry.getValue().getAverageRating();
v1 += av * av;
@ -239,7 +245,8 @@ public class list extends SubCommand {
v1 /= p1s;
v1 += p1s;
}
if ((p2.getSettings().ratings != null) && (p2s > 0)) {
double v2 = 0;
if (!p2.getSettings().getRatings().isEmpty()) {
for (final Entry<UUID, Rating> entry : p2.getRatings().entrySet()) {
final double av = entry.getValue().getAverageRating();
v2 += av * av;
@ -414,14 +421,5 @@ public class list extends SubCommand {
}
}, "/plot list " + args[0], C.PLOT_LIST_HEADER_PAGED.s());
}
private String getArgumentList(final String[] strings) {
final StringBuilder builder = new StringBuilder();
String prefix = "";
for (final String s : strings) {
builder.append(prefix + s);
prefix = " | ";
}
return builder.toString();
}
}

View file

@ -20,6 +20,13 @@
////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.plot.config;
import com.intellectualcrafters.configuration.ConfigurationSection;
import com.intellectualcrafters.configuration.file.YamlConfiguration;
import com.intellectualcrafters.plot.PS;
import com.intellectualcrafters.plot.object.ConsolePlayer;
import com.intellectualcrafters.plot.util.StringMan;
import com.plotsquared.general.commands.CommandCaller;
import java.io.File;
import java.util.EnumSet;
import java.util.HashMap;
@ -28,13 +35,6 @@ import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Set;
import com.intellectualcrafters.configuration.ConfigurationSection;
import com.intellectualcrafters.configuration.file.YamlConfiguration;
import com.intellectualcrafters.plot.PS;
import com.intellectualcrafters.plot.object.ConsolePlayer;
import com.intellectualcrafters.plot.util.StringMan;
import com.plotsquared.general.commands.CommandCaller;
/**
* Captions class.
*
@ -655,9 +655,7 @@ public enum C {
*/
C(final String d, final boolean prefix, final String cat) {
this.d = d;
if (s == null) {
s = d;
}
this.s = d;
this.prefix = prefix;
this.cat = cat.toLowerCase();
}

View file

@ -122,18 +122,10 @@ public class Settings {
* Max allowed plots
*/
public static int MAX_PLOTS = 127;
/**
* WorldGuard region on claimed plots
*/
public static boolean WORLDGUARD = false;
/**
* metrics
*/
public static boolean METRICS = true;
/**
* plot specific resource pack
*/
public static String PLOT_SPECIFIC_RESOURCE_PACK = "";
/**
* Kill road mobs?
*/

View file

@ -20,14 +20,14 @@
////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.plot.database;
import com.intellectualcrafters.plot.PS;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import com.intellectualcrafters.plot.PS;
/**
* Connects to and uses a MySQL database
*
@ -103,8 +103,9 @@ public class MySQL extends Database {
if (checkConnection()) {
openConnection();
}
final Statement statement = connection.createStatement();
return statement.executeQuery(query);
try (Statement statement = connection.createStatement()) {
return statement.executeQuery(query);
}
}
@Override
@ -112,7 +113,8 @@ public class MySQL extends Database {
if (checkConnection()) {
openConnection();
}
final Statement statement = connection.createStatement();
return statement.executeUpdate(query);
try (Statement statement = connection.createStatement()) {
return statement.executeUpdate(query);
}
}
}

View file

@ -25,15 +25,37 @@ import com.intellectualcrafters.plot.PS;
import com.intellectualcrafters.plot.config.Settings;
import com.intellectualcrafters.plot.flag.Flag;
import com.intellectualcrafters.plot.flag.FlagManager;
import com.intellectualcrafters.plot.object.*;
import com.intellectualcrafters.plot.object.BlockLoc;
import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.object.PlotArea;
import com.intellectualcrafters.plot.object.PlotCluster;
import com.intellectualcrafters.plot.object.PlotId;
import com.intellectualcrafters.plot.object.PlotSettings;
import com.intellectualcrafters.plot.object.RunnableVal;
import com.intellectualcrafters.plot.object.comment.PlotComment;
import com.intellectualcrafters.plot.util.MainUtil;
import com.intellectualcrafters.plot.util.StringMan;
import com.intellectualcrafters.plot.util.TaskManager;
import java.sql.*;
import java.util.*;
import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Queue;
import java.util.Set;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.atomic.AtomicInteger;
@ -1224,9 +1246,6 @@ public class SQLManager implements AbstractDB {
@Override
public void deleteSettings(final Plot plot) {
if (plot.settings == null) {
return;
}
addPlotTask(plot, new UniqueStatement("delete_plot_settings") {
@Override
public void set(final PreparedStatement stmt) throws SQLException {
@ -1669,10 +1688,7 @@ public class SQLManager implements AbstractDB {
}
final Plot plot = plots.get(id);
if (plot != null) {
if (plot.getSettings().ratings == null) {
plot.getSettings().ratings = new HashMap<>();
}
plot.getSettings().ratings.put(user, r.getInt("rating"));
plot.getSettings().getRatings().put(user, r.getInt("rating"));
} else if (Settings.AUTO_PURGE) {
toDelete.add(id);
} else {
@ -2561,7 +2577,8 @@ public class SQLManager implements AbstractDB {
try {
BlockLoc loc = BlockLoc.fromString(pos);
cluster.settings.setPosition(loc);
} catch (final Exception e) {}
} catch (final Exception ignored) {
}
}
final Integer m = r.getInt("merged");
final boolean[] merged = new boolean[4];

View file

@ -20,6 +20,8 @@
////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.plot.database;
import com.intellectualcrafters.plot.PS;
import java.io.File;
import java.io.IOException;
import java.sql.Connection;
@ -28,11 +30,10 @@ import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import com.intellectualcrafters.plot.PS;
/**
* Connects to and uses a SQLite database
*
*
* @author tips48
*/
public class SQLite extends Database {
@ -94,8 +95,9 @@ public class SQLite extends Database {
if (checkConnection()) {
openConnection();
}
final Statement statement = connection.createStatement();
return statement.executeQuery(query);
try (Statement statement = connection.createStatement()) {
return statement.executeQuery(query);
}
}
@Override
@ -103,8 +105,9 @@ public class SQLite extends Database {
if (checkConnection()) {
openConnection();
}
final Statement statement = connection.createStatement();
return statement.executeUpdate(query);
try (Statement statement = connection.createStatement()) {
return statement.executeUpdate(query);
}
}
@Override

View file

@ -97,16 +97,6 @@ public class HybridPlotWorld extends ClassicPlotWorld {
case 163:
case 164:
case 180:
data = wrap(data, 0);
data = wrap(data, 4);
data = wrap(data, 8);
data = wrap(data, 12);
return data;
case 26:
case 86:
data = wrap(data, 0);
return data;
case 64:
case 71:
case 193:
@ -127,6 +117,11 @@ public class HybridPlotWorld extends ClassicPlotWorld {
data = wrap(data, 8);
data = wrap(data, 12);
return data;
case 26:
case 86:
data = wrap(data, 0);
return data;
case 28:
case 66:
case 157:

View file

@ -115,9 +115,7 @@ public abstract class SquarePlotManager extends GridPlotManager {
end = pathWidthLower + dpw.PLOT_WIDTH;
}
int dx;
int dz;
int rx;
int rz;
if (x < 0) {
dx = (x / size);
rx = size + (x % size);
@ -125,6 +123,8 @@ public abstract class SquarePlotManager extends GridPlotManager {
dx = (x / size) + 1;
rx = (x % size);
}
int dz;
int rz;
if (z < 0) {
dz = (z / size);
rz = size + (z % size);

View file

@ -29,18 +29,34 @@ import com.intellectualcrafters.plot.config.Settings;
import com.intellectualcrafters.plot.database.DBFunc;
import com.intellectualcrafters.plot.flag.Flag;
import com.intellectualcrafters.plot.flag.FlagManager;
import com.intellectualcrafters.plot.util.*;
import com.intellectualcrafters.plot.util.BO3Handler;
import com.intellectualcrafters.plot.util.ChunkManager;
import com.intellectualcrafters.plot.util.EventUtil;
import com.intellectualcrafters.plot.util.MainUtil;
import com.intellectualcrafters.plot.util.Permissions;
import com.intellectualcrafters.plot.util.SchematicHandler;
import com.intellectualcrafters.plot.util.SetQueue;
import com.intellectualcrafters.plot.util.TaskManager;
import com.intellectualcrafters.plot.util.UUIDHandler;
import com.intellectualcrafters.plot.util.WorldUtil;
import com.plotsquared.listener.PlotListener;
import java.awt.*;
import java.awt.Rectangle;
import java.awt.geom.Area;
import java.awt.geom.PathIterator;
import java.io.File;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.util.*;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map.Entry;
import java.util.Set;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicInteger;
@ -61,11 +77,9 @@ public class Plot {
private static HashSet<Plot> connected_cache;
private static HashSet<RegionWrapper> regions_cache;
/**
* plot ID
* Direct access is Deprecated: use getId()
* The {@link PlotId}
*/
@Deprecated
public final PlotId id;
private final PlotId id;
/**
* plot owner
* (Merged plots can have multiple owners)
@ -73,39 +87,6 @@ public class Plot {
*/
@Deprecated
public UUID owner;
/**
* Plot creation timestamp (not accurate if the plot was created before this was implemented)<br>
* - Milliseconds since the epoch<br>
* Direct access is Deprecated: use {@link #getTimestamp() getTimestamp}
*/
@Deprecated
public long timestamp;
/**
* List of trusted (with plot permissions)
* Direct access is Deprecated: use getTrusted()
*/
@Deprecated
public HashSet<UUID> trusted;
/**
* List of members users (with plot permissions)
* Direct access is Deprecated: use getMembers()
*/
@Deprecated
public HashSet<UUID> members;
/**
* List of denied players
* Direct access is Deprecated: use getDenied()
*/
@Deprecated
public HashSet<UUID> denied;
/**
* External settings class<br>
* - Please favor the methods over direct access to this class<br>
* - The methods are more likely to be left unchanged from version changes<br>
* Direct access is Deprecated: use getSettings()
*/
@Deprecated
public PlotSettings settings;
/**
* Has the plot changed since the last save cycle?
*/
@ -119,8 +100,30 @@ public class Plot {
@Deprecated
public int temp;
/**
* plot world
* Direct access is Deprecated: use getWorld()
* Plot creation timestamp (not accurate if the plot was created before this was implemented)<br>
* - Milliseconds since the epoch<br>
*/
private long timestamp;
/**
* List of trusted (with plot permissions)
*/
private HashSet<UUID> trusted;
/**
* List of members users (with plot permissions)
*/
private HashSet<UUID> members;
/**
* List of denied players
*/
private HashSet<UUID> denied;
/**
* External settings class<br>
* - Please favor the methods over direct access to this class<br>
* - The methods are more likely to be left unchanged from version changes<br>
*/
private PlotSettings settings;
/**
* The {@link PlotArea}
*/
private PlotArea area;
/**
@ -486,10 +489,7 @@ public class Plot {
* @return
*/
public boolean isBasePlot() {
if ((this.settings == null) || !this.isMerged()) {
return true;
}
return this.equals(this.getBasePlot(false));
return !this.isMerged() || this.equals(this.getBasePlot(false));
}
/**
@ -530,10 +530,7 @@ public class Plot {
* @return
*/
public boolean isMerged() {
if (this.settings == null) {
return false;
}
return this.settings.getMerged(0) || this.settings.getMerged(2) || this.settings.getMerged(1) || this.settings.getMerged(3);
return getSettings().getMerged(0) || getSettings().getMerged(2) || getSettings().getMerged(1) || getSettings().getMerged(3);
}
/**
@ -567,40 +564,41 @@ public class Plot {
* @return true if merged in that direction
*/
public boolean getMerged(final int direction) {
if (this.settings == null) {
return false;
}
switch (direction) {
case 0:
case 1:
case 2:
case 3:
return this.settings.getMerged(direction);
case 7:
int i = direction - 4;
int i2 = 0;
if (this.settings.getMerged(i2)) {
if (this.settings.getMerged(i)) {
if (this.area.getPlotAbs(this.id.getRelative(i)).getMerged(i2)) {
if (this.area.getPlotAbs(this.id.getRelative(i2)).getMerged(i)) {
return true;
if (isMerged()) {
switch (direction) {
case 0:
case 1:
case 2:
case 3:
return this.getSettings().getMerged(direction);
case 7:
int i = direction - 4;
int i2 = 0;
if (this.getSettings().getMerged(i2)) {
if (this.getSettings().getMerged(i)) {
if (this.area.getPlotAbs(this.id.getRelative(i)).getMerged(i2)) {
if (this.area.getPlotAbs(this.id.getRelative(i2)).getMerged(i)) {
return true;
}
}
}
}
}
return false;
case 4:
case 5:
case 6:
i = direction - 4;
i2 = direction - 3;
return this.settings.getMerged(i2)
&& this.settings.getMerged(i)
&& this.area.getPlotAbs(this.id.getRelative(i)).getMerged(i2)
&& this.area.getPlotAbs(this.id.getRelative(i2)).getMerged(i);
return false;
case 4:
case 5:
case 6:
i = direction - 4;
i2 = direction - 3;
return this.getSettings().getMerged(i2)
&& this.getSettings().getMerged(i)
&& this.area.getPlotAbs(this.id.getRelative(i)).getMerged(i2)
&& this.area.getPlotAbs(this.id.getRelative(i2)).getMerged(i);
}
return false;
} else {
return false;
}
return false;
}
/**
@ -1132,16 +1130,12 @@ public class Plot {
*/
public void setHome(final BlockLoc loc) {
final BlockLoc pos = this.getSettings().getPosition();
if ((((pos == null) || pos.equals(new BlockLoc(0, 0, 0))) && (loc == null)) || ((pos != null) && pos.equals(loc))) {
if (pos.equals(new BlockLoc(0, 0, 0)) && loc == null || pos.equals(loc)) {
return;
}
final Plot plot = this.getBasePlot(false);
plot.getSettings().setPosition(loc);
if (plot.getSettings().getPosition() == null) {
DBFunc.setPosition(plot, "");
} else {
DBFunc.setPosition(plot, this.getSettings().getPosition().toString());
}
DBFunc.setPosition(plot, this.getSettings().getPosition().toString());
}
/**
@ -1240,11 +1234,7 @@ public class Plot {
public boolean hasRatings() {
Plot base = this.getBasePlot(false);
if (base.settings != null && base.settings.ratings != null) {
return true;
} else {
return false;
}
return base.settings != null && base.settings.ratings != null;
}
/**
@ -1368,7 +1358,7 @@ public class Plot {
this.getDenied().clear();
this.settings = new PlotSettings();
if (this.area.addPlot(this)) {
DBFunc.createPlotAndSettings(Plot.this, new Runnable() {
DBFunc.createPlotAndSettings(this, new Runnable() {
@Override
public void run() {
final PlotArea plotworld = Plot.this.area;
@ -1910,10 +1900,7 @@ public class Plot {
* @return boolean [ north, east, south, west ]
*/
public boolean[] getMerged() {
if (this.settings == null) {
return new boolean[] { false, false, false, false };
}
return this.settings.getMerged();
return this.getSettings().getMerged();
}
/**
@ -1948,10 +1935,7 @@ public class Plot {
* @return
*/
public BlockLoc getPosition() {
if (this.settings == null) {
return new BlockLoc(0, 0, 0);
}
return this.settings.getPosition();
return this.getSettings().getPosition();
}
/**
@ -2085,7 +2069,7 @@ public class Plot {
}
visited.add(current);
Set<Plot> plots;
if ((max >= 0) && ((dir == -1) || (dir == 0)) && !current.getMerged(0)) {
if ((dir == -1 || (dir == 0)) && !current.getMerged(0)) {
final Plot other = current.getRelative(0);
if ((other != null)
&& other.isOwner(uuid)
@ -2256,10 +2240,10 @@ public class Plot {
PS.debug("Fixing invalid merge: " + this);
if (tmp.isOwnerAbs(owner)) {
tmp.getSettings().setMerged(2, true);
DBFunc.setMerged(tmp, tmp.settings.getMerged());
DBFunc.setMerged(tmp, tmp.getSettings().getMerged());
} else {
this.getSettings().setMerged(0, false);
DBFunc.setMerged(this, this.settings.getMerged());
DBFunc.setMerged(this, this.getSettings().getMerged());
}
}
queuecache.add(tmp);
@ -2272,10 +2256,10 @@ public class Plot {
PS.debug("Fixing invalid merge: " + this);
if (tmp.isOwnerAbs(owner)) {
tmp.getSettings().setMerged(3, true);
DBFunc.setMerged(tmp, tmp.settings.getMerged());
DBFunc.setMerged(tmp, tmp.getSettings().getMerged());
} else {
this.getSettings().setMerged(1, false);
DBFunc.setMerged(this, this.settings.getMerged());
DBFunc.setMerged(this, this.getSettings().getMerged());
}
}
queuecache.add(tmp);
@ -2288,10 +2272,10 @@ public class Plot {
PS.debug("Fixing invalid merge: " + this);
if (tmp.isOwnerAbs(owner)) {
tmp.getSettings().setMerged(0, true);
DBFunc.setMerged(tmp, tmp.settings.getMerged());
DBFunc.setMerged(tmp, tmp.getSettings().getMerged());
} else {
this.getSettings().setMerged(2, false);
DBFunc.setMerged(this, this.settings.getMerged());
DBFunc.setMerged(this, this.getSettings().getMerged());
}
}
queuecache.add(tmp);
@ -2304,10 +2288,10 @@ public class Plot {
PS.debug("Fixing invalid merge: " + this);
if (tmp.isOwnerAbs(owner)) {
tmp.getSettings().setMerged(1, true);
DBFunc.setMerged(tmp, tmp.settings.getMerged());
DBFunc.setMerged(tmp, tmp.getSettings().getMerged());
} else {
this.getSettings().setMerged(3, false);
DBFunc.setMerged(this, this.settings.getMerged());
DBFunc.setMerged(this, this.getSettings().getMerged());
}
}
queuecache.add(tmp);
@ -2324,6 +2308,9 @@ public class Plot {
connected_cache.add(current);
queuecache.remove(current);
merged = current.getMerged();
for (int i = 0; i < 5; i++) {
}
if (merged[0]) {
tmp = current.area.getPlotAbs(current.id.getRelative(0));
if ((tmp != null) && !queuecache.contains(tmp) && !connected_cache.contains(tmp)) {
@ -2794,7 +2781,7 @@ public class Plot {
for (final Plot plot : plots) {
final Plot other = plot.getRelative(offset.x, offset.y);
other.create(other.owner, false);
if ((plot.getFlags() != null) && !plot.getFlags().isEmpty()) {
if (!plot.getFlags().isEmpty()) {
other.getSettings().flags = plot.getFlags();
DBFunc.setFlags(other, plot.getFlags().values());
}

View file

@ -1,41 +1,22 @@
package com.intellectualcrafters.plot.object;
import java.util.HashSet;
import java.util.UUID;
import com.intellectualcrafters.plot.database.DBFunc;
import com.intellectualcrafters.plot.util.MainUtil;
import java.util.HashSet;
import java.util.UUID;
public class PlotCluster {
public PlotArea area;
public PlotSettings settings;
public UUID owner;
public HashSet<UUID> helpers = new HashSet<UUID>();
public HashSet<UUID> invited = new HashSet<UUID>();
public HashSet<UUID> helpers = new HashSet<>();
public HashSet<UUID> invited = new HashSet<>();
public int temp;
private PlotId pos1;
private PlotId pos2;
private RegionWrapper region;
public int temp;
public PlotId getP1() {
return pos1;
}
public PlotId getP2() {
return pos2;
}
public void setP1(final PlotId id) {
pos1 = id;
setRegion();
}
public void setP2(final PlotId id) {
pos2 = id;
setRegion();
}
public PlotCluster(final PlotArea area, final PlotId pos1, final PlotId pos2, final UUID owner) {
this.area = area;
this.pos1 = pos1;
@ -55,6 +36,24 @@ public class PlotCluster {
this.temp = temp;
setRegion();
}
public PlotId getP1() {
return pos1;
}
public void setP1(final PlotId id) {
pos1 = id;
setRegion();
}
public PlotId getP2() {
return pos2;
}
public void setP2(final PlotId id) {
pos2 = id;
setRegion();
}
private void setRegion() {
region = new RegionWrapper(pos1.x, pos2.x, pos1.y, pos2.y);
@ -83,6 +82,14 @@ public class PlotCluster {
public int getArea() {
return ((1 + pos2.x) - pos1.x) * ((1 + pos2.y) - pos1.y);
}
public void setArea(PlotArea plotarea) {
if (this.area != null) {
this.area.removeCluster(this);
}
this.area = plotarea;
plotarea.addCluster(this);
}
@Override
public int hashCode() {
@ -136,7 +143,7 @@ public class PlotCluster {
final PlotId top = getP2();
return new PlotId((bot.x + top.x) / 2, (bot.y + top.y) / 2);
}
public Plot getCenterPlot() {
return area.getPlotAbs(getCenterPlotId());
}
@ -155,14 +162,6 @@ public class PlotCluster {
return (pos1.x <= this.pos2.x) && (pos2.x >= this.pos1.x) && (pos1.y <= this.pos2.y) && (pos2.y >= this.pos1.y);
}
public void setArea(PlotArea plotarea) {
if (this.area != null) {
this.area.removeCluster(this);
}
this.area = plotarea;
plotarea.addCluster(this);
}
public boolean contains(final PlotId id) {
return (pos1.x <= id.x) && (pos1.y <= id.y) && (pos2.x >= id.x) && (pos2.y >= id.y);
}

View file

@ -95,7 +95,7 @@ public class BO3Handler {
BO3 bo3 = map.get(loc);
for (int y = 1; y < height; y++) {
final PlotBlock block = WorldUtil.IMP.getBlock(new Location(plot.getArea().worldname, x, y, z));
if ((block != null) && !contains(cpw.MAIN_BLOCK, block)) {
if (!contains(cpw.MAIN_BLOCK, block)) {
if (bo3 == null) {
bo3 = new BO3(alias, loc);
map.put(loc, bo3);
@ -105,7 +105,7 @@ public class BO3Handler {
}
}
final PlotBlock floor = WorldUtil.IMP.getBlock(new Location(plot.getArea().worldname, x, height, z));
if ((floor != null) && !contains(cpw.TOP_BLOCK, floor)) {
if (!contains(cpw.TOP_BLOCK, floor)) {
if (bo3 == null) {
bo3 = new BO3(alias, loc);
map.put(loc, bo3);
@ -115,7 +115,7 @@ public class BO3Handler {
}
for (int y = height + 1; y < 256; y++) {
final PlotBlock block = WorldUtil.IMP.getBlock(new Location(plot.getArea().worldname, x, y, z));
if ((block != null) && (block.id != 0)) {
if (block.id != 0) {
if (bo3 == null) {
bo3 = new BO3(alias, loc);
map.put(loc, bo3);
@ -205,4 +205,4 @@ public class BO3Handler {
}
return base;
}
}
}

View file

@ -7,7 +7,14 @@ import com.intellectualcrafters.plot.database.DBFunc;
import com.intellectualcrafters.plot.flag.Flag;
import com.intellectualcrafters.plot.flag.FlagManager;
import com.intellectualcrafters.plot.generator.HybridUtils;
import com.intellectualcrafters.plot.object.*;
import com.intellectualcrafters.plot.object.OfflinePlotPlayer;
import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.object.PlotAnalysis;
import com.intellectualcrafters.plot.object.PlotArea;
import com.intellectualcrafters.plot.object.PlotMessage;
import com.intellectualcrafters.plot.object.PlotPlayer;
import com.intellectualcrafters.plot.object.RunnableVal;
import com.intellectualcrafters.plot.object.RunnableVal2;
import java.util.HashSet;
import java.util.Iterator;
@ -20,7 +27,7 @@ public class ExpireManager {
public static ExpireManager IMP;
private static HashSet<Plot> plotsToDelete;
private ConcurrentHashMap<UUID, Long> dates_cache = new ConcurrentHashMap<>();
private final ConcurrentHashMap<UUID, Long> dates_cache = new ConcurrentHashMap<>();
/**
* 0 = stopped, 1 = stopping, 2 = running
*/
@ -154,7 +161,7 @@ public class ExpireManager {
}
return;
}
if (plots.size() == 0) {
if (plots.isEmpty()) {
running = 3;
TaskManager.runTaskLater(new Runnable() {
@Override
@ -165,7 +172,6 @@ public class ExpireManager {
}
}
}, 86400000);
return;
} else {
TaskManager.runTaskLaterAsync(task, Settings.CLEAR_INTERVAL * 20);
}

View file

@ -1,24 +1,56 @@
package com.intellectualcrafters.plot.util;
import com.google.common.collect.Lists;
import com.intellectualcrafters.jnbt.*;
import com.intellectualcrafters.jnbt.ByteArrayTag;
import com.intellectualcrafters.jnbt.CompoundTag;
import com.intellectualcrafters.jnbt.IntTag;
import com.intellectualcrafters.jnbt.ListTag;
import com.intellectualcrafters.jnbt.NBTInputStream;
import com.intellectualcrafters.jnbt.NBTOutputStream;
import com.intellectualcrafters.jnbt.ShortTag;
import com.intellectualcrafters.jnbt.StringTag;
import com.intellectualcrafters.jnbt.Tag;
import com.intellectualcrafters.json.JSONArray;
import com.intellectualcrafters.json.JSONException;
import com.intellectualcrafters.plot.PS;
import com.intellectualcrafters.plot.config.Settings;
import com.intellectualcrafters.plot.flag.Flag;
import com.intellectualcrafters.plot.generator.ClassicPlotWorld;
import com.intellectualcrafters.plot.object.*;
import com.intellectualcrafters.plot.object.ChunkLoc;
import com.intellectualcrafters.plot.object.Location;
import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.object.PlotArea;
import com.intellectualcrafters.plot.object.PlotBlock;
import com.intellectualcrafters.plot.object.RegionWrapper;
import com.intellectualcrafters.plot.object.RunnableVal;
import com.intellectualcrafters.plot.object.schematic.PlotItem;
import java.io.*;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLConnection;
import java.nio.channels.Channels;
import java.nio.channels.ReadableByteChannel;
import java.nio.charset.StandardCharsets;
import java.util.*;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
import java.util.zip.GZIPInputStream;
import java.util.zip.GZIPOutputStream;
@ -35,7 +67,7 @@ public abstract class SchematicHandler {
return false;
}
exportAll = true;
final ArrayList<Plot> plots = new ArrayList<Plot>(collection);
final ArrayList<Plot> plots = new ArrayList<>(collection);
TaskManager.runTask(new Runnable() {
@Override
public void run() {
@ -661,14 +693,14 @@ public abstract class SchematicHandler {
getCompoundTag(plot.getArea().worldname, plot.getRegions(), new RunnableVal<CompoundTag>() {
@Override
public void run(CompoundTag value) {
if (plot.getFlags().size() > 0) {
if (!plot.getFlags().isEmpty()) {
HashMap<String, Tag> flagMap = new HashMap<>();
for (Map.Entry<String, Flag> entry : plot.getFlags().entrySet()) {
String key = entry.getKey();
flagMap.put(key, new StringTag(key, entry.getValue().getValueString()));
}
CompoundTag tag = new CompoundTag("Flags", flagMap);
HashMap<String, Tag> map = new HashMap<String, Tag>(value.getValue());
HashMap<String, Tag> map = new HashMap<>(value.getValue());
map.put("Flags", tag);
value.setValue(map);
}
@ -716,9 +748,8 @@ public abstract class SchematicHandler {
// Lossy but fast
private final short[] ids;
private final byte[] datas;
private Map<String, Tag> flags;
private final Dimension schematicDimension;
private Map<String, Tag> flags;
private HashSet<PlotItem> items;
public Schematic(final short[] i, final byte[] b, final Dimension d, Map<String, Tag> flags) {

View file

@ -44,7 +44,7 @@ public class StringMan {
if (obj == null) {
return "null";
}
if (obj.getClass() == String.class) {
if (obj instanceof String) {
return (String) obj;
}
if (obj.getClass().isArray()) {
@ -124,7 +124,7 @@ public class StringMan {
public static boolean isAlphanumericUnd(final String str) {
for (int i = 0; i < str.length(); i++) {
final char c = str.charAt(i);
if ((c < 0x30) || ((c >= 0x3a) && (c <= 0x40)) || ((c > 0x5a) && (c <= 0x60)) || (c > 0x7a) || (c == '_')) {
if (c < 0x30 || (c >= 0x3a) && (c <= 0x40) || (c > 0x5a) && (c <= 0x60) || (c > 0x7a)) {
return false;
}
}

View file

@ -6,16 +6,14 @@ import com.plotsquared.general.commands.Argument;
import com.plotsquared.general.commands.Command;
public class HelpObject {
private final Command _command;
private final String _rendered;
public HelpObject(final Command command, final String label) {
_command = command;
_rendered = StringMan.replaceAll(C.HELP_ITEM.s(), "%usage%", _command.getUsage().replaceAll("\\{label\\}", label), "[%alias%]",
!_command.getAliases().isEmpty() ? "(" + StringMan.join(_command.getAliases(), "|") + ")" : "", "%desc%", _command.getDescription(),
_rendered = StringMan.replaceAll(C.HELP_ITEM.s(), "%usage%", command.getUsage().replaceAll("\\{label\\}", label), "[%alias%]",
!command.getAliases().isEmpty() ? "(" + StringMan.join(command.getAliases(), "|") + ")" : "", "%desc%", command.getDescription(),
"%arguments%",
buildArgumentList(_command.getRequiredArguments()), "{label}", label);
buildArgumentList(command.getRequiredArguments()), "{label}", label);
}
@Override

View file

@ -155,9 +155,6 @@ public abstract class Command<E extends CommandCaller> extends CommandManager {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}