misc cleanup
This commit is contained in:
@@ -28,10 +28,10 @@ package me.lucko.luckperms.bukkit.compat;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
public final class ReflectionUtil {
|
||||
private static final String SERVER_VERSION = _getServerVersion();
|
||||
private static final String SERVER_VERSION = getServerVersion();
|
||||
private static final boolean CHAT_COMPATIBLE = !SERVER_VERSION.startsWith(".v1_7_");
|
||||
|
||||
private static String _getServerVersion() {
|
||||
private static String getServerVersion() {
|
||||
Class<?> server = Bukkit.getServer().getClass();
|
||||
if (!server.getSimpleName().equals("CraftServer")) {
|
||||
return ".";
|
||||
@@ -45,16 +45,12 @@ public final class ReflectionUtil {
|
||||
}
|
||||
}
|
||||
|
||||
private static String getServerVersion() {
|
||||
return SERVER_VERSION;
|
||||
}
|
||||
|
||||
public static boolean isChatCompatible() {
|
||||
return CHAT_COMPATIBLE;
|
||||
}
|
||||
|
||||
public static String nms(String className) {
|
||||
return "net.minecraft.server" + getServerVersion() + className;
|
||||
return "net.minecraft.server" + SERVER_VERSION + className;
|
||||
}
|
||||
|
||||
public static Class<?> nmsClass(String className) throws ClassNotFoundException {
|
||||
@@ -62,7 +58,7 @@ public final class ReflectionUtil {
|
||||
}
|
||||
|
||||
public static String obc(String className) {
|
||||
return "org.bukkit.craftbukkit" + getServerVersion() + className;
|
||||
return "org.bukkit.craftbukkit" + SERVER_VERSION + className;
|
||||
}
|
||||
|
||||
public static Class<?> obcClass(String className) throws ClassNotFoundException {
|
||||
|
||||
+3
-3
@@ -32,13 +32,13 @@ import org.bukkit.Bukkit;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public final class BukkitMigrationUtils {
|
||||
public final class BukkitUuids {
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public static UUID lookupUuid(ProgressLogger log, String s) {
|
||||
UUID uuid = Uuids.parseNullable(s);
|
||||
if (uuid == null) {
|
||||
try {
|
||||
//noinspection deprecation
|
||||
uuid = Bukkit.getOfflinePlayer(s).getUniqueId();
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
@@ -50,6 +50,6 @@ public final class BukkitMigrationUtils {
|
||||
return uuid;
|
||||
}
|
||||
|
||||
private BukkitMigrationUtils() {}
|
||||
private BukkitUuids() {}
|
||||
|
||||
}
|
||||
@@ -155,7 +155,7 @@ public class MigrationBPermissions extends SubCommand<Object> {
|
||||
AtomicInteger userCount = new AtomicInteger(0);
|
||||
Iterators.iterate(world.getAll(CalculableType.USER), user -> {
|
||||
// There is no mention of UUIDs in the API. I assume that name = uuid. idk?
|
||||
UUID uuid = BukkitMigrationUtils.lookupUuid(log, user.getName());
|
||||
UUID uuid = BukkitUuids.lookupUuid(log, user.getName());
|
||||
if (uuid == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -163,7 +163,7 @@ public class MigrationGroupManager extends SubCommand<Object> {
|
||||
|
||||
AtomicInteger userWorldCount = new AtomicInteger(0);
|
||||
Iterators.iterate(wdh.getUserList(), user -> {
|
||||
UUID uuid = BukkitMigrationUtils.lookupUuid(log, user.getUUID());
|
||||
UUID uuid = BukkitUuids.lookupUuid(log, user.getUUID());
|
||||
if (uuid == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
+1
-1
@@ -100,7 +100,7 @@ public class MigrationPermissionsBukkit extends SubCommand<Object> {
|
||||
ConfigurationSection usersSection = config.getConfigurationSection("users");
|
||||
|
||||
Iterators.iterate(usersSection.getKeys(false), key -> {
|
||||
UUID uuid = BukkitMigrationUtils.lookupUuid(log, key);
|
||||
UUID uuid = BukkitUuids.lookupUuid(log, key);
|
||||
if (uuid == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
+1
-1
@@ -162,7 +162,7 @@ public class MigrationPermissionsEx extends SubCommand<Object> {
|
||||
int userWeight = maxWeight + 5;
|
||||
|
||||
Iterators.iterate(manager.getUsers(), user -> {
|
||||
UUID u = BukkitMigrationUtils.lookupUuid(log, user.getIdentifier());
|
||||
UUID u = BukkitUuids.lookupUuid(log, user.getIdentifier());
|
||||
if (u == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -116,7 +116,7 @@ public class MigrationZPermissions extends SubCommand<Object> {
|
||||
// store user data for later
|
||||
Set<Membership> members = entity.getMemberships();
|
||||
for (Membership membership : members) {
|
||||
UUID uuid = BukkitMigrationUtils.lookupUuid(log, membership.getMember());
|
||||
UUID uuid = BukkitUuids.lookupUuid(log, membership.getMember());
|
||||
if (uuid == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user