模块 mxlib.bukkit

类 BukkitToolkit


  • public class BukkitToolkit
    extends Object
    • 构造器详细资料

      • BukkitToolkit

        public BukkitToolkit()
    • 方法详细资料

      • getMaterial

        @NotNull
        public static @NotNull Material getMaterial​(ItemStack stack)
        For 1.13+ Server.
        参数:
        stack - The source ItemStack
        返回:
        The real material of item stack
        从以下版本开始:
        2.7
      • getNMS

        @Contract(pure=true)
        public static String getNMS()
        Get Minecraft NMS Version.

        net.minecraft.server.v1_14_R1.MinecraftServer

        返回:
        Minecraft Server Version
      • getCraftBukkitPackage

        @Contract(pure=true)
        public static String getCraftBukkitPackage()
        Get CraftBukkit Package.

        org.bukkit.craftserver.v_1_14_R1.CraftServer

        返回:
        CraftBukkit Package.
      • getNMSPackage

        @Contract(pure=true)
        public static String getNMSPackage()
        Get NMS Package.

        net.minecraft.server.v1_14_R1.MinecraftServer

        返回:
        NMS Package.
      • getCallerPlugin

        @Nullable
        public static @Nullable Plugin getCallerPlugin​(int from)
        Get who is invoking your method.

        See the Thread Stack Trace Here.

        PluginCalling ClassTrack trace(from value)
        MXLibBukkitToolkit
        <Your Plugin><The class invoking this method>
        <Your Method Caller Plugin><The class invoking your method>0
        Wel. It’s impossible to understand this.
        
         // Plugin info: "MyPlugin v1.0"
         class MyService implements Runnable{
             public void run(){
                 // Waiting for the form is right here.
                 System.out.println(BukkitToolkit.getCallerPlugin(0));
             }
         }
        
         // Plugin info: "ProxyPlugin v1.0.0"
         class ServiceProxy implements Runnable{
             public MyService parent;
             public void run(){
                 parent.run();
             }
         }
        
         // Plugin info: "OtherPlugin v1.0.1"
         class ServiceUser extends JavaPlugin{
             public void onEnable(){
                 ServiceProxy service = ....; // It is ServiceProxy.
                 service.run();
             }
         }
         
        PluginCalling ClassTrack trace(from value)
        MXLibBukkitToolkit
        MyPlugin v1.0MyService
        ServiceProxy v1.0.0ServiceProxy0
        ServiceUser v1.0.1ServiceUser1
        [null][Spigot Plugin Loader][Spigot Plugin Class Loader]2
        .........
        Sometimes the stack is also wrapped in several layers of non-plugin agents, like this
        PluginCalling ClassTrack trace(from value)
        MXLibBukkitToolkit
        MyPlugin v1.0MyService
        [Java Runtime.jar]sun.reflect....Impl0
        [Java Runtime.jar]sun.reflect....1
        [Java Runtime.jar]sun.reflect....2
        [Java Runtime.jar]sun.reflect....3
        ServiceProxy v1.0.0ServiceProxy4
        ServiceUser v1.0.1ServiceUser5
        [null][Spigot Plugin Loader][Spigot Plugin Class Loader]2
        .........
        Using getCallerPlugin(0) will return "ServiceProxy v1.0.0". [Java Runtime.jar] not a plugin. Then find the next track stack. into end.
        参数:
        from - Stack lookup starting point
        返回:
        The plugin at stack [from](or deeper)
        从以下版本开始:
        2.3
      • getCallerPlugin

        @Nullable
        public static @Nullable Plugin getCallerPlugin()
        get your method caller.
        返回:
        The method caller.
        从以下版本开始:
        2.3
        另请参阅:
        getCallerPlugin(int)
      • getPluginByClass

        @Contract(pure=true)
        @Nullable
        public static @Nullable Plugin getPluginByClass​(@NotNull
                                                        @NotNull Class<?> clazz)
        Get Class Owner..
        参数:
        clazz - The class will check
        返回:
        The class owner or null if it is not loaded by org.bukkit.java.plugin.PluginClassLoader.
      • toMinecraftKey

        public static MinecraftKey toMinecraftKey​(String key)
        参数:
        key - The key
        返回:
        The minecraft key
        从以下版本开始:
        2.6
      • validateAndCorrectChannel

        @NotNull
        public static @NotNull String validateAndCorrectChannel​(@NotNull
                                                                @NotNull String channel)
        Validates and corrects a Plugin Channel name. Method is not reentrant / idempotent.
        参数:
        channel - Channel name to validate.
        返回:
        corrected channel name
      • getPlugin

        public static Plugin getPlugin()
      • getPacketId

        public static int getPacketId​(@NotNull
                                      @NotNull String packetType)
      • getFile

        public static File getFile​(JavaPlugin p)
        参数:
        p - Get Plugin's file
        返回:
        The file of plugin
        从以下版本开始:
        2.12