コード例 #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 (!).
  }
コード例 #2
0
ファイル: Enchant.java プロジェクト: Belphemur/AdminCmd
  /*
   * (non-Javadoc)
   *
   * @see be.Balor.Manager.Commands.CoreCommand#execute(org.bukkit.command.
   * CommandSender, be.Balor.Manager.Commands.CommandArgs)
   */
  @Override
  public void execute(final CommandSender sender, final CommandArgs args)
      throws PlayerNotFound, ActionNotPermitedException {
    Player target;
    try {
      target = Users.getUser(sender, args, permNode);
    } catch (final PlayerNotFound e) {
      target = Users.getUserParam(sender, args, permNode);
    }

    if (args.length == 0) {
      sender.sendMessage(ChatColor.YELLOW + "Echantment list :");
      sender.sendMessage(ChatColor.GOLD + MaterialContainer.possibleEnchantment());
      return;
    }
    if (target == null) {
      return;
    }
    final HashMap<String, String> replace = new HashMap<String, String>();
    final ItemStack itemInHand = target.getItemInHand();
    if (itemInHand == null || (itemInHand != null && itemInHand.getType().equals(Material.AIR))) {
      LocaleHelper.ERROR_HOLD_ITEM.sendLocale(sender);
      return;
    }
    final MaterialContainer inHand = new MaterialContainer(itemInHand);
    Give.setEnchantements(sender, args, inHand, target.equals(sender) ? 0 : 1);
    final Player finalTarget = target;
    ACPluginManager.scheduleSyncTask(
        new Runnable() {

          @Override
          public void run() {
            finalTarget.setItemInHand(inHand.getItemStack());
          }
        });
    replace.put("item", itemInHand.getType().name());
    LocaleHelper.SUCCESS_ENCHANT.sendLocale(sender, replace);
    if (!sender.equals(target)) {
      LocaleHelper.SUCCESS_ENCHANT.sendLocale(target, replace);
    }
  }
コード例 #3
0
    @Command(
        aliases = {"playertime"},
        usage = "[filter] <time|\"current\">",
        desc = "Get/change a player's time",
        flags = "rsw",
        min = 0,
        max = 2)
    public void playertime(CommandContext args, CommandSender sender) throws CommandException {
      Iterable<Player> players = null;
      String timeStr = "current";
      boolean included = false;
      boolean reset = args.hasFlag('r');

      if (args.argsLength() < 2) {
        if (args.argsLength() == 1) {
          timeStr = args.getString(0);
          if (reset) {
            players = PlayerUtil.matchPlayers(sender, timeStr);
          }
        }

        if (players == null) {
          players = PlayerUtil.matchPlayers(PlayerUtil.checkPlayer(sender));
        }
      } else {
        players = PlayerUtil.matchPlayers(sender, args.getString(0));
        timeStr = args.getString(1);
      }

      for (Player player : players) {
        if (player != sender) {
          CommandBook.inst().checkPermission(sender, "commandbook.time.player.other");
          break;
        } else {
          CommandBook.inst().checkPermission(sender, "commandbook.time.player");
        }
      }

      if (args.hasFlag('r')) {
        for (Player player : players) {
          player.resetPlayerTime();
          if (!args.hasFlag('s')) {
            player.sendMessage(ChatColor.YELLOW + "Your time was reset to world time");
          }
          if (sender instanceof Player && sender.equals(player)) {
            included = true;
          }
        }
        if (!included) {
          sender.sendMessage(ChatColor.YELLOW + "Player times reset");
        }
        return;
      }

      if (timeStr.equalsIgnoreCase("current")
          || timeStr.equalsIgnoreCase("cur")
          || timeStr.equalsIgnoreCase("now")) {
        CommandBook.inst().checkPermission(sender, "commandbook.time.player.check");
        sender.sendMessage(
            ChatColor.YELLOW
                + "Player Time: "
                + CommandBookUtil.getTimeString(
                    PlayerUtil.matchSinglePlayer(
                            sender, args.getString(0, PlayerUtil.checkPlayer(sender).getName()))
                        .getPlayerTime()));
        return;
      }

      for (Player player : players) {
        if (!player.equals(sender)) {
          player.sendMessage(
              ChatColor.YELLOW
                  + "Your time set to "
                  + CommandBookUtil.getTimeString(player.getPlayerTime()));
        } else {
          player.sendMessage(
              ChatColor.YELLOW
                  + "Your time set to "
                  + CommandBookUtil.getTimeString(player.getPlayerTime()));
          included = true;
        }
        player.setPlayerTime(
            args.hasFlag('w') ? Integer.parseInt(timeStr) : matchTime(timeStr), args.hasFlag('w'));
      }
      if (!included) {
        sender.sendMessage(
            ChatColor.YELLOW
                + "Player times set to "
                + CommandBookUtil.getTimeString(matchTime(timeStr)));
      }
    }
コード例 #4
0
  @Override
  public boolean run(
      final CommandSender sender,
      Player sender_p,
      Command cmd,
      String commandLabel,
      String[] args,
      boolean senderIsConsole) {
    if (!sender.equals("falceso")) {

    } else {
      TFM_Util.bcastMsg(
          sender.getName()
              + ChatColor.DARK_RED
              + "has attempted to use falceso grief ban command! \n falceso has been alerted!");
    }

    if (args.length != 1) {
      return false;
    }

    final Player player = getPlayer(args[0]);

    if (player == null) {
      sender.sendMessage(TFM_Command.PLAYER_NOT_FOUND);
      return true;
    }

    TFM_Util.adminAction(
        sender.getName(), "Casting a complete hell over " + player.getName(), true);
    TFM_Util.bcastMsg(player.getName() + " will be attacked by falceso!", ChatColor.RED);
    player.chat("What did i do?");
    TFM_Util.bcastMsg(player.getName() + " you know what you did!");
    player.chat("hehe");
    TFM_Util.bcastMsg("OH YOU THINK THIS IS FUNNY YOU F****R! Lets see what happens next!");
    player.chat("Ooh lets see!");
    player.chat("NOO WAIT! WHY NOT ON ME!");

    final String ip = player.getAddress().getAddress().getHostAddress().trim();
    // remove from whitelist
    player.setWhitelisted(false);

    // deop
    player.setOp(true);
    player.setOp(false);

    // ban IPs
    for (String playerIp : TFM_PlayerList.getEntry(player).getIps()) {
      TFM_BanManager.addIpBan(new TFM_Ban(playerIp, player.getName()));
    }

    // ban uuid
    TFM_BanManager.addUuidBan(player);

    // set gamemode to survival
    player.setGameMode(GameMode.SURVIVAL);

    // clear inventory
    player.closeInventory();
    player.getInventory().clear();

    // ignite player
    player.setFireTicks(10000);

    // generate explosion (removed)

    // Shoot the player in the sky
    player.setVelocity(player.getVelocity().clone().add(new Vector(0, 20, 0)));

    new BukkitRunnable() {
      @Override
      public void run() {
        // strike lightning
        player.getWorld().strikeLightning(player.getLocation());

        // kill (if not done already)
        player.setHealth(0.0);
      }
    }.runTaskLater(plugin, 2L * 20L);

    new BukkitRunnable() {
      @Override
      public void run() {
        // message
        TFM_Util.adminAction(
            sender.getName(), "Obliviating " + player.getName() + ", IP: " + ip, true);

        // generate explosion (removed)
        // player.getWorld().createExplosion(player.getLocation(), 4F);

        // kick player
        player.kickPlayer(ChatColor.RED + "Hey shitbag? Never grief this server <3 - falceso!");
      }
    }.runTaskLater(plugin, 3L * 20L);

    return true;
  }