mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-22 21:26:45 +01:00
OCD
This commit is contained in:
parent
d0622eb87d
commit
6007f040cd
@ -170,11 +170,11 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void registerCommands() {
|
public void registerCommands() {
|
||||||
BukkitCommand bcmd = new BukkitCommand();
|
BukkitCommand bukkitCommand = new BukkitCommand();
|
||||||
PluginCommand plotCommand = getCommand("plots");
|
PluginCommand plotCommand = getCommand("plots");
|
||||||
plotCommand.setExecutor(bcmd);
|
plotCommand.setExecutor(bukkitCommand);
|
||||||
plotCommand.setAliases(Arrays.asList("p", "ps", "plotme", "plot"));
|
plotCommand.setAliases(Arrays.asList("p", "ps", "plotme", "plot"));
|
||||||
plotCommand.setTabCompleter(bcmd);
|
plotCommand.setTabCompleter(bukkitCommand);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -225,7 +225,7 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
|
|||||||
case WITHER_SKULL:
|
case WITHER_SKULL:
|
||||||
case UNKNOWN:
|
case UNKNOWN:
|
||||||
case PLAYER: {
|
case PLAYER: {
|
||||||
// non moving / unremovable
|
// non moving / unmovable
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
case THROWN_EXP_BOTTLE:
|
case THROWN_EXP_BOTTLE:
|
||||||
|
@ -107,9 +107,9 @@ public class DebugUUID extends SubCommand {
|
|||||||
worlds.add("world");
|
worlds.add("world");
|
||||||
HashSet<UUID> uuids = new HashSet<>();
|
HashSet<UUID> uuids = new HashSet<>();
|
||||||
HashSet<String> names = new HashSet<>();
|
HashSet<String> names = new HashSet<>();
|
||||||
for (String worldname : worlds) {
|
for (String worldName : worlds) {
|
||||||
File playerdataFolder = new File(worldname + File.separator + "playerdata");
|
File playerDataFolder = new File(worldName + File.separator + "playerdata");
|
||||||
String[] dat = playerdataFolder.list(new FilenameFilter() {
|
String[] dat = playerDataFolder.list(new FilenameFilter() {
|
||||||
@Override
|
@Override
|
||||||
public boolean accept(File f, String s) {
|
public boolean accept(File f, String s) {
|
||||||
return s.endsWith(".dat");
|
return s.endsWith(".dat");
|
||||||
@ -126,7 +126,7 @@ public class DebugUUID extends SubCommand {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
File playersFolder = new File(worldname + File.separator + "players");
|
File playersFolder = new File(worldName + File.separator + "players");
|
||||||
dat = playersFolder.list(new FilenameFilter() {
|
dat = playersFolder.list(new FilenameFilter() {
|
||||||
@Override
|
@Override
|
||||||
public boolean accept(File f, String s) {
|
public boolean accept(File f, String s) {
|
||||||
@ -286,7 +286,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 e) {
|
||||||
MainUtil.sendMessage(player, "Could not save configuration. It will need to be manuall set!");
|
MainUtil.sendMessage(player, "Could not save configuration. It will need to be manual set!");
|
||||||
}
|
}
|
||||||
|
|
||||||
MainUtil.sendMessage(player, "&7 - Populating tables");
|
MainUtil.sendMessage(player, "&7 - Populating tables");
|
||||||
|
@ -154,8 +154,8 @@ public class ClassicPlotMeConnector extends APlotMeConnector {
|
|||||||
for (Entry<String, HashMap<PlotId, boolean[]>> entry : merges.entrySet()) {
|
for (Entry<String, HashMap<PlotId, boolean[]>> entry : merges.entrySet()) {
|
||||||
String world = entry.getKey();
|
String world = entry.getKey();
|
||||||
for (Entry<PlotId, boolean[]> entry2 : entry.getValue().entrySet()) {
|
for (Entry<PlotId, boolean[]> entry2 : entry.getValue().entrySet()) {
|
||||||
HashMap<PlotId, Plot> newplots = plots.get(world);
|
HashMap<PlotId, Plot> newPlots = plots.get(world);
|
||||||
Plot plot = newplots.get(entry2.getKey());
|
Plot plot = newPlots.get(entry2.getKey());
|
||||||
if (plot != null) {
|
if (plot != null) {
|
||||||
plot.setMerged(entry2.getValue());
|
plot.setMerged(entry2.getValue());
|
||||||
}
|
}
|
||||||
|
@ -45,9 +45,9 @@ public class LikePlotMeConverter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static String getWorld(String world) {
|
public static String getWorld(String world) {
|
||||||
for (World newworld : Bukkit.getWorlds()) {
|
for (World newWorld : Bukkit.getWorlds()) {
|
||||||
if (newworld.getName().equalsIgnoreCase(world)) {
|
if (newWorld.getName().equalsIgnoreCase(world)) {
|
||||||
return newworld.getName();
|
return newWorld.getName();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return world;
|
return world;
|
||||||
@ -205,11 +205,11 @@ public class LikePlotMeConverter {
|
|||||||
PS.get().config.set("worlds." + world + ".road.height", pathheight);
|
PS.get().config.set("worlds." + world + ".road.height", pathheight);
|
||||||
PS.get().config.set("worlds." + world + ".wall.height", pathheight);
|
PS.get().config.set("worlds." + world + ".wall.height", pathheight);
|
||||||
PS.get().config.set("worlds." + world + ".plot.height", pathheight);
|
PS.get().config.set("worlds." + world + ".plot.height", pathheight);
|
||||||
Integer plotsize = plotmeDgYml.getInt("worlds." + plotMeWorldName + ".PlotSize"); //
|
Integer plotSize = plotmeDgYml.getInt("worlds." + plotMeWorldName + ".PlotSize"); //
|
||||||
if (plotsize == 0) {
|
if (plotSize == 0) {
|
||||||
plotsize = 32;
|
plotSize = 32;
|
||||||
}
|
}
|
||||||
PS.get().config.set("worlds." + world + ".plot.size", plotsize);
|
PS.get().config.set("worlds." + world + ".plot.size", plotSize);
|
||||||
String wallblock = plotmeDgYml.getString("worlds." + plotMeWorldName + ".WallBlock", "44"); //
|
String wallblock = plotmeDgYml.getString("worlds." + plotMeWorldName + ".WallBlock", "44"); //
|
||||||
PS.get().config.set("worlds." + world + ".wall.block", wallblock);
|
PS.get().config.set("worlds." + world + ".wall.block", wallblock);
|
||||||
String floor = plotmeDgYml.getString("worlds." + plotMeWorldName + ".PlotFloorBlock", "2"); //
|
String floor = plotmeDgYml.getString("worlds." + plotMeWorldName + ".PlotFloorBlock", "2"); //
|
||||||
@ -310,10 +310,10 @@ public class LikePlotMeConverter {
|
|||||||
.isEnabled()) {
|
.isEnabled()) {
|
||||||
mw = true;
|
mw = true;
|
||||||
}
|
}
|
||||||
for (String worldname : worlds) {
|
for (String worldName : worlds) {
|
||||||
World world = Bukkit.getWorld(getWorld(worldname));
|
World world = Bukkit.getWorld(getWorld(worldName));
|
||||||
if (world == null) {
|
if (world == null) {
|
||||||
sendMessage("&cInvalid world in PlotMe configuration: " + worldname);
|
sendMessage("&cInvalid world in PlotMe configuration: " + worldName);
|
||||||
}
|
}
|
||||||
String actualWorldName = world.getName();
|
String actualWorldName = world.getName();
|
||||||
sendMessage("Reloading generator for world: '" + actualWorldName + "'...");
|
sendMessage("Reloading generator for world: '" + actualWorldName + "'...");
|
||||||
@ -344,8 +344,8 @@ public class LikePlotMeConverter {
|
|||||||
// Load using Bukkit API
|
// Load using Bukkit API
|
||||||
// - User must set generator manually
|
// - User must set generator manually
|
||||||
Bukkit.getServer().unloadWorld(world, true);
|
Bukkit.getServer().unloadWorld(world, true);
|
||||||
World myworld = WorldCreator.name(actualWorldName).generator(new BukkitPlotGenerator(new HybridGen())).createWorld();
|
World myWorld = WorldCreator.name(actualWorldName).generator(new BukkitPlotGenerator(new HybridGen())).createWorld();
|
||||||
myworld.save();
|
myWorld.save();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (CommandException e) {
|
} catch (CommandException e) {
|
||||||
|
@ -111,8 +111,8 @@ public class ChunkListener implements Listener {
|
|||||||
if (!PS.get().hasPlotArea(name)) {
|
if (!PS.get().hasPlotArea(name)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
boolean autosave = world.isAutoSave();
|
boolean autoSave = world.isAutoSave();
|
||||||
if (autosave) {
|
if (autoSave) {
|
||||||
world.setAutoSave(false);
|
world.setAutoSave(false);
|
||||||
}
|
}
|
||||||
HashMap<ChunkLoc, Integer> map = players.get(name);
|
HashMap<ChunkLoc, Integer> map = players.get(name);
|
||||||
@ -142,7 +142,7 @@ public class ChunkListener implements Listener {
|
|||||||
time = 1;
|
time = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!Settings.CHUNK_PROCESSOR_TRIM_ON_SAVE && autosave) {
|
if (!Settings.CHUNK_PROCESSOR_TRIM_ON_SAVE && autoSave) {
|
||||||
world.setAutoSave(true);
|
world.setAutoSave(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -636,22 +636,22 @@ public class PlayerEvents extends PlotListener implements Listener {
|
|||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||||
public void onBigBoom(EntityExplodeEvent event) {
|
public void onBigBoom(EntityExplodeEvent event) {
|
||||||
Location loc = BukkitUtil.getLocation(event.getLocation());
|
Location location = BukkitUtil.getLocation(event.getLocation());
|
||||||
PlotArea area = loc.getPlotArea();
|
PlotArea area = location.getPlotArea();
|
||||||
if (area == null) {
|
if (area == null) {
|
||||||
if (!PS.get().hasPlotArea(loc.getWorld())) {
|
if (!PS.get().hasPlotArea(location.getWorld())) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Iterator<Block> iter = event.blockList().iterator();
|
Iterator<Block> iterator = event.blockList().iterator();
|
||||||
while (iter.hasNext()) {
|
while (iterator.hasNext()) {
|
||||||
iter.next();
|
iterator.next();
|
||||||
if (loc.getPlotArea() != null) {
|
if (location.getPlotArea() != null) {
|
||||||
iter.remove();
|
iterator.remove();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Plot plot = area.getOwnedPlot(loc);
|
Plot plot = area.getOwnedPlot(location);
|
||||||
if (plot != null) {
|
if (plot != null) {
|
||||||
if (FlagManager.isPlotFlagTrue(plot, "explosion")) {
|
if (FlagManager.isPlotFlagTrue(plot, "explosion")) {
|
||||||
List<MetadataValue> meta = event.getEntity().getMetadata("plot");
|
List<MetadataValue> meta = event.getEntity().getMetadata("plot");
|
||||||
@ -672,12 +672,12 @@ public class PlayerEvents extends PlotListener implements Listener {
|
|||||||
}
|
}
|
||||||
this.lastRadius = 0;
|
this.lastRadius = 0;
|
||||||
}
|
}
|
||||||
Iterator<Block> iter = event.blockList().iterator();
|
Iterator<Block> iterator = event.blockList().iterator();
|
||||||
while (iter.hasNext()) {
|
while (iterator.hasNext()) {
|
||||||
Block b = iter.next();
|
Block block = iterator.next();
|
||||||
loc = BukkitUtil.getLocation(b.getLocation());
|
location = BukkitUtil.getLocation(block.getLocation());
|
||||||
if (!area.contains(loc.getX(), loc.getZ()) || !origin.equals(area.getOwnedPlot(loc))) {
|
if (!area.contains(location.getX(), location.getZ()) || !origin.equals(area.getOwnedPlot(location))) {
|
||||||
iter.remove();
|
iterator.remove();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
@ -1267,8 +1267,8 @@ public class PlayerEvents extends PlotListener implements Listener {
|
|||||||
}
|
}
|
||||||
Block block = event.getBlock();
|
Block block = event.getBlock();
|
||||||
World world = block.getWorld();
|
World world = block.getWorld();
|
||||||
String worldname = world.getName();
|
String worldName = world.getName();
|
||||||
if (!PS.get().hasPlotArea(worldname)) {
|
if (!PS.get().hasPlotArea(worldName)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Location loc = BukkitUtil.getLocation(block.getLocation());
|
Location loc = BukkitUtil.getLocation(block.getLocation());
|
||||||
@ -1382,7 +1382,7 @@ public class PlayerEvents extends PlotListener implements Listener {
|
|||||||
case LIGHTNING:
|
case LIGHTNING:
|
||||||
case WITHER_SKULL:
|
case WITHER_SKULL:
|
||||||
case UNKNOWN:
|
case UNKNOWN:
|
||||||
// non moving / unremovable
|
// non moving / unmovable
|
||||||
return checkEntity(plot, "entity-cap");
|
return checkEntity(plot, "entity-cap");
|
||||||
case ITEM_FRAME:
|
case ITEM_FRAME:
|
||||||
case PAINTING:
|
case PAINTING:
|
||||||
@ -1540,17 +1540,17 @@ public class PlayerEvents extends PlotListener implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
} else if (event.getIgnitingBlock() != null) {
|
} else if (event.getIgnitingBlock() != null) {
|
||||||
Block igniter = event.getIgnitingBlock();
|
Block ignitingBlock = event.getIgnitingBlock();
|
||||||
if (igniteCause == BlockIgniteEvent.IgniteCause.FLINT_AND_STEEL) {
|
if (igniteCause == BlockIgniteEvent.IgniteCause.FLINT_AND_STEEL) {
|
||||||
if (plot == null || !FlagManager.isPlotFlagTrue(plot, "block-ignition")) {
|
if (plot == null || !FlagManager.isPlotFlagTrue(plot, "block-ignition")) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (BukkitUtil.getLocation(igniter.getLocation()).getPlot() == null) {
|
if (BukkitUtil.getLocation(ignitingBlock.getLocation()).getPlot() == null) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!BukkitUtil.getLocation(igniter.getLocation()).getPlot().equals(plot)) {
|
if (!BukkitUtil.getLocation(ignitingBlock.getLocation()).getPlot().equals(plot)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -1560,11 +1560,11 @@ public class PlayerEvents extends PlotListener implements Listener {
|
|||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (BukkitUtil.getLocation(igniter.getLocation()).getPlot() == null) {
|
if (BukkitUtil.getLocation(ignitingBlock.getLocation()).getPlot() == null) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!BukkitUtil.getLocation(igniter.getLocation()).getPlot().equals(plot)) {
|
if (!BukkitUtil.getLocation(ignitingBlock.getLocation()).getPlot().equals(plot)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -25,11 +25,11 @@ public class PlayerEvents183 implements Listener {
|
|||||||
}
|
}
|
||||||
PlotArea area = loc.getPlotArea();
|
PlotArea area = loc.getPlotArea();
|
||||||
if (area == null) {
|
if (area == null) {
|
||||||
Iterator<Block> iter = event.blockList().iterator();
|
Iterator<Block> iterator = event.blockList().iterator();
|
||||||
while (iter.hasNext()) {
|
while (iterator.hasNext()) {
|
||||||
loc = BukkitUtil.getLocation(iter.next().getLocation());
|
loc = BukkitUtil.getLocation(iterator.next().getLocation());
|
||||||
if (loc.getPlotArea() != null) {
|
if (loc.getPlotArea() != null) {
|
||||||
iter.remove();
|
iterator.remove();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
@ -38,11 +38,11 @@ public class PlayerEvents183 implements Listener {
|
|||||||
if (plot == null || !FlagManager.isPlotFlagTrue(plot, "explosion")) {
|
if (plot == null || !FlagManager.isPlotFlagTrue(plot, "explosion")) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
Iterator<Block> iter = event.blockList().iterator();
|
Iterator<Block> iterator = event.blockList().iterator();
|
||||||
while (iter.hasNext()) {
|
while (iterator.hasNext()) {
|
||||||
Block b = iter.next();
|
Block b = iterator.next();
|
||||||
if (!plot.equals(area.getOwnedPlot(BukkitUtil.getLocation(b.getLocation())))) {
|
if (!plot.equals(area.getOwnedPlot(BukkitUtil.getLocation(b.getLocation())))) {
|
||||||
iter.remove();
|
iterator.remove();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,10 +8,6 @@ import com.plotsquared.bukkit.events.PlayerEnterPlotEvent;
|
|||||||
import com.plotsquared.bukkit.events.PlayerLeavePlotEvent;
|
import com.plotsquared.bukkit.events.PlayerLeavePlotEvent;
|
||||||
import com.plotsquared.bukkit.util.BukkitUtil;
|
import com.plotsquared.bukkit.util.BukkitUtil;
|
||||||
import com.plotsquared.listener.PlotListener;
|
import com.plotsquared.listener.PlotListener;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.Map.Entry;
|
|
||||||
import java.util.UUID;
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.GameMode;
|
import org.bukkit.GameMode;
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
@ -26,6 +22,11 @@ import org.bukkit.event.player.PlayerPickupItemEvent;
|
|||||||
import org.bukkit.event.player.PlayerQuitEvent;
|
import org.bukkit.event.player.PlayerQuitEvent;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.Map.Entry;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
public class PlotPlusListener extends PlotListener implements Listener {
|
public class PlotPlusListener extends PlotListener implements Listener {
|
||||||
|
|
||||||
private static final HashMap<String, Interval> feedRunnable = new HashMap<>();
|
private static final HashMap<String, Interval> feedRunnable = new HashMap<>();
|
||||||
@ -36,15 +37,15 @@ public class PlotPlusListener extends PlotListener implements Listener {
|
|||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if (!healRunnable.isEmpty()) {
|
if (!healRunnable.isEmpty()) {
|
||||||
for (Iterator<Entry<String, Interval>> iter = healRunnable.entrySet().iterator(); iter.hasNext(); ) {
|
for (Iterator<Entry<String, Interval>> iterator = healRunnable.entrySet().iterator(); iterator.hasNext(); ) {
|
||||||
Entry<String, Interval> entry = iter.next();
|
Entry<String, Interval> entry = iterator.next();
|
||||||
Interval value = entry.getValue();
|
Interval value = entry.getValue();
|
||||||
++value.count;
|
++value.count;
|
||||||
if (value.count == value.interval) {
|
if (value.count == value.interval) {
|
||||||
value.count = 0;
|
value.count = 0;
|
||||||
Player player = Bukkit.getPlayer(entry.getKey());
|
Player player = Bukkit.getPlayer(entry.getKey());
|
||||||
if (player == null) {
|
if (player == null) {
|
||||||
iter.remove();
|
iterator.remove();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
double level = player.getHealth();
|
double level = player.getHealth();
|
||||||
@ -55,15 +56,15 @@ public class PlotPlusListener extends PlotListener implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!feedRunnable.isEmpty()) {
|
if (!feedRunnable.isEmpty()) {
|
||||||
for (Iterator<Entry<String, Interval>> iter = feedRunnable.entrySet().iterator(); iter.hasNext(); ) {
|
for (Iterator<Entry<String, Interval>> iterator = feedRunnable.entrySet().iterator(); iterator.hasNext(); ) {
|
||||||
Entry<String, Interval> entry = iter.next();
|
Entry<String, Interval> entry = iterator.next();
|
||||||
Interval value = entry.getValue();
|
Interval value = entry.getValue();
|
||||||
++value.count;
|
++value.count;
|
||||||
if (value.count == value.interval) {
|
if (value.count == value.interval) {
|
||||||
value.count = 0;
|
value.count = 0;
|
||||||
Player player = Bukkit.getPlayer(entry.getKey());
|
Player player = Bukkit.getPlayer(entry.getKey());
|
||||||
if (player == null) {
|
if (player == null) {
|
||||||
iter.remove();
|
iterator.remove();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
int level = player.getFoodLevel();
|
int level = player.getFoodLevel();
|
||||||
|
@ -182,7 +182,7 @@ public class EntityWrapper {
|
|||||||
storeLiving((LivingEntity) entity);
|
storeLiving((LivingEntity) entity);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// END AMEABLE //
|
// END TAMEABLE //
|
||||||
case SHEEP: {
|
case SHEEP: {
|
||||||
Sheep sheep = (Sheep) entity;
|
Sheep sheep = (Sheep) entity;
|
||||||
this.dataByte = (byte) (sheep.isSheared() ? 1 : 0);
|
this.dataByte = (byte) (sheep.isSheared() ? 1 : 0);
|
||||||
|
@ -275,9 +275,9 @@ public class BukkitHybridUtils extends HybridUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int checkModified(String worldname, int x1, int x2, int y1, int y2, int z1, int z2,
|
public int checkModified(String worldName, int x1, int x2, int y1, int y2, int z1, int z2,
|
||||||
PlotBlock[] blocks) {
|
PlotBlock[] blocks) {
|
||||||
World world = BukkitUtil.getWorld(worldname);
|
World world = BukkitUtil.getWorld(worldName);
|
||||||
int count = 0;
|
int count = 0;
|
||||||
for (int y = y1; y <= y2; y++) {
|
for (int y = y1; y <= y2; y++) {
|
||||||
for (int x = x1; x <= x2; x++) {
|
for (int x = x1; x <= x2; x++) {
|
||||||
@ -301,8 +301,8 @@ public class BukkitHybridUtils extends HybridUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int get_ey(String worldname, int sx, int ex, int sz, int ez, int sy) {
|
public int get_ey(String worldName, int sx, int ex, int sz, int ez, int sy) {
|
||||||
World world = BukkitUtil.getWorld(worldname);
|
World world = BukkitUtil.getWorld(worldName);
|
||||||
int maxY = world.getMaxHeight();
|
int maxY = world.getMaxHeight();
|
||||||
int ey = sy;
|
int ey = sy;
|
||||||
for (int x = sx; x <= ex; x++) {
|
for (int x = sx; x <= ex; x++) {
|
||||||
|
@ -310,7 +310,7 @@ public class BukkitSchematicHandler extends SchematicHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void restoreTag(CompoundTag ct, short x, short y, short z, Schematic schem) {
|
public void restoreTag(CompoundTag ct, short x, short y, short z, Schematic schematic) {
|
||||||
new StateWrapper(ct).restoreTag(x, y, z, schem);
|
new StateWrapper(ct).restoreTag(x, y, z, schematic);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -62,8 +62,8 @@ public class BukkitSetupUtils extends SetupUtils {
|
|||||||
switch (type) {
|
switch (type) {
|
||||||
case 2: {
|
case 2: {
|
||||||
if (object.id != null) {
|
if (object.id != null) {
|
||||||
String areaname = object.id + "-" + object.min + "-" + object.max;
|
String areaName = object.id + "-" + object.min + "-" + object.max;
|
||||||
String areaPath = "areas." + areaname;
|
String areaPath = "areas." + areaName;
|
||||||
if (!worldSection.contains(areaPath)) {
|
if (!worldSection.contains(areaPath)) {
|
||||||
worldSection.createSection(areaPath);
|
worldSection.createSection(areaPath);
|
||||||
}
|
}
|
||||||
|
@ -97,8 +97,8 @@ public class BukkitUtil extends WorldUtil {
|
|||||||
return entity.getWorld().getName();
|
return entity.getWorld().getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<Entity> getEntities(String worldname) {
|
public static List<Entity> getEntities(String worldName) {
|
||||||
return getWorld(worldname).getEntities();
|
return getWorld(worldName).getEntities();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Location getLocation(Entity entity) {
|
public static Location getLocation(Entity entity) {
|
||||||
@ -114,8 +114,8 @@ public class BukkitUtil extends WorldUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isWorld(String world) {
|
public boolean isWorld(String worldName) {
|
||||||
return getWorld(world) != null;
|
return getWorld(worldName) != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -124,8 +124,8 @@ public class BukkitUtil extends WorldUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setSign(String worldname, int x, int y, int z, String[] lines) {
|
public void setSign(String worldName, int x, int y, int z, String[] lines) {
|
||||||
World world = getWorld(worldname);
|
World world = getWorld(worldName);
|
||||||
Block block = world.getBlockAt(x, y, z);
|
Block block = world.getBlockAt(x, y, z);
|
||||||
// block.setType(Material.AIR);
|
// block.setType(Material.AIR);
|
||||||
block.setTypeIdAndData(Material.WALL_SIGN.getId(), (byte) 2, false);
|
block.setTypeIdAndData(Material.WALL_SIGN.getId(), (byte) 2, false);
|
||||||
@ -172,8 +172,8 @@ public class BukkitUtil extends WorldUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void saveWorld(String worldname) {
|
public void saveWorld(String worldName) {
|
||||||
World world = getWorld(worldname);
|
World world = getWorld(worldName);
|
||||||
if (world != null) {
|
if (world != null) {
|
||||||
world.save();
|
world.save();
|
||||||
}
|
}
|
||||||
|
@ -321,7 +321,7 @@ public class Metrics {
|
|||||||
// Construct the post data
|
// Construct the post data
|
||||||
StringBuilder json = new StringBuilder(1024);
|
StringBuilder json = new StringBuilder(1024);
|
||||||
json.append('{');
|
json.append('{');
|
||||||
// The plugin's description file containg all of the plugin data such as name, version, author, etc
|
// The plugin's description file containing all of the plugin data such as name, version, author, etc
|
||||||
appendJSONPair(json, "guid", this.guid);
|
appendJSONPair(json, "guid", this.guid);
|
||||||
appendJSONPair(json, "plugin_version", pluginVersion);
|
appendJSONPair(json, "plugin_version", pluginVersion);
|
||||||
appendJSONPair(json, "server_version", serverVersion);
|
appendJSONPair(json, "server_version", serverVersion);
|
||||||
|
@ -223,7 +223,7 @@ public class NbtFactory {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct a new NBT wrapper from a compound.
|
* Construct a new NBT wrapper from a compound.
|
||||||
* @param nmsCompound - the NBT compund.
|
* @param nmsCompound - the NBT compound.
|
||||||
* @return The wrapper.
|
* @return The wrapper.
|
||||||
*/
|
*/
|
||||||
public static NbtCompound fromCompound(Object nmsCompound) {
|
public static NbtCompound fromCompound(Object nmsCompound) {
|
||||||
@ -247,7 +247,7 @@ public class NbtFactory {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct a wrapper for an NBT tag stored (in memory) in an item stack. This is where
|
* Construct a wrapper for an NBT tag stored (in memory) in an item stack. This is where
|
||||||
* auxillary data such as enchanting, name and lore is stored. It does not include items
|
* auxiliary data such as enchanting, name and lore is stored. It does not include items
|
||||||
* material, damage value or count.
|
* material, damage value or count.
|
||||||
* <p>
|
* <p>
|
||||||
* The item stack must be a wrapper for a CraftItemStack.
|
* The item stack must be a wrapper for a CraftItemStack.
|
||||||
@ -669,7 +669,7 @@ public class NbtFactory {
|
|||||||
super(handle, getDataMap(handle));
|
super(handle, getDataMap(handle));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Simplifiying access to each value
|
// Simplifying access to each value
|
||||||
public Byte getByte(String key, Byte defaultValue) {
|
public Byte getByte(String key, Byte defaultValue) {
|
||||||
return containsKey(key) ? (Byte) get(key) : defaultValue;
|
return containsKey(key) ? (Byte) get(key) : defaultValue;
|
||||||
}
|
}
|
||||||
|
@ -116,10 +116,10 @@ public class SendChunk {
|
|||||||
try {
|
try {
|
||||||
chunk.unload(true, false);
|
chunk.unload(true, false);
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
String worldname = chunk.getWorld().getName();
|
String worldName = chunk.getWorld().getName();
|
||||||
PS.debug("$4Could not save chunk: " + worldname + ";" + chunk.getX() + ";" + chunk.getZ());
|
PS.debug("$4Could not save chunk: " + worldName + ";" + chunk.getX() + ";" + chunk.getZ());
|
||||||
PS.debug("$3 - $4File may be open in another process (e.g. MCEdit)");
|
PS.debug("$3 - $4File may be open in another process (e.g. MCEdit)");
|
||||||
PS.debug("$3 - $4" + worldname + "/level.dat or " + worldname
|
PS.debug("$3 - $4" + worldName + "/level.dat or " + worldName
|
||||||
+ "/level_old.dat may be corrupt (try repairing or removing these)");
|
+ "/level_old.dat may be corrupt (try repairing or removing these)");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -127,12 +127,12 @@ public class SendChunk {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sendChunk(String worldname, Collection<ChunkLoc> chunkLocs) {
|
public void sendChunk(String worldName, Collection<ChunkLoc> chunkLocations) {
|
||||||
World myworld = Bukkit.getWorld(worldname);
|
World myWorld = Bukkit.getWorld(worldName);
|
||||||
ArrayList<Chunk> chunks = new ArrayList<>();
|
ArrayList<Chunk> chunks = new ArrayList<>();
|
||||||
for (ChunkLoc loc : chunkLocs) {
|
for (ChunkLoc loc : chunkLocations) {
|
||||||
if (myworld.isChunkLoaded(loc.x, loc.z)) {
|
if (myWorld.isChunkLoaded(loc.x, loc.z)) {
|
||||||
chunks.add(myworld.getChunkAt(loc.x, loc.z));
|
chunks.add(myWorld.getChunkAt(loc.x, loc.z));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
sendChunk(chunks);
|
sendChunk(chunks);
|
||||||
|
@ -45,10 +45,10 @@ public class SetGenCB {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!set) {
|
if (!set) {
|
||||||
Iterator<BlockPopulator> iter = world.getPopulators().iterator();
|
Iterator<BlockPopulator> iterator = world.getPopulators().iterator();
|
||||||
while (iter.hasNext()) {
|
while (iterator.hasNext()) {
|
||||||
if (iter.next() instanceof BukkitAugmentedGenerator) {
|
if (iterator.next() instanceof BukkitAugmentedGenerator) {
|
||||||
iter.remove();
|
iterator.remove();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -34,8 +34,7 @@ public class FastQueue_1_7 extends SlowQueue {
|
|||||||
private final RefMethod methodA;
|
private final RefMethod methodA;
|
||||||
private final RefMethod methodGetById;
|
private final RefMethod methodGetById;
|
||||||
private final RefMethod methodInitLighting;
|
private final RefMethod methodInitLighting;
|
||||||
|
private final SendChunk sendChunk;
|
||||||
private final SendChunk chunksender;
|
|
||||||
|
|
||||||
private final HashMap<ChunkWrapper, Chunk> toUpdate = new HashMap<>();
|
private final HashMap<ChunkWrapper, Chunk> toUpdate = new HashMap<>();
|
||||||
|
|
||||||
@ -45,7 +44,7 @@ public class FastQueue_1_7 extends SlowQueue {
|
|||||||
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);
|
||||||
this.methodGetById = this.classBlock.getMethod("getById", int.class);
|
this.methodGetById = this.classBlock.getMethod("getById", int.class);
|
||||||
this.methodInitLighting = this.classChunk.getMethod("initLighting");
|
this.methodInitLighting = this.classChunk.getMethod("initLighting");
|
||||||
this.chunksender = new SendChunk();
|
this.sendChunk = new SendChunk();
|
||||||
TaskManager.runTaskRepeat(new Runnable() {
|
TaskManager.runTaskRepeat(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
@ -82,7 +81,7 @@ public class FastQueue_1_7 extends SlowQueue {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
this.chunksender.sendChunk(chunks);
|
this.sendChunk.sendChunk(chunks);
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
MainUtil.canSendChunk = false;
|
MainUtil.canSendChunk = false;
|
||||||
@ -175,6 +174,6 @@ public class FastQueue_1_7 extends SlowQueue {
|
|||||||
ChunkWrapper wrapper = SetQueue.IMP.new ChunkWrapper(world, loc.x, loc.z);
|
ChunkWrapper wrapper = SetQueue.IMP.new ChunkWrapper(world, loc.x, loc.z);
|
||||||
this.toUpdate.remove(wrapper);
|
this.toUpdate.remove(wrapper);
|
||||||
}
|
}
|
||||||
this.chunksender.sendChunk(world, locations);
|
this.sendChunk.sendChunk(world, locations);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -40,7 +40,7 @@ public class FastQueue_1_8 extends SlowQueue {
|
|||||||
private final RefMethod methodA;
|
private final RefMethod methodA;
|
||||||
private final RefMethod methodGetByCombinedId;
|
private final RefMethod methodGetByCombinedId;
|
||||||
private final RefConstructor constructorBlockPosition;
|
private final RefConstructor constructorBlockPosition;
|
||||||
private final SendChunk chunksender;
|
private final SendChunk sendChunk;
|
||||||
|
|
||||||
public FastQueue_1_8() throws RuntimeException {
|
public FastQueue_1_8() throws RuntimeException {
|
||||||
this.methodInitLighting = this.classChunk.getMethod("initLighting");
|
this.methodInitLighting = this.classChunk.getMethod("initLighting");
|
||||||
@ -49,7 +49,7 @@ public class FastQueue_1_8 extends SlowQueue {
|
|||||||
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", this.classBlockPosition, this.classIBlockData);
|
this.methodA = this.classChunk.getMethod("a", this.classBlockPosition, this.classIBlockData);
|
||||||
this.chunksender = new SendChunk();
|
this.sendChunk = new SendChunk();
|
||||||
TaskManager.runTaskRepeat(new Runnable() {
|
TaskManager.runTaskRepeat(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
@ -86,7 +86,7 @@ public class FastQueue_1_8 extends SlowQueue {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
this.chunksender.sendChunk(chunks);
|
this.sendChunk.sendChunk(chunks);
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
MainUtil.canSendChunk = false;
|
MainUtil.canSendChunk = false;
|
||||||
@ -378,6 +378,6 @@ public class FastQueue_1_8 extends SlowQueue {
|
|||||||
ChunkWrapper wrapper = SetQueue.IMP.new ChunkWrapper(world, loc.x, loc.z);
|
ChunkWrapper wrapper = SetQueue.IMP.new ChunkWrapper(world, loc.x, loc.z);
|
||||||
this.toUpdate.remove(wrapper);
|
this.toUpdate.remove(wrapper);
|
||||||
}
|
}
|
||||||
this.chunksender.sendChunk(world, locations);
|
this.sendChunk.sendChunk(world, locations);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
package com.plotsquared.bukkit.util.block;
|
package com.plotsquared.bukkit.util.block;
|
||||||
|
|
||||||
|
import static com.intellectualcrafters.plot.util.ReflectionUtils.getRefClass;
|
||||||
|
|
||||||
import com.intellectualcrafters.plot.object.ChunkLoc;
|
import com.intellectualcrafters.plot.object.ChunkLoc;
|
||||||
import com.intellectualcrafters.plot.object.PseudoRandom;
|
import com.intellectualcrafters.plot.object.PseudoRandom;
|
||||||
import com.intellectualcrafters.plot.util.ChunkManager;
|
import com.intellectualcrafters.plot.util.ChunkManager;
|
||||||
@ -14,6 +16,12 @@ import com.intellectualcrafters.plot.util.SetQueue;
|
|||||||
import com.intellectualcrafters.plot.util.SetQueue.ChunkWrapper;
|
import com.intellectualcrafters.plot.util.SetQueue.ChunkWrapper;
|
||||||
import com.intellectualcrafters.plot.util.TaskManager;
|
import com.intellectualcrafters.plot.util.TaskManager;
|
||||||
import com.plotsquared.bukkit.util.SendChunk;
|
import com.plotsquared.bukkit.util.SendChunk;
|
||||||
|
import org.bukkit.Chunk;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.World.Environment;
|
||||||
|
import org.bukkit.block.Biome;
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
@ -23,18 +31,10 @@ import java.util.HashMap;
|
|||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import org.bukkit.Chunk;
|
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.World;
|
|
||||||
import org.bukkit.World.Environment;
|
|
||||||
import org.bukkit.block.Biome;
|
|
||||||
|
|
||||||
|
|
||||||
import static com.intellectualcrafters.plot.util.ReflectionUtils.getRefClass;
|
|
||||||
|
|
||||||
public class FastQueue_1_8_3 extends SlowQueue {
|
public class FastQueue_1_8_3 extends SlowQueue {
|
||||||
|
|
||||||
private final SendChunk chunksender;
|
private final SendChunk sendChunk;
|
||||||
private final HashMap<ChunkWrapper, Chunk> toUpdate = new HashMap<>();
|
private final HashMap<ChunkWrapper, Chunk> toUpdate = new HashMap<>();
|
||||||
private final RefMethod methodGetHandleChunk;
|
private final RefMethod methodGetHandleChunk;
|
||||||
private final RefMethod methodInitLighting;
|
private final RefMethod methodInitLighting;
|
||||||
@ -65,7 +65,7 @@ public class FastQueue_1_8_3 extends SlowQueue {
|
|||||||
this.classChunkSectionConstructor = classChunkSection.getConstructor(int.class, boolean.class, char[].class);
|
this.classChunkSectionConstructor = classChunkSection.getConstructor(int.class, boolean.class, char[].class);
|
||||||
this.tileEntityUnload = classWorld.getField("c");
|
this.tileEntityUnload = classWorld.getField("c");
|
||||||
this.methodGetWorld = classChunk.getMethod("getWorld");
|
this.methodGetWorld = classChunk.getMethod("getWorld");
|
||||||
this.chunksender = new SendChunk();
|
this.sendChunk = new SendChunk();
|
||||||
TaskManager.runTaskRepeat(new Runnable() {
|
TaskManager.runTaskRepeat(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
@ -102,7 +102,7 @@ public class FastQueue_1_8_3 extends SlowQueue {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
this.chunksender.sendChunk(chunks);
|
this.sendChunk.sendChunk(chunks);
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
MainUtil.canSendChunk = false;
|
MainUtil.canSendChunk = false;
|
||||||
@ -129,7 +129,7 @@ public class FastQueue_1_8_3 extends SlowQueue {
|
|||||||
// Sections
|
// Sections
|
||||||
Method getHandle = chunk.getClass().getDeclaredMethod("getHandle");
|
Method getHandle = chunk.getClass().getDeclaredMethod("getHandle");
|
||||||
Object c = getHandle.invoke(chunk);
|
Object c = getHandle.invoke(chunk);
|
||||||
Object w = methodGetWorld.of(c).call();
|
Object w = this.methodGetWorld.of(c).call();
|
||||||
Class<? extends Object> clazz = c.getClass();
|
Class<? extends Object> clazz = c.getClass();
|
||||||
Field sections1 = clazz.getDeclaredField("sections");
|
Field sections1 = clazz.getDeclaredField("sections");
|
||||||
sections1.setAccessible(true);
|
sections1.setAccessible(true);
|
||||||
@ -138,7 +138,7 @@ public class FastQueue_1_8_3 extends SlowQueue {
|
|||||||
|
|
||||||
Object[] sections = (Object[]) sections1.get(c);
|
Object[] sections = (Object[]) sections1.get(c);
|
||||||
HashMap<?, ?> tiles = (HashMap<?, ?>) tileEntities.get(c);
|
HashMap<?, ?> tiles = (HashMap<?, ?>) tileEntities.get(c);
|
||||||
Collection<Object> tilesUnload = (Collection<Object>) tileEntityUnload.of(w).get();
|
Collection<Object> tilesUnload = (Collection<Object>) this.tileEntityUnload.of(w).get();
|
||||||
Collection<?>[] entities = (Collection<?>[]) entitySlices.get(c);
|
Collection<?>[] entities = (Collection<?>[]) entitySlices.get(c);
|
||||||
|
|
||||||
Method getX = null;
|
Method getX = null;
|
||||||
@ -407,6 +407,6 @@ public class FastQueue_1_8_3 extends SlowQueue {
|
|||||||
ChunkWrapper wrapper = SetQueue.IMP.new ChunkWrapper(world, loc.x, loc.z);
|
ChunkWrapper wrapper = SetQueue.IMP.new ChunkWrapper(world, loc.x, loc.z);
|
||||||
this.toUpdate.remove(wrapper);
|
this.toUpdate.remove(wrapper);
|
||||||
}
|
}
|
||||||
this.chunksender.sendChunk(world, locations);
|
this.sendChunk.sendChunk(world, locations);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
package com.plotsquared.bukkit.util.block;
|
package com.plotsquared.bukkit.util.block;
|
||||||
|
|
||||||
|
import static com.intellectualcrafters.plot.util.ReflectionUtils.getRefClass;
|
||||||
|
|
||||||
import com.intellectualcrafters.plot.object.ChunkLoc;
|
import com.intellectualcrafters.plot.object.ChunkLoc;
|
||||||
import com.intellectualcrafters.plot.object.PseudoRandom;
|
import com.intellectualcrafters.plot.object.PseudoRandom;
|
||||||
import com.intellectualcrafters.plot.util.ChunkManager;
|
import com.intellectualcrafters.plot.util.ChunkManager;
|
||||||
@ -15,6 +17,12 @@ import com.intellectualcrafters.plot.util.SetQueue.ChunkWrapper;
|
|||||||
import com.intellectualcrafters.plot.util.TaskManager;
|
import com.intellectualcrafters.plot.util.TaskManager;
|
||||||
import com.plotsquared.bukkit.util.BukkitUtil;
|
import com.plotsquared.bukkit.util.BukkitUtil;
|
||||||
import com.plotsquared.bukkit.util.SendChunk;
|
import com.plotsquared.bukkit.util.SendChunk;
|
||||||
|
import org.bukkit.Chunk;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.World.Environment;
|
||||||
|
import org.bukkit.block.Biome;
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
@ -24,14 +32,6 @@ import java.util.HashMap;
|
|||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import org.bukkit.Chunk;
|
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.World;
|
|
||||||
import org.bukkit.World.Environment;
|
|
||||||
import org.bukkit.block.Biome;
|
|
||||||
|
|
||||||
|
|
||||||
import static com.intellectualcrafters.plot.util.ReflectionUtils.getRefClass;
|
|
||||||
|
|
||||||
public class FastQueue_1_9 extends SlowQueue {
|
public class FastQueue_1_9 extends SlowQueue {
|
||||||
|
|
||||||
@ -143,7 +143,7 @@ public class FastQueue_1_9 extends SlowQueue {
|
|||||||
// Sections
|
// Sections
|
||||||
Method getHandle = chunk.getClass().getDeclaredMethod("getHandle");
|
Method getHandle = chunk.getClass().getDeclaredMethod("getHandle");
|
||||||
Object c = getHandle.invoke(chunk);
|
Object c = getHandle.invoke(chunk);
|
||||||
Object w = methodGetWorld.of(c).call();
|
Object w = this.methodGetWorld.of(c).call();
|
||||||
Class<? extends Object> clazz = c.getClass();
|
Class<? extends Object> clazz = c.getClass();
|
||||||
Field sf = clazz.getDeclaredField("sections");
|
Field sf = clazz.getDeclaredField("sections");
|
||||||
sf.setAccessible(true);
|
sf.setAccessible(true);
|
||||||
@ -152,7 +152,7 @@ public class FastQueue_1_9 extends SlowQueue {
|
|||||||
|
|
||||||
Object[] sections = (Object[]) sf.get(c);
|
Object[] sections = (Object[]) sf.get(c);
|
||||||
HashMap<?, ?> tiles = (HashMap<?, ?>) tf.get(c);
|
HashMap<?, ?> tiles = (HashMap<?, ?>) tf.get(c);
|
||||||
Collection<Object> tilesUnload = (Collection<Object>) tileEntityUnload.of(w).get();
|
Collection<Object> tilesUnload = (Collection<Object>) this.tileEntityUnload.of(w).get();
|
||||||
Collection<?>[] entities = (Collection<?>[]) entitySlices.get(c);
|
Collection<?>[] entities = (Collection<?>[]) entitySlices.get(c);
|
||||||
|
|
||||||
Method xm = null;
|
Method xm = null;
|
||||||
@ -306,7 +306,7 @@ public class FastQueue_1_9 extends SlowQueue {
|
|||||||
if (fixAll && !(boolean) this.methodAreNeighborsLoaded.of(c).call(1)) {
|
if (fixAll && !(boolean) this.methodAreNeighborsLoaded.of(c).call(1)) {
|
||||||
World world = chunk.getWorld();
|
World world = chunk.getWorld();
|
||||||
ChunkWrapper wrapper = bc.getChunkWrapper();
|
ChunkWrapper wrapper = bc.getChunkWrapper();
|
||||||
String worldname = wrapper.world;
|
String worldName = wrapper.world;
|
||||||
for (int x = wrapper.x - 1; x <= wrapper.x + 1; x++) {
|
for (int x = wrapper.x - 1; x <= wrapper.x + 1; x++) {
|
||||||
for (int z = wrapper.z - 1; z <= wrapper.z + 1; z++) {
|
for (int z = wrapper.z - 1; z <= wrapper.z + 1; z++) {
|
||||||
if (x != 0 && z != 0) {
|
if (x != 0 && z != 0) {
|
||||||
@ -314,7 +314,7 @@ public class FastQueue_1_9 extends SlowQueue {
|
|||||||
while (!other.isLoaded()) {
|
while (!other.isLoaded()) {
|
||||||
other.load(true);
|
other.load(true);
|
||||||
}
|
}
|
||||||
ChunkManager.manager.loadChunk(worldname, new ChunkLoc(x, z), true);
|
ChunkManager.manager.loadChunk(worldName, new ChunkLoc(x, z), true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -62,12 +62,12 @@ public class SlowQueue implements PlotQueue<Chunk> {
|
|||||||
if (this.blocks.isEmpty()) {
|
if (this.blocks.isEmpty()) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
Iterator<Entry<ChunkWrapper, PlotChunk<Chunk>>> iter = this.blocks.entrySet().iterator();
|
Iterator<Entry<ChunkWrapper, PlotChunk<Chunk>>> iterator = this.blocks.entrySet().iterator();
|
||||||
PlotChunk<Chunk> toReturn = iter.next().getValue();
|
PlotChunk<Chunk> toReturn = iterator.next().getValue();
|
||||||
if (SetQueue.IMP.isWaiting()) {
|
if (SetQueue.IMP.isWaiting()) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
iter.remove();
|
iterator.remove();
|
||||||
execute(toReturn);
|
execute(toReturn);
|
||||||
fixLighting(toReturn, true);
|
fixLighting(toReturn, true);
|
||||||
return toReturn;
|
return toReturn;
|
||||||
|
@ -55,10 +55,10 @@ public class FileUUIDHandler extends UUIDHandlerImplementation {
|
|||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
PS.debug(C.PREFIX + "&6Starting player data caching for: " + world);
|
PS.debug(C.PREFIX + "&6Starting player data caching for: " + world);
|
||||||
File uuidfile = new File(PS.get().IMP.getDirectory(), "uuids.txt");
|
File uuidFile = new File(PS.get().IMP.getDirectory(), "uuids.txt");
|
||||||
if (uuidfile.exists()) {
|
if (uuidFile.exists()) {
|
||||||
try {
|
try {
|
||||||
List<String> lines = Files.readAllLines(uuidfile.toPath(), StandardCharsets.UTF_8);
|
List<String> lines = Files.readAllLines(uuidFile.toPath(), StandardCharsets.UTF_8);
|
||||||
for (String line : lines) {
|
for (String line : lines) {
|
||||||
try {
|
try {
|
||||||
line = line.trim();
|
line = line.trim();
|
||||||
@ -89,8 +89,8 @@ public class FileUUIDHandler extends UUIDHandlerImplementation {
|
|||||||
toAdd.put(new StringWrapper("*"), DBFunc.everyone);
|
toAdd.put(new StringWrapper("*"), DBFunc.everyone);
|
||||||
HashSet<UUID> all = UUIDHandler.getAllUUIDS();
|
HashSet<UUID> all = UUIDHandler.getAllUUIDS();
|
||||||
PS.debug("&aFast mode UUID caching enabled!");
|
PS.debug("&aFast mode UUID caching enabled!");
|
||||||
File playerdataFolder = new File(container, world + File.separator + "playerdata");
|
File playerDataFolder = new File(container, world + File.separator + "playerdata");
|
||||||
String[] dat = playerdataFolder.list(new FilenameFilter() {
|
String[] dat = playerDataFolder.list(new FilenameFilter() {
|
||||||
@Override
|
@Override
|
||||||
public boolean accept(File f, String s) {
|
public boolean accept(File f, String s) {
|
||||||
return s.endsWith(".dat");
|
return s.endsWith(".dat");
|
||||||
@ -103,7 +103,7 @@ public class FileUUIDHandler extends UUIDHandlerImplementation {
|
|||||||
try {
|
try {
|
||||||
UUID uuid = UUID.fromString(s);
|
UUID uuid = UUID.fromString(s);
|
||||||
if (check || all.remove(uuid)) {
|
if (check || all.remove(uuid)) {
|
||||||
File file = new File(playerdataFolder + File.separator + current);
|
File file = new File(playerDataFolder + File.separator + current);
|
||||||
InputSupplier<FileInputStream> is = com.google.common.io.Files.newInputStreamSupplier(file);
|
InputSupplier<FileInputStream> is = com.google.common.io.Files.newInputStreamSupplier(file);
|
||||||
NbtFactory.NbtCompound compound = NbtFactory.fromStream(is, NbtFactory.StreamOptions.GZIP_COMPRESSION);
|
NbtFactory.NbtCompound compound = NbtFactory.fromStream(is, NbtFactory.StreamOptions.GZIP_COMPRESSION);
|
||||||
NbtFactory.NbtCompound bukkit = (NbtFactory.NbtCompound) compound.get("bukkit");
|
NbtFactory.NbtCompound bukkit = (NbtFactory.NbtCompound) compound.get("bukkit");
|
||||||
@ -137,11 +137,11 @@ public class FileUUIDHandler extends UUIDHandlerImplementation {
|
|||||||
worlds.add("world");
|
worlds.add("world");
|
||||||
HashSet<UUID> uuids = new HashSet<>();
|
HashSet<UUID> uuids = new HashSet<>();
|
||||||
HashSet<String> names = new HashSet<>();
|
HashSet<String> names = new HashSet<>();
|
||||||
File playerdataFolder = null;
|
File playerDataFolder = null;
|
||||||
for (String worldName : worlds) {
|
for (String worldName : worlds) {
|
||||||
// Getting UUIDs
|
// Getting UUIDs
|
||||||
playerdataFolder = new File(container, worldName + File.separator + "playerdata");
|
playerDataFolder = new File(container, worldName + File.separator + "playerdata");
|
||||||
String[] dat = playerdataFolder.list(new FilenameFilter() {
|
String[] dat = playerDataFolder.list(new FilenameFilter() {
|
||||||
@Override
|
@Override
|
||||||
public boolean accept(File f, String s) {
|
public boolean accept(File f, String s) {
|
||||||
return s.endsWith(".dat");
|
return s.endsWith(".dat");
|
||||||
@ -154,7 +154,7 @@ public class FileUUIDHandler extends UUIDHandlerImplementation {
|
|||||||
UUID uuid = UUID.fromString(s);
|
UUID uuid = UUID.fromString(s);
|
||||||
uuids.add(uuid);
|
uuids.add(uuid);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
PS.debug(C.PREFIX + "Invalid playerdata: " + current);
|
PS.debug(C.PREFIX + "Invalid PlayerData: " + current);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -176,7 +176,7 @@ public class FileUUIDHandler extends UUIDHandlerImplementation {
|
|||||||
}
|
}
|
||||||
for (UUID uuid : uuids) {
|
for (UUID uuid : uuids) {
|
||||||
try {
|
try {
|
||||||
File file = new File(playerdataFolder + File.separator + uuid.toString() + ".dat");
|
File file = new File(playerDataFolder + File.separator + uuid.toString() + ".dat");
|
||||||
if (!file.exists()) {
|
if (!file.exists()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -199,7 +199,7 @@ public class FileUUIDHandler extends UUIDHandlerImplementation {
|
|||||||
}
|
}
|
||||||
toAdd.put(new StringWrapper(name), uuid);
|
toAdd.put(new StringWrapper(name), uuid);
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
PS.debug(C.PREFIX + "&6Invalid playerdata: " + uuid.toString() + ".dat");
|
PS.debug(C.PREFIX + "&6Invalid PlayerData: " + uuid.toString() + ".dat");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (String name : names) {
|
for (String name : names) {
|
||||||
|
@ -151,7 +151,7 @@ public class SQLUUIDHandler extends UUIDHandlerImplementation {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void fetchUUID(final String name, final RunnableVal<UUID> ifFetch) {
|
public void fetchUUID(final String name, final RunnableVal<UUID> ifFetch) {
|
||||||
PS.debug(C.PREFIX + "UUID for '" + name + "' was null. We'll cache this from the mojang servers!");
|
PS.debug(C.PREFIX + "UUID for '" + name + "' was null. We'll cache this from the Mojang servers!");
|
||||||
if (ifFetch == null) {
|
if (ifFetch == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -46,7 +46,7 @@ public class JSONArray {
|
|||||||
* Construct an empty JSONArray.
|
* Construct an empty JSONArray.
|
||||||
*/
|
*/
|
||||||
public JSONArray() {
|
public JSONArray() {
|
||||||
myArrayList = new ArrayList<Object>();
|
this.myArrayList = new ArrayList<Object>();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -56,7 +56,7 @@ public class JSONArray {
|
|||||||
*
|
*
|
||||||
* @throws JSONException If there is a syntax error.
|
* @throws JSONException If there is a syntax error.
|
||||||
*/
|
*/
|
||||||
public JSONArray(final JSONTokener x) throws JSONException {
|
public JSONArray(JSONTokener x) throws JSONException {
|
||||||
this();
|
this();
|
||||||
if (x.nextClean() != '[') {
|
if (x.nextClean() != '[') {
|
||||||
throw x.syntaxError("A JSONArray text must start with '['");
|
throw x.syntaxError("A JSONArray text must start with '['");
|
||||||
@ -66,10 +66,10 @@ public class JSONArray {
|
|||||||
for (;;) {
|
for (;;) {
|
||||||
if (x.nextClean() == ',') {
|
if (x.nextClean() == ',') {
|
||||||
x.back();
|
x.back();
|
||||||
myArrayList.add(JSONObject.NULL);
|
this.myArrayList.add(JSONObject.NULL);
|
||||||
} else {
|
} else {
|
||||||
x.back();
|
x.back();
|
||||||
myArrayList.add(x.nextValue());
|
this.myArrayList.add(x.nextValue());
|
||||||
}
|
}
|
||||||
switch (x.nextClean()) {
|
switch (x.nextClean()) {
|
||||||
case ',':
|
case ',':
|
||||||
@ -95,7 +95,7 @@ public class JSONArray {
|
|||||||
*
|
*
|
||||||
* @throws JSONException If there is a syntax error.
|
* @throws JSONException If there is a syntax error.
|
||||||
*/
|
*/
|
||||||
public JSONArray(final String source) throws JSONException {
|
public JSONArray(String source) throws JSONException {
|
||||||
this(new JSONTokener(source));
|
this(new JSONTokener(source));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -104,11 +104,11 @@ public class JSONArray {
|
|||||||
*
|
*
|
||||||
* @param collection A Collection.
|
* @param collection A Collection.
|
||||||
*/
|
*/
|
||||||
public JSONArray(final Collection<Object> collection) {
|
public JSONArray(Collection<Object> collection) {
|
||||||
myArrayList = new ArrayList<Object>();
|
this.myArrayList = new ArrayList<Object>();
|
||||||
if (collection != null) {
|
if (collection != null) {
|
||||||
for (final Object aCollection : collection) {
|
for (Object aCollection : collection) {
|
||||||
myArrayList.add(JSONObject.wrap(aCollection));
|
this.myArrayList.add(JSONObject.wrap(aCollection));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -118,10 +118,10 @@ public class JSONArray {
|
|||||||
*
|
*
|
||||||
* @throws JSONException If not an array.
|
* @throws JSONException If not an array.
|
||||||
*/
|
*/
|
||||||
public JSONArray(final Object array) throws JSONException {
|
public JSONArray(Object array) throws JSONException {
|
||||||
this();
|
this();
|
||||||
if (array.getClass().isArray()) {
|
if (array.getClass().isArray()) {
|
||||||
final int length = Array.getLength(array);
|
int length = Array.getLength(array);
|
||||||
for (int i = 0; i < length; i += 1) {
|
for (int i = 0; i < length; i += 1) {
|
||||||
this.put(JSONObject.wrap(Array.get(array, i)));
|
this.put(JSONObject.wrap(Array.get(array, i)));
|
||||||
}
|
}
|
||||||
@ -139,8 +139,8 @@ public class JSONArray {
|
|||||||
*
|
*
|
||||||
* @throws JSONException If there is no value for the index.
|
* @throws JSONException If there is no value for the index.
|
||||||
*/
|
*/
|
||||||
public Object get(final int index) throws JSONException {
|
public Object get(int index) throws JSONException {
|
||||||
final Object object = opt(index);
|
Object object = opt(index);
|
||||||
if (object == null) {
|
if (object == null) {
|
||||||
throw new JSONException("JSONArray[" + index + "] not found.");
|
throw new JSONException("JSONArray[" + index + "] not found.");
|
||||||
}
|
}
|
||||||
@ -156,8 +156,8 @@ public class JSONArray {
|
|||||||
*
|
*
|
||||||
* @throws JSONException If there is no value for the index or if the value is not convertible to boolean.
|
* @throws JSONException If there is no value for the index or if the value is not convertible to boolean.
|
||||||
*/
|
*/
|
||||||
public boolean getBoolean(final int index) throws JSONException {
|
public boolean getBoolean(int index) throws JSONException {
|
||||||
final Object object = get(index);
|
Object object = get(index);
|
||||||
if (object.equals(Boolean.FALSE) || ((object instanceof String) && ((String) object).equalsIgnoreCase("false"))) {
|
if (object.equals(Boolean.FALSE) || ((object instanceof String) && ((String) object).equalsIgnoreCase("false"))) {
|
||||||
return false;
|
return false;
|
||||||
} else if (object.equals(Boolean.TRUE) || ((object instanceof String) && ((String) object).equalsIgnoreCase("true"))) {
|
} else if (object.equals(Boolean.TRUE) || ((object instanceof String) && ((String) object).equalsIgnoreCase("true"))) {
|
||||||
@ -175,8 +175,8 @@ public class JSONArray {
|
|||||||
*
|
*
|
||||||
* @throws JSONException If the key is not found or if the value cannot be converted to a number.
|
* @throws JSONException If the key is not found or if the value cannot be converted to a number.
|
||||||
*/
|
*/
|
||||||
public double getDouble(final int index) throws JSONException {
|
public double getDouble(int index) throws JSONException {
|
||||||
final Object object = get(index);
|
Object object = get(index);
|
||||||
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 e) {
|
||||||
@ -193,8 +193,8 @@ public class JSONArray {
|
|||||||
*
|
*
|
||||||
* @throws JSONException If the key is not found or if the value is not a number.
|
* @throws JSONException If the key is not found or if the value is not a number.
|
||||||
*/
|
*/
|
||||||
public int getInt(final int index) throws JSONException {
|
public int getInt(int index) throws JSONException {
|
||||||
final Object object = get(index);
|
Object object = get(index);
|
||||||
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 e) {
|
||||||
@ -211,8 +211,8 @@ public class JSONArray {
|
|||||||
*
|
*
|
||||||
* @throws JSONException If there is no value for the index. or if the value is not a JSONArray
|
* @throws JSONException If there is no value for the index. or if the value is not a JSONArray
|
||||||
*/
|
*/
|
||||||
public JSONArray getJSONArray(final int index) throws JSONException {
|
public JSONArray getJSONArray(int index) throws JSONException {
|
||||||
final Object object = get(index);
|
Object object = get(index);
|
||||||
if (object instanceof JSONArray) {
|
if (object instanceof JSONArray) {
|
||||||
return (JSONArray) object;
|
return (JSONArray) object;
|
||||||
}
|
}
|
||||||
@ -228,8 +228,8 @@ public class JSONArray {
|
|||||||
*
|
*
|
||||||
* @throws JSONException If there is no value for the index or if the value is not a JSONObject
|
* @throws JSONException If there is no value for the index or if the value is not a JSONObject
|
||||||
*/
|
*/
|
||||||
public JSONObject getJSONObject(final int index) throws JSONException {
|
public JSONObject getJSONObject(int index) throws JSONException {
|
||||||
final Object object = get(index);
|
Object object = get(index);
|
||||||
if (object instanceof JSONObject) {
|
if (object instanceof JSONObject) {
|
||||||
return (JSONObject) object;
|
return (JSONObject) object;
|
||||||
}
|
}
|
||||||
@ -245,8 +245,8 @@ public class JSONArray {
|
|||||||
*
|
*
|
||||||
* @throws JSONException If the key is not found or if the value cannot be converted to a number.
|
* @throws JSONException If the key is not found or if the value cannot be converted to a number.
|
||||||
*/
|
*/
|
||||||
public long getLong(final int index) throws JSONException {
|
public long getLong(int index) throws JSONException {
|
||||||
final Object object = get(index);
|
Object object = get(index);
|
||||||
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 e) {
|
||||||
@ -263,8 +263,8 @@ public class JSONArray {
|
|||||||
*
|
*
|
||||||
* @throws JSONException If there is no string value for the index.
|
* @throws JSONException If there is no string value for the index.
|
||||||
*/
|
*/
|
||||||
public String getString(final int index) throws JSONException {
|
public String getString(int index) throws JSONException {
|
||||||
final Object object = get(index);
|
Object object = get(index);
|
||||||
if (object instanceof String) {
|
if (object instanceof String) {
|
||||||
return (String) object;
|
return (String) object;
|
||||||
}
|
}
|
||||||
@ -278,7 +278,7 @@ public class JSONArray {
|
|||||||
*
|
*
|
||||||
* @return true if the value at the index is null, or if there is no value.
|
* @return true if the value at the index is null, or if there is no value.
|
||||||
*/
|
*/
|
||||||
public boolean isNull(final int index) {
|
public boolean isNull(int index) {
|
||||||
return JSONObject.NULL.equals(opt(index));
|
return JSONObject.NULL.equals(opt(index));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -292,14 +292,14 @@ public class JSONArray {
|
|||||||
*
|
*
|
||||||
* @throws JSONException If the array contains an invalid number.
|
* @throws JSONException If the array contains an invalid number.
|
||||||
*/
|
*/
|
||||||
public String join(final String separator) throws JSONException {
|
public String join(String separator) throws JSONException {
|
||||||
final int len = length();
|
int len = length();
|
||||||
final StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
for (int i = 0; i < len; i += 1) {
|
for (int i = 0; i < len; i += 1) {
|
||||||
if (i > 0) {
|
if (i > 0) {
|
||||||
sb.append(separator);
|
sb.append(separator);
|
||||||
}
|
}
|
||||||
sb.append(JSONObject.valueToString(myArrayList.get(i)));
|
sb.append(JSONObject.valueToString(this.myArrayList.get(i)));
|
||||||
}
|
}
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
}
|
}
|
||||||
@ -310,7 +310,7 @@ public class JSONArray {
|
|||||||
* @return The length (or size).
|
* @return The length (or size).
|
||||||
*/
|
*/
|
||||||
public int length() {
|
public int length() {
|
||||||
return myArrayList.size();
|
return this.myArrayList.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -320,8 +320,8 @@ public class JSONArray {
|
|||||||
*
|
*
|
||||||
* @return An object value, or null if there is no object at that index.
|
* @return An object value, or null if there is no object at that index.
|
||||||
*/
|
*/
|
||||||
public Object opt(final int index) {
|
public Object opt(int index) {
|
||||||
return ((index < 0) || (index >= length())) ? null : myArrayList.get(index);
|
return ((index < 0) || (index >= length())) ? null : this.myArrayList.get(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -332,7 +332,7 @@ public class JSONArray {
|
|||||||
*
|
*
|
||||||
* @return The truth.
|
* @return The truth.
|
||||||
*/
|
*/
|
||||||
public boolean optBoolean(final int index) {
|
public boolean optBoolean(int index) {
|
||||||
return this.optBoolean(index, false);
|
return this.optBoolean(index, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -345,7 +345,7 @@ public class JSONArray {
|
|||||||
*
|
*
|
||||||
* @return The truth.
|
* @return The truth.
|
||||||
*/
|
*/
|
||||||
public boolean optBoolean(final int index, final boolean defaultValue) {
|
public boolean optBoolean(int index, boolean defaultValue) {
|
||||||
try {
|
try {
|
||||||
return getBoolean(index);
|
return getBoolean(index);
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
@ -361,7 +361,7 @@ public class JSONArray {
|
|||||||
*
|
*
|
||||||
* @return The value.
|
* @return The value.
|
||||||
*/
|
*/
|
||||||
public double optDouble(final int index) {
|
public double optDouble(int index) {
|
||||||
return this.optDouble(index, Double.NaN);
|
return this.optDouble(index, Double.NaN);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -374,7 +374,7 @@ public class JSONArray {
|
|||||||
*
|
*
|
||||||
* @return The value.
|
* @return The value.
|
||||||
*/
|
*/
|
||||||
public double optDouble(final int index, final double defaultValue) {
|
public double optDouble(int index, double defaultValue) {
|
||||||
try {
|
try {
|
||||||
return getDouble(index);
|
return getDouble(index);
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
@ -390,7 +390,7 @@ public class JSONArray {
|
|||||||
*
|
*
|
||||||
* @return The value.
|
* @return The value.
|
||||||
*/
|
*/
|
||||||
public int optInt(final int index) {
|
public int optInt(int index) {
|
||||||
return this.optInt(index, 0);
|
return this.optInt(index, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -403,7 +403,7 @@ public class JSONArray {
|
|||||||
*
|
*
|
||||||
* @return The value.
|
* @return The value.
|
||||||
*/
|
*/
|
||||||
public int optInt(final int index, final int defaultValue) {
|
public int optInt(int index, int defaultValue) {
|
||||||
try {
|
try {
|
||||||
return getInt(index);
|
return getInt(index);
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
@ -418,8 +418,8 @@ public class JSONArray {
|
|||||||
*
|
*
|
||||||
* @return A JSONArray value, or null if the index has no value, or if the value is not a JSONArray.
|
* @return A JSONArray value, or null if the index has no value, or if the value is not a JSONArray.
|
||||||
*/
|
*/
|
||||||
public JSONArray optJSONArray(final int index) {
|
public JSONArray optJSONArray(int index) {
|
||||||
final Object o = opt(index);
|
Object o = opt(index);
|
||||||
return o instanceof JSONArray ? (JSONArray) o : null;
|
return o instanceof JSONArray ? (JSONArray) o : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -431,8 +431,8 @@ public class JSONArray {
|
|||||||
*
|
*
|
||||||
* @return A JSONObject value.
|
* @return A JSONObject value.
|
||||||
*/
|
*/
|
||||||
public JSONObject optJSONObject(final int index) {
|
public JSONObject optJSONObject(int index) {
|
||||||
final Object o = opt(index);
|
Object o = opt(index);
|
||||||
return o instanceof JSONObject ? (JSONObject) o : null;
|
return o instanceof JSONObject ? (JSONObject) o : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -444,7 +444,7 @@ public class JSONArray {
|
|||||||
*
|
*
|
||||||
* @return The value.
|
* @return The value.
|
||||||
*/
|
*/
|
||||||
public long optLong(final int index) {
|
public long optLong(int index) {
|
||||||
return this.optLong(index, 0);
|
return this.optLong(index, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -457,7 +457,7 @@ public class JSONArray {
|
|||||||
*
|
*
|
||||||
* @return The value.
|
* @return The value.
|
||||||
*/
|
*/
|
||||||
public long optLong(final int index, final long defaultValue) {
|
public long optLong(int index, long defaultValue) {
|
||||||
try {
|
try {
|
||||||
return getLong(index);
|
return getLong(index);
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
@ -467,13 +467,13 @@ public class JSONArray {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the optional string value associated with an index. It returns an empty string if there is no value at that
|
* Get the optional string value associated with an index. It returns an empty string if there is no value at that
|
||||||
* index. If the value is not a string and is not null, then it is coverted to a string.
|
* index. If the value is not a string and is not null, then it is converted to a string.
|
||||||
*
|
*
|
||||||
* @param index The index must be between 0 and length() - 1.
|
* @param index The index must be between 0 and length() - 1.
|
||||||
*
|
*
|
||||||
* @return A String value.
|
* @return A String value.
|
||||||
*/
|
*/
|
||||||
public String optString(final int index) {
|
public String optString(int index) {
|
||||||
return this.optString(index, "");
|
return this.optString(index, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -485,8 +485,8 @@ public class JSONArray {
|
|||||||
*
|
*
|
||||||
* @return A String value.
|
* @return A String value.
|
||||||
*/
|
*/
|
||||||
public String optString(final int index, final String defaultValue) {
|
public String optString(int index, String defaultValue) {
|
||||||
final Object object = opt(index);
|
Object object = opt(index);
|
||||||
return JSONObject.NULL.equals(object) ? defaultValue : object.toString();
|
return JSONObject.NULL.equals(object) ? defaultValue : object.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -497,7 +497,7 @@ public class JSONArray {
|
|||||||
*
|
*
|
||||||
* @return this.
|
* @return this.
|
||||||
*/
|
*/
|
||||||
public JSONArray put(final boolean value) {
|
public JSONArray put(boolean value) {
|
||||||
this.put(value ? Boolean.TRUE : Boolean.FALSE);
|
this.put(value ? Boolean.TRUE : Boolean.FALSE);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
@ -509,7 +509,7 @@ public class JSONArray {
|
|||||||
*
|
*
|
||||||
* @return this.
|
* @return this.
|
||||||
*/
|
*/
|
||||||
public JSONArray put(final Collection<Object> value) {
|
public JSONArray put(Collection<Object> value) {
|
||||||
this.put(new JSONArray(value));
|
this.put(new JSONArray(value));
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
@ -523,8 +523,8 @@ public class JSONArray {
|
|||||||
*
|
*
|
||||||
* @throws JSONException if the value is not finite.
|
* @throws JSONException if the value is not finite.
|
||||||
*/
|
*/
|
||||||
public JSONArray put(final double value) throws JSONException {
|
public JSONArray put(double value) throws JSONException {
|
||||||
final Double d = value;
|
Double d = value;
|
||||||
JSONObject.testValidity(d);
|
JSONObject.testValidity(d);
|
||||||
this.put(d);
|
this.put(d);
|
||||||
return this;
|
return this;
|
||||||
@ -537,7 +537,7 @@ public class JSONArray {
|
|||||||
*
|
*
|
||||||
* @return this.
|
* @return this.
|
||||||
*/
|
*/
|
||||||
public JSONArray put(final int value) {
|
public JSONArray put(int value) {
|
||||||
this.put(Integer.valueOf(value));
|
this.put(Integer.valueOf(value));
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
@ -549,7 +549,7 @@ public class JSONArray {
|
|||||||
*
|
*
|
||||||
* @return this.
|
* @return this.
|
||||||
*/
|
*/
|
||||||
public JSONArray put(final long value) {
|
public JSONArray put(long value) {
|
||||||
this.put(Long.valueOf(value));
|
this.put(Long.valueOf(value));
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
@ -561,7 +561,7 @@ public class JSONArray {
|
|||||||
*
|
*
|
||||||
* @return this.
|
* @return this.
|
||||||
*/
|
*/
|
||||||
public JSONArray put(final Map<String, Object> value) {
|
public JSONArray put(Map<String, Object> value) {
|
||||||
this.put(new JSONObject(value));
|
this.put(new JSONObject(value));
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
@ -574,8 +574,8 @@ public class JSONArray {
|
|||||||
*
|
*
|
||||||
* @return this.
|
* @return this.
|
||||||
*/
|
*/
|
||||||
public JSONArray put(final Object value) {
|
public JSONArray put(Object value) {
|
||||||
myArrayList.add(value);
|
this.myArrayList.add(value);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -590,7 +590,7 @@ public class JSONArray {
|
|||||||
*
|
*
|
||||||
* @throws JSONException If the index is negative.
|
* @throws JSONException If the index is negative.
|
||||||
*/
|
*/
|
||||||
public JSONArray put(final int index, final boolean value) throws JSONException {
|
public JSONArray put(int index, boolean value) throws JSONException {
|
||||||
this.put(index, value ? Boolean.TRUE : Boolean.FALSE);
|
this.put(index, value ? Boolean.TRUE : Boolean.FALSE);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
@ -605,7 +605,7 @@ public class JSONArray {
|
|||||||
*
|
*
|
||||||
* @throws JSONException If the index is negative or if the value is not finite.
|
* @throws JSONException If the index is negative or if the value is not finite.
|
||||||
*/
|
*/
|
||||||
public JSONArray put(final int index, final Collection<Object> value) throws JSONException {
|
public JSONArray put(int index, Collection<Object> value) throws JSONException {
|
||||||
this.put(index, new JSONArray(value));
|
this.put(index, new JSONArray(value));
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
@ -621,7 +621,7 @@ public class JSONArray {
|
|||||||
*
|
*
|
||||||
* @throws JSONException If the index is negative or if the value is not finite.
|
* @throws JSONException If the index is negative or if the value is not finite.
|
||||||
*/
|
*/
|
||||||
public JSONArray put(final int index, final double value) throws JSONException {
|
public JSONArray put(int index, double value) throws JSONException {
|
||||||
this.put(index, new Double(value));
|
this.put(index, new Double(value));
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
@ -637,7 +637,7 @@ public class JSONArray {
|
|||||||
*
|
*
|
||||||
* @throws JSONException If the index is negative.
|
* @throws JSONException If the index is negative.
|
||||||
*/
|
*/
|
||||||
public JSONArray put(final int index, final int value) throws JSONException {
|
public JSONArray put(int index, int value) throws JSONException {
|
||||||
this.put(index, Integer.valueOf(value));
|
this.put(index, Integer.valueOf(value));
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
@ -653,7 +653,7 @@ public class JSONArray {
|
|||||||
*
|
*
|
||||||
* @throws JSONException If the index is negative.
|
* @throws JSONException If the index is negative.
|
||||||
*/
|
*/
|
||||||
public JSONArray put(final int index, final long value) throws JSONException {
|
public JSONArray put(int index, long value) throws JSONException {
|
||||||
this.put(index, Long.valueOf(value));
|
this.put(index, Long.valueOf(value));
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
@ -668,7 +668,7 @@ public class JSONArray {
|
|||||||
*
|
*
|
||||||
* @throws JSONException If the index is negative or if the the value is an invalid number.
|
* @throws JSONException If the index is negative or if the the value is an invalid number.
|
||||||
*/
|
*/
|
||||||
public JSONArray put(final int index, final Map<String, Object> value) throws JSONException {
|
public JSONArray put(int index, Map<String, Object> value) throws JSONException {
|
||||||
this.put(index, new JSONObject(value));
|
this.put(index, new JSONObject(value));
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
@ -685,13 +685,13 @@ public class JSONArray {
|
|||||||
*
|
*
|
||||||
* @throws JSONException If the index is negative or if the the value is an invalid number.
|
* @throws JSONException If the index is negative or if the the value is an invalid number.
|
||||||
*/
|
*/
|
||||||
public JSONArray put(final int index, final Object value) throws JSONException {
|
public JSONArray put(int index, Object value) throws JSONException {
|
||||||
JSONObject.testValidity(value);
|
JSONObject.testValidity(value);
|
||||||
if (index < 0) {
|
if (index < 0) {
|
||||||
throw new JSONException("JSONArray[" + index + "] not found.");
|
throw new JSONException("JSONArray[" + index + "] not found.");
|
||||||
}
|
}
|
||||||
if (index < length()) {
|
if (index < length()) {
|
||||||
myArrayList.set(index, value);
|
this.myArrayList.set(index, value);
|
||||||
} else {
|
} else {
|
||||||
while (index != length()) {
|
while (index != length()) {
|
||||||
this.put(JSONObject.NULL);
|
this.put(JSONObject.NULL);
|
||||||
@ -708,8 +708,8 @@ public class JSONArray {
|
|||||||
*
|
*
|
||||||
* @return The value that was associated with the index, or null if there was no value.
|
* @return The value that was associated with the index, or null if there was no value.
|
||||||
*/
|
*/
|
||||||
public Object remove(final int index) {
|
public Object remove(int index) {
|
||||||
return (index >= 0) && (index < length()) ? myArrayList.remove(index) : null;
|
return (index >= 0) && (index < length()) ? this.myArrayList.remove(index) : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -719,17 +719,17 @@ public class JSONArray {
|
|||||||
*
|
*
|
||||||
* @return true if they are equal
|
* @return true if they are equal
|
||||||
*/
|
*/
|
||||||
public boolean similar(final Object other) {
|
public boolean similar(Object other) {
|
||||||
if (!(other instanceof JSONArray)) {
|
if (!(other instanceof JSONArray)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
final int len = length();
|
int len = length();
|
||||||
if (len != ((JSONArray) other).length()) {
|
if (len != ((JSONArray) other).length()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
for (int i = 0; i < len; i += 1) {
|
for (int i = 0; i < len; i += 1) {
|
||||||
final Object valueThis = get(i);
|
Object valueThis = get(i);
|
||||||
final Object valueOther = ((JSONArray) other).get(i);
|
Object valueOther = ((JSONArray) other).get(i);
|
||||||
if (valueThis instanceof JSONObject) {
|
if (valueThis instanceof JSONObject) {
|
||||||
if (!((JSONObject) valueThis).similar(valueOther)) {
|
if (!((JSONObject) valueThis).similar(valueOther)) {
|
||||||
return false;
|
return false;
|
||||||
@ -754,11 +754,11 @@ public class JSONArray {
|
|||||||
*
|
*
|
||||||
* @throws JSONException If any of the names are null.
|
* @throws JSONException If any of the names are null.
|
||||||
*/
|
*/
|
||||||
public JSONObject toJSONObject(final JSONArray names) throws JSONException {
|
public JSONObject toJSONObject(JSONArray names) throws JSONException {
|
||||||
if ((names == null) || (names.length() == 0) || (length() == 0)) {
|
if ((names == null) || (names.length() == 0) || (length() == 0)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
final JSONObject jo = new JSONObject();
|
JSONObject jo = new JSONObject();
|
||||||
for (int i = 0; i < names.length(); i += 1) {
|
for (int i = 0; i < names.length(); i += 1) {
|
||||||
jo.put(names.getString(i), opt(i));
|
jo.put(names.getString(i), opt(i));
|
||||||
}
|
}
|
||||||
@ -795,8 +795,8 @@ public class JSONArray {
|
|||||||
*
|
*
|
||||||
* @throws JSONException
|
* @throws JSONException
|
||||||
*/
|
*/
|
||||||
public String toString(final int indentFactor) throws JSONException {
|
public String toString(int indentFactor) throws JSONException {
|
||||||
final StringWriter sw = new StringWriter();
|
StringWriter sw = new StringWriter();
|
||||||
synchronized (sw.getBuffer()) {
|
synchronized (sw.getBuffer()) {
|
||||||
return this.write(sw, indentFactor, 0).toString();
|
return this.write(sw, indentFactor, 0).toString();
|
||||||
}
|
}
|
||||||
@ -811,7 +811,7 @@ public class JSONArray {
|
|||||||
*
|
*
|
||||||
* @throws JSONException
|
* @throws JSONException
|
||||||
*/
|
*/
|
||||||
public Writer write(final Writer writer) throws JSONException {
|
public Writer write(Writer writer) throws JSONException {
|
||||||
return this.write(writer, 0, 0);
|
return this.write(writer, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -827,15 +827,15 @@ public class JSONArray {
|
|||||||
*
|
*
|
||||||
* @throws JSONException
|
* @throws JSONException
|
||||||
*/
|
*/
|
||||||
Writer write(final Writer writer, final int indentFactor, final int indent) throws JSONException {
|
Writer write(Writer writer, int indentFactor, int indent) throws JSONException {
|
||||||
try {
|
try {
|
||||||
boolean commanate = false;
|
boolean commanate = false;
|
||||||
final int length = length();
|
int length = length();
|
||||||
writer.write('[');
|
writer.write('[');
|
||||||
if (length == 1) {
|
if (length == 1) {
|
||||||
JSONObject.writeValue(writer, myArrayList.get(0), indentFactor, indent);
|
JSONObject.writeValue(writer, this.myArrayList.get(0), indentFactor, indent);
|
||||||
} else if (length != 0) {
|
} else if (length != 0) {
|
||||||
final int newindent = indent + indentFactor;
|
int newindent = indent + indentFactor;
|
||||||
for (int i = 0; i < length; i += 1) {
|
for (int i = 0; i < length; i += 1) {
|
||||||
if (commanate) {
|
if (commanate) {
|
||||||
writer.write(',');
|
writer.write(',');
|
||||||
@ -844,7 +844,7 @@ public class JSONArray {
|
|||||||
writer.write('\n');
|
writer.write('\n');
|
||||||
}
|
}
|
||||||
JSONObject.indent(writer, newindent);
|
JSONObject.indent(writer, newindent);
|
||||||
JSONObject.writeValue(writer, myArrayList.get(i), indentFactor, newindent);
|
JSONObject.writeValue(writer, this.myArrayList.get(i), indentFactor, newindent);
|
||||||
commanate = true;
|
commanate = true;
|
||||||
}
|
}
|
||||||
if (indentFactor > 0) {
|
if (indentFactor > 0) {
|
||||||
@ -854,7 +854,7 @@ public class JSONArray {
|
|||||||
}
|
}
|
||||||
writer.write(']');
|
writer.write(']');
|
||||||
return writer;
|
return writer;
|
||||||
} catch (final IOException e) {
|
} catch (IOException e) {
|
||||||
throw new JSONException(e);
|
throw new JSONException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -24,26 +24,26 @@ public interface IPlotMain {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Log a message to console.
|
* Log a message to console.
|
||||||
* @param message
|
* @param message The message to log
|
||||||
*/
|
*/
|
||||||
void log(String message);
|
void log(String message);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the `PlotSquared` directory.
|
* Get the `PlotSquared` directory.
|
||||||
* @return
|
* @return The plugin directory
|
||||||
*/
|
*/
|
||||||
File getDirectory();
|
File getDirectory();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the directory containing all the worlds.
|
* Get the directory containing all the worlds.
|
||||||
* @return
|
* @return The directory containing the worlds
|
||||||
*/
|
*/
|
||||||
File getWorldContainer();
|
File getWorldContainer();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Wrap a player into a PlotPlayer object.
|
* Wrap a player into a PlotPlayer object.
|
||||||
* @param player
|
* @param player The player to convert to a PlotPlayer
|
||||||
* @return
|
* @return A PlotPlayer
|
||||||
*/
|
*/
|
||||||
PlotPlayer wrapPlayer(Object player);
|
PlotPlayer wrapPlayer(Object player);
|
||||||
|
|
||||||
@ -69,20 +69,20 @@ public interface IPlotMain {
|
|||||||
int[] getServerVersion();
|
int[] getServerVersion();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the nms package prefix.
|
* Get the NMS package prefix.
|
||||||
* @return
|
* @return The NMS package prefix
|
||||||
*/
|
*/
|
||||||
String getNMSPackage();
|
String getNMSPackage();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the schematic handler.
|
* Get the schematic handler.
|
||||||
* @return
|
* @return The {@link SchematicHandler}
|
||||||
*/
|
*/
|
||||||
SchematicHandler initSchematicHandler();
|
SchematicHandler initSchematicHandler();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the schematic handler.
|
* Get the Chat Manager.
|
||||||
* @return
|
* @return The {@link ChatManager}
|
||||||
*/
|
*/
|
||||||
ChatManager initChatManager();
|
ChatManager initChatManager();
|
||||||
|
|
||||||
@ -176,24 +176,27 @@ public interface IPlotMain {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* If a world is already loaded, set the generator (use NMS if required).
|
* If a world is already loaded, set the generator (use NMS if required).
|
||||||
* @param world
|
* @param world The world to set the generator
|
||||||
*/
|
*/
|
||||||
void setGenerator(String world);
|
void setGenerator(String world);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the {@link UUIDHandlerImplementation} which will cache and provide UUIDs.
|
* Get the {@link UUIDHandlerImplementation} which will cache and
|
||||||
|
* provide UUIDs.
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
UUIDHandlerImplementation initUUIDHandler();
|
UUIDHandlerImplementation initUUIDHandler();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the {@link InventoryUtil} class (used for implementation specific inventory guis).
|
* Get the {@link InventoryUtil} class (used for implementation specific
|
||||||
|
* inventory guis).
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
InventoryUtil initInventoryUtil();
|
InventoryUtil initInventoryUtil();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Run the converter for the implementation (not necessarily PlotMe, just any plugin that we can convert from).
|
* Run the converter for the implementation (not necessarily PlotMe, just
|
||||||
|
* any plugin that we can convert from).
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
boolean initPlotMeConverter();
|
boolean initPlotMeConverter();
|
||||||
@ -212,26 +215,23 @@ public interface IPlotMain {
|
|||||||
*/
|
*/
|
||||||
GeneratorWrapper<?> getGenerator(String world, String name);
|
GeneratorWrapper<?> getGenerator(String world, String name);
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @param generator
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
GeneratorWrapper<?> wrapPlotGenerator(IndependentPlotGenerator generator);
|
GeneratorWrapper<?> wrapPlotGenerator(IndependentPlotGenerator generator);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Register the chunk processor which will clean out chunks that have too many blockstates or entities.
|
* Register the chunk processor which will clean out chunks that have too
|
||||||
|
* many blockstates or entities.
|
||||||
*/
|
*/
|
||||||
void registerChunkProcessor();
|
void registerChunkProcessor();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Register the world initialization events (used to keep track of worlds being generated).
|
* Register the world initialization events (used to keep track of worlds
|
||||||
|
* being generated).
|
||||||
*/
|
*/
|
||||||
void registerWorldEvents();
|
void registerWorldEvents();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the name of the server.
|
* Get the name of the server.
|
||||||
* @return
|
* @return The server name
|
||||||
*/
|
*/
|
||||||
String getServerName();
|
String getServerName();
|
||||||
|
|
||||||
|
@ -53,6 +53,7 @@ import com.intellectualcrafters.plot.util.WorldUtil;
|
|||||||
import com.intellectualcrafters.plot.util.area.QuadMap;
|
import com.intellectualcrafters.plot.util.area.QuadMap;
|
||||||
import com.plotsquared.listener.WESubscriber;
|
import com.plotsquared.listener.WESubscriber;
|
||||||
import com.sk89q.worldedit.WorldEdit;
|
import com.sk89q.worldedit.WorldEdit;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
@ -89,11 +90,11 @@ import java.util.zip.ZipInputStream;
|
|||||||
public class PS {
|
public class PS {
|
||||||
|
|
||||||
private static PS instance;
|
private static PS instance;
|
||||||
private final HashSet<Integer> plotareaHashCheck = new HashSet<>();
|
private final HashSet<Integer> plotAreaHashCheck = new HashSet<>();
|
||||||
/**
|
/**
|
||||||
* All plot areas mapped by world (quick world access).
|
* All plot areas mapped by world (quick world access).
|
||||||
*/
|
*/
|
||||||
private final HashMap<String, PlotArea[]> plotareamap = new HashMap<>();
|
private final HashMap<String, PlotArea[]> plotAreaMap = new HashMap<>();
|
||||||
/**
|
/**
|
||||||
* All plot areas mapped by location (quick location based access).
|
* All plot areas mapped by location (quick location based access).
|
||||||
*/
|
*/
|
||||||
@ -112,7 +113,7 @@ public class PS {
|
|||||||
public TaskManager TASK;
|
public TaskManager TASK;
|
||||||
public WorldEdit worldedit;
|
public WorldEdit worldedit;
|
||||||
public URL update;
|
public URL update;
|
||||||
private boolean plotareaHasCollision = false;
|
private boolean plotAreaHasCollision = false;
|
||||||
/**
|
/**
|
||||||
* All plot areas (quick global access).
|
* All plot areas (quick global access).
|
||||||
*/
|
*/
|
||||||
@ -306,7 +307,7 @@ public class PS {
|
|||||||
PS.debug(
|
PS.debug(
|
||||||
"&8 - &7Are you trying to delete this world? Remember to remove it from the settings.yml, bukkit.yml and "
|
"&8 - &7Are you trying to delete this world? Remember to remove it from the settings.yml, bukkit.yml and "
|
||||||
+ "multiverse worlds.yml");
|
+ "multiverse worlds.yml");
|
||||||
PS.debug("&8 - &7Your world management plugin may be faulty (or non existant)");
|
PS.debug("&8 - &7Your world management plugin may be faulty (or non existent)");
|
||||||
PS.this.IMP.setGenerator(world);
|
PS.this.IMP.setGenerator(world);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -441,14 +442,14 @@ public class PS {
|
|||||||
int hash = world.hashCode();
|
int hash = world.hashCode();
|
||||||
for (PlotArea area : this.plotAreas) {
|
for (PlotArea area : this.plotAreas) {
|
||||||
if (hash == area.worldhash) {
|
if (hash == area.worldhash) {
|
||||||
if (area.contains(location.getX(), location.getZ()) && (!this.plotareaHasCollision || world.equals(area.worldname))) {
|
if (area.contains(location.getX(), location.getZ()) && (!this.plotAreaHasCollision || world.equals(area.worldname))) {
|
||||||
return area;
|
return area;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
default:
|
default:
|
||||||
PlotArea[] areas = this.plotareamap.get(location.getWorld());
|
PlotArea[] areas = this.plotAreaMap.get(location.getWorld());
|
||||||
if (areas == null) {
|
if (areas == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -480,7 +481,7 @@ public class PS {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public PlotArea getPlotArea(String world, String id) {
|
public PlotArea getPlotArea(String world, String id) {
|
||||||
PlotArea[] areas = this.plotareamap.get(world);
|
PlotArea[] areas = this.plotAreaMap.get(world);
|
||||||
if (areas == null) {
|
if (areas == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -499,7 +500,7 @@ public class PS {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public PlotArea getPlotAreaAbs(String world, String id) {
|
public PlotArea getPlotAreaAbs(String world, String id) {
|
||||||
PlotArea[] areas = this.plotareamap.get(world);
|
PlotArea[] areas = this.plotAreaMap.get(world);
|
||||||
if (areas == null) {
|
if (areas == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -513,7 +514,7 @@ public class PS {
|
|||||||
|
|
||||||
public PlotArea getPlotAreaByString(String search) {
|
public PlotArea getPlotAreaByString(String search) {
|
||||||
String[] split = search.split(";|,");
|
String[] split = search.split(";|,");
|
||||||
PlotArea[] areas = this.plotareamap.get(split[0]);
|
PlotArea[] areas = this.plotAreaMap.get(split[0]);
|
||||||
if (areas == null) {
|
if (areas == null) {
|
||||||
for (PlotArea area : this.plotAreas) {
|
for (PlotArea area : this.plotAreas) {
|
||||||
if (area.worldname.equalsIgnoreCase(split[0])) {
|
if (area.worldname.equalsIgnoreCase(split[0])) {
|
||||||
@ -570,14 +571,14 @@ public class PS {
|
|||||||
int hash = world.hashCode();
|
int hash = world.hashCode();
|
||||||
for (PlotArea area : this.plotAreas) {
|
for (PlotArea area : this.plotAreas) {
|
||||||
if (hash == area.worldhash) {
|
if (hash == area.worldhash) {
|
||||||
if (area.contains(location.getX(), location.getZ()) && (!this.plotareaHasCollision || world.equals(area.worldname))) {
|
if (area.contains(location.getX(), location.getZ()) && (!this.plotAreaHasCollision || world.equals(area.worldname))) {
|
||||||
return area;
|
return area;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
default:
|
default:
|
||||||
PlotArea[] areas = this.plotareamap.get(location.getWorld());
|
PlotArea[] areas = this.plotAreaMap.get(location.getWorld());
|
||||||
if (areas == null) {
|
if (areas == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -630,13 +631,13 @@ public class PS {
|
|||||||
if (plotArea.TYPE == 2) {
|
if (plotArea.TYPE == 2) {
|
||||||
plots = this.plots_tmp.get(plotArea.worldname);
|
plots = this.plots_tmp.get(plotArea.worldname);
|
||||||
if (plots != null) {
|
if (plots != null) {
|
||||||
Iterator<Entry<PlotId, Plot>> iter = plots.entrySet().iterator();
|
Iterator<Entry<PlotId, Plot>> iterator = plots.entrySet().iterator();
|
||||||
while (iter.hasNext()) {
|
while (iterator.hasNext()) {
|
||||||
Entry<PlotId, Plot> next = iter.next();
|
Entry<PlotId, Plot> next = iterator.next();
|
||||||
PlotId id = next.getKey();
|
PlotId id = next.getKey();
|
||||||
if (plotArea.contains(id)) {
|
if (plotArea.contains(id)) {
|
||||||
next.getValue().setArea(plotArea);
|
next.getValue().setArea(plotArea);
|
||||||
iter.remove();
|
iterator.remove();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -652,12 +653,12 @@ public class PS {
|
|||||||
if (plotArea.TYPE == 2) {
|
if (plotArea.TYPE == 2) {
|
||||||
clusters = this.clusters_tmp.get(plotArea.worldname);
|
clusters = this.clusters_tmp.get(plotArea.worldname);
|
||||||
if (clusters != null) {
|
if (clusters != null) {
|
||||||
Iterator<PlotCluster> iter = clusters.iterator();
|
Iterator<PlotCluster> iterator = clusters.iterator();
|
||||||
while (iter.hasNext()) {
|
while (iterator.hasNext()) {
|
||||||
PlotCluster next = iter.next();
|
PlotCluster next = iterator.next();
|
||||||
if (next.intersects(plotArea.getMin(), plotArea.getMax())) {
|
if (next.intersects(plotArea.getMin(), plotArea.getMax())) {
|
||||||
next.setArea(plotArea);
|
next.setArea(plotArea);
|
||||||
iter.remove();
|
iterator.remove();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -672,7 +673,7 @@ public class PS {
|
|||||||
localAreas.add(plotArea);
|
localAreas.add(plotArea);
|
||||||
globalAreas.add(plotArea);
|
globalAreas.add(plotArea);
|
||||||
this.plotAreas = globalAreas.toArray(new PlotArea[globalAreas.size()]);
|
this.plotAreas = globalAreas.toArray(new PlotArea[globalAreas.size()]);
|
||||||
this.plotareamap.put(plotArea.worldname, localAreas.toArray(new PlotArea[localAreas.size()]));
|
this.plotAreaMap.put(plotArea.worldname, localAreas.toArray(new PlotArea[localAreas.size()]));
|
||||||
QuadMap<PlotArea> map = this.plotAreaGrid.get(plotArea.worldname);
|
QuadMap<PlotArea> map = this.plotAreaGrid.get(plotArea.worldname);
|
||||||
if (map == null) {
|
if (map == null) {
|
||||||
map = new QuadMap<PlotArea>(Integer.MAX_VALUE, 0, 0) {
|
map = new QuadMap<PlotArea>(Integer.MAX_VALUE, 0, 0) {
|
||||||
@ -697,10 +698,10 @@ public class PS {
|
|||||||
areas.remove(area);
|
areas.remove(area);
|
||||||
this.plotAreas = areas.toArray(new PlotArea[areas.size()]);
|
this.plotAreas = areas.toArray(new PlotArea[areas.size()]);
|
||||||
if (areas.isEmpty()) {
|
if (areas.isEmpty()) {
|
||||||
this.plotareamap.remove(area.worldname);
|
this.plotAreaMap.remove(area.worldname);
|
||||||
this.plotAreaGrid.remove(area.worldname);
|
this.plotAreaGrid.remove(area.worldname);
|
||||||
} else {
|
} else {
|
||||||
this.plotareamap.put(area.worldname, areas.toArray(new PlotArea[areas.size()]));
|
this.plotAreaMap.put(area.worldname, areas.toArray(new PlotArea[areas.size()]));
|
||||||
this.plotAreaGrid.get(area.worldname).remove(area);
|
this.plotAreaGrid.get(area.worldname).remove(area);
|
||||||
}
|
}
|
||||||
setPlotsTmp(area);
|
setPlotsTmp(area);
|
||||||
@ -922,26 +923,26 @@ public class PS {
|
|||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public ArrayList<Plot> sortPlotsByTimestamp(Collection<Plot> plots) {
|
public ArrayList<Plot> sortPlotsByTimestamp(Collection<Plot> plots) {
|
||||||
int hardmax = 256000;
|
int hardMax = 256000;
|
||||||
int max = 0;
|
int max = 0;
|
||||||
int overflowSize = 0;
|
int overflowSize = 0;
|
||||||
for (Plot plot : plots) {
|
for (Plot plot : plots) {
|
||||||
int hash = MathMan.getPositiveId(plot.hashCode());
|
int hash = MathMan.getPositiveId(plot.hashCode());
|
||||||
if (hash > max) {
|
if (hash > max) {
|
||||||
if (hash >= hardmax) {
|
if (hash >= hardMax) {
|
||||||
overflowSize++;
|
overflowSize++;
|
||||||
} else {
|
} else {
|
||||||
max = hash;
|
max = hash;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
hardmax = Math.min(hardmax, max);
|
hardMax = Math.min(hardMax, max);
|
||||||
Plot[] cache = new Plot[hardmax + 1];
|
Plot[] cache = new Plot[hardMax + 1];
|
||||||
List<Plot> overflow = new ArrayList<>(overflowSize);
|
List<Plot> overflow = new ArrayList<>(overflowSize);
|
||||||
ArrayList<Plot> extra = new ArrayList<>();
|
ArrayList<Plot> extra = new ArrayList<>();
|
||||||
for (Plot plot : plots) {
|
for (Plot plot : plots) {
|
||||||
int hash = MathMan.getPositiveId(plot.hashCode());
|
int hash = MathMan.getPositiveId(plot.hashCode());
|
||||||
if (hash < hardmax) {
|
if (hash < hardMax) {
|
||||||
if (hash >= 0) {
|
if (hash >= 0) {
|
||||||
cache[hash] = plot;
|
cache[hash] = plot;
|
||||||
} else {
|
} else {
|
||||||
@ -1025,17 +1026,17 @@ public class PS {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Sort a collection of plots by world (with a priority world), then by hashcode.
|
* Sort a collection of plots by world (with a priority world), then by hashcode.
|
||||||
* @param myplots
|
* @param myPlots
|
||||||
* @param type The sorting method to use for each world (timestamp, or hash)
|
* @param type The sorting method to use for each world (timestamp, or hash)
|
||||||
* @param priorityArea Use null, "world", or "gibberish" if you want default world order
|
* @param priorityArea Use null, "world", or "gibberish" if you want default world order
|
||||||
* @return ArrayList of plot
|
* @return ArrayList of plot
|
||||||
*/
|
*/
|
||||||
public ArrayList<Plot> sortPlots(Collection<Plot> myplots, SortType type, final PlotArea priorityArea) {
|
public ArrayList<Plot> sortPlots(Collection<Plot> myPlots, SortType type, final PlotArea priorityArea) {
|
||||||
// group by world
|
// group by world
|
||||||
// sort each
|
// sort each
|
||||||
HashMap<PlotArea, Collection<Plot>> map = new HashMap<>();
|
HashMap<PlotArea, Collection<Plot>> map = new HashMap<>();
|
||||||
int totalSize = getPlotCount();
|
int totalSize = getPlotCount();
|
||||||
if (myplots.size() == totalSize) {
|
if (myPlots.size() == totalSize) {
|
||||||
for (PlotArea area : this.plotAreas) {
|
for (PlotArea area : this.plotAreas) {
|
||||||
map.put(area, area.getPlots());
|
map.put(area, area.getPlots());
|
||||||
}
|
}
|
||||||
@ -1045,7 +1046,7 @@ public class PS {
|
|||||||
}
|
}
|
||||||
Collection<Plot> lastList = null;
|
Collection<Plot> lastList = null;
|
||||||
PlotArea lastWorld = null;
|
PlotArea lastWorld = null;
|
||||||
for (Plot plot : myplots) {
|
for (Plot plot : myPlots) {
|
||||||
if (lastWorld == plot.getArea()) {
|
if (lastWorld == plot.getArea()) {
|
||||||
lastList.add(plot);
|
lastList.add(plot);
|
||||||
} else {
|
} else {
|
||||||
@ -1065,7 +1066,7 @@ public class PS {
|
|||||||
return a.hashCode() - b.hashCode();
|
return a.hashCode() - b.hashCode();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
ArrayList<Plot> toReturn = new ArrayList<>(myplots.size());
|
ArrayList<Plot> toReturn = new ArrayList<>(myPlots.size());
|
||||||
for (PlotArea area : areas) {
|
for (PlotArea area : areas) {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case CREATION_DATE:
|
case CREATION_DATE:
|
||||||
@ -1137,15 +1138,15 @@ public class PS {
|
|||||||
* @return Set of plot
|
* @return Set of plot
|
||||||
*/
|
*/
|
||||||
public Set<Plot> getPlots(String world, UUID uuid) {
|
public Set<Plot> getPlots(String world, UUID uuid) {
|
||||||
ArrayList<Plot> myplots = new ArrayList<>();
|
ArrayList<Plot> myPlots = new ArrayList<>();
|
||||||
for (Plot plot : getPlots(world)) {
|
for (Plot plot : getPlots(world)) {
|
||||||
if (plot.hasOwner()) {
|
if (plot.hasOwner()) {
|
||||||
if (plot.isOwnerAbs(uuid)) {
|
if (plot.isOwnerAbs(uuid)) {
|
||||||
myplots.add(plot);
|
myPlots.add(plot);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return new HashSet<>(myplots);
|
return new HashSet<>(myPlots);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1175,7 +1176,7 @@ public class PS {
|
|||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public boolean isPlotWorld(String world) {
|
public boolean isPlotWorld(String world) {
|
||||||
return this.plotareamap.containsKey(world);
|
return this.plotAreaMap.containsKey(world);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1190,7 +1191,7 @@ public class PS {
|
|||||||
return false;
|
return false;
|
||||||
case 1:
|
case 1:
|
||||||
PlotArea a = this.plotAreas[0];
|
PlotArea a = this.plotAreas[0];
|
||||||
return world.hashCode() == a.worldhash && (!this.plotareaHasCollision || a.worldname.equals(world));
|
return world.hashCode() == a.worldhash && (!this.plotAreaHasCollision || a.worldname.equals(world));
|
||||||
case 2:
|
case 2:
|
||||||
case 3:
|
case 3:
|
||||||
case 4:
|
case 4:
|
||||||
@ -1200,13 +1201,13 @@ public class PS {
|
|||||||
case 8:
|
case 8:
|
||||||
int hash = world.hashCode();
|
int hash = world.hashCode();
|
||||||
for (PlotArea area : this.plotAreas) {
|
for (PlotArea area : this.plotAreas) {
|
||||||
if (area.worldhash == hash && (!this.plotareaHasCollision || area.worldname.equals(world))) {
|
if (area.worldhash == hash && (!this.plotAreaHasCollision || area.worldname.equals(world))) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
default:
|
default:
|
||||||
return this.plotareamap.containsKey(world);
|
return this.plotAreaMap.containsKey(world);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1248,16 +1249,16 @@ public class PS {
|
|||||||
* @return Set of Plot
|
* @return Set of Plot
|
||||||
*/
|
*/
|
||||||
public Set<Plot> getPlots(final UUID uuid) {
|
public Set<Plot> getPlots(final UUID uuid) {
|
||||||
final ArrayList<Plot> myplots = new ArrayList<>();
|
final ArrayList<Plot> myPlots = new ArrayList<>();
|
||||||
foreachPlot(new RunnableVal<Plot>() {
|
foreachPlot(new RunnableVal<Plot>() {
|
||||||
@Override
|
@Override
|
||||||
public void run(Plot value) {
|
public void run(Plot value) {
|
||||||
if (value.isOwnerAbs(uuid)) {
|
if (value.isOwnerAbs(uuid)) {
|
||||||
myplots.add(value);
|
myPlots.add(value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return new HashSet<>(myplots);
|
return new HashSet<>(myPlots);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Set<Plot> getBasePlots(final UUID uuid) {
|
public Set<Plot> getBasePlots(final UUID uuid) {
|
||||||
@ -1274,21 +1275,21 @@ public class PS {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the plots for a UUID
|
* Get the plots for a UUID.
|
||||||
* @param uuid
|
* @param uuid The UUID of the owner
|
||||||
* @return Set of Plot
|
* @return Set of Plot
|
||||||
*/
|
*/
|
||||||
public Set<Plot> getPlotsAbs(final UUID uuid) {
|
public Set<Plot> getPlotsAbs(final UUID uuid) {
|
||||||
final ArrayList<Plot> myplots = new ArrayList<>();
|
final ArrayList<Plot> myPlots = new ArrayList<>();
|
||||||
foreachPlot(new RunnableVal<Plot>() {
|
foreachPlot(new RunnableVal<Plot>() {
|
||||||
@Override
|
@Override
|
||||||
public void run(Plot value) {
|
public void run(Plot value) {
|
||||||
if (value.isOwnerAbs(uuid)) {
|
if (value.isOwnerAbs(uuid)) {
|
||||||
myplots.add(value);
|
myPlots.add(value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return new HashSet<>(myplots);
|
return new HashSet<>(myPlots);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1332,15 +1333,15 @@ public class PS {
|
|||||||
if (world.equals("CheckingPlotSquaredGenerator")) {
|
if (world.equals("CheckingPlotSquaredGenerator")) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!this.plotareaHasCollision && !this.plotareaHashCheck.add(world.hashCode())) {
|
if (!this.plotAreaHasCollision && !this.plotAreaHashCheck.add(world.hashCode())) {
|
||||||
this.plotareaHasCollision = true;
|
this.plotAreaHasCollision = true;
|
||||||
}
|
}
|
||||||
Set<String> worlds = this.config.contains("worlds") ? this.config.getConfigurationSection("worlds").getKeys(false) : new HashSet<String>();
|
Set<String> worlds = this.config.contains("worlds") ? this.config.getConfigurationSection("worlds").getKeys(false) : new HashSet<String>();
|
||||||
String path = "worlds." + world;
|
String path = "worlds." + world;
|
||||||
ConfigurationSection worldSection = this.config.getConfigurationSection(path);
|
ConfigurationSection worldSection = this.config.getConfigurationSection(path);
|
||||||
int type = worldSection != null ? worldSection.getInt("generator.type") : 0;
|
int type = worldSection != null ? worldSection.getInt("generator.type") : 0;
|
||||||
if (type == 0) {
|
if (type == 0) {
|
||||||
if (this.plotareamap.containsKey(world)) {
|
if (this.plotAreaMap.containsKey(world)) {
|
||||||
PS.debug("World possibly already loaded: " + world);
|
PS.debug("World possibly already loaded: " + world);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -1392,7 +1393,7 @@ public class PS {
|
|||||||
}
|
}
|
||||||
ConfigurationSection areasSection = worldSection.getConfigurationSection("areas");
|
ConfigurationSection areasSection = worldSection.getConfigurationSection("areas");
|
||||||
if (areasSection == null) {
|
if (areasSection == null) {
|
||||||
if (this.plotareamap.containsKey(world)) {
|
if (this.plotAreaMap.containsKey(world)) {
|
||||||
PS.debug("World possibly already loaded: " + world);
|
PS.debug("World possibly already loaded: " + world);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -2297,7 +2298,7 @@ public class PS {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Show startup debug information
|
* Show startup debug information.
|
||||||
*/
|
*/
|
||||||
private void showDebug() {
|
private void showDebug() {
|
||||||
if (Settings.DEBUG) {
|
if (Settings.DEBUG) {
|
||||||
@ -2335,7 +2336,7 @@ public class PS {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the java version
|
* Get the java version.
|
||||||
* @return Java version as a double
|
* @return Java version as a double
|
||||||
*/
|
*/
|
||||||
public double getJavaVersion() {
|
public double getJavaVersion() {
|
||||||
@ -2378,7 +2379,7 @@ public class PS {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void foreachPlotArea(String world, RunnableVal<PlotArea> runnable) {
|
public void foreachPlotArea(String world, RunnableVal<PlotArea> runnable) {
|
||||||
PlotArea[] array = this.plotareamap.get(world);
|
PlotArea[] array = this.plotAreaMap.get(world);
|
||||||
if (array == null) {
|
if (array == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -2404,7 +2405,7 @@ public class PS {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public int getPlotAreaCount(String world) {
|
public int getPlotAreaCount(String world) {
|
||||||
return this.plotareamap.size();
|
return this.plotAreaMap.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Set<PlotArea> getPlotAreas() {
|
public Set<PlotArea> getPlotAreas() {
|
||||||
@ -2419,15 +2420,15 @@ public class PS {
|
|||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public Set<String> getPlotWorldStrings() {
|
public Set<String> getPlotWorldStrings() {
|
||||||
HashSet<String> set = new HashSet<>(this.plotareamap.size());
|
HashSet<String> set = new HashSet<>(this.plotAreaMap.size());
|
||||||
for (Entry<String, PlotArea[]> entry : this.plotareamap.entrySet()) {
|
for (Entry<String, PlotArea[]> entry : this.plotAreaMap.entrySet()) {
|
||||||
set.add(entry.getKey());
|
set.add(entry.getKey());
|
||||||
}
|
}
|
||||||
return set;
|
return set;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isAugmented(String world) {
|
public boolean isAugmented(String world) {
|
||||||
PlotArea[] areas = this.plotareamap.get(world);
|
PlotArea[] areas = this.plotAreaMap.get(world);
|
||||||
if (areas == null) {
|
if (areas == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -2443,7 +2444,7 @@ public class PS {
|
|||||||
* @return Collection of PlotArea objects
|
* @return Collection of PlotArea objects
|
||||||
*/
|
*/
|
||||||
public Set<PlotArea> getPlotAreas(String world) {
|
public Set<PlotArea> getPlotAreas(String world) {
|
||||||
PlotArea[] areas = this.plotareamap.get(world);
|
PlotArea[] areas = this.plotAreaMap.get(world);
|
||||||
if (areas == null) {
|
if (areas == null) {
|
||||||
return new HashSet<>(0);
|
return new HashSet<>(0);
|
||||||
}
|
}
|
||||||
|
@ -86,17 +86,17 @@ public class Area extends SubCommand {
|
|||||||
Location pos2 = plr.getMeta("area_pos1");
|
Location pos2 = plr.getMeta("area_pos1");
|
||||||
int dx = Math.abs(pos1.getX() - pos2.getX());
|
int dx = Math.abs(pos1.getX() - pos2.getX());
|
||||||
int dz = Math.abs(pos1.getZ() - pos2.getZ());
|
int dz = Math.abs(pos1.getZ() - pos2.getZ());
|
||||||
int numx = Math.max(1, (dx + 1 + area.ROAD_WIDTH + area.SIZE / 2) / area.SIZE);
|
int numX = Math.max(1, (dx + 1 + area.ROAD_WIDTH + area.SIZE / 2) / area.SIZE);
|
||||||
int numz = Math.max(1, (dz + 1 + area.ROAD_WIDTH + area.SIZE / 2) / area.SIZE);
|
int numZ = Math.max(1, (dz + 1 + area.ROAD_WIDTH + area.SIZE / 2) / area.SIZE);
|
||||||
int ddx = dx - (numx * area.SIZE - area.ROAD_WIDTH);
|
int ddx = dx - (numX * area.SIZE - area.ROAD_WIDTH);
|
||||||
int ddz = dz - (numz * area.SIZE - area.ROAD_WIDTH);
|
int ddz = dz - (numZ * area.SIZE - area.ROAD_WIDTH);
|
||||||
int bx = Math.min(pos1.getX(), pos2.getX()) + ddx;
|
int bx = Math.min(pos1.getX(), pos2.getX()) + ddx;
|
||||||
int bz = Math.min(pos1.getZ(), pos2.getZ()) + ddz;
|
int bz = Math.min(pos1.getZ(), pos2.getZ()) + ddz;
|
||||||
int tx = Math.max(pos1.getX(), pos2.getX()) - ddx;
|
int tx = Math.max(pos1.getX(), pos2.getX()) - ddx;
|
||||||
int tz = Math.max(pos1.getZ(), pos2.getZ()) - ddz;
|
int tz = Math.max(pos1.getZ(), pos2.getZ()) - ddz;
|
||||||
int lower = (area.ROAD_WIDTH & 1) == 0 ? area.ROAD_WIDTH / 2 - 1 : area.ROAD_WIDTH / 2;
|
int lower = (area.ROAD_WIDTH & 1) == 0 ? area.ROAD_WIDTH / 2 - 1 : area.ROAD_WIDTH / 2;
|
||||||
final int offsetx = bx - (area.ROAD_WIDTH == 0 ? 0 : lower);
|
final int offsetX = bx - (area.ROAD_WIDTH == 0 ? 0 : lower);
|
||||||
final int offsetz = bz - (area.ROAD_WIDTH == 0 ? 0 : lower);
|
final int offsetZ = bz - (area.ROAD_WIDTH == 0 ? 0 : lower);
|
||||||
final RegionWrapper region = new RegionWrapper(bx, tx, bz, tz);
|
final RegionWrapper region = new RegionWrapper(bx, tx, bz, tz);
|
||||||
Set<PlotArea> areas = PS.get().getPlotAreas(area.worldname, region);
|
Set<PlotArea> areas = PS.get().getPlotAreas(area.worldname, region);
|
||||||
if (!areas.isEmpty()) {
|
if (!areas.isEmpty()) {
|
||||||
@ -109,7 +109,7 @@ public class Area extends SubCommand {
|
|||||||
object.terrain = area.TERRAIN;
|
object.terrain = area.TERRAIN;
|
||||||
object.type = area.TYPE;
|
object.type = area.TYPE;
|
||||||
object.min = new PlotId(1, 1);
|
object.min = new PlotId(1, 1);
|
||||||
object.max = new PlotId(numx, numz);
|
object.max = new PlotId(numX, numZ);
|
||||||
object.plotManager = "PlotSquared";
|
object.plotManager = "PlotSquared";
|
||||||
object.setupGenerator = "PlotSquared";
|
object.setupGenerator = "PlotSquared";
|
||||||
object.step = area.getSettingNodes();
|
object.step = area.getSettingNodes();
|
||||||
@ -117,11 +117,11 @@ public class Area extends SubCommand {
|
|||||||
Runnable run = new Runnable() {
|
Runnable run = new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if (offsetx != 0) {
|
if (offsetX != 0) {
|
||||||
PS.get().config.set(path + ".road.offset.x", offsetx);
|
PS.get().config.set(path + ".road.offset.x", offsetX);
|
||||||
}
|
}
|
||||||
if (offsetz != 0) {
|
if (offsetZ != 0) {
|
||||||
PS.get().config.set(path + ".road.offset.z", offsetz);
|
PS.get().config.set(path + ".road.offset.z", offsetZ);
|
||||||
}
|
}
|
||||||
final String world = SetupUtils.manager.setupWorld(object);
|
final String world = SetupUtils.manager.setupWorld(object);
|
||||||
if (WorldUtil.IMP.isWorld(world)) {
|
if (WorldUtil.IMP.isWorld(world)) {
|
||||||
|
@ -15,6 +15,7 @@ import com.intellectualcrafters.plot.util.MainUtil;
|
|||||||
import com.intellectualcrafters.plot.util.Permissions;
|
import com.intellectualcrafters.plot.util.Permissions;
|
||||||
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.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
@ -237,9 +238,9 @@ public class Cluster extends SubCommand {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
HashSet<Plot> existing = area.getPlotSelectionOwned(cluster.getP1(), cluster.getP2());
|
HashSet<Plot> existing = area.getPlotSelectionOwned(cluster.getP1(), cluster.getP2());
|
||||||
HashSet<Plot> newplots = area.getPlotSelectionOwned(pos1, pos2);
|
HashSet<Plot> newPlots = area.getPlotSelectionOwned(pos1, pos2);
|
||||||
HashSet<Plot> removed = (HashSet<Plot>) existing.clone();
|
HashSet<Plot> removed = (HashSet<Plot>) existing.clone();
|
||||||
removed.removeAll(newplots);
|
removed.removeAll(newPlots);
|
||||||
// Check expand / shrink
|
// Check expand / shrink
|
||||||
if (!removed.isEmpty()) {
|
if (!removed.isEmpty()) {
|
||||||
if (!Permissions.hasPermission(plr, "plots.cluster.resize.shrink")) {
|
if (!Permissions.hasPermission(plr, "plots.cluster.resize.shrink")) {
|
||||||
@ -247,8 +248,8 @@ public class Cluster extends SubCommand {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
newplots.removeAll(existing);
|
newPlots.removeAll(existing);
|
||||||
if (!newplots.isEmpty()) {
|
if (!newPlots.isEmpty()) {
|
||||||
if (!Permissions.hasPermission(plr, "plots.cluster.resize.expand")) {
|
if (!Permissions.hasPermission(plr, "plots.cluster.resize.expand")) {
|
||||||
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.resize.expand");
|
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.resize.expand");
|
||||||
return false;
|
return false;
|
||||||
|
@ -3,19 +3,15 @@ package com.intellectualcrafters.plot.commands;
|
|||||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||||
import com.intellectualcrafters.plot.util.Permissions;
|
import com.intellectualcrafters.plot.util.Permissions;
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by Citymonstret on 2014-08-03.
|
|
||||||
*
|
|
||||||
|
|
||||||
*/
|
|
||||||
public class CommandPermission {
|
public class CommandPermission {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Permission Node
|
* Permission Node.
|
||||||
*/
|
*/
|
||||||
public final String permission;
|
public final String permission;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Command Permission
|
||||||
* @param permission Command Permission
|
* @param permission Command Permission
|
||||||
*/
|
*/
|
||||||
public CommandPermission(String permission) {
|
public CommandPermission(String permission) {
|
||||||
@ -23,7 +19,8 @@ public class CommandPermission {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param player Does the player have the permission?
|
* Check the permissions of a player.
|
||||||
|
* @param player The player to check permissions for
|
||||||
*
|
*
|
||||||
* @return true of player has the required permission node
|
* @return true of player has the required permission node
|
||||||
*/
|
*/
|
||||||
|
@ -10,6 +10,7 @@ import com.intellectualcrafters.plot.util.MathMan;
|
|||||||
import com.intellectualcrafters.plot.util.TaskManager;
|
import com.intellectualcrafters.plot.util.TaskManager;
|
||||||
import com.intellectualcrafters.plot.util.WorldUtil;
|
import com.intellectualcrafters.plot.util.WorldUtil;
|
||||||
import com.plotsquared.general.commands.CommandDeclaration;
|
import com.plotsquared.general.commands.CommandDeclaration;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
@ -55,13 +56,13 @@ public class Condense extends SubCommand {
|
|||||||
int radius = Integer.parseInt(args[2]);
|
int radius = Integer.parseInt(args[2]);
|
||||||
ArrayList<Plot> plots = new ArrayList<>(PS.get().getPlots(area));
|
ArrayList<Plot> plots = new ArrayList<>(PS.get().getPlots(area));
|
||||||
// remove non base plots
|
// remove non base plots
|
||||||
Iterator<Plot> iter = plots.iterator();
|
Iterator<Plot> iterator = plots.iterator();
|
||||||
int maxSize = 0;
|
int maxSize = 0;
|
||||||
ArrayList<Integer> sizes = new ArrayList<>();
|
ArrayList<Integer> sizes = new ArrayList<>();
|
||||||
while (iter.hasNext()) {
|
while (iterator.hasNext()) {
|
||||||
Plot plot = iter.next();
|
Plot plot = iterator.next();
|
||||||
if (!plot.isBasePlot()) {
|
if (!plot.isBasePlot()) {
|
||||||
iter.remove();
|
iterator.remove();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
int size = plot.getConnectedPlots().size();
|
int size = plot.getConnectedPlots().size();
|
||||||
|
@ -95,7 +95,7 @@ public class DebugClaimTest extends SubCommand {
|
|||||||
plot.owner = uuid;
|
plot.owner = 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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -350,10 +350,10 @@ public class ListCmd extends SubCommand {
|
|||||||
public void displayPlots(final PlotPlayer player, java.util.List<Plot> plots, int pageSize, int page, PlotArea area,
|
public void displayPlots(final PlotPlayer player, java.util.List<Plot> plots, int pageSize, int page, PlotArea area,
|
||||||
String[] args, boolean sort) {
|
String[] args, boolean sort) {
|
||||||
// Header
|
// Header
|
||||||
Iterator<Plot> iter = plots.iterator();
|
Iterator<Plot> iterator = plots.iterator();
|
||||||
while (iter.hasNext()) {
|
while (iterator.hasNext()) {
|
||||||
if (!iter.next().isBasePlot()) {
|
if (!iterator.next().isBasePlot()) {
|
||||||
iter.remove();
|
iterator.remove();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (sort) {
|
if (sort) {
|
||||||
|
@ -65,9 +65,9 @@ public class Load extends SubCommand {
|
|||||||
MainUtil.sendMessage(plr, C.LOAD_NULL);
|
MainUtil.sendMessage(plr, C.LOAD_NULL);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
String schem;
|
String schematic;
|
||||||
try {
|
try {
|
||||||
schem = schematics.get(Integer.parseInt(args[0]) - 1);
|
schematic = schematics.get(Integer.parseInt(args[0]) - 1);
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
// 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() + ")");
|
||||||
@ -75,7 +75,7 @@ public class Load extends SubCommand {
|
|||||||
}
|
}
|
||||||
final URL url;
|
final URL url;
|
||||||
try {
|
try {
|
||||||
url = new URL(Settings.WEB_URL + "saves/" + plr.getUUID() + "/" + schem + ".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);
|
||||||
@ -140,8 +140,8 @@ public class Load extends SubCommand {
|
|||||||
List<String> schematics = player.getMeta("plot_schematics");
|
List<String> schematics = player.getMeta("plot_schematics");
|
||||||
for (int i = 0; i < Math.min(schematics.size(), 32); i++) {
|
for (int i = 0; i < Math.min(schematics.size(), 32); i++) {
|
||||||
try {
|
try {
|
||||||
String schem = schematics.get(i);
|
String schematic = schematics.get(i);
|
||||||
String[] split = schem.split("_");
|
String[] split = schematic.split("_");
|
||||||
if (split.length != 6) {
|
if (split.length != 6) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -121,8 +121,8 @@ public class Purge extends SubCommand {
|
|||||||
}
|
}
|
||||||
if (PS.get().plots_tmp != null) {
|
if (PS.get().plots_tmp != null) {
|
||||||
for (Entry<String, HashMap<PlotId, Plot>> entry : PS.get().plots_tmp.entrySet()) {
|
for (Entry<String, HashMap<PlotId, Plot>> entry : PS.get().plots_tmp.entrySet()) {
|
||||||
String worldname = entry.getKey();
|
String worldName = entry.getKey();
|
||||||
if (world != null && !world.equalsIgnoreCase(worldname)) {
|
if (world != null && !world.equalsIgnoreCase(worldName)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
for (Entry<PlotId, Plot> entry2 : entry.getValue().entrySet()) {
|
for (Entry<PlotId, Plot> entry2 : entry.getValue().entrySet()) {
|
||||||
|
@ -20,16 +20,16 @@ public class Target extends SubCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(PlotPlayer plr, String[] args) {
|
public boolean onCommand(PlotPlayer plr, String[] args) {
|
||||||
Location ploc = plr.getLocation();
|
Location plrLocation = plr.getLocation();
|
||||||
if (!ploc.isPlotArea()) {
|
if (!plrLocation.isPlotArea()) {
|
||||||
MainUtil.sendMessage(plr, C.NOT_IN_PLOT_WORLD);
|
MainUtil.sendMessage(plr, C.NOT_IN_PLOT_WORLD);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
Plot target = null;
|
Plot target = null;
|
||||||
if (StringMan.isEqualIgnoreCaseToAny(args[0], "near", "nearest")) {
|
if (StringMan.isEqualIgnoreCaseToAny(args[0], "near", "nearest")) {
|
||||||
int distance = Integer.MAX_VALUE;
|
int distance = Integer.MAX_VALUE;
|
||||||
for (Plot plot : PS.get().getPlots(ploc.getWorld())) {
|
for (Plot plot : PS.get().getPlots(plrLocation.getWorld())) {
|
||||||
double current = plot.getCenter().getEuclideanDistanceSquared(ploc);
|
double current = plot.getCenter().getEuclideanDistanceSquared(plrLocation);
|
||||||
if (current < distance) {
|
if (current < distance) {
|
||||||
distance = (int) current;
|
distance = (int) current;
|
||||||
target = plot;
|
target = plot;
|
||||||
|
@ -14,6 +14,7 @@ import com.intellectualcrafters.plot.util.MainUtil;
|
|||||||
import com.intellectualcrafters.plot.util.TaskManager;
|
import com.intellectualcrafters.plot.util.TaskManager;
|
||||||
import com.intellectualcrafters.plot.util.WorldUtil;
|
import com.intellectualcrafters.plot.util.WorldUtil;
|
||||||
import com.plotsquared.general.commands.CommandDeclaration;
|
import com.plotsquared.general.commands.CommandDeclaration;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
@ -164,9 +165,9 @@ public class Trim extends SubCommand {
|
|||||||
plr.sendMessage("Trim done!");
|
plr.sendMessage("Trim done!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Iterator<ChunkLoc> iter = nonViable.iterator();
|
Iterator<ChunkLoc> iterator = nonViable.iterator();
|
||||||
ChunkLoc mcr = iter.next();
|
ChunkLoc mcr = iterator.next();
|
||||||
iter.remove();
|
iterator.remove();
|
||||||
int cbx = mcr.x << 5;
|
int cbx = mcr.x << 5;
|
||||||
int cbz = mcr.z << 5;
|
int cbz = mcr.z << 5;
|
||||||
// get all 1024 chunks
|
// get all 1024 chunks
|
||||||
|
@ -9,6 +9,7 @@ import com.intellectualcrafters.plot.util.MathMan;
|
|||||||
import com.intellectualcrafters.plot.util.Permissions;
|
import com.intellectualcrafters.plot.util.Permissions;
|
||||||
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.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
@ -85,10 +86,10 @@ public class Visit extends SubCommand {
|
|||||||
sendMessage(player, C.FOUND_NO_PLOTS);
|
sendMessage(player, C.FOUND_NO_PLOTS);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
Iterator<Plot> iter = unsorted.iterator();
|
Iterator<Plot> iterator = unsorted.iterator();
|
||||||
while (iter.hasNext()) {
|
while (iterator.hasNext()) {
|
||||||
if (!iter.next().isBasePlot()) {
|
if (!iterator.next().isBasePlot()) {
|
||||||
iter.remove();
|
iterator.remove();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (page < 1 || page > unsorted.size()) {
|
if (page < 1 || page > unsorted.size()) {
|
||||||
|
@ -1599,7 +1599,7 @@ public class SQLManager implements AbstractDB {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public HashMap<String, HashMap<PlotId, Plot>> getPlots() {
|
public HashMap<String, HashMap<PlotId, Plot>> getPlots() {
|
||||||
HashMap<String, HashMap<PlotId, Plot>> newplots = new HashMap<>();
|
HashMap<String, HashMap<PlotId, Plot>> newPlots = new HashMap<>();
|
||||||
HashMap<Integer, Plot> plots = new HashMap<>();
|
HashMap<Integer, Plot> plots = new HashMap<>();
|
||||||
try {
|
try {
|
||||||
HashSet<String> areas = new HashSet<>();
|
HashSet<String> areas = new HashSet<>();
|
||||||
@ -1660,7 +1660,7 @@ public class SQLManager implements AbstractDB {
|
|||||||
long time = timestamp.getTime();
|
long time = timestamp.getTime();
|
||||||
Plot p = new Plot(plot_id, user, new HashSet<UUID>(), new HashSet<UUID>(), new HashSet<UUID>(), "", null, null, null,
|
Plot p = new Plot(plot_id, user, new HashSet<UUID>(), new HashSet<UUID>(), new HashSet<UUID>(), "", null, null, null,
|
||||||
new boolean[]{false, false, false, false}, time, id);
|
new boolean[]{false, false, false, false}, time, id);
|
||||||
HashMap<PlotId, Plot> map = newplots.get(areaid);
|
HashMap<PlotId, Plot> map = newPlots.get(areaid);
|
||||||
if (map != null) {
|
if (map != null) {
|
||||||
Plot last = map.put(p.getId(), p);
|
Plot last = map.put(p.getId(), p);
|
||||||
if (last != null) {
|
if (last != null) {
|
||||||
@ -1675,7 +1675,7 @@ public class SQLManager implements AbstractDB {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
map = new HashMap<>();
|
map = new HashMap<>();
|
||||||
newplots.put(areaid, map);
|
newPlots.put(areaid, map);
|
||||||
map.put(p.getId(), p);
|
map.put(p.getId(), p);
|
||||||
}
|
}
|
||||||
plots.put(id, p);
|
plots.put(id, p);
|
||||||
@ -1872,9 +1872,9 @@ public class SQLManager implements AbstractDB {
|
|||||||
}
|
}
|
||||||
boolean invalidPlot = false;
|
boolean invalidPlot = false;
|
||||||
for (Entry<String, AtomicInteger> entry : noExist.entrySet()) {
|
for (Entry<String, AtomicInteger> entry : noExist.entrySet()) {
|
||||||
String worldname = entry.getKey();
|
String worldName = entry.getKey();
|
||||||
invalidPlot = true;
|
invalidPlot = true;
|
||||||
PS.debug("&c[WARNING] Found " + entry.getValue().intValue() + " plots in DB for non existant world; '" + worldname + "'.");
|
PS.debug("&c[WARNING] Found " + entry.getValue().intValue() + " plots in DB for non existent world; '" + worldName + "'.");
|
||||||
}
|
}
|
||||||
if (invalidPlot) {
|
if (invalidPlot) {
|
||||||
PS.debug("&c[WARNING] - Please create the world/s or remove the plots using the purge command");
|
PS.debug("&c[WARNING] - Please create the world/s or remove the plots using the purge command");
|
||||||
@ -1883,7 +1883,7 @@ public class SQLManager implements AbstractDB {
|
|||||||
PS.debug("&7[WARN] " + "Failed to load plots.");
|
PS.debug("&7[WARN] " + "Failed to load plots.");
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
return newplots;
|
return newPlots;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -2072,9 +2072,9 @@ public class SQLManager implements AbstractDB {
|
|||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
PS.debug("&c[ERROR] " + "FAILED TO PURGE AREA '" + area + "'!");
|
PS.debug("&c[ERROR] " + "FAILED TO PURGE AREA '" + area + "'!");
|
||||||
}
|
}
|
||||||
for (Iterator<PlotId> iter = plots.iterator(); iter.hasNext(); ) {
|
for (Iterator<PlotId> iterator = plots.iterator(); iterator.hasNext(); ) {
|
||||||
PlotId plotId = iter.next();
|
PlotId plotId = iterator.next();
|
||||||
iter.remove();
|
iterator.remove();
|
||||||
PlotId id = new PlotId(plotId.x, plotId.y);
|
PlotId id = new PlotId(plotId.x, plotId.y);
|
||||||
area.removePlot(id);
|
area.removePlot(id);
|
||||||
}
|
}
|
||||||
@ -2673,7 +2673,7 @@ public class SQLManager implements AbstractDB {
|
|||||||
for (Entry<String, Integer> entry : noExist.entrySet()) {
|
for (Entry<String, Integer> entry : noExist.entrySet()) {
|
||||||
String a = entry.getKey();
|
String a = entry.getKey();
|
||||||
invalidPlot = true;
|
invalidPlot = true;
|
||||||
PS.debug("&c[WARNING] Found " + noExist.get(a) + " clusters in DB for non existant area; '" + a + "'.");
|
PS.debug("&c[WARNING] Found " + noExist.get(a) + " clusters in DB for non existent area; '" + a + "'.");
|
||||||
}
|
}
|
||||||
if (invalidPlot) {
|
if (invalidPlot) {
|
||||||
PS.debug("&c[WARNING] - Please create the world/s or remove the clusters using the purge command");
|
PS.debug("&c[WARNING] - Please create the world/s or remove the clusters using the purge command");
|
||||||
@ -2943,29 +2943,29 @@ public class SQLManager implements AbstractDB {
|
|||||||
if (plot.temp == -1) {
|
if (plot.temp == -1) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
HashMap<PlotId, Plot> worldplots = database.get(plot.getArea().toString());
|
HashMap<PlotId, Plot> worldPlots = database.get(plot.getArea().toString());
|
||||||
if (worldplots == null) {
|
if (worldPlots == null) {
|
||||||
PS.debug("&8 - &7Creating plot (1): " + plot);
|
PS.debug("&8 - &7Creating plot (1): " + plot);
|
||||||
toCreate.add(plot);
|
toCreate.add(plot);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
Plot dataplot = worldplots.remove(plot.getId());
|
Plot dataPlot = worldPlots.remove(plot.getId());
|
||||||
if (dataplot == null) {
|
if (dataPlot == null) {
|
||||||
PS.debug("&8 - &7Creating plot (2): " + plot);
|
PS.debug("&8 - &7Creating plot (2): " + plot);
|
||||||
toCreate.add(plot);
|
toCreate.add(plot);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// owner
|
// owner
|
||||||
if (!plot.owner.equals(dataplot.owner)) {
|
if (!plot.owner.equals(dataPlot.owner)) {
|
||||||
PS.debug("&8 - &7Setting owner: " + plot + " -> " + MainUtil.getName(plot.owner));
|
PS.debug("&8 - &7Setting owner: " + plot + " -> " + MainUtil.getName(plot.owner));
|
||||||
setOwner(plot, plot.owner);
|
setOwner(plot, plot.owner);
|
||||||
}
|
}
|
||||||
// trusted
|
// trusted
|
||||||
if (!plot.getTrusted().equals(dataplot.getTrusted())) {
|
if (!plot.getTrusted().equals(dataPlot.getTrusted())) {
|
||||||
HashSet<UUID> toAdd = (HashSet<UUID>) plot.getTrusted().clone();
|
HashSet<UUID> toAdd = (HashSet<UUID>) plot.getTrusted().clone();
|
||||||
HashSet<UUID> toRemove = (HashSet<UUID>) dataplot.getTrusted().clone();
|
HashSet<UUID> toRemove = (HashSet<UUID>) dataPlot.getTrusted().clone();
|
||||||
toRemove.removeAll(plot.getTrusted());
|
toRemove.removeAll(plot.getTrusted());
|
||||||
toAdd.removeAll(dataplot.getTrusted());
|
toAdd.removeAll(dataPlot.getTrusted());
|
||||||
PS.debug("&8 - &7Correcting " + (toAdd.size() + toRemove.size()) + " trusted for: " + plot);
|
PS.debug("&8 - &7Correcting " + (toAdd.size() + toRemove.size()) + " trusted for: " + plot);
|
||||||
if (!toRemove.isEmpty()) {
|
if (!toRemove.isEmpty()) {
|
||||||
for (UUID uuid : toRemove) {
|
for (UUID uuid : toRemove) {
|
||||||
@ -2978,11 +2978,11 @@ public class SQLManager implements AbstractDB {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!plot.getMembers().equals(dataplot.getMembers())) {
|
if (!plot.getMembers().equals(dataPlot.getMembers())) {
|
||||||
HashSet<UUID> toAdd = (HashSet<UUID>) plot.getMembers().clone();
|
HashSet<UUID> toAdd = (HashSet<UUID>) plot.getMembers().clone();
|
||||||
HashSet<UUID> toRemove = (HashSet<UUID>) dataplot.getMembers().clone();
|
HashSet<UUID> toRemove = (HashSet<UUID>) dataPlot.getMembers().clone();
|
||||||
toRemove.removeAll(plot.getMembers());
|
toRemove.removeAll(plot.getMembers());
|
||||||
toAdd.removeAll(dataplot.getMembers());
|
toAdd.removeAll(dataPlot.getMembers());
|
||||||
PS.debug("&8 - &7Correcting " + (toAdd.size() + toRemove.size()) + " members for: " + plot);
|
PS.debug("&8 - &7Correcting " + (toAdd.size() + toRemove.size()) + " members for: " + plot);
|
||||||
if (!toRemove.isEmpty()) {
|
if (!toRemove.isEmpty()) {
|
||||||
for (UUID uuid : toRemove) {
|
for (UUID uuid : toRemove) {
|
||||||
@ -2995,11 +2995,11 @@ public class SQLManager implements AbstractDB {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!plot.getDenied().equals(dataplot.getDenied())) {
|
if (!plot.getDenied().equals(dataPlot.getDenied())) {
|
||||||
HashSet<UUID> toAdd = (HashSet<UUID>) plot.getDenied().clone();
|
HashSet<UUID> toAdd = (HashSet<UUID>) plot.getDenied().clone();
|
||||||
HashSet<UUID> toRemove = (HashSet<UUID>) dataplot.getDenied().clone();
|
HashSet<UUID> toRemove = (HashSet<UUID>) dataPlot.getDenied().clone();
|
||||||
toRemove.removeAll(plot.getDenied());
|
toRemove.removeAll(plot.getDenied());
|
||||||
toAdd.removeAll(dataplot.getDenied());
|
toAdd.removeAll(dataPlot.getDenied());
|
||||||
PS.debug("&8 - &7Correcting " + (toAdd.size() + toRemove.size()) + " denied for: " + plot);
|
PS.debug("&8 - &7Correcting " + (toAdd.size() + toRemove.size()) + " denied for: " + plot);
|
||||||
if (!toRemove.isEmpty()) {
|
if (!toRemove.isEmpty()) {
|
||||||
for (UUID uuid : toRemove) {
|
for (UUID uuid : toRemove) {
|
||||||
@ -3013,13 +3013,13 @@ public class SQLManager implements AbstractDB {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
boolean[] pm = plot.getMerged();
|
boolean[] pm = plot.getMerged();
|
||||||
boolean[] dm = dataplot.getMerged();
|
boolean[] dm = dataPlot.getMerged();
|
||||||
if (pm[0] != dm[0] || pm[1] != dm[1]) {
|
if (pm[0] != dm[0] || pm[1] != dm[1]) {
|
||||||
PS.debug("&8 - &7Correcting merge for: " + plot);
|
PS.debug("&8 - &7Correcting merge for: " + plot);
|
||||||
setMerged(dataplot, plot.getMerged());
|
setMerged(dataPlot, plot.getMerged());
|
||||||
}
|
}
|
||||||
HashMap<String, Flag> pf = plot.getFlags();
|
HashMap<String, Flag> pf = plot.getFlags();
|
||||||
HashMap<String, Flag> df = dataplot.getFlags();
|
HashMap<String, Flag> df = dataPlot.getFlags();
|
||||||
if (!pf.isEmpty() && !df.isEmpty()) {
|
if (!pf.isEmpty() && !df.isEmpty()) {
|
||||||
if (pf.size() != df.size() || !StringMan.isEqual(StringMan.joinOrdered(pf.values(), ","), StringMan.joinOrdered(df.values(), ","))) {
|
if (pf.size() != df.size() || !StringMan.isEqual(StringMan.joinOrdered(pf.values(), ","), StringMan.joinOrdered(df.values(), ","))) {
|
||||||
PS.debug("&8 - &7Correcting flags for: " + plot);
|
PS.debug("&8 - &7Correcting flags for: " + plot);
|
||||||
|
@ -172,23 +172,24 @@ public class HybridPlotWorld extends ClassicPlotWorld {
|
|||||||
|
|
||||||
public void setupSchematics() {
|
public void setupSchematics() {
|
||||||
this.G_SCH = new HashMap<>();
|
this.G_SCH = new HashMap<>();
|
||||||
File schem1File = MainUtil.getFile(PS.get().IMP.getDirectory(), "schematics/GEN_ROAD_SCHEMATIC/" + this.worldname + "/sideroad.schematic");
|
File schematic1File =
|
||||||
File schem2File =
|
MainUtil.getFile(PS.get().IMP.getDirectory(), "schematics/GEN_ROAD_SCHEMATIC/" + this.worldname + "/sideroad.schematic");
|
||||||
|
File schematic2File =
|
||||||
MainUtil.getFile(PS.get().IMP.getDirectory(), "schematics/GEN_ROAD_SCHEMATIC/" + this.worldname + "/intersection.schematic");
|
MainUtil.getFile(PS.get().IMP.getDirectory(), "schematics/GEN_ROAD_SCHEMATIC/" + this.worldname + "/intersection.schematic");
|
||||||
File schem3File = MainUtil.getFile(PS.get().IMP.getDirectory(), "schematics/GEN_ROAD_SCHEMATIC/" + this.worldname + "/plot.schematic");
|
File schem3File = MainUtil.getFile(PS.get().IMP.getDirectory(), "schematics/GEN_ROAD_SCHEMATIC/" + this.worldname + "/plot.schematic");
|
||||||
Schematic schem1 = SchematicHandler.manager.getSchematic(schem1File);
|
Schematic schematic1 = SchematicHandler.manager.getSchematic(schematic1File);
|
||||||
Schematic schem2 = SchematicHandler.manager.getSchematic(schem2File);
|
Schematic schematic2 = SchematicHandler.manager.getSchematic(schematic2File);
|
||||||
Schematic schem3 = SchematicHandler.manager.getSchematic(schem3File);
|
Schematic schematic3 = SchematicHandler.manager.getSchematic(schem3File);
|
||||||
int shift = this.ROAD_WIDTH / 2;
|
int shift = this.ROAD_WIDTH / 2;
|
||||||
int oddshift = 0;
|
int oddshift = 0;
|
||||||
if ((this.ROAD_WIDTH & 1) != 0) {
|
if ((this.ROAD_WIDTH & 1) != 0) {
|
||||||
oddshift = 1;
|
oddshift = 1;
|
||||||
}
|
}
|
||||||
if (schem3 != null) {
|
if (schematic3 != null) {
|
||||||
this.PLOT_SCHEMATIC = true;
|
this.PLOT_SCHEMATIC = true;
|
||||||
short[] ids = schem3.getIds();
|
short[] ids = schematic3.getIds();
|
||||||
byte[] datas = schem3.getDatas();
|
byte[] datas = schematic3.getDatas();
|
||||||
Dimension d3 = schem3.getSchematicDimension();
|
Dimension d3 = schematic3.getSchematicDimension();
|
||||||
short w3 = (short) d3.getX();
|
short w3 = (short) d3.getX();
|
||||||
short l3 = (short) d3.getZ();
|
short l3 = (short) d3.getZ();
|
||||||
short h3 = (short) d3.getY();
|
short h3 = (short) d3.getY();
|
||||||
@ -214,7 +215,7 @@ public class HybridPlotWorld extends ClassicPlotWorld {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
HashSet<PlotItem> items = schem3.getItems();
|
HashSet<PlotItem> items = schematic3.getItems();
|
||||||
if (items != null) {
|
if (items != null) {
|
||||||
this.G_SCH_STATE = new HashMap<>();
|
this.G_SCH_STATE = new HashMap<>();
|
||||||
for (PlotItem item : items) {
|
for (PlotItem item : items) {
|
||||||
@ -235,7 +236,7 @@ public class HybridPlotWorld extends ClassicPlotWorld {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (schem1 == null || schem2 == null || this.ROAD_WIDTH == 0) {
|
if (schematic1 == null || schematic2 == null || this.ROAD_WIDTH == 0) {
|
||||||
PS.debug(C.PREFIX + "&3 - schematic: &7false");
|
PS.debug(C.PREFIX + "&3 - schematic: &7false");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -243,17 +244,17 @@ public class HybridPlotWorld extends ClassicPlotWorld {
|
|||||||
// Do not populate road if using schematic population
|
// Do not populate road if using schematic population
|
||||||
this.ROAD_BLOCK = new PlotBlock(this.ROAD_BLOCK.id, (byte) 0);
|
this.ROAD_BLOCK = new PlotBlock(this.ROAD_BLOCK.id, (byte) 0);
|
||||||
|
|
||||||
short[] ids1 = schem1.getIds();
|
short[] ids1 = schematic1.getIds();
|
||||||
byte[] datas1 = schem1.getDatas();
|
byte[] datas1 = schematic1.getDatas();
|
||||||
|
|
||||||
short[] ids2 = schem2.getIds();
|
short[] ids2 = schematic2.getIds();
|
||||||
byte[] datas2 = schem2.getDatas();
|
byte[] datas2 = schematic2.getDatas();
|
||||||
|
|
||||||
Dimension d1 = schem1.getSchematicDimension();
|
Dimension d1 = schematic1.getSchematicDimension();
|
||||||
short w1 = (short) d1.getX();
|
short w1 = (short) d1.getX();
|
||||||
short l1 = (short) d1.getZ();
|
short l1 = (short) d1.getZ();
|
||||||
short h1 = (short) d1.getY();
|
short h1 = (short) d1.getY();
|
||||||
Dimension d2 = schem2.getSchematicDimension();
|
Dimension d2 = schematic2.getSchematicDimension();
|
||||||
short w2 = (short) d2.getX();
|
short w2 = (short) d2.getX();
|
||||||
short l2 = (short) d2.getZ();
|
short l2 = (short) d2.getZ();
|
||||||
short h2 = (short) d2.getY();
|
short h2 = (short) d2.getY();
|
||||||
@ -293,9 +294,9 @@ public class HybridPlotWorld extends ClassicPlotWorld {
|
|||||||
x += this.SIZE;
|
x += this.SIZE;
|
||||||
}
|
}
|
||||||
if (rotate) {
|
if (rotate) {
|
||||||
byte newdata = rotate(id, data);
|
byte newData = rotate(id, data);
|
||||||
if (data != 0 || newdata != 0) {
|
if (data != 0 || newData != 0) {
|
||||||
data = newdata;
|
data = newData;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
int pair = MathMan.pair(x, z);
|
int pair = MathMan.pair(x, z);
|
||||||
|
@ -223,9 +223,9 @@ public abstract class HybridUtils {
|
|||||||
}
|
}
|
||||||
if (chunks.size() < 1024) {
|
if (chunks.size() < 1024) {
|
||||||
if (!regions.isEmpty()) {
|
if (!regions.isEmpty()) {
|
||||||
Iterator<ChunkLoc> iter = regions.iterator();
|
Iterator<ChunkLoc> iterator = regions.iterator();
|
||||||
ChunkLoc loc = iter.next();
|
ChunkLoc loc = iterator.next();
|
||||||
iter.remove();
|
iterator.remove();
|
||||||
PS.debug("&3Updating .mcr: " + loc.x + ", " + loc.z + " (aprrox 1024 chunks)");
|
PS.debug("&3Updating .mcr: " + loc.x + ", " + loc.z + " (aprrox 1024 chunks)");
|
||||||
PS.debug(" - Remaining: " + regions.size());
|
PS.debug(" - Remaining: " + regions.size());
|
||||||
chunks.addAll(getChunks(loc));
|
chunks.addAll(getChunks(loc));
|
||||||
@ -237,9 +237,9 @@ public abstract class HybridUtils {
|
|||||||
if (System.currentTimeMillis() - baseTime - last.get() > 2000 && last.get() != 0) {
|
if (System.currentTimeMillis() - baseTime - last.get() > 2000 && last.get() != 0) {
|
||||||
last.set(0);
|
last.set(0);
|
||||||
PS.debug(C.PREFIX.s() + "Detected low TPS. Rescheduling in 30s");
|
PS.debug(C.PREFIX.s() + "Detected low TPS. Rescheduling in 30s");
|
||||||
Iterator<ChunkLoc> iter = chunks.iterator();
|
Iterator<ChunkLoc> iterator = chunks.iterator();
|
||||||
final ChunkLoc chunk = iter.next();
|
final ChunkLoc chunk = iterator.next();
|
||||||
iter.remove();
|
iterator.remove();
|
||||||
TaskManager.runTask(new Runnable() {
|
TaskManager.runTask(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
@ -252,9 +252,9 @@ public abstract class HybridUtils {
|
|||||||
}
|
}
|
||||||
if (System.currentTimeMillis() - baseTime - last.get() < 1500 && last.get() != 0) {
|
if (System.currentTimeMillis() - baseTime - last.get() < 1500 && last.get() != 0) {
|
||||||
while (System.currentTimeMillis() < diff && !chunks.isEmpty()) {
|
while (System.currentTimeMillis() < diff && !chunks.isEmpty()) {
|
||||||
Iterator<ChunkLoc> iter = chunks.iterator();
|
Iterator<ChunkLoc> iterator = chunks.iterator();
|
||||||
final ChunkLoc chunk = iter.next();
|
final ChunkLoc chunk = iterator.next();
|
||||||
iter.remove();
|
iterator.remove();
|
||||||
TaskManager.runTask(new Runnable() {
|
TaskManager.runTask(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
@ -267,9 +267,9 @@ public abstract class HybridUtils {
|
|||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
Iterator<ChunkLoc> iter = regions.iterator();
|
Iterator<ChunkLoc> iterator = regions.iterator();
|
||||||
ChunkLoc loc = iter.next();
|
ChunkLoc loc = iterator.next();
|
||||||
iter.remove();
|
iterator.remove();
|
||||||
PS.debug("&c[ERROR]&7 Could not update '" + area.worldname + "/region/r." + loc.x + "." + loc.z
|
PS.debug("&c[ERROR]&7 Could not update '" + area.worldname + "/region/r." + loc.x + "." + loc.z
|
||||||
+ ".mca' (Corrupt chunk?)");
|
+ ".mca' (Corrupt chunk?)");
|
||||||
int sx = loc.x << 5;
|
int sx = loc.x << 5;
|
||||||
@ -311,12 +311,12 @@ public abstract class HybridUtils {
|
|||||||
int tz = sz - 1;
|
int tz = sz - 1;
|
||||||
int ty = get_ey(world, sx, ex, bz, tz, sy);
|
int ty = get_ey(world, sx, ex, bz, tz, sy);
|
||||||
|
|
||||||
Set<RegionWrapper> sideroad = new HashSet<>(Collections.singletonList(new RegionWrapper(sx, ex, sy, ey, sz, ez)));
|
Set<RegionWrapper> sideRoad = new HashSet<>(Collections.singletonList(new RegionWrapper(sx, ex, sy, ey, sz, ez)));
|
||||||
final Set<RegionWrapper> intersection = new HashSet<>(Collections.singletonList(new RegionWrapper(sx, ex, sy, ty, bz, tz)));
|
final Set<RegionWrapper> intersection = new HashSet<>(Collections.singletonList(new RegionWrapper(sx, ex, sy, ty, bz, tz)));
|
||||||
|
|
||||||
final String dir = "schematics" + File.separator + "GEN_ROAD_SCHEMATIC" + File.separator + plot
|
final String dir = "schematics" + File.separator + "GEN_ROAD_SCHEMATIC" + File.separator + plot
|
||||||
.getArea().toString() + File.separator;
|
.getArea().toString() + File.separator;
|
||||||
SchematicHandler.manager.getCompoundTag(world, sideroad, new RunnableVal<CompoundTag>() {
|
SchematicHandler.manager.getCompoundTag(world, sideRoad, new RunnableVal<CompoundTag>() {
|
||||||
@Override
|
@Override
|
||||||
public void run(CompoundTag value) {
|
public void run(CompoundTag value) {
|
||||||
SchematicHandler.manager.save(value, dir + "sideroad.schematic");
|
SchematicHandler.manager.save(value, dir + "sideroad.schematic");
|
||||||
|
@ -28,9 +28,9 @@ public abstract class SquarePlotManager extends GridPlotManager {
|
|||||||
whenDone.run();
|
whenDone.run();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Iterator<RegionWrapper> iter = regions.iterator();
|
Iterator<RegionWrapper> iterator = regions.iterator();
|
||||||
RegionWrapper region = iter.next();
|
RegionWrapper region = iterator.next();
|
||||||
iter.remove();
|
iterator.remove();
|
||||||
Location pos1 = new Location(plot.getArea().worldname, region.minX, region.minY, region.minZ);
|
Location pos1 = new Location(plot.getArea().worldname, region.minX, region.minY, region.minZ);
|
||||||
Location pos2 = new Location(plot.getArea().worldname, region.maxX, region.maxY, region.maxZ);
|
Location pos2 = new Location(plot.getArea().worldname, region.maxX, region.maxY, region.maxZ);
|
||||||
ChunkManager.manager.regenerateRegion(pos1, pos2, false, this);
|
ChunkManager.manager.regenerateRegion(pos1, pos2, false, this);
|
||||||
|
@ -11,8 +11,8 @@ public abstract class SquarePlotWorld extends GridPlotWorld {
|
|||||||
public int ROAD_OFFSET_X = 0;
|
public int ROAD_OFFSET_X = 0;
|
||||||
public int ROAD_OFFSET_Z = 0;
|
public int ROAD_OFFSET_Z = 0;
|
||||||
|
|
||||||
public SquarePlotWorld(String worldname, String id, IndependentPlotGenerator generator, PlotId min, PlotId max) {
|
public SquarePlotWorld(String worldName, String id, IndependentPlotGenerator generator, PlotId min, PlotId max) {
|
||||||
super(worldname, id, generator, min, max);
|
super(worldName, id, generator, min, max);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -81,12 +81,12 @@ public class PlotAnalysis {
|
|||||||
TaskManager.runTaskAsync(new Runnable() {
|
TaskManager.runTaskAsync(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
Iterator<Plot> iter = plots.iterator();
|
Iterator<Plot> iterator = plots.iterator();
|
||||||
PS.debug(" - $1Reducing " + plots.size() + " plots to those with sufficient data");
|
PS.debug(" - $1Reducing " + plots.size() + " plots to those with sufficient data");
|
||||||
while (iter.hasNext()) {
|
while (iterator.hasNext()) {
|
||||||
Plot plot = iter.next();
|
Plot plot = iterator.next();
|
||||||
if (plot.getSettings().ratings == null || plot.getSettings().getRatings().isEmpty()) {
|
if (plot.getSettings().ratings == null || plot.getSettings().getRatings().isEmpty()) {
|
||||||
iter.remove();
|
iterator.remove();
|
||||||
} else {
|
} else {
|
||||||
plot.addRunning();
|
plot.addRunning();
|
||||||
}
|
}
|
||||||
@ -393,7 +393,7 @@ public class PlotAnalysis {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get correllation coefficient.
|
* Get correlation coefficient.
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static double getCC(int n, int sum) {
|
public static double getCC(int n, int sum) {
|
||||||
|
@ -72,8 +72,8 @@ public abstract class PlotArea {
|
|||||||
private ConcurrentHashMap<String, Object> meta;
|
private ConcurrentHashMap<String, Object> meta;
|
||||||
private QuadMap<PlotCluster> clusters;
|
private QuadMap<PlotCluster> clusters;
|
||||||
|
|
||||||
public PlotArea(String worldname, String id, IndependentPlotGenerator generator, PlotId min, PlotId max) {
|
public PlotArea(String worldName, String id, IndependentPlotGenerator generator, PlotId min, PlotId max) {
|
||||||
this.worldname = worldname;
|
this.worldname = worldName;
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.manager = generator != null ? generator.getNewPlotManager() : null;
|
this.manager = generator != null ? generator.getNewPlotManager() : null;
|
||||||
this.generator = generator;
|
this.generator = generator;
|
||||||
@ -87,7 +87,7 @@ public abstract class PlotArea {
|
|||||||
this.min = min;
|
this.min = min;
|
||||||
this.max = max;
|
this.max = max;
|
||||||
}
|
}
|
||||||
this.worldhash = worldname.hashCode();
|
this.worldhash = worldName.hashCode();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -303,7 +303,7 @@ public abstract class PlotArea {
|
|||||||
public abstract void loadConfiguration(ConfigurationSection config);
|
public abstract void loadConfiguration(ConfigurationSection config);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Saving core plotarea settings
|
* Saving core PlotArea settings
|
||||||
*
|
*
|
||||||
* @param config Configuration Section
|
* @param config Configuration Section
|
||||||
*/
|
*/
|
||||||
@ -457,16 +457,16 @@ public abstract class PlotArea {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Set<Plot> getPlotsAbs(final UUID uuid) {
|
public Set<Plot> getPlotsAbs(final UUID uuid) {
|
||||||
final HashSet<Plot> myplots = new HashSet<>();
|
final HashSet<Plot> myPlots = new HashSet<>();
|
||||||
foreachPlotAbs(new RunnableVal<Plot>() {
|
foreachPlotAbs(new RunnableVal<Plot>() {
|
||||||
@Override
|
@Override
|
||||||
public void run(Plot value) {
|
public void run(Plot value) {
|
||||||
if (value.owner.equals(uuid)) {
|
if (value.owner.equals(uuid)) {
|
||||||
myplots.add(value);
|
myPlots.add(value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return myplots;
|
return myPlots;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Set<Plot> getPlots(UUID uuid) {
|
public Set<Plot> getPlots(UUID uuid) {
|
||||||
@ -595,14 +595,14 @@ public abstract class PlotArea {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Set<Plot> getBasePlots() {
|
public Set<Plot> getBasePlots() {
|
||||||
HashSet<Plot> myplots = new HashSet<>(getPlots());
|
HashSet<Plot> myPlots = new HashSet<>(getPlots());
|
||||||
Iterator<Plot> iter = myplots.iterator();
|
Iterator<Plot> iterator = myPlots.iterator();
|
||||||
while (iter.hasNext()) {
|
while (iterator.hasNext()) {
|
||||||
if (!iter.next().isBasePlot()) {
|
if (!iterator.next().isBasePlot()) {
|
||||||
iter.remove();
|
iterator.remove();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return myplots;
|
return myPlots;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void foreachPlotAbs(RunnableVal<Plot> run) {
|
public void foreachPlotAbs(RunnableVal<Plot> run) {
|
||||||
|
@ -128,14 +128,14 @@ public class ExpireManager {
|
|||||||
}
|
}
|
||||||
final Runnable task = this;
|
final Runnable task = this;
|
||||||
long start = System.currentTimeMillis();
|
long start = System.currentTimeMillis();
|
||||||
Iterator<Plot> iter = plots.iterator();
|
Iterator<Plot> iterator = plots.iterator();
|
||||||
while (iter.hasNext() && System.currentTimeMillis() - start < 2) {
|
while (iterator.hasNext() && System.currentTimeMillis() - start < 2) {
|
||||||
if (ExpireManager.this.running != 2) {
|
if (ExpireManager.this.running != 2) {
|
||||||
ExpireManager.this.running = 0;
|
ExpireManager.this.running = 0;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final Plot plot = iter.next();
|
final Plot plot = iterator.next();
|
||||||
iter.remove();
|
iterator.remove();
|
||||||
if (!isExpired(plot)) {
|
if (!isExpired(plot)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -277,19 +277,19 @@ public class MainUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a list of plot ids within a selection
|
* Get a list of plot ids within a selection.
|
||||||
* @param pos1
|
* @param pos1
|
||||||
* @param pos2
|
* @param pos2
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static ArrayList<PlotId> getPlotSelectionIds(PlotId pos1, PlotId pos2) {
|
public static ArrayList<PlotId> getPlotSelectionIds(PlotId pos1, PlotId pos2) {
|
||||||
ArrayList<PlotId> myplots = new ArrayList<>();
|
ArrayList<PlotId> myPlots = new ArrayList<>();
|
||||||
for (int x = pos1.x; x <= pos2.x; x++) {
|
for (int x = pos1.x; x <= pos2.x; x++) {
|
||||||
for (int y = pos1.y; y <= pos2.y; y++) {
|
for (int y = pos1.y; y <= pos2.y; y++) {
|
||||||
myplots.add(new PlotId(x, y));
|
myPlots.add(new PlotId(x, y));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return myplots;
|
return myPlots;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -346,7 +346,7 @@ public class MainUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fuzzy plot search with spaces separating terms<br>
|
* Fuzzy plot search with spaces separating terms.
|
||||||
* - Terms: type, alias, world, owner, trusted, member
|
* - Terms: type, alias, world, owner, trusted, member
|
||||||
* @param search
|
* @param search
|
||||||
* @return
|
* @return
|
||||||
@ -421,7 +421,7 @@ public class MainUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the plot from a string<br>
|
* Get the plot from a string.
|
||||||
* @param player Provides a context for what world to search in. Prefixing the term with 'world_name;' will override this context.
|
* @param player Provides a context for what world to search in. Prefixing the term with 'world_name;' will override this context.
|
||||||
* @param arg The search term
|
* @param arg The search term
|
||||||
* @param message If a message should be sent to the player if a plot cannot be found
|
* @param message If a message should be sent to the player if a plot cannot be found
|
||||||
@ -533,13 +533,13 @@ public class MainUtil {
|
|||||||
* @param world
|
* @param world
|
||||||
* @param pos1
|
* @param pos1
|
||||||
* @param pos2
|
* @param pos2
|
||||||
* @param newblock
|
* @param newBlock
|
||||||
*/
|
*/
|
||||||
public static void setSimpleCuboidAsync(String world, Location pos1, Location pos2, PlotBlock newblock) {
|
public static void setSimpleCuboidAsync(String world, Location pos1, Location pos2, PlotBlock newBlock) {
|
||||||
for (int y = pos1.getY(); y <= Math.min(255, pos2.getY()); y++) {
|
for (int y = pos1.getY(); y <= Math.min(255, pos2.getY()); y++) {
|
||||||
for (int x = pos1.getX(); x <= pos2.getX(); x++) {
|
for (int x = pos1.getX(); x <= pos2.getX(); x++) {
|
||||||
for (int z = pos1.getZ(); z <= pos2.getZ(); z++) {
|
for (int z = pos1.getZ(); z <= pos2.getZ(); z++) {
|
||||||
SetQueue.IMP.setBlock(world, x, y, z, newblock);
|
SetQueue.IMP.setBlock(world, x, y, z, newBlock);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,17 +1,37 @@
|
|||||||
package com.intellectualcrafters.plot.util;
|
package com.intellectualcrafters.plot.util;
|
||||||
|
|
||||||
public class MathMan {
|
public class MathMan {
|
||||||
public static double getMean(final int[] array) {
|
|
||||||
|
private static final int ATAN2_BITS = 7;
|
||||||
|
private static final int ATAN2_BITS2 = ATAN2_BITS << 1;
|
||||||
|
private static final int ATAN2_MASK = ~(-1 << ATAN2_BITS2);
|
||||||
|
private static final int ATAN2_COUNT = ATAN2_MASK + 1;
|
||||||
|
private static final int ATAN2_DIM = (int) Math.sqrt(ATAN2_COUNT);
|
||||||
|
private static final float INV_ATAN2_DIM_MINUS_1 = 1.0f / (ATAN2_DIM - 1);
|
||||||
|
private static final float[] atan2 = new float[ATAN2_COUNT];
|
||||||
|
|
||||||
|
static {
|
||||||
|
for (int i = 0; i < ATAN2_DIM; i++) {
|
||||||
|
for (int j = 0; j < ATAN2_DIM; j++) {
|
||||||
|
float x0 = (float) i / ATAN2_DIM;
|
||||||
|
float y0 = (float) j / ATAN2_DIM;
|
||||||
|
|
||||||
|
atan2[(j * ATAN2_DIM) + i] = (float) Math.atan2(y0, x0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static double getMean(int[] array) {
|
||||||
double count = 0;
|
double count = 0;
|
||||||
for (final int i : array) {
|
for (int i : array) {
|
||||||
count += i;
|
count += i;
|
||||||
}
|
}
|
||||||
return count / array.length;
|
return count / array.length;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static double getMean(final double[] array) {
|
public static double getMean(double[] array) {
|
||||||
double count = 0;
|
double count = 0;
|
||||||
for (final double i : array) {
|
for (double i : array) {
|
||||||
count += i;
|
count += i;
|
||||||
}
|
}
|
||||||
return count / array.length;
|
return count / array.length;
|
||||||
@ -35,12 +55,12 @@ public class MathMan {
|
|||||||
* @param pitch
|
* @param pitch
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static float[] getDirection(final float yaw, final float pitch) {
|
public static float[] getDirection(float yaw, float pitch) {
|
||||||
final double pitch_sin = Math.sin(pitch);
|
double pitch_sin = Math.sin(pitch);
|
||||||
return new float[] { (float) (pitch_sin * Math.cos(yaw)), (float) (pitch_sin * Math.sin(yaw)), (float) Math.cos(pitch) };
|
return new float[]{(float) (pitch_sin * Math.cos(yaw)), (float) (pitch_sin * Math.sin(yaw)), (float) Math.cos(pitch)};
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int roundInt(final double value) {
|
public static int roundInt(double value) {
|
||||||
return (int) (value < 0 ? (value == (int) value) ? value : value - 1 : value);
|
return (int) (value < 0 ? (value == (int) value) ? value : value - 1 : value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -51,31 +71,9 @@ public class MathMan {
|
|||||||
* @param z
|
* @param z
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static float[] getPitchAndYaw(final float x, final float y, final float z) {
|
public static float[] getPitchAndYaw(float x, float y, float z) {
|
||||||
final float distance = sqrtApprox((z * z) + (x * x));
|
float distance = sqrtApprox((z * z) + (x * x));
|
||||||
return new float[] { atan2(y, distance), atan2(x, z) };
|
return new float[]{atan2(y, distance), atan2(x, z)};
|
||||||
}
|
|
||||||
|
|
||||||
private static final int ATAN2_BITS = 7;
|
|
||||||
|
|
||||||
private static final int ATAN2_BITS2 = ATAN2_BITS << 1;
|
|
||||||
private static final int ATAN2_MASK = ~(-1 << ATAN2_BITS2);
|
|
||||||
private static final int ATAN2_COUNT = ATAN2_MASK + 1;
|
|
||||||
private static final int ATAN2_DIM = (int) Math.sqrt(ATAN2_COUNT);
|
|
||||||
|
|
||||||
private static final float INV_ATAN2_DIM_MINUS_1 = 1.0f / (ATAN2_DIM - 1);
|
|
||||||
|
|
||||||
private static final float[] atan2 = new float[ATAN2_COUNT];
|
|
||||||
|
|
||||||
static {
|
|
||||||
for (int i = 0; i < ATAN2_DIM; i++) {
|
|
||||||
for (int j = 0; j < ATAN2_DIM; j++) {
|
|
||||||
final float x0 = (float) i / ATAN2_DIM;
|
|
||||||
final float y0 = (float) j / ATAN2_DIM;
|
|
||||||
|
|
||||||
atan2[(j * ATAN2_DIM) + i] = (float) Math.atan2(y0, x0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final float atan2(float y, float x) {
|
public static final float atan2(float y, float x) {
|
||||||
@ -104,24 +102,24 @@ public class MathMan {
|
|||||||
add = 0.0f;
|
add = 0.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
final float invDiv = 1.0f / (((x < y) ? y : x) * INV_ATAN2_DIM_MINUS_1);
|
float invDiv = 1.0f / (((x < y) ? y : x) * INV_ATAN2_DIM_MINUS_1);
|
||||||
|
|
||||||
final int xi = (int) (x * invDiv);
|
int xi = (int) (x * invDiv);
|
||||||
final int yi = (int) (y * invDiv);
|
int yi = (int) (y * invDiv);
|
||||||
|
|
||||||
return (atan2[(yi * ATAN2_DIM) + xi] + add) * mul;
|
return (atan2[(yi * ATAN2_DIM) + xi] + add) * mul;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static float sqrtApprox(final float f) {
|
public static float sqrtApprox(float f) {
|
||||||
return f * Float.intBitsToFloat(0x5f375a86 - (Float.floatToIntBits(f) >> 1));
|
return f * Float.intBitsToFloat(0x5f375a86 - (Float.floatToIntBits(f) >> 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static double sqrtApprox(final double d) {
|
public static double sqrtApprox(double d) {
|
||||||
return Double.longBitsToDouble(((Double.doubleToLongBits(d) - (1l << 52)) >> 1) + (1l << 61));
|
return Double.longBitsToDouble(((Double.doubleToLongBits(d) - (1l << 52)) >> 1) + (1l << 61));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static float invSqrt(float x) {
|
public static float invSqrt(float x) {
|
||||||
final float xhalf = 0.5f * x;
|
float xhalf = 0.5f * x;
|
||||||
int i = Float.floatToIntBits(x);
|
int i = Float.floatToIntBits(x);
|
||||||
i = 0x5f3759df - (i >> 1);
|
i = 0x5f3759df - (i >> 1);
|
||||||
x = Float.intBitsToFloat(i);
|
x = Float.intBitsToFloat(i);
|
||||||
@ -129,18 +127,18 @@ public class MathMan {
|
|||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int getPositiveId(final int i) {
|
public static int getPositiveId(int i) {
|
||||||
if (i < 0) {
|
if (i < 0) {
|
||||||
return (-i * 2) - 1;
|
return (-i * 2) - 1;
|
||||||
}
|
}
|
||||||
return i * 2;
|
return i * 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isInteger(final String str) {
|
public static boolean isInteger(String str) {
|
||||||
if (str == null) {
|
if (str == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
final int length = str.length();
|
int length = str.length();
|
||||||
if (length == 0) {
|
if (length == 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -152,7 +150,7 @@ public class MathMan {
|
|||||||
i = 1;
|
i = 1;
|
||||||
}
|
}
|
||||||
for (; i < length; i++) {
|
for (; i < length; i++) {
|
||||||
final char c = str.charAt(i);
|
char c = str.charAt(i);
|
||||||
if ((c <= '/') || (c >= ':')) {
|
if ((c <= '/') || (c >= ':')) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -160,37 +158,37 @@ public class MathMan {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static double getSD(final double[] array, final double av) {
|
public static double getSD(double[] array, double av) {
|
||||||
double sd = 0;
|
double sd = 0;
|
||||||
for (final double element : array) {
|
for (double element : array) {
|
||||||
sd += Math.pow(Math.abs(element - av), 2);
|
sd += Math.pow(Math.abs(element - av), 2);
|
||||||
}
|
}
|
||||||
return Math.sqrt(sd / array.length);
|
return Math.sqrt(sd / array.length);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static double getSD(final int[] array, final double av) {
|
public static double getSD(int[] array, double av) {
|
||||||
double sd = 0;
|
double sd = 0;
|
||||||
for (final int element : array) {
|
for (int element : array) {
|
||||||
sd += Math.pow(Math.abs(element - av), 2);
|
sd += Math.pow(Math.abs(element - av), 2);
|
||||||
}
|
}
|
||||||
return Math.sqrt(sd / array.length);
|
return Math.sqrt(sd / array.length);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int mod(final int x, final int y) {
|
public static int mod(int x, int y) {
|
||||||
if (isPowerOfTwo(y)) {
|
if (isPowerOfTwo(y)) {
|
||||||
return x & (y - 1);
|
return x & (y - 1);
|
||||||
}
|
}
|
||||||
return x % y;
|
return x % y;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int unsignedmod(final int x, final int y) {
|
public static int unsignedmod(int x, int y) {
|
||||||
if (isPowerOfTwo(y)) {
|
if (isPowerOfTwo(y)) {
|
||||||
return x & (y - 1);
|
return x & (y - 1);
|
||||||
}
|
}
|
||||||
return x % y;
|
return x % y;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isPowerOfTwo(final int x) {
|
public static boolean isPowerOfTwo(int x) {
|
||||||
return (x & (x - 1)) == 0;
|
return (x & (x - 1)) == 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -162,10 +162,10 @@ public abstract class SchematicHandler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Dimension demensions = schematic.getSchematicDimension();
|
Dimension dimension = schematic.getSchematicDimension();
|
||||||
final int WIDTH = demensions.getX();
|
final int WIDTH = dimension.getX();
|
||||||
final int LENGTH = demensions.getZ();
|
final int LENGTH = dimension.getZ();
|
||||||
final int HEIGHT = demensions.getY();
|
final int HEIGHT = dimension.getY();
|
||||||
// Validate dimensions
|
// Validate dimensions
|
||||||
RegionWrapper region = plot.getLargestRegion();
|
RegionWrapper region = plot.getLargestRegion();
|
||||||
if (((region.maxX - region.minX + xOffset + 1) < WIDTH) || ((region.maxZ - region.minZ + zOffset + 1) < LENGTH) || (HEIGHT
|
if (((region.maxX - region.minX + xOffset + 1) < WIDTH) || ((region.maxZ - region.minZ + zOffset + 1) < LENGTH) || (HEIGHT
|
||||||
@ -469,7 +469,7 @@ public abstract class SchematicHandler {
|
|||||||
return schem;
|
return schem;
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract void restoreTag(CompoundTag ct, short x, short y, short z, Schematic schem);
|
public abstract void restoreTag(CompoundTag ct, short x, short y, short z, Schematic schematic);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a schematic
|
* Get a schematic
|
||||||
@ -616,11 +616,11 @@ public abstract class SchematicHandler {
|
|||||||
* Create a compound tag from blocks
|
* Create a compound tag from blocks
|
||||||
* - Untested
|
* - Untested
|
||||||
* @param blocks
|
* @param blocks
|
||||||
* @param blockdata
|
* @param blockData
|
||||||
* @param dimension
|
* @param dimension
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public CompoundTag createTag(byte[] blocks, byte[] blockdata, Dimension dimension) {
|
public CompoundTag createTag(byte[] blocks, byte[] blockData, Dimension dimension) {
|
||||||
HashMap<String, Tag> schematic = new HashMap<>();
|
HashMap<String, Tag> schematic = new HashMap<>();
|
||||||
schematic.put("Width", new ShortTag("Width", (short) dimension.getX()));
|
schematic.put("Width", new ShortTag("Width", (short) dimension.getX()));
|
||||||
schematic.put("Length", new ShortTag("Length", (short) dimension.getZ()));
|
schematic.put("Length", new ShortTag("Length", (short) dimension.getZ()));
|
||||||
@ -633,7 +633,7 @@ public abstract class SchematicHandler {
|
|||||||
schematic.put("WEOffsetY", new IntTag("WEOffsetY", 0));
|
schematic.put("WEOffsetY", new IntTag("WEOffsetY", 0));
|
||||||
schematic.put("WEOffsetZ", new IntTag("WEOffsetZ", 0));
|
schematic.put("WEOffsetZ", new IntTag("WEOffsetZ", 0));
|
||||||
schematic.put("Blocks", new ByteArrayTag("Blocks", blocks));
|
schematic.put("Blocks", new ByteArrayTag("Blocks", blocks));
|
||||||
schematic.put("Data", new ByteArrayTag("Data", blockdata));
|
schematic.put("Data", new ByteArrayTag("Data", blockData));
|
||||||
schematic.put("Entities", new ListTag("Entities", CompoundTag.class, new ArrayList<Tag>()));
|
schematic.put("Entities", new ListTag("Entities", CompoundTag.class, new ArrayList<Tag>()));
|
||||||
schematic.put("TileEntities", new ListTag("TileEntities", CompoundTag.class, new ArrayList<Tag>()));
|
schematic.put("TileEntities", new ListTag("TileEntities", CompoundTag.class, new ArrayList<Tag>()));
|
||||||
return new CompoundTag("Schematic", schematic);
|
return new CompoundTag("Schematic", schematic);
|
||||||
|
@ -42,21 +42,6 @@ public class StringMan {
|
|||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Collection match(Collection col, String startsWith) {
|
|
||||||
if (col == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
startsWith = startsWith.toLowerCase();
|
|
||||||
Iterator iter = col.iterator();
|
|
||||||
while (iter.hasNext()) {
|
|
||||||
Object item = iter.next();
|
|
||||||
if (item == null || !item.toString().toLowerCase().startsWith(startsWith)) {
|
|
||||||
iter.remove();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return col;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String getString(Object obj) {
|
public static String getString(Object obj) {
|
||||||
if (obj == null) {
|
if (obj == null) {
|
||||||
return "null";
|
return "null";
|
||||||
@ -279,4 +264,19 @@ public class StringMan {
|
|||||||
}
|
}
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Collection match(Collection col, String startsWith) {
|
||||||
|
if (col == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
startsWith = startsWith.toLowerCase();
|
||||||
|
Iterator iterator = col.iterator();
|
||||||
|
while (iterator.hasNext()) {
|
||||||
|
Object item = iterator.next();
|
||||||
|
if (item == null || !item.toString().toLowerCase().startsWith(startsWith)) {
|
||||||
|
iterator.remove();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return col;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -88,14 +88,14 @@ public abstract class TaskManager {
|
|||||||
* @param whenDone
|
* @param whenDone
|
||||||
*/
|
*/
|
||||||
public static <T> void objectTask(Collection<T> objects, final RunnableVal<T> task, final Runnable whenDone) {
|
public static <T> void objectTask(Collection<T> objects, final RunnableVal<T> task, final Runnable whenDone) {
|
||||||
final Iterator<T> iter = objects.iterator();
|
final Iterator<T> iterator = objects.iterator();
|
||||||
TaskManager.runTask(new Runnable() {
|
TaskManager.runTask(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
long start = System.currentTimeMillis();
|
long start = System.currentTimeMillis();
|
||||||
boolean hasNext;
|
boolean hasNext;
|
||||||
while ((hasNext = iter.hasNext()) && System.currentTimeMillis() - start < 5) {
|
while ((hasNext = iterator.hasNext()) && System.currentTimeMillis() - start < 5) {
|
||||||
task.value = iter.next();
|
task.value = iterator.next();
|
||||||
task.run();
|
task.run();
|
||||||
}
|
}
|
||||||
if (!hasNext) {
|
if (!hasNext) {
|
||||||
|
@ -26,7 +26,7 @@ public abstract class WorldUtil {
|
|||||||
|
|
||||||
public abstract String getMainWorld();
|
public abstract String getMainWorld();
|
||||||
|
|
||||||
public abstract boolean isWorld(String worldname);
|
public abstract boolean isWorld(String worldName);
|
||||||
|
|
||||||
public abstract String[] getSign(Location location);
|
public abstract String[] getSign(Location location);
|
||||||
|
|
||||||
|
@ -14,6 +14,7 @@ import com.intellectualcrafters.plot.util.MathMan;
|
|||||||
import com.intellectualcrafters.plot.util.Permissions;
|
import com.intellectualcrafters.plot.util.Permissions;
|
||||||
import com.intellectualcrafters.plot.util.StringComparison;
|
import com.intellectualcrafters.plot.util.StringComparison;
|
||||||
import com.intellectualcrafters.plot.util.StringMan;
|
import com.intellectualcrafters.plot.util.StringMan;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.lang.annotation.Annotation;
|
import java.lang.annotation.Annotation;
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
@ -101,8 +102,8 @@ public abstract class Command {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String getFullId() {
|
public String getFullId() {
|
||||||
if (parent != null && parent.getParent() != null) {
|
if (this.parent != null && this.parent.getParent() != null) {
|
||||||
return parent.getFullId() + "." + id;
|
return this.parent.getFullId() + "." + this.id;
|
||||||
}
|
}
|
||||||
return this.id;
|
return this.id;
|
||||||
}
|
}
|
||||||
@ -118,16 +119,16 @@ public abstract class Command {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public List<Command> getCommands(CommandCategory cat, PlotPlayer player) {
|
public List<Command> getCommands(CommandCategory cat, PlotPlayer player) {
|
||||||
List<Command> cmds = getCommands(player);
|
List<Command> commands = getCommands(player);
|
||||||
if (cat != null) {
|
if (cat != null) {
|
||||||
Iterator<Command> iter = cmds.iterator();
|
Iterator<Command> iterator = commands.iterator();
|
||||||
while (iter.hasNext()) {
|
while (iterator.hasNext()) {
|
||||||
if (iter.next().category != cat) {
|
if (iterator.next().category != cat) {
|
||||||
iter.remove();
|
iterator.remove();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return cmds;
|
return commands;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Command> getCommands() {
|
public List<Command> getCommands() {
|
||||||
@ -302,8 +303,8 @@ public abstract class Command {
|
|||||||
// Command recommendation
|
// Command recommendation
|
||||||
MainUtil.sendMessage(player, C.NOT_VALID_SUBCOMMAND);
|
MainUtil.sendMessage(player, C.NOT_VALID_SUBCOMMAND);
|
||||||
{
|
{
|
||||||
List<Command> cmds = getCommands(player);
|
List<Command> commands = getCommands(player);
|
||||||
if (cmds.isEmpty()) {
|
if (commands.isEmpty()) {
|
||||||
MainUtil.sendMessage(player, C.DID_YOU_MEAN, MainCommand.getInstance().help.getUsage());
|
MainUtil.sendMessage(player, C.DID_YOU_MEAN, MainCommand.getInstance().help.getUsage());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -313,7 +314,7 @@ public abstract class Command {
|
|||||||
}
|
}
|
||||||
String[] allargs = setargs.toArray(new String[setargs.size()]);
|
String[] allargs = setargs.toArray(new String[setargs.size()]);
|
||||||
int best = 0;
|
int best = 0;
|
||||||
for (Command current : cmds) {
|
for (Command current : commands) {
|
||||||
int match = getMatch(allargs, current);
|
int match = getMatch(allargs, current);
|
||||||
if (match > best) {
|
if (match > best) {
|
||||||
cmd = current;
|
cmd = current;
|
||||||
|
@ -315,11 +315,11 @@ public class SpongeMain implements IPlotMain {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setGenerator(String worldname) {
|
public void setGenerator(String worldName) {
|
||||||
World world = SpongeUtil.getWorld(worldname);
|
World world = SpongeUtil.getWorld(worldName);
|
||||||
if (world == null) {
|
if (world == null) {
|
||||||
// create world
|
// create world
|
||||||
ConfigurationSection worldConfig = PS.get().config.getConfigurationSection("worlds." + worldname);
|
ConfigurationSection worldConfig = PS.get().config.getConfigurationSection("worlds." + worldName);
|
||||||
String manager = worldConfig.getString("generator.plugin", "PlotSquared");
|
String manager = worldConfig.getString("generator.plugin", "PlotSquared");
|
||||||
String generator = worldConfig.getString("generator.init", manager);
|
String generator = worldConfig.getString("generator.init", manager);
|
||||||
|
|
||||||
@ -331,15 +331,15 @@ public class SpongeMain implements IPlotMain {
|
|||||||
setup.type = type;
|
setup.type = type;
|
||||||
setup.terrain = terrain;
|
setup.terrain = terrain;
|
||||||
setup.step = new ConfigurationNode[0];
|
setup.step = new ConfigurationNode[0];
|
||||||
setup.world = worldname;
|
setup.world = worldName;
|
||||||
SetupUtils.manager.setupWorld(setup);
|
SetupUtils.manager.setupWorld(setup);
|
||||||
} else {
|
} else {
|
||||||
throw new IllegalArgumentException("World already loaded: " + worldname + "???");
|
throw new IllegalArgumentException("World already loaded: " + worldName + "???");
|
||||||
}
|
}
|
||||||
WorldGenerator wg = world.getWorldGenerator();
|
WorldGenerator wg = world.getWorldGenerator();
|
||||||
GenerationPopulator gen = wg.getBaseGenerationPopulator();
|
GenerationPopulator gen = wg.getBaseGenerationPopulator();
|
||||||
if (gen instanceof SpongePlotGenerator) {
|
if (gen instanceof SpongePlotGenerator) {
|
||||||
PS.get().loadWorld(worldname, (SpongePlotGenerator) gen);
|
PS.get().loadWorld(worldName, (SpongePlotGenerator) gen);
|
||||||
} else {
|
} else {
|
||||||
throw new UnsupportedOperationException("NOT IMPLEMENTED YET!");
|
throw new UnsupportedOperationException("NOT IMPLEMENTED YET!");
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,9 @@
|
|||||||
package com.plotsquared.sponge.events;
|
package com.plotsquared.sponge.events;
|
||||||
|
|
||||||
import org.spongepowered.api.entity.living.player.Player;
|
|
||||||
import org.spongepowered.api.event.Cancellable;
|
|
||||||
|
|
||||||
import com.intellectualcrafters.plot.object.Location;
|
import com.intellectualcrafters.plot.object.Location;
|
||||||
import com.intellectualcrafters.plot.object.Plot;
|
import com.intellectualcrafters.plot.object.Plot;
|
||||||
|
import org.spongepowered.api.entity.living.player.Player;
|
||||||
|
import org.spongepowered.api.event.Cancellable;
|
||||||
|
|
||||||
public class PlayerTeleportToPlotEvent extends PlayerEvent implements Cancellable {
|
public class PlayerTeleportToPlotEvent extends PlayerEvent implements Cancellable {
|
||||||
|
|
||||||
@ -13,43 +12,43 @@ public class PlayerTeleportToPlotEvent extends PlayerEvent implements Cancellabl
|
|||||||
private boolean cancelled;
|
private boolean cancelled;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PlayerTeleportToPlotEvent: Called when a player teleports to a plot
|
* PlayerTeleportToPlotEvent: Called when a player teleports to a plot.
|
||||||
*
|
*
|
||||||
* @param player That was teleported
|
* @param player That was teleported
|
||||||
* @param from Start location
|
* @param from Start location
|
||||||
* @param plot Plot to which the player was teleported
|
* @param plot Plot to which the player was teleported
|
||||||
*/
|
*/
|
||||||
public PlayerTeleportToPlotEvent(final Player player, final Location from, final Plot plot) {
|
public PlayerTeleportToPlotEvent(Player player, Location from, Plot plot) {
|
||||||
super(player);
|
super(player);
|
||||||
this.from = from;
|
this.from = from;
|
||||||
this.plot = plot;
|
this.plot = plot;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the from location
|
* Get the from location.
|
||||||
*
|
*
|
||||||
* @return Location
|
* @return Location
|
||||||
*/
|
*/
|
||||||
public Location getFrom() {
|
public Location getFrom() {
|
||||||
return from;
|
return this.from;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the plot involved
|
* Get the plot involved.
|
||||||
*
|
*
|
||||||
* @return Plot
|
* @return Plot
|
||||||
*/
|
*/
|
||||||
public Plot getPlot() {
|
public Plot getPlot() {
|
||||||
return plot;
|
return this.plot;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isCancelled() {
|
public boolean isCancelled() {
|
||||||
return cancelled;
|
return this.cancelled;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setCancelled(final boolean cancel) {
|
public void setCancelled(boolean cancel) {
|
||||||
cancelled = cancel;
|
this.cancelled = cancel;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,9 +25,9 @@ public class SpongeAugmentedGenerator implements GenerationPopulator {
|
|||||||
public static SpongeAugmentedGenerator get(World world) {
|
public static SpongeAugmentedGenerator get(World world) {
|
||||||
WorldGenerator wg = world.getWorldGenerator();
|
WorldGenerator wg = world.getWorldGenerator();
|
||||||
List<GenerationPopulator> populators = wg.getGenerationPopulators();
|
List<GenerationPopulator> populators = wg.getGenerationPopulators();
|
||||||
for (GenerationPopulator poplator : populators) {
|
for (GenerationPopulator populator : populators) {
|
||||||
if (poplator instanceof SpongeAugmentedGenerator) {
|
if (populator instanceof SpongeAugmentedGenerator) {
|
||||||
return (SpongeAugmentedGenerator) poplator;
|
return (SpongeAugmentedGenerator) populator;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (generator == null) {
|
if (generator == null) {
|
||||||
@ -38,12 +38,12 @@ public class SpongeAugmentedGenerator implements GenerationPopulator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void populate(final World world, final MutableBlockVolume terrain, final ImmutableBiomeArea biome) {
|
public void populate(World world, MutableBlockVolume terrain, ImmutableBiomeArea biome) {
|
||||||
Vector3i min = terrain.getBlockMin();
|
Vector3i min = terrain.getBlockMin();
|
||||||
final int bx = min.getX();
|
int bx = min.getX();
|
||||||
final int bz = min.getZ();
|
int bz = min.getZ();
|
||||||
final int cx = bx >> 4;
|
int cx = bx >> 4;
|
||||||
final int cz = bz >> 4;
|
int cz = bz >> 4;
|
||||||
AugmentedUtils.generate(world.getName(), cx, cz, new LazyResult<PlotChunk<?>>() {
|
AugmentedUtils.generate(world.getName(), cx, cz, new LazyResult<PlotChunk<?>>() {
|
||||||
@Override
|
@Override
|
||||||
public PlotChunk<?> create() {
|
public PlotChunk<?> create() {
|
||||||
|
@ -28,9 +28,9 @@ public class SpongePlotGenerator implements WorldGeneratorModifier, GeneratorWra
|
|||||||
private final IndependentPlotGenerator plotGenerator;
|
private final IndependentPlotGenerator plotGenerator;
|
||||||
private final List<GenerationPopulator> populators = new ArrayList<>();
|
private final List<GenerationPopulator> populators = new ArrayList<>();
|
||||||
private final boolean loaded = false;
|
private final boolean loaded = false;
|
||||||
private PlotManager manager;
|
|
||||||
private final WorldGeneratorModifier platformGenerator;
|
private final WorldGeneratorModifier platformGenerator;
|
||||||
private final boolean full;
|
private final boolean full;
|
||||||
|
private PlotManager manager;
|
||||||
|
|
||||||
public SpongePlotGenerator(IndependentPlotGenerator generator) {
|
public SpongePlotGenerator(IndependentPlotGenerator generator) {
|
||||||
this.plotGenerator = generator;
|
this.plotGenerator = generator;
|
||||||
@ -48,34 +48,34 @@ public class SpongePlotGenerator implements WorldGeneratorModifier, GeneratorWra
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getId() {
|
public String getId() {
|
||||||
if (plotGenerator == null) {
|
if (this.plotGenerator == null) {
|
||||||
if (platformGenerator != this) {
|
if (this.platformGenerator != this) {
|
||||||
return platformGenerator.getId();
|
return this.platformGenerator.getId();
|
||||||
}
|
}
|
||||||
return "null";
|
return "null";
|
||||||
}
|
}
|
||||||
return plotGenerator.getName();
|
return this.plotGenerator.getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
if (plotGenerator == null) {
|
if (this.plotGenerator == null) {
|
||||||
if (platformGenerator != this) {
|
if (this.platformGenerator != this) {
|
||||||
return platformGenerator.getName();
|
return this.platformGenerator.getName();
|
||||||
}
|
}
|
||||||
return "null";
|
return "null";
|
||||||
}
|
}
|
||||||
return plotGenerator.getName();
|
return this.plotGenerator.getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void modifyWorldGenerator(WorldCreationSettings settings, DataContainer data, WorldGenerator wg) {
|
public void modifyWorldGenerator(WorldCreationSettings settings, DataContainer data, WorldGenerator wg) {
|
||||||
final String worldname = settings.getWorldName();
|
String worldName = settings.getWorldName();
|
||||||
wg.setBaseGenerationPopulator(new SpongeTerrainGen(this, plotGenerator));
|
wg.setBaseGenerationPopulator(new SpongeTerrainGen(this, this.plotGenerator));
|
||||||
wg.setBiomeGenerator(new BiomeGenerator() {
|
wg.setBiomeGenerator(new BiomeGenerator() {
|
||||||
@Override
|
@Override
|
||||||
public void generateBiomes(MutableBiomeArea buffer) {
|
public void generateBiomes(MutableBiomeArea buffer) {
|
||||||
PlotArea area = PS.get().getPlotArea(worldname, null);
|
PlotArea area = PS.get().getPlotArea(worldName, null);
|
||||||
if (area != null) {
|
if (area != null) {
|
||||||
BiomeType biome = SpongeUtil.getBiome(area.PLOT_BIOME);
|
BiomeType biome = SpongeUtil.getBiome(area.PLOT_BIOME);
|
||||||
Vector2i min = buffer.getBiomeMin();
|
Vector2i min = buffer.getBiomeMin();
|
||||||
@ -96,17 +96,17 @@ public class SpongePlotGenerator implements WorldGeneratorModifier, GeneratorWra
|
|||||||
}
|
}
|
||||||
wg.getGenerationPopulators().clear();
|
wg.getGenerationPopulators().clear();
|
||||||
wg.getPopulators().clear();
|
wg.getPopulators().clear();
|
||||||
PS.get().loadWorld(worldname, this);
|
PS.get().loadWorld(worldName, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IndependentPlotGenerator getPlotGenerator() {
|
public IndependentPlotGenerator getPlotGenerator() {
|
||||||
return plotGenerator;
|
return this.plotGenerator;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public WorldGeneratorModifier getPlatformGenerator() {
|
public WorldGeneratorModifier getPlatformGenerator() {
|
||||||
return platformGenerator;
|
return this.platformGenerator;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -116,7 +116,7 @@ public class SpongePlotGenerator implements WorldGeneratorModifier, GeneratorWra
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isFull() {
|
public boolean isFull() {
|
||||||
return full;
|
return this.full;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -372,8 +372,8 @@ public class MainListener {
|
|||||||
if (e instanceof ExplosionEvent.Detonate) {
|
if (e instanceof ExplosionEvent.Detonate) {
|
||||||
ExplosionEvent.Detonate event = (Detonate) e;
|
ExplosionEvent.Detonate event = (Detonate) e;
|
||||||
World world = event.getTargetWorld();
|
World world = event.getTargetWorld();
|
||||||
String worldname = world.getName();
|
String worldName = world.getName();
|
||||||
if (!PS.get().hasPlotArea(worldname)) {
|
if (!PS.get().hasPlotArea(worldName)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Optional<Explosive> source = event.getExplosion().getSourceExplosive();
|
Optional<Explosive> source = event.getExplosion().getSourceExplosive();
|
||||||
@ -418,13 +418,13 @@ public class MainListener {
|
|||||||
|
|
||||||
public void onChangeBlock(ChangeBlockEvent event) {
|
public void onChangeBlock(ChangeBlockEvent event) {
|
||||||
World world = event.getTargetWorld();
|
World world = event.getTargetWorld();
|
||||||
String worldname = world.getName();
|
String worldName = world.getName();
|
||||||
if (!PS.get().hasPlotArea(worldname)) {
|
if (!PS.get().hasPlotArea(worldName)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
List<Transaction<BlockSnapshot>> transactions = event.getTransactions();
|
List<Transaction<BlockSnapshot>> transactions = event.getTransactions();
|
||||||
Transaction<BlockSnapshot> first = transactions.get(0);
|
Transaction<BlockSnapshot> first = transactions.get(0);
|
||||||
Location loc = SpongeUtil.getLocation(worldname, first.getOriginal().getPosition());
|
Location loc = SpongeUtil.getLocation(worldName, first.getOriginal().getPosition());
|
||||||
Plot plot = loc.getPlot();
|
Plot plot = loc.getPlot();
|
||||||
if (plot == null) {
|
if (plot == null) {
|
||||||
if (!loc.isPlotArea()) {
|
if (!loc.isPlotArea()) {
|
||||||
@ -436,7 +436,7 @@ public class MainListener {
|
|||||||
event.filter(new Predicate<org.spongepowered.api.world.Location<World>>() {
|
event.filter(new Predicate<org.spongepowered.api.world.Location<World>>() {
|
||||||
@Override
|
@Override
|
||||||
public boolean test(org.spongepowered.api.world.Location<World> loc) {
|
public boolean test(org.spongepowered.api.world.Location<World> loc) {
|
||||||
return !SpongeUtil.getLocation(worldname, loc).isPlotRoad();
|
return !SpongeUtil.getLocation(worldName, loc).isPlotRoad();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -465,14 +465,14 @@ public class MainListener {
|
|||||||
}
|
}
|
||||||
PlotPlayer pp = SpongeUtil.getPlayer(player);
|
PlotPlayer pp = SpongeUtil.getPlayer(player);
|
||||||
World world = event.getTargetWorld();
|
World world = event.getTargetWorld();
|
||||||
String worldname = world.getName();
|
String worldName = world.getName();
|
||||||
if (!PS.get().hasPlotArea(worldname)) {
|
if (!PS.get().hasPlotArea(worldName)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
List<Transaction<BlockSnapshot>> transactions = event.getTransactions();
|
List<Transaction<BlockSnapshot>> transactions = event.getTransactions();
|
||||||
Transaction<BlockSnapshot> first = transactions.get(0);
|
Transaction<BlockSnapshot> first = transactions.get(0);
|
||||||
BlockSnapshot pos = first.getOriginal();
|
BlockSnapshot pos = first.getOriginal();
|
||||||
Location loc = SpongeUtil.getLocation(worldname, pos.getPosition());
|
Location loc = SpongeUtil.getLocation(worldName, pos.getPosition());
|
||||||
Plot plot = loc.getPlot();
|
Plot plot = loc.getPlot();
|
||||||
if (plot == null) {
|
if (plot == null) {
|
||||||
if (!loc.isPlotArea()) {
|
if (!loc.isPlotArea()) {
|
||||||
@ -507,7 +507,7 @@ public class MainListener {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean test(org.spongepowered.api.world.Location<World> l) {
|
public boolean test(org.spongepowered.api.world.Location<World> l) {
|
||||||
Location loc = SpongeUtil.getLocation(worldname, l);
|
Location loc = SpongeUtil.getLocation(worldName, l);
|
||||||
Plot plot = loc.getPlot();
|
Plot plot = loc.getPlot();
|
||||||
if (plot == null) {
|
if (plot == null) {
|
||||||
if (loc.getPlotAbs() == null) {
|
if (loc.getPlotAbs() == null) {
|
||||||
@ -546,14 +546,14 @@ public class MainListener {
|
|||||||
}
|
}
|
||||||
PlotPlayer pp = SpongeUtil.getPlayer(player);
|
PlotPlayer pp = SpongeUtil.getPlayer(player);
|
||||||
World world = event.getTargetWorld();
|
World world = event.getTargetWorld();
|
||||||
String worldname = world.getName();
|
String worldName = world.getName();
|
||||||
if (!PS.get().hasPlotArea(worldname)) {
|
if (!PS.get().hasPlotArea(worldName)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
List<Transaction<BlockSnapshot>> transactions = event.getTransactions();
|
List<Transaction<BlockSnapshot>> transactions = event.getTransactions();
|
||||||
Transaction<BlockSnapshot> first = transactions.get(0);
|
Transaction<BlockSnapshot> first = transactions.get(0);
|
||||||
BlockSnapshot pos = first.getOriginal();
|
BlockSnapshot pos = first.getOriginal();
|
||||||
Location loc = SpongeUtil.getLocation(worldname, pos.getPosition());
|
Location loc = SpongeUtil.getLocation(worldName, pos.getPosition());
|
||||||
Plot plot = loc.getPlot();
|
Plot plot = loc.getPlot();
|
||||||
if (plot == null) {
|
if (plot == null) {
|
||||||
if (loc.getPlotAbs() == null) {
|
if (loc.getPlotAbs() == null) {
|
||||||
@ -588,7 +588,7 @@ public class MainListener {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean test(org.spongepowered.api.world.Location<World> l) {
|
public boolean test(org.spongepowered.api.world.Location<World> l) {
|
||||||
Location loc = SpongeUtil.getLocation(worldname, l);
|
Location loc = SpongeUtil.getLocation(worldName, l);
|
||||||
Plot plot = loc.getPlot();
|
Plot plot = loc.getPlot();
|
||||||
if (plot == null) {
|
if (plot == null) {
|
||||||
if (loc.getPlotAbs() == null) {
|
if (loc.getPlotAbs() == null) {
|
||||||
|
@ -126,8 +126,8 @@ public class SpongeChunkManager extends ChunkManager {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void clearAllEntities(Location pos1, Location pos2) {
|
public void clearAllEntities(Location pos1, Location pos2) {
|
||||||
String worldname = pos1.getWorld();
|
String worldName = pos1.getWorld();
|
||||||
World world = SpongeUtil.getWorld(worldname);
|
World world = SpongeUtil.getWorld(worldName);
|
||||||
int bx = pos1.getX();
|
int bx = pos1.getX();
|
||||||
int bz = pos1.getZ();
|
int bz = pos1.getZ();
|
||||||
int tx = pos2.getX();
|
int tx = pos2.getX();
|
||||||
|
@ -1,28 +1,27 @@
|
|||||||
package com.plotsquared.sponge.util;
|
package com.plotsquared.sponge.util;
|
||||||
|
|
||||||
import org.spongepowered.api.block.BlockState;
|
|
||||||
import org.spongepowered.api.block.BlockTypes;
|
|
||||||
import org.spongepowered.api.world.World;
|
|
||||||
|
|
||||||
import com.intellectualcrafters.plot.generator.HybridUtils;
|
import com.intellectualcrafters.plot.generator.HybridUtils;
|
||||||
import com.intellectualcrafters.plot.object.PlotAnalysis;
|
import com.intellectualcrafters.plot.object.PlotAnalysis;
|
||||||
import com.intellectualcrafters.plot.object.PlotBlock;
|
import com.intellectualcrafters.plot.object.PlotBlock;
|
||||||
import com.intellectualcrafters.plot.object.RegionWrapper;
|
import com.intellectualcrafters.plot.object.RegionWrapper;
|
||||||
import com.intellectualcrafters.plot.object.RunnableVal;
|
import com.intellectualcrafters.plot.object.RunnableVal;
|
||||||
|
import org.spongepowered.api.block.BlockState;
|
||||||
|
import org.spongepowered.api.block.BlockTypes;
|
||||||
|
import org.spongepowered.api.world.World;
|
||||||
|
|
||||||
public class SpongeHybridUtils extends HybridUtils {
|
public class SpongeHybridUtils extends HybridUtils {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int checkModified(final String worldname, final int x1, final int x2, final int y1, final int y2, final int z1, final int z2, final PlotBlock[] blocks) {
|
public int checkModified(String worldName, int x1, int x2, int y1, int y2, int z1, int z2, PlotBlock[] blocks) {
|
||||||
final World world = SpongeUtil.getWorld(worldname);
|
World world = SpongeUtil.getWorld(worldName);
|
||||||
int count = 0;
|
int count = 0;
|
||||||
for (int y = y1; y <= y2; y++) {
|
for (int y = y1; y <= y2; y++) {
|
||||||
for (int x = x1; x <= x2; x++) {
|
for (int x = x1; x <= x2; x++) {
|
||||||
for (int z = z1; z <= z2; z++) {
|
for (int z = z1; z <= z2; z++) {
|
||||||
final BlockState state = world.getBlock(x, y, z);
|
BlockState state = world.getBlock(x, y, z);
|
||||||
final PlotBlock block = SpongeUtil.getPlotBlock(state);
|
PlotBlock block = SpongeUtil.getPlotBlock(state);
|
||||||
boolean same = false;
|
boolean same = false;
|
||||||
for (final PlotBlock p : blocks) {
|
for (PlotBlock p : blocks) {
|
||||||
if (block.id == p.id) {
|
if (block.id == p.id) {
|
||||||
same = true;
|
same = true;
|
||||||
break;
|
break;
|
||||||
@ -38,15 +37,15 @@ public class SpongeHybridUtils extends HybridUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int get_ey(final String worldname, final int sx, final int ex, final int sz, final int ez, final int sy) {
|
public int get_ey(String worldName, int sx, int ex, int sz, int ez, int sy) {
|
||||||
final World world = SpongeUtil.getWorld(worldname);
|
World world = SpongeUtil.getWorld(worldName);
|
||||||
int ey = sy;
|
int ey = sy;
|
||||||
for (int x = sx; x <= ex; x++) {
|
for (int x = sx; x <= ex; x++) {
|
||||||
for (int z = sz; z <= ez; z++) {
|
for (int z = sz; z <= ez; z++) {
|
||||||
for (int y = sy; y < 256; y++) {
|
for (int y = sy; y < 256; y++) {
|
||||||
if (y > ey) {
|
if (y > ey) {
|
||||||
final BlockState state = world.getBlock(x, y, z);
|
BlockState state = world.getBlock(x, y, z);
|
||||||
if ((state != null) && (state.getType() != BlockTypes.AIR)) {
|
if (state.getType() != BlockTypes.AIR) {
|
||||||
ey = y;
|
ey = y;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,18 +1,5 @@
|
|||||||
package com.plotsquared.sponge.util;
|
package com.plotsquared.sponge.util;
|
||||||
|
|
||||||
import java.util.ArrayDeque;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Map.Entry;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import org.spongepowered.api.block.BlockState;
|
|
||||||
import org.spongepowered.api.item.inventory.Carrier;
|
|
||||||
import org.spongepowered.api.item.inventory.type.CarriedInventory;
|
|
||||||
import org.spongepowered.api.world.World;
|
|
||||||
|
|
||||||
import com.intellectualcrafters.jnbt.ByteArrayTag;
|
import com.intellectualcrafters.jnbt.ByteArrayTag;
|
||||||
import com.intellectualcrafters.jnbt.CompoundTag;
|
import com.intellectualcrafters.jnbt.CompoundTag;
|
||||||
import com.intellectualcrafters.jnbt.IntTag;
|
import com.intellectualcrafters.jnbt.IntTag;
|
||||||
@ -28,25 +15,37 @@ import com.intellectualcrafters.plot.object.RunnableVal;
|
|||||||
import com.intellectualcrafters.plot.util.MainUtil;
|
import com.intellectualcrafters.plot.util.MainUtil;
|
||||||
import com.intellectualcrafters.plot.util.SchematicHandler;
|
import com.intellectualcrafters.plot.util.SchematicHandler;
|
||||||
import com.intellectualcrafters.plot.util.TaskManager;
|
import com.intellectualcrafters.plot.util.TaskManager;
|
||||||
|
import org.spongepowered.api.block.BlockState;
|
||||||
|
import org.spongepowered.api.item.inventory.Carrier;
|
||||||
|
import org.spongepowered.api.item.inventory.type.CarriedInventory;
|
||||||
|
import org.spongepowered.api.world.World;
|
||||||
|
|
||||||
|
import java.util.ArrayDeque;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Map.Entry;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
public class SpongeSchematicHandler extends SchematicHandler {
|
public class SpongeSchematicHandler extends SchematicHandler {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void getCompoundTag(final String world, final Set<RegionWrapper> regions, final RunnableVal<CompoundTag> whenDone) {
|
public void getCompoundTag(String world, Set<RegionWrapper> regions, RunnableVal<CompoundTag> whenDone) {
|
||||||
// async
|
// async
|
||||||
TaskManager.runTaskAsync(new Runnable() {
|
TaskManager.runTaskAsync(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
// Main positions
|
// Main positions
|
||||||
Location[] corners = MainUtil.getCorners(world, regions);
|
Location[] corners = MainUtil.getCorners(world, regions);
|
||||||
final Location bot = corners[0];
|
Location bot = corners[0];
|
||||||
final Location top = corners[1];
|
Location top = corners[1];
|
||||||
|
|
||||||
final int width = (top.getX() - bot.getX()) + 1;
|
int width = (top.getX() - bot.getX()) + 1;
|
||||||
final int height = (top.getY() - bot.getY()) + 1;
|
int height = (top.getY() - bot.getY()) + 1;
|
||||||
final int length = (top.getZ() - bot.getZ()) + 1;
|
int length = (top.getZ() - bot.getZ()) + 1;
|
||||||
// Main Schematic tag
|
// Main Schematic tag
|
||||||
final HashMap<String, Tag> schematic = new HashMap<>();
|
HashMap<String, Tag> schematic = new HashMap<>();
|
||||||
schematic.put("Width", new ShortTag("Width", (short) width));
|
schematic.put("Width", new ShortTag("Width", (short) width));
|
||||||
schematic.put("Length", new ShortTag("Length", (short) length));
|
schematic.put("Length", new ShortTag("Length", (short) length));
|
||||||
schematic.put("Height", new ShortTag("Height", (short) height));
|
schematic.put("Height", new ShortTag("Height", (short) height));
|
||||||
@ -58,11 +57,11 @@ public class SpongeSchematicHandler extends SchematicHandler {
|
|||||||
schematic.put("WEOffsetY", new IntTag("WEOffsetY", 0));
|
schematic.put("WEOffsetY", new IntTag("WEOffsetY", 0));
|
||||||
schematic.put("WEOffsetZ", new IntTag("WEOffsetZ", 0));
|
schematic.put("WEOffsetZ", new IntTag("WEOffsetZ", 0));
|
||||||
// Arrays of data types
|
// Arrays of data types
|
||||||
final List<Tag> tileEntities = new ArrayList<Tag>();
|
List<Tag> tileEntities = new ArrayList<Tag>();
|
||||||
final byte[] blocks = new byte[width * height * length];
|
byte[] blocks = new byte[width * height * length];
|
||||||
final byte[] blockData = new byte[width * height * length];
|
byte[] blockData = new byte[width * height * length];
|
||||||
// Queue
|
// Queue
|
||||||
final ArrayDeque<RegionWrapper> queue = new ArrayDeque<>(regions);
|
ArrayDeque<RegionWrapper> queue = new ArrayDeque<>(regions);
|
||||||
TaskManager.runTask(new Runnable() {
|
TaskManager.runTask(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
@ -82,40 +81,40 @@ public class SpongeSchematicHandler extends SchematicHandler {
|
|||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final Runnable regionTask = this;
|
Runnable regionTask = this;
|
||||||
RegionWrapper region = queue.poll();
|
RegionWrapper region = queue.poll();
|
||||||
Location pos1 = new Location(world, region.minX, region.minY, region.minZ);
|
Location pos1 = new Location(world, region.minX, region.minY, region.minZ);
|
||||||
Location pos2 = new Location(world, region.maxX, region.maxY, region.maxZ);
|
Location pos2 = new Location(world, region.maxX, region.maxY, region.maxZ);
|
||||||
final int bx = bot.getX();
|
int bx = bot.getX();
|
||||||
final int bz = bot.getZ();
|
int bz = bot.getZ();
|
||||||
final int p1x = pos1.getX();
|
int p1x = pos1.getX();
|
||||||
final int p1z = pos1.getZ();
|
int p1z = pos1.getZ();
|
||||||
final int p2x = pos2.getX();
|
int p2x = pos2.getX();
|
||||||
final int p2z = pos2.getZ();
|
int p2z = pos2.getZ();
|
||||||
final int bcx = p1x >> 4;
|
int bcx = p1x >> 4;
|
||||||
final int bcz = p1z >> 4;
|
int bcz = p1z >> 4;
|
||||||
final int tcx = p2x >> 4;
|
int tcx = p2x >> 4;
|
||||||
final int tcz = p2z >> 4;
|
int tcz = p2z >> 4;
|
||||||
final int sy = pos1.getY();
|
int sy = pos1.getY();
|
||||||
final int ey = pos2.getY();
|
int ey = pos2.getY();
|
||||||
// Generate list of chunks
|
// Generate list of chunks
|
||||||
final ArrayList<ChunkLoc> chunks = new ArrayList<ChunkLoc>();
|
ArrayList<ChunkLoc> chunks = new ArrayList<ChunkLoc>();
|
||||||
for (int x = bcx; x <= tcx; x++) {
|
for (int x = bcx; x <= tcx; x++) {
|
||||||
for (int z = bcz; z <= tcz; z++) {
|
for (int z = bcz; z <= tcz; z++) {
|
||||||
chunks.add(new ChunkLoc(x, z));
|
chunks.add(new ChunkLoc(x, z));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
final World worldObj = SpongeUtil.getWorld(world);
|
World worldObj = SpongeUtil.getWorld(world);
|
||||||
// Main thread
|
// Main thread
|
||||||
TaskManager.runTask(new Runnable() {
|
TaskManager.runTask(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
final long start = System.currentTimeMillis();
|
long start = System.currentTimeMillis();
|
||||||
while ((!chunks.isEmpty()) && ((System.currentTimeMillis() - start) < 20)) {
|
while (!chunks.isEmpty() && ((System.currentTimeMillis() - start) < 20)) {
|
||||||
// save schematics
|
// save schematics
|
||||||
final ChunkLoc chunk = chunks.remove(0);
|
ChunkLoc chunk = chunks.remove(0);
|
||||||
final int X = chunk.x;
|
int X = chunk.x;
|
||||||
final int Z = chunk.z;
|
int Z = chunk.z;
|
||||||
int xxb = X << 4;
|
int xxb = X << 4;
|
||||||
int zzb = Z << 4;
|
int zzb = Z << 4;
|
||||||
if (!worldObj.getChunk(xxb, 1, zzb).isPresent() && !worldObj.loadChunk(xxb, 1, zzb, false).isPresent()) {
|
if (!worldObj.getChunk(xxb, 1, zzb).isPresent() && !worldObj.loadChunk(xxb, 1, zzb, false).isPresent()) {
|
||||||
@ -137,18 +136,18 @@ public class SpongeSchematicHandler extends SchematicHandler {
|
|||||||
zzt = p2z;
|
zzt = p2z;
|
||||||
}
|
}
|
||||||
for (int y = sy; y <= Math.min(255, ey); y++) {
|
for (int y = sy; y <= Math.min(255, ey); y++) {
|
||||||
final int ry = y - sy;
|
int ry = y - sy;
|
||||||
final int i1 = (ry * width * length);
|
int i1 = ry * width * length;
|
||||||
for (int z = zzb; z <= zzt; z++) {
|
for (int z = zzb; z <= zzt; z++) {
|
||||||
final int rz = z - p1z;
|
int rz = z - p1z;
|
||||||
final int i2 = i1 + (rz * width);
|
int i2 = i1 + (rz * width);
|
||||||
for (int x = xxb; x <= xxt; x++) {
|
for (int x = xxb; x <= xxt; x++) {
|
||||||
final int rx = x - p1x;
|
int rx = x - p1x;
|
||||||
final int index = i2 + rx;
|
int index = i2 + rx;
|
||||||
|
|
||||||
final BlockState state = worldObj.getBlock(x, y, z);
|
BlockState state = worldObj.getBlock(x, y, z);
|
||||||
PlotBlock block = SpongeUtil.getPlotBlock(state);
|
PlotBlock block = SpongeUtil.getPlotBlock(state);
|
||||||
final int id = block.id;
|
int id = block.id;
|
||||||
switch (id) {
|
switch (id) {
|
||||||
case 0:
|
case 0:
|
||||||
case 2:
|
case 2:
|
||||||
@ -265,15 +264,15 @@ public class SpongeSchematicHandler extends SchematicHandler {
|
|||||||
rawTag = null;
|
rawTag = null;
|
||||||
}
|
}
|
||||||
if (rawTag != null) {
|
if (rawTag != null) {
|
||||||
final Map<String, Tag> values = new HashMap<String, Tag>();
|
Map<String, Tag> values = new HashMap<String, Tag>();
|
||||||
for (final Entry<String, Tag> entry : rawTag.getValue().entrySet()) {
|
for (Entry<String, Tag> entry : rawTag.getValue().entrySet()) {
|
||||||
values.put(entry.getKey(), entry.getValue());
|
values.put(entry.getKey(), entry.getValue());
|
||||||
}
|
}
|
||||||
values.put("id", new StringTag("id", "Chest"));
|
values.put("id", new StringTag("id", "Chest"));
|
||||||
values.put("x", new IntTag("x", x));
|
values.put("x", new IntTag("x", x));
|
||||||
values.put("y", new IntTag("y", y));
|
values.put("y", new IntTag("y", y));
|
||||||
values.put("z", new IntTag("z", z));
|
values.put("z", new IntTag("z", z));
|
||||||
final CompoundTag tileEntityTag = new CompoundTag(values);
|
CompoundTag tileEntityTag = new CompoundTag(values);
|
||||||
tileEntities.add(tileEntityTag);
|
tileEntities.add(tileEntityTag);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -300,7 +299,7 @@ public class SpongeSchematicHandler extends SchematicHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void restoreTag(CompoundTag ct, short x, short y, short z, Schematic schem) {
|
public void restoreTag(CompoundTag ct, short x, short y, short z, Schematic schematic) {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
// This method should place the compound tag at a location e.g. chest contents
|
// This method should place the compound tag at a location e.g. chest contents
|
||||||
throw new UnsupportedOperationException("NOT IMPLEMENTED YET");
|
throw new UnsupportedOperationException("NOT IMPLEMENTED YET");
|
||||||
|
@ -50,23 +50,23 @@ public class SpongeSetupUtils extends SetupUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getGenerator(final PlotArea plotworld) {
|
public String getGenerator(PlotArea plotworld) {
|
||||||
if (SetupUtils.generators.isEmpty()) {
|
if (SetupUtils.generators.isEmpty()) {
|
||||||
updateGenerators();
|
updateGenerators();
|
||||||
}
|
}
|
||||||
final World world = SpongeUtil.getWorld(plotworld.worldname);
|
World world = SpongeUtil.getWorld(plotworld.worldname);
|
||||||
if (world == null) {
|
if (world == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
final WorldGenerator generator = world.getWorldGenerator();
|
WorldGenerator generator = world.getWorldGenerator();
|
||||||
throw new UnsupportedOperationException("NOT IMPLEMENTED YET");
|
throw new UnsupportedOperationException("NOT IMPLEMENTED YET");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String setupWorld(final SetupObject object) {
|
public String setupWorld(SetupObject object) {
|
||||||
SetupUtils.manager.updateGenerators();
|
SetupUtils.manager.updateGenerators();
|
||||||
ConfigurationNode[] steps = object.step == null ? new ConfigurationNode[0] : object.step;
|
ConfigurationNode[] steps = object.step == null ? new ConfigurationNode[0] : object.step;
|
||||||
final String world = object.world;
|
String world = object.world;
|
||||||
int type = object.type;
|
int type = object.type;
|
||||||
String worldPath = "worlds." + object.world;
|
String worldPath = "worlds." + object.world;
|
||||||
if (!PS.get().config.contains(worldPath)) {
|
if (!PS.get().config.contains(worldPath)) {
|
||||||
@ -76,14 +76,14 @@ public class SpongeSetupUtils extends SetupUtils {
|
|||||||
switch (type) {
|
switch (type) {
|
||||||
case 2: {
|
case 2: {
|
||||||
if (object.id != null) {
|
if (object.id != null) {
|
||||||
String areaname = object.id + "-" + object.min + "-" + object.max;
|
String areaName = object.id + "-" + object.min + "-" + object.max;
|
||||||
String areaPath = "areas." + areaname;
|
String areaPath = "areas." + areaName;
|
||||||
if (!worldSection.contains(areaPath)) {
|
if (!worldSection.contains(areaPath)) {
|
||||||
worldSection.createSection(areaPath);
|
worldSection.createSection(areaPath);
|
||||||
}
|
}
|
||||||
ConfigurationSection areaSection = worldSection.getConfigurationSection(areaPath);
|
ConfigurationSection areaSection = worldSection.getConfigurationSection(areaPath);
|
||||||
HashMap<String, Object> options = new HashMap<>();
|
HashMap<String, Object> options = new HashMap<>();
|
||||||
for (final ConfigurationNode step : steps) {
|
for (ConfigurationNode step : steps) {
|
||||||
options.put(step.getConstant(), step.getValue());
|
options.put(step.getConstant(), step.getValue());
|
||||||
}
|
}
|
||||||
options.put("generator.type", object.type);
|
options.put("generator.type", object.type);
|
||||||
@ -112,7 +112,7 @@ public class SpongeSetupUtils extends SetupUtils {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 1: {
|
case 1: {
|
||||||
for (final ConfigurationNode step : steps) {
|
for (ConfigurationNode step : steps) {
|
||||||
worldSection.set(step.getConstant(), step.getValue());
|
worldSection.set(step.getConstant(), step.getValue());
|
||||||
}
|
}
|
||||||
PS.get().config.set("worlds." + world + "." + "generator.type", object.type);
|
PS.get().config.set("worlds." + world + "." + "generator.type", object.type);
|
||||||
@ -128,7 +128,7 @@ public class SpongeSetupUtils extends SetupUtils {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 0: {
|
case 0: {
|
||||||
for (final ConfigurationNode step : steps) {
|
for (ConfigurationNode step : steps) {
|
||||||
worldSection.set(step.getConstant(), step.getValue());
|
worldSection.set(step.getConstant(), step.getValue());
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -136,7 +136,7 @@ public class SpongeSetupUtils extends SetupUtils {
|
|||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
PS.get().config.save(PS.get().configFile);
|
PS.get().config.save(PS.get().configFile);
|
||||||
} catch (final IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
if (object.setupGenerator != null) {
|
if (object.setupGenerator != null) {
|
||||||
|
@ -362,7 +362,7 @@ public class SpongeUtil extends WorldUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void saveWorld(String worldname) {
|
public void saveWorld(String worldName) {
|
||||||
throw new NotImplementedException("TODO WIP"); // TODO FIXME
|
throw new NotImplementedException("TODO WIP"); // TODO FIXME
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -391,8 +391,8 @@ public class SpongeUtil extends WorldUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isWorld(String world) {
|
public boolean isWorld(String worldName) {
|
||||||
return SpongeUtil.getWorld(world) != null;
|
return SpongeUtil.getWorld(worldName) != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -401,8 +401,8 @@ public class SpongeUtil extends WorldUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getHighestBlock(String worldname, int x, int z) {
|
public int getHighestBlock(String worldName, int x, int z) {
|
||||||
World world = SpongeUtil.getWorld(worldname);
|
World world = SpongeUtil.getWorld(worldName);
|
||||||
if (world == null) {
|
if (world == null) {
|
||||||
return 64;
|
return 64;
|
||||||
}
|
}
|
||||||
@ -416,8 +416,8 @@ public class SpongeUtil extends WorldUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setSign(String worldname, int x, int y, int z, String[] lines) {
|
public void setSign(String worldName, int x, int y, int z, String[] lines) {
|
||||||
World world = SpongeUtil.getWorld(worldname);
|
World world = SpongeUtil.getWorld(worldName);
|
||||||
world.setBlock(x, y, z, BlockTypes.WALL_SIGN.getDefaultState());
|
world.setBlock(x, y, z, BlockTypes.WALL_SIGN.getDefaultState());
|
||||||
Optional<TileEntity> block = world.getTileEntity(x, y, z);
|
Optional<TileEntity> block = world.getTileEntity(x, y, z);
|
||||||
if (!block.isPresent()) {
|
if (!block.isPresent()) {
|
||||||
@ -436,8 +436,8 @@ public class SpongeUtil extends WorldUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setBiomes(String worldname, RegionWrapper region, String biomename) {
|
public void setBiomes(String worldName, RegionWrapper region, String biomename) {
|
||||||
World world = SpongeUtil.getWorld(worldname);
|
World world = SpongeUtil.getWorld(worldName);
|
||||||
BiomeType biome = SpongeUtil.getBiome(biomename);
|
BiomeType biome = SpongeUtil.getBiome(biomename);
|
||||||
for (int x = region.minX; x <= region.maxX; x++) {
|
for (int x = region.minX; x <= region.maxX; x++) {
|
||||||
for (int z = region.minZ; z <= region.maxZ; z++) {
|
for (int z = region.minZ; z <= region.maxZ; z++) {
|
||||||
|
@ -97,9 +97,9 @@ public class FastQueue extends SlowQueue {
|
|||||||
ClassInheritanceMultiMap<Entity>[] entities = nmsChunk.getEntityLists();
|
ClassInheritanceMultiMap<Entity>[] entities = nmsChunk.getEntityLists();
|
||||||
// Trim tiles
|
// Trim tiles
|
||||||
Set<Entry<BlockPos, TileEntity>> entryset = tiles.entrySet();
|
Set<Entry<BlockPos, TileEntity>> entryset = tiles.entrySet();
|
||||||
Iterator<Entry<BlockPos, TileEntity>> iter = entryset.iterator();
|
Iterator<Entry<BlockPos, TileEntity>> iterator = entryset.iterator();
|
||||||
while (iter.hasNext()) {
|
while (iterator.hasNext()) {
|
||||||
Entry<BlockPos,TileEntity> tile = iter.next();
|
Entry<BlockPos, TileEntity> tile = iterator.next();
|
||||||
BlockPos pos = tile.getKey();
|
BlockPos pos = tile.getKey();
|
||||||
int lx = pos.getX() & 15;
|
int lx = pos.getX() & 15;
|
||||||
int ly = pos.getY();
|
int ly = pos.getY();
|
||||||
@ -111,7 +111,7 @@ public class FastQueue extends SlowQueue {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (array[k] != 0) {
|
if (array[k] != 0) {
|
||||||
iter.remove();
|
iterator.remove();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Trim entities
|
// Trim entities
|
||||||
@ -206,7 +206,7 @@ public class FastQueue extends SlowQueue {
|
|||||||
spongeChunk.unloadChunk();
|
spongeChunk.unloadChunk();
|
||||||
spongeChunk.loadChunk(false);
|
spongeChunk.loadChunk(false);
|
||||||
}
|
}
|
||||||
// TODO load adjaced chunks
|
// TODO load adjacent chunks
|
||||||
nmsChunk.generateSkylightMap();
|
nmsChunk.generateSkylightMap();
|
||||||
if (bc.getTotalRelight() == 0 && !fixAll) {
|
if (bc.getTotalRelight() == 0 && !fixAll) {
|
||||||
return true;
|
return true;
|
||||||
|
@ -6,7 +6,6 @@ import com.intellectualcrafters.plot.object.ChunkLoc;
|
|||||||
import com.intellectualcrafters.plot.object.Location;
|
import com.intellectualcrafters.plot.object.Location;
|
||||||
import com.intellectualcrafters.plot.object.Plot;
|
import com.intellectualcrafters.plot.object.Plot;
|
||||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||||
import com.intellectualcrafters.plot.util.StringMan;
|
|
||||||
import com.intellectualcrafters.plot.util.TaskManager;
|
import com.intellectualcrafters.plot.util.TaskManager;
|
||||||
import com.intellectualcrafters.plot.util.UUIDHandler;
|
import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||||
import com.plotsquared.sponge.object.SpongePlayer;
|
import com.plotsquared.sponge.object.SpongePlayer;
|
||||||
@ -19,7 +18,11 @@ import org.spongepowered.api.entity.living.player.Player;
|
|||||||
import org.spongepowered.api.world.Chunk;
|
import org.spongepowered.api.world.Chunk;
|
||||||
import org.spongepowered.api.world.World;
|
import org.spongepowered.api.world.World;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -29,11 +32,11 @@ import java.util.Map.Entry;
|
|||||||
*/
|
*/
|
||||||
public class SendChunk {
|
public class SendChunk {
|
||||||
|
|
||||||
public void sendChunk(final Collection<Chunk> input) {
|
public void sendChunk(Collection<Chunk> input) {
|
||||||
final HashSet<Chunk> chunks = new HashSet<Chunk>(input);
|
HashSet<Chunk> chunks = new HashSet<Chunk>(input);
|
||||||
final HashMap<String, ArrayList<Chunk>> map = new HashMap<>();
|
HashMap<String, ArrayList<Chunk>> map = new HashMap<>();
|
||||||
for (final Chunk chunk : chunks) {
|
for (Chunk chunk : chunks) {
|
||||||
final String world = chunk.getWorld().getName();
|
String world = chunk.getWorld().getName();
|
||||||
ArrayList<Chunk> list = map.get(world);
|
ArrayList<Chunk> list = map.get(world);
|
||||||
if (list == null) {
|
if (list == null) {
|
||||||
list = new ArrayList<>();
|
list = new ArrayList<>();
|
||||||
@ -44,7 +47,7 @@ public class SendChunk {
|
|||||||
}
|
}
|
||||||
for (Entry<String, PlotPlayer> entry : UUIDHandler.getPlayers().entrySet()) {
|
for (Entry<String, PlotPlayer> entry : UUIDHandler.getPlayers().entrySet()) {
|
||||||
PlotPlayer pp = entry.getValue();
|
PlotPlayer pp = entry.getValue();
|
||||||
final Plot plot = pp.getCurrentPlot();
|
Plot plot = pp.getCurrentPlot();
|
||||||
Location loc = null;
|
Location loc = null;
|
||||||
String world;
|
String world;
|
||||||
if (plot != null) {
|
if (plot != null) {
|
||||||
@ -53,16 +56,16 @@ public class SendChunk {
|
|||||||
loc = pp.getLocation();
|
loc = pp.getLocation();
|
||||||
world = loc.getWorld();
|
world = loc.getWorld();
|
||||||
}
|
}
|
||||||
final ArrayList<Chunk> list = map.get(world);
|
ArrayList<Chunk> list = map.get(world);
|
||||||
if (list == null) {
|
if (list == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (loc == null) {
|
if (loc == null) {
|
||||||
loc = pp.getLocation();
|
loc = pp.getLocation();
|
||||||
}
|
}
|
||||||
final int cx = loc.getX() >> 4;
|
int cx = loc.getX() >> 4;
|
||||||
final int cz = loc.getZ() >> 4;
|
int cz = loc.getZ() >> 4;
|
||||||
final Player player = ((SpongePlayer) pp).player;
|
Player player = ((SpongePlayer) pp).player;
|
||||||
int view = player.getViewDistance();
|
int view = player.getViewDistance();
|
||||||
EntityPlayer nmsPlayer = (EntityPlayer) player;
|
EntityPlayer nmsPlayer = (EntityPlayer) player;
|
||||||
if (!(nmsPlayer instanceof EntityPlayerMP)) {
|
if (!(nmsPlayer instanceof EntityPlayerMP)) {
|
||||||
@ -70,10 +73,10 @@ public class SendChunk {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
EntityPlayerMP nmsPlayerMP = (EntityPlayerMP) nmsPlayer;
|
EntityPlayerMP nmsPlayerMP = (EntityPlayerMP) nmsPlayer;
|
||||||
for (final Chunk chunk : list) {
|
for (Chunk chunk : list) {
|
||||||
Vector3i min = chunk.getBlockMin();
|
Vector3i min = chunk.getBlockMin();
|
||||||
final int dx = Math.abs(cx - (min.getX() >> 4));
|
int dx = Math.abs(cx - (min.getX() >> 4));
|
||||||
final int dz = Math.abs(cz - (min.getZ() >> 4));
|
int dz = Math.abs(cz - (min.getZ() >> 4));
|
||||||
if ((dx > view) || (dz > view)) {
|
if ((dx > view) || (dz > view)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -84,7 +87,7 @@ public class SendChunk {
|
|||||||
con.sendPacket(packet);
|
con.sendPacket(packet);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (final Chunk chunk : chunks) {
|
for (Chunk chunk : chunks) {
|
||||||
TaskManager.runTask(new Runnable() {
|
TaskManager.runTask(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
@ -94,10 +97,10 @@ public class SendChunk {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sendChunk(final String worldname, final List<ChunkLoc> locs) {
|
public void sendChunk(String worldName, List<ChunkLoc> chunkLocations) {
|
||||||
World spongeWorld = SpongeUtil.getWorld(worldname);
|
World spongeWorld = SpongeUtil.getWorld(worldName);
|
||||||
final ArrayList<Chunk> chunks = new ArrayList<>();
|
ArrayList<Chunk> chunks = new ArrayList<>();
|
||||||
for (final ChunkLoc loc : locs) {
|
for (ChunkLoc loc : chunkLocations) {
|
||||||
chunks.add(spongeWorld.getChunk(loc.x, 0, loc.z).get());
|
chunks.add(spongeWorld.getChunk(loc.x, 0, loc.z).get());
|
||||||
}
|
}
|
||||||
sendChunk(chunks);
|
sendChunk(chunks);
|
||||||
|
Loading…
Reference in New Issue
Block a user