mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2025-06-25 10:14:42 +02:00
OCD
This commit is contained in:
@ -170,11 +170,11 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
|
||||
|
||||
@Override
|
||||
public void registerCommands() {
|
||||
BukkitCommand bcmd = new BukkitCommand();
|
||||
BukkitCommand bukkitCommand = new BukkitCommand();
|
||||
PluginCommand plotCommand = getCommand("plots");
|
||||
plotCommand.setExecutor(bcmd);
|
||||
plotCommand.setExecutor(bukkitCommand);
|
||||
plotCommand.setAliases(Arrays.asList("p", "ps", "plotme", "plot"));
|
||||
plotCommand.setTabCompleter(bcmd);
|
||||
plotCommand.setTabCompleter(bukkitCommand);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -225,7 +225,7 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
|
||||
case WITHER_SKULL:
|
||||
case UNKNOWN:
|
||||
case PLAYER: {
|
||||
// non moving / unremovable
|
||||
// non moving / unmovable
|
||||
continue;
|
||||
}
|
||||
case THROWN_EXP_BOTTLE:
|
||||
|
@ -107,9 +107,9 @@ public class DebugUUID extends SubCommand {
|
||||
worlds.add("world");
|
||||
HashSet<UUID> uuids = new HashSet<>();
|
||||
HashSet<String> names = new HashSet<>();
|
||||
for (String worldname : worlds) {
|
||||
File playerdataFolder = new File(worldname + File.separator + "playerdata");
|
||||
String[] dat = playerdataFolder.list(new FilenameFilter() {
|
||||
for (String worldName : worlds) {
|
||||
File playerDataFolder = new File(worldName + File.separator + "playerdata");
|
||||
String[] dat = playerDataFolder.list(new FilenameFilter() {
|
||||
@Override
|
||||
public boolean accept(File f, String s) {
|
||||
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() {
|
||||
@Override
|
||||
public boolean accept(File f, String s) {
|
||||
@ -286,7 +286,7 @@ public class DebugUUID extends SubCommand {
|
||||
try {
|
||||
PS.get().config.save(PS.get().configFile);
|
||||
} 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");
|
||||
|
@ -154,8 +154,8 @@ public class ClassicPlotMeConnector extends APlotMeConnector {
|
||||
for (Entry<String, HashMap<PlotId, boolean[]>> entry : merges.entrySet()) {
|
||||
String world = entry.getKey();
|
||||
for (Entry<PlotId, boolean[]> entry2 : entry.getValue().entrySet()) {
|
||||
HashMap<PlotId, Plot> newplots = plots.get(world);
|
||||
Plot plot = newplots.get(entry2.getKey());
|
||||
HashMap<PlotId, Plot> newPlots = plots.get(world);
|
||||
Plot plot = newPlots.get(entry2.getKey());
|
||||
if (plot != null) {
|
||||
plot.setMerged(entry2.getValue());
|
||||
}
|
||||
|
@ -45,9 +45,9 @@ public class LikePlotMeConverter {
|
||||
}
|
||||
|
||||
public static String getWorld(String world) {
|
||||
for (World newworld : Bukkit.getWorlds()) {
|
||||
if (newworld.getName().equalsIgnoreCase(world)) {
|
||||
return newworld.getName();
|
||||
for (World newWorld : Bukkit.getWorlds()) {
|
||||
if (newWorld.getName().equalsIgnoreCase(world)) {
|
||||
return newWorld.getName();
|
||||
}
|
||||
}
|
||||
return world;
|
||||
@ -205,11 +205,11 @@ public class LikePlotMeConverter {
|
||||
PS.get().config.set("worlds." + world + ".road.height", pathheight);
|
||||
PS.get().config.set("worlds." + world + ".wall.height", pathheight);
|
||||
PS.get().config.set("worlds." + world + ".plot.height", pathheight);
|
||||
Integer plotsize = plotmeDgYml.getInt("worlds." + plotMeWorldName + ".PlotSize"); //
|
||||
if (plotsize == 0) {
|
||||
plotsize = 32;
|
||||
Integer plotSize = plotmeDgYml.getInt("worlds." + plotMeWorldName + ".PlotSize"); //
|
||||
if (plotSize == 0) {
|
||||
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"); //
|
||||
PS.get().config.set("worlds." + world + ".wall.block", wallblock);
|
||||
String floor = plotmeDgYml.getString("worlds." + plotMeWorldName + ".PlotFloorBlock", "2"); //
|
||||
@ -310,10 +310,10 @@ public class LikePlotMeConverter {
|
||||
.isEnabled()) {
|
||||
mw = true;
|
||||
}
|
||||
for (String worldname : worlds) {
|
||||
World world = Bukkit.getWorld(getWorld(worldname));
|
||||
for (String worldName : worlds) {
|
||||
World world = Bukkit.getWorld(getWorld(worldName));
|
||||
if (world == null) {
|
||||
sendMessage("&cInvalid world in PlotMe configuration: " + worldname);
|
||||
sendMessage("&cInvalid world in PlotMe configuration: " + worldName);
|
||||
}
|
||||
String actualWorldName = world.getName();
|
||||
sendMessage("Reloading generator for world: '" + actualWorldName + "'...");
|
||||
@ -344,8 +344,8 @@ public class LikePlotMeConverter {
|
||||
// Load using Bukkit API
|
||||
// - User must set generator manually
|
||||
Bukkit.getServer().unloadWorld(world, true);
|
||||
World myworld = WorldCreator.name(actualWorldName).generator(new BukkitPlotGenerator(new HybridGen())).createWorld();
|
||||
myworld.save();
|
||||
World myWorld = WorldCreator.name(actualWorldName).generator(new BukkitPlotGenerator(new HybridGen())).createWorld();
|
||||
myWorld.save();
|
||||
}
|
||||
}
|
||||
} catch (CommandException e) {
|
||||
|
@ -111,8 +111,8 @@ public class ChunkListener implements Listener {
|
||||
if (!PS.get().hasPlotArea(name)) {
|
||||
continue;
|
||||
}
|
||||
boolean autosave = world.isAutoSave();
|
||||
if (autosave) {
|
||||
boolean autoSave = world.isAutoSave();
|
||||
if (autoSave) {
|
||||
world.setAutoSave(false);
|
||||
}
|
||||
HashMap<ChunkLoc, Integer> map = players.get(name);
|
||||
@ -142,7 +142,7 @@ public class ChunkListener implements Listener {
|
||||
time = 1;
|
||||
}
|
||||
}
|
||||
if (!Settings.CHUNK_PROCESSOR_TRIM_ON_SAVE && autosave) {
|
||||
if (!Settings.CHUNK_PROCESSOR_TRIM_ON_SAVE && autoSave) {
|
||||
world.setAutoSave(true);
|
||||
}
|
||||
}
|
||||
|
@ -636,22 +636,22 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onBigBoom(EntityExplodeEvent event) {
|
||||
Location loc = BukkitUtil.getLocation(event.getLocation());
|
||||
PlotArea area = loc.getPlotArea();
|
||||
Location location = BukkitUtil.getLocation(event.getLocation());
|
||||
PlotArea area = location.getPlotArea();
|
||||
if (area == null) {
|
||||
if (!PS.get().hasPlotArea(loc.getWorld())) {
|
||||
if (!PS.get().hasPlotArea(location.getWorld())) {
|
||||
return;
|
||||
}
|
||||
Iterator<Block> iter = event.blockList().iterator();
|
||||
while (iter.hasNext()) {
|
||||
iter.next();
|
||||
if (loc.getPlotArea() != null) {
|
||||
iter.remove();
|
||||
Iterator<Block> iterator = event.blockList().iterator();
|
||||
while (iterator.hasNext()) {
|
||||
iterator.next();
|
||||
if (location.getPlotArea() != null) {
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
Plot plot = area.getOwnedPlot(loc);
|
||||
Plot plot = area.getOwnedPlot(location);
|
||||
if (plot != null) {
|
||||
if (FlagManager.isPlotFlagTrue(plot, "explosion")) {
|
||||
List<MetadataValue> meta = event.getEntity().getMetadata("plot");
|
||||
@ -672,12 +672,12 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
}
|
||||
this.lastRadius = 0;
|
||||
}
|
||||
Iterator<Block> iter = event.blockList().iterator();
|
||||
while (iter.hasNext()) {
|
||||
Block b = iter.next();
|
||||
loc = BukkitUtil.getLocation(b.getLocation());
|
||||
if (!area.contains(loc.getX(), loc.getZ()) || !origin.equals(area.getOwnedPlot(loc))) {
|
||||
iter.remove();
|
||||
Iterator<Block> iterator = event.blockList().iterator();
|
||||
while (iterator.hasNext()) {
|
||||
Block block = iterator.next();
|
||||
location = BukkitUtil.getLocation(block.getLocation());
|
||||
if (!area.contains(location.getX(), location.getZ()) || !origin.equals(area.getOwnedPlot(location))) {
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
return;
|
||||
@ -1267,8 +1267,8 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
}
|
||||
Block block = event.getBlock();
|
||||
World world = block.getWorld();
|
||||
String worldname = world.getName();
|
||||
if (!PS.get().hasPlotArea(worldname)) {
|
||||
String worldName = world.getName();
|
||||
if (!PS.get().hasPlotArea(worldName)) {
|
||||
return;
|
||||
}
|
||||
Location loc = BukkitUtil.getLocation(block.getLocation());
|
||||
@ -1382,7 +1382,7 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
case LIGHTNING:
|
||||
case WITHER_SKULL:
|
||||
case UNKNOWN:
|
||||
// non moving / unremovable
|
||||
// non moving / unmovable
|
||||
return checkEntity(plot, "entity-cap");
|
||||
case ITEM_FRAME:
|
||||
case PAINTING:
|
||||
@ -1540,17 +1540,17 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
}
|
||||
|
||||
} else if (event.getIgnitingBlock() != null) {
|
||||
Block igniter = event.getIgnitingBlock();
|
||||
Block ignitingBlock = event.getIgnitingBlock();
|
||||
if (igniteCause == BlockIgniteEvent.IgniteCause.FLINT_AND_STEEL) {
|
||||
if (plot == null || !FlagManager.isPlotFlagTrue(plot, "block-ignition")) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
if (BukkitUtil.getLocation(igniter.getLocation()).getPlot() == null) {
|
||||
if (BukkitUtil.getLocation(ignitingBlock.getLocation()).getPlot() == null) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
if (!BukkitUtil.getLocation(igniter.getLocation()).getPlot().equals(plot)) {
|
||||
if (!BukkitUtil.getLocation(ignitingBlock.getLocation()).getPlot().equals(plot)) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
@ -1560,11 +1560,11 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
if (BukkitUtil.getLocation(igniter.getLocation()).getPlot() == null) {
|
||||
if (BukkitUtil.getLocation(ignitingBlock.getLocation()).getPlot() == null) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
if (!BukkitUtil.getLocation(igniter.getLocation()).getPlot().equals(plot)) {
|
||||
if (!BukkitUtil.getLocation(ignitingBlock.getLocation()).getPlot().equals(plot)) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
@ -25,11 +25,11 @@ public class PlayerEvents183 implements Listener {
|
||||
}
|
||||
PlotArea area = loc.getPlotArea();
|
||||
if (area == null) {
|
||||
Iterator<Block> iter = event.blockList().iterator();
|
||||
while (iter.hasNext()) {
|
||||
loc = BukkitUtil.getLocation(iter.next().getLocation());
|
||||
Iterator<Block> iterator = event.blockList().iterator();
|
||||
while (iterator.hasNext()) {
|
||||
loc = BukkitUtil.getLocation(iterator.next().getLocation());
|
||||
if (loc.getPlotArea() != null) {
|
||||
iter.remove();
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
return;
|
||||
@ -38,11 +38,11 @@ public class PlayerEvents183 implements Listener {
|
||||
if (plot == null || !FlagManager.isPlotFlagTrue(plot, "explosion")) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
Iterator<Block> iter = event.blockList().iterator();
|
||||
while (iter.hasNext()) {
|
||||
Block b = iter.next();
|
||||
Iterator<Block> iterator = event.blockList().iterator();
|
||||
while (iterator.hasNext()) {
|
||||
Block b = iterator.next();
|
||||
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.util.BukkitUtil;
|
||||
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.GameMode;
|
||||
import org.bukkit.entity.EntityType;
|
||||
@ -26,6 +22,11 @@ import org.bukkit.event.player.PlayerPickupItemEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
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 {
|
||||
|
||||
private static final HashMap<String, Interval> feedRunnable = new HashMap<>();
|
||||
@ -36,15 +37,15 @@ public class PlotPlusListener extends PlotListener implements Listener {
|
||||
@Override
|
||||
public void run() {
|
||||
if (!healRunnable.isEmpty()) {
|
||||
for (Iterator<Entry<String, Interval>> iter = healRunnable.entrySet().iterator(); iter.hasNext(); ) {
|
||||
Entry<String, Interval> entry = iter.next();
|
||||
for (Iterator<Entry<String, Interval>> iterator = healRunnable.entrySet().iterator(); iterator.hasNext(); ) {
|
||||
Entry<String, Interval> entry = iterator.next();
|
||||
Interval value = entry.getValue();
|
||||
++value.count;
|
||||
if (value.count == value.interval) {
|
||||
value.count = 0;
|
||||
Player player = Bukkit.getPlayer(entry.getKey());
|
||||
if (player == null) {
|
||||
iter.remove();
|
||||
iterator.remove();
|
||||
continue;
|
||||
}
|
||||
double level = player.getHealth();
|
||||
@ -55,15 +56,15 @@ public class PlotPlusListener extends PlotListener implements Listener {
|
||||
}
|
||||
}
|
||||
if (!feedRunnable.isEmpty()) {
|
||||
for (Iterator<Entry<String, Interval>> iter = feedRunnable.entrySet().iterator(); iter.hasNext(); ) {
|
||||
Entry<String, Interval> entry = iter.next();
|
||||
for (Iterator<Entry<String, Interval>> iterator = feedRunnable.entrySet().iterator(); iterator.hasNext(); ) {
|
||||
Entry<String, Interval> entry = iterator.next();
|
||||
Interval value = entry.getValue();
|
||||
++value.count;
|
||||
if (value.count == value.interval) {
|
||||
value.count = 0;
|
||||
Player player = Bukkit.getPlayer(entry.getKey());
|
||||
if (player == null) {
|
||||
iter.remove();
|
||||
iterator.remove();
|
||||
continue;
|
||||
}
|
||||
int level = player.getFoodLevel();
|
||||
|
@ -182,7 +182,7 @@ public class EntityWrapper {
|
||||
storeLiving((LivingEntity) entity);
|
||||
return;
|
||||
}
|
||||
// END AMEABLE //
|
||||
// END TAMEABLE //
|
||||
case SHEEP: {
|
||||
Sheep sheep = (Sheep) entity;
|
||||
this.dataByte = (byte) (sheep.isSheared() ? 1 : 0);
|
||||
|
@ -275,9 +275,9 @@ public class BukkitHybridUtils extends HybridUtils {
|
||||
}
|
||||
|
||||
@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) {
|
||||
World world = BukkitUtil.getWorld(worldname);
|
||||
World world = BukkitUtil.getWorld(worldName);
|
||||
int count = 0;
|
||||
for (int y = y1; y <= y2; y++) {
|
||||
for (int x = x1; x <= x2; x++) {
|
||||
@ -301,8 +301,8 @@ public class BukkitHybridUtils extends HybridUtils {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int get_ey(String worldname, int sx, int ex, int sz, int ez, int sy) {
|
||||
World world = BukkitUtil.getWorld(worldname);
|
||||
public int get_ey(String worldName, int sx, int ex, int sz, int ez, int sy) {
|
||||
World world = BukkitUtil.getWorld(worldName);
|
||||
int maxY = world.getMaxHeight();
|
||||
int ey = sy;
|
||||
for (int x = sx; x <= ex; x++) {
|
||||
|
@ -310,7 +310,7 @@ public class BukkitSchematicHandler extends SchematicHandler {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void restoreTag(CompoundTag ct, short x, short y, short z, Schematic schem) {
|
||||
new StateWrapper(ct).restoreTag(x, y, z, schem);
|
||||
public void restoreTag(CompoundTag ct, short x, short y, short z, Schematic schematic) {
|
||||
new StateWrapper(ct).restoreTag(x, y, z, schematic);
|
||||
}
|
||||
}
|
||||
|
@ -62,8 +62,8 @@ public class BukkitSetupUtils extends SetupUtils {
|
||||
switch (type) {
|
||||
case 2: {
|
||||
if (object.id != null) {
|
||||
String areaname = object.id + "-" + object.min + "-" + object.max;
|
||||
String areaPath = "areas." + areaname;
|
||||
String areaName = object.id + "-" + object.min + "-" + object.max;
|
||||
String areaPath = "areas." + areaName;
|
||||
if (!worldSection.contains(areaPath)) {
|
||||
worldSection.createSection(areaPath);
|
||||
}
|
||||
|
@ -97,8 +97,8 @@ public class BukkitUtil extends WorldUtil {
|
||||
return entity.getWorld().getName();
|
||||
}
|
||||
|
||||
public static List<Entity> getEntities(String worldname) {
|
||||
return getWorld(worldname).getEntities();
|
||||
public static List<Entity> getEntities(String worldName) {
|
||||
return getWorld(worldName).getEntities();
|
||||
}
|
||||
|
||||
public static Location getLocation(Entity entity) {
|
||||
@ -114,8 +114,8 @@ public class BukkitUtil extends WorldUtil {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isWorld(String world) {
|
||||
return getWorld(world) != null;
|
||||
public boolean isWorld(String worldName) {
|
||||
return getWorld(worldName) != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -124,8 +124,8 @@ public class BukkitUtil extends WorldUtil {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSign(String worldname, int x, int y, int z, String[] lines) {
|
||||
World world = getWorld(worldname);
|
||||
public void setSign(String worldName, int x, int y, int z, String[] lines) {
|
||||
World world = getWorld(worldName);
|
||||
Block block = world.getBlockAt(x, y, z);
|
||||
// block.setType(Material.AIR);
|
||||
block.setTypeIdAndData(Material.WALL_SIGN.getId(), (byte) 2, false);
|
||||
@ -172,8 +172,8 @@ public class BukkitUtil extends WorldUtil {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveWorld(String worldname) {
|
||||
World world = getWorld(worldname);
|
||||
public void saveWorld(String worldName) {
|
||||
World world = getWorld(worldName);
|
||||
if (world != null) {
|
||||
world.save();
|
||||
}
|
||||
|
@ -321,7 +321,7 @@ public class Metrics {
|
||||
// Construct the post data
|
||||
StringBuilder json = new StringBuilder(1024);
|
||||
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, "plugin_version", pluginVersion);
|
||||
appendJSONPair(json, "server_version", serverVersion);
|
||||
|
@ -223,7 +223,7 @@ public class NbtFactory {
|
||||
|
||||
/**
|
||||
* Construct a new NBT wrapper from a compound.
|
||||
* @param nmsCompound - the NBT compund.
|
||||
* @param nmsCompound - the NBT compound.
|
||||
* @return The wrapper.
|
||||
*/
|
||||
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
|
||||
* 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.
|
||||
* <p>
|
||||
* The item stack must be a wrapper for a CraftItemStack.
|
||||
@ -669,7 +669,7 @@ public class NbtFactory {
|
||||
super(handle, getDataMap(handle));
|
||||
}
|
||||
|
||||
// Simplifiying access to each value
|
||||
// Simplifying access to each value
|
||||
public Byte getByte(String key, Byte defaultValue) {
|
||||
return containsKey(key) ? (Byte) get(key) : defaultValue;
|
||||
}
|
||||
|
@ -116,10 +116,10 @@ public class SendChunk {
|
||||
try {
|
||||
chunk.unload(true, false);
|
||||
} catch (Throwable e) {
|
||||
String worldname = chunk.getWorld().getName();
|
||||
PS.debug("$4Could not save chunk: " + worldname + ";" + chunk.getX() + ";" + chunk.getZ());
|
||||
String worldName = chunk.getWorld().getName();
|
||||
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 - $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)");
|
||||
}
|
||||
}
|
||||
@ -127,12 +127,12 @@ public class SendChunk {
|
||||
}
|
||||
}
|
||||
|
||||
public void sendChunk(String worldname, Collection<ChunkLoc> chunkLocs) {
|
||||
World myworld = Bukkit.getWorld(worldname);
|
||||
public void sendChunk(String worldName, Collection<ChunkLoc> chunkLocations) {
|
||||
World myWorld = Bukkit.getWorld(worldName);
|
||||
ArrayList<Chunk> chunks = new ArrayList<>();
|
||||
for (ChunkLoc loc : chunkLocs) {
|
||||
if (myworld.isChunkLoaded(loc.x, loc.z)) {
|
||||
chunks.add(myworld.getChunkAt(loc.x, loc.z));
|
||||
for (ChunkLoc loc : chunkLocations) {
|
||||
if (myWorld.isChunkLoaded(loc.x, loc.z)) {
|
||||
chunks.add(myWorld.getChunkAt(loc.x, loc.z));
|
||||
}
|
||||
}
|
||||
sendChunk(chunks);
|
||||
|
@ -45,10 +45,10 @@ public class SetGenCB {
|
||||
}
|
||||
}
|
||||
if (!set) {
|
||||
Iterator<BlockPopulator> iter = world.getPopulators().iterator();
|
||||
while (iter.hasNext()) {
|
||||
if (iter.next() instanceof BukkitAugmentedGenerator) {
|
||||
iter.remove();
|
||||
Iterator<BlockPopulator> iterator = world.getPopulators().iterator();
|
||||
while (iterator.hasNext()) {
|
||||
if (iterator.next() instanceof BukkitAugmentedGenerator) {
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -34,8 +34,7 @@ public class FastQueue_1_7 extends SlowQueue {
|
||||
private final RefMethod methodA;
|
||||
private final RefMethod methodGetById;
|
||||
private final RefMethod methodInitLighting;
|
||||
|
||||
private final SendChunk chunksender;
|
||||
private final SendChunk sendChunk;
|
||||
|
||||
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.methodGetById = this.classBlock.getMethod("getById", int.class);
|
||||
this.methodInitLighting = this.classChunk.getMethod("initLighting");
|
||||
this.chunksender = new SendChunk();
|
||||
this.sendChunk = new SendChunk();
|
||||
TaskManager.runTaskRepeat(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
@ -82,7 +81,7 @@ public class FastQueue_1_7 extends SlowQueue {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
this.chunksender.sendChunk(chunks);
|
||||
this.sendChunk.sendChunk(chunks);
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
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);
|
||||
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 methodGetByCombinedId;
|
||||
private final RefConstructor constructorBlockPosition;
|
||||
private final SendChunk chunksender;
|
||||
private final SendChunk sendChunk;
|
||||
|
||||
public FastQueue_1_8() throws RuntimeException {
|
||||
this.methodInitLighting = this.classChunk.getMethod("initLighting");
|
||||
@ -49,7 +49,7 @@ public class FastQueue_1_8 extends SlowQueue {
|
||||
this.methodGetHandle = this.classCraftWorld.getMethod("getHandle");
|
||||
this.methodGetChunkAt = this.classWorld.getMethod("getChunkAt", int.class, int.class);
|
||||
this.methodA = this.classChunk.getMethod("a", this.classBlockPosition, this.classIBlockData);
|
||||
this.chunksender = new SendChunk();
|
||||
this.sendChunk = new SendChunk();
|
||||
TaskManager.runTaskRepeat(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
@ -86,7 +86,7 @@ public class FastQueue_1_8 extends SlowQueue {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
this.chunksender.sendChunk(chunks);
|
||||
this.sendChunk.sendChunk(chunks);
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
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);
|
||||
this.toUpdate.remove(wrapper);
|
||||
}
|
||||
this.chunksender.sendChunk(world, locations);
|
||||
this.sendChunk.sendChunk(world, locations);
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,7 @@
|
||||
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.PseudoRandom;
|
||||
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.TaskManager;
|
||||
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.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
@ -23,18 +31,10 @@ import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map.Entry;
|
||||
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 {
|
||||
|
||||
private final SendChunk chunksender;
|
||||
private final SendChunk sendChunk;
|
||||
private final HashMap<ChunkWrapper, Chunk> toUpdate = new HashMap<>();
|
||||
private final RefMethod methodGetHandleChunk;
|
||||
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.tileEntityUnload = classWorld.getField("c");
|
||||
this.methodGetWorld = classChunk.getMethod("getWorld");
|
||||
this.chunksender = new SendChunk();
|
||||
this.sendChunk = new SendChunk();
|
||||
TaskManager.runTaskRepeat(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
@ -102,7 +102,7 @@ public class FastQueue_1_8_3 extends SlowQueue {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
this.chunksender.sendChunk(chunks);
|
||||
this.sendChunk.sendChunk(chunks);
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
MainUtil.canSendChunk = false;
|
||||
@ -129,7 +129,7 @@ public class FastQueue_1_8_3 extends SlowQueue {
|
||||
// Sections
|
||||
Method getHandle = chunk.getClass().getDeclaredMethod("getHandle");
|
||||
Object c = getHandle.invoke(chunk);
|
||||
Object w = methodGetWorld.of(c).call();
|
||||
Object w = this.methodGetWorld.of(c).call();
|
||||
Class<? extends Object> clazz = c.getClass();
|
||||
Field sections1 = clazz.getDeclaredField("sections");
|
||||
sections1.setAccessible(true);
|
||||
@ -138,7 +138,7 @@ public class FastQueue_1_8_3 extends SlowQueue {
|
||||
|
||||
Object[] sections = (Object[]) sections1.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);
|
||||
|
||||
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);
|
||||
this.toUpdate.remove(wrapper);
|
||||
}
|
||||
this.chunksender.sendChunk(world, locations);
|
||||
this.sendChunk.sendChunk(world, locations);
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,7 @@
|
||||
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.PseudoRandom;
|
||||
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.plotsquared.bukkit.util.BukkitUtil;
|
||||
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.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
@ -24,14 +32,6 @@ import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map.Entry;
|
||||
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 {
|
||||
|
||||
@ -143,7 +143,7 @@ public class FastQueue_1_9 extends SlowQueue {
|
||||
// Sections
|
||||
Method getHandle = chunk.getClass().getDeclaredMethod("getHandle");
|
||||
Object c = getHandle.invoke(chunk);
|
||||
Object w = methodGetWorld.of(c).call();
|
||||
Object w = this.methodGetWorld.of(c).call();
|
||||
Class<? extends Object> clazz = c.getClass();
|
||||
Field sf = clazz.getDeclaredField("sections");
|
||||
sf.setAccessible(true);
|
||||
@ -152,7 +152,7 @@ public class FastQueue_1_9 extends SlowQueue {
|
||||
|
||||
Object[] sections = (Object[]) sf.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);
|
||||
|
||||
Method xm = null;
|
||||
@ -306,7 +306,7 @@ public class FastQueue_1_9 extends SlowQueue {
|
||||
if (fixAll && !(boolean) this.methodAreNeighborsLoaded.of(c).call(1)) {
|
||||
World world = chunk.getWorld();
|
||||
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 z = wrapper.z - 1; z <= wrapper.z + 1; z++) {
|
||||
if (x != 0 && z != 0) {
|
||||
@ -314,7 +314,7 @@ public class FastQueue_1_9 extends SlowQueue {
|
||||
while (!other.isLoaded()) {
|
||||
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()) {
|
||||
return null;
|
||||
}
|
||||
Iterator<Entry<ChunkWrapper, PlotChunk<Chunk>>> iter = this.blocks.entrySet().iterator();
|
||||
PlotChunk<Chunk> toReturn = iter.next().getValue();
|
||||
Iterator<Entry<ChunkWrapper, PlotChunk<Chunk>>> iterator = this.blocks.entrySet().iterator();
|
||||
PlotChunk<Chunk> toReturn = iterator.next().getValue();
|
||||
if (SetQueue.IMP.isWaiting()) {
|
||||
return null;
|
||||
}
|
||||
iter.remove();
|
||||
iterator.remove();
|
||||
execute(toReturn);
|
||||
fixLighting(toReturn, true);
|
||||
return toReturn;
|
||||
|
@ -55,10 +55,10 @@ public class FileUUIDHandler extends UUIDHandlerImplementation {
|
||||
@Override
|
||||
public void run() {
|
||||
PS.debug(C.PREFIX + "&6Starting player data caching for: " + world);
|
||||
File uuidfile = new File(PS.get().IMP.getDirectory(), "uuids.txt");
|
||||
if (uuidfile.exists()) {
|
||||
File uuidFile = new File(PS.get().IMP.getDirectory(), "uuids.txt");
|
||||
if (uuidFile.exists()) {
|
||||
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) {
|
||||
try {
|
||||
line = line.trim();
|
||||
@ -89,8 +89,8 @@ public class FileUUIDHandler extends UUIDHandlerImplementation {
|
||||
toAdd.put(new StringWrapper("*"), DBFunc.everyone);
|
||||
HashSet<UUID> all = UUIDHandler.getAllUUIDS();
|
||||
PS.debug("&aFast mode UUID caching enabled!");
|
||||
File playerdataFolder = new File(container, world + File.separator + "playerdata");
|
||||
String[] dat = playerdataFolder.list(new FilenameFilter() {
|
||||
File playerDataFolder = new File(container, world + File.separator + "playerdata");
|
||||
String[] dat = playerDataFolder.list(new FilenameFilter() {
|
||||
@Override
|
||||
public boolean accept(File f, String s) {
|
||||
return s.endsWith(".dat");
|
||||
@ -103,7 +103,7 @@ public class FileUUIDHandler extends UUIDHandlerImplementation {
|
||||
try {
|
||||
UUID uuid = UUID.fromString(s);
|
||||
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);
|
||||
NbtFactory.NbtCompound compound = NbtFactory.fromStream(is, NbtFactory.StreamOptions.GZIP_COMPRESSION);
|
||||
NbtFactory.NbtCompound bukkit = (NbtFactory.NbtCompound) compound.get("bukkit");
|
||||
@ -137,11 +137,11 @@ public class FileUUIDHandler extends UUIDHandlerImplementation {
|
||||
worlds.add("world");
|
||||
HashSet<UUID> uuids = new HashSet<>();
|
||||
HashSet<String> names = new HashSet<>();
|
||||
File playerdataFolder = null;
|
||||
File playerDataFolder = null;
|
||||
for (String worldName : worlds) {
|
||||
// Getting UUIDs
|
||||
playerdataFolder = new File(container, worldName + File.separator + "playerdata");
|
||||
String[] dat = playerdataFolder.list(new FilenameFilter() {
|
||||
playerDataFolder = new File(container, worldName + File.separator + "playerdata");
|
||||
String[] dat = playerDataFolder.list(new FilenameFilter() {
|
||||
@Override
|
||||
public boolean accept(File f, String s) {
|
||||
return s.endsWith(".dat");
|
||||
@ -154,7 +154,7 @@ public class FileUUIDHandler extends UUIDHandlerImplementation {
|
||||
UUID uuid = UUID.fromString(s);
|
||||
uuids.add(uuid);
|
||||
} catch (Exception e) {
|
||||
PS.debug(C.PREFIX + "Invalid playerdata: " + current);
|
||||
PS.debug(C.PREFIX + "Invalid PlayerData: " + current);
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -176,7 +176,7 @@ public class FileUUIDHandler extends UUIDHandlerImplementation {
|
||||
}
|
||||
for (UUID uuid : uuids) {
|
||||
try {
|
||||
File file = new File(playerdataFolder + File.separator + uuid.toString() + ".dat");
|
||||
File file = new File(playerDataFolder + File.separator + uuid.toString() + ".dat");
|
||||
if (!file.exists()) {
|
||||
continue;
|
||||
}
|
||||
@ -199,7 +199,7 @@ public class FileUUIDHandler extends UUIDHandlerImplementation {
|
||||
}
|
||||
toAdd.put(new StringWrapper(name), uuid);
|
||||
} 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) {
|
||||
|
@ -151,7 +151,7 @@ public class SQLUUIDHandler extends UUIDHandlerImplementation {
|
||||
|
||||
@Override
|
||||
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) {
|
||||
return;
|
||||
}
|
||||
|
Reference in New Issue
Block a user