mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2025-06-27 19:24:43 +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:
@ -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