mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2025-06-25 02:04:44 +02:00
Minor cleanup in favor of Java 16
- Addressing a few command deprecations during the major release superseded by toggles - Don't swallow SQL warnings in loggers behind debug, as it's often set to false - Deleted JavaVersionCheck, it's part of ServerLib.
This commit is contained in:
@ -68,7 +68,6 @@ import com.plotsquared.bukkit.uuid.SquirrelIdUUIDService;
|
||||
import com.plotsquared.core.PlotPlatform;
|
||||
import com.plotsquared.core.PlotSquared;
|
||||
import com.plotsquared.core.backup.BackupManager;
|
||||
import com.plotsquared.core.command.WE_Anywhere;
|
||||
import com.plotsquared.core.components.ComponentPresetManager;
|
||||
import com.plotsquared.core.configuration.ConfigurationNode;
|
||||
import com.plotsquared.core.configuration.ConfigurationSection;
|
||||
@ -162,7 +161,6 @@ import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.LinkedBlockingQueue;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import static com.plotsquared.bukkit.util.JavaVersionCheck.checkJvm;
|
||||
import static com.plotsquared.core.util.PremiumVerification.getDownloadID;
|
||||
import static com.plotsquared.core.util.PremiumVerification.getResourceID;
|
||||
import static com.plotsquared.core.util.PremiumVerification.getUserID;
|
||||
@ -321,9 +319,6 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl
|
||||
try {
|
||||
logger.info("{} hooked into WorldEdit", this.pluginName());
|
||||
WorldEdit.getInstance().getEventBus().register(this.injector().getInstance(WESubscriber.class));
|
||||
if (Settings.Enabled_Components.COMMANDS) {
|
||||
new WE_Anywhere();
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
logger.error(
|
||||
"Incompatible version of WorldEdit, please upgrade: https://builds.enginehub.org/job/worldedit?branch=master");
|
||||
@ -542,10 +537,9 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl
|
||||
}
|
||||
}, 100L, 100L);
|
||||
|
||||
// Check whether the server runs on 11 or greater
|
||||
checkJvm();
|
||||
// Check if we are in a safe environment
|
||||
ServerLib.checkUnsafeForks();
|
||||
// Check whether the server runs on 16 or greater
|
||||
ServerLib.checkJavaLTS();
|
||||
}
|
||||
|
||||
@ -947,8 +941,7 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl
|
||||
if (Settings.Enabled_Components.KILL_ROAD_MOBS) {
|
||||
Location location = entity.getLocation();
|
||||
if (BukkitUtil.adapt(location).isPlotRoad()) {
|
||||
if (entity instanceof LivingEntity) {
|
||||
LivingEntity livingEntity = (LivingEntity) entity;
|
||||
if (entity instanceof LivingEntity livingEntity) {
|
||||
if ((Settings.Enabled_Components.KILL_OWNED_ROAD_MOBS || !livingEntity.isLeashed())
|
||||
|| !entity.hasMetadata("keep")) {
|
||||
Entity passenger = entity.getPassenger();
|
||||
@ -976,7 +969,6 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl
|
||||
}
|
||||
}
|
||||
}
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -189,8 +189,7 @@ public final class ReplicatingEntityWrapper extends EntityWrapper {
|
||||
AbstractHorse horse = (AbstractHorse) entity;
|
||||
this.horse = new HorseStats();
|
||||
this.horse.jump = horse.getJumpStrength();
|
||||
if (horse instanceof ChestedHorse) {
|
||||
ChestedHorse horse1 = (ChestedHorse) horse;
|
||||
if (horse instanceof ChestedHorse horse1) {
|
||||
this.horse.chest = horse1.isCarryingChest();
|
||||
}
|
||||
//todo these horse features need fixing
|
||||
|
@ -243,22 +243,13 @@ public class BlockEventListener implements Listener {
|
||||
default:
|
||||
if (Settings.Redstone.DETECT_INVALID_EDGE_PISTONS) {
|
||||
switch (block.getType()) {
|
||||
case PISTON:
|
||||
case STICKY_PISTON:
|
||||
case PISTON, STICKY_PISTON -> {
|
||||
org.bukkit.block.data.Directional piston = (org.bukkit.block.data.Directional) block.getBlockData();
|
||||
switch (piston.getFacing()) {
|
||||
case EAST:
|
||||
location = location.add(1, 0, 0);
|
||||
break;
|
||||
case SOUTH:
|
||||
location = location.add(-1, 0, 0);
|
||||
break;
|
||||
case WEST:
|
||||
location = location.add(0, 0, 1);
|
||||
break;
|
||||
case NORTH:
|
||||
location = location.add(0, 0, -1);
|
||||
break;
|
||||
case EAST -> location = location.add(1, 0, 0);
|
||||
case SOUTH -> location = location.add(-1, 0, 0);
|
||||
case WEST -> location = location.add(0, 0, 1);
|
||||
case NORTH -> location = location.add(0, 0, -1);
|
||||
}
|
||||
Plot newPlot = area.getOwnedPlotAbs(location);
|
||||
if (!plot.equals(newPlot)) {
|
||||
@ -266,6 +257,7 @@ public class BlockEventListener implements Listener {
|
||||
plot.debug("Prevented piston update because of invalid edge piston detection");
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -548,8 +540,7 @@ public class BlockEventListener implements Listener {
|
||||
}
|
||||
boolean allowed = plot.getFlag(flag);
|
||||
Entity entity = event.getEntity();
|
||||
if (entity instanceof Player) {
|
||||
Player player = (Player) entity;
|
||||
if (entity instanceof Player player) {
|
||||
BukkitPlayer plotPlayer = BukkitUtil.adapt(player);
|
||||
if (!plot.isAdded(plotPlayer.getUUID())) {
|
||||
if (allowed) {
|
||||
@ -889,37 +880,7 @@ public class BlockEventListener implements Listener {
|
||||
public void onBlockDispense(BlockDispenseEvent event) {
|
||||
Material type = event.getItem().getType();
|
||||
switch (type) {
|
||||
case SHULKER_BOX:
|
||||
case WHITE_SHULKER_BOX:
|
||||
case ORANGE_SHULKER_BOX:
|
||||
case MAGENTA_SHULKER_BOX:
|
||||
case LIGHT_BLUE_SHULKER_BOX:
|
||||
case YELLOW_SHULKER_BOX:
|
||||
case LIME_SHULKER_BOX:
|
||||
case PINK_SHULKER_BOX:
|
||||
case GRAY_SHULKER_BOX:
|
||||
case LIGHT_GRAY_SHULKER_BOX:
|
||||
case CYAN_SHULKER_BOX:
|
||||
case PURPLE_SHULKER_BOX:
|
||||
case BLUE_SHULKER_BOX:
|
||||
case BROWN_SHULKER_BOX:
|
||||
case GREEN_SHULKER_BOX:
|
||||
case RED_SHULKER_BOX:
|
||||
case BLACK_SHULKER_BOX:
|
||||
case CARVED_PUMPKIN:
|
||||
case WITHER_SKELETON_SKULL:
|
||||
case FLINT_AND_STEEL:
|
||||
case BONE_MEAL:
|
||||
case SHEARS:
|
||||
case GLASS_BOTTLE:
|
||||
case GLOWSTONE:
|
||||
case COD_BUCKET:
|
||||
case PUFFERFISH_BUCKET:
|
||||
case SALMON_BUCKET:
|
||||
case TROPICAL_FISH_BUCKET:
|
||||
case BUCKET:
|
||||
case WATER_BUCKET:
|
||||
case LAVA_BUCKET: {
|
||||
case SHULKER_BOX, WHITE_SHULKER_BOX, ORANGE_SHULKER_BOX, MAGENTA_SHULKER_BOX, LIGHT_BLUE_SHULKER_BOX, YELLOW_SHULKER_BOX, LIME_SHULKER_BOX, PINK_SHULKER_BOX, GRAY_SHULKER_BOX, LIGHT_GRAY_SHULKER_BOX, CYAN_SHULKER_BOX, PURPLE_SHULKER_BOX, BLUE_SHULKER_BOX, BROWN_SHULKER_BOX, GREEN_SHULKER_BOX, RED_SHULKER_BOX, BLACK_SHULKER_BOX, CARVED_PUMPKIN, WITHER_SKELETON_SKULL, FLINT_AND_STEEL, BONE_MEAL, SHEARS, GLASS_BOTTLE, GLOWSTONE, COD_BUCKET, PUFFERFISH_BUCKET, SALMON_BUCKET, TROPICAL_FISH_BUCKET, BUCKET, WATER_BUCKET, LAVA_BUCKET -> {
|
||||
if (event.getBlock().getType() == Material.DROPPER) {
|
||||
return;
|
||||
}
|
||||
@ -1100,8 +1061,7 @@ public class BlockEventListener implements Listener {
|
||||
if (ignitingEntity instanceof Fireball) {
|
||||
Projectile fireball = (Projectile) ignitingEntity;
|
||||
Location location = null;
|
||||
if (fireball.getShooter() instanceof Entity) {
|
||||
Entity shooter = (Entity) fireball.getShooter();
|
||||
if (fireball.getShooter() instanceof Entity shooter) {
|
||||
location = BukkitUtil.adapt(shooter.getLocation());
|
||||
} else if (fireball.getShooter() instanceof BlockProjectileSource) {
|
||||
Block shooter =
|
||||
|
@ -259,7 +259,7 @@ public class ChunkListener implements Listener {
|
||||
|
||||
private void cleanChunk(final Chunk chunk) {
|
||||
TaskManager.index.incrementAndGet();
|
||||
final Integer currentIndex = TaskManager.index.get();
|
||||
final int currentIndex = TaskManager.index.get();
|
||||
PlotSquaredTask task = TaskManager.runTaskRepeat(() -> {
|
||||
if (!chunk.isLoaded()) {
|
||||
Objects.requireNonNull(TaskManager.removeTask(currentIndex)).cancel();
|
||||
|
@ -111,8 +111,7 @@ public class EntityEventListener implements Listener {
|
||||
*/
|
||||
if (!BukkitEntityUtil.entityDamage(damager, victim, event.getCause())) {
|
||||
if (event.isCancelled()) {
|
||||
if (victim instanceof Ageable) {
|
||||
Ageable ageable = (Ageable) victim;
|
||||
if (victim instanceof Ageable ageable) {
|
||||
if (ageable.getAge() == -24000) {
|
||||
ageable.setAge(0);
|
||||
ageable.setAdult();
|
||||
|
@ -436,8 +436,7 @@ public class PlayerEventListener extends PlotListener implements Listener {
|
||||
if (!vehicle.getPassengers().isEmpty()) {
|
||||
Entity passenger = vehicle.getPassengers().get(0);
|
||||
|
||||
if (passenger instanceof Player) {
|
||||
final Player player = (Player) passenger;
|
||||
if (passenger instanceof final Player player) {
|
||||
// reset
|
||||
if (moveTmp == null) {
|
||||
moveTmp = new PlayerMoveEvent(null, from, to);
|
||||
@ -778,10 +777,9 @@ public class PlayerEventListener extends PlotListener implements Listener {
|
||||
}
|
||||
|
||||
HumanEntity clicker = event.getWhoClicked();
|
||||
if (!(clicker instanceof Player)) {
|
||||
if (!(clicker instanceof Player player)) {
|
||||
return;
|
||||
}
|
||||
Player player = (Player) clicker;
|
||||
BukkitPlayer pp = BukkitUtil.adapt(player);
|
||||
final PlotInventory inventory = PlotInventory.getOpenPlotInventory(pp);
|
||||
if (inventory != null && event.getRawSlot() == event.getSlot()) {
|
||||
@ -1029,7 +1027,6 @@ public class PlayerEventListener extends PlotListener implements Listener {
|
||||
Block block = event.getClickedBlock();
|
||||
Location location = BukkitUtil.adapt(block.getLocation());
|
||||
Action action = event.getAction();
|
||||
outer:
|
||||
switch (action) {
|
||||
case PHYSICAL: {
|
||||
eventType = PlayerBlockEventType.TRIGGER_PHYSICAL;
|
||||
@ -1077,12 +1074,12 @@ public class PlayerEventListener extends PlotListener implements Listener {
|
||||
if (PaperLib.isPaper()) {
|
||||
if (MaterialTags.SPAWN_EGGS.isTagged(type) || Material.EGG.equals(type)) {
|
||||
eventType = PlayerBlockEventType.SPAWN_MOB;
|
||||
break outer;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
if (type.toString().toLowerCase().endsWith("egg")) {
|
||||
eventType = PlayerBlockEventType.SPAWN_MOB;
|
||||
break outer;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (type.isEdible()) {
|
||||
@ -1090,34 +1087,13 @@ public class PlayerEventListener extends PlotListener implements Listener {
|
||||
return;
|
||||
}
|
||||
switch (type) {
|
||||
case ACACIA_BOAT:
|
||||
case BIRCH_BOAT:
|
||||
case CHEST_MINECART:
|
||||
case COMMAND_BLOCK_MINECART:
|
||||
case DARK_OAK_BOAT:
|
||||
case FURNACE_MINECART:
|
||||
case HOPPER_MINECART:
|
||||
case JUNGLE_BOAT:
|
||||
case MINECART:
|
||||
case OAK_BOAT:
|
||||
case SPRUCE_BOAT:
|
||||
case TNT_MINECART:
|
||||
eventType = PlayerBlockEventType.PLACE_VEHICLE;
|
||||
break outer;
|
||||
case FIREWORK_ROCKET:
|
||||
case FIREWORK_STAR:
|
||||
eventType = PlayerBlockEventType.SPAWN_MOB;
|
||||
break outer;
|
||||
case BOOK:
|
||||
case KNOWLEDGE_BOOK:
|
||||
case WRITABLE_BOOK:
|
||||
case WRITTEN_BOOK:
|
||||
eventType = PlayerBlockEventType.READ;
|
||||
break outer;
|
||||
case ARMOR_STAND:
|
||||
case ACACIA_BOAT, BIRCH_BOAT, CHEST_MINECART, COMMAND_BLOCK_MINECART, DARK_OAK_BOAT, FURNACE_MINECART, HOPPER_MINECART, JUNGLE_BOAT, MINECART, OAK_BOAT, SPRUCE_BOAT, TNT_MINECART -> eventType = PlayerBlockEventType.PLACE_VEHICLE;
|
||||
case FIREWORK_ROCKET, FIREWORK_STAR -> eventType = PlayerBlockEventType.SPAWN_MOB;
|
||||
case BOOK, KNOWLEDGE_BOOK, WRITABLE_BOOK, WRITTEN_BOOK -> eventType = PlayerBlockEventType.READ;
|
||||
case ARMOR_STAND -> {
|
||||
location = BukkitUtil.adapt(block.getRelative(event.getBlockFace()).getLocation());
|
||||
eventType = PlayerBlockEventType.PLACE_MISC;
|
||||
break outer;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -1231,10 +1207,9 @@ public class PlayerEventListener extends PlotListener implements Listener {
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void onInventoryClose(InventoryCloseEvent event) {
|
||||
HumanEntity closer = event.getPlayer();
|
||||
if (!(closer instanceof Player)) {
|
||||
if (!(closer instanceof Player player)) {
|
||||
return;
|
||||
}
|
||||
Player player = (Player) closer;
|
||||
PlotInventory.removePlotInventoryOpen(BukkitUtil.adapt(player));
|
||||
}
|
||||
|
||||
@ -1359,8 +1334,7 @@ public class PlayerEventListener extends PlotListener implements Listener {
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onHangingBreakByEntity(HangingBreakByEntityEvent event) {
|
||||
Entity remover = event.getRemover();
|
||||
if (remover instanceof Player) {
|
||||
Player p = (Player) remover;
|
||||
if (remover instanceof Player p) {
|
||||
Location location = BukkitUtil.adapt(event.getEntity().getLocation());
|
||||
PlotArea area = location.getPlotArea();
|
||||
if (area == null) {
|
||||
@ -1398,10 +1372,8 @@ public class PlayerEventListener extends PlotListener implements Listener {
|
||||
+ " could not break hanging entity because hanging-break = false");
|
||||
}
|
||||
}
|
||||
} else if (remover instanceof Projectile) {
|
||||
Projectile p = (Projectile) remover;
|
||||
if (p.getShooter() instanceof Player) {
|
||||
Player shooter = (Player) p.getShooter();
|
||||
} else if (remover instanceof Projectile p) {
|
||||
if (p.getShooter() instanceof Player shooter) {
|
||||
Location location = BukkitUtil.adapt(event.getEntity().getLocation());
|
||||
PlotArea area = location.getPlotArea();
|
||||
if (area == null) {
|
||||
@ -1535,8 +1507,7 @@ public class PlayerEventListener extends PlotListener implements Listener {
|
||||
return;
|
||||
}
|
||||
Entity attacker = event.getAttacker();
|
||||
if (attacker instanceof Player) {
|
||||
Player p = (Player) attacker;
|
||||
if (attacker instanceof Player p) {
|
||||
BukkitPlayer pp = BukkitUtil.adapt(p);
|
||||
Plot plot = area.getPlot(location);
|
||||
if (plot == null) {
|
||||
@ -1642,8 +1613,7 @@ public class PlayerEventListener extends PlotListener implements Listener {
|
||||
@EventHandler
|
||||
public void onItemPickup(EntityPickupItemEvent event) {
|
||||
LivingEntity ent = event.getEntity();
|
||||
if (ent instanceof Player) {
|
||||
Player player = (Player) ent;
|
||||
if (ent instanceof Player player) {
|
||||
BukkitPlayer pp = BukkitUtil.adapt(player);
|
||||
Location location = pp.getLocation();
|
||||
PlotArea area = location.getPlotArea();
|
||||
|
@ -45,7 +45,7 @@ import static com.plotsquared.core.util.ReflectionUtils.getRefClass;
|
||||
@SuppressWarnings("unused")
|
||||
public class SingleWorldListener implements Listener {
|
||||
|
||||
private Method methodGetHandleChunk;
|
||||
private final Method methodGetHandleChunk;
|
||||
private Field mustSave;
|
||||
private boolean isTrueForNotSave = true;
|
||||
|
||||
|
@ -53,8 +53,7 @@ public class WorldEvents implements Listener {
|
||||
public void onWorldInit(WorldInitEvent event) {
|
||||
World world = event.getWorld();
|
||||
String name = world.getName();
|
||||
if (this.plotAreaManager instanceof SinglePlotAreaManager) {
|
||||
final SinglePlotAreaManager single = (SinglePlotAreaManager) this.plotAreaManager;
|
||||
if (this.plotAreaManager instanceof final SinglePlotAreaManager single) {
|
||||
if (single.isWorld(name)) {
|
||||
world.setKeepSpawnInMemory(false);
|
||||
return;
|
||||
|
@ -34,7 +34,10 @@ import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
/**
|
||||
* Multiverse specific manager that informs Multiverse of
|
||||
* world creation by executing a console command
|
||||
* @deprecated Deprecated and scheduled for removal without replacement
|
||||
* in favor of the build in setup wizard.
|
||||
*/
|
||||
@Deprecated
|
||||
@Singleton
|
||||
public class MultiverseWorldManager extends BukkitWorldManager {
|
||||
|
||||
|
@ -52,8 +52,7 @@ public class BukkitPermissionHandler implements PermissionHandler {
|
||||
public Optional<PermissionProfile> getPermissionProfile(
|
||||
@NonNull PlotPlayer<?> playerPlotPlayer
|
||||
) {
|
||||
if (playerPlotPlayer instanceof BukkitPlayer) {
|
||||
final BukkitPlayer bukkitPlayer = (BukkitPlayer) playerPlotPlayer;
|
||||
if (playerPlotPlayer instanceof final BukkitPlayer bukkitPlayer) {
|
||||
return Optional.of(new BukkitPermissionProfile(bukkitPlayer.getPlatformPlayer()));
|
||||
} else if (playerPlotPlayer instanceof ConsolePlayer) {
|
||||
return Optional.of(ConsolePermissionProfile.INSTANCE);
|
||||
|
@ -65,8 +65,7 @@ public class VaultPermissionHandler implements PermissionHandler {
|
||||
public Optional<PermissionProfile> getPermissionProfile(
|
||||
@NonNull PlotPlayer<?> playerPlotPlayer
|
||||
) {
|
||||
if (playerPlotPlayer instanceof BukkitPlayer) {
|
||||
final BukkitPlayer bukkitPlayer = (BukkitPlayer) playerPlotPlayer;
|
||||
if (playerPlotPlayer instanceof final BukkitPlayer bukkitPlayer) {
|
||||
return Optional.of(new VaultPermissionProfile(bukkitPlayer.getPlatformPlayer()));
|
||||
} else if (playerPlotPlayer instanceof ConsolePlayer) {
|
||||
return Optional.of(ConsolePermissionProfile.INSTANCE);
|
||||
|
@ -263,32 +263,20 @@ public class BukkitPlayer extends PlotPlayer<Player> {
|
||||
@Override
|
||||
public void setWeather(final @NonNull PlotWeather weather) {
|
||||
switch (weather) {
|
||||
case CLEAR:
|
||||
this.player.setPlayerWeather(WeatherType.CLEAR);
|
||||
break;
|
||||
case RAIN:
|
||||
this.player.setPlayerWeather(WeatherType.DOWNFALL);
|
||||
break;
|
||||
case RESET:
|
||||
default:
|
||||
this.player.resetPlayerWeather();
|
||||
break;
|
||||
case CLEAR -> this.player.setPlayerWeather(WeatherType.CLEAR);
|
||||
case RAIN -> this.player.setPlayerWeather(WeatherType.DOWNFALL);
|
||||
default -> this.player.resetPlayerWeather();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public com.sk89q.worldedit.world.gamemode.GameMode getGameMode() {
|
||||
switch (this.player.getGameMode()) {
|
||||
case ADVENTURE:
|
||||
return ADVENTURE;
|
||||
case CREATIVE:
|
||||
return CREATIVE;
|
||||
case SPECTATOR:
|
||||
return SPECTATOR;
|
||||
case SURVIVAL:
|
||||
default:
|
||||
return SURVIVAL;
|
||||
}
|
||||
return switch (this.player.getGameMode()) {
|
||||
case ADVENTURE -> ADVENTURE;
|
||||
case CREATIVE -> CREATIVE;
|
||||
case SPECTATOR -> SPECTATOR;
|
||||
default -> SURVIVAL;
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -372,14 +360,11 @@ public class BukkitPlayer extends PlotPlayer<Player> {
|
||||
}
|
||||
|
||||
public PlayerTeleportEvent.TeleportCause getTeleportCause(final @NonNull TeleportCause cause) {
|
||||
switch (cause) {
|
||||
case COMMAND:
|
||||
return PlayerTeleportEvent.TeleportCause.COMMAND;
|
||||
case PLUGIN:
|
||||
return PlayerTeleportEvent.TeleportCause.PLUGIN;
|
||||
default:
|
||||
return PlayerTeleportEvent.TeleportCause.UNKNOWN;
|
||||
}
|
||||
return switch (cause) {
|
||||
case COMMAND -> PlayerTeleportEvent.TeleportCause.COMMAND;
|
||||
case PLUGIN -> PlayerTeleportEvent.TeleportCause.PLUGIN;
|
||||
default -> PlayerTeleportEvent.TeleportCause.UNKNOWN;
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -177,19 +177,11 @@ public class StateWrapper {
|
||||
}
|
||||
org.bukkit.block.BlockState state = block.getState();
|
||||
switch (getId()) {
|
||||
case "chest":
|
||||
case "beacon":
|
||||
case "brewingstand":
|
||||
case "dispenser":
|
||||
case "dropper":
|
||||
case "furnace":
|
||||
case "hopper":
|
||||
case "shulkerbox":
|
||||
if (!(state instanceof Container)) {
|
||||
case "chest", "beacon", "brewingstand", "dispenser", "dropper", "furnace", "hopper", "shulkerbox" -> {
|
||||
if (!(state instanceof Container container)) {
|
||||
return false;
|
||||
}
|
||||
List<Tag> itemsTag = this.tag.getListTag("Items").getValue();
|
||||
Container container = (Container) state;
|
||||
Inventory inv = container.getSnapshotInventory();
|
||||
for (Tag itemTag : itemsTag) {
|
||||
CompoundTag itemComp = (CompoundTag) itemTag;
|
||||
@ -206,9 +198,9 @@ public class StateWrapper {
|
||||
}
|
||||
container.update(true, false);
|
||||
return true;
|
||||
case "sign":
|
||||
if (state instanceof Sign) {
|
||||
Sign sign = (Sign) state;
|
||||
}
|
||||
case "sign" -> {
|
||||
if (state instanceof Sign sign) {
|
||||
sign.setLine(0, jsonToColourCode(tag.getString("Text1")));
|
||||
sign.setLine(1, jsonToColourCode(tag.getString("Text2")));
|
||||
sign.setLine(2, jsonToColourCode(tag.getString("Text3")));
|
||||
@ -217,6 +209,7 @@ public class StateWrapper {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@ -225,8 +218,7 @@ public class StateWrapper {
|
||||
if (this.tag != null) {
|
||||
return this.tag;
|
||||
}
|
||||
if (this.state instanceof InventoryHolder) {
|
||||
InventoryHolder inv = (InventoryHolder) this.state;
|
||||
if (this.state instanceof InventoryHolder inv) {
|
||||
ItemStack[] contents = inv.getInventory().getContents();
|
||||
Map<String, Tag> values = new HashMap<>();
|
||||
values.put("Items", new ListTag(CompoundTag.class, serializeInventory(contents)));
|
||||
|
@ -144,8 +144,7 @@ public class BukkitEntityUtil {
|
||||
Player player;
|
||||
if (damager instanceof Player) { // attacker is player
|
||||
player = (Player) damager;
|
||||
} else if (damager instanceof Projectile) {
|
||||
Projectile projectile = (Projectile) damager;
|
||||
} else if (damager instanceof Projectile projectile) {
|
||||
ProjectileSource shooter = projectile.getShooter();
|
||||
if (shooter instanceof Player) { // shooter is player
|
||||
player = (Player) shooter;
|
||||
|
@ -135,7 +135,7 @@ public class BukkitSetupUtils extends SetupUtils {
|
||||
PlotAreaType type = builder.plotAreaType();
|
||||
String worldPath = "worlds." + builder.worldName();
|
||||
switch (type) {
|
||||
case PARTIAL: {
|
||||
case PARTIAL -> {
|
||||
if (builder.areaName() != null) {
|
||||
if (!this.worldConfiguration.contains(worldPath)) {
|
||||
this.worldConfiguration.createSection(worldPath);
|
||||
@ -177,9 +177,8 @@ public class BukkitSetupUtils extends SetupUtils {
|
||||
if (gen != null && gen.isFull()) {
|
||||
builder.generatorName(null);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case AUGMENTED: {
|
||||
case AUGMENTED -> {
|
||||
if (!builder.plotManager().endsWith(":single")) {
|
||||
if (!this.worldConfiguration.contains(worldPath)) {
|
||||
this.worldConfiguration.createSection(worldPath);
|
||||
@ -207,9 +206,8 @@ public class BukkitSetupUtils extends SetupUtils {
|
||||
if (gen != null && gen.isFull()) {
|
||||
builder.generatorName(null);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case NORMAL: {
|
||||
case NORMAL -> {
|
||||
if (steps.length != 0) {
|
||||
if (!this.worldConfiguration.contains(worldPath)) {
|
||||
this.worldConfiguration.createSection(worldPath);
|
||||
@ -220,7 +218,6 @@ public class BukkitSetupUtils extends SetupUtils {
|
||||
worldSection.set(step.getConstant(), step.getValue());
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -297,8 +297,7 @@ public class BukkitUtil extends WorldUtil {
|
||||
);
|
||||
try {
|
||||
return TaskManager.getPlatformImplementation().sync(() -> {
|
||||
if (block.getState() instanceof Sign) {
|
||||
Sign sign = (Sign) block.getState();
|
||||
if (block.getState() instanceof Sign sign) {
|
||||
return sign.getLines();
|
||||
}
|
||||
return new String[0];
|
||||
@ -364,8 +363,7 @@ public class BukkitUtil extends WorldUtil {
|
||||
block.setBlockData(sign, false);
|
||||
}
|
||||
final org.bukkit.block.BlockState blockstate = block.getState();
|
||||
if (blockstate instanceof Sign) {
|
||||
final Sign sign = (Sign) blockstate;
|
||||
if (blockstate instanceof final Sign sign) {
|
||||
for (int i = 0; i < lines.length; i++) {
|
||||
sign.setLine(i, LEGACY_COMPONENT_SERIALIZER
|
||||
.serialize(MINI_MESSAGE.parse(lines[i].getComponent(LocaleHolder.console()), replacements)));
|
||||
@ -454,23 +452,20 @@ public class BukkitUtil extends WorldUtil {
|
||||
public @NonNull Set<com.sk89q.worldedit.world.entity.EntityType> getTypesInCategory(final @NonNull String category) {
|
||||
final Collection<Class<?>> allowedInterfaces = new HashSet<>();
|
||||
switch (category) {
|
||||
case "animal": {
|
||||
case "animal" -> {
|
||||
allowedInterfaces.add(IronGolem.class);
|
||||
allowedInterfaces.add(Snowman.class);
|
||||
allowedInterfaces.add(Animals.class);
|
||||
allowedInterfaces.add(WaterMob.class);
|
||||
allowedInterfaces.add(Ambient.class);
|
||||
}
|
||||
break;
|
||||
case "tameable": {
|
||||
case "tameable" -> {
|
||||
allowedInterfaces.add(Tameable.class);
|
||||
}
|
||||
break;
|
||||
case "vehicle": {
|
||||
case "vehicle" -> {
|
||||
allowedInterfaces.add(Vehicle.class);
|
||||
}
|
||||
break;
|
||||
case "hostile": {
|
||||
case "hostile" -> {
|
||||
allowedInterfaces.add(Shulker.class);
|
||||
allowedInterfaces.add(Monster.class);
|
||||
allowedInterfaces.add(Boss.class);
|
||||
@ -479,20 +474,16 @@ public class BukkitUtil extends WorldUtil {
|
||||
allowedInterfaces.add(Phantom.class);
|
||||
allowedInterfaces.add(EnderCrystal.class);
|
||||
}
|
||||
break;
|
||||
case "hanging": {
|
||||
case "hanging" -> {
|
||||
allowedInterfaces.add(Hanging.class);
|
||||
}
|
||||
break;
|
||||
case "villager": {
|
||||
case "villager" -> {
|
||||
allowedInterfaces.add(NPC.class);
|
||||
}
|
||||
break;
|
||||
case "projectile": {
|
||||
case "projectile" -> {
|
||||
allowedInterfaces.add(Projectile.class);
|
||||
}
|
||||
break;
|
||||
case "other": {
|
||||
case "other" -> {
|
||||
allowedInterfaces.add(ArmorStand.class);
|
||||
allowedInterfaces.add(FallingBlock.class);
|
||||
allowedInterfaces.add(Item.class);
|
||||
@ -504,15 +495,12 @@ public class BukkitUtil extends WorldUtil {
|
||||
allowedInterfaces.add(EnderSignal.class);
|
||||
allowedInterfaces.add(Firework.class);
|
||||
}
|
||||
break;
|
||||
case "player": {
|
||||
case "player" -> {
|
||||
allowedInterfaces.add(Player.class);
|
||||
}
|
||||
break;
|
||||
default: {
|
||||
default -> {
|
||||
logger.error("Unknown entity category requested: {}", category);
|
||||
}
|
||||
break;
|
||||
}
|
||||
final Set<com.sk89q.worldedit.world.entity.EntityType> types = new HashSet<>();
|
||||
outer:
|
||||
|
@ -87,10 +87,9 @@ public class BukkitWorld implements World<org.bukkit.World> {
|
||||
if (o == this) {
|
||||
return true;
|
||||
}
|
||||
if (!(o instanceof BukkitWorld)) {
|
||||
if (!(o instanceof final BukkitWorld other)) {
|
||||
return false;
|
||||
}
|
||||
final BukkitWorld other = (BukkitWorld) o;
|
||||
if (!other.canEqual(this)) {
|
||||
return false;
|
||||
}
|
||||
|
@ -1,71 +0,0 @@
|
||||
/*
|
||||
* _____ _ _ _____ _
|
||||
* | __ \| | | | / ____| | |
|
||||
* | |__) | | ___ | |_| (___ __ _ _ _ __ _ _ __ ___ __| |
|
||||
* | ___/| |/ _ \| __|\___ \ / _` | | | |/ _` | '__/ _ \/ _` |
|
||||
* | | | | (_) | |_ ____) | (_| | |_| | (_| | | | __/ (_| |
|
||||
* |_| |_|\___/ \__|_____/ \__, |\__,_|\__,_|_| \___|\__,_|
|
||||
* | |
|
||||
* |_|
|
||||
* PlotSquared plot management system for Minecraft
|
||||
* Copyright (C) 2021 IntellectualSites
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.plotsquared.bukkit.util;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class JavaVersionCheck {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger("P2/" + JavaVersionCheck.class.getSimpleName());
|
||||
|
||||
private static int checkJavaVersion() {
|
||||
String javaVersion = System.getProperty("java.version");
|
||||
final Matcher matcher = Pattern.compile("(?:1\\.)?(\\d+)").matcher(javaVersion);
|
||||
if (!matcher.find()) {
|
||||
logger.error("Failed to determine Java version; Could not parse: {}", javaVersion);
|
||||
return -1;
|
||||
}
|
||||
|
||||
final String version = matcher.group(1);
|
||||
try {
|
||||
return Integer.parseInt(version);
|
||||
} catch (final NumberFormatException e) {
|
||||
logger.error("Failed to determine Java version; Could not parse {} from {}", version, javaVersion, e);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
public static void checkJvm() {
|
||||
if (checkJavaVersion() < 11) {
|
||||
logger.error("************************************************************");
|
||||
logger.error("* WARNING - YOU ARE RUNNING AN OUTDATED VERSION OF JAVA.");
|
||||
logger.error("* PLOTSQUARED WILL STOP BEING COMPATIBLE WITH THIS VERSION OF");
|
||||
logger.error("* JAVA WHEN MINECRAFT 1.17 IS RELEASED.");
|
||||
logger.error("*");
|
||||
logger.error("* Please update the version of Java to 11. When Minecraft 1.17");
|
||||
logger.error("* is released, support for versions of Java prior to 11 will");
|
||||
logger.error("* be dropped.");
|
||||
logger.error("*");
|
||||
logger.error("* Current Java version: {}", System.getProperty("java.version"));
|
||||
logger.error("************************************************************");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user