PlotBlock cache / events / flags

This commit is contained in:
Jesse Boyd 2016-06-04 06:20:13 +10:00
parent f84766074e
commit ca5d3a818b
26 changed files with 171 additions and 138 deletions

View File

@ -1,26 +1,22 @@
package com.plotsquared.bukkit.listeners; package com.plotsquared.bukkit.listeners;
import com.google.common.base.Optional;
import com.intellectualcrafters.plot.flag.Flags; import com.intellectualcrafters.plot.flag.Flags;
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.plotsquared.bukkit.object.BukkitPlayer; import com.plotsquared.bukkit.object.BukkitPlayer;
import com.plotsquared.bukkit.util.BukkitUtil; import com.plotsquared.bukkit.util.BukkitUtil;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.util.Vector;
import java.util.HashSet; import java.util.HashSet;
import java.util.Set; import java.util.Set;
import java.util.UUID; import java.util.UUID;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.event.Listener;
import org.bukkit.util.Vector;
public class ForceFieldListener implements Listener { public class ForceFieldListener implements Listener {
private Set<PlotPlayer> getNearbyPlayers(Player player, Plot plot) { private static Set<PlotPlayer> getNearbyPlayers(Player player, Plot plot) {
Set<PlotPlayer> players = new HashSet<>(); Set<PlotPlayer> players = new HashSet<>();
for (Entity entity : player.getNearbyEntities(5d, 5d, 5d)) { for (Entity entity : player.getNearbyEntities(5d, 5d, 5d)) {
PlotPlayer plotPlayer; PlotPlayer plotPlayer;
@ -34,7 +30,7 @@ public class ForceFieldListener implements Listener {
return players; return players;
} }
private PlotPlayer hasNearbyPermitted(Player player, Plot plot) { private static PlotPlayer hasNearbyPermitted(Player player, Plot plot) {
for (Entity entity : player.getNearbyEntities(5d, 5d, 5d)) { for (Entity entity : player.getNearbyEntities(5d, 5d, 5d)) {
if (!(entity instanceof Player)) { if (!(entity instanceof Player)) {
continue; continue;
@ -53,7 +49,7 @@ public class ForceFieldListener implements Listener {
return null; return null;
} }
private Vector calculateVelocity(PlotPlayer player, PlotPlayer e) { private static Vector calculateVelocity(PlotPlayer player, PlotPlayer e) {
Location playerLocation = player.getLocationFull(); Location playerLocation = player.getLocationFull();
Location oPlayerLocation = e.getLocation(); Location oPlayerLocation = e.getLocation();
double playerX = playerLocation.getX(); double playerX = playerLocation.getX();
@ -83,16 +79,8 @@ public class ForceFieldListener implements Listener {
return new Vector(x, y, z); return new Vector(x, y, z);
} }
@EventHandler public static void handleForcefield(Player player, PlotPlayer plotPlayer, Plot plot) {
public void onPlotEntry(PlayerMoveEvent event) { if (Flags.FORCEFIELD.isTrue(plot)) {
Player player = event.getPlayer();
PlotPlayer plotPlayer = BukkitUtil.getPlayer(player);
Plot plot = plotPlayer.getCurrentPlot();
if (plot == null) {
return;
}
Optional<Boolean> forcefield = plot.getFlag(Flags.FORCEFIELD);
if (forcefield.isPresent() && forcefield.get()) {
UUID uuid = plotPlayer.getUUID(); UUID uuid = plotPlayer.getUUID();
if (plot.isAdded(uuid)) { if (plot.isAdded(uuid)) {
Set<PlotPlayer> players = getNearbyPlayers(player, plot); Set<PlotPlayer> players = getNearbyPlayers(player, plot);

View File

@ -498,6 +498,7 @@ public class PlayerEvents extends PlotListener implements Listener {
return; return;
} }
} else if (now.equals(lastPlot)) { } else if (now.equals(lastPlot)) {
ForceFieldListener.handleForcefield(player, pp, now);
return; return;
} else if (!plotEntry(pp, now)) { } else if (!plotEntry(pp, now)) {
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_ENTRY_DENIED); MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_ENTRY_DENIED);
@ -548,6 +549,7 @@ public class PlayerEvents extends PlotListener implements Listener {
return; return;
} }
} else if (now.equals(lastPlot)) { } else if (now.equals(lastPlot)) {
ForceFieldListener.handleForcefield(player, pp, now);
return; return;
} else if (!plotEntry(pp, now)) { } else if (!plotEntry(pp, now)) {
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_ENTRY_DENIED); MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_ENTRY_DENIED);
@ -637,7 +639,7 @@ public class PlayerEvents extends PlotListener implements Listener {
Optional<HashSet<PlotBlock>> destroy = plot.getFlag(Flags.BREAK); Optional<HashSet<PlotBlock>> destroy = plot.getFlag(Flags.BREAK);
Block block = event.getBlock(); Block block = event.getBlock();
if (destroy.isPresent() && destroy.get() if (destroy.isPresent() && destroy.get()
.contains(new PlotBlock((short) block.getTypeId(), block.getData()))) { .contains(PlotBlock.get((short) block.getTypeId(), block.getData()))) {
return; return;
} }
if (Permissions.hasPermission(plotPlayer, C.PERMISSION_ADMIN_DESTROY_OTHER)) { if (Permissions.hasPermission(plotPlayer, C.PERMISSION_ADMIN_DESTROY_OTHER)) {
@ -834,7 +836,7 @@ public class PlayerEvents extends PlotListener implements Listener {
if (!plot.isAdded(plotPlayer.getUUID())) { if (!plot.isAdded(plotPlayer.getUUID())) {
Optional<HashSet<PlotBlock>> destroy = plot.getFlag(Flags.BREAK); Optional<HashSet<PlotBlock>> destroy = plot.getFlag(Flags.BREAK);
Block block = event.getBlock(); Block block = event.getBlock();
if (destroy.isPresent() && destroy.get().contains(new PlotBlock((short) block.getTypeId(), block.getData())) || Permissions if (destroy.isPresent() && destroy.get().contains(PlotBlock.get((short) block.getTypeId(), block.getData())) || Permissions
.hasPermission(plotPlayer, C.PERMISSION_ADMIN_DESTROY_OTHER)) { .hasPermission(plotPlayer, C.PERMISSION_ADMIN_DESTROY_OTHER)) {
return; return;
} }
@ -1189,7 +1191,7 @@ public class PlayerEvents extends PlotListener implements Listener {
break; break;
} }
Material handType = hand.getType(); Material handType = hand.getType();
lb = new BukkitLazyBlock(new PlotBlock((short) handType.getId(), (byte) 0)); lb = new BukkitLazyBlock(PlotBlock.get((short) handType.getId(), (byte) 0));
switch (handType) { switch (handType) {
case MONSTER_EGG: case MONSTER_EGG:
case MONSTER_EGGS: case MONSTER_EGGS:
@ -1787,8 +1789,7 @@ public class PlayerEvents extends PlotListener implements Listener {
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_BUILD_UNOWNED); MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_BUILD_UNOWNED);
event.setCancelled(true); event.setCancelled(true);
} else if (!plot.isAdded(pp.getUUID())) { } else if (!plot.isAdded(pp.getUUID())) {
Optional<HashSet<PlotBlock>> use = plot.getFlag(Flags.USE); if (Flags.USE.contains(plot, PlotBlock.get(event.getBucket().getId(), 0))) {
if (use.isPresent() && use.get().contains(new PlotBlock((short) event.getBucket().getId(), (byte) 0))) {
return; return;
} }
if (Permissions.hasPermission(pp, C.PERMISSION_ADMIN_BUILD_OTHER)) { if (Permissions.hasPermission(pp, C.PERMISSION_ADMIN_BUILD_OTHER)) {
@ -1858,7 +1859,7 @@ public class PlayerEvents extends PlotListener implements Listener {
} else if (!plot.isAdded(plotPlayer.getUUID())) { } else if (!plot.isAdded(plotPlayer.getUUID())) {
Optional<HashSet<PlotBlock>> use = plot.getFlag(Flags.USE); Optional<HashSet<PlotBlock>> use = plot.getFlag(Flags.USE);
Block block = event.getBlockClicked(); Block block = event.getBlockClicked();
if (use.isPresent() && use.get().contains(new PlotBlock((short) block.getTypeId(), block.getData()))) { if (use.isPresent() && use.get().contains(PlotBlock.get(block.getTypeId(), block.getData()))) {
return; return;
} }
if (Permissions.hasPermission(plotPlayer, C.PERMISSION_ADMIN_BUILD_OTHER)) { if (Permissions.hasPermission(plotPlayer, C.PERMISSION_ADMIN_BUILD_OTHER)) {
@ -2292,7 +2293,7 @@ public class PlayerEvents extends PlotListener implements Listener {
Set<PlotBlock> place = plot.getFlag(Flags.PLACE, null); Set<PlotBlock> place = plot.getFlag(Flags.PLACE, null);
if (place != null) { if (place != null) {
Block block = event.getBlock(); Block block = event.getBlock();
if (place.contains(new PlotBlock((short) block.getTypeId(), block.getData()))) { if (place.contains(PlotBlock.get((short) block.getTypeId(), block.getData()))) {
return; return;
} }
} }

View File

@ -88,7 +88,7 @@ public class PlotPlusListener extends PlotListener implements Listener {
if (plot == null) { if (plot == null) {
return; return;
} }
if (plot.getFlag(Flags.INSTABREAK).or(false)) { if (Flags.INSTABREAK.isTrue(plot)) {
event.getBlock().breakNaturally(); event.getBlock().breakNaturally();
} }
} }
@ -103,7 +103,7 @@ public class PlotPlusListener extends PlotListener implements Listener {
if (plot == null) { if (plot == null) {
return; return;
} }
if (plot.getFlag(Flags.INVINCIBLE).or(false)) { if (Flags.INVINCIBLE.isTrue(plot)) {
event.setCancelled(true); event.setCancelled(true);
} }
} }
@ -117,7 +117,7 @@ public class PlotPlusListener extends PlotListener implements Listener {
return; return;
} }
UUID uuid = pp.getUUID(); UUID uuid = pp.getUUID();
if (plot.isAdded(uuid) && plot.getFlag(Flags.DROP_PROTECTION).or(false)) { if (plot.isAdded(uuid) && Flags.DROP_PROTECTION.isTrue(plot)) {
event.setCancelled(true); event.setCancelled(true);
} }
} }

View File

@ -122,7 +122,7 @@ public class BukkitLazyBlock extends LazyBlock {
data = this.block.getData(); data = this.block.getData();
break; break;
} }
this.pb = new PlotBlock((short) this.id, data); this.pb = PlotBlock.get((short) this.id, data);
return this.pb; return this.pb;
} }

View File

@ -1066,7 +1066,7 @@ public class BukkitChunkManager extends ChunkManager {
if (typeId == 0) { if (typeId == 0) {
ids[y] = PlotBlock.EVERYTHING; ids[y] = PlotBlock.EVERYTHING;
} else { } else {
ids[y] = new PlotBlock((short) typeId, block.getData()); ids[y] = PlotBlock.get((short) typeId, block.getData());
} }
} }
if (!id.equals(Material.AIR)) { if (!id.equals(Material.AIR)) {

View File

@ -270,7 +270,7 @@ public class BukkitUtil extends WorldUtil {
public StringComparison<PlotBlock>.ComparisonResult getClosestBlock(String name) { public StringComparison<PlotBlock>.ComparisonResult getClosestBlock(String name) {
try { try {
Material material = Material.valueOf(name.toUpperCase()); Material material = Material.valueOf(name.toUpperCase());
return new StringComparison<PlotBlock>().new ComparisonResult(0, new PlotBlock((short) material.getId(), (byte) 0)); return new StringComparison<PlotBlock>().new ComparisonResult(0, PlotBlock.get((short) material.getId(), (byte) 0));
} catch (IllegalArgumentException ignored) {} } catch (IllegalArgumentException ignored) {}
try { try {
byte data; byte data;
@ -291,7 +291,7 @@ public class BukkitUtil extends WorldUtil {
match = comparison.match; match = comparison.match;
id = (short) comparison.best.getId(); id = (short) comparison.best.getId();
} }
PlotBlock block = new PlotBlock(id, data); PlotBlock block = PlotBlock.get(id, data);
StringComparison<PlotBlock> outer = new StringComparison<>(); StringComparison<PlotBlock> outer = new StringComparison<>();
return outer.new ComparisonResult(match, block); return outer.new ComparisonResult(match, block);
@ -317,7 +317,7 @@ public class BukkitUtil extends WorldUtil {
if (block == null) { if (block == null) {
return PlotBlock.EVERYTHING; return PlotBlock.EVERYTHING;
} }
return new PlotBlock((short) block.getTypeId(), block.getData()); return PlotBlock.get((short) block.getTypeId(), block.getData());
} }
@Override @Override

View File

@ -35,7 +35,7 @@ public class SlowChunk extends PlotChunk<Chunk> {
if (this.result[y >> 4] == null) { if (this.result[y >> 4] == null) {
this.result[y >> 4] = new PlotBlock[4096]; this.result[y >> 4] = new PlotBlock[4096];
} }
this.result[MainUtil.CACHE_I[y][x][z]][MainUtil.CACHE_J[y][x][z]] = new PlotBlock((short) id, data); this.result[MainUtil.CACHE_I[y][x][z]][MainUtil.CACHE_J[y][x][z]] = PlotBlock.get((short) id, data);
} }
@Override @Override

View File

@ -62,7 +62,7 @@ public class FlagCmd extends SubCommand {
Flag<?> flag = null; Flag<?> flag = null;
if (args.length > 1) { if (args.length > 1) {
flag = FlagManager.getFlag(args[1]); flag = FlagManager.getFlag(args[1]);
if (flag == null || FlagManager.isReserved(flag)) { if (flag == null || flag.isReserved()) {
MainUtil.sendMessage(player, C.NOT_VALID_FLAG); MainUtil.sendMessage(player, C.NOT_VALID_FLAG);
return false; return false;
} }

View File

@ -49,7 +49,7 @@ public class Music extends SubCommand {
}; };
int index = 0; int index = 0;
for (int i = 2256; i < 2268; i++) { for (int i = 2256; i < 2268; i++) {
String name = "&r&6" + WorldUtil.IMP.getClosestMatchingName(new PlotBlock((short) i, (byte) 0)); String name = "&r&6" + WorldUtil.IMP.getClosestMatchingName(PlotBlock.get((short) i, (byte) 0));
String[] lore = {"&r&aClick to play!"}; String[] lore = {"&r&aClick to play!"};
PlotItemStack item = new PlotItemStack(i, (byte) 0, 1, name, lore); PlotItemStack item = new PlotItemStack(i, (byte) 0, 1, name, lore);
inv.setItem(index, item); inv.setItem(index, item);

View File

@ -5,6 +5,7 @@ import com.intellectualcrafters.plot.object.Plot;
public abstract class Flag<V> { public abstract class Flag<V> {
private final String name; private final String name;
private boolean reserved = false;
/** /**
* Flag object used to store basic information for a Plot. Flags are a * Flag object used to store basic information for a Plot. Flags are a
@ -17,6 +18,20 @@ public abstract class Flag<V> {
this.name = name; this.name = name;
} }
public Flag reserve() {
reserved = true;
return this;
}
public boolean isReserved() {
return reserved;
}
public Flag unreserve() {
reserved = false;
return this;
}
public abstract String valueToString(Object value); public abstract String valueToString(Object value);
@Override @Override

View File

@ -1,7 +1,6 @@
package com.intellectualcrafters.plot.flag; package com.intellectualcrafters.plot.flag;
import com.google.common.base.Optional; import com.google.common.base.Optional;
import com.google.common.collect.Sets;
import com.intellectualcrafters.plot.PS; import com.intellectualcrafters.plot.PS;
import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.database.DBFunc;
import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.Plot;
@ -11,7 +10,6 @@ import com.intellectualcrafters.plot.object.PlotPlayer;
import com.intellectualcrafters.plot.object.PlotSettings; import com.intellectualcrafters.plot.object.PlotSettings;
import com.intellectualcrafters.plot.util.EventUtil; import com.intellectualcrafters.plot.util.EventUtil;
import com.intellectualcrafters.plot.util.Permissions; import com.intellectualcrafters.plot.util.Permissions;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
@ -28,8 +26,6 @@ import java.util.Set;
public class FlagManager { public class FlagManager {
private static final HashSet<Flag<?>> reserved = Sets.newHashSet(Flags.ANALYSIS, Flags.DONE);
/** /**
* Some events can be called millions of times each second (e.g. physics) and reusing is a lot faster. * Some events can be called millions of times each second (e.g. physics) and reusing is a lot faster.
*/ */
@ -67,7 +63,11 @@ public class FlagManager {
* @return false if the flag was already reserved, otherwise true * @return false if the flag was already reserved, otherwise true
*/ */
public static boolean reserveFlag(Flag<?> flag) { public static boolean reserveFlag(Flag<?> flag) {
return reserved.add(flag); if (flag.isReserved()) {
return false;
}
flag.reserve();
return true;
} }
/** /**
@ -76,7 +76,7 @@ public class FlagManager {
* @return true if the flag is reserved, false otherwise * @return true if the flag is reserved, false otherwise
*/ */
public static boolean isReserved(Flag<?> flag) { public static boolean isReserved(Flag<?> flag) {
return reserved.contains(flag); return flag.isReserved();
} }
/** /**
@ -84,7 +84,13 @@ public class FlagManager {
* @return a set of reserved flags * @return a set of reserved flags
*/ */
public static Set<Flag<?>> getReservedFlags() { public static Set<Flag<?>> getReservedFlags() {
return Collections.unmodifiableSet(reserved); HashSet<Flag<?>> reserved = new HashSet<>();
for (Flag flag : Flags.getFlags()) {
if (flag.isReserved()) {
reserved.add(flag);
}
}
return reserved;
} }
/** /**
@ -93,7 +99,11 @@ public class FlagManager {
* @return true if the flag was unreserved * @return true if the flag was unreserved
*/ */
public static boolean unreserveFlag(Flag<?> flag) { public static boolean unreserveFlag(Flag<?> flag) {
return reserved.remove(flag); if (flag.isReserved()) {
flag.unreserve();
return true;
}
return false;
} }
public static String toString(HashMap<Flag<?>, Object> flags) { public static String toString(HashMap<Flag<?>, Object> flags) {
@ -175,22 +185,24 @@ public class FlagManager {
} }
public static HashMap<Flag<?>, Object> getPlotFlags(PlotArea area, PlotSettings settings, boolean ignorePluginflags) { public static HashMap<Flag<?>, Object> getPlotFlags(PlotArea area, PlotSettings settings, boolean ignorePluginflags) {
HashMap<Flag<?>, Object> flags = new HashMap<>(); HashMap<Flag<?>, Object> flags = null;
if (area != null && !area.DEFAULT_FLAGS.isEmpty()) { if (area != null && !area.DEFAULT_FLAGS.isEmpty()) {
flags = new HashMap<>(area.DEFAULT_FLAGS.size());
flags.putAll(area.DEFAULT_FLAGS); flags.putAll(area.DEFAULT_FLAGS);
} }
if (ignorePluginflags) { if (ignorePluginflags) {
if (flags == null) {
flags = new HashMap<>(settings.flags.size());
}
for (Map.Entry<Flag<?>, Object> flag : settings.flags.entrySet()) { for (Map.Entry<Flag<?>, Object> flag : settings.flags.entrySet()) {
if (isReserved(flag.getKey())) { if (flag.getKey().isReserved()) {
continue; continue;
} }
flags.put(flag.getKey(), flag.getValue()); flags.put(flag.getKey(), flag.getValue());
} }
} else { return flags;
flags.putAll(settings.flags);
} }
return settings.flags;
return flags;
} }
public static Map<Flag<?>, Object> getSettingFlags(PlotArea area, PlotSettings settings) { public static Map<Flag<?>, Object> getSettingFlags(PlotArea area, PlotSettings settings) {
@ -288,29 +300,15 @@ public class FlagManager {
* @return the {@code Flag} object defined by {@code string} * @return the {@code Flag} object defined by {@code string}
*/ */
public static Flag<?> getFlag(String string) { public static Flag<?> getFlag(String string) {
for (Flag flag : Flags.getFlags()) { return Flags.getFlag(string);
if (flag.getName().equalsIgnoreCase(string)) {
if (isReserved(flag)) {
return null;
}
return flag;
}
}
return null;
} }
public static Flag<?> getFlag(String string, boolean ignoreReserved) { public static Flag<?> getFlag(String string, boolean ignoreReserved) {
for (Flag flag : Flags.getFlags()) { Flag<?> flag = Flags.getFlag(string);
if (flag.getName().equalsIgnoreCase(string)) { if (!ignoreReserved && flag != null && flag.isReserved()) {
if (!ignoreReserved) { return null;
if (isReserved(flag)) {
return null;
}
}
return flag;
}
} }
return null; return flag;
} }

View File

@ -1,17 +1,14 @@
package com.intellectualcrafters.plot.flag; package com.intellectualcrafters.plot.flag;
import com.google.common.collect.Sets;
import com.intellectualcrafters.plot.PS; import com.intellectualcrafters.plot.PS;
import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.object.PlotArea; import com.intellectualcrafters.plot.object.PlotArea;
import com.intellectualcrafters.plot.object.RunnableVal; import com.intellectualcrafters.plot.object.RunnableVal;
import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.MainUtil;
import com.intellectualcrafters.plot.util.MathMan; import com.intellectualcrafters.plot.util.MathMan;
import java.lang.reflect.Field;
import java.util.Collections; import java.util.Collection;
import java.util.HashSet; import java.util.HashMap;
import java.util.Iterator;
import java.util.Set;
public class Flags { public class Flags {
@ -115,46 +112,51 @@ public class Flags {
}; };
public static final BooleanFlag SLEEP = new BooleanFlag("sleep"); public static final BooleanFlag SLEEP = new BooleanFlag("sleep");
private static final HashSet<Flag<?>> flags = Sets.newHashSet(MUSIC, DESCRIPTION, ANALYSIS, GREETING, FAREWELL, FEED, HEAL, private static final HashMap<String, Flag<?>> flags;
GAMEMODE, static {
DONE, flags = new HashMap<>();
REDSTONE, try {
FLY, NOTIFY_LEAVE, NOTIFY_ENTER, TIME, WEATHER, KEEP, PRICE, EXPLOSION, GRASS_GROW, VINE_GROW, MYCEL_GROW, DISABLE_PHYSICS, SNOW_MELT, for (Field field : Flags.class.getDeclaredFields()) {
ICE_MELT, if (!field.isAccessible()) {
FIRE_SPREAD, BLOCK_BURN, BLOCK_IGNITION, SOIL_DRY, BLOCKED_CMDS, USE, BREAK, PLACE, DEVICE_INTERACT, VEHICLE_BREAK, VEHICLE_PLACE, field.setAccessible(true);
VEHICLE_USE, }
HANGING_BREAK, HANGING_PLACE, HANGING_INTERACT, MISC_PLACE, MISC_BREAK, MISC_INTERACT, PLAYER_INTERACT, TAMED_ATTACK, TAMED_INTERACT, String fieldName = field.getName().replace("_","-").toLowerCase();
ANIMAL_ATTACK, ANIMAL_INTERACT, HOSTILE_ATTACK, HOSTILE_INTERACT, MOB_PLACE, FORCEFIELD, INVINCIBLE, ITEM_DROP, INSTABREAK, Object fieldValue = field.get(null);
DROP_PROTECTION, PVP, if (!(fieldValue instanceof Flag)) {
PVE, NO_WORLDEDIT, MISC_CAP, ENTITY_CAP, MOB_CAP, ANIMAL_CAP, HOSTILE_CAP, VEHICLE_CAP); continue;
}
Flag flag = (Flag) fieldValue;
if (!flag.getName().equals(fieldName)) {
PS.debug(Flags.class + "Field doesn't match: " + fieldName + " != " + flag.getName());
}
flags.put(flag.getName(), flag);
}
} catch (IllegalAccessException e) {
e.printStackTrace();
}
}
/** /**
* Get an immutable set of registered flags. * Get an immutable set of registered flags.
* *
* @return a set of registered flags. * @return a set of registered flags.
*/ */
public static Set<Flag<?>> getFlags() { public static Collection<Flag<?>> getFlags() {
return Collections.unmodifiableSet(flags); return flags.values();
}
public static Flag<?> getFlag(String flag) {
return flags.get(flag);
} }
public static void registerFlag(final Flag<?> flag) { public static void registerFlag(final Flag<?> flag) {
Iterator<Flag<?>> iterator = flags.iterator(); final Flag<?> duplicate = flags.put(flag.getName(), flag);
Flag<?> duplicate = null;
while (iterator.hasNext()){
duplicate = iterator.next();
if (flag.getName().equalsIgnoreCase(duplicate.getName())) {
iterator.remove();
flags.add(flag);
break;
}
}
final Flag<?> dupFinal = duplicate;
PS.get().foreachPlotArea(new RunnableVal<PlotArea>() { PS.get().foreachPlotArea(new RunnableVal<PlotArea>() {
@Override public void run(PlotArea value) { @Override public void run(PlotArea value) {
if (dupFinal != null) { if (duplicate != null) {
Object remove; Object remove;
if (value.DEFAULT_FLAGS.containsKey(dupFinal)) { if (value.DEFAULT_FLAGS.containsKey(duplicate)) {
remove = value.DEFAULT_FLAGS.remove(dupFinal); remove = value.DEFAULT_FLAGS.remove(duplicate);
if (!(remove instanceof String)) { if (!(remove instanceof String)) {
//error message? maybe? //error message? maybe?
return; return;
@ -166,10 +168,10 @@ public class Flags {
}); });
PS.get().foreachPlotRaw(new RunnableVal<Plot>() { PS.get().foreachPlotRaw(new RunnableVal<Plot>() {
@Override public void run(Plot value) { @Override public void run(Plot value) {
if (dupFinal != null) { if (duplicate != null) {
Object remove = null; Object remove = null;
if (value.getFlags().containsKey(dupFinal)) { if (value.getFlags().containsKey(duplicate)) {
remove = value.getFlags().remove(dupFinal); remove = value.getFlags().remove(duplicate);
} }
if (!(remove instanceof String)) { if (!(remove instanceof String)) {
//error message? maybe? //error message? maybe?

View File

@ -1,5 +1,7 @@
package com.intellectualcrafters.plot.flag; package com.intellectualcrafters.plot.flag;
import com.intellectualcrafters.plot.object.Plot;
public class IntegerFlag extends Flag<Integer> { public class IntegerFlag extends Flag<Integer> {
public IntegerFlag(String name) { public IntegerFlag(String name) {
@ -21,4 +23,19 @@ public class IntegerFlag extends Flag<Integer> {
return null; return null;
} }
} }
public boolean isEqual(Plot plot, int value) {
Integer existing = FlagManager.getPlotFlagRaw(plot, this);
return existing != null && existing == value;
}
public boolean isMore(Plot plot, int value) {
Integer existing = FlagManager.getPlotFlagRaw(plot, this);
return existing != null && existing > value;
}
public boolean isLess(Plot plot, int value) {
Integer existing = FlagManager.getPlotFlagRaw(plot, this);
return existing != null && existing < value;
}
} }

View File

@ -34,7 +34,7 @@ public class PlotBlockListFlag extends ListFlag<HashSet<PlotBlock>> {
data = -1; data = -1;
} }
short id = Short.parseShort(split[0]); short id = Short.parseShort(split[0]);
block = new PlotBlock(id, data); block = PlotBlock.get(id, data);
} catch (NumberFormatException ignored) { } catch (NumberFormatException ignored) {
StringComparison<PlotBlock>.ComparisonResult str = WorldUtil.IMP.getClosestBlock(value); StringComparison<PlotBlock>.ComparisonResult str = WorldUtil.IMP.getClosestBlock(value);
if (str == null || str.match > 1) { if (str == null || str.match > 1) {

View File

@ -106,7 +106,7 @@ public class AugmentedUtils {
primaryMask = result; primaryMask = result;
} }
PlotChunk<?> secondaryMask; PlotChunk<?> secondaryMask;
PlotBlock air = new PlotBlock((short) 0, (byte) 0); PlotBlock air = PlotBlock.get((short) 0, (byte) 0);
if (area.TERRAIN == 2) { if (area.TERRAIN == 2) {
PlotManager manager = area.getPlotManager(); PlotManager manager = area.getPlotManager();
final boolean[][] canPlace = new boolean[16][16]; final boolean[][] canPlace = new boolean[16][16];

View File

@ -272,9 +272,9 @@ public class ClassicPlotManager extends SquarePlotManager {
int ez = pos2.getZ() + 2; int ez = pos2.getZ() + 2;
MainUtil.setSimpleCuboidAsync(plotArea.worldname, MainUtil.setSimpleCuboidAsync(plotArea.worldname,
new Location(plotArea.worldname, sx, Math.min(dpw.WALL_HEIGHT, dpw.ROAD_HEIGHT) + 1, sz + 1), new Location(plotArea.worldname, sx, Math.min(dpw.WALL_HEIGHT, dpw.ROAD_HEIGHT) + 1, sz + 1),
new Location(plotArea.worldname, ex, 255, ez - 1), new PlotBlock((short) 0, (byte) 0)); new Location(plotArea.worldname, ex, 255, ez - 1), PlotBlock.get((short) 0, (byte) 0));
MainUtil.setSimpleCuboidAsync(plotArea.worldname, new Location(plotArea.worldname, sx, 0, sz + 1), MainUtil.setSimpleCuboidAsync(plotArea.worldname, new Location(plotArea.worldname, sx, 0, sz + 1),
new Location(plotArea.worldname, ex, 0, ez - 1), new PlotBlock((short) 7, new Location(plotArea.worldname, ex, 0, ez - 1), PlotBlock.get((short) 7,
(byte) 0)); (byte) 0));
MainUtil.setSimpleCuboidAsync(plotArea.worldname, new Location(plotArea.worldname, sx, 1, sz + 1), MainUtil.setSimpleCuboidAsync(plotArea.worldname, new Location(plotArea.worldname, sx, 1, sz + 1),
new Location(plotArea.worldname, sx, dpw.WALL_HEIGHT, ez - 1), dpw.WALL_FILLING); new Location(plotArea.worldname, sx, dpw.WALL_HEIGHT, ez - 1), dpw.WALL_FILLING);
@ -302,9 +302,9 @@ public class ClassicPlotManager extends SquarePlotManager {
int ex = pos2.getX() + 2; int ex = pos2.getX() + 2;
MainUtil.setSimpleCuboidAsync(plotArea.worldname, MainUtil.setSimpleCuboidAsync(plotArea.worldname,
new Location(plotArea.worldname, sx + 1, Math.min(dpw.WALL_HEIGHT, dpw.ROAD_HEIGHT) + 1, sz), new Location(plotArea.worldname, sx + 1, Math.min(dpw.WALL_HEIGHT, dpw.ROAD_HEIGHT) + 1, sz),
new Location(plotArea.worldname, ex - 1, 255, ez), new PlotBlock((short) 0, (byte) 0)); new Location(plotArea.worldname, ex - 1, 255, ez), PlotBlock.get((short) 0, (byte) 0));
MainUtil.setSimpleCuboidAsync(plotArea.worldname, new Location(plotArea.worldname, sx + 1, 0, sz), MainUtil.setSimpleCuboidAsync(plotArea.worldname, new Location(plotArea.worldname, sx + 1, 0, sz),
new Location(plotArea.worldname, ex - 1, 0, ez), new PlotBlock((short) 7, (byte) 0)); new Location(plotArea.worldname, ex - 1, 0, ez), PlotBlock.get((short) 7, (byte) 0));
MainUtil.setSimpleCuboidAsync(plotArea.worldname, new Location(plotArea.worldname, sx + 1, 1, sz), MainUtil.setSimpleCuboidAsync(plotArea.worldname, new Location(plotArea.worldname, sx + 1, 1, sz),
new Location(plotArea.worldname, ex - 1, dpw.WALL_HEIGHT, sz), dpw.WALL_FILLING); new Location(plotArea.worldname, ex - 1, dpw.WALL_HEIGHT, sz), dpw.WALL_FILLING);
MainUtil.setSimpleCuboidAsync(plotArea.worldname, new Location(plotArea.worldname, sx + 1, dpw.WALL_HEIGHT + 1, sz), MainUtil.setSimpleCuboidAsync(plotArea.worldname, new Location(plotArea.worldname, sx + 1, dpw.WALL_HEIGHT + 1, sz),
@ -329,10 +329,10 @@ public class ClassicPlotManager extends SquarePlotManager {
int sz = pos2.getZ() + 1; int sz = pos2.getZ() + 1;
int ez = sz + dpw.ROAD_WIDTH - 1; int ez = sz + dpw.ROAD_WIDTH - 1;
MainUtil.setSimpleCuboidAsync(plotArea.worldname, new Location(plotArea.worldname, sx + 1, dpw.ROAD_HEIGHT + 1, sz + 1), MainUtil.setSimpleCuboidAsync(plotArea.worldname, new Location(plotArea.worldname, sx + 1, dpw.ROAD_HEIGHT + 1, sz + 1),
new Location(plotArea.worldname, ex - 1, 255, ez - 1), new PlotBlock( new Location(plotArea.worldname, ex - 1, 255, ez - 1), PlotBlock.get(
(short) 0, (byte) 0)); (short) 0, (byte) 0));
MainUtil.setSimpleCuboidAsync(plotArea.worldname, new Location(plotArea.worldname, sx + 1, 0, sz + 1), MainUtil.setSimpleCuboidAsync(plotArea.worldname, new Location(plotArea.worldname, sx + 1, 0, sz + 1),
new Location(plotArea.worldname, ex - 1, 0, ez - 1), new PlotBlock((short) 7, (byte) 0)); new Location(plotArea.worldname, ex - 1, 0, ez - 1), PlotBlock.get((short) 7, (byte) 0));
MainUtil.setSimpleCuboidAsync(plotArea.worldname, new Location(plotArea.worldname, sx + 1, 1, sz + 1), MainUtil.setSimpleCuboidAsync(plotArea.worldname, new Location(plotArea.worldname, sx + 1, 1, sz + 1),
new Location(plotArea.worldname, ex - 1, dpw.ROAD_HEIGHT, ez - 1), dpw.ROAD_BLOCK); new Location(plotArea.worldname, ex - 1, dpw.ROAD_HEIGHT, ez - 1), dpw.ROAD_BLOCK);
return true; return true;
@ -348,7 +348,7 @@ public class ClassicPlotManager extends SquarePlotManager {
int sz = pos1.getZ() - 1; int sz = pos1.getZ() - 1;
int ez = pos2.getZ() + 1; int ez = pos2.getZ() + 1;
MainUtil.setSimpleCuboidAsync(plotArea.worldname, new Location(plotArea.worldname, sx, Math.min(dpw.PLOT_HEIGHT, dpw.ROAD_HEIGHT) + 1, sz), MainUtil.setSimpleCuboidAsync(plotArea.worldname, new Location(plotArea.worldname, sx, Math.min(dpw.PLOT_HEIGHT, dpw.ROAD_HEIGHT) + 1, sz),
new Location(plotArea.worldname, ex, 255, ez), new PlotBlock((short) 0, (byte) 0)); new Location(plotArea.worldname, ex, 255, ez), PlotBlock.get((short) 0, (byte) 0));
MainUtil.setCuboidAsync(plotArea.worldname, new Location(plotArea.worldname, sx, 1, sz + 1), MainUtil.setCuboidAsync(plotArea.worldname, new Location(plotArea.worldname, sx, 1, sz + 1),
new Location(plotArea.worldname, ex, dpw.PLOT_HEIGHT - 1, ez - 1), dpw.MAIN_BLOCK); new Location(plotArea.worldname, ex, dpw.PLOT_HEIGHT - 1, ez - 1), dpw.MAIN_BLOCK);
MainUtil.setCuboidAsync(plotArea.worldname, new Location(plotArea.worldname, sx, dpw.PLOT_HEIGHT, sz + 1), MainUtil.setCuboidAsync(plotArea.worldname, new Location(plotArea.worldname, sx, dpw.PLOT_HEIGHT, sz + 1),
@ -366,7 +366,7 @@ public class ClassicPlotManager extends SquarePlotManager {
int sx = pos1.getX() - 1; int sx = pos1.getX() - 1;
int ex = pos2.getX() + 1; int ex = pos2.getX() + 1;
MainUtil.setSimpleCuboidAsync(plotArea.worldname, new Location(plotArea.worldname, sx, Math.min(dpw.PLOT_HEIGHT, dpw.ROAD_HEIGHT) + 1, sz), MainUtil.setSimpleCuboidAsync(plotArea.worldname, new Location(plotArea.worldname, sx, Math.min(dpw.PLOT_HEIGHT, dpw.ROAD_HEIGHT) + 1, sz),
new Location(plotArea.worldname, ex, 255, ez), new PlotBlock((short) 0, (byte) 0)); new Location(plotArea.worldname, ex, 255, ez), PlotBlock.get((short) 0, (byte) 0));
MainUtil.setCuboidAsync(plotArea.worldname, new Location(plotArea.worldname, sx + 1, 1, sz), MainUtil.setCuboidAsync(plotArea.worldname, new Location(plotArea.worldname, sx + 1, 1, sz),
new Location(plotArea.worldname, ex - 1, dpw.PLOT_HEIGHT - 1, ez), dpw.MAIN_BLOCK); new Location(plotArea.worldname, ex - 1, dpw.PLOT_HEIGHT - 1, ez), dpw.MAIN_BLOCK);
MainUtil.setCuboidAsync(plotArea.worldname, new Location(plotArea.worldname, sx + 1, dpw.PLOT_HEIGHT, sz), MainUtil.setCuboidAsync(plotArea.worldname, new Location(plotArea.worldname, sx + 1, dpw.PLOT_HEIGHT, sz),
@ -383,7 +383,7 @@ public class ClassicPlotManager extends SquarePlotManager {
int sz = location.getZ() + 1; int sz = location.getZ() + 1;
int ez = sz + dpw.ROAD_WIDTH - 1; int ez = sz + dpw.ROAD_WIDTH - 1;
MainUtil.setSimpleCuboidAsync(plotArea.worldname, new Location(plotArea.worldname, sx, dpw.ROAD_HEIGHT + 1, sz), MainUtil.setSimpleCuboidAsync(plotArea.worldname, new Location(plotArea.worldname, sx, dpw.ROAD_HEIGHT + 1, sz),
new Location(plotArea.worldname, ex, 255, ez), new PlotBlock((short) 0, (byte) 0)); new Location(plotArea.worldname, ex, 255, ez), PlotBlock.get((short) 0, (byte) 0));
MainUtil.setCuboidAsync(plotArea.worldname, new Location(plotArea.worldname, sx, 1, sz), MainUtil.setCuboidAsync(plotArea.worldname, new Location(plotArea.worldname, sx, 1, sz),
new Location(plotArea.worldname, ex, dpw.ROAD_HEIGHT - 1, ez), dpw.MAIN_BLOCK); new Location(plotArea.worldname, ex, dpw.ROAD_HEIGHT - 1, ez), dpw.MAIN_BLOCK);
MainUtil.setCuboidAsync(plotArea.worldname, new Location(plotArea.worldname, sx, dpw.ROAD_HEIGHT, sz), MainUtil.setCuboidAsync(plotArea.worldname, new Location(plotArea.worldname, sx, dpw.ROAD_HEIGHT, sz),

View File

@ -12,12 +12,12 @@ public abstract class ClassicPlotWorld extends SquarePlotWorld {
public int ROAD_HEIGHT = 64; public int ROAD_HEIGHT = 64;
public int PLOT_HEIGHT = 64; public int PLOT_HEIGHT = 64;
public int WALL_HEIGHT = 64; public int WALL_HEIGHT = 64;
public PlotBlock[] MAIN_BLOCK = new PlotBlock[] { new PlotBlock((short) 1, (byte) 0) }; public PlotBlock[] MAIN_BLOCK = new PlotBlock[] { PlotBlock.get((short) 1, (byte) 0) };
public PlotBlock[] TOP_BLOCK = new PlotBlock[] { new PlotBlock((short) 2, (byte) 0) }; public PlotBlock[] TOP_BLOCK = new PlotBlock[] { PlotBlock.get((short) 2, (byte) 0) };
public PlotBlock WALL_BLOCK = new PlotBlock((short) 44, (byte) 0); public PlotBlock WALL_BLOCK = PlotBlock.get((short) 44, (byte) 0);
public PlotBlock CLAIMED_WALL_BLOCK = new PlotBlock((short) 44, (byte) 1); public PlotBlock CLAIMED_WALL_BLOCK = PlotBlock.get((short) 44, (byte) 1);
public PlotBlock WALL_FILLING = new PlotBlock((short) 1, (byte) 0); public PlotBlock WALL_FILLING = PlotBlock.get((short) 1, (byte) 0);
public PlotBlock ROAD_BLOCK = new PlotBlock((short) 155, (byte) 0); public PlotBlock ROAD_BLOCK = PlotBlock.get((short) 155, (byte) 0);
public boolean PLOT_BEDROCK = true; public boolean PLOT_BEDROCK = true;
public ClassicPlotWorld(String worldName, String id, IndependentPlotGenerator generator, PlotId min, PlotId max) { public ClassicPlotWorld(String worldName, String id, IndependentPlotGenerator generator, PlotId min, PlotId max) {

View File

@ -151,11 +151,11 @@ public class HybridPlotManager extends ClassicPlotManager {
final PlotBlock[] filling = dpw.MAIN_BLOCK; final PlotBlock[] filling = dpw.MAIN_BLOCK;
final PlotBlock bedrock; final PlotBlock bedrock;
if (dpw.PLOT_BEDROCK) { if (dpw.PLOT_BEDROCK) {
bedrock = new PlotBlock((short) 7, (byte) 0); bedrock = PlotBlock.get((short) 7, (byte) 0);
} else { } else {
bedrock = new PlotBlock((short) 0, (byte) 0); bedrock = PlotBlock.get((short) 0, (byte) 0);
} }
final PlotBlock air = new PlotBlock((short) 0, (byte) 0); final PlotBlock air = PlotBlock.get((short) 0, (byte) 0);
final String biome = WorldUtil.IMP.getBiomeList()[dpw.PLOT_BIOME]; final String biome = WorldUtil.IMP.getBiomeList()[dpw.PLOT_BIOME];
ChunkManager.chunkTask(pos1, pos2, new RunnableVal<int[]>() { ChunkManager.chunkTask(pos1, pos2, new RunnableVal<int[]>() {
@Override @Override

View File

@ -237,7 +237,7 @@ public class HybridPlotWorld extends ClassicPlotWorld {
} }
this.ROAD_SCHEMATIC_ENABLED = true; this.ROAD_SCHEMATIC_ENABLED = true;
// 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 = PlotBlock.get(this.ROAD_BLOCK.id, (byte) 0);
short[] ids1 = schematic1.getIds(); short[] ids1 = schematic1.getIds();
byte[] datas1 = schematic1.getDatas(); byte[] datas1 = schematic1.getDatas();
@ -300,6 +300,6 @@ public class HybridPlotWorld extends ClassicPlotWorld {
existing = new HashMap<>(); existing = new HashMap<>();
this.G_SCH.put(pair, existing); this.G_SCH.put(pair, existing);
} }
existing.put((int) y, new PlotBlock(id, data)); existing.put((int) y, PlotBlock.get(id, data));
} }
} }

View File

@ -163,7 +163,7 @@ public abstract class HybridUtils {
whenDone.value += checkModified(plot.getArea().worldname, bx, ex, cpw.PLOT_HEIGHT, cpw.PLOT_HEIGHT, bz, ez, cpw.TOP_BLOCK); whenDone.value += checkModified(plot.getArea().worldname, bx, ex, cpw.PLOT_HEIGHT, cpw.PLOT_HEIGHT, bz, ez, cpw.TOP_BLOCK);
whenDone.value += checkModified( whenDone.value += checkModified(
plot.getArea().worldname, bx, ex, cpw.PLOT_HEIGHT + 1, 255, bz, ez, plot.getArea().worldname, bx, ex, cpw.PLOT_HEIGHT + 1, 255, bz, ez,
new PlotBlock[]{new PlotBlock((short) 0, (byte) 0)}); new PlotBlock[]{PlotBlock.get((short) 0, (byte) 0)});
} }
}, this, 5); }, this, 5);

View File

@ -3,6 +3,18 @@ package com.intellectualcrafters.plot.object;
public class PlotBlock { public class PlotBlock {
public static final PlotBlock EVERYTHING = new PlotBlock((short) 0, (byte) 0); public static final PlotBlock EVERYTHING = new PlotBlock((short) 0, (byte) 0);
private static final PlotBlock[] CACHE = new PlotBlock[65535];
static {
for (int i = 0; i < 65535; i++) {
short id = (short) (i >> 4);
byte data = (byte) (i & 15);
CACHE[i] = new PlotBlock(id, data);
}
}
public static PlotBlock get(int id, int data) {
return CACHE[(id << 4) + data];
}
public final short id; public final short id;
public final byte data; public final byte data;

View File

@ -325,7 +325,7 @@ public abstract class SchematicHandler {
SetQueue.IMP.setBlock(plot.getArea().worldname, xx, yy, zz, id); SetQueue.IMP.setBlock(plot.getArea().worldname, xx, yy, zz, id);
break; break;
default: default:
SetQueue.IMP.setBlock(plot.getArea().worldname, xx, yy, zz, new PlotBlock((short) id, datas[i])); SetQueue.IMP.setBlock(plot.getArea().worldname, xx, yy, zz, PlotBlock.get((short) id, datas[i]));
break; break;
} }
} }

View File

@ -217,7 +217,7 @@ public class ProcessedWEExtent extends AbstractDelegateExtent {
break; break;
default: default:
if (Settings.EXPERIMENTAL_FAST_ASYNC_WORLDEDIT) { if (Settings.EXPERIMENTAL_FAST_ASYNC_WORLDEDIT) {
SetQueue.IMP.setBlock(this.world, x, y, z, new PlotBlock((short) id, (byte) block.getData())); SetQueue.IMP.setBlock(this.world, x, y, z, PlotBlock.get((short) id, (byte) block.getData()));
} else { } else {
super.setBlock(location, block); super.setBlock(location, block);
} }

View File

@ -38,7 +38,7 @@ public class FlagTest {
Optional<? extends Collection> flag = plot.getFlag(use); Optional<? extends Collection> flag = plot.getFlag(use);
if (flag.isPresent()) { if (flag.isPresent()) {
System.out.println(Flags.USE.valueToString(flag.get())); System.out.println(Flags.USE.valueToString(flag.get()));
testBlock = new PlotBlock((short) 1, (byte) 0); testBlock = PlotBlock.get((short) 1, (byte) 0);
flag.get().add(testBlock); flag.get().add(testBlock);
} }
if (flag.isPresent()) { if (flag.isPresent()) {

View File

@ -153,7 +153,7 @@ public class SpongeUtil extends WorldUtil {
if (state.getType() == BlockTypes.AIR) { if (state.getType() == BlockTypes.AIR) {
continue; continue;
} }
PlotBlock plotBlock = new PlotBlock((short) (i & 0xFFF), (byte) (i >> 12 & 0xF)); PlotBlock plotBlock = PlotBlock.get((short) (i & 0xFFF), (byte) (i >> 12 & 0xF));
stateArray[i] = state; stateArray[i] = state;
stateMap.put(state, plotBlock); stateMap.put(state, plotBlock);
} catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException ignored) { } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException ignored) {
@ -301,7 +301,7 @@ public class SpongeUtil extends WorldUtil {
match = comparison.match; match = comparison.match;
id = SpongeUtil.getPlotBlock(comparison.best.getDefaultState()).id; id = SpongeUtil.getPlotBlock(comparison.best.getDefaultState()).id;
} }
PlotBlock block = new PlotBlock(id, data); PlotBlock block = PlotBlock.get(id, data);
StringComparison<PlotBlock> outer = new StringComparison<PlotBlock>(); StringComparison<PlotBlock> outer = new StringComparison<PlotBlock>();
return outer.new ComparisonResult(match, block); return outer.new ComparisonResult(match, block);

View File

@ -39,7 +39,7 @@ public class SlowChunk extends PlotChunk<Chunk> {
if (id == this.lastBlock.id && data == this.lastBlock.data) { if (id == this.lastBlock.id && data == this.lastBlock.data) {
this.result[MainUtil.CACHE_I[x][y][z]][MainUtil.CACHE_J[x][y][z]] = this.lastBlock; this.result[MainUtil.CACHE_I[x][y][z]][MainUtil.CACHE_J[x][y][z]] = this.lastBlock;
} else { } else {
this.result[MainUtil.CACHE_I[x][y][z]][MainUtil.CACHE_J[x][y][z]] = new PlotBlock((short) id, data); this.result[MainUtil.CACHE_I[x][y][z]][MainUtil.CACHE_J[x][y][z]] = PlotBlock.get((short) id, data);
} }
} }