diff --git a/patches/minecraft/net/minecraft/world/chunk/NibbleArray.java.patch b/patches/minecraft/net/minecraft/world/chunk/NibbleArray.java.patch new file mode 100644 index 0000000000..af969fa895 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/chunk/NibbleArray.java.patch @@ -0,0 +1,20 @@ +--- a/net/minecraft/world/chunk/NibbleArray.java ++++ b/net/minecraft/world/chunk/NibbleArray.java +@@ -33,7 +_,7 @@ + return p_177483_2_ << 8 | p_177483_3_ << 4 | p_177483_1_; + } + +- private int func_177480_a(int p_177480_1_) { ++ public int func_177480_a(int p_177480_1_) { + if (this.field_76585_a == null) { + return 0; + } else { +@@ -42,7 +_,7 @@ + } + } + +- private void func_177482_a(int p_177482_1_, int p_177482_2_) { ++ public void func_177482_a(int p_177482_1_, int p_177482_2_) { + if (this.field_76585_a == null) { + this.field_76585_a = new byte[2048]; + } diff --git a/src/fmllauncher/java/com/mohistmc/libraries/DefaultLibraries.java b/src/fmllauncher/java/com/mohistmc/libraries/DefaultLibraries.java index d52d3092a0..17efa35588 100644 --- a/src/fmllauncher/java/com/mohistmc/libraries/DefaultLibraries.java +++ b/src/fmllauncher/java/com/mohistmc/libraries/DefaultLibraries.java @@ -60,7 +60,7 @@ public static void run() { lib.getParentFile().mkdirs(); String u = url + "libraries/" + lib.getAbsolutePath().replaceAll("\\\\", "/").split("/libraries/")[1]; - System.out.println(i18n.get("libraries.global.percentage", Math.round((float) (currentSize.get() * 100) / allSize.get()) + "%")); //Global percentage + System.out.println(i18n.get("libraries.global.percentage", Math.min(Math.round((float) (currentSize.get() * 100) / allSize.get()), 100) + "%")); //Global percentage try { UpdateUtils.downloadFile(u, lib, libs.get(lib)); if (lib.getName().endsWith(".jar") && !lib.getName().contains("asm-tree-6.1.1.jar")) diff --git a/src/main/java/com/mohistmc/Metrics.java b/src/main/java/com/mohistmc/Metrics.java index 9c86e24cc2..f09938dc7b 100644 --- a/src/main/java/com/mohistmc/Metrics.java +++ b/src/main/java/com/mohistmc/Metrics.java @@ -20,16 +20,6 @@ import com.mohistmc.api.ServerAPI; import com.mohistmc.common.async.MohistThreadBox; -import net.minecraft.server.MinecraftServer; -import org.bukkit.Bukkit; -import org.bukkit.configuration.file.YamlConfiguration; -import org.bukkit.craftbukkit.v1_16_R3.CraftServer; -import org.bukkit.plugin.Plugin; -import org.json.simple.JSONArray; -import org.json.simple.JSONObject; -import org.spigotmc.SpigotConfig; - -import javax.net.ssl.HttpsURLConnection; import java.io.ByteArrayOutputStream; import java.io.DataOutputStream; import java.io.File; @@ -46,6 +36,15 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; import java.util.zip.GZIPOutputStream; +import javax.net.ssl.HttpsURLConnection; +import net.minecraft.server.MinecraftServer; +import org.bukkit.Bukkit; +import org.bukkit.configuration.file.YamlConfiguration; +import org.bukkit.craftbukkit.v1_16_R3.CraftServer; +import org.bukkit.plugin.Plugin; +import org.json.simple.JSONArray; +import org.json.simple.JSONObject; +import org.spigotmc.SpigotConfig; /** * bStats collects some data for plugin authors. diff --git a/src/main/java/com/mohistmc/MohistConfig.java b/src/main/java/com/mohistmc/MohistConfig.java index 70f8c2db93..7d1142a5fd 100644 --- a/src/main/java/com/mohistmc/MohistConfig.java +++ b/src/main/java/com/mohistmc/MohistConfig.java @@ -12,12 +12,6 @@ import com.mohistmc.command.UpdateMohistCommand; import com.mohistmc.command.WhitelistModsCommand; import com.mohistmc.plugins.WorldCommand; -import net.minecraft.server.MinecraftServer; -import org.bukkit.Bukkit; -import org.bukkit.command.Command; -import org.bukkit.configuration.InvalidConfigurationException; -import org.bukkit.configuration.file.YamlConfiguration; - import java.io.File; import java.io.IOException; import java.lang.reflect.InvocationTargetException; @@ -28,6 +22,11 @@ import java.util.List; import java.util.Map; import java.util.logging.Level; +import net.minecraft.server.MinecraftServer; +import org.bukkit.Bukkit; +import org.bukkit.command.Command; +import org.bukkit.configuration.InvalidConfigurationException; +import org.bukkit.configuration.file.YamlConfiguration; public class MohistConfig { diff --git a/src/main/java/com/mohistmc/MohistProxySelector.java b/src/main/java/com/mohistmc/MohistProxySelector.java index f6d45c12db..8f1baa4b6e 100644 --- a/src/main/java/com/mohistmc/MohistProxySelector.java +++ b/src/main/java/com/mohistmc/MohistProxySelector.java @@ -20,14 +20,13 @@ import com.mohistmc.api.event.MohistNetworkEvent; import com.mohistmc.util.IOUtil; -import org.bukkit.Bukkit; - import java.io.IOException; import java.net.Proxy; import java.net.ProxySelector; import java.net.SocketAddress; import java.net.URI; import java.util.List; +import org.bukkit.Bukkit; public class MohistProxySelector extends ProxySelector { diff --git a/src/main/java/com/mohistmc/api/ItemAPI.java b/src/main/java/com/mohistmc/api/ItemAPI.java index 9a2822f5f2..24c141bd64 100644 --- a/src/main/java/com/mohistmc/api/ItemAPI.java +++ b/src/main/java/com/mohistmc/api/ItemAPI.java @@ -18,17 +18,16 @@ package com.mohistmc.api; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; import net.minecraft.util.ResourceLocation; import org.bukkit.Material; import org.bukkit.craftbukkit.v1_16_R3.inventory.CraftItemStack; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.ItemMeta; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; - public class ItemAPI { public static Map MODNAME_MAP = new ConcurrentHashMap(); diff --git a/src/main/java/com/mohistmc/api/PlayerAPI.java b/src/main/java/com/mohistmc/api/PlayerAPI.java index 30139fcaa7..009a219136 100644 --- a/src/main/java/com/mohistmc/api/PlayerAPI.java +++ b/src/main/java/com/mohistmc/api/PlayerAPI.java @@ -19,16 +19,15 @@ package com.mohistmc.api; import com.mojang.authlib.GameProfile; +import java.net.SocketAddress; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.ServerPlayerEntity; import net.minecraft.server.MinecraftServer; import org.bukkit.craftbukkit.v1_16_R3.entity.CraftPlayer; import org.bukkit.entity.Player; -import java.net.SocketAddress; -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; - public class PlayerAPI { public static Map mods = new ConcurrentHashMap<>(); diff --git a/src/main/java/com/mohistmc/api/ServerAPI.java b/src/main/java/com/mohistmc/api/ServerAPI.java index 841558877f..ad018b514d 100644 --- a/src/main/java/com/mohistmc/api/ServerAPI.java +++ b/src/main/java/com/mohistmc/api/ServerAPI.java @@ -19,6 +19,11 @@ package com.mohistmc.api; import io.netty.util.internal.ConcurrentSet; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.concurrent.ConcurrentHashMap; import net.minecraft.server.MinecraftServer; import net.minecraftforge.fml.ModList; import net.minecraftforge.fml.loading.moddiscovery.ModInfo; @@ -28,12 +33,6 @@ import org.bukkit.event.Listener; import org.bukkit.plugin.Plugin; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.concurrent.ConcurrentHashMap; - public class ServerAPI { public static Map mods = new ConcurrentHashMap(); diff --git a/src/main/java/com/mohistmc/api/event/MohistNetworkEvent.java b/src/main/java/com/mohistmc/api/event/MohistNetworkEvent.java index 12a6a17394..5852af0721 100644 --- a/src/main/java/com/mohistmc/api/event/MohistNetworkEvent.java +++ b/src/main/java/com/mohistmc/api/event/MohistNetworkEvent.java @@ -18,13 +18,12 @@ package com.mohistmc.api.event; +import java.net.URI; import org.bukkit.Bukkit; import org.bukkit.event.Cancellable; import org.bukkit.event.Event; import org.bukkit.event.HandlerList; -import java.net.URI; - public class MohistNetworkEvent extends Event implements Cancellable { private static HandlerList handlers = new HandlerList(); diff --git a/src/main/java/com/mohistmc/api/mc/ChunkMcAPI.java b/src/main/java/com/mohistmc/api/mc/ChunkMcAPI.java index dd87801ceb..d038b34957 100644 --- a/src/main/java/com/mohistmc/api/mc/ChunkMcAPI.java +++ b/src/main/java/com/mohistmc/api/mc/ChunkMcAPI.java @@ -19,6 +19,8 @@ package com.mohistmc.api.mc; import com.mojang.datafixers.util.Either; +import java.util.Optional; +import java.util.concurrent.CompletableFuture; import net.minecraft.util.math.ChunkPos; import net.minecraft.world.chunk.Chunk; import net.minecraft.world.server.ChunkHolder; @@ -26,9 +28,6 @@ import net.minecraft.world.server.ChunkHolder.LocationType; import net.minecraft.world.server.ServerWorld; -import java.util.Optional; -import java.util.concurrent.CompletableFuture; - /** * Mohist API for Minecraft chunks. * @author KR33PY diff --git a/src/main/java/com/mohistmc/bukkit/ServerListPingEvent.java b/src/main/java/com/mohistmc/bukkit/ServerListPingEvent.java index 9a62003bdc..e4fb2e9366 100644 --- a/src/main/java/com/mohistmc/bukkit/ServerListPingEvent.java +++ b/src/main/java/com/mohistmc/bukkit/ServerListPingEvent.java @@ -18,6 +18,9 @@ package com.mohistmc.bukkit; +import java.net.InetSocketAddress; +import java.util.Iterator; +import java.util.NoSuchElementException; import net.minecraft.entity.player.ServerPlayerEntity; import net.minecraft.network.NetworkManager; import net.minecraft.server.MinecraftServer; @@ -26,10 +29,6 @@ import org.bukkit.craftbukkit.v1_16_R3.util.CraftIconCache; import org.bukkit.entity.Player; -import java.net.InetSocketAddress; -import java.util.Iterator; -import java.util.NoSuchElementException; - public class ServerListPingEvent extends org.bukkit.event.server.ServerListPingEvent { public CraftIconCache icon; diff --git a/src/main/java/com/mohistmc/bukkit/nms/model/ClassMapping.java b/src/main/java/com/mohistmc/bukkit/nms/model/ClassMapping.java index 4e02c707f7..08d001d97d 100644 --- a/src/main/java/com/mohistmc/bukkit/nms/model/ClassMapping.java +++ b/src/main/java/com/mohistmc/bukkit/nms/model/ClassMapping.java @@ -20,7 +20,6 @@ import com.google.common.collect.BiMap; import com.google.common.collect.HashBiMap; - import java.util.HashMap; import java.util.Map; diff --git a/src/main/java/com/mohistmc/bukkit/nms/proxy/DelegateClassLoder.java b/src/main/java/com/mohistmc/bukkit/nms/proxy/DelegateClassLoder.java index 674f33a282..9bc23598a2 100644 --- a/src/main/java/com/mohistmc/bukkit/nms/proxy/DelegateClassLoder.java +++ b/src/main/java/com/mohistmc/bukkit/nms/proxy/DelegateClassLoder.java @@ -19,9 +19,8 @@ package com.mohistmc.bukkit.nms.proxy; import com.mohistmc.bukkit.nms.utils.RemapUtils; -import net.md_5.specialsource.repo.RuntimeRepo; - import java.security.ProtectionDomain; +import net.md_5.specialsource.repo.RuntimeRepo; public class DelegateClassLoder extends ClassLoader{ diff --git a/src/main/java/com/mohistmc/bukkit/nms/proxy/DelegateURLClassLoder.java b/src/main/java/com/mohistmc/bukkit/nms/proxy/DelegateURLClassLoder.java index 433b83b798..5b9e25c894 100644 --- a/src/main/java/com/mohistmc/bukkit/nms/proxy/DelegateURLClassLoder.java +++ b/src/main/java/com/mohistmc/bukkit/nms/proxy/DelegateURLClassLoder.java @@ -20,10 +20,6 @@ import com.mohistmc.bukkit.nms.utils.RemapUtils; import com.mohistmc.util.MohistJDK9EnumHelper; -import net.md_5.specialsource.repo.RuntimeRepo; -import org.bukkit.configuration.serialization.ConfigurationSerializable; -import org.bukkit.configuration.serialization.ConfigurationSerialization; - import java.io.InputStream; import java.net.JarURLConnection; import java.net.URL; @@ -38,6 +34,9 @@ import java.util.concurrent.ConcurrentHashMap; import java.util.jar.Attributes; import java.util.jar.Manifest; +import net.md_5.specialsource.repo.RuntimeRepo; +import org.bukkit.configuration.serialization.ConfigurationSerializable; +import org.bukkit.configuration.serialization.ConfigurationSerialization; /** * diff --git a/src/main/java/com/mohistmc/bukkit/nms/proxy/ProxyClass.java b/src/main/java/com/mohistmc/bukkit/nms/proxy/ProxyClass.java index c02a7b5b8d..3af7330195 100644 --- a/src/main/java/com/mohistmc/bukkit/nms/proxy/ProxyClass.java +++ b/src/main/java/com/mohistmc/bukkit/nms/proxy/ProxyClass.java @@ -22,7 +22,6 @@ import com.mohistmc.bukkit.nms.utils.ASMUtils; import com.mohistmc.bukkit.nms.utils.ReflectionUtils; import com.mohistmc.bukkit.nms.utils.RemapUtils; - import java.lang.reflect.Field; import java.lang.reflect.Method; diff --git a/src/main/java/com/mohistmc/bukkit/nms/proxy/ProxyMethodHandlesLookup.java b/src/main/java/com/mohistmc/bukkit/nms/proxy/ProxyMethodHandlesLookup.java index 0ab33e1793..efac83585d 100644 --- a/src/main/java/com/mohistmc/bukkit/nms/proxy/ProxyMethodHandlesLookup.java +++ b/src/main/java/com/mohistmc/bukkit/nms/proxy/ProxyMethodHandlesLookup.java @@ -20,7 +20,6 @@ import com.mohistmc.bukkit.nms.remappers.ReflectMethodRemapper; import com.mohistmc.bukkit.nms.utils.RemapUtils; - import java.lang.invoke.MethodHandle; import java.lang.invoke.MethodHandles; import java.lang.invoke.MethodType; diff --git a/src/main/java/com/mohistmc/bukkit/nms/proxy/ProxyYamlConfiguration.java b/src/main/java/com/mohistmc/bukkit/nms/proxy/ProxyYamlConfiguration.java index 3758fbbe31..3ea6808e58 100644 --- a/src/main/java/com/mohistmc/bukkit/nms/proxy/ProxyYamlConfiguration.java +++ b/src/main/java/com/mohistmc/bukkit/nms/proxy/ProxyYamlConfiguration.java @@ -18,13 +18,12 @@ package com.mohistmc.bukkit.nms.proxy; -import org.bukkit.configuration.file.YamlConfiguration; -import org.yaml.snakeyaml.reader.ReaderException; - import java.io.InputStream; import java.io.InputStreamReader; import java.nio.charset.Charset; import java.nio.charset.StandardCharsets; +import org.bukkit.configuration.file.YamlConfiguration; +import org.yaml.snakeyaml.reader.ReaderException; /** * diff --git a/src/main/java/com/mohistmc/bukkit/nms/remappers/MohistClassRepo.java b/src/main/java/com/mohistmc/bukkit/nms/remappers/MohistClassRepo.java index d6ae655f0f..315b4e0277 100644 --- a/src/main/java/com/mohistmc/bukkit/nms/remappers/MohistClassRepo.java +++ b/src/main/java/com/mohistmc/bukkit/nms/remappers/MohistClassRepo.java @@ -19,13 +19,12 @@ package com.mohistmc.bukkit.nms.remappers; import com.mohistmc.bukkit.nms.ClassLoaderContext; +import java.io.IOException; +import java.io.InputStream; import net.md_5.specialsource.repo.CachingRepo; import org.objectweb.asm.ClassReader; import org.objectweb.asm.tree.ClassNode; -import java.io.IOException; -import java.io.InputStream; - /** * * @author pyz diff --git a/src/main/java/com/mohistmc/bukkit/nms/remappers/MohistInheritanceProvider.java b/src/main/java/com/mohistmc/bukkit/nms/remappers/MohistInheritanceProvider.java index 91684ae959..f0642b8419 100644 --- a/src/main/java/com/mohistmc/bukkit/nms/remappers/MohistInheritanceProvider.java +++ b/src/main/java/com/mohistmc/bukkit/nms/remappers/MohistInheritanceProvider.java @@ -19,12 +19,11 @@ package com.mohistmc.bukkit.nms.remappers; import com.mohistmc.bukkit.nms.utils.RemapUtils; -import net.md_5.specialsource.provider.InheritanceProvider; -import org.objectweb.asm.tree.ClassNode; - import java.util.HashSet; import java.util.Objects; import java.util.Set; +import net.md_5.specialsource.provider.InheritanceProvider; +import org.objectweb.asm.tree.ClassNode; public class MohistInheritanceProvider implements InheritanceProvider { @Override diff --git a/src/main/java/com/mohistmc/bukkit/nms/remappers/MohistJarMapping.java b/src/main/java/com/mohistmc/bukkit/nms/remappers/MohistJarMapping.java index 64da834daa..58dd88dce8 100644 --- a/src/main/java/com/mohistmc/bukkit/nms/remappers/MohistJarMapping.java +++ b/src/main/java/com/mohistmc/bukkit/nms/remappers/MohistJarMapping.java @@ -20,14 +20,6 @@ import com.google.common.collect.BiMap; import com.mohistmc.bukkit.nms.model.ClassMapping; -import net.md_5.specialsource.InheritanceMap; -import net.md_5.specialsource.NodeType; -import net.md_5.specialsource.provider.InheritanceProvider; -import net.md_5.specialsource.transformer.MappingTransformer; -import net.md_5.specialsource.transformer.MavenShade; -import org.objectweb.asm.Type; -import org.objectweb.asm.commons.Remapper; - import java.io.BufferedReader; import java.io.IOException; import java.lang.reflect.Modifier; @@ -38,6 +30,13 @@ import java.util.List; import java.util.Map; import java.util.StringJoiner; +import net.md_5.specialsource.InheritanceMap; +import net.md_5.specialsource.NodeType; +import net.md_5.specialsource.provider.InheritanceProvider; +import net.md_5.specialsource.transformer.MappingTransformer; +import net.md_5.specialsource.transformer.MavenShade; +import org.objectweb.asm.Type; +import org.objectweb.asm.commons.Remapper; /** * diff --git a/src/main/java/com/mohistmc/bukkit/nms/remappers/MohistJarRemapper.java b/src/main/java/com/mohistmc/bukkit/nms/remappers/MohistJarRemapper.java index 559480150e..f9db64e914 100644 --- a/src/main/java/com/mohistmc/bukkit/nms/remappers/MohistJarRemapper.java +++ b/src/main/java/com/mohistmc/bukkit/nms/remappers/MohistJarRemapper.java @@ -19,6 +19,9 @@ package com.mohistmc.bukkit.nms.remappers; import com.mohistmc.bukkit.nms.model.ClassMapping; +import java.io.IOException; +import java.io.InputStream; +import java.util.Map; import net.md_5.specialsource.CustomRemapper; import net.md_5.specialsource.NodeType; import net.md_5.specialsource.RemapperProcessor; @@ -27,13 +30,8 @@ import net.md_5.specialsource.repo.ClassRepo; import org.objectweb.asm.ClassReader; import org.objectweb.asm.ClassWriter; -import org.objectweb.asm.tree.ClassNode; - -import java.io.IOException; -import java.io.InputStream; -import java.util.Map; - import static org.objectweb.asm.ClassWriter.COMPUTE_MAXS; +import org.objectweb.asm.tree.ClassNode; /** * diff --git a/src/main/java/com/mohistmc/bukkit/nms/remappers/MohistSuperClassRemapper.java b/src/main/java/com/mohistmc/bukkit/nms/remappers/MohistSuperClassRemapper.java index e76ee14056..4c54324c3c 100644 --- a/src/main/java/com/mohistmc/bukkit/nms/remappers/MohistSuperClassRemapper.java +++ b/src/main/java/com/mohistmc/bukkit/nms/remappers/MohistSuperClassRemapper.java @@ -22,6 +22,9 @@ import com.mohistmc.bukkit.nms.proxy.DelegateClassLoder; import com.mohistmc.bukkit.nms.proxy.DelegateURLClassLoder; import com.mohistmc.bukkit.nms.utils.ASMUtils; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Map; import org.objectweb.asm.Opcodes; import org.objectweb.asm.Type; import org.objectweb.asm.tree.AbstractInsnNode; @@ -29,10 +32,6 @@ import org.objectweb.asm.tree.MethodInsnNode; import org.objectweb.asm.tree.MethodNode; import org.objectweb.asm.tree.TypeInsnNode; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Map; public class MohistSuperClassRemapper { public static Map> defineClass = Maps.newHashMap(); diff --git a/src/main/java/com/mohistmc/bukkit/nms/remappers/ReflectMethodRemapper.java b/src/main/java/com/mohistmc/bukkit/nms/remappers/ReflectMethodRemapper.java index c577c0b64e..cfc0b7c116 100644 --- a/src/main/java/com/mohistmc/bukkit/nms/remappers/ReflectMethodRemapper.java +++ b/src/main/java/com/mohistmc/bukkit/nms/remappers/ReflectMethodRemapper.java @@ -25,14 +25,6 @@ import com.mohistmc.bukkit.nms.proxy.ProxyYamlConfiguration; import com.mohistmc.bukkit.nms.proxy.asm.ProxyClassWriter; import com.mohistmc.bukkit.nms.utils.ASMUtils; -import net.minecraftforge.server.ServerMain; -import org.bukkit.configuration.file.YamlConfiguration; -import org.objectweb.asm.MethodVisitor; -import org.objectweb.asm.Opcodes; -import org.objectweb.asm.Type; -import org.objectweb.asm.commons.MethodRemapper; -import org.objectweb.asm.commons.Remapper; - import java.io.InputStream; import java.lang.invoke.MethodHandle; import java.lang.invoke.MethodType; @@ -44,6 +36,13 @@ import java.util.HashSet; import java.util.Map; import java.util.Set; +import net.minecraftforge.server.ServerMain; +import org.bukkit.configuration.file.YamlConfiguration; +import org.objectweb.asm.MethodVisitor; +import org.objectweb.asm.Opcodes; +import org.objectweb.asm.Type; +import org.objectweb.asm.commons.MethodRemapper; +import org.objectweb.asm.commons.Remapper; /** * diff --git a/src/main/java/com/mohistmc/bukkit/nms/utils/ASMUtils.java b/src/main/java/com/mohistmc/bukkit/nms/utils/ASMUtils.java index 21c574da87..89e60f5d0c 100644 --- a/src/main/java/com/mohistmc/bukkit/nms/utils/ASMUtils.java +++ b/src/main/java/com/mohistmc/bukkit/nms/utils/ASMUtils.java @@ -18,6 +18,16 @@ package com.mohistmc.bukkit.nms.utils; +import java.io.File; +import java.io.IOException; +import java.lang.reflect.Field; +import java.lang.reflect.Modifier; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.HashMap; +import java.util.Map; +import java.util.StringJoiner; +import java.util.function.BiConsumer; import org.objectweb.asm.ClassReader; import org.objectweb.asm.Handle; import org.objectweb.asm.Opcodes; @@ -30,17 +40,6 @@ import org.objectweb.asm.tree.TypeInsnNode; import org.objectweb.asm.tree.VarInsnNode; -import java.io.File; -import java.io.IOException; -import java.lang.reflect.Field; -import java.lang.reflect.Modifier; -import java.nio.file.Files; -import java.nio.file.Path; -import java.util.HashMap; -import java.util.Map; -import java.util.StringJoiner; -import java.util.function.BiConsumer; - /** * * @author pyz diff --git a/src/main/java/com/mohistmc/bukkit/nms/utils/RemapUtils.java b/src/main/java/com/mohistmc/bukkit/nms/utils/RemapUtils.java index 378bbdab62..c7e81e9354 100644 --- a/src/main/java/com/mohistmc/bukkit/nms/utils/RemapUtils.java +++ b/src/main/java/com/mohistmc/bukkit/nms/utils/RemapUtils.java @@ -28,6 +28,14 @@ import com.mohistmc.bukkit.nms.remappers.MohistSuperClassRemapper; import com.mohistmc.bukkit.nms.remappers.ReflectMethodRemapper; import com.mohistmc.bukkit.nms.remappers.ReflectRemapper; +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.lang.invoke.MethodType; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; import net.md_5.specialsource.InheritanceMap; import net.md_5.specialsource.JarMapping; import net.md_5.specialsource.transformer.MavenShade; @@ -38,15 +46,6 @@ import org.objectweb.asm.commons.Remapper; import org.objectweb.asm.tree.ClassNode; -import java.io.BufferedReader; -import java.io.IOException; -import java.io.InputStreamReader; -import java.lang.invoke.MethodType; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - /** * * @author pyz diff --git a/src/main/java/com/mohistmc/bukkit/pluginfix/DynmapFix.java b/src/main/java/com/mohistmc/bukkit/pluginfix/DynmapFix.java index 521dd1f343..b0ba1059e4 100644 --- a/src/main/java/com/mohistmc/bukkit/pluginfix/DynmapFix.java +++ b/src/main/java/com/mohistmc/bukkit/pluginfix/DynmapFix.java @@ -21,14 +21,13 @@ import com.mohistmc.bukkit.nms.utils.RemapUtils; import org.objectweb.asm.ClassReader; import org.objectweb.asm.ClassWriter; +import static org.objectweb.asm.Opcodes.ARETURN; import org.objectweb.asm.tree.ClassNode; import org.objectweb.asm.tree.InsnList; import org.objectweb.asm.tree.InsnNode; import org.objectweb.asm.tree.LdcInsnNode; import org.objectweb.asm.tree.MethodNode; -import static org.objectweb.asm.Opcodes.ARETURN; - public class DynmapFix { public static byte[] replaceBukkitVersionHelperSpigot116_4(byte[] basicClass) { diff --git a/src/main/java/com/mohistmc/bukkit/pluginfix/MultiverseCore.java b/src/main/java/com/mohistmc/bukkit/pluginfix/MultiverseCore.java new file mode 100644 index 0000000000..2c2694e9af --- /dev/null +++ b/src/main/java/com/mohistmc/bukkit/pluginfix/MultiverseCore.java @@ -0,0 +1,35 @@ +package com.mohistmc.bukkit.pluginfix; + +import org.bukkit.Bukkit; +import org.bukkit.craftbukkit.v1_16_R3.CraftServer; +import org.objectweb.asm.Opcodes; +import org.objectweb.asm.Type; +import org.objectweb.asm.tree.ClassNode; +import org.objectweb.asm.tree.InsnList; +import org.objectweb.asm.tree.MethodInsnNode; +import org.objectweb.asm.tree.MethodNode; +import org.objectweb.asm.tree.VarInsnNode; + +/** + * @author Mgazul by MohistMC + * @date 2023/8/27 11:29:47 + */ +public class MultiverseCore { + + public static void fix(ClassNode node) { + for (MethodNode method : node.methods) { + if (method.name.equals("doLoad") && method.desc.equals("(Ljava/lang/String;ZLorg/bukkit/WorldType;)Z")) { + InsnList toInject = new InsnList(); + toInject.add(new VarInsnNode(Opcodes.ALOAD, 1)); + toInject.add(new MethodInsnNode(Opcodes.INVOKESTATIC, Type.getInternalName(MultiverseCore.class), "isLoad", "(Ljava/lang/String;)Z")); + toInject.add(new VarInsnNode(Opcodes.ISTORE, 2)); + method.instructions.insert(toInject); + } + } + } + + public static boolean isLoad(String name) { + return ((CraftServer) Bukkit.getServer()).getWorldsByName().contains(name); + } +} + diff --git a/src/main/java/com/mohistmc/bukkit/pluginfix/PluginFixManager.java b/src/main/java/com/mohistmc/bukkit/pluginfix/PluginFixManager.java index ad8d43b22e..9f06894257 100644 --- a/src/main/java/com/mohistmc/bukkit/pluginfix/PluginFixManager.java +++ b/src/main/java/com/mohistmc/bukkit/pluginfix/PluginFixManager.java @@ -18,66 +18,83 @@ package com.mohistmc.bukkit.pluginfix; +import java.util.function.Consumer; import org.objectweb.asm.ClassReader; import org.objectweb.asm.ClassWriter; +import org.objectweb.asm.Opcodes; import org.objectweb.asm.Type; import org.objectweb.asm.tree.AbstractInsnNode; import org.objectweb.asm.tree.ClassNode; import org.objectweb.asm.tree.InsnList; import org.objectweb.asm.tree.InsnNode; +import org.objectweb.asm.tree.IntInsnNode; import org.objectweb.asm.tree.LdcInsnNode; import org.objectweb.asm.tree.MethodInsnNode; import org.objectweb.asm.tree.MethodNode; -import static org.objectweb.asm.Opcodes.INVOKESTATIC; -import static org.objectweb.asm.Opcodes.IRETURN; - public class PluginFixManager { public static byte[] injectPluginFix(String className, byte[] clazz) { if (className.endsWith("PaperLib")) { - return PluginFixManager.removePaper(clazz); + return patch(clazz, PluginFixManager::removePaper); + } + if (className.equals("com.onarandombox.MultiverseCore.utils.WorldManager")) { + return patch(clazz, MultiverseCore::fix); } if (className.equals("org.dynmap.bukkit.helper.v116_4.BukkitVersionHelperSpigot116_4")) { return DynmapFix.replaceBukkitVersionHelperSpigot116_4(clazz); } - if (className.equals("org.dynmap.bukkit.helper.BukkitVersionHelperGeneric")) { - return helloWorld(clazz, "[Lnet.minecraft.server.BiomeBase;", "[Lnet.minecraft.world.biome.Biome;"); + if (className.equals("com.sk89q.worldedit.bukkit.adapter.impl.Spigot_v1_16_R3")) { + return WorldEdit.patchSpigot_v1_16_R3(clazz); } - if (className.equals("com.earth2me.essentials.utils.VersionUtil")) { - return helloWorld(clazz, "net.minecraftforge.common.MinecraftForge", "hello.World"); + + Consumer patcher; + switch (className) { + case "com.sk89q.worldedit.bukkit.adapter.Refraction": + patcher = WorldEdit::handlePickName; + break; + case "com.earth2me.essentials.utils.VersionUtil": + patcher = node -> helloWorld(node, 110, 109); + break; + case "org.dynmap.bukkit.helper.BukkitVersionHelperGeneric": + patcher = node -> helloWorld(node, "[Lnet.minecraft.server.BiomeBase;", "[Lnet.minecraft.world.biome.Biome;"); + break; + case "net.Zrips.CMILib.Reflections": + patcher = node -> helloWorld(node, "bR", "f_36096_"); + break; + default: + patcher = null; + break; } - return clazz; + return patcher == null ? clazz : patch(clazz, patcher); } - public static byte[] removePaper(byte[] basicClass) { - ClassReader classReader = new ClassReader(basicClass); - ClassNode classNode = new ClassNode(); - ClassWriter classWriter = new ClassWriter(0); - classReader.accept(classNode, 0); - for (MethodNode methodNode : classNode.methods) { + private static byte[] patch(byte[] basicClass, Consumer handler) { + ClassNode node = new ClassNode(); + new ClassReader(basicClass).accept(node, 0); + handler.accept(node); + ClassWriter writer = new ClassWriter(0); + node.accept(writer); + return writer.toByteArray(); + } + + private static void removePaper(ClassNode node) { + for (MethodNode methodNode : node.methods) { if (methodNode.name.equals("isPaper") && methodNode.desc.equals("()Z")) { InsnList toInject = new InsnList(); - toInject.add(new MethodInsnNode(INVOKESTATIC, Type.getInternalName(PluginFixManager.class), "isPaper", "()Z")); - toInject.add(new InsnNode(IRETURN)); + toInject.add(new MethodInsnNode(Opcodes.INVOKESTATIC, Type.getInternalName(PluginFixManager.class), "isPaper", "()Z")); + toInject.add(new InsnNode(Opcodes.IRETURN)); methodNode.instructions = toInject; } } - classNode.accept(classWriter); - return classWriter.toByteArray(); } public static boolean isPaper() { return false; } - public static byte[] helloWorld(byte[] basicClass, String a, String b) { - ClassReader classReader = new ClassReader(basicClass); - ClassNode classNode = new ClassNode(); - ClassWriter classWriter = new ClassWriter(0); - classReader.accept(classNode, 0); - - for (MethodNode method : classNode.methods) { + private static void helloWorld(ClassNode node, String a, String b) { + node.methods.forEach(method -> { for (AbstractInsnNode next : method.instructions) { if (next instanceof LdcInsnNode) { LdcInsnNode ldcInsnNode = (LdcInsnNode) next; @@ -89,10 +106,20 @@ public static byte[] helloWorld(byte[] basicClass, String a, String b) { } } } - } + }); + } - classNode.accept(classWriter); - return classWriter.toByteArray(); + private static void helloWorld(ClassNode node, int a, int b) { + node.methods.forEach(method -> { + for (AbstractInsnNode next : method.instructions) { + if (next instanceof IntInsnNode) { + IntInsnNode ldcInsnNode = (IntInsnNode) next; + if (ldcInsnNode.operand == a) { + ldcInsnNode.operand = b; + } + } + } + }); } } diff --git a/src/main/java/com/mohistmc/bukkit/pluginfix/WorldEdit.java b/src/main/java/com/mohistmc/bukkit/pluginfix/WorldEdit.java new file mode 100644 index 0000000000..a49ec70009 --- /dev/null +++ b/src/main/java/com/mohistmc/bukkit/pluginfix/WorldEdit.java @@ -0,0 +1,60 @@ +package com.mohistmc.bukkit.pluginfix; + +import org.objectweb.asm.ClassReader; +import org.objectweb.asm.ClassWriter; +import org.objectweb.asm.Opcodes; +import org.objectweb.asm.tree.AbstractInsnNode; +import org.objectweb.asm.tree.ClassNode; +import org.objectweb.asm.tree.InsnList; +import org.objectweb.asm.tree.InsnNode; +import org.objectweb.asm.tree.MethodInsnNode; +import org.objectweb.asm.tree.MethodNode; +import org.objectweb.asm.tree.VarInsnNode; + +/** + * @author Mgazul by MohistMC + * @date 2023/8/11 4:24:52 + * FAWE: ... + */ +public class WorldEdit { + + public static byte[] patchSpigot_v1_16_R3(byte[] basicClass) { + ClassReader reader = new ClassReader(basicClass); + ClassNode node = new ClassNode(); + reader.accept(node, 0); + + for1: + for (MethodNode methodNode : node.methods) { + if (methodNode.name.equals("getProperties") && methodNode.desc.equals("(Lcom/sk89q/worldedit/world/block/BlockType;)Ljava/util/Map;")) { + for (AbstractInsnNode insnNode : methodNode.instructions) { + if (insnNode instanceof InsnNode) { + if (insnNode.getOpcode() == Opcodes.ATHROW) { + InsnList insnList = new InsnList(); + insnList.add(new InsnNode(Opcodes.POP)); + insnList.add(new MethodInsnNode(Opcodes.INVOKESTATIC, "java/util/Collections", "emptyMap", "()Ljava/util/Map;")); + insnList.add(new InsnNode(Opcodes.ARETURN)); + methodNode.instructions.insertBefore(insnNode, insnList); + methodNode.instructions.remove(insnNode); + break for1; + } + } + } + } + } + + ClassWriter writer = new ClassWriter(0); + node.accept(writer); + return writer.toByteArray(); + } + + public static void handlePickName(ClassNode node) { + for (MethodNode method : node.methods) { + if (method.name.equals("pickName")) { + method.instructions.clear(); + method.instructions.add(new VarInsnNode(Opcodes.ALOAD, 1)); + method.instructions.add(new InsnNode(Opcodes.ARETURN)); + return; + } + } + } +} diff --git a/src/main/java/com/mohistmc/command/BackupWorldCommand.java b/src/main/java/com/mohistmc/command/BackupWorldCommand.java index 8758b62f61..15111c59f4 100644 --- a/src/main/java/com/mohistmc/command/BackupWorldCommand.java +++ b/src/main/java/com/mohistmc/command/BackupWorldCommand.java @@ -19,15 +19,14 @@ package com.mohistmc.command; import com.mohistmc.util.ZipUtil; +import java.io.File; +import java.nio.file.Paths; +import java.time.LocalDateTime; import org.bukkit.Bukkit; import org.bukkit.World; import org.bukkit.command.Command; import org.bukkit.command.CommandSender; -import java.io.File; -import java.nio.file.Paths; -import java.time.LocalDateTime; - public class BackupWorldCommand extends Command { public BackupWorldCommand(String name) { diff --git a/src/main/java/com/mohistmc/command/DownloadFileCommand.java b/src/main/java/com/mohistmc/command/DownloadFileCommand.java index 15ab730bd9..89909a08b6 100644 --- a/src/main/java/com/mohistmc/command/DownloadFileCommand.java +++ b/src/main/java/com/mohistmc/command/DownloadFileCommand.java @@ -18,13 +18,11 @@ package com.mohistmc.command; +import static com.mohistmc.network.download.UpdateUtils.downloadFile; +import java.io.File; import org.bukkit.command.Command; import org.bukkit.command.CommandSender; -import java.io.File; - -import static com.mohistmc.network.download.UpdateUtils.downloadFile; - public class DownloadFileCommand extends Command { public DownloadFileCommand(String name) { diff --git a/src/main/java/com/mohistmc/command/DumpCommand.java b/src/main/java/com/mohistmc/command/DumpCommand.java index 95285ee4a6..6667b3bfec 100644 --- a/src/main/java/com/mohistmc/command/DumpCommand.java +++ b/src/main/java/com/mohistmc/command/DumpCommand.java @@ -21,6 +21,14 @@ import com.mohistmc.api.ChatComponentAPI; import com.mohistmc.api.ServerAPI; import com.mohistmc.util.HasteUtils; +import java.io.File; +import java.io.IOException; +import java.nio.charset.StandardCharsets; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Locale; +import java.util.Map; import net.minecraft.server.MinecraftServer; import org.apache.commons.io.FileUtils; import org.bukkit.ChatColor; @@ -38,15 +46,6 @@ import org.bukkit.potion.PotionType; import org.jetbrains.annotations.NotNull; -import java.io.File; -import java.io.IOException; -import java.nio.charset.StandardCharsets; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.Locale; -import java.util.Map; - public class DumpCommand extends Command { private final List tab_cmd = Arrays.asList("potions", "effect", "particle", "enchants", "cbcmds", "modscmds", "entitytypes", "biomes", "pattern", "worldgen", "worldtype", "material"); private final List tab_mode = Arrays.asList("file", "web"); diff --git a/src/main/java/com/mohistmc/command/GetPluginListCommand.java b/src/main/java/com/mohistmc/command/GetPluginListCommand.java index 3793e2730c..dd6de65c0a 100644 --- a/src/main/java/com/mohistmc/command/GetPluginListCommand.java +++ b/src/main/java/com/mohistmc/command/GetPluginListCommand.java @@ -19,13 +19,12 @@ package com.mohistmc.command; import com.mohistmc.util.HasteUtils; +import java.io.IOException; import org.bukkit.Bukkit; import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.plugin.Plugin; -import java.io.IOException; - public class GetPluginListCommand extends Command { private static String sendToHaste = ""; diff --git a/src/main/java/com/mohistmc/command/MohistCommand.java b/src/main/java/com/mohistmc/command/MohistCommand.java index fd5c8e36d4..e0a6336c48 100644 --- a/src/main/java/com/mohistmc/command/MohistCommand.java +++ b/src/main/java/com/mohistmc/command/MohistCommand.java @@ -23,6 +23,11 @@ import com.mohistmc.api.PlayerAPI; import com.mohistmc.api.ServerAPI; import com.mohistmc.util.i18n.i18n; +import java.io.File; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Locale; import net.minecraft.server.MinecraftServer; import net.minecraftforge.versions.forge.ForgeVersion; import org.bukkit.Bukkit; @@ -32,12 +37,6 @@ import org.bukkit.craftbukkit.v1_16_R3.CraftServer; import org.bukkit.entity.Player; -import java.io.File; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.Locale; - public class MohistCommand extends Command { public MohistCommand(String name) { diff --git a/src/main/java/com/mohistmc/command/PluginCommand.java b/src/main/java/com/mohistmc/command/PluginCommand.java index 5ec0f721a6..60fcd4450d 100644 --- a/src/main/java/com/mohistmc/command/PluginCommand.java +++ b/src/main/java/com/mohistmc/command/PluginCommand.java @@ -19,17 +19,16 @@ package com.mohistmc.command; import com.mohistmc.util.pluginmanager.PluginManagers; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Locale; import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.plugin.Plugin; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.Locale; - public class PluginCommand extends Command { public PluginCommand(String name) { diff --git a/src/main/java/com/mohistmc/eventhandler/dispatcher/BlockEventDispatcher.java b/src/main/java/com/mohistmc/eventhandler/dispatcher/BlockEventDispatcher.java index 9bd62b84a1..a77f46fd35 100644 --- a/src/main/java/com/mohistmc/eventhandler/dispatcher/BlockEventDispatcher.java +++ b/src/main/java/com/mohistmc/eventhandler/dispatcher/BlockEventDispatcher.java @@ -19,6 +19,8 @@ package com.mohistmc.eventhandler.dispatcher; import com.mohistmc.block.CraftCustomSnapshot; +import java.util.ArrayList; +import java.util.List; import net.minecraft.entity.Entity; import net.minecraft.entity.player.ServerPlayerEntity; import net.minecraft.util.Direction; @@ -38,9 +40,6 @@ import org.bukkit.inventory.EquipmentSlot; import org.bukkit.inventory.ItemStack; -import java.util.ArrayList; -import java.util.List; - public class BlockEventDispatcher { public static boolean isDropItems; diff --git a/src/main/java/com/mohistmc/forge/BukkitPermissionsHandler.java b/src/main/java/com/mohistmc/forge/BukkitPermissionsHandler.java index 134a6c1666..5de8f45b6f 100644 --- a/src/main/java/com/mohistmc/forge/BukkitPermissionsHandler.java +++ b/src/main/java/com/mohistmc/forge/BukkitPermissionsHandler.java @@ -20,6 +20,8 @@ import com.mohistmc.api.PlayerAPI; import com.mojang.authlib.GameProfile; +import java.util.Collection; +import java.util.stream.Collectors; import net.minecraft.entity.player.PlayerEntity; import net.minecraftforge.server.permission.DefaultPermissionLevel; import net.minecraftforge.server.permission.IPermissionHandler; @@ -29,9 +31,6 @@ import org.bukkit.permissions.Permission; import org.jetbrains.annotations.NotNull; -import java.util.Collection; -import java.util.stream.Collectors; - /** * https://github.com/CJ-MC-Mods/ForgeToBukkitPermissions */ diff --git a/src/main/java/com/mohistmc/forge/ForgeInjectBukkit.java b/src/main/java/com/mohistmc/forge/ForgeInjectBukkit.java index 27103736d6..26f127c5ef 100644 --- a/src/main/java/com/mohistmc/forge/ForgeInjectBukkit.java +++ b/src/main/java/com/mohistmc/forge/ForgeInjectBukkit.java @@ -25,6 +25,10 @@ import com.mohistmc.api.ServerAPI; import com.mohistmc.entity.CraftCustomEntity; import com.mohistmc.util.MohistEnumHelper; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; import net.minecraft.block.Block; import net.minecraft.enchantment.Enchantment; import net.minecraft.entity.ai.attributes.Attribute; @@ -65,11 +69,6 @@ import org.bukkit.potion.PotionType; import org.bukkit.util.permissions.DefaultPermissions; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - public class ForgeInjectBukkit { public static BiMap, World.Environment> environment = diff --git a/src/main/java/com/mohistmc/forge/ModCustomCommand.java b/src/main/java/com/mohistmc/forge/ModCustomCommand.java index c04ba6cd72..32d7cc648b 100644 --- a/src/main/java/com/mohistmc/forge/ModCustomCommand.java +++ b/src/main/java/com/mohistmc/forge/ModCustomCommand.java @@ -21,6 +21,9 @@ import com.google.common.base.Joiner; import com.mojang.brigadier.ParseResults; import com.mojang.brigadier.tree.CommandNode; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; import net.minecraft.command.CommandSource; import net.minecraft.command.Commands; import net.minecraft.server.MinecraftServer; @@ -41,10 +44,6 @@ import org.bukkit.entity.Player; import org.bukkit.entity.minecart.CommandMinecart; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - public class ModCustomCommand extends BukkitCommand { private final Commands dispatcher; diff --git a/src/main/java/com/mohistmc/forge/MohistDerivedWorldInfo.java b/src/main/java/com/mohistmc/forge/MohistDerivedWorldInfo.java index 35cb72a1fa..71cc7cc004 100644 --- a/src/main/java/com/mohistmc/forge/MohistDerivedWorldInfo.java +++ b/src/main/java/com/mohistmc/forge/MohistDerivedWorldInfo.java @@ -1,6 +1,7 @@ package com.mohistmc.forge; import com.mojang.serialization.Lifecycle; +import java.util.UUID; import net.minecraft.command.TimerCallbackManager; import net.minecraft.crash.CrashReportCategory; import net.minecraft.server.MinecraftServer; @@ -15,8 +16,6 @@ import net.minecraft.world.storage.IServerWorldInfo; import net.minecraft.world.storage.ServerWorldInfo; -import java.util.UUID; - public class MohistDerivedWorldInfo extends ServerWorldInfo { private final DerivedWorldInfo derivedWorldInfo; diff --git a/src/main/java/com/mohistmc/forge/MohistForgeUtils.java b/src/main/java/com/mohistmc/forge/MohistForgeUtils.java index 988b12fa51..afa6717209 100644 --- a/src/main/java/com/mohistmc/forge/MohistForgeUtils.java +++ b/src/main/java/com/mohistmc/forge/MohistForgeUtils.java @@ -19,7 +19,6 @@ package com.mohistmc.forge; import com.mohistmc.MohistConfig; - import java.util.List; import java.util.concurrent.atomic.AtomicBoolean; import java.util.regex.Pattern; diff --git a/src/main/java/com/mohistmc/inventory/CraftCustomInventory.java b/src/main/java/com/mohistmc/inventory/CraftCustomInventory.java index 26f238828d..82b3a3a770 100644 --- a/src/main/java/com/mohistmc/inventory/CraftCustomInventory.java +++ b/src/main/java/com/mohistmc/inventory/CraftCustomInventory.java @@ -18,6 +18,7 @@ package com.mohistmc.inventory; +import java.util.List; import net.minecraft.inventory.IInventory; import net.minecraftforge.items.ItemStackHandler; import org.bukkit.craftbukkit.v1_16_R3.inventory.CraftInventory; @@ -26,8 +27,6 @@ import org.bukkit.inventory.Inventory; import org.bukkit.inventory.InventoryHolder; -import java.util.List; - public class CraftCustomInventory implements InventoryHolder { private final CraftInventory container; diff --git a/src/main/java/com/mohistmc/inventory/InventoryOwner.java b/src/main/java/com/mohistmc/inventory/InventoryOwner.java index 3b3de52861..72fdb485f3 100644 --- a/src/main/java/com/mohistmc/inventory/InventoryOwner.java +++ b/src/main/java/com/mohistmc/inventory/InventoryOwner.java @@ -18,6 +18,7 @@ package com.mohistmc.inventory; +import javax.annotation.Nullable; import net.minecraft.inventory.IInventory; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.math.BlockPos; @@ -36,8 +37,6 @@ import org.bukkit.inventory.Inventory; import org.bukkit.inventory.InventoryHolder; -import javax.annotation.Nullable; - /** * @author Mgazul * @date 2020/4/10 13:39 diff --git a/src/main/java/com/mohistmc/netty/NettyPacketCompressor.java b/src/main/java/com/mohistmc/netty/NettyPacketCompressor.java index 18e8ed5002..2e65425064 100644 --- a/src/main/java/com/mohistmc/netty/NettyPacketCompressor.java +++ b/src/main/java/com/mohistmc/netty/NettyPacketCompressor.java @@ -3,9 +3,8 @@ import io.netty.buffer.ByteBuf; import io.netty.channel.ChannelHandlerContext; import io.netty.handler.codec.MessageToByteEncoder; -import net.minecraft.network.PacketBuffer; - import java.util.zip.Deflater; +import net.minecraft.network.PacketBuffer; public class NettyPacketCompressor extends MessageToByteEncoder { private final byte[] encodeBuf = new byte[8192]; diff --git a/src/main/java/com/mohistmc/netty/NettyPacketDecompressor.java b/src/main/java/com/mohistmc/netty/NettyPacketDecompressor.java index 7895479345..b039c39105 100644 --- a/src/main/java/com/mohistmc/netty/NettyPacketDecompressor.java +++ b/src/main/java/com/mohistmc/netty/NettyPacketDecompressor.java @@ -6,10 +6,9 @@ import io.netty.channel.ChannelHandlerContext; import io.netty.handler.codec.ByteToMessageDecoder; import io.netty.handler.codec.DecoderException; -import net.minecraft.network.PacketBuffer; - import java.util.List; import java.util.zip.Inflater; +import net.minecraft.network.PacketBuffer; public class NettyPacketDecompressor extends ByteToMessageDecoder { private final Inflater inflater; diff --git a/src/main/java/com/mohistmc/plugins/WorldCommand.java b/src/main/java/com/mohistmc/plugins/WorldCommand.java index 933d1d6b5a..ac7fdaba65 100644 --- a/src/main/java/com/mohistmc/plugins/WorldCommand.java +++ b/src/main/java/com/mohistmc/plugins/WorldCommand.java @@ -19,6 +19,7 @@ package com.mohistmc.plugins; import com.mohistmc.api.ItemAPI; +import java.util.ArrayList; import org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.World; @@ -28,8 +29,6 @@ import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.inventory.Inventory; -import java.util.ArrayList; - public class WorldCommand extends Command { public WorldCommand(String name) { diff --git a/src/main/java/com/mohistmc/util/Counter.java b/src/main/java/com/mohistmc/util/Counter.java index 5cf171c105..adc53a786f 100644 --- a/src/main/java/com/mohistmc/util/Counter.java +++ b/src/main/java/com/mohistmc/util/Counter.java @@ -2,11 +2,10 @@ import com.google.common.collect.ForwardingMap; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - import java.util.HashMap; import java.util.Map; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * @author Mgazul by MohistMC diff --git a/src/main/java/com/mohistmc/util/FindClassInJar.java b/src/main/java/com/mohistmc/util/FindClassInJar.java index f7a14a4bab..bbb83775d1 100644 --- a/src/main/java/com/mohistmc/util/FindClassInJar.java +++ b/src/main/java/com/mohistmc/util/FindClassInJar.java @@ -22,12 +22,11 @@ import java.io.FileFilter; import java.io.IOException; import java.nio.file.Files; +import static java.nio.file.StandardCopyOption.REPLACE_EXISTING; import java.util.Enumeration; import java.util.jar.JarEntry; import java.util.jar.JarFile; -import static java.nio.file.StandardCopyOption.REPLACE_EXISTING; - /** * @author Mgazul * @date 2019/12/15 21:42 diff --git a/src/main/java/com/mohistmc/util/MohistJDK8EnumHelper.java b/src/main/java/com/mohistmc/util/MohistJDK8EnumHelper.java index 624edfa6ed..8c6f1db69e 100644 --- a/src/main/java/com/mohistmc/util/MohistJDK8EnumHelper.java +++ b/src/main/java/com/mohistmc/util/MohistJDK8EnumHelper.java @@ -18,7 +18,6 @@ package com.mohistmc.util; -import javax.annotation.Nullable; import java.lang.reflect.Array; import java.lang.reflect.Constructor; import java.lang.reflect.Field; @@ -27,6 +26,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; +import javax.annotation.Nullable; public class MohistJDK8EnumHelper { diff --git a/src/main/java/com/mohistmc/util/MohistJDK9EnumHelper.java b/src/main/java/com/mohistmc/util/MohistJDK9EnumHelper.java index 3457a6c9d8..f61e0142f1 100644 --- a/src/main/java/com/mohistmc/util/MohistJDK9EnumHelper.java +++ b/src/main/java/com/mohistmc/util/MohistJDK9EnumHelper.java @@ -18,8 +18,6 @@ package com.mohistmc.util; -import sun.misc.Unsafe; - import java.lang.invoke.MethodHandle; import java.lang.invoke.MethodHandles; import java.lang.invoke.MethodType; @@ -28,6 +26,7 @@ import java.lang.reflect.Modifier; import java.util.ArrayList; import java.util.List; +import sun.misc.Unsafe; public class MohistJDK9EnumHelper { diff --git a/src/main/java/com/mohistmc/util/MohistModuleManager.java b/src/main/java/com/mohistmc/util/MohistModuleManager.java index d6d93207fc..e2bdbb0c96 100644 --- a/src/main/java/com/mohistmc/util/MohistModuleManager.java +++ b/src/main/java/com/mohistmc/util/MohistModuleManager.java @@ -18,8 +18,6 @@ package com.mohistmc.util; -import sun.misc.Unsafe; - import java.io.File; import java.lang.module.Configuration; import java.lang.module.ModuleFinder; @@ -32,6 +30,7 @@ import java.util.Set; import java.util.stream.Collectors; import java.util.stream.Stream; +import sun.misc.Unsafe; /** * @author Shawiiz_z diff --git a/src/main/java/com/mohistmc/util/pluginmanager/Control.java b/src/main/java/com/mohistmc/util/pluginmanager/Control.java index b623212881..e2e0f050d0 100644 --- a/src/main/java/com/mohistmc/util/pluginmanager/Control.java +++ b/src/main/java/com/mohistmc/util/pluginmanager/Control.java @@ -18,6 +18,14 @@ package com.mohistmc.util.pluginmanager; +import java.io.File; +import java.io.IOException; +import java.lang.reflect.Field; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.jar.JarFile; +import java.util.zip.ZipEntry; import net.minecraftforge.fml.common.ObfuscationReflectionHelper; import org.bukkit.Bukkit; import org.bukkit.command.Command; @@ -29,15 +37,6 @@ import org.bukkit.plugin.SimplePluginManager; import org.bukkit.plugin.java.JavaPlugin; -import java.io.File; -import java.io.IOException; -import java.lang.reflect.Field; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.jar.JarFile; -import java.util.zip.ZipEntry; - public class Control { public static PluginDescriptionFile getDescription(File file) { diff --git a/src/main/java/com/mohistmc/util/pluginmanager/PluginManagers.java b/src/main/java/com/mohistmc/util/pluginmanager/PluginManagers.java index f31b36cb4a..7c086bf2d8 100644 --- a/src/main/java/com/mohistmc/util/pluginmanager/PluginManagers.java +++ b/src/main/java/com/mohistmc/util/pluginmanager/PluginManagers.java @@ -19,15 +19,14 @@ package com.mohistmc.util.pluginmanager; import com.mohistmc.util.i18n.i18n; +import java.io.File; +import java.util.ArrayList; import org.bukkit.Bukkit; import org.bukkit.command.CommandSender; import org.bukkit.plugin.Plugin; import org.bukkit.plugin.PluginDescriptionFile; import org.bukkit.plugin.java.JavaPlugin; -import java.io.File; -import java.util.ArrayList; - public class PluginManagers { public static String permission = "mohist.command.plugin"; diff --git a/src/main/java/org/bukkit/craftbukkit/v1_16_R3/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/v1_16_R3/CraftServer.java index 887443dddf..90593fa25f 100644 --- a/src/main/java/org/bukkit/craftbukkit/v1_16_R3/CraftServer.java +++ b/src/main/java/org/bukkit/craftbukkit/v1_16_R3/CraftServer.java @@ -739,6 +739,10 @@ public List getWorlds() { return new ArrayList(worlds.values()); } + public Set getWorldsByName() { + return new HashSet<>(worlds.keySet()); + } + public DedicatedPlayerList getHandle() { return playerList; }