Exemplo n.º 1
0
 /**
  * Returns whether our running CraftBukkit already supports the HangingEvent instead of the
  * PaintingEvent
  *
  * @return true if the hanging event is supported
  */
 public static boolean hasHangingEvent() {
   Class<?> tmp = null;
   try {
     tmp = Class.forName("org.bukkit.event.hanging.HangingEvent");
   } catch (ClassNotFoundException ignored) {
   }
   return (tmp != null);
 }
Exemplo n.º 2
0
 static {
   ParticleUtils.version = "";
   try {
     ParticleUtils.version = Bukkit.getServer().getClass().getPackage().getName().split("\\.")[3];
     ParticleUtils.packetType = Class.forName(getPacketPlayOutParticles());
     final Class<?> typeCraftPlayer = Class.forName(getCraftPlayerClasspath());
     final Class<?> typeNMSPlayer = Class.forName(getNMSPlayerClasspath());
     final Class<?> typePlayerConnection = Class.forName(getPlayerConnectionClasspath());
     ParticleUtils.getHandle = typeCraftPlayer.getMethod("getHandle", (Class<?>[]) new Class[0]);
     ParticleUtils.playerConnection = typeNMSPlayer.getField("playerConnection");
     ParticleUtils.sendPacket =
         typePlayerConnection.getMethod("sendPacket", Class.forName(getPacketClasspath()));
   } catch (Exception e) {
     System.out.println("Failed to setup reflection for PacketPlayOutWorldParticles");
     e.printStackTrace();
   }
 }
Exemplo n.º 3
0
 public boolean setSkin(final String url) {
   try {
     Class.forName("org.getspout.spout.Spout");
     final SpoutPlayer sp = this.getSpoutPlayer();
     sp.setSkin(url);
     return true;
   } catch (final ClassNotFoundException e) {
     return false;
   }
 }
Exemplo n.º 4
0
 public SpoutPlayer getSpoutPlayer() {
   try {
     Class.forName("org.getspout.spout.Spout");
     if (!(this.getEntity().getBukkitEntity() instanceof SpoutCraftPlayer))
       ((NPCEntity) this.getEntity())
           .setBukkitEntity(
               new SpoutCraftPlayer(
                   (CraftServer) Bukkit.getServer(), (EntityPlayer) this.getEntity()));
     return (SpoutPlayer) this.getEntity().getBukkitEntity();
   } catch (final ClassNotFoundException e) {
     return null;
   }
 }
Exemplo n.º 5
0
 private static Class<?> getVersionedClass(final String className) throws ClassNotFoundException {
   if (className.startsWith("net.minecraft.server")) {
     if (InventoryUtil.version.isEmpty()) {
       return Class.forName(className);
     }
     return Class.forName(
         String.format(
             "net.minecraft.server%s.%s",
             InventoryUtil.version, className.substring("net.minecraft.server.".length())));
   } else {
     if (!className.startsWith("org.bukkit.craftbukkit")) {
       throw new IllegalArgumentException("Not a versioned class!");
     }
     if (InventoryUtil.version.isEmpty()) {
       return Class.forName(className);
     }
     return Class.forName(
         String.format(
             "net.minecraft.server%s.%s",
             InventoryUtil.version, className.substring("org.bukkit.craftbukkit.".length())));
   }
 }