Fixes a few typos
Fixes #943
Fixes #944
Fixes metrics (broke in b69e31129d)
Fixes plot setup issue
Fixes some lighting issues
Fixes ChunkListener + cauldron
Tweak some  schematic stuff
This commit is contained in:
Jesse Boyd 2016-03-11 15:33:18 +11:00
parent c979be2994
commit 66da71bc9f
15 changed files with 170 additions and 198 deletions

View File

@ -1,7 +1,5 @@
package com.plotsquared.bukkit.listeners; package com.plotsquared.bukkit.listeners;
import static com.intellectualcrafters.plot.util.ReflectionUtils.getRefClass;
import com.intellectualcrafters.plot.PS; import com.intellectualcrafters.plot.PS;
import com.intellectualcrafters.plot.config.Settings; import com.intellectualcrafters.plot.config.Settings;
import com.intellectualcrafters.plot.object.ChunkLoc; import com.intellectualcrafters.plot.object.ChunkLoc;
@ -35,25 +33,30 @@ import java.util.ArrayDeque;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map.Entry; import java.util.Map.Entry;
import static com.intellectualcrafters.plot.util.ReflectionUtils.getRefClass;
public class ChunkListener implements Listener { public class ChunkListener implements Listener {
private final RefClass classChunk = getRefClass("{nms}.Chunk");
private final RefClass classCraftChunk = getRefClass("{cb}.CraftChunk");
private final RefField mustSave = classChunk.getField("mustSave");
private Chunk lastChunk = null;
private RefMethod methodGetHandleChunk; private RefMethod methodGetHandleChunk;
private RefClass classChunk;
private RefClass classCraftChunk;
private RefField mustSave;
private Chunk lastChunk;
public ChunkListener() { public ChunkListener() {
RefMethod method; if (Settings.CHUNK_PROCESSOR_GC || Settings.CHUNK_PROCESSOR_TRIM_ON_SAVE) {
try { try {
method = classCraftChunk.getMethod("getHandle"); this.classChunk = getRefClass("{nms}.Chunk");
} catch (final Exception e) { this.classCraftChunk = getRefClass("{cb}.CraftChunk");
method = null; this.mustSave = classChunk.getField("mustSave");
e.printStackTrace(); this.methodGetHandleChunk = classCraftChunk.getMethod("getHandle");
} catch (Throwable e) {
PS.debug("PlotSquared/Server not compatible for chunk processor trim/gc");
Settings.CHUNK_PROCESSOR_GC = false;
Settings.CHUNK_PROCESSOR_TRIM_ON_SAVE = false;
}
} }
methodGetHandleChunk = method;
if (!Settings.CHUNK_PROCESSOR_GC) { if (!Settings.CHUNK_PROCESSOR_GC) {
return; return;
} }

View File

@ -4,8 +4,6 @@ import com.intellectualcrafters.plot.object.PlotPlayer;
import com.intellectualcrafters.plot.util.AbstractTitle; import com.intellectualcrafters.plot.util.AbstractTitle;
import com.plotsquared.bukkit.object.BukkitPlayer; import com.plotsquared.bukkit.object.BukkitPlayer;
import java.lang.reflect.InvocationTargetException;
public class DefaultTitle extends AbstractTitle { public class DefaultTitle extends AbstractTitle {
@Override @Override
@ -13,8 +11,7 @@ public class DefaultTitle extends AbstractTitle {
try { try {
final DefaultTitleManager title = new DefaultTitleManager(head, sub, in, delay, out); final DefaultTitleManager title = new DefaultTitleManager(head, sub, in, delay, out);
title.send(((BukkitPlayer) player).player); title.send(((BukkitPlayer) player).player);
} catch (ClassNotFoundException | InvocationTargetException | SecurityException | NoSuchMethodException | InstantiationException | } catch (Throwable e) {
IllegalArgumentException | IllegalAccessException e) {
AbstractTitle.TITLE_CLASS = new DefaultTitle_183(); AbstractTitle.TITLE_CLASS = new DefaultTitle_183();
AbstractTitle.TITLE_CLASS.sendTitle(player, head, sub, in, delay, out); AbstractTitle.TITLE_CLASS.sendTitle(player, head, sub, in, delay, out);
} }

View File

@ -12,7 +12,7 @@ public class HackTitle extends AbstractTitle {
try { try {
final HackTitleManager title = new HackTitleManager(head, sub, in, delay, out); final HackTitleManager title = new HackTitleManager(head, sub, in, delay, out);
title.send(((BukkitPlayer) player).player); title.send(((BukkitPlayer) player).player);
} catch (Exception e) { } catch (Throwable e) {
PS.debug("&cYour server version does not support titles!"); PS.debug("&cYour server version does not support titles!");
Settings.TITLES = false; Settings.TITLES = false;
AbstractTitle.TITLE_CLASS = null; AbstractTitle.TITLE_CLASS = null;

View File

@ -20,7 +20,6 @@
//////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////
package com.plotsquared.bukkit.util; package com.plotsquared.bukkit.util;
import com.intellectualcrafters.configuration.file.YamlConfiguration;
import com.intellectualcrafters.plot.PS; import com.intellectualcrafters.plot.PS;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -64,14 +63,6 @@ public class Metrics {
* All of the custom graphs to submit to metrics * All of the custom graphs to submit to metrics
*/ */
private final Set<Graph> graphs = Collections.synchronizedSet(new HashSet<Graph>()); private final Set<Graph> graphs = Collections.synchronizedSet(new HashSet<Graph>());
/**
* The plugin configuration file
*/
private final YamlConfiguration configuration;
/**
* The plugin configuration file
*/
private final File configurationFile;
/** /**
* Unique server id * Unique server id
*/ */
@ -90,21 +81,8 @@ public class Metrics {
throw new IllegalArgumentException("Plugin cannot be null"); throw new IllegalArgumentException("Plugin cannot be null");
} }
this.plugin = plugin; this.plugin = plugin;
// load the config guid = UUID.randomUUID().toString();
configurationFile = getConfigFile(); debug = false;
configuration = YamlConfiguration.loadConfiguration(configurationFile);
// add some defaults
configuration.addDefault("opt-out", false);
configuration.addDefault("guid", UUID.randomUUID().toString());
configuration.addDefault("debug", false);
// Do we need to create the file?
if (configuration.get("guid", null) == null) {
configuration.options().header("http://mcstats.org").copyDefaults(true);
configuration.save(configurationFile);
}
// Load the guid then
guid = configuration.getString("guid");
debug = configuration.getBoolean("debug", false);
} }
/** /**
@ -276,6 +254,7 @@ public class Metrics {
// Each post thereafter will be a ping // Each post thereafter will be a ping
firstPost = false; firstPost = false;
} catch (final IOException e) { } catch (final IOException e) {
e.printStackTrace();
if (debug) { if (debug) {
Bukkit.getLogger().log(Level.INFO, "[Metrics] " + e.getMessage()); Bukkit.getLogger().log(Level.INFO, "[Metrics] " + e.getMessage());
} }
@ -350,6 +329,7 @@ public class Metrics {
playersOnline = ((Player[]) Bukkit.class.getMethod("getOnlinePlayers", new Class<?>[0]).invoke(null)).length; playersOnline = ((Player[]) Bukkit.class.getMethod("getOnlinePlayers", new Class<?>[0]).invoke(null)).length;
} }
} catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException ex) { } catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException ex) {
ex.printStackTrace();
} }
// END server software specific section -- all code below does not use // END server software specific section -- all code below does not use
// any code outside of this class / Java // any code outside of this class / Java
@ -435,34 +415,43 @@ public class Metrics {
if (debug) { if (debug) {
PS.debug("[Metrics] Prepared request for " + pluginName + " uncompressed=" + uncompressed.length + " compressed=" + compressed.length); PS.debug("[Metrics] Prepared request for " + pluginName + " uncompressed=" + uncompressed.length + " compressed=" + compressed.length);
} }
// Write the data try {
String response; try (OutputStream os = connection.getOutputStream()) {
try (OutputStream os = connection.getOutputStream(); os.write(compressed);
BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()))) { os.flush();
os.write(compressed);
os.flush();
// Now read the response
response = reader.readLine();
}
if (response == null || response.startsWith("ERR") || response.startsWith("7")) {
if (response == null) {
response = "null";
} else if (response.startsWith("7")) {
response = response.substring(response.startsWith("7,") ? 2 : 1);
} }
throw new IOException(response); String response;
} else { try (BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()))) {
// Is this the first update this hour? response = reader.readLine();
if ("1".equals(response) || response.contains("This is your first update this hour")) { if (debug) {
synchronized (graphs) { PS.debug("[Metrics] Response for " + pluginName + ": " + response);
for (final Graph graph : graphs) { }
for (final Plotter plotter : graph.getPlotters()) { }
plotter.reset(); if (response == null || response.startsWith("ERR") || response.startsWith("7")) {
if (response == null) {
response = "null";
} else if (response.startsWith("7")) {
response = response.substring(response.startsWith("7,") ? 2 : 1);
}
throw new IOException(response);
} else {
// Is this the first update this hour?
if ("1".equals(response) || response.contains("This is your first update this hour")) {
synchronized (graphs) {
for (final Graph graph : graphs) {
for (final Plotter plotter : graph.getPlotters()) {
plotter.reset();
}
} }
} }
} }
} }
} }
catch (Exception e) {
if (debug) {
e.printStackTrace();
}
}
} }
/** /**

View File

@ -338,45 +338,47 @@ public class FastQueue_1_9 extends SlowQueue {
continue; continue;
} }
final int[] array = bc.getIdArray(j); final int[] array = bc.getIdArray(j);
int l = PseudoRandom.random.random(2); if (array != null) {
for (int k = 0; k < array.length; k++) { int l = PseudoRandom.random.random(2);
final int i = array[k]; for (int k = 0; k < array.length; k++) {
if (i < 16) { final int i = array[k];
continue; if (i < 16) {
} continue;
final short id = (short) (i >> 4); }
switch (id) { // Lighting final short id = (short) (i >> 4);
default: switch (id) { // Lighting
if (!fixAll) { default:
continue; if (!fixAll) {
} continue;
if ((k & 1) == l) { }
l = 1 - l; if ((k & 1) == l) {
continue; l = 1 - l;
} continue;
case 10: }
case 11: case 10:
case 39: case 11:
case 40: case 39:
case 50: case 40:
case 51: case 50:
case 62: case 51:
case 74: case 62:
case 76: case 74:
case 89: case 76:
case 122: case 89:
case 124: case 122:
case 130: case 124:
case 138: case 130:
case 169: case 138:
final int x = MainUtil.x_loc[j][k]; case 169:
final int y = MainUtil.y_loc[j][k]; final int x = MainUtil.x_loc[j][k];
final int z = MainUtil.z_loc[j][k]; final int y = MainUtil.y_loc[j][k];
if (isSurrounded(bc.getIdArrays(), x, y, z)) { final int z = MainUtil.z_loc[j][k];
continue; if (isSurrounded(bc.getIdArrays(), x, y, z)) {
} continue;
final Object pos = classBlockPositionConstructor.create(X + x, y, Z + z); }
relight.call(pos); final Object pos = classBlockPositionConstructor.create(X + x, y, Z + z);
relight.call(pos);
}
} }
} }
} }

View File

@ -20,11 +20,6 @@
//////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.plot.commands; package com.intellectualcrafters.plot.commands;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map.Entry;
import com.intellectualcrafters.plot.PS; import com.intellectualcrafters.plot.PS;
import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.config.ConfigurationNode; import com.intellectualcrafters.plot.config.ConfigurationNode;
@ -39,6 +34,11 @@ import com.intellectualcrafters.plot.util.StringMan;
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.Arrays;
import java.util.List;
import java.util.Map.Entry;
@CommandDeclaration( @CommandDeclaration(
command = "setup", command = "setup",
permission = "plots.admin.command.setup", permission = "plots.admin.command.setup",
@ -132,14 +132,13 @@ public class Setup extends SubCommand {
object.type = allTypes.indexOf(args[0].toLowerCase()); object.type = allTypes.indexOf(args[0].toLowerCase());
final GeneratorWrapper<?> gen = SetupUtils.generators.get(object.setupGenerator); final GeneratorWrapper<?> gen = SetupUtils.generators.get(object.setupGenerator);
if (object.type == 0) { if (object.type == 0) {
object.current = 7; object.current = 6;
if (object.step == null) { if (object.step == null) {
object.plotManager = object.setupGenerator; object.plotManager = object.setupGenerator;
object.step = SetupUtils.generators.get(object.plotManager).getPlotGenerator().getNewPlotArea("CheckingPlotSquaredGenerator", null, null, null).getSettingNodes(); object.step = SetupUtils.generators.get(object.plotManager).getPlotGenerator().getNewPlotArea("CheckingPlotSquaredGenerator", null, null, null).getSettingNodes();
SetupUtils.generators.get(object.plotManager).getPlotGenerator().processSetup(object); SetupUtils.generators.get(object.plotManager).getPlotGenerator().processSetup(object);
} }
if (object.step.length == 0) { if (object.step.length == 0) {
object.current = 7;
MainUtil.sendMessage(plr, "&6What do you want your world to be called?"); MainUtil.sendMessage(plr, "&6What do you want your world to be called?");
object.setup_index = 0; object.setup_index = 0;
return true; return true;

View File

@ -1,18 +1,13 @@
package com.intellectualcrafters.plot.generator; package com.intellectualcrafters.plot.generator;
import java.util.Set;
import com.intellectualcrafters.plot.PS; import com.intellectualcrafters.plot.PS;
import com.intellectualcrafters.plot.object.LazyResult; import com.intellectualcrafters.plot.object.*;
import com.intellectualcrafters.plot.object.PlotArea;
import com.intellectualcrafters.plot.object.PlotBlock;
import com.intellectualcrafters.plot.object.PlotManager;
import com.intellectualcrafters.plot.object.PseudoRandom;
import com.intellectualcrafters.plot.object.RegionWrapper;
import com.intellectualcrafters.plot.util.PlotChunk; import com.intellectualcrafters.plot.util.PlotChunk;
import com.intellectualcrafters.plot.util.SetQueue; import com.intellectualcrafters.plot.util.SetQueue;
import com.intellectualcrafters.plot.util.SetQueue.ChunkWrapper; import com.intellectualcrafters.plot.util.SetQueue.ChunkWrapper;
import java.util.Set;
public class AugmentedUtils { public class AugmentedUtils {
private static boolean enabled = true; private static boolean enabled = true;
@ -23,9 +18,9 @@ public class AugmentedUtils {
enabled = true; enabled = true;
} }
public static void generate(final String world, final int cx, final int cz, LazyResult<PlotChunk<?>> lazyChunk) { public static boolean generate(final String world, final int cx, final int cz, LazyResult<PlotChunk<?>> lazyChunk) {
if (!enabled) { if (!enabled) {
return; return false;
} }
if (lazyChunk == null) { if (lazyChunk == null) {
lazyChunk = new LazyResult<PlotChunk<?>>() { lazyChunk = new LazyResult<PlotChunk<?>>() {
@ -40,14 +35,15 @@ public class AugmentedUtils {
RegionWrapper region = new RegionWrapper(bx, bx + 15, bz, bz + 15); RegionWrapper region = new RegionWrapper(bx, bx + 15, bz, bz + 15);
Set<PlotArea> areas = PS.get().getPlotAreas(world, region); Set<PlotArea> areas = PS.get().getPlotAreas(world, region);
if (areas.isEmpty()) { if (areas.isEmpty()) {
return; return false;
} }
final PseudoRandom r = new PseudoRandom(); final PseudoRandom r = new PseudoRandom();
r.state = (cx << 16) | (cz & 0xFFFF);; r.state = (cx << 16) | (cz & 0xFFFF);
ChunkWrapper wrap = SetQueue.IMP.new ChunkWrapper(world, cx, cz); ChunkWrapper wrap = SetQueue.IMP.new ChunkWrapper(world, cx, cz);
boolean toReturn = false;
for (final PlotArea area : areas) { for (final PlotArea area : areas) {
if (area.TYPE == 0) { if (area.TYPE == 0) {
return; return false;
} }
if (area.TERRAIN == 3) { if (area.TERRAIN == 3) {
continue; continue;
@ -59,12 +55,13 @@ public class AugmentedUtils {
final PlotChunk<?> result = lazyChunk.getOrCreate(); final PlotChunk<?> result = lazyChunk.getOrCreate();
final PlotChunk<?> primaryMask; final PlotChunk<?> primaryMask;
// coords // coords
int bxx = Math.max(0, area.getRegion().minX - bx); int bxx,bzz,txx,tzz;
int bzz = Math.max(0, area.getRegion().minZ - bz);
int txx = Math.min(15, area.getRegion().maxX - bx);
int tzz = Math.min(15, area.getRegion().maxZ - bz);
// gen // gen
if (area.TYPE == 2) { if (area.TYPE == 2) {
bxx = Math.max(0, area.getRegion().minX - bx);
bzz = Math.max(0, area.getRegion().minZ - bz);
txx = Math.min(15, area.getRegion().maxX - bx);
tzz = Math.min(15, area.getRegion().maxZ - bz);
primaryMask = new PlotChunk<Object>(wrap) { primaryMask = new PlotChunk<Object>(wrap) {
@Override @Override
public Object getChunkAbs() { public Object getChunkAbs() {
@ -96,6 +93,8 @@ public class AugmentedUtils {
} }
}; };
} else { } else {
bxx = bzz = 0;
txx = tzz = 15;
primaryMask = result; primaryMask = result;
} }
PlotChunk<?> secondaryMask; PlotChunk<?> secondaryMask;
@ -120,6 +119,8 @@ public class AugmentedUtils {
} }
if (!has) { if (!has) {
continue; continue;
} else {
toReturn = true;
} }
secondaryMask = new PlotChunk<Object>(wrap) { secondaryMask = new PlotChunk<Object>(wrap) {
@Override @Override
@ -156,6 +157,7 @@ public class AugmentedUtils {
} }
} }
} }
toReturn = true;
} }
generator.generateChunk(secondaryMask, area, r); generator.generateChunk(secondaryMask, area, r);
} }
@ -163,5 +165,6 @@ public class AugmentedUtils {
lazyChunk.get().addToQueue(); lazyChunk.get().addToQueue();
lazyChunk.get().flush(false); lazyChunk.get().flush(false);
} }
return toReturn;
} }
} }

View File

@ -22,14 +22,7 @@ package com.intellectualcrafters.plot.generator;
import com.intellectualcrafters.plot.PS; import com.intellectualcrafters.plot.PS;
import com.intellectualcrafters.plot.commands.Template; import com.intellectualcrafters.plot.commands.Template;
import com.intellectualcrafters.plot.object.ChunkLoc; import com.intellectualcrafters.plot.object.*;
import com.intellectualcrafters.plot.object.FileBytes;
import com.intellectualcrafters.plot.object.Location;
import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.object.PlotArea;
import com.intellectualcrafters.plot.object.PlotBlock;
import com.intellectualcrafters.plot.object.PlotId;
import com.intellectualcrafters.plot.object.RunnableVal;
import com.intellectualcrafters.plot.util.*; import com.intellectualcrafters.plot.util.*;
import java.io.File; import java.io.File;
@ -46,19 +39,18 @@ public class HybridPlotManager extends ClassicPlotManager {
public void exportTemplate(final PlotArea plotworld) throws IOException { public void exportTemplate(final PlotArea plotworld) throws IOException {
final HashSet<FileBytes> files = new HashSet<>( final HashSet<FileBytes> files = new HashSet<>(
Collections.singletonList(new FileBytes("templates/" + "tmp-data.yml", Template.getBytes(plotworld)))); Collections.singletonList(new FileBytes("templates/" + "tmp-data.yml", Template.getBytes(plotworld))));
final String psRoot = PS.get().IMP.getDirectory() + File.separator;
final String dir = "schematics" + File.separator + "GEN_ROAD_SCHEMATIC" + File.separator + plotworld.worldname + File.separator; final String dir = "schematics" + File.separator + "GEN_ROAD_SCHEMATIC" + File.separator + plotworld.worldname + File.separator;
final String newDir = "schematics" + File.separator + "GEN_ROAD_SCHEMATIC" + File.separator + "__TEMP_DIR__" + File.separator; final String newDir = "schematics" + File.separator + "GEN_ROAD_SCHEMATIC" + File.separator + "__TEMP_DIR__" + File.separator;
try { try {
final File sideroad = new File(psRoot + dir + "sideroad.schematic"); final File sideroad = MainUtil.getFile(PS.get().IMP.getDirectory(), dir + "sideroad.schematic");
if (sideroad.exists()) { if (sideroad.exists()) {
files.add(new FileBytes(newDir + "sideroad.schematic", Files.readAllBytes(sideroad.toPath()))); files.add(new FileBytes(newDir + "sideroad.schematic", Files.readAllBytes(sideroad.toPath())));
} }
final File intersection = new File(psRoot + dir + "intersection.schematic"); final File intersection = MainUtil.getFile(PS.get().IMP.getDirectory(), "intersection.schematic");
if (intersection.exists()) { if (intersection.exists()) {
files.add(new FileBytes(newDir + "intersection.schematic", Files.readAllBytes(intersection.toPath()))); files.add(new FileBytes(newDir + "intersection.schematic", Files.readAllBytes(intersection.toPath())));
} }
final File plot = new File(psRoot + dir + "plot.schematic"); final File plot = MainUtil.getFile(PS.get().IMP.getDirectory(), dir + "plot.schematic");
if (plot.exists()) { if (plot.exists()) {
files.add(new FileBytes(newDir + "plot.schematic", Files.readAllBytes(plot.toPath()))); files.add(new FileBytes(newDir + "plot.schematic", Files.readAllBytes(plot.toPath())));
} }

View File

@ -27,11 +27,13 @@ import com.intellectualcrafters.plot.object.PlotArea;
import com.intellectualcrafters.plot.object.PlotBlock; import com.intellectualcrafters.plot.object.PlotBlock;
import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.object.PlotId;
import com.intellectualcrafters.plot.object.schematic.PlotItem; import com.intellectualcrafters.plot.object.schematic.PlotItem;
import com.intellectualcrafters.plot.util.MainUtil;
import com.intellectualcrafters.plot.util.MathMan; import com.intellectualcrafters.plot.util.MathMan;
import com.intellectualcrafters.plot.util.SchematicHandler; import com.intellectualcrafters.plot.util.SchematicHandler;
import com.intellectualcrafters.plot.util.SchematicHandler.Dimension; import com.intellectualcrafters.plot.util.SchematicHandler.Dimension;
import com.intellectualcrafters.plot.util.SchematicHandler.Schematic; import com.intellectualcrafters.plot.util.SchematicHandler.Schematic;
import java.io.File;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
@ -191,12 +193,12 @@ public class HybridPlotWorld extends ClassicPlotWorld {
public void setupSchematics() { public void setupSchematics() {
G_SCH = new HashMap<>(); G_SCH = new HashMap<>();
final String schem1Str = "GEN_ROAD_SCHEMATIC/" + worldname + "/sideroad"; final File schem1File = MainUtil.getFile(PS.get().IMP.getDirectory(),"schematics/GEN_ROAD_SCHEMATIC/" + worldname + "/sideroad.schematic");
final String schem2Str = "GEN_ROAD_SCHEMATIC/" + worldname + "/intersection"; final File schem2File = MainUtil.getFile(PS.get().IMP.getDirectory(), "schematics/GEN_ROAD_SCHEMATIC/" + worldname + "/intersection.schematic");
final String schem3Str = "GEN_ROAD_SCHEMATIC/" + worldname + "/plot"; final File schem3File = MainUtil.getFile(PS.get().IMP.getDirectory(), "schematics/GEN_ROAD_SCHEMATIC/" + worldname + "/plot.schematic");
final Schematic schem1 = SchematicHandler.manager.getSchematic(schem1Str); final Schematic schem1 = SchematicHandler.manager.getSchematic(schem1File);
final Schematic schem2 = SchematicHandler.manager.getSchematic(schem2Str); final Schematic schem2 = SchematicHandler.manager.getSchematic(schem2File);
final Schematic schem3 = SchematicHandler.manager.getSchematic(schem3Str); final Schematic schem3 = SchematicHandler.manager.getSchematic(schem3File);
final int shift = ROAD_WIDTH / 2; final int shift = ROAD_WIDTH / 2;
int oddshift = 0; int oddshift = 0;
if ((ROAD_WIDTH & 1) != 0) { if ((ROAD_WIDTH & 1) != 0) {

View File

@ -5,32 +5,12 @@ import com.intellectualcrafters.plot.PS;
import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.flag.Flag; import com.intellectualcrafters.plot.flag.Flag;
import com.intellectualcrafters.plot.flag.FlagManager; import com.intellectualcrafters.plot.flag.FlagManager;
import com.intellectualcrafters.plot.object.ChunkLoc; import com.intellectualcrafters.plot.object.*;
import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.util.*;
import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.object.PlotAnalysis;
import com.intellectualcrafters.plot.object.PlotArea;
import com.intellectualcrafters.plot.object.PlotBlock;
import com.intellectualcrafters.plot.object.PlotId;
import com.intellectualcrafters.plot.object.PlotManager;
import com.intellectualcrafters.plot.object.RegionWrapper;
import com.intellectualcrafters.plot.object.RunnableVal;
import com.intellectualcrafters.plot.util.ChunkManager;
import com.intellectualcrafters.plot.util.MathMan;
import com.intellectualcrafters.plot.util.SchematicHandler;
import com.intellectualcrafters.plot.util.SetQueue;
import com.intellectualcrafters.plot.util.TaskManager;
import java.io.File; import java.io.File;
import java.util.ArrayDeque; import java.util.*;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map.Entry; import java.util.Map.Entry;
import java.util.Set;
import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger;
public abstract class HybridUtils { public abstract class HybridUtils {
@ -313,7 +293,7 @@ public abstract class HybridUtils {
final Set<RegionWrapper> sideroad = new HashSet<>(Collections.singletonList(new RegionWrapper(sx, ex, sy, ey, sz, ez))); final 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 = PS.get().IMP.getDirectory() + File.separator + "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

View File

@ -361,10 +361,11 @@ public class Plot {
} }
if (isMerged()) { if (isMerged()) {
HashSet<Plot> plots = getConnectedPlots(); HashSet<Plot> plots = getConnectedPlots();
final HashSet<UUID> owners = new HashSet<UUID>(2); Plot[] array = plots.toArray(new Plot[plots.size()]);
final HashSet<UUID> owners = new HashSet<UUID>(1);
UUID last = owner; UUID last = owner;
owners.add(owner); owners.add(owner);
for (Plot current : plots) { for (Plot current : array) {
if (last == null || current.owner.getMostSignificantBits() != last.getMostSignificantBits()) { if (last == null || current.owner.getMostSignificantBits() != last.getMostSignificantBits()) {
owners.add(current.owner); owners.add(current.owner);
last = current.owner; last = current.owner;
@ -1953,7 +1954,11 @@ public class Plot {
} else if (index < -1) { } else if (index < -1) {
PS.debug("This should NEVER happen. Seriously, it's impossible."); PS.debug("This should NEVER happen. Seriously, it's impossible.");
} }
final String name = lines[i - 1].substring(index); String line = lines[i-1];
if (line.length() <= index) {
return null;
}
final String name = line.substring(index);
if (name.isEmpty()) { if (name.isEmpty()) {
return null; return null;
} }

View File

@ -205,4 +205,4 @@ public class BO3Handler {
} }
return base; return base;
} }
} }

View File

@ -52,7 +52,7 @@ public class ExpireManager {
PlotMessage msg = new PlotMessage() PlotMessage msg = new PlotMessage()
.text(num + " " + (num > 1 ? "plots are" : "plot is") + " expired:").color("$1").command("/plot list expired").tooltip("/plot list expired") .text(num + " " + (num > 1 ? "plots are" : "plot is") + " expired:").color("$1").command("/plot list expired").tooltip("/plot list expired")
//.text("\n - ").color("$3").text("Delete all (/plot delete expired)").color("$2").command("/plot delete expired") //.text("\n - ").color("$3").text("Delete all (/plot delete expired)").color("$2").command("/plot delete expired")
.text("\n - ").color("$3").text("Delete this (/plot expired)").color("$2").command("/plot delete").tooltip("/plot delete") .text("\n - ").color("$3").text("Delete this (/plot delete)").color("$2").command("/plot delete").tooltip("/plot delete")
.text("\n - ").color("$3").text("Remind later (/plot set keep 1d)").color("$2").command("/plot set keep 1d").tooltip("/plot set keep 1d") .text("\n - ").color("$3").text("Remind later (/plot set keep 1d)").color("$2").command("/plot set keep 1d").tooltip("/plot set keep 1d")
.text("\n - ").color("$3").text("Keep this (/plot set keep true)").color("$2").command("/plot set keep true").tooltip("/plot set keep true"); .text("\n - ").color("$3").text("Keep this (/plot set keep true)").color("$2").command("/plot set keep true").tooltip("/plot set keep true");
msg.send(pp); msg.send(pp);

View File

@ -356,13 +356,15 @@ public class MainUtil {
} }
return null; return null;
} }
return player.getLocation().getPlotAbs(); return player.getCurrentPlot();
} }
PlotArea area; PlotArea area;
if (player != null) { if (player != null) {
area = player.getApplicablePlotArea(); area = PS.get().getPlotAreaByString(arg);
} if (area == null) {
else { area = player.getApplicablePlotArea();
}
} else {
area = ConsolePlayer.getConsole().getApplicablePlotArea(); area = ConsolePlayer.getConsole().getApplicablePlotArea();
} }
final String[] split = arg.split(";|,"); final String[] split = arg.split(";|,");
@ -376,24 +378,22 @@ public class MainUtil {
} else if (split.length == 2) { } else if (split.length == 2) {
id = PlotId.fromString(arg); id = PlotId.fromString(arg);
} else { } else {
PlotArea tmp = PS.get().getPlotAreaByString(arg); Collection<Plot> plots;
if (area == null) { if (area == null) {
if (message) { plots = PS.get().getPlots();
MainUtil.sendMessage(player, C.NOT_VALID_PLOT_WORLD);
}
return null;
} else { } else {
for (final Plot p : area.getPlots()) { plots = area.getPlots();
final String name = p.getAlias();
if (!name.isEmpty() && StringMan.isEqualIgnoreCase(name, arg)) {
return p;
}
}
if (message) {
MainUtil.sendMessage(player, C.NOT_VALID_PLOT_ID);
}
return null;
} }
for (final Plot p : plots) {
final String name = p.getAlias();
if (!name.isEmpty() && StringMan.isEqualIgnoreCase(name, arg)) {
return p;
}
}
if (message) {
MainUtil.sendMessage(player, C.NOT_VALID_PLOT_ID);
}
return null;
} }
if (id == null) { if (id == null) {
if (message) { if (message) {

View File

@ -62,7 +62,7 @@ public abstract class SchematicHandler {
if (outputDir == null) { if (outputDir == null) {
directory = Settings.SCHEMATIC_SAVE_PATH; directory = Settings.SCHEMATIC_SAVE_PATH;
} else { } else {
directory = outputDir.getPath(); directory = outputDir.getAbsolutePath();
} }
final Runnable THIS = this; final Runnable THIS = this;
SchematicHandler.manager.getCompoundTag(plot, new RunnableVal<CompoundTag>() { SchematicHandler.manager.getCompoundTag(plot, new RunnableVal<CompoundTag>() {
@ -827,7 +827,7 @@ public abstract class SchematicHandler {
ids2[i] = (byte) ids[i]; ids2[i] = (byte) ids[i];
} }
CompoundTag tag = createTag(ids2, datas, schematicDimension); CompoundTag tag = createTag(ids2, datas, schematicDimension);
SchematicHandler.this.save(tag, file.toString()); SchematicHandler.this.save(tag, file.getAbsolutePath());
} }
} }