コード例 #1
0
 public static WrappedGameProfile getSkullBlob(WrappedGameProfile gameProfile) {
   try {
     Object minecraftServer = getNmsMethod("MinecraftServer", "getServer").invoke(null);
     for (Method method : getNmsClass("MinecraftServer").getMethods()) {
       if (method.getReturnType().getSimpleName().equals("MinecraftSessionService")) {
         Object session = method.invoke(minecraftServer);
         return WrappedGameProfile.fromHandle(
             session
                 .getClass()
                 .getMethod("fillProfileProperties", gameProfile.getHandleType(), boolean.class)
                 .invoke(session, gameProfile.getHandle(), true));
       }
     }
   } catch (Exception ex) {
     ex.printStackTrace();
   }
   return null;
 }
コード例 #2
0
 public static Object createEntityInstance(String entityName) {
   try {
     Class<?> entityClass = getNmsClass("Entity" + entityName);
     Object entityObject;
     Object world = getWorld(Bukkit.getWorlds().get(0));
     if (entityName.equals("Player")) {
       Object minecraftServer = getNmsMethod("MinecraftServer", "getServer").invoke(null);
       Object playerinteractmanager =
           getNmsClass("PlayerInteractManager")
               .getConstructor(getNmsClass("World"))
               .newInstance(world);
       if (LibVersion.is1_7()) {
         WrappedGameProfile gameProfile = getGameProfile(null, "LibsDisguises");
         entityObject =
             entityClass
                 .getConstructor(
                     getNmsClass("MinecraftServer"),
                     getNmsClass("WorldServer"),
                     gameProfile.getHandleType(),
                     playerinteractmanager.getClass())
                 .newInstance(
                     minecraftServer, world, gameProfile.getHandle(), playerinteractmanager);
       } else {
         entityObject =
             entityClass
                 .getConstructor(
                     getNmsClass("MinecraftServer"),
                     getNmsClass("World"),
                     String.class,
                     playerinteractmanager.getClass())
                 .newInstance(minecraftServer, world, "LibsDisguises", playerinteractmanager);
       }
     } else {
       entityObject = entityClass.getConstructor(getNmsClass("World")).newInstance(world);
     }
     return entityObject;
   } catch (Exception e) {
     e.printStackTrace();
   }
   return null;
 }