Critical bug fixes, reformatting, and cleaning

Signed-off-by: matt <4009945+MattBDev@users.noreply.github.com>
This commit is contained in:
matt 2019-02-21 21:14:48 -05:00
parent c5d9412c6c
commit 2f18ef6828
35 changed files with 274 additions and 239 deletions

View File

@ -2,7 +2,7 @@
issueOpened: >
Thank your for raising a issue. We will try and get back to you as soon as possible.
Please make sure that you followed the issue template, and provied all neccessary information.
Please make sure that you followed the issue template, and provided all neccessary information.
Failure to do so will prevent us from resolving the issue in a timely manner.
Please note that suggestions are now to be submitted to https://git.io/fN5B4 rather than this issue tracker!

View File

@ -125,9 +125,10 @@ public class EntitySpawnListener implements Listener {
@EventHandler public void onTeleport(EntityTeleportEvent event) {
Entity ent = event.getEntity();
if (ent instanceof Vehicle || ent instanceof ArmorStand)
if (ent instanceof Vehicle || ent instanceof ArmorStand) {
test(event.getEntity());
}
}
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void vehicleMove(VehicleMoveEvent event) throws IllegalAccessException {

View File

@ -672,8 +672,9 @@ import java.util.regex.Pattern;
if (passenger instanceof Player) {
final Player player = (Player) passenger;
// reset
if (moveTmp == null)
if (moveTmp == null) {
moveTmp = new PlayerMoveEvent(null, from, to);
}
moveTmp.setFrom(from);
moveTmp.setTo(to);
moveTmp.setCancelled(false);
@ -859,8 +860,9 @@ import java.util.regex.Pattern;
}
@EventHandler(priority = EventPriority.LOW) public void onChat(AsyncPlayerChatEvent event) {
if (event.isCancelled())
if (event.isCancelled()) {
return;
}
PlotPlayer plotPlayer = BukkitUtil.getPlayer(event.getPlayer());
Location location = plotPlayer.getLocation();
@ -1077,8 +1079,9 @@ import java.util.regex.Pattern;
PlotArea area = location.getPlotArea();
if (area != null) {
Plot plot = area.getOwnedPlot(location);
if (plot != null && Flags.MOB_BREAK.isTrue(plot))
if (plot != null && Flags.MOB_BREAK.isTrue(plot)) {
return;
}
event.setCancelled(true);
}
}
@ -1446,8 +1449,9 @@ import java.util.regex.Pattern;
switch (type) {
case WATER_BUCKET:
case LAVA_BUCKET: {
if (event.getBlock().getType() == Material.DROPPER)
if (event.getBlock().getType() == Material.DROPPER) {
return;
}
BlockFace targetFace =
((Directional) event.getBlock().getState().getData()).getFacing();
Location location =
@ -1570,8 +1574,9 @@ import java.util.regex.Pattern;
switch (newItem.getType()) {
case LEGACY_BANNER:
case PLAYER_HEAD:
if (newMeta != null)
if (newMeta != null) {
break;
}
default:
return;
}
@ -1587,11 +1592,13 @@ import java.util.regex.Pattern;
switch (stateType) {
case LEGACY_STANDING_BANNER:
case LEGACY_WALL_BANNER:
if (itemType == Material.LEGACY_BANNER)
if (itemType == Material.LEGACY_BANNER) {
break;
}
case LEGACY_SKULL:
if (itemType == Material.LEGACY_SKULL_ITEM)
if (itemType == Material.LEGACY_SKULL_ITEM) {
break;
}
default:
return;
}

View File

@ -42,14 +42,18 @@ import static com.github.intellectualsites.plotsquared.plot.util.ReflectionUtils
public void markChunkAsClean(Chunk chunk) {
try {
Object nmsChunk = methodGetHandleChunk.invoke(chunk);
if (done != null)
if (done != null) {
this.done.set(nmsChunk, true);
if (mustSave != null)
}
if (mustSave != null) {
this.mustSave.set(nmsChunk, false);
if (lit != null)
}
if (lit != null) {
this.lit.set(nmsChunk, false);
if (s != null)
}
if (s != null) {
this.s.set(nmsChunk, false);
}
} catch (Throwable e) {
e.printStackTrace();
}
@ -59,10 +63,12 @@ import static com.github.intellectualsites.plotsquared.plot.util.ReflectionUtils
World world = event.getWorld();
String name = world.getName();
PlotAreaManager man = PlotSquared.get().getPlotAreaManager();
if (!(man instanceof SinglePlotAreaManager))
if (!(man instanceof SinglePlotAreaManager)) {
return;
if (!isPlotId(name))
}
if (!isPlotId(name)) {
return;
}
markChunkAsClean(event.getChunk());
}

View File

@ -126,13 +126,15 @@ public class BukkitPlayer extends PlotPlayer {
String end = perm.substring(stubPlus.length());
if (MathMan.isInteger(end)) {
int val = Integer.parseInt(end);
if (val > range)
if (val > range) {
return val;
if (val > max)
}
if (val > max) {
max = val;
}
}
}
}
} else {
for (int i = range; i > 0; i--) {
if (hasPermission(stub + "." + i)) {

View File

@ -145,7 +145,7 @@ public final class ReplicatingEntityWrapper extends EntityWrapper {
ChestedHorse horse1 = (ChestedHorse) horse;
this.horse.chest = horse1.isCarryingChest();
}
//todo these horse feeatures need fixing
//todo these horse features need fixing
//this.horse.variant = horse.getVariant();
//this.horse.style = horse.getStyle();
//this.horse.color = horse.getColor();

View File

@ -109,8 +109,9 @@ public class TitleManager_1_11 {
}
private static boolean equalsTypeArray(Class<?>[] a, Class<?>[] o) {
if (a.length != o.length)
if (a.length != o.length) {
return false;
}
return IntStream.range(0, a.length)
.noneMatch(i -> !a[i].equals(o[i]) && !a[i].isAssignableFrom(o[i]));
}
@ -202,8 +203,9 @@ public class TitleManager_1_11 {
Integer.TYPE).newInstance(actions[3], null, fadeInTime * (ticks ? 1 : 20),
stayTime * (ticks ? 1 : 20), fadeOutTime * (ticks ? 1 : 20));
// Send if set
if (fadeInTime != -1 && fadeOutTime != -1 && stayTime != -1)
if (fadeInTime != -1 && fadeOutTime != -1 && stayTime != -1) {
sendPacket.invoke(connection, packet);
}
Object serialized;
if (!subtitle.equals("")) {
@ -339,8 +341,9 @@ public class TitleManager_1_11 {
private Class<?>[] toPrimitiveTypeArray(Class<?>[] classes) {
int a = classes != null ? classes.length : 0;
Class<?>[] types = new Class<?>[a];
for (int i = 0; i < a; i++)
for (int i = 0; i < a; i++) {
types[i] = getPrimitiveType(classes[i]);
}
return types;
}
@ -357,9 +360,10 @@ public class TitleManager_1_11 {
Class<?>[] t = toPrimitiveTypeArray(paramTypes);
for (Method m : clazz.getMethods()) {
Class<?>[] types = toPrimitiveTypeArray(m.getParameterTypes());
if (m.getName().equals(name) && equalsTypeArray(types, t))
if (m.getName().equals(name) && equalsTypeArray(types, t)) {
return m;
}
}
return null;
}
@ -403,24 +407,26 @@ public class TitleManager_1_11 {
}
private Method getMethod(Class<?> clazz, String name, Class<?>... args) {
for (Method m : clazz.getMethods())
if (m.getName().equals(name) && (args.length == 0 || ClassListEqual(args,
m.getParameterTypes()))) {
for (Method m : clazz.getMethods()) {
if (m.getName().equals(name) && (args.length == 0 || ClassListEqual(args, m.getParameterTypes()))) {
m.setAccessible(true);
return m;
}
}
return null;
}
private boolean ClassListEqual(Class<?>[] l1, Class<?>[] l2) {
boolean equal = true;
if (l1.length != l2.length)
if (l1.length != l2.length) {
return false;
for (int i = 0; i < l1.length; i++)
}
for (int i = 0; i < l1.length; i++) {
if (l1[i] != l2[i]) {
equal = false;
break;
}
}
return equal;
}

View File

@ -476,6 +476,7 @@ public class BukkitChunkManager extends ChunkManager {
case SNOWBALL:
case ENDER_PEARL:
case ARROW:
case TRIDENT:
case TIPPED_ARROW:
case SHULKER_BULLET:
case SPECTRAL_ARROW:
@ -537,6 +538,13 @@ public class BukkitChunkManager extends ChunkManager {
case SKELETON_HORSE:
case ZOMBIE_HORSE:
case MULE:
case DOLPHIN:
case TURTLE:
case COD:
case PARROT:
case SALMON:
case PUFFERFISH:
case TROPICAL_FISH:
// animal
count[3]++;
count[1]++;

View File

@ -70,8 +70,9 @@ public class BukkitHybridUtils extends HybridUtils {
PlotArea area = PlotSquared.get().getPlotArea(world, null);
if (!(area instanceof HybridPlotWorld))
if (!(area instanceof HybridPlotWorld)) {
return;
}
HybridPlotWorld hpw = (HybridPlotWorld) area;
final BlockBucket[][] result = hpw.getBlockBucketChunk();

View File

@ -74,7 +74,7 @@ public final class BukkitLegacyMappings extends LegacyMappings {
new LegacyBlock(19, 1, "sponge", "wet_sponge"), new LegacyBlock(20, "glass"),
new LegacyBlock(21, "lapis_ore"), new LegacyBlock(22, "lapis_block"),
new LegacyBlock(23, "dispenser"), new LegacyBlock(24, "sandstone"),
new LegacyBlock(24, 1, "sandstone", "chisled_sandstone"),
new LegacyBlock(24, 1, "sandstone", "chiseled_sandstone"),
new LegacyBlock(24, 2, "sandstone", "cut_sandstone"), new LegacyBlock(25, "note_block"),
new LegacyBlock(26, "bed_block"), new LegacyBlock(27, "powered_rail"),
new LegacyBlock(28, "detector_rail"),
@ -181,10 +181,10 @@ public final class BukkitLegacyMappings extends LegacyMappings {
new LegacyBlock(95, 15, "stained_glass", "black_stained_glass"),
new LegacyBlock(96, "trap_door", "oak_trapdoor"),
new LegacyBlock(97, "monster_eggs", "infested_stone"),
new LegacyBlock(97, 1, "monster_eggs", "infested_coblestone"),
new LegacyBlock(97, 1, "monster_eggs", "infested_cobblestone"),
new LegacyBlock(97, 2, "monster_eggs", "infested_stone_bricks"),
new LegacyBlock(97, 3, "monster_eggs", "infested_mossy_stone_bricks"),
new LegacyBlock(97, 4, "monster_eggs", "infested_crcked_stone_bricks"),
new LegacyBlock(97, 4, "monster_eggs", "infested_cracked_stone_bricks"),
new LegacyBlock(97, 5, "monster_eggs", "infested_chiseled_stone_bricks"),
new LegacyBlock(98, "smooth_brick", "stone_bricks"),
new LegacyBlock(98, 1, "smooth_brick", "mossy_stone_bricks"),
@ -207,7 +207,7 @@ public final class BukkitLegacyMappings extends LegacyMappings {
new LegacyBlock(100, 10, "huge_mushroom_2", "mushroom_stem"),
new LegacyBlock(100, 14, "huge_mushroom_2"),
new LegacyBlock(100, 15, "huge_mushroom_2"),
new LegacyBlock(101, "iron_fence", "ironbars"),
new LegacyBlock(101, "iron_fence", "iron_bars"),
new LegacyBlock(102, "thin_glass", "glass_pane"), new LegacyBlock(103, "melon_block"),
new LegacyBlock(104, "pumpkin_stem"), new LegacyBlock(105, "melon_stem"),
new LegacyBlock(106, "vine"), new LegacyBlock(107, "fence_gate", "oak_fence_gate"),
@ -540,7 +540,7 @@ public final class BukkitLegacyMappings extends LegacyMappings {
new LegacyBlock(383, 5, "monster_egg", "wither_skeleton_spawn_egg"),
new LegacyBlock(383, 6, "monster_egg", "stray_spawn_egg"),
new LegacyBlock(383, 23, "monster_egg", "husk_spawn_egg"),
new LegacyBlock(383, 27, "monster_egg", "zombe_villager_spawn_egg"),
new LegacyBlock(383, 27, "monster_egg", "zombie_villager_spawn_egg"),
new LegacyBlock(383, 28, "monster_egg", "skeleton_horse_spawn_egg"),
new LegacyBlock(383, 29, "monster_egg", "zombie_horse_spawn_egg"),
new LegacyBlock(383, 31, "monster_egg", "donkey_spawn_egg"),

View File

@ -264,35 +264,29 @@ import java.util.*;
return getWorld(world).getBiome(x, z).name();
}
@Override @SuppressWarnings("deprecation")
public void setSign(@NonNull final String worldName, final int x, final int y, final int z,
@NonNull final String[] lines) {
final World world = getWorld(worldName);
final Block block = world.getBlockAt(x, y, z);
// block.setType(Material.AIR);
final Material type = block.getType();
if (type != Material.SIGN && type != Material.WALL_SIGN) {
BlockFace facing = BlockFace.EAST;
if (world.getBlockAt(x, y, z + 1).getType().isSolid())
facing = BlockFace.NORTH;
else if (world.getBlockAt(x + 1, y, z).getType().isSolid())
facing = BlockFace.WEST;
else if (world.getBlockAt(x, y, z - 1).getType().isSolid())
facing = BlockFace.SOUTH;
block.setType(Material.WALL_SIGN, false);
final WallSign sign = (WallSign) block.getBlockData();
sign.setFacing(facing);
block.setBlockData(sign, false);
@Override public int getHighestBlock(@NonNull final String world, final int x, final int z) {
final World bukkitWorld = getWorld(world);
// Skip top and bottom block
int air = 1;
for (int y = bukkitWorld.getMaxHeight() - 1; y >= 0; y--) {
Block block = bukkitWorld.getBlockAt(x, y, z);
if (block != null) {
Material type = block.getType();
if (type.isSolid()) {
if (air > 1) {
return y;
}
final BlockState blockstate = block.getState();
if (blockstate instanceof Sign) {
final Sign sign = (Sign) blockstate;
for (int i = 0; i < lines.length; i++) {
sign.setLine(i, lines[i]);
air = 0;
} else {
if (block.isLiquid()) {
return y;
}
sign.update(true);
air++;
}
}
}
return bukkitWorld.getMaxHeight() - 1;
}
@Override @Nullable public String[] getSign(@NonNull final Location location) {
Block block = getWorld(location.getWorld())
@ -330,27 +324,35 @@ import java.util.*;
}
}
@Override public int getHighestBlock(@NonNull final String world, final int x, final int z) {
final World bukkitWorld = getWorld(world);
// Skip top and bottom block
int air = 1;
for (int y = bukkitWorld.getMaxHeight() - 1; y >= 0; y--) {
Block block = bukkitWorld.getBlockAt(x, y, z);
if (block != null) {
Material type = block.getType();
if (type.isSolid()) {
if (air > 1)
return y;
air = 0;
} else {
if (block.isLiquid()) {
return y;
@Override @SuppressWarnings("deprecation")
public void setSign(@NonNull final String worldName, final int x, final int y, final int z,
@NonNull final String[] lines) {
final World world = getWorld(worldName);
final Block block = world.getBlockAt(x, y, z);
// block.setType(Material.AIR);
final Material type = block.getType();
if (type != Material.SIGN && type != Material.WALL_SIGN) {
BlockFace facing = BlockFace.EAST;
if (world.getBlockAt(x, y, z + 1).getType().isSolid()) {
facing = BlockFace.NORTH;
} else if (world.getBlockAt(x + 1, y, z).getType().isSolid()) {
facing = BlockFace.WEST;
} else if (world.getBlockAt(x, y, z - 1).getType().isSolid()) {
facing = BlockFace.SOUTH;
}
air++;
block.setType(Material.WALL_SIGN, false);
final WallSign sign = (WallSign) block.getBlockData();
sign.setFacing(facing);
block.setBlockData(sign, false);
}
final BlockState blockstate = block.getState();
if (blockstate instanceof Sign) {
final Sign sign = (Sign) blockstate;
for (int i = 0; i < lines.length; i++) {
sign.setLine(i, lines[i]);
}
sign.update(true);
}
return bukkitWorld.getMaxHeight() - 1;
}
@Override public int getBiomeFromString(@NonNull final String biomeString) {

View File

@ -49,7 +49,8 @@ import java.util.zip.ZipInputStream;
* An implementation of the core, with a static getter for easy access.
*/
@SuppressWarnings({"unused", "WeakerAccess"}) public class PlotSquared {
private static final Set<Plot> EMPTY_SET = Collections.unmodifiableSet(Collections.emptySet());
private static final Set<Plot> EMPTY_SET = Collections.
unmodifiableSet(Collections.emptySet());
private static PlotSquared instance;
// Implementation
public final IPlotMain IMP;

View File

@ -15,11 +15,8 @@ import java.util.ArrayList;
import java.util.Objects;
import java.util.Set;
@CommandDeclaration(command = "area", permission = "plots.area",
category = CommandCategory.ADMINISTRATION, requiredType = RequiredType.NONE,
description = "Create a new PlotArea", aliases = "world",
usage = "/plot area <create|info|list|tp|regen>", confirmation = true) public class Area
extends SubCommand {
@CommandDeclaration(command = "area", permission = "plots.area", category = CommandCategory.ADMINISTRATION, requiredType = RequiredType.NONE, description = "Create a new PlotArea", aliases = "world", usage = "/plot area <create|info|list|tp|regen>", confirmation = true)
public class Area extends SubCommand {
@Override public boolean onCommand(final PlotPlayer player, String[] args) {
if (args.length == 0) {
@ -104,8 +101,7 @@ import java.util.Set;
final String path =
"worlds." + area.worldname + ".areas." + area.id + '-'
+ object.min + '-' + object.max;
Runnable run = new Runnable() {
@Override public void run() {
Runnable run = () -> {
if (offsetX != 0) {
PlotSquared.get().worlds
.set(path + ".road.offset.x", offsetX);
@ -134,7 +130,6 @@ import java.util.Set;
"An error occurred while creating the world: "
+ area.worldname);
}
}
};
if (hasConfirmation(player)) {
CmdConfirm.addPending(player,
@ -228,8 +223,7 @@ import java.util.Set;
C.SETUP_WORLD_TAKEN.send(player, pa.worldname);
return false;
}
Runnable run = new Runnable() {
@Override public void run() {
Runnable run = () -> {
String path = "worlds." + pa.worldname;
if (!PlotSquared.get().worlds.contains(path)) {
PlotSquared.get().worlds.createSection(path);
@ -254,7 +248,6 @@ import java.util.Set;
} catch (IOException e) {
e.printStackTrace();
}
}
};
if (hasConfirmation(player)) {
CmdConfirm.addPending(player,
@ -422,11 +415,7 @@ import java.util.Set;
@Override public void run(ChunkLoc value) {
AugmentedUtils.generate(area.worldname, value.x, value.z, null);
}
}, new Runnable() {
@Override public void run() {
player.sendMessage("Regen complete");
}
});
}, () -> player.sendMessage("Regen complete"));
return true;
}
case "goto":

View File

@ -22,8 +22,9 @@ public class Auto extends SubCommand {
private static boolean checkAllowedPlots(PlotPlayer player, PlotArea plotarea,
@Nullable Integer allowed_plots, int size_x, int size_z) {
if (allowed_plots == null)
if (allowed_plots == null) {
allowed_plots = player.getAllowedPlots();
}
int currentPlots =
Settings.Limit.GLOBAL ? player.getPlotCount() : player.getPlotCount(plotarea.worldname);
int diff = currentPlots - allowed_plots;
@ -189,8 +190,9 @@ public class Auto extends SubCommand {
}
final int allowed_plots = player.getAllowedPlots();
if (player.getMeta(Auto.class.getName(), false) || !checkAllowedPlots(player, plotarea,
allowed_plots, size_x, size_z))
allowed_plots, size_x, size_z)) {
return false;
}
if (schematic != null && !schematic.isEmpty()) {
if (!plotarea.SCHEMATICS.contains(schematic.toLowerCase())) {

View File

@ -70,7 +70,7 @@ import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
RunnableVal3<Command, Runnable, Runnable> confirm,
RunnableVal2<Command, CommandResult> whenDone) {
PlotArea area = player.getApplicablePlotArea();
boolean chat = area == null ? false : area.PLOT_CHAT;
boolean chat = area != null && area.PLOT_CHAT;
if (toggle(player, "disabletitles") != chat) {
MainUtil.sendMessage(player, C.TOGGLE_ENABLED, command.toString());
} else {

View File

@ -64,8 +64,9 @@ import java.util.*;
page = Integer.parseInt(args[1]);
case 1:
UUID user = args[0].length() >= 2 ? UUIDHandler.getUUIDFromString(args[0]) : null;
if (user != null && !PlotSquared.get().hasPlot(user))
if (user != null && !PlotSquared.get().hasPlot(user)) {
user = null;
}
if (page == Integer.MIN_VALUE && user == null && MathMan.isInteger(args[0])) {
page = Integer.parseInt(args[0]);
unsorted = PlotSquared.get().getBasePlots(player);

View File

@ -45,7 +45,7 @@ public interface AbstractDB {
void createTables() throws Exception;
/**
* Deletess a plot.
* Deletes a plot.
*
* @param plot the plot to delete
*/

View File

@ -1001,15 +1001,17 @@ import java.util.concurrent.atomic.AtomicInteger;
+ "plot_settings`(`plot_plot_id`) VALUES(?)");
}
});
if (success != null)
if (success != null) {
addNotifyTask(success);
}
return;
}
}
}
if (failure != null)
if (failure != null) {
failure.run();
}
}
});
}

View File

@ -145,7 +145,7 @@ public class ClassicPlotManager extends SquarePlotManager {
Location top = plot.getExtendedTopAbs();
LocalBlockQueue queue = plotArea.getQueue(false);
int maxY = plotArea.getPlotManager().getWorldHeight();
if (!plot.getMerged(0)) {
if (!plot.getMerged(Direction.NORTH)) {
int z = bottom.getZ();
for (int x = bottom.getX(); x <= top.getX(); x++) {
for (int y = dpw.PLOT_HEIGHT; y <= maxY; y++) {
@ -153,7 +153,7 @@ public class ClassicPlotManager extends SquarePlotManager {
}
}
}
if (!plot.getMerged(3)) {
if (!plot.getMerged(Direction.WEST)) {
int x = bottom.getX();
for (int z = bottom.getZ(); z <= top.getZ(); z++) {
for (int y = dpw.PLOT_HEIGHT; y <= maxY; y++) {
@ -162,7 +162,7 @@ public class ClassicPlotManager extends SquarePlotManager {
}
}
if (!plot.getMerged(2)) {
if (!plot.getMerged(Direction.SOUTH)) {
int z = top.getZ();
for (int x = bottom.getX(); x <= top.getX(); x++) {
for (int y = dpw.PLOT_HEIGHT; y <= maxY; y++) {
@ -170,7 +170,7 @@ public class ClassicPlotManager extends SquarePlotManager {
}
}
}
if (!plot.getMerged(1)) {
if (!plot.getMerged(Direction.EAST)) {
int x = top.getX();
for (int z = bottom.getZ(); z <= top.getZ(); z++) {
for (int y = dpw.PLOT_HEIGHT; y <= maxY; y++) {
@ -196,10 +196,11 @@ public class ClassicPlotManager extends SquarePlotManager {
}
Plot plot = plotArea.getPlotAbs(plotId);
Location bot = plot.getExtendedBottomAbs()
.subtract(plot.getMerged(3) ? 0 : 1, 0, plot.getMerged(0) ? 0 : 1);
.subtract(plot.getMerged(Direction.WEST) ? 0 : 1, 0,
plot.getMerged(Direction.NORTH) ? 0 : 1);
Location top = plot.getExtendedTopAbs().add(1, 0, 1);
LocalBlockQueue queue = plotArea.getQueue(false);
if (!plot.getMerged(0)) {
if (!plot.getMerged(Direction.NORTH)) {
int z = bot.getZ();
for (int x = bot.getX(); x < top.getX(); x++) {
for (int y = 1; y <= dpw.WALL_HEIGHT; y++) {
@ -207,7 +208,7 @@ public class ClassicPlotManager extends SquarePlotManager {
}
}
}
if (!plot.getMerged(3)) {
if (!plot.getMerged(Direction.WEST)) {
int x = bot.getX();
for (int z = bot.getZ(); z < top.getZ(); z++) {
for (int y = 1; y <= dpw.WALL_HEIGHT; y++) {
@ -215,17 +216,19 @@ public class ClassicPlotManager extends SquarePlotManager {
}
}
}
if (!plot.getMerged(2)) {
if (!plot.getMerged(Direction.SOUTH)) {
int z = top.getZ();
for (int x = bot.getX(); x < top.getX() + (plot.getMerged(1) ? 0 : 1); x++) {
for (int x = bot.getX();
x < top.getX() + (plot.getMerged(Direction.EAST) ? 0 : 1); x++) {
for (int y = 1; y <= dpw.WALL_HEIGHT; y++) {
queue.setBlock(x, y, z, blocks.getBlock());
}
}
}
if (!plot.getMerged(1)) {
if (!plot.getMerged(Direction.EAST)) {
int x = top.getX();
for (int z = bot.getZ(); z < top.getZ() + (plot.getMerged(2) ? 0 : 1); z++) {
for (int z = bot.getZ();
z < top.getZ() + (plot.getMerged(Direction.SOUTH) ? 0 : 1); z++) {
for (int y = 1; y <= dpw.WALL_HEIGHT; y++) {
queue.setBlock(x, y, z, blocks.getBlock());
}
@ -242,32 +245,35 @@ public class ClassicPlotManager extends SquarePlotManager {
}
Plot plot = plotArea.getPlotAbs(plotId);
Location bot = plot.getExtendedBottomAbs()
.subtract(plot.getMerged(3) ? 0 : 1, 0, plot.getMerged(0) ? 0 : 1);
.subtract(plot.getMerged(Direction.WEST) ? 0 : 1, 0,
plot.getMerged(Direction.NORTH) ? 0 : 1);
Location top = plot.getExtendedTopAbs().add(1, 0, 1);
PseudoRandom random = new PseudoRandom();
LocalBlockQueue queue = plotArea.getQueue(false);
int y = dpw.WALL_HEIGHT + 1;
if (!plot.getMerged(0)) {
if (!plot.getMerged(Direction.NORTH)) {
int z = bot.getZ();
for (int x = bot.getX(); x < top.getX(); x++) {
queue.setBlock(x, y, z, blocks.getBlock());
}
}
if (!plot.getMerged(3)) {
if (!plot.getMerged(Direction.WEST)) {
int x = bot.getX();
for (int z = bot.getZ(); z < top.getZ(); z++) {
queue.setBlock(x, y, z, blocks.getBlock());
}
}
if (!plot.getMerged(2)) {
if (!plot.getMerged(Direction.SOUTH)) {
int z = top.getZ();
for (int x = bot.getX(); x < top.getX() + (plot.getMerged(1) ? 0 : 1); x++) {
for (int x = bot.getX();
x < top.getX() + (plot.getMerged(Direction.EAST) ? 0 : 1); x++) {
queue.setBlock(x, y, z, blocks.getBlock());
}
}
if (!plot.getMerged(1)) {
if (!plot.getMerged(Direction.EAST)) {
int x = top.getX();
for (int z = bot.getZ(); z < top.getZ() + (plot.getMerged(2) ? 0 : 1); z++) {
for (int z = bot.getZ();
z < top.getZ() + (plot.getMerged(Direction.SOUTH) ? 0 : 1); z++) {
queue.setBlock(x, y, z, blocks.getBlock());
}
}

View File

@ -95,9 +95,7 @@ public class HybridPlotWorld extends ClassicPlotWorld {
return bot.add(-1, 0, -2);
} else {
bot.setY(0);
Location loc =
bot.add(SIGN_LOCATION.getX(), SIGN_LOCATION.getY(), SIGN_LOCATION.getZ());
return loc;
return bot.add(SIGN_LOCATION.getX(), SIGN_LOCATION.getY(), SIGN_LOCATION.getZ());
}
}
@ -277,11 +275,7 @@ public class HybridPlotWorld extends ClassicPlotWorld {
id = rotate(id);
}
int pair = MathMan.pair(x, z);
BaseBlock[] existing = this.G_SCH.get(pair);
if (existing == null) {
existing = new BaseBlock[height];
this.G_SCH.put(pair, existing);
}
BaseBlock[] existing = this.G_SCH.computeIfAbsent(pair, k -> new BaseBlock[height]);
existing[y] = id;
}
}

View File

@ -173,28 +173,28 @@ public abstract class SquarePlotManager extends GridPlotManager {
switch (hash) {
case 8:
// north
return plot.getMerged(0) ? id : null;
return plot.getMerged(Direction.NORTH) ? id : null;
case 4:
// east
return plot.getMerged(1) ? id : null;
return plot.getMerged(Direction.EAST) ? id : null;
case 2:
// south
return plot.getMerged(2) ? id : null;
return plot.getMerged(Direction.SOUTH) ? id : null;
case 1:
// west
return plot.getMerged(3) ? id : null;
return plot.getMerged(Direction.WEST) ? id : null;
case 12:
// northest
return plot.getMerged(4) ? id : null;
// northeast
return plot.getMerged(Direction.NORTHEAST) ? id : null;
case 6:
// southeast
return plot.getMerged(5) ? id : null;
return plot.getMerged(Direction.SOUTHEAST) ? id : null;
case 3:
// southwest
return plot.getMerged(6) ? id : null;
return plot.getMerged(Direction.SOUTHWEST) ? id : null;
case 9:
// northwest
return plot.getMerged(7) ? id : null;
return plot.getMerged(Direction.NORTHWEST) ? id : null;
}
PlotSquared.debug("invalid location: " + Arrays.toString(merged));
} catch (Exception ignored) {

View File

@ -13,7 +13,7 @@ import com.sk89q.worldedit.extent.NullExtent;
import com.sk89q.worldedit.math.BlockVector2;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.util.Location;
import com.sk89q.worldedit.world.biome.BaseBiome;
import com.sk89q.worldedit.world.biome.BiomeType;
import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.block.BlockStateHolder;
@ -46,21 +46,22 @@ public class ProcessedWEExtent extends AbstractDelegateExtent {
this.parent = parent;
}
@Override public BlockState getBlock(BlockVector3 location) {
if (WEManager.maskContains(this.mask, location.getX(), location.getY(), location.getZ())) {
return super.getBlock(location);
@Override public BlockState getBlock(BlockVector3 position) {
if (WEManager.maskContains(this.mask, position.getX(), position.getY(), position.getZ())) {
return super.getBlock(position);
}
return WEExtent.AIRSTATE;
}
@Override public BaseBlock getFullBlock(BlockVector3 location) {
if (WEManager.maskContains(this.mask, location.getX(), location.getY(), location.getZ())) {
return super.getFullBlock(location);
@Override public BaseBlock getFullBlock(BlockVector3 position) {
if (WEManager.maskContains(this.mask, position.getX(), position.getY(), position.getZ())) {
return super.getFullBlock(position);
}
return WEExtent.AIRBASE;
}
@Override public boolean setBlock(BlockVector3 location, BlockStateHolder block)
@Override
public <T extends BlockStateHolder<T>> boolean setBlock(BlockVector3 location, T block)
throws WorldEditException {
String id = block.getBlockType().getId();
switch (id) {
@ -171,7 +172,7 @@ public class ProcessedWEExtent extends AbstractDelegateExtent {
return null;
}
@Override public boolean setBiome(BlockVector2 position, BaseBiome biome) {
@Override public boolean setBiome(BlockVector2 position, BiomeType biome) {
return WEManager.maskContains(this.mask, position.getX(), position.getZ()) && super
.setBiome(position, biome);
}

View File

@ -9,7 +9,7 @@ import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.math.BlockVector2;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.util.Location;
import com.sk89q.worldedit.world.biome.BaseBiome;
import com.sk89q.worldedit.world.biome.BiomeType;
import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.block.BlockStateHolder;
@ -42,22 +42,22 @@ public class WEExtent extends AbstractDelegateExtent {
return null;
}
@Override public boolean setBiome(BlockVector2 position, BaseBiome biome) {
return WEManager.maskContains(this.mask, position.getX(), position.getZ()) && super
.setBiome(position, biome);
}
@Override public BlockState getBlock(BlockVector3 location) {
if (WEManager.maskContains(this.mask, location.getX(), location.getY(), location.getZ())) {
return super.getBlock(location);
@Override public BlockState getBlock(BlockVector3 position) {
if (WEManager.maskContains(this.mask, position.getX(), position.getY(), position.getZ())) {
return super.getBlock(position);
}
return AIRSTATE;
}
@Override public BaseBlock getFullBlock(BlockVector3 location) {
if (WEManager.maskContains(this.mask, location.getX(), location.getY(), location.getZ())) {
return super.getFullBlock(location);
@Override public BaseBlock getFullBlock(BlockVector3 position) {
if (WEManager.maskContains(this.mask, position.getX(), position.getY(), position.getZ())) {
return super.getFullBlock(position);
}
return AIRBASE;
}
@Override public boolean setBiome(BlockVector2 position, BiomeType biome) {
return WEManager.maskContains(this.mask, position.getX(), position.getZ()) && super
.setBiome(position, biome);
}
}

View File

@ -3015,4 +3015,8 @@ public class Plot {
@SuppressWarnings("deprecation") public void setComments(List<PlotComment> list) {
getSettings().setComments(list);
}
public boolean getMerged(Direction direction) {
return getMerged(direction.getIndex());
}
}

View File

@ -713,8 +713,9 @@ public abstract class PlotArea {
if (TYPE == 2) {
center = new PlotId(MathMan.average(min.x, max.x), MathMan.average(min.y, max.y));
plots = Math.max(max.x - min.x, max.y - min.y) + 1;
if (start != null)
if (start != null) {
start = new PlotId(start.x - center.x, start.y - center.y);
}
} else {
center = new PlotId(0, 0);
plots = Integer.MAX_VALUE;

View File

@ -6,7 +6,6 @@ import com.github.intellectualsites.plotsquared.plot.object.comment.PlotComment;
import com.google.common.collect.ImmutableList;
import java.util.*;
import java.util.stream.IntStream;
/**
* Generic settings class.
@ -57,13 +56,6 @@ public class PlotSettings {
return this.merged[direction];
}
/**
* Returns true if the plot is merged (i.e. if it's a mega plot)
*/
public boolean isMerged() {
return IntStream.of(0, 1, 2, 3).anyMatch(i -> this.merged[i]);
}
public boolean[] getMerged() {
return this.merged;
}

View File

@ -30,8 +30,9 @@ public class SinglePlotArea extends GridPlotWorld {
TaskManager.IMP.sync(new RunnableVal<Object>() {
@Override public void run(Object value) {
String worldName = id.toCommaSeparatedString();
if (WorldUtil.IMP.isWorld(worldName))
if (WorldUtil.IMP.isWorld(worldName)) {
return;
}
SetupObject setup = new SetupObject();
setup.plotManager = "PlotSquared:single";
setup.setupGenerator = "PlotSquared:single";

View File

@ -70,32 +70,36 @@ public class SinglePlotAreaManager extends DefaultPlotAreaManager {
@Override public PlotArea getApplicablePlotArea(Location location) {
PlotArea found = super.getApplicablePlotArea(location);
if (found != null)
if (found != null) {
return found;
}
String world = location.getWorld();
return isWorld(world) || world.equals("*") || super.getAllPlotAreas().length == 0 ?
area :
null;
}
@Override public PlotArea getPlotArea(Location location) {
PlotArea found = super.getPlotArea(location);
if (found != null)
return found;
return isWorld(location.getWorld()) || location.getWorld().equals("*") ? area : null;
}
@Override public PlotArea getPlotArea(String world, String id) {
PlotArea found = super.getPlotArea(world, id);
if (found != null)
if (found != null) {
return found;
}
return isWorld(world) || world.equals("*") ? area : null;
}
@Override public PlotArea getPlotArea(Location location) {
PlotArea found = super.getPlotArea(location);
if (found != null) {
return found;
}
return isWorld(location.getWorld()) || location.getWorld().equals("*") ? area : null;
}
@Override public PlotArea[] getPlotAreas(String world, RegionWrapper region) {
PlotArea[] found = super.getPlotAreas(world, region);
if (found != null && found.length != 0)
if (found != null && found.length != 0) {
return found;
}
return isWorld(world) || world.equals("*") ? array : noPlotAreas;
}

View File

@ -33,9 +33,10 @@ public class SinglePlotManager extends PlotManager {
TaskManager.IMP.taskAsync(new Runnable() {
@Override public void run() {
MainUtil.deleteDirectory(worldFolder);
if (whenDone != null)
if (whenDone != null) {
whenDone.run();
}
}
});
return true;
}
@ -46,8 +47,9 @@ public class SinglePlotManager extends PlotManager {
}
@Override public boolean unclaimPlot(PlotArea plotArea, Plot plot, Runnable whenDone) {
if (whenDone != null)
if (whenDone != null) {
whenDone.run();
}
return true;
}

View File

@ -264,11 +264,8 @@ public abstract class ChunkManager {
}
Location top = new Location(world, x2, 0, z2);
plot = top.getOwnedPlotAbs();
if (plot != null) {
return plot;
}
return null;
}
/**
* Copy a region to a new location (in the same world)

View File

@ -17,8 +17,9 @@ public class CmdConfirm {
public static void addPending(final PlotPlayer player, String commandStr,
final Runnable runnable) {
removePending(player);
if (commandStr != null)
if (commandStr != null) {
MainUtil.sendMessage(player, C.REQUIRES_CONFIRM, commandStr);
}
TaskManager.runTaskLater(new Runnable() {
@Override public void run() {
CmdInstance cmd = new CmdInstance(runnable);

View File

@ -181,8 +181,9 @@ public class MathMan {
public static int floorMod(int x, int y) {
int i = x % y;
if (i < 0)
if (i < 0) {
i += y;
}
return i;
}

View File

@ -171,9 +171,10 @@ public abstract class BasicLocalBlockQueue<T> extends LocalBlockQueue {
GlobalBlockQueue.IMP.dequeue(this);
TaskManager.IMP.sync(new RunnableVal<Object>() {
@Override public void run(Object value) {
while (next())
while (next()) {
;
}
}
});
}

View File

@ -329,11 +329,12 @@ public class ExpireManager {
long diff = time - existing;
if (diff > 0) {
Long account_age = this.account_age_cache.get(uuid);
if (account_age != null)
if (account_age != null) {
this.account_age_cache.put(uuid, account_age + diff);
}
}
}
}
public void storeAccountAge(UUID uuid, long time) {
this.account_age_cache.put(uuid, time);

View File

@ -106,8 +106,9 @@ public class ExpiryTask {
}
public boolean appliesAccountAge(long accountAge) {
if (settings.SKIP_ACCOUNT_AGE_DAYS != -1)
if (settings.SKIP_ACCOUNT_AGE_DAYS != -1) {
return accountAge <= TimeUnit.DAYS.toMillis(settings.SKIP_ACCOUNT_AGE_DAYS);
}
return false;
}