示例#1
0
 @Override
 public void initialize(Spell spell, ConfigurationSection parameters)
 {
     super.initialize(spell, parameters);
     if (parameters.contains("biomes"))
     {
         ConfigurationSection biomeConfig = ConfigurationUtils.getConfigurationSection(parameters, "biomes");
         biomeMap = new HashMap<>();
         Collection<String> biomeKeys = biomeConfig.getKeys(false);
         for (String biomeKey : biomeKeys)
         {
             try {
                 Biome biome = Biome.valueOf(biomeKey.toUpperCase());
                 List<String> treeTypes = ConfigurationUtils.getStringList(biomeConfig, biomeKey);
                 for (String typeKey : treeTypes)
                 {
                     try {
                         TreeType treeType = TreeType.valueOf(typeKey.toUpperCase());
                         List<TreeType> biomeTypes = biomeMap.get(biome);
                         if (biomeTypes == null) {
                             biomeTypes = new ArrayList<>();
                             biomeMap.put(biome, biomeTypes);
                         }
                         biomeTypes.add(treeType);
                     } catch (Exception treeEx) {
                         Bukkit.getLogger().warning("Invalid tree type: " + typeKey);
                     }
                 }
             } catch (Exception biomeEx) {
                 Bukkit.getLogger().warning("Invalid biome: " + biomeKey);
             }
         }
     }
 }
示例#2
0
 /**
  * Set the behavior of the current editing component to display information about a statistic
  * parameter with an entity type when the client hovers over the text.
  *
  * <p>Tooltips do not inherit display characteristics, such as color and styles, from the message
  * component on which they are applied.
  *
  * @param which The statistic to display.
  * @param entity The sole entity type parameter to the statistic.
  * @return This builder instance.
  * @exception IllegalArgumentException If the statistic requires a parameter which was not
  *     supplied, or was supplied a parameter that was not required.
  */
 public FancyMessage statisticTooltip(final Statistic which, EntityType entity) {
   Type type = which.getType();
   if (type == Type.UNTYPED) {
     throw new IllegalArgumentException("That statistic needs no additional parameter!");
   }
   if (type != Type.ENTITY) {
     throw new IllegalArgumentException(
         "Wrong parameter type for that statistic - needs " + type + "!");
   }
   try {
     Object statistic =
         Reflection.getMethod(
                 Reflection.getOBCClass("CraftStatistic"),
                 "getEntityStatistic",
                 Statistic.class,
                 EntityType.class)
             .invoke(null, which, entity);
     return achievementTooltip(
         (String) Reflection.getField(Reflection.getNMSClass("Statistic"), "name").get(statistic));
   } catch (IllegalAccessException e) {
     Bukkit.getLogger().log(Level.WARNING, "Could not access method.", e);
     return this;
   } catch (IllegalArgumentException e) {
     Bukkit.getLogger().log(Level.WARNING, "Argument could not be passed.", e);
     return this;
   } catch (InvocationTargetException e) {
     Bukkit.getLogger().log(Level.WARNING, "A error has occured durring invoking of method.", e);
     return this;
   }
 }
示例#3
0
 public static ItemStack addGlow(ItemStack item) {
   switch (Version.getVersion()) {
     case TOO_NEW:
       Bukkit.getLogger()
           .log(
               Level.SEVERE,
               "[Crazy Crates]>> Your server is too new for this plugin. "
                   + "Please update or remove this plugin to stop further Errors.");
       break;
     case v1_10_R1:
       return NMS_v1_10_R1.addGlow(item);
     case v1_9_R2:
       return NMS_v1_9_R2.addGlow(item);
     case v1_9_R1:
       return NMS_v1_9_R1.addGlow(item);
     case v1_8_R3:
       return NMS_v1_8_R3.addGlow(item);
     case v1_8_R2:
       return NMS_v1_8_R2.addGlow(item);
     case v1_8_R1:
       return NMS_v1_8_R1.addGlow(item);
     case TOO_OLD:
       Bukkit.getLogger()
           .log(
               Level.SEVERE,
               "[Crazy Crates]>> Your server is too far out of date. "
                   + "Please update or remove this plugin to stop further Errors.");
       break;
   }
   return item;
 }
示例#4
0
  public boolean selfUpdate() {
    if (new Version(plugin.getDescription().getVersion()).compareTo(updateCheck.getNewVersion())
        < 0) {
      if (currentPlayer != null) {
        currentPlayer.sendMessage(
            "A newer version of EssentialsUpdate is found. Downloading new file and reloading server.");
      }
      Bukkit.getLogger()
          .log(
              Level.INFO,
              "A newer version of EssentialsUpdate is found. Downloading new file and reloading server.");
      new SelfUpdate(
              new AbstractWorkListener(plugin, updateCheck.getNewVersionInfo()) {
                @Override
                public void onWorkAbort(final String message) {
                  if (message != null
                      && !message.isEmpty()
                      && UpdateProcess.this.currentPlayer != null
                      && UpdateProcess.this.currentPlayer.isOnline()) {
                    UpdateProcess.this.currentPlayer.sendMessage(message);
                  }
                  if (message != null && !message.isEmpty()) {
                    Bukkit.getLogger().log(Level.SEVERE, message);
                  }
                  UpdateProcess.this.currentPlayer = null;
                }

                @Override
                public void onWorkDone(final String message) {
                  if (message != null
                      && !message.isEmpty()
                      && UpdateProcess.this.currentPlayer != null
                      && UpdateProcess.this.currentPlayer.isOnline()) {
                    UpdateProcess.this.currentPlayer.sendMessage(message);
                  }
                  if (message != null && !message.isEmpty()) {
                    Bukkit.getLogger().log(Level.INFO, message);
                  }
                  UpdateProcess.this.currentPlayer = null;
                }
              })
          .start();
      return true;
    }
    if (updateCheck.getResult() == UpdateCheck.CheckResult.NEW_ESS_BUKKIT) {
      final String message =
          "Please update bukkit to version "
              + updateCheck.getNewBukkitVersion()
              + " before updating Essentials.";
      if (currentPlayer != null) {
        currentPlayer.sendMessage(message);
      }
      Bukkit.getLogger().log(Level.INFO, message);
      currentPlayer = null;
      return true;
    }
    return false;
  }
示例#5
0
  public static int distanceBetweenRegionsSide(NovaRegion region1, Location l1, Location l2) {
    int distance;

    int[] x1 = new int[2];
    int[] x2 = new int[2];

    int[] z1 = new int[2];
    int[] z2 = new int[2];

    Location[] c1 = new Location[2];
    Location[] c2 = new Location[2];

    c1[0] = region1.getCorner(0);
    c1[1] = region1.getCorner(1);

    //		c2[0] = region2.getCorner(0);
    //		c2[1] = region2.getCorner(1);

    c2[0] = l1;
    c2[1] = l2;

    x1[0] = c1[0].getBlockX();
    x1[1] = c1[1].getBlockX();

    x2[0] = c2[0].getBlockX();
    x2[1] = c2[1].getBlockX();

    z1[0] = c1[0].getBlockZ();
    z1[1] = c1[1].getBlockZ();

    z2[0] = c2[0].getBlockZ();
    z2[1] = c2[1].getBlockZ();

    boolean x_inside = x1[0] < x2[0] && x2[1] < x1[1];

    if (x_inside) {
      int dif = Math.abs(x1[0] - x2[0]);
      Bukkit.getLogger().info("dif=" + dif);
      distance = dif;

      dif = Math.abs(x1[1] - x2[1]);
      Bukkit.getLogger().info("dif=" + dif);
      if (distance > dif || distance == -1) distance = dif;
    } else {
      int dif = Math.abs(z1[0] - z2[0]);
      Bukkit.getLogger().info("dif=" + dif);
      distance = dif;

      dif = Math.abs(z1[1] - z2[1]);
      Bukkit.getLogger().info("dif=" + dif);
      if (distance > dif || distance == -1) distance = dif;
    }

    return distance;
  }
示例#6
0
  @Override
  public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {

    if (args.length == 0) {
      helpMessage(sender);
    } else if (args.length == 1) {
      helpMessage(sender);
    } else if (args.length >= 2) {

      StringBuilder buffer = new StringBuilder();
      for (int i = 1; i < args.length; i++) {
        buffer.append(' ').append(args[i]);
      }

      if (sender instanceof Player) {
        Player player = (Player) sender;
        Bukkit.getLogger()
            .info(
                ChatColor.YELLOW
                    + "Player "
                    + ChatColor.GREEN
                    + player.getDisplayName()
                    + ChatColor.YELLOW
                    + " reported "
                    + ChatColor.RED
                    + args[0]
                    + ChatColor.YELLOW
                    + ", for"
                    + ChatColor.RED
                    + buffer.toString()
                    + ChatColor.YELLOW
                    + ".");
      }
      if (sender instanceof ConsoleCommandSender) {
        Bukkit.getLogger()
            .info(
                ChatColor.GREEN
                    + "Console"
                    + ChatColor.YELLOW
                    + " reported "
                    + ChatColor.RED
                    + args[0]
                    + ChatColor.YELLOW
                    + ", for"
                    + ChatColor.RED
                    + buffer.toString()
                    + ChatColor.YELLOW
                    + ".");
      }
    }
    return true;
  }
示例#7
0
  /**
   * Logs an error that was probably caused by a client plugin.
   *
   * @param plugin the plugin that caused the exception, or null
   * @param e the exception that was thrown
   * @param msg an accompanying message
   */
  public static void logException(Plugin plugin, Throwable e, String msg) {
    Bukkit.getLogger().log(Level.SEVERE, "[Flex] " + msg, e);

    if (plugin != null) {
      /*
          Bukkit.getLogger().log(Level.SEVERE, "[Flex] This may to be a bug in one or more of the plugins using the Flex command handling framework.");
          Bukkit.getLogger().log(Level.SEVERE, "[Flex] Plugins using Flex: " + getClientsStr());
      }
      else {*/
      Bukkit.getLogger()
          .log(Level.SEVERE, "[Flex] The plugin that caused this error is: " + plugin.getName());
    }
  }
示例#8
0
  public void onEnable() {

    Bukkit.getLogger().log(Level.INFO, ChatColor.RED + "Custom plugin by PorterK enabled...");

    getCommand("mmo").setExecutor(CommandExecutor);

    MySQL sql = new MySQL("host", "port", "database", "user", "password");

    try {
      sql.open();
    } catch (Exception e) {

      Bukkit.getLogger().log(Level.SEVERE, "Could not connect to SQL database!");
    }
  }
示例#9
0
 /**
  * Has the server owner denied plugin metrics?
  *
  * @return true if metrics should be opted out of it
  */
 public boolean isOptOut() {
   synchronized (optOutLock) {
     try {
       // Reload the metrics file
       configuration.load(getConfigFile());
     } catch (IOException ex) {
       Bukkit.getLogger().log(Level.INFO, "[Metrics] " + ex.getMessage());
       return true;
     } catch (InvalidConfigurationException ex) {
       Bukkit.getLogger().log(Level.INFO, "[Metrics] " + ex.getMessage());
       return true;
     }
     return configuration.getBoolean("opt-out", false);
   }
 }
  public void inject(Plugin plugin) {
    Bukkit.getLogger()
        .info(
            "["
                + PluginBungeePermsBukkitBridge.getInstance().getDescription().getName()
                + "] Injection of BungeepermsBukkit into Vault");
    try {
      Vault v = (Vault) plugin;

      // inject BungeePerms
      Method m =
          v.getClass()
              .getDeclaredMethod(
                  "hookPermission",
                  String.class,
                  Class.class,
                  ServicePriority.class,
                  String[].class);
      m.setAccessible(true);
      m.invoke(
          v,
          "BungeePermsBukkit",
          Permission_BungeePermsBukkit.class,
          ServicePriority.Normal,
          new String[] {"net.alpenblock.bungeeperms.bukkit.BungeePerms"});

      Field f = v.getClass().getDeclaredField("perms");
      f.setAccessible(true);
      f.set(v, Bukkit.getServicesManager().getRegistration(Permission.class).getProvider());

    } catch (Exception ex) {
      ex.printStackTrace();
    }
  }
示例#11
0
文件: User.java 项目: Syndek/Root
  public void saveData() {
    JSONObject attributes = new JSONObject();
    attributes.put("fill", fill);
    attributes.put("muted", muted);
    attributes.put("frozen", frozen);
    attributes.put("undercover", undercover);

    JSONObject user = new JSONObject();
    user.put("name", base.getName());
    user.put("uuid", base.getUniqueId());
    user.put("attributes", attributes);

    JSONObject stat = new JSONObject();
    // Stat and ting

    JSONObject data = new JSONObject();
    data.put("user", user);
    data.put("stat", stat);

    try {
      FileWriter writer = new FileWriter("plugins/Root/users/" + base.getUniqueId() + "/data.json");
      writer.write(data.toJSONString());
      writer.flush();
      writer.close();
    } catch (IOException e) {
      Bukkit.getLogger()
          .warning("Error while saving data for " + getName() + ": " + e.getMessage());
    }
  }
 public void uninject(Plugin plugin) {
   Bukkit.getLogger()
       .info(
           "["
               + PluginBungeePermsBukkitBridge.getInstance().getDescription().getName()
               + "] Uninjection of BungeepermsBukkit into Vault");
 }
示例#13
0
  /**
   * Set the behavior of the current editing component to display the specified lines of formatted
   * text when the client hovers over the text.
   *
   * <p>Tooltips do not inherit display characteristics, such as color and styles, from the message
   * component on which they are applied.
   *
   * @param lines The lines of formatted text which will be displayed to the client upon hovering.
   * @return This builder instance.
   */
  public FancyMessage formattedTooltip(FancyMessage... lines) {
    if (lines.length < 1) {
      onHover(null, null); // Clear tooltip
      return this;
    }

    FancyMessage result = new FancyMessage();
    result.messageParts
        .clear(); // Remove the one existing text component that exists by default, which
                  // destabilizes the object

    for (int i = 0; i < lines.length; i++) {
      try {
        for (MessagePart component : lines[i]) {
          if (component.clickActionData != null && component.clickActionName != null) {
            throw new IllegalArgumentException("The tooltip text cannot have click data.");
          } else if (component.hoverActionData != null && component.hoverActionName != null) {
            throw new IllegalArgumentException("The tooltip text cannot have a tooltip.");
          }
          if (component.hasText()) {
            result.messageParts.add(component.clone());
          }
        }
        if (i != lines.length - 1) {
          result.messageParts.add(new MessagePart(rawText("\n")));
        }
      } catch (CloneNotSupportedException e) {
        Bukkit.getLogger().log(Level.WARNING, "Failed to clone object", e);
        return this;
      }
    }
    return formattedTooltip(
        result.messageParts.isEmpty() ? null : result); // Throws NPE if size is 0, intended
  }
 public void onEnable() {
   p = this;
   Bukkit.getLogger().info("SwornRefferal enabled!");
   refferals = new FileAccessor(this, "refferals.yml");
   pstats = new FileAccessor(this, "pstats.yml");
   Bukkit.getScheduler().scheduleSyncRepeatingTask(this, new CheckRunnable(), 1200L, 1200L);
   getCommand("refer").setExecutor(new CommandRefer());
   getCommand("reflb").setExecutor(new CommandRefLB());
   Bukkit.getPluginManager().registerEvents(new PlayerListener(), this);
   /* I seem to be loading data incorrectly here..
    * reload --> Tick, it resets
    * :(
    */
   for (Player p : Bukkit.getOnlinePlayers()) {
     // System.out.println(SwornRefferal.p.pstats.getFile().getConfigurationSection(p.getName().toLowerCase()) == null);
     if (SwornRefferal.p.pstats.getFile().getConfigurationSection(p.getName().toLowerCase())
         != null) {
       int level = SwornRefferal.p.pstats.getFile().getInt(p.getName().toLowerCase() + ".level");
       int refferal =
           SwornRefferal.p.pstats.getFile().getInt(p.getName().toLowerCase() + ".refferals");
       long lrt = SwornRefferal.p.pstats.getFile().getLong(p.getName().toLowerCase() + ".lrt");
       long lastRewardTime =
           SwornRefferal.p.pstats.getFile().getLong(p.getName().toLowerCase() + ".lastRewardTime");
       // System.out.println(level + "--" + refferal + "---" + lrt);
       PlayerData newp = new PlayerData(p, level, refferal, lrt, lastRewardTime);
       PlayerDataCollection.pds.add(newp);
     } else {
       PlayerData newp = new PlayerData(p, 1, 0, 0, 0);
       PlayerDataCollection.pds.add(newp);
       PlayerDataCollection.saveData();
     }
   }
 }
  /**
   * Register an event. python-facing. this version converts from string info.
   *
   * @param handler function handler
   * @param type Event type string
   * @param priority Event priority string
   */
  public void registerEvent(PyObject handler, PyString type, PyString priority) {
    try {
      String clazz = type.asString();
      Class<?> event = null;

      if (clazz.contains(".")) {
        try {
          // try if we can find the class
          event = Class.forName(clazz);
        } catch (ClassNotFoundException e) {
          // assume the subpackage and class name was given and append org.bukkit.event
          event = Class.forName("org.bukkit.event." + clazz);
        }
      } else if (customEvents.containsKey(clazz)) {
        // check if the name of a custom event was given
        event = customEvents.get(clazz);
      } else {
        throw new IllegalArgumentException("Could not find Event " + clazz);
      }

      if (!event.getClass().isInstance(event)) {
        throw new IllegalArgumentException(type.asString().toUpperCase() + " is not of type Event");
      }
      Class<? extends Event> realtype = (Class<? extends Event>) event;
      EventPriority realpriority = EventPriority.valueOf(priority.upper());
      registerEvent(handler, realtype, realpriority);

    } catch (ClassNotFoundException e) {
      Bukkit.getLogger()
          .log(
              Level.SEVERE,
              "Could not register event " + type + " because the event could not be found",
              e);
    }
  }
 /** Saves this File Configuration to file */
 public void save() {
   try {
     boolean regen = !this.exists();
     this.saveToStream(StreamUtil.createOutputStream(this.file));
     if (regen) {
       Bukkit.getLogger()
           .log(Level.INFO, "[Configuration] File '" + this.file + "' has been generated");
     }
   } catch (Exception ex) {
     Bukkit.getLogger()
         .log(
             Level.SEVERE,
             "[Configuration] An error occured while saving to file '" + this.file + "':");
     ex.printStackTrace();
   }
 }
示例#17
0
  public void addChair(Player player, Block block) {

    if (disabled) return;
    try {
      PacketContainer entitymeta = ProtocolLibrary.getProtocolManager().createPacket(40);
      entitymeta.getSpecificModifier(int.class).write(0, player.getEntityId());
      WrappedDataWatcher watcher = new WrappedDataWatcher();
      watcher.setObject(0, (byte) 4);
      entitymeta.getWatchableCollectionModifier().write(0, watcher.getWatchableObjects());
      for (Player play : plugin.getServer().getOnlinePlayers()) {
        if (play.getWorld().equals(player.getPlayer().getWorld())) {
          try {
            ProtocolLibrary.getProtocolManager().sendServerPacket(play, entitymeta);
          } catch (InvocationTargetException e) {
            BukkitUtil.printStacktrace(e);
          }
        }
      }
    } catch (Error e) {
      Bukkit.getLogger().severe("Chairs do not work without ProtocolLib!");
      disabled = true;
      return;
    }
    if (chairs.containsKey(player.getName())) return;
    plugin.wrapPlayer(player).print(ChatColor.YELLOW + "You are now sitting.");
    chairs.put(player.getName(), block);
  }
示例#18
0
  public PreparedStatement prepare(Connection c) {
    PreparedStatement pr = null;

    // Attempt to create a prepared statement that can be executed over the given connection
    try {
      pr = c.prepareStatement(this.query);
      // Insert all applicable parameters into the prepared statement
      for (int i = 0; i < this.values.size(); i++)
        pr.setObject(i + 1, this.values.get(i)); // Statement starts at index 1
    } catch (SQLException e) {
      Bukkit.getLogger().severe("Could not prepare SQL statement: '" + this.query + "'");
      Bukkit.getLogger().severe(e.getMessage());
      pr = null;
    }

    return pr;
  }
示例#19
0
 void addSign(TeleportSign ts) {
   signs.add(ts);
   database.save(ts);
   if (debugmode)
     Bukkit.getLogger()
         .log(
             Level.INFO, "[TeleportSigns] Saved TeleportSign at {0}", ts.getLocation().toString());
 }
示例#20
0
 // Safe Ranks File
 public void saveRanks() {
   if (ranks == null || ranksFile == null) return;
   try {
     getRanks().save(ranksFile);
   } catch (IOException ex) {
     Bukkit.getLogger().log(Level.SEVERE, "Could not save config " + ranksFile, ex);
   }
 }
示例#21
0
 public static void initialize() {
   database = new SQLiteDB();
   try {
     database.load();
   } catch (Exception e) {
     Bukkit.getLogger().info("Error loading database!");
   }
 }
 public static void setCommandConsole(String[] args) {
   PlayerData pd;
   Player pl = AncientRPG.plugin.getServer().getPlayer(args[1]);
   if (pl != null) {
     pd = PlayerData.getPlayerData(pl.getName());
   } else {
     Bukkit.getLogger().log(Level.WARNING, "Player not found");
     return;
   }
   AncientRPGClass oldclass = AncientRPGClass.classList.get(pd.getClassName().toLowerCase());
   AncientRPGClass c = AncientRPGClass.classList.get(args[2].toLowerCase());
   if (c != null) {
     setClass(c, oldclass, pl, null);
   } else {
     Bukkit.getLogger().log(Level.WARNING, "This class does not exist (typo?)");
   }
 }
示例#23
0
  @Override
  public void onEnable() {
    // Check for Spout
    if (!Bukkit.getPluginManager().isPluginEnabled("Spout")) {
      Bukkit.getLogger().severe("You need to have SpoutPlugin to run ComputerCraft!");
      this.setEnabled(false);

      return;
    }

    // Setup all the defaults - This MIGHT be better off in it's own class as we add more configs
    getDataFolder().mkdir(); // This will not do anythig if it already exists
    new File(getDataFolder().getAbsolutePath(), "computers" + File.separator).mkdir();
    File romDir = new File(getDataFolder().getAbsolutePath(), "rom" + File.separator);
    romDir.mkdir();
    File defaultRom = new File(romDir, "boot.lua");
    if (!defaultRom.exists()) {
      try {
        defaultRom.createNewFile();
        OutputStream output = new FileOutputStream(defaultRom, false);
        InputStream input = CCMain.class.getResourceAsStream("/defaults/boot.lua");
        byte[] buf = new byte[8192];
        while (true) {
          int length = input.read(buf);
          getLogger().info("" + length);
          if (length < 0) {
            break;
          }
          output.write(buf, 0, length);
        }
        input.close();
        output.close();
      } catch (IOException e) {
        e.printStackTrace();
      }
    }

    // Load configs
    ConfigManager.loadConfig(getConfig());
    saveConfig();

    // Fill in the static variables
    instance = this;
    ComputerThreads = new HashMap<Integer, ComputerThread>();

    // Register recipes with Spout
    new Materials();

    // Register listeners
    Bukkit.getPluginManager().registerEvents(new ComputerBlockPlacementListener(), this);

    // Database stuff
    try {
      getDatabase().find(ComputerData.class).findRowCount();
    } catch (Exception ex) {
      installDDL();
    }
  }
示例#24
0
  public static OkapiConfig loadConfiguration(File file) {
    if (file == null) {
      throw new IllegalArgumentException("File cannot be null");
    }

    OkapiConfig config = new OkapiConfig();

    try {
      config.load(file);
    } catch (FileNotFoundException ex) {
    } catch (IOException ex) {
      Bukkit.getLogger().log(Level.SEVERE, "Cannot load " + file, ex);
    } catch (InvalidConfigurationException ex) {
      Bukkit.getLogger().log(Level.SEVERE, "Cannot load " + file, ex);
    }

    return config;
  }
示例#25
0
 public static void debug(String s, long start) {
   if (DEBUG) {
     Bukkit.getLogger()
         .log(
             Level.INFO,
             "At {0}. Time since start: {1}ms",
             new Object[] {s, (System.currentTimeMillis() - start)});
   }
 }
 public boolean save() {
   try {
     save(file);
     return true;
   } catch (IOException e) {
     Bukkit.getLogger().severe(e.getMessage());
     return false;
   }
 }
 public static void savePerms() {
   if ((perms == null) || (permsFile == null)) {
     return;
   }
   try {
     getPerms().save(permsFile);
   } catch (IOException ex) {
     Bukkit.getLogger().log(Level.SEVERE, "Could not save config " + permsFile, ex);
   }
 }
示例#28
0
  public FancyMessage(final TextualComponent firstPartText) {
    messageParts = new ArrayList<MessagePart>();
    messageParts.add(new MessagePart(firstPartText));
    jsonString = null;
    dirty = false;

    if (nmsPacketPlayOutChatConstructor == null) {
      try {
        nmsPacketPlayOutChatConstructor =
            Reflection.getNMSClass("PacketPlayOutChat")
                .getDeclaredConstructor(Reflection.getNMSClass("IChatBaseComponent"));
        nmsPacketPlayOutChatConstructor.setAccessible(true);
      } catch (NoSuchMethodException e) {
        Bukkit.getLogger().log(Level.SEVERE, "Could not find Minecraft method or constructor.", e);
      } catch (SecurityException e) {
        Bukkit.getLogger().log(Level.WARNING, "Could not access constructor.", e);
      }
    }
  }
  @EventHandler
  @SuppressWarnings("unused")
  public void onEvent(EntityChangeBlockEvent e) {
    Bukkit.getLogger().info(e.getEntityType().toString());
    if (!plugin.enabled()) return;

    if (e.getEntityType() != EntityType.WITHER) return;

    if (e.getTo() == Material.AIR) e.setCancelled(true);
  }
 @Override
 public void onDisable() {
   Bukkit.getLogger().info("Disabling");
   try {
     utils.setOffline();
   } catch (SQLException e) {
     // TODO Auto-generated catch block
     e.printStackTrace();
   }
 }