コード例 #1
0
 @Override
 public boolean onCommand(CommandSender cs, Command cmd, String label, String[] args) {
   if (cmd.getName().equalsIgnoreCase("loadplayer")) {
     if (!plugin.ah.isAuthorized(cs, "rcmds.loadplayer")) {
       RUtils.dispNoPerms(cs);
       return true;
     }
     if (args.length < 1) {
       cs.sendMessage(cmd.getDescription());
       return false;
     }
     final Player t = plugin.getServer().getPlayer(args[0]);
     if (t == null) {
       cs.sendMessage(MessageColor.NEGATIVE + "No such player!");
       return true;
     }
     if (!t.getName().equals(cs.getName())
         && !plugin.ah.isAuthorized(cs, "rcmds.others.loadplayer")) {
       cs.sendMessage(MessageColor.NEGATIVE + "You cannot load other players' data!");
       return true;
     }
     t.loadData();
     cs.sendMessage(MessageColor.POSITIVE + "Data loaded.");
     return true;
   }
   return false;
 }
コード例 #2
0
  /** {@inheritDoc} */
  public boolean dispatch(CommandSender sender, String commandLine) throws CommandException {
    String[] args = PATTERN_ON_SPACE.split(commandLine);

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

    String sentCommandLabel = args[0].toLowerCase();
    Command target = getCommand(sentCommandLabel);

    if (target == null) {
      return false;
    }

    try {
      target.timings.startTiming(); // Spigot
      // Note: we don't return the result of target.execute as thats success / failure, we return
      // handled (true) or not handled (false)
      target.execute(sender, sentCommandLabel, Arrays_copyOfRange(args, 1, args.length));
      target.timings.stopTiming(); // Spigot
    } catch (CommandException ex) {
      target.timings.stopTiming(); // Spigot
      throw ex;
    } catch (Throwable ex) {
      target.timings.stopTiming(); // Spigot
      throw new CommandException(
          "Unhandled exception executing '" + commandLine + "' in " + target, ex);
    }

    // return true as command was handled
    return true;
  }
コード例 #3
0
  /**
   * Registers a command with the given name is possible. Also uses fallbackPrefix to create a
   * unique name.
   *
   * @param label the name of the command, without the '/'-prefix.
   * @param command the command to register
   * @param isAlias whether the command is an alias
   * @param fallbackPrefix a prefix which is prepended to the command for a unique address
   * @return true if command was registered, false otherwise.
   */
  private synchronized boolean register(
      String label, Command command, boolean isAlias, String fallbackPrefix) {
    knownCommands.put(fallbackPrefix + ":" + label, command);
    if ((command instanceof VanillaCommand || isAlias) && knownCommands.containsKey(label)) {
      // Request is for an alias/fallback command and it conflicts with
      // a existing command or previous alias ignore it
      // Note: This will mean it gets removed from the commands list of active aliases
      return false;
    }

    boolean registered = true;

    // If the command exists but is an alias we overwrite it, otherwise we return
    Command conflict = knownCommands.get(label);
    if (conflict != null && conflict.getLabel().equals(label)) {
      return false;
    }

    if (!isAlias) {
      command.setLabel(label);
    }
    knownCommands.put(label, command);

    return registered;
  }
コード例 #4
0
ファイル: MailBoxes.java プロジェクト: killje/MailBoxes
 @Override
 public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
   if (cmd.getName().equalsIgnoreCase("send")) {
     if (args.length < 2) {
       return false;
     }
     UUID to = lastKnownAlias(args[0]);
     if (!(sender instanceof Player)) {
       return false;
     }
     OnlinePlayer from = getOnlinePlayer((Player) sender);
     switch (args[1]) {
       case "item":
         if (args.length != 2 || from == null) {
           return false;
         }
         from.sendItems(instance, to);
         return true;
       case "message":
         if (args.length < 3) {
           return false;
         }
         from.sendMessage(instance, to, (String[]) ArrayUtils.subarray(args, 2, args.length));
         return true;
     }
   } else if (cmd.getName().equalsIgnoreCase("getmessage")) {
     if (!(sender instanceof Player)) {
       return false;
     }
     OnlinePlayer player = getOnlinePlayer((Player) sender);
     player.showMessages();
   }
   return false;
 }
コード例 #5
0
 public boolean showUsage(Command command) {
   commandSender.sendMessage(
       ChatColor.YELLOW
           + "Usage: "
           + command.getUsage().replaceAll("<command>", command.getName()));
   return true;
 }
コード例 #6
0
  @Override
  public boolean execute(CommandSender sender, String currentAlias, String[] args) {
    if (!testPermission(sender)) return true;

    if (args.length == 1) {
      if (args[0].equalsIgnoreCase("reload")) {
        if (badPerm(sender, "reload")) return true;

        Bukkit.reloadWhitelist();
        Command.broadcastCommandMessage(sender, "Reloaded white-list from file");
        return true;
      } else if (args[0].equalsIgnoreCase("on")) {
        if (badPerm(sender, "enable")) return true;

        Bukkit.setWhitelist(true);
        Command.broadcastCommandMessage(sender, "Turned on white-listing");
        return true;
      } else if (args[0].equalsIgnoreCase("off")) {
        if (badPerm(sender, "disable")) return true;

        Bukkit.setWhitelist(false);
        Command.broadcastCommandMessage(sender, "Turned off white-listing");
        return true;
      } else if (args[0].equalsIgnoreCase("list")) {
        if (badPerm(sender, "list")) return true;

        StringBuilder result = new StringBuilder();

        for (OfflinePlayer player : Bukkit.getWhitelistedPlayers()) {
          if (result.length() > 0) {
            result.append(", ");
          }

          result.append(player.getName());
        }

        sender.sendMessage("White-listed players: " + result.toString());
        return true;
      }
    } else if (args.length == 2) {
      if (args[0].equalsIgnoreCase("add")) {
        if (badPerm(sender, "add")) return true;

        Bukkit.getOfflinePlayer(args[1]).setWhitelisted(true);

        Command.broadcastCommandMessage(sender, "Added " + args[1] + " to white-list");
        return true;
      } else if (args[0].equalsIgnoreCase("remove")) {
        if (badPerm(sender, "remove")) return true;

        Bukkit.getOfflinePlayer(args[1]).setWhitelisted(false);

        Command.broadcastCommandMessage(sender, "Removed " + args[1] + " from white-list");
        return true;
      }
    }

    sender.sendMessage(ChatColor.RED + "Correct command usage:\n" + usageMessage);
    return false;
  }
コード例 #7
0
ファイル: AdminWatch.java プロジェクト: Sinnoh/Adminwatch
 public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
   if (args.length == 1) {
     if (sender instanceof Player) {
       Player player = (Player) sender;
       if (command.getName().equalsIgnoreCase("adminwatch")) {
         if (player.hasPermission("adminwatch.admin")) {
           if (args[0].equalsIgnoreCase("reload")) {
             this.reloadConfig();
             player.sendMessage(
                 ChatColor.GREEN
                     + "["
                     + this.getConfig().getString("AdminWatch.prefix")
                     + "]"
                     + ChatColor.WHITE
                     + "Reload completed!");
             return true;
           }
         }
       }
     }
     if (!(sender instanceof Player)) {
       if (command.getName().equalsIgnoreCase("adminwatch")) {
         if (args[0].equalsIgnoreCase("reload")) {
           this.reloadConfig();
           System.out.print(
               "[" + this.getConfig().getString("AdminWatch.prefix") + "]Reload completed!");
           return true;
         }
       }
     }
   }
   return false;
 }
コード例 #8
0
 public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
   if (cmd.getName().equalsIgnoreCase("ef")
       || cmd.getName().equalsIgnoreCase("endlessflow") && sender.hasPermission("endlessflow.*")) {
     if (args.length == 0) {
       message("help");
     }
     if (args.length == 1) {
       if (args[0].equalsIgnoreCase("lava")) {
         if (lava) {
           lava = false;
           message("Lava toggled off!");
         } else {
           lava = true;
           message("Lava toggled on!");
         }
       }
       if (args[0].equalsIgnoreCase("water")) {
         if (water) {
           water = false;
           message("Water toggled off!");
         } else {
           water = true;
           message("Water toggled on!");
         }
       }
     }
   }
   return true;
 }
コード例 #9
0
  @Test
  public void testWorldImportWithNoFolder() {
    // Make sure the world directory do NOT exist
    // (it was created by the TestInstanceCreator)
    File worldFile = new File(TestInstanceCreator.serverDirectory, "world");
    assertTrue(worldFile.exists());
    assertTrue(worldFile.delete());

    // Start actual testing.
    // Pull a core instance from the server.
    Plugin plugin = mockServer.getPluginManager().getPlugin("Multiverse-Core");

    // Make sure Core is not null
    assertNotNull(plugin);

    // Make sure Core is enabled
    assertTrue(plugin.isEnabled());
    // Initialize a fake command
    Command mockCommand = mock(Command.class);
    when(mockCommand.getName()).thenReturn("mv");
    String[] normalArgs = new String[] {"import", "world", "normal"};

    // Ensure we have a fresh copy of MV, 0 worlds.
    assertEquals(0, creator.getCore().getMVWorldManager().getMVWorlds().size());

    // Import the first world. The world folder does not exist.
    plugin.onCommand(mockCommandSender, mockCommand, "", normalArgs);
    verify(mockCommandSender).sendMessage(ChatColor.RED + "FAILED.");
    verify(mockCommandSender)
        .sendMessage("That world folder does not exist. These look like worlds to me:");

    // We should still have no worlds.
    assertEquals(0, creator.getCore().getMVWorldManager().getMVWorlds().size());
  }
コード例 #10
0
ファイル: CmdKits.java プロジェクト: Borito/RoyalCommands
 @Override
 public boolean onCommand(CommandSender cs, Command cmd, String label, String[] args) {
   if (cmd.getName().equalsIgnoreCase("kits")) {
     if (!plugin.isAuthorized(cs, "rcmds.kits")) {
       RUtils.dispNoPerms(cs);
       return true;
     }
     if (!(cs instanceof Player) && args.length < 1) {
       cs.sendMessage(cmd.getDescription());
       return false;
     }
     final Map<String, Object> opts =
         plugin.getConfig().getConfigurationSection("kits").getValues(false);
     if (opts.keySet().isEmpty()) {
       cs.sendMessage(ChatColor.RED + "No kits found!");
       return true;
     }
     String kits = "";
     for (String s : opts.keySet()) {
       if (plugin.kitPerms && plugin.isAuthorized(cs, "rcmds.kit." + s))
         kits = (kits.isEmpty()) ? kits + s : kits + ", " + s;
       else if (!plugin.kitPerms) kits = (kits.isEmpty()) ? kits + s : kits + ", " + s;
     }
     cs.sendMessage(ChatColor.BLUE + "Kits:");
     if (kits.isEmpty()) return true;
     cs.sendMessage(kits);
     return true;
   }
   return false;
 }
コード例 #11
0
ファイル: superpick.java プロジェクト: Kyle1264x/PCE
  @Override
  public boolean onCommand(CommandSender sender, Command cmd, String cmdLabel, String[] args) {
    if (cmd.getName().equalsIgnoreCase("superpick")) {
      if (sender instanceof Player) {
        if (permissionCheck(sender, "PalCraftEssentials.command.superpick")) {
          CustomConfig conf = getConfig(((Player) sender));
          boolean s = conf.getFC().getBoolean("superpick");
          conf.getFC().set("superpick", !s);
          conf.save();
          sendMessage(
              sender,
              ChatColor.GOLD
                  + "SuperPick"
                  + ChatColor.WHITE
                  + ": "
                  + (!s ? ChatColor.GREEN + "Enabled" : ChatColor.RED + "Disabled"));
          return true;

        } else {
          noPermission(cmd.getName(), sender);
          return true;
        }
      } else {
        sendMessage(sender, ChatColor.RED + "Only players in game can use this command!");
        return true;
      }
    }
    return false;
  }
コード例 #12
0
ファイル: CmdKill.java プロジェクト: nsordk/RoyalCommands
 @Override
 public boolean onCommand(CommandSender cs, Command cmd, String label, String[] args) {
   if (cmd.getName().equalsIgnoreCase("kill")) {
     if (!plugin.isAuthorized(cs, "rcmds.kill")) {
       RUtils.dispNoPerms(cs);
       return true;
     }
     if (args.length < 1) {
       cs.sendMessage(cmd.getDescription());
       return false;
     }
     Player t = plugin.getServer().getPlayer(args[0].trim());
     if (t == null || plugin.isVanished(t, cs)) {
       cs.sendMessage(ChatColor.RED + "That player does not exist!");
       return true;
     }
     if (plugin.isAuthorized(t, "rcmds.exempt.kill")) {
       cs.sendMessage(ChatColor.RED + "You cannot kill that player!");
       return true;
     }
     t.setHealth(0);
     cs.sendMessage(
         ChatColor.BLUE
             + "You have killed "
             + ChatColor.GRAY
             + t.getDisplayName()
             + ChatColor.BLUE
             + ".");
     return true;
   }
   return false;
 }
コード例 #13
0
  @Override
  public void runCommand(CommandSender sender, List<String> args) {
    String worldName = args.get(0);
    File worldFile = new File(this.plugin.getServer().getWorldContainer(), worldName);
    String env = args.get(1);
    String seed = CommandHandler.getFlag("-s", args);
    String generator = CommandHandler.getFlag("-g", args);
    boolean useSpawnAdjust = true;
    for (String s : args) {
      if (s.equalsIgnoreCase("-n")) {
        useSpawnAdjust = false;
      }
    }
    if (worldFile.exists() || this.worldManager.isMVWorld(worldName)) {
      sender.sendMessage(ChatColor.RED + "A Folder/World already exists with this name!");
      sender.sendMessage(
          ChatColor.RED + "If you are confident it is a world you can import with /mvimport");
      return;
    }

    Environment environment = this.plugin.getEnvFromString(env);
    if (environment == null) {
      sender.sendMessage(ChatColor.RED + "That is not a valid environment.");
      EnvironmentCommand.showEnvironments(sender);
      return;
    }

    Command.broadcastCommandMessage(sender, "Starting creation of world '" + worldName + "'...");

    if (this.worldManager.addWorld(worldName, environment, seed, generator, useSpawnAdjust)) {
      Command.broadcastCommandMessage(sender, "Complete!");
    } else {
      Command.broadcastCommandMessage(sender, "FAILED.");
    }
  }
コード例 #14
0
  @Test
  public void testNullWorld() {
    // Pull a core instance from the server.
    Plugin plugin = mockServer.getPluginManager().getPlugin("Multiverse-Core");

    // Make sure Core is not null
    assertNotNull(plugin);

    // Make sure Core is enabled
    assertTrue(plugin.isEnabled());

    // Initialize a fake command
    Command mockCommand = mock(Command.class);
    when(mockCommand.getName()).thenReturn("mv");

    // Ensure that there are no worlds imported. This is a fresh setup.
    assertEquals(0, creator.getCore().getMVWorldManager().getMVWorlds().size());

    // Create the NULL world
    // The safe check is now BALLS SLOW. Use the -n to skip checking.
    String[] normalArgs = new String[] {"create", "nullworld", "normal", "-n"};
    plugin.onCommand(mockCommandSender, mockCommand, "", normalArgs);

    // We should now have one world!
    assertEquals(1, creator.getCore().getMVWorldManager().getMVWorlds().size());

    // Verify
    verify(mockCommandSender).sendMessage("Starting creation of world 'nullworld'...");
    verify(mockCommandSender).sendMessage("Complete!");

    WorldCreatorMatcher matcher = new WorldCreatorMatcher(new WorldCreator("nullworld"));
    verify(mockServer).createWorld(Matchers.argThat(matcher));
  }
コード例 #15
0
  @Test
  public void testWorldCreateInvalidGenerator() {
    // Pull a core instance from the server.
    Plugin plugin = mockServer.getPluginManager().getPlugin("Multiverse-Core");

    // Make sure Core is not null
    assertNotNull(plugin);

    // Make sure Core is enabled
    assertTrue(plugin.isEnabled());

    // Initialize a fake command
    Command mockCommand = mock(Command.class);
    when(mockCommand.getName()).thenReturn("mv");

    // Ensure that there are no worlds imported. This is a fresh setup.
    assertEquals(0, creator.getCore().getMVWorldManager().getMVWorlds().size());

    // Create the world
    String[] normalArgs = new String[] {"create", "newworld", "normal", "-g", "BogusGen"};
    plugin.onCommand(mockCommandSender, mockCommand, "", normalArgs);

    // This command should halt, not creating any worlds
    assertEquals(0, creator.getCore().getMVWorldManager().getMVWorlds().size());

    // Verify
    verify(mockCommandSender)
        .sendMessage(
            "Invalid generator! 'BogusGen'. " + ChatColor.RED + "Aborting world creation.");
  }
コード例 #16
0
ファイル: Vault.java プロジェクト: grandwazir/Vault
  @Override
  public boolean onCommand(
      CommandSender sender, Command command, String commandLabel, String[] args) {
    if (sender instanceof Player) {
      // Check if Player
      // If so, ignore command if player is not Op
      Player p = (Player) sender;
      if (!p.isOp()) {
        return true;
      }
    }

    if (command.getName().equalsIgnoreCase("vault-info")) {
      infoCommand(sender);
      return true;
    } else if (command.getName().equalsIgnoreCase("vault-convert")) {
      convertCommand(sender, args);
      return true;
    } else {
      // Show help
      sender.sendMessage("Vault Commands:");
      sender.sendMessage("  /vault-info - Displays information about Vault");
      sender.sendMessage(
          "  /vault-convert [economy1] [economy2] - Converts from one Economy to another");
      return true;
    }
  }
コード例 #17
0
 public boolean unregisterCommands() {
   CommandMap commandMap = getCommandMap();
   List<String> toRemove = new ArrayList<String>();
   Map<String, org.bukkit.command.Command> knownCommands =
       ReflectionUtil.getField(commandMap, "knownCommands");
   Set<String> aliases = ReflectionUtil.getField(commandMap, "aliases");
   if (knownCommands == null || aliases == null) {
     return false;
   }
   for (Iterator<org.bukkit.command.Command> i = knownCommands.values().iterator();
       i.hasNext(); ) {
     org.bukkit.command.Command cmd = i.next();
     if (cmd instanceof DynamicPluginCommand
         && ((DynamicPluginCommand) cmd).getOwner().equals(executor)) {
       i.remove();
       for (String alias : cmd.getAliases()) {
         org.bukkit.command.Command aliasCmd = knownCommands.get(alias);
         if (cmd.equals(aliasCmd)) {
           aliases.remove(alias);
           toRemove.add(alias);
         }
       }
     }
   }
   for (String string : toRemove) {
     knownCommands.remove(string);
   }
   return true;
 }
コード例 #18
0
 public boolean onCommand(CommandSender cs, Command cmd, String label, String[] args) {
   if (cmd.getName().equalsIgnoreCase("mobignore")) {
     if (!plugin.ah.isAuthorized(cs, "rcmds.mobignore")) {
       RUtils.dispNoPerms(cs);
       return true;
     }
     if (args.length < 1) {
       if (!(cs instanceof Player)) {
         cs.sendMessage(cmd.getDescription());
         return false;
       }
       Player p = (Player) cs;
       PConfManager pcm = PConfManager.getPConfManager(p);
       Boolean isHidden = pcm.getBoolean("mobignored");
       if (isHidden == null) isHidden = false;
       pcm.set("mobignored", !isHidden);
       String status = BooleanUtils.toStringOnOff(isHidden);
       cs.sendMessage(
           MessageColor.POSITIVE
               + "Toggled mob ignore "
               + MessageColor.NEUTRAL
               + status
               + MessageColor.POSITIVE
               + ".");
       return true;
     }
     Player t = plugin.getServer().getPlayer(args[0]);
     if (t == null || plugin.isVanished(t, cs)) {
       cs.sendMessage(MessageColor.NEGATIVE + "That player does not exist.");
       return true;
     }
     PConfManager pcm = PConfManager.getPConfManager(t);
     Boolean isHidden = pcm.getBoolean("mobignored");
     if (isHidden == null) isHidden = false;
     pcm.set("mobignored", !isHidden);
     String status = BooleanUtils.toStringOnOff(isHidden);
     cs.sendMessage(
         MessageColor.POSITIVE
             + "Toggled mob ignore "
             + MessageColor.NEUTRAL
             + status
             + MessageColor.POSITIVE
             + " for "
             + MessageColor.NEUTRAL
             + t.getName()
             + MessageColor.POSITIVE
             + ".");
     t.sendMessage(
         MessageColor.NEUTRAL
             + cs.getName()
             + MessageColor.POSITIVE
             + " toggled mob ignore "
             + MessageColor.NEUTRAL
             + status
             + MessageColor.POSITIVE
             + " for you.");
     return true;
   }
   return false;
 }
コード例 #19
0
 @Override
 public boolean always(CommandSender sender, Command command, String label, String[] args) {
   if ("test1".equalsIgnoreCase(command.getName())) return !test1(sender, args);
   if ("test2".equalsIgnoreCase(command.getName())) return !test2(sender, args);
   if ("test3".equalsIgnoreCase(command.getName())) return !test3(sender, args);
   return !("obelisk".equalsIgnoreCase(command.getName()) && obelisk(sender, args));
 }
コード例 #20
0
ファイル: tp.java プロジェクト: adriancfbr/CHBukkitHunger
 public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
   if (!(sender instanceof Player)) {
     sender.sendMessage("�rro> �omente jogadores podem executar este comando!");
     return true;
   }
   Player player = (Player) sender;
   if (cmd.getName().equalsIgnoreCase("tp")) {
     if (!player.hasPermission("hg.mod")) {
       player.sendMessage("Voc� n鉶 tem permissao para fazer isso!");
       return true;
     }
     if (args.length == 0) {
       player.sendMessage("Use /tp [player] para ir at� um player!");
       player.sendMessage("Use /s [player] para puxar um player at� voc�!");
       return true;
     }
     if (args.length == 1) {
       Player target = Bukkit.getPlayerExact(args[0]);
       if ((target == null) || (!(target instanceof Player))) {
         player.sendMessage("�Jogador n鉶 encontrado!");
         return true;
       }
       player.teleport(target);
       player.sendMessage("�Teleportado para " + target.getName());
       return true;
     }
     if (args.length > 1) {
       player.sendMessage("�Use /tp [player] para ir at� um player!");
       player.sendMessage("� Use /s [player] para puxar um player at� voc�!");
       return true;
     }
   } else if (cmd.getName().equalsIgnoreCase("s")) {
     if (!player.hasPermission("hg.mod")) {
       player.sendMessage("�Voc� n鉶 tem permissao para fazer isso!");
       return true;
     }
     if (args.length == 0) {
       player.sendMessage("�Use /tp [player] para ir at� um player!");
       player.sendMessage("�Use /s [player] para puxar um player at� voc�!");
       return true;
     }
     if (args.length == 1) {
       Player target = Bukkit.getPlayerExact(args[0]);
       if ((target == null) || (!(target instanceof Player))) {
         player.sendMessage("�Jogador n鉶 encontrado!");
         return true;
       }
       target.teleport(player);
       player.sendMessage("�Voc� puxou -> " + target.getName());
       return true;
     }
     if (args.length > 1) {
       player.sendMessage("Use /tp [player] para ir at� um player!");
       player.sendMessage("Use /s [player] para puxar um player at� voc�!");
       return true;
     }
   }
   return false;
 }
コード例 #21
0
 /**
  * Get the command label (trim + lower case), include server commands [subject to change].
  *
  * @param alias
  * @param strict If to return null if no command is found.
  * @return The command label, if possible to find, or the alias itself (+ trim + lower-case).
  */
 public static String getCommandLabel(final String alias, final boolean strict) {
   final Command command = getCommand(alias);
   if (command == null) {
     return strict ? null : alias.trim().toLowerCase();
   } else {
     return command.getLabel().trim().toLowerCase();
   }
 }
コード例 #22
0
ファイル: PwnFilter.java プロジェクト: riking/PwnFilter3
  @Override
  public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {

    if (cmd.getName().equalsIgnoreCase("pfreload")) {
      sender.sendMessage(ChatColor.RED + "Reloading config.yml and rules.txt");

      // Remove all our listeners, first.
      HandlerList.unregisterAll(this);

      // Shut down the DataCache
      dataCache.stop();

      reloadConfig();
      configurePlugin();

      ruleset = new RuleSet(this);
      if (ruleset.init(getRulesFile())) {
        logger.config("rules.txt and config.yml reloaded by " + sender.getName());
      } else {
        logger.warning("failed to reload rules.txt as requested by " + sender.getName());
      }

      // Start the DataCache again
      dataCache = new DataCache(this, ruleset.permList);

      // Re-register our listeners
      registerListeners();

      return true;
    } else if (cmd.getName().equalsIgnoreCase("pfcls")) {
      sender.sendMessage(ChatColor.RED + "Clearing chat screen");
      logger.info("chat screen cleared by " + sender.getName());
      int i = 0;
      while (i <= 120) {
        getServer().broadcastMessage(" ");
        i++;
      }
      return true;
    } else if (cmd.getName().equalsIgnoreCase("pfmute")) {
      if (pwnMute) {
        getServer()
            .broadcastMessage(ChatColor.RED + "Global mute cancelled by " + sender.getName());
        logger.info("global mute cancelled by " + sender.getName());
        pwnMute = false;
      } else {
        getServer()
            .broadcastMessage(ChatColor.RED + "Global mute initiated by " + sender.getName());
        logger.info("global mute initiated by " + sender.getName());
        pwnMute = true;
      }
      return true;
    } else if (cmd.getName().equalsIgnoreCase("pfdumpcache")) {
      dataCache.dumpCache(logger);
      sender.sendMessage(ChatColor.RED + "Dumped PwnFilter cache to log.");
      logger.info("Dumped PwnFilter cache to log by " + sender.getName());
    }
    return false;
  }
コード例 #23
0
 @Override
 public boolean onCommand(CommandSender cs, Command cmd, String label, String[] args) {
   if (cmd.getName().equals("playertime")) {
     if (!plugin.isAuthorized(cs, "rcmds.playertime")) {
       RUtils.dispNoPerms(cs);
       return true;
     }
     if (args.length < 1) {
       cs.sendMessage(cmd.getDescription());
       return false;
     }
     Player t = plugin.getServer().getPlayer(args[0]);
     if (t == null || plugin.isVanished(t, cs)) {
       cs.sendMessage(ChatColor.RED + "That player does not exist!");
       return true;
     }
     String possessive = (t.getName().toLowerCase().endsWith("s")) ? "'" : "'s";
     Integer time = null;
     if (args.length > 1) {
       try {
         time = Integer.valueOf(args[1]);
       } catch (Exception e) {
         cs.sendMessage(ChatColor.RED + "That time was invalid!");
         return true;
       }
     }
     if (time == null) {
       t.resetPlayerTime();
       cs.sendMessage(
           ChatColor.BLUE
               + "Synced "
               + ChatColor.GRAY
               + t.getName()
               + possessive
               + ChatColor.BLUE
               + " time with the server's.");
       return true;
     }
     if (plugin.smoothTime) smoothPlayerTimeChange(time, t);
     t.setPlayerTime(time, true);
     cs.sendMessage(
         ChatColor.BLUE
             + "Set "
             + ChatColor.GRAY
             + t.getName()
             + possessive
             + ChatColor.BLUE
             + " time to "
             + ChatColor.GRAY
             + time
             + " ticks"
             + ChatColor.BLUE
             + ".");
     return true;
   }
   return false;
 }
コード例 #24
0
ファイル: TabSorter.java プロジェクト: Notate/TabSorter
  @Override
  public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
    if (sender.hasPermission("rank.modify")) {
      if (cmd.getName().equalsIgnoreCase("tabsorter")) {
        if (args.length == 0) {
          sender.sendMessage(
              ChatColor.translateAlternateColorCodes(
                  '&', "&8[&eTab &aRank&8] &5Help syntaxes for Tab Rank:"));
          sender.sendMessage(
              ChatColor.translateAlternateColorCodes(
                  '&', "&8[&eTab &aRank&8] &5/tabrank reload &e- Reloads tab"));
          sender.sendMessage(
              ChatColor.translateAlternateColorCodes(
                  '&', "&8[&eTab &aRank&8] &5/tabrank [name] &e- Reloads for invidual player"));
        } else if (args.length == 1) {
          if (args[0].equalsIgnoreCase("reload")) {
            sender.sendMessage(
                ChatColor.translateAlternateColorCodes(
                    '&', "&8[&eTab &aRank&8] &6Reloaded config and scoreboard manager"));
            cutConfig();
            initConfig();
          } else {
            Player name = Bukkit.getPlayer(args[0]);
            if (name != null) {
              updateTab(name);
              sender.sendMessage(
                  ChatColor.translateAlternateColorCodes(
                      '&', "&8[&eTab &aRank&8] &aPlayer updated"));
            } else {
              sender.sendMessage(
                  ChatColor.translateAlternateColorCodes(
                      '&', "&8[&eTab &aRank&8] &cPlayer not found"));
            }
          }
        }
      }
    }

    if (cmd.getName().equalsIgnoreCase("tabver")) {
      sender.sendMessage(
          ChatColor.translateAlternateColorCodes(
              '&',
              "&8[&eTab &aRank&8] &ev"
                  + plgv[0]
                  + " b "
                  + plgv[1]
                  + " pshd by"
                  + plgv[2]
                  + " ("
                  + plgv[3]
                  + ")"));
      sender.sendMessage(
          ChatColor.translateAlternateColorCodes(
              '&', "&8[&eTab &aRank&8] &cGit: https://github.com/Notate/TabSorter"));
    }
    return false;
  }
コード例 #25
0
ファイル: xpconverter.java プロジェクト: mobsi09/xpconverter
  @Override
  public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
    Player player = null;

    if (sender instanceof Player) {
      player = (Player) sender;
    }

    if (command.getName().equalsIgnoreCase("convertxp")) {

      if (player == null) {
        return false;
      } else {
        if (player.hasPermission("convertxp.convert")) {

          if (args.length > 0) {
            try {
              int arg = Integer.parseInt(args[0]);
            } catch (NumberFormatException nfe) {
              player.sendMessage(ChatColor.DARK_AQUA + "Please enter a valid number");
              return true;
            }
            convertxppart(player, args[0]);
            return true;
          } else {
            convertxp(player);
            return true;
          }
        }
      }
    } else if (command.getName().equalsIgnoreCase("getxp")) {
      if (player == null) {
        return false;
      } else {
        if (player.hasPermission("convertxp.getxp")) {
          getxp(player);
          return true;
        }
      }
    } else if (command.getName().equalsIgnoreCase("convertxpreload")) {
      if (player.hasPermission("convertxp.convertxpreload") || (player == null)) {
        reloadconfig();
        return true;
      }
    } else if (command.getName().equalsIgnoreCase("convertxpinfo")) {
      if (player == null) {
        return false;
      } else {
        if (player.hasPermission("convertxp.convertxpinfo")) {
          convertxpinfo(player);
          return true;
        }
      }
    }

    return false;
  }
コード例 #26
0
  public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String arg[]) {

    List<String> args = Arrays.asList(arg);

    if (cmd.getName().equalsIgnoreCase("creativerights") && Permission.promote(sender)) {

      if (args.size() != 1) {
        Util.sendMessage(sender, "&cInvalid arguments supplied!");
        return true;
      }

      // Check permissions
      PermissionUser user = Permission.manager.getUser(args.get(0));
      if (user.inGroup(Config.CreativeGroup))
        Util.sendMessage(sender, "&7" + args.get(0) + " already has creative rights!");
      else {
        user.addGroup(Config.CreativeGroup);
        Util.sendMessage(sender, "&7" + args.get(0) + " granted creative rights");
      }

      // Check config list
      Config.savePlayers();
      return true;
    }
    if (cmd.getName().equalsIgnoreCase("delcreativerights") && Permission.promote(sender)) {

      if (args.size() != 1) {
        Util.sendMessage(sender, "&cInvalid arguments supplied!");
        return true;
      }

      // Check permissions
      PermissionUser user = Permission.manager.getUser(args.get(0));
      if (!user.inGroup(Config.CreativeGroup))
        Util.sendMessage(sender, "&7" + args.get(0) + " does not have creative rights!");
      else {
        user.removeGroup(Config.CreativeGroup);
        Util.sendMessage(sender, "&7Removed creative rights from " + args.get(0));
      }

      // Check config list
      Config.savePlayers();
      return true;
    }
    if (cmd.getName().equalsIgnoreCase("creativerender") && Permission.render(sender)) {
      if (generator.enabled) {
        Util.info("Running map generator...");
        Thread thread = new Thread(generator);
        thread.start();
      } else {
        Util.info("Map generator not enabled!");
      }
      return true;
    }
    return false;
  }
コード例 #27
0
ファイル: ACommand.java プロジェクト: Bindernews/Fast-Titles
 public void setAsExecutor(Command cmd) {
   cmd.setDescription(annot.desc());
   cmd.setUsage(annot.usage());
   cmd.setPermission(annot.permission());
   cmd.setAliases(new ArrayList<String>(Arrays.asList(annot.alias())));
   if (cmd instanceof PluginCommand) {
     PluginCommand pcmd = ((PluginCommand) cmd);
     pcmd.setExecutor(this);
     pcmd.setTabCompleter(this);
   }
 }
コード例 #28
0
ファイル: CmdBanIP.java プロジェクト: WizardCM/RoyalCommands
 @Override
 public boolean onCommand(CommandSender cs, Command cmd, String label, String[] args) {
   if (cmd.getName().equalsIgnoreCase("banip")) {
     if (!plugin.ah.isAuthorized(cs, "rcmds.banip")) {
       RUtils.dispNoPerms(cs);
       return true;
     }
     if (args.length < 1) {
       cs.sendMessage(cmd.getDescription());
       return false;
     }
     OfflinePlayer op = plugin.getServer().getOfflinePlayer(args[0]);
     String ip =
         (!op.hasPlayedBefore()) ? args[0] : PConfManager.getPConfManager(op).getString("ip");
     if (ip == null) ip = args[0];
     if (!isValid(ip)) {
       cs.sendMessage(
           MessageColor.NEGATIVE
               + "Invalid IP ("
               + MessageColor.NEUTRAL
               + ip
               + MessageColor.NEGATIVE
               + ").");
       return true;
     }
     plugin.getServer().banIP(ip);
     if (!op.hasPlayedBefore()) {
       cs.sendMessage(
           MessageColor.POSITIVE
               + "Banned IP "
               + MessageColor.NEUTRAL
               + ip
               + MessageColor.POSITIVE
               + ".");
       return true;
     } else {
       op.setBanned(true);
       RUtils.writeBanHistory(op);
       cs.sendMessage(
           MessageColor.POSITIVE
               + "Banned IP of "
               + MessageColor.NEUTRAL
               + op.getName()
               + MessageColor.POSITIVE
               + " ("
               + MessageColor.NEUTRAL
               + ip
               + MessageColor.POSITIVE
               + ").");
       return true;
     }
   }
   return false;
 }
コード例 #29
0
ファイル: Commands.java プロジェクト: CodeBeasty/BukkitCoding
  public boolean onCommand(CommandSender sender, Command cmd, String commmandLabel, String[] args) {
    Player p = (Player) sender;
    if (cmd.getName().equalsIgnoreCase("me")) {
      p.setFoodLevel(1);
      p.sendMessage(
          ChatColor.GOLD + "" + ChatColor.BOLD + "You have ran the /me command, You are awesome");

      return true;
    }
    String healmsg = main.getConfig().getString("HealMSG");
    String feedmsg = main.getConfig().getString("FeedMSG");
    String healtargetmsg = main.getConfig().getString("HealTarget");
    String feedtargetmsg = main.getConfig().getString("FeedTarget");

    if (cmd.getName().equalsIgnoreCase("heal")) {
      if (args.length == 0) {
        p.setHealth(20);
        p.sendMessage(ChatColor.translateAlternateColorCodes('&', healmsg));
        return true;
      }
      Player t = Bukkit.getServer().getPlayer(args[0]);
      if (t == null) {
        p.sendMessage(ChatColor.RED + "Please specify a Player!");
        return true;
      }
      t.setHealth(20);
      t.sendMessage(ChatColor.translateAlternateColorCodes('&', healmsg));
      p.sendMessage(
          ChatColor.translateAlternateColorCodes(
              '&', ChatColor.GREEN + t.getName() + healtargetmsg));
      return true;
    }
    if (cmd.getName().equalsIgnoreCase("feed")) {
      if (args.length == 0) {
        p.setFoodLevel(20);
        p.sendMessage(ChatColor.translateAlternateColorCodes('&', feedmsg));
        return true;
      }
      Player t = Bukkit.getServer().getPlayer(args[0]);
      if (t == null) {
        p.sendMessage(ChatColor.RED + "Please specify a Player!");
        return true;
      }
      t.setFoodLevel(20);
      t.sendMessage(ChatColor.translateAlternateColorCodes('&', feedmsg));
      p.sendMessage(
          ChatColor.translateAlternateColorCodes(
              '&', ChatColor.GREEN + t.getName() + feedtargetmsg));
      return true;
    }

    return false;
  }
コード例 #30
0
  public DynamicCommand(
      Plugin plugin,
      String name,
      String description,
      String usage,
      CommandExecutor exec,
      String... aliases) {
    this(plugin, name, description, exec, aliases);

    super.setUsage(usage);
    super.setAliases(Arrays.asList(aliases));
  }