public static void spawnParticle(
     Location location,
     ParticleType particleID,
     boolean force,
     float offx,
     float offy,
     float offz,
     float speed,
     int amount,
     int viewDistance,
     List<Player> ignorePlayers,
     int... extra) {
   if (SurvivalCosmetic.getInstance().isDisableParticles()) return;
   try {
     Class<?> packetClass = ReflectionUtil.getNMSClass("PacketPlayOutWorldParticles");
     Class<?> enumParticleClass = ReflectionUtil.getNMSClass("EnumParticle");
     Constructor<?> packetCons = packetClass.getConstructor();
     Object packet = packetCons.newInstance();
     ReflectionUtil.setValue(
         packet, true, "a", enumParticleClass.getEnumConstants()[particleID.id]);
     ReflectionUtil.setValue(packet, true, "b", (float) location.getX());
     ReflectionUtil.setValue(packet, true, "c", (float) location.getY());
     ReflectionUtil.setValue(packet, true, "d", (float) location.getZ());
     ReflectionUtil.setValue(packet, true, "e", offx);
     ReflectionUtil.setValue(packet, true, "f", offy);
     ReflectionUtil.setValue(packet, true, "g", offz);
     ReflectionUtil.setValue(packet, true, "h", speed);
     ReflectionUtil.setValue(packet, true, "i", amount);
     ReflectionUtil.setValue(packet, true, "j", force);
     ReflectionUtil.setValue(packet, true, "k", extra);
     Method sendPacket =
         ReflectionUtil.getNMSClass("PlayerConnection")
             .getMethod("sendPacket", ReflectionUtil.getNMSClass("Packet"));
     for (Player player : Bukkit.getOnlinePlayers()) {
       if (inParticleRange(player, location, viewDistance))
         if (!ignorePlayers.contains(player))
           sendPacket.invoke(ReflectionUtil.getConnection(player), packet);
     }
   } catch (ClassNotFoundException
       | NoSuchMethodException
       | InvocationTargetException
       | IllegalAccessException
       | InstantiationException
       | NoSuchFieldException ex) {
     Bukkit.getConsoleSender()
         .sendMessage(Messages.ERROR.prefix + "Error doing NMS stuff (with reflection), details:");
     ex.printStackTrace();
     Bukkit.getPluginManager().disablePlugin(SurvivalCosmetic.getInstance());
   }
 }
示例#2
0
 public void onEnable() {
   instance = this;
   Bukkit.getConsoleSender()
       .sendMessage(
           Messages.INFO.prefix
               + "Creating tables for survival server if they don't already exist...");
   try {
     if (Main.getInstance().debugMsgs)
       Bukkit.getConsoleSender()
           .sendMessage(Messages.DEBUG.prefix + "Creating table 'SurvivalKit'...");
     Main.getInstance()
         .getSql()
         .updateSQL(
             "CREATE TABLE IF NOT EXISTS`survival`.`survivalkit` ( "
                 + "  `ID` BIGINT(20) NOT NULL AUTO_INCREMENT, "
                 + "  `UUID` TINYTEXT NOT NULL, "
                 + "  `SNOWBALL` BIGINT(20) ZEROFILL, "
                 + "  `FIREWORK` BIGINT(20) ZEROFILL, "
                 + "  `SIGN` BIGINT(20) ZEROFILL, "
                 + "  `FOOD` BIGINT(20) ZEROFILL, "
                 + "  `STONE` BIGINT(20) ZEROFILL, "
                 + "  `TORCH` BIGINT(20) ZEROFILL, "
                 + "  `GOLD` BIGINT(20) ZEROFILL, "
                 + "  `FUEL` BIGINT(20) ZEROFILL, "
                 + "  `LOG` BIGINT(20) ZEROFILL, "
                 + "  `GOLDARMOUR` BIGINT(20) ZEROFILL, "
                 + "  `WATER` BIGINT(20) ZEROFILL, "
                 + "  `LAVA` BIGINT(20) ZEROFILL, "
                 + "  `IRON` BIGINT(20) ZEROFILL, "
                 + "  `FARMER` BIGINT(20) ZEROFILL, "
                 + "  `IRONARMOUR` BIGINT(20) ZEROFILL, "
                 + "  `BUCKET` BIGINT(20) ZEROFILL, "
                 + "  `BUFFET` BIGINT(20) ZEROFILL, "
                 + "  `BOW` BIGINT(20) ZEROFILL, "
                 + "  `DIAMOND` BIGINT(20) ZEROFILL, "
                 + "  `PISTON` BIGINT(20) ZEROFILL, "
                 + "  `LANDSCAPE` BIGINT(20) ZEROFILL, "
                 + "  `DIAMONDARMOUR` BIGINT(20) ZEROFILL, "
                 + "  `REDSTONE` BIGINT(20) ZEROFILL, "
                 + "  `WOOL` BIGINT(20) ZEROFILL, "
                 + "  `ACHIEVEMENT` BIGINT(20) ZEROFILL, "
                 + "  `ACHIEVEMENT2` BIGINT(20) ZEROFILL, "
                 + "  PRIMARY KEY (`ID`)); ");
     if (Main.getInstance().debugMsgs)
       Bukkit.getConsoleSender().sendMessage(Messages.DEBUG.prefix + "Completed!");
   } catch (SQLException e) {
     Bukkit.getConsoleSender()
         .sendMessage(Messages.ERROR.prefix + "Couldn't create table 'SurvivalKit'! Details:");
     e.printStackTrace();
     Bukkit.getPluginManager().disablePlugin(instance);
     return;
   }
   Bukkit.getConsoleSender().sendMessage(Messages.INFO.prefix + "Done!");
   timeChangePrevention.runTaskTimer(instance, timeChangePrevDelay, timeChangePrevDelay);
   tabListHeader.runTaskTimer(instance, 20, 20);
   Bukkit.getPluginManager().registerEvents(new PlayerJoin(), instance);
   Bukkit.getPluginManager().registerEvents(new PlayerQuit(), instance);
   Bukkit.getPluginManager().registerEvents(new KitInvClick(), instance);
   Bukkit.getPluginManager().registerEvents(new PlayerDamage(), instance);
   Bukkit.getPluginManager().registerEvents(new MobHandle(), instance);
   Bukkit.getPluginManager().registerEvents(new WeatherChange(), instance);
   Bukkit.getPluginManager().registerEvents(new ServerListPing(), instance);
   Bukkit.getPluginManager().registerEvents(new PlayerDeath(), instance);
   setCmds();
   // DISABLE CHEST IN COSMETIC
   if (Bukkit.getPluginManager().getPlugin("SurvivalCosmetic") != null
       && Bukkit.getPluginManager().getPlugin("SurvivalCosmetic").isEnabled()) {
     SurvivalCosmetic.getInstance().setDisableChest(true);
   }
 }