Esempio n. 1
0
  /**
   * Handle the '/nocheatplus reload' command.
   *
   * @param sender the sender
   * @return true, if successful
   */
  private void handleReloadCommand(final CommandSender sender) {
    final LogManager logManager = NCPAPIProvider.getNoCheatPlusAPI().getLogManager();
    if (!sender.equals(Bukkit.getConsoleSender())) {
      sender.sendMessage(TAG + "Reloading configuration...");
    }
    logManager.info(Streams.INIT, TAG + "Reloading configuration...");

    // Do the actual reload.
    ConfigManager.cleanup();
    ConfigManager.init(access);
    if (logManager instanceof INotifyReload) { // TODO: This is a band-aid.
      ((INotifyReload) logManager).onReload();
    }

    // Remove all cached configs.
    DataManager.clearConfigs(); // There you have to add XConfig.clear() form now on.

    // Remove some checks data.
    // TODO: Better concept (INotifyReload).
    for (final CheckType checkType :
        new CheckType[] {
          CheckType.BLOCKBREAK, CheckType.FIGHT,
        }) {
      DataManager.clearData(checkType);
    }

    // Reset debug flags to default (temp, heavy).
    DataManager.restoreDefaultDebugFlags();

    // Tell the registered listeners to adapt to new config, first sort them (!).
    Collections.sort(notifyReload, Order.cmpSetupOrder);
    for (final INotifyReload component : notifyReload) {
      component.onReload();
    }

    // Say to the other plugins that we've reloaded the configuration.
    Bukkit.getPluginManager().callEvent(new NCPReloadEvent());

    // Log reloading done.
    if (!sender.equals(Bukkit.getConsoleSender())) {
      sender.sendMessage(TAG + "Configuration reloaded!");
    }
    logManager.info(Streams.INIT, TAG + "Configuration reloaded.");
    logManager.info(
        Streams.DEFAULT_FILE,
        StringUtil.join(VersionCommand.getVersionInfo(), "\n")); // Queued (!).
  }
Esempio n. 2
0
 /* (non-Javadoc)
  * @see fr.neatmonster.nocheatplus.command.AbstractCommand#onCommand(org.bukkit.command.CommandSender, org.bukkit.command.Command, java.lang.String, java.lang.String[])
  */
 @Override
 public boolean onCommand(CommandSender sender, Command command, String alias, String[] args) {
   if (args.length != 2) {
     return false;
   }
   if (!(sender instanceof Player)) {
     // TODO: Might implement if upvoted a lot.
     sender.sendMessage(
         "[NoCheatPlus] Toggling notifications is only available for online players.");
     return true;
   }
   DataManager.getPlayerData(sender.getName(), true).setNotifyOff(true);
   sender.sendMessage(
       ChatColor.RED
           + "NCP: "
           + ChatColor.WHITE
           + "Notifications are now turned "
           + ChatColor.RED
           + "off"
           + ChatColor.WHITE
           + ".");
   return true;
 }
Esempio n. 3
0
 void kick(CommandSender sender, String name, String reason) {
   Player player = DataManager.getPlayer(name);
   if (player == null) return;
   player.kickPlayer(reason);
   StaticLog.logInfo("(" + sender.getName() + ") Kicked " + player.getName() + " : " + reason);
 }
Esempio n. 4
0
 /**
  * Instantiates a new check.
  *
  * @param type the type
  */
 public Check(final CheckType type) {
   this.type = type;
   mcAccess = NoCheatPlus.getMCAccess();
   ViolationHistory.checkTypeMap.put(getClass().getName(), type);
   DataManager.registerExecutionHistory(type, histories);
 }