mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2025-06-25 10:14:42 +02:00
Critical bug fixes, reformatting, and cleaning
Signed-off-by: matt <4009945+MattBDev@users.noreply.github.com>
This commit is contained in:
@ -125,8 +125,9 @@ 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)
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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());
|
||||
}
|
||||
|
@ -126,10 +126,12 @@ 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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();
|
||||
|
@ -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,8 +360,9 @@ 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;
|
||||
}
|
||||
|
||||
|
@ -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]++;
|
||||
|
@ -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();
|
||||
|
@ -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"),
|
||||
|
@ -264,34 +264,28 @@ 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);
|
||||
}
|
||||
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]);
|
||||
@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;
|
||||
}
|
||||
air++;
|
||||
}
|
||||
}
|
||||
sign.update(true);
|
||||
}
|
||||
return bukkitWorld.getMaxHeight() - 1;
|
||||
}
|
||||
|
||||
@Override @Nullable public String[] getSign(@NonNull final Location location) {
|
||||
@ -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;
|
||||
}
|
||||
air++;
|
||||
}
|
||||
@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);
|
||||
}
|
||||
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) {
|
||||
|
Reference in New Issue
Block a user