Java 类org.bukkit.event.player.PlayerCommandPreprocessEvent 实例源码

项目:BloodMoon    文件:DisabledCommandsListener.java   
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onPlayerCommand(PlayerCommandPreprocessEvent event) {
    Player player = event.getPlayer();
    String message = event.getMessage();
    World world = player.getWorld();

    int spaceIndex = message.indexOf(' ');

    String command = (spaceIndex > 0) ? message.substring(1, spaceIndex) : message.substring(1);

    if (plugin.isActive(world) && plugin.isFeatureEnabled(world, Feature.DISABLED_COMMANDS)) {
        if (plugin.getConfig(world).getStringList(Config.FEATURE_DISABLED_COMMANDS_COMMANDS).contains(command)) {
            event.setCancelled(true);
            player.sendMessage(ChatColor.RED + "The /" + command + " is disabled during a bloodmoon!");
        }
    }
}
项目:pine-commons    文件:CommandHandler.java   
@EventHandler
public void onCommandProcess(PlayerCommandPreprocessEvent e) {
    String entryLabel = e.getMessage().split(" ")[0].replace("/", "");
    String[] entryArgs = e.getMessage().replace(entryLabel, "").split(" ");

    if (!commands.containsKey(entryLabel))
        return;

    CommandMethod commandMethod = commands.get(entryLabel);

    if (entryArgs.length < commandMethod.getCommand().minimumArgs())
        return;

    if (entryLabel.equals(commandMethod.getCommand().commandLabel()))
        try {
            commandMethod.getMethod().invoke(commandMethod.getObject(), e.getPlayer(), entryArgs);
        } catch (IllegalAccessException | InvocationTargetException ex) {
            Bukkit.getLogger().log(Level.SEVERE, String.format("Couldn't invoke %s method.", commandMethod.getMethod().getName()), ex);
        }
}
项目:bskyblock    文件:VisitorGuard.java   
/**
 * Prevents visitors from using commands on islands, like /spawner
 * @param e
 */
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onVisitorCommand(final PlayerCommandPreprocessEvent e) {
    if (DEBUG) {
        plugin.getLogger().info("Visitor command " + e.getEventName() + ": " + e.getMessage());
    }
    if (!Util.inWorld(e.getPlayer()) || e.getPlayer().isOp()
            || VaultHelper.hasPerm(e.getPlayer(), Settings.PERMPREFIX + "mod.bypassprotect")
            || plugin.getIslands().locationIsOnIsland(e.getPlayer(), e.getPlayer().getLocation())) {
        //plugin.getLogger().info("player is not in world or op etc.");
        return;
    }
    // Check banned commands
    //plugin.getLogger().info(Settings.visitorCommandBlockList.toString());
    String[] args = e.getMessage().substring(1).toLowerCase().split(" ");
    if (Settings.visitorBannedCommands.contains(args[0])) {
        Util.sendMessage(e.getPlayer(), plugin.getLocale(e.getPlayer().getUniqueId()).get("island.protected"));
        e.setCancelled(true);
    }
}
项目:ServerConnect    文件:EListener.java   
@EventHandler
public void onPlayerPreCommand(PlayerCommandPreprocessEvent event) {
    Player player = event.getPlayer();

    String command = event.getMessage().replaceFirst("/", "").toLowerCase();
    String server = this.plugin.getServer(command);
    if (server == null) return;

    event.setCancelled(true);

    if (player.isOp() || player.hasPermission(ServerConnect.PERMISSION_SERVERS + server)) {
        this.plugin.getMessageBungee().connect(player, command);
    } else {
        player.sendMessage(ChatColor.translateAlternateColorCodes('&', this.plugin.getConfig().getString("noPermission", "&cYou don't have permissions for that server!")));
    }
}
项目:kaosEssentials    文件:Core.java   
@EventHandler
public void helpMessage(PlayerCommandPreprocessEvent e){
    if(e.getMessage().startsWith("/help")){
        e.setCancelled(true);
        Player p = e.getPlayer();
        p.sendMessage(tag + ChatColor.GRAY + "=================================");
        p.sendMessage(ChatColor.BLUE + "KaosPvP is a custom massive pvp like server");
        p.sendMessage(ChatColor.BLUE + " with chaotic enchantments, pots and gaps.");
        p.sendMessage(ChatColor.BLUE + "Grab an axe and some gear, then step into pvp");
        p.sendMessage(ChatColor.BLUE + " for an awesome and unique pvp experience.");
        p.sendMessage(ChatColor.AQUA + "---Commands---");
        p.sendMessage(ChatColor.RED + "/help " + ChatColor.BLUE + "This help message");
        p.sendMessage(ChatColor.RED + "/rules " + ChatColor.BLUE + "Server rules");
        p.sendMessage(ChatColor.RED + "/report " + ChatColor.BLUE + "Report a player to the online staff");
        p.sendMessage(ChatColor.RED + "/trash " + ChatColor.BLUE + "Throw away useless items");
        p.sendMessage(ChatColor.RED + "/msg " + ChatColor.BLUE + "Send a private message");
        p.sendMessage(ChatColor.RED + "/r " + ChatColor.BLUE + "Reply to your last private message");
        p.sendMessage(ChatColor.RED + "/discord " + ChatColor.BLUE + "Display discord link");
        p.sendMessage(ChatColor.RED + "/pmc " + ChatColor.BLUE + "Display PMC link");
        p.sendMessage(ChatColor.RED + "/tokens " + ChatColor.BLUE + "Everything to do with tokens");
        p.sendMessage(ChatColor.RED + "/shop " + ChatColor.BLUE + "Open the shop");
        p.sendMessage(tag + ChatColor.GRAY + "=================================");
    }
}
项目:ChatMenuAPI    文件:CMListener.java   
@EventHandler(priority = EventPriority.LOWEST)
public void onCommandPreprocess(PlayerCommandPreprocessEvent e)
{
    String cmd = e.getMessage().substring(1);
    if(cmd.length() <= 0) return;
    String[] unprocessedArgs = cmd.split(" ");

    String label = unprocessedArgs[0];
    String[] args = new String[unprocessedArgs.length - 1];
    System.arraycopy(unprocessedArgs, 1, args, 0, args.length);

    if(label.equalsIgnoreCase("cmapi"))
    {
        e.setCancelled(true);
        command.onCommand(e.getPlayer(), null, label, args);
    }
}
项目:Kineticraft    文件:Commands.java   
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onCommand(PlayerCommandPreprocessEvent evt) {
    Player p = evt.getPlayer();
    String input = evt.getMessage();

    if (input.startsWith("/minecraft:") && !Utils.isStaff(p))
        evt.setCancelled(true); // Prevent /minecraft: prefixed commands.

    if (input.startsWith("/ ")) {
        sendStaffChat(p, input.substring(2));
        evt.setCancelled(true);
        return;
    }

    if (!input.startsWith("/trigger ")) // Alert staff of commands used, if the command isn't /trigger.
        Core.alertStaff(p.getName() + ": " + ChatColor.GRAY + input);

    evt.setCancelled(handleCommand(p, CommandType.SLASH, input) || handleCommand(p, CommandType.TRIGGER, input)); // Don't show 'unknown command....'
}
项目:VanillaPlus    文件:CPManager.java   
@EventHandler (priority = EventPriority.HIGHEST, ignoreCancelled = false)
public void onCommand(PlayerCommandPreprocessEvent event){
    if(event.getMessage().isEmpty()){
        event.setMessage("/help");
        return;
    }
    Command cmd = commandMap.get(event.getMessage().replaceFirst("/", "").split(" ")[0].toLowerCase());
    if(cmd == null){
        event.setMessage("/help");
        return;
    }
    if(!cmd.testPermissionSilent(event.getPlayer()))
        if(!(cmd instanceof LinkCommand)){
            event.setMessage("/help");
        }
}
项目:EssentialCommands    文件:CommandEvent.java   
public void whenAfk(PlayerCommandPreprocessEvent e) {
    User user = Core.getUser(e.getPlayer());
    String message = e.getMessage().toLowerCase();
    if (user.isAfk()) {
        if (getAliases("afk").contains(message)) {
            return;
        }
        user.setAfk(false);
    }

    /*
     * if (getAliases(afkCommand).contains(message) ||
     * afkCommand.getName().equalsIgnoreCase(message) || getAliases(
     * broadcastCommand).contains(message) ||
     * messageCommand.getName().equalsIgnoreCase(message) || getAliases(
     * messageCommand).contains(message) ||
     * replyCommand.getName().equalsIgnoreCase(message) ||
     * getAliases(replyCommand).contains(message) ||
     * broadcastCommand.getName().equalsIgnoreCase(message) ||
     * getAliases(vanishCommand).contains(message) ||
     * vanishCommand.getName().equalsIgnoreCase(message)) { if
     * (user.isAfk()) { return; } else { user.setAfk(false); } }
     */
}
项目:WildernessTp    文件:CommandUseEvent.java   
@EventHandler(priority = EventPriority.LOWEST)
public void onCmd(PlayerCommandPreprocessEvent e) {
    String command = e.getMessage().toLowerCase();
    List<String> blockedCmds = wild.getConfig().getStringList("BlockCommands");
    if (TeleportTarget.cmdUsed.contains(e.getPlayer().getUniqueId())) {
        for (String cmd : blockedCmds) {
            if (command.contains(cmd)) {
                e.getPlayer().sendMessage(ChatColor.translateAlternateColorCodes('&', wild.getConfig().getString("Blocked_Command_Message")));
                e.setCancelled(true);
                break;
            }
        }
    }
    if (e.getMessage().equalsIgnoreCase("/wild") && wild.getConfig().getBoolean("FBasics")) {
        e.setCancelled(true);
        CheckPerms check = new CheckPerms(wild);
        Checks checks = new Checks(wild);
        Player p = e.getPlayer();
        if (!checks.world(p))
            p.sendMessage(ChatColor.translateAlternateColorCodes('&', wild.getConfig().getString("WorldMsg")));
        else
            check.check(p);
    }
}
项目:SecureMyAccount    文件:PreventListener.java   
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOW)
public void onCommand(PlayerCommandPreprocessEvent commandEvent) {
    Player invoker = commandEvent.getPlayer();

    //remove the command identifier and further command arguments
    String command = commandEvent.getMessage().replaceFirst("/", "").split(" ")[0];
    if ("login".equalsIgnoreCase(command) || "register".equalsIgnoreCase(command)) {
        //ignore our own commands
        return;
    }

    if (plugin.getConfig().getBoolean("commandOnlyProtection")) {
        List<String> protectedCommands = plugin.getConfig().getStringList("protectedCommands");
        if (protectedCommands.isEmpty() || protectedCommands.contains(command)) {
            if (!plugin.isInSession(invoker)) {
                invoker.sendMessage(ChatColor.DARK_RED + "This action is protected for extra security");
                invoker.sendMessage(ChatColor.DARK_RED + "Please type /session <code>");
                commandEvent.setCancelled(true);
            }
        }
    } else {
        checkLoginStatus(invoker, commandEvent);
    }
}
项目:OldBukkit    文件:PlayerListener.java   
@EventHandler
void onCommandProcess(PlayerCommandPreprocessEvent e) {
    Player p = e.getPlayer();
    ProtectedRegion region = Hooks.getWorldguard().getRegionManager(p.getWorld()).getRegion(TerrenosManager.getTerrenoIdByBlock(e.getPlayer().getLocation().getBlock()));
    if (region == null || !region.getId().contains("-")) return;
    String[] s = region.getId().split("-");

    if (!region.isOwner(e.getPlayer().getName()) && !region.isMember(e.getPlayer().getName())) {
        for (String cmd : Utils.getComandosBloqueados(s[0], s[1])) {
            if (e.getMessage().startsWith(cmd)) {
                p.sendMessage(Utils.getMensagem("comando_bloqueado"));
                e.setCancelled(true);
                break;
            }
        }
    }
}
项目:QuestGUI    文件:DoCmd.java   
@EventHandler
public void onEvent(PlayerCommandPreprocessEvent e){
    String QuestName = Main.data.getString(e.getPlayer().getName() + ".temp-questname");
    DoCmd dc = new DoCmd(e.getPlayer(), QuestName);
    Player p = e.getPlayer();
    if(dc.isGoing() && dc.isObjective()){
        if(e.getMessage().contains(dc.getCommand(QuestName))){
            p.sendMessage(Main.PREFIX + "§e" + dc.getQuestName() + "§6퀘스트를 완료 하였습니다! NPC에게 찾아가보세요!");
            Main.data.set(p.getName() + "." + dc.getQuestName() + "-data", null);
            Main.data.set(p.getName() + ".temp-questname", null);
            Main.data.set(p.getName() + "." + dc.getQuestName() + "-ing", null);
            Main.data.set(p.getName() + "." + dc.getQuestName() + "-done", true);
            Main.saveconfig();
        }
    }
}
项目:BloodMoon    文件:DungeonListener.java   
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onPlayerCommand(PlayerCommandPreprocessEvent event) {
    Player player = event.getPlayer();
    String message = event.getMessage();
    World world = player.getWorld();
    PluginConfig worldConfig = plugin.getConfig(world);

    int spaceIndex = message.indexOf(' ');

    String command = (spaceIndex > 0) ? message.substring(1, spaceIndex) : message.substring(1);

    if (plugin.isFeatureEnabled(world, Feature.DISABLED_COMMANDS) && worldConfig.getStringList(Config.FEATURE_DISABLED_COMMANDS_COMMANDS).contains(command) && this.isProtected(player.getLocation())) {
        event.setCancelled(true);
        player.sendMessage(ChatColor.RED + "The /" + command + " is disabled in bloodmoon dungeons!");
    }
}
项目:TownyWands    文件:TownyWandsListener.java   
@EventHandler
public void onCommand(PlayerCommandPreprocessEvent e) {
    if(e.getMessage().trim().isEmpty() || e.getMessage().trim().length() < 2) return;

    String command = e.getMessage().substring(1, e.getMessage().length());
    Player p = e.getPlayer();

    if (!Inventories.exist(command)) return;
    e.setCancelled(true);

    ModularInventory inventory = Inventories.get(command);

    if (!p.hasPermission(inventory.getPermission())) {
        p.sendMessage(String.format("§cYou require the permission §a%s§c to be able to open the GUI §6'§r%s§6'§c!", inventory.getPermission(), inventory.getTitle()));
        return;
    }

    Inventories.display(inventory, p);
}
项目:RageMode    文件:EventListener.java   
@EventHandler
public void onCommand(PlayerCommandPreprocessEvent event) {
    if (PlayerList.isPlayerPlaying(event.getPlayer().getUniqueId().toString())
            && !event.getPlayer().hasPermission("ragemode.admin.cmd")) {
        if (event.getMessage() != null) {
            String cmd = event.getMessage().trim().toLowerCase();
            if (cmd.equals("/rm leave") || cmd.equals("/ragemode leave") || cmd.equals("/rm list")
                    || cmd.equals("/ragemode list") || cmd.equals("/rm stop") || cmd.equals("/ragemode stop")
                    || PluginLoader.getInGameCommands().contains(cmd)) {
                if (waitingGames.containsKey(PlayerList.getPlayersGame(event.getPlayer())))
                    if (waitingGames.get(PlayerList.getPlayersGame(event.getPlayer())))
                        event.setCancelled(true);
            } else {
                event.setCancelled(true);
            }
        }
    }
}
项目:CanaryBukkit    文件:CanaryPlayerListener.java   
@HookHandler(priority = Priority.CRITICAL, ignoreCanceled = true)
public void onCommand(final PlayerCommandHook hook) {
    String command = "";
    for (String s : hook.getCommand()) {
        command += s + " ";
    }
    PlayerCommandPreprocessEvent event =
            new PlayerCommandPreprocessEvent(new CanaryPlayer(hook.getPlayer()), command) {
                @Override
                public void setMessage(String msg) {
                    super.setMessage(msg);
                    // Set command
                }
            };
    event.setCancelled(hook.isCanceled());
    server.getPluginManager().callEvent(event);
    if (event.isCancelled()) {
        hook.setCanceled();
    }
    if (server.dispatchCommand(new CanaryCommandSender(hook.getPlayer()), command)) {
        hook.setCanceled(); //TODO: is this the best possible way?
    }
}
项目:SuperVanish    文件:EssentialsHook.java   
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onCommand(final PlayerCommandPreprocessEvent e) {
    if (!CommandAction.VANISH_SELF.checkPermission(e.getPlayer(), superVanish)) return;
    if (superVanish.getVanishStateMgr().isVanished(e.getPlayer().getUniqueId())) return;
    String command = e.getMessage().toLowerCase(Locale.ENGLISH).split(" ")[0].replace("/", "")
            .toLowerCase(Locale.ENGLISH);
    if (command.contains(":")) command = command.split(":")[1];
    if (command.equals("supervanish") || command.equals("sv")
            || command.equals("v") || command.equals("vanish")) {
        final User user = essentials.getUser(e.getPlayer());
        if (user == null || !user.isAfk()) return;
        user.setHidden(true);
        preVanishHiddenPlayers.add(e.getPlayer().getUniqueId());
        superVanish.getServer().getScheduler().runTaskLater(superVanish, new Runnable() {
            @Override
            public void run() {
                if (preVanishHiddenPlayers.remove(e.getPlayer().getUniqueId())) {
                    user.setHidden(false);
                }
            }
        }, 1);
    }
}
项目:buildinggame    文件:CommandBlocker.java   
/**
    * Handles blocked commands while in-game
    *
    * @param e an event representing a command executed
    * @see PlayerCommandPreprocessEvent
    * @since 2.1.0
    */
@EventHandler
public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent e) {
    Player player = e.getPlayer();
       String message = e.getMessage();

       if (ArenaManager.getInstance().getArena(player) == null || message.startsWith("/bg") ||
               message.startsWith("/buildinggame"))
        return;

    for (String string : SettingsManager.getInstance().getConfig().getStringList("command-whitelist")) {
        if (string.charAt(0) != '/')
            string = '/' + string;

        if (message.startsWith(string))
            return;
    }

    MessageManager.getInstance().send(player, SettingsManager.getInstance().getMessages()
               .getStringList("in-game.command-blocked"));

    e.setCancelled(true);
}
项目:AdvancedAchievements    文件:AchievePlayerCommandListener.java   
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPlayerCommand(PlayerCommandPreprocessEvent event) {
    Player player = event.getPlayer();

    if (!shouldIncreaseBeTakenIntoAccountNoPermissions(player)) {
        return;
    }

    MultipleAchievements category = MultipleAchievements.PLAYERCOMMANDS;

    List<String> equivalentCommands = getEquivalentCommands(event.getMessage());
    for (String prefix : plugin.getPluginConfig().getConfigurationSection(category.toString()).getKeys(false)) {
        for (String equivalentCommand : equivalentCommands) {
            if (equivalentCommand.startsWith(prefix)) {
                if (player.hasPermission(category.toPermName() + '.' + StringUtils.replace(prefix, " ", ""))) {
                    updateStatisticAndAwardAchievementsIfAvailable(player, category, prefix, 1);
                }
                return;
            }
        }
    }
}
项目:PermissionsShop    文件:PlayerListener.java   
@EventHandler(ignoreCancelled = true)
public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent e) {
    Lang lang = this.plugin.getLang();
    String command = e.getMessage();
    for(Shop shop : this.plugin.getShops().getShops()) {
        if(shop.getCommand().equalsIgnoreCase(command)) {
            Player p = e.getPlayer();
            e.setCancelled(true);
            if(this.hasPermission(p, shop.getPermission())) {
                if(this.plugin.getMoney(p) >= shop.getPrice()) this.openGUI(p, shop);
                else p.sendMessage(Placeholders.parse(lang.getNotEnoughMoney(), p));
            } else p.sendMessage(Placeholders.parse(lang.getShopNoPermission(), p));
            break;
        }
    }
}
项目:SupaCommons    文件:ServerShutdown.java   
@EventHandler(priority = EventPriority.LOWEST)
public void onServerCommandEvent(PlayerCommandPreprocessEvent event) {
  String message = event.getMessage();
  if (message.startsWith("/restart")) {
    if (!event.getPlayer().hasPermission(getRestartPermission())) {
      return;
    }
    ServerShutdown.this.run(true);
    event.setCancelled(true); // dont execute stop!
  } else if (message.startsWith("/stop")) {
    if (!event.getPlayer().hasPermission(getStopPermission())) {
      return;
    }
    ServerShutdown.this.run(false);
    event.setCancelled(true); // dont execute stop!
  }
}
项目:vanillacraft    文件:HomeCommand.java   
@EventHandler(priority = EventPriority.NORMAL)
public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event)
{
    if (!event.isCancelled())
    {
        Player player = event.getPlayer();
        String command[] = event.getMessage().split(" ");
        PlayerProfile profile = CoreData.getProfile(player);

        if (command[0].equalsIgnoreCase("/home"))
        {
            plugin.getCoreMethods().teleport(player, profile.getHomeLocation().toLocation());
        }

    }
}
项目:vanillacraft    文件:SpawnCommand.java   
@EventHandler(priority = EventPriority.NORMAL)
public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event)
{
    if (!event.isCancelled())
    {
        Player player = event.getPlayer();
        String command[] = event.getMessage().split(" ");

        if (command[0].equalsIgnoreCase("/spawn"))
        {
            if (player.getLocation().getWorld() == plugin.getCoreData().getSpawnLocation().getWorld())
            {
                plugin.getCoreMethods().teleport(player, plugin.getCoreData().getSpawnLocation());
            }
            else
            {
                plugin.getCoreErrors().mustBeInWorld(player, "main world");
            }
        }
    }
}
项目:vanillacraft    文件:Spy.java   
@EventHandler(priority = EventPriority.NORMAL)
public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event)
{
    if (!event.isCancelled())
    {
        Player player = event.getPlayer();
        String command[] = event.getMessage().split(" ");
        PlayerProfile profile = CoreData.getProfile(player);

        if (command[0].equalsIgnoreCase("/spy"))
        {
            if (profile.isModMode())
            {
                plugin.getCoreMethods().hidePlayer(player);
                player.sendMessage(ChatColor.GREEN + "You're now hidden from other players except people in mod mode.");
            }
            else
            {
                plugin.getCoreErrors().enableModMode(player);
            }
        }
    }
}
项目:vanillacraft    文件:God.java   
@EventHandler(priority = EventPriority.NORMAL)
public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event)
{
    if (!event.isCancelled())
    {
        Player player = event.getPlayer();
        String command[] = event.getMessage().split(" ");
        PlayerProfile profile = CoreData.getProfile(player);

        if (command[0].equalsIgnoreCase("/god"))
        {
            if (profile.isModMode())
            {
                //todo make this a var passed by user with reason
                profile.setData("Godmode", System.currentTimeMillis() + 1800000);
            }
            else
            {
                plugin.getCoreErrors().enableModMode(player);
            }
        }
    }
}
项目:PlotSquared-Chinese    文件:PlayerEvents.java   
@EventHandler
public void PlayerCommand(final PlayerCommandPreprocessEvent event) {
    final String message = event.getMessage().toLowerCase().replaceAll("/", "");
    String[] split = message.split(" ");
    PluginCommand cmd = Bukkit.getServer().getPluginCommand(split[0]);
    if (cmd != null) {
        return;
    }
    if (split[0].equals("plotme") || split[0].equals("ap")) {
        final Player player = event.getPlayer();
        if (Settings.USE_PLOTME_ALIAS) {
            player.performCommand("plots " + StringUtils.join(Arrays.copyOfRange(split, 1, split.length), " "));
        } else {
            MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.NOT_USING_PLOTME);
        }
        event.setCancelled(true);
    }
}
项目:BlockParty-1.8    文件:CommandListener.java   
@EventHandler
public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent e) {
    Player p = e.getPlayer();
    String[] commandArgs = e.getMessage().split("");

    if (BlockParty.inGamePlayers.containsKey(p.getName())) {
        if (!p.isOp()) {
            if (!p.hasPermission("blockparty.admin") || !p.hasPermission("blockparty.cmdbypass")) {
                if (!checkCommand(commandArgs[0]))
                    e.setCancelled(true);

            }
            return;
        } else {

        }
    }
}
项目:RegionLogger    文件:ERListener.java   
@EventHandler
public void onPlayerCommandPreprocessEvent(PlayerCommandPreprocessEvent event) {
    String n;
    Player p = event.getPlayer();
    n = p.getName();
    String[] label = event.getMessage().split(" ");
    if ((label[0].equalsIgnoreCase("/region") || label[0].equalsIgnoreCase("/rg"))) {StringBuilder builder = new StringBuilder();
        for (final String value : label) {builder.append(value + " ");
        }
        String eregion = builder.toString();
        Date now = new Date();
        SimpleDateFormat format = new SimpleDateFormat("MM-dd-yyyy HH:mm:ss");
        try {
            String filename = "regionlog.txt";
            FileWriter fw = new FileWriter(filename, true);
            fw.write(("[" + format.format(now) + "] " + eregion + "Staff: "+ n + System.getProperty("line.separator")));
            fw.close();
        } catch (final IOException e) {
            e.printStackTrace();
        }
    }
}
项目:IceBall    文件:IceBallLimitListener.java   
@EventHandler
public void noCommand(PlayerCommandPreprocessEvent e) {
        if(!plugin.hasSnowballPerms(e.getPlayer()) &&
                Utility.isInsideSnowball(e.getPlayer().getLocation(), plugin, false)) {
        String cmd = e.getMessage();
        if(cmd == null)
            return;
        cmd = cmd.indexOf(" ") != -1 ? cmd.substring(0, cmd.indexOf(" ")) : cmd;
        if(cmd.charAt(0) == '/' && cmd.length() > 1)
            cmd = cmd.substring(1);
        for(int i = 0; i < plugin.validCommands.length; i++) {
            if(cmd.equalsIgnoreCase(plugin.validCommands[i]))
                return;
        }
        e.setCancelled(true);
        e.getPlayer().sendMessage(ChatColor.DARK_AQUA + "You are only permitted to use /spawn, /home, and " +
                "/warp while in the Snowball arena.");
    }
}
项目:askygrid    文件:PlayerEvents.java   
/**
    * Prevents teleporting when falling based on setting by stopping commands
    * 
    * @param e
    */
   @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = false)
   public void onPlayerTeleport(final PlayerCommandPreprocessEvent e) {
if (DEBUG) {
    plugin.getLogger().info(e.getEventName());
}
if (Settings.allowTeleportWhenFalling || e.getPlayer().isOp() || !e.getPlayer().getGameMode().equals(GameMode.SURVIVAL)) {
    return;
}
if (!inASkyGridWorld(e.getPlayer().getWorld())) {
    return;
}
// Check commands
// plugin.getLogger().info("DEBUG: falling command: '" +
// e.getMessage().substring(1).toLowerCase() + "'");
if (isFalling(e.getPlayer().getUniqueId()) && Settings.fallingCommandBlockList.contains(e.getMessage().substring(1).toLowerCase())) {
    // Sorry you are going to die
    e.getPlayer().sendMessage(plugin.myLocale(e.getPlayer().getUniqueId()).gridcannotTeleport);
    e.setCancelled(true);
}
   }
项目:askygrid    文件:PlayerEvents.java   
/**
    * Prevents players from using commands like /spawner
    * @param e
    */
   @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = false)
   public void onPlayerCommand(final PlayerCommandPreprocessEvent e) {
if (DEBUG) {
    plugin.getLogger().info("Player command " + e.getEventName() + ": " + e.getMessage());
}
if (e.getPlayer().isOp() || VaultHelper.checkPerm(e.getPlayer(), Settings.PERMPREFIX + "mod.bannedcommands")) {
    return;
}
// Check world
if (!inASkyGridWorld(e.getPlayer().getWorld())) {
    return;
}
// Check banned commands
//plugin.getLogger().info(Settings.visitorCommandBlockList.toString());
String[] args = e.getMessage().substring(1).toLowerCase().split(" ");
if (Settings.bannedCommandList.contains(args[0])) {
    e.getPlayer().sendMessage(ChatColor.RED + plugin.myLocale(e.getPlayer().getUniqueId()).errorNoPermission);
    e.setCancelled(true);
}
   }
项目:GameDispenser    文件:Events.java   
@EventHandler(ignoreCancelled = true)
public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event) {
    if (GameManager.getGameManager().getGameForPlayer(event.getPlayer()) == null) {
        return;
    }

    String command = event.getMessage()
            .replaceAll("^/*", "") // Remove forward slash if exists
            .replaceAll(" .*", ""); // Remove anything after first word

    for (String s : GameDispenser.getInstance().getBlacklistedCommands()) {
        if (s.equalsIgnoreCase(command)) {
            event.getPlayer().sendMessage(FormatUtil.format("&4Cannot use that command while playing a game."));
            event.setCancelled(true);
            return;
        }
    }
}
项目:defend-the-village    文件:Main.java   
@EventHandler(priority = EventPriority.HIGHEST)
public void onCommandPre(PlayerCommandPreprocessEvent ev) {
    if (this.am.isInGame(ev.getPlayer())) {
        // Only if the player is in game
        boolean c = true;

        // Is it allowed?
        for (String com : this.allowedCommands) {
            if (ev.getMessage().toLowerCase().startsWith("/" + com)) {
                c = false;
            }
        }
        if (c)
            // If the command is not allowed, notify the user
            s(ev.getPlayer(), this.config.get("no_command_in_game"));
        ev.setCancelled(c);
    }
}
项目:ProSpam    文件:ChatListener.java   
@EventHandler(ignoreCancelled = true)
public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event)
{
    String txt = event.getMessage();

    for(String cmd: settings.filter_commands)
    {
        String cmdStr[] = txt.split(" ");

        if(cmdStr.length >= 1 && cmdStr[0].equalsIgnoreCase(cmd))
        {
            String filtered = filterText(event.getPlayer(), txt.substring(cmd.length()));

            if(filtered != null)
            {
                event.setMessage(cmd + filtered);
            }
            else
            {
                event.setCancelled(true);
            }

            return;
        }
    }
}
项目:acidisland    文件:PlayerEvents.java   
/**
 * Prevents teleporting when falling based on setting by stopping commands
 * 
 * @param e
 */
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onPlayerTeleport(final PlayerCommandPreprocessEvent e) {
    if (DEBUG) {
        plugin.getLogger().info(e.getEventName());
    }
    if (!IslandGuard.inWorld(e.getPlayer()) || Settings.allowTeleportWhenFalling || e.getPlayer().isOp()
            || !e.getPlayer().getGameMode().equals(GameMode.SURVIVAL)
            || plugin.getPlayers().isInTeleport(e.getPlayer().getUniqueId())) {
        return;
    }
    // Check commands
    // plugin.getLogger().info("DEBUG: falling command: '" +
    // e.getMessage().substring(1).toLowerCase() + "'");
    if (isFalling(e.getPlayer().getUniqueId()) && (Settings.fallingCommandBlockList.contains("*") || Settings.fallingCommandBlockList.contains(e.getMessage().substring(1).toLowerCase()))) {
        // Sorry you are going to die
        Util.sendMessage(e.getPlayer(), plugin.myLocale(e.getPlayer().getUniqueId()).errorNoPermission); 
        Util.sendMessage(e.getPlayer(), plugin.myLocale(e.getPlayer().getUniqueId()).islandcannotTeleport);
        e.setCancelled(true);
    }
}
项目:acidisland    文件:PlayerEvents.java   
/**
 * Prevents visitors from using commands on islands, like /spawner
 * @param e
 */
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onVisitorCommand(final PlayerCommandPreprocessEvent e) {
    if (DEBUG) {
        plugin.getLogger().info("Visitor command " + e.getEventName() + ": " + e.getMessage());
    }
    if (!IslandGuard.inWorld(e.getPlayer()) || e.getPlayer().isOp()
            || VaultHelper.checkPerm(e.getPlayer(), Settings.PERMPREFIX + "mod.bypassprotect")
            || plugin.getGrid().locationIsOnIsland(e.getPlayer(), e.getPlayer().getLocation())) {
        //plugin.getLogger().info("player is not in world or op etc.");
        return;
    }
    // Check banned commands
    //plugin.getLogger().info(Settings.visitorCommandBlockList.toString());
    String[] args = e.getMessage().substring(1).toLowerCase().split(" ");
    if (Settings.visitorCommandBlockList.contains(args[0])) {
        Util.sendMessage(e.getPlayer(), ChatColor.RED + plugin.myLocale(e.getPlayer().getUniqueId()).islandProtected);
        e.setCancelled(true);
    }
}
项目:BukkitLib    文件:PreprocessableCommand.java   
/**
 * Checks for this command as the preprocessed command.
 * @param event The command preprocessing event.
 */
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onPlayerCommandPreProcess(PlayerCommandPreprocessEvent event){
    if(getExecutor() == null){
        return;
    }

    String[] cmdAndArgs = event.getMessage().split(" ", 2);
    cmdAndArgs[0] = cmdAndArgs[0].toLowerCase().trim();
    for(String alias : _aliases){
        if(alias.equals(cmdAndArgs[0])){
            event.setCancelled(getExecutor().onCommand(event.getPlayer(), this, alias, cmdAndArgs.length == 1 ? new String[0] : cmdAndArgs[1].split(" ")));
            break;
        }
    }
}
项目:UltimateSurvivalGames    文件:PlayerListener.java   
@EventHandler
public void onPlayerCommand(PlayerCommandPreprocessEvent event) {
    Player p = event.getPlayer();
    if(um.isPlaying(p.getName()) || um.isSpectator(p.getName())) {
        String message = event.getMessage().toLowerCase();

        for(String cmd : allowedCmds) {
            if(message.startsWith(cmd))
                return;
        }
        if(message.startsWith("/list")) {
            UserState u = um.getUser(p.getName());
            if(u == null)
                u = um.getSpectator(p.getName());
            Game g = u.getGame();
            p.sendMessage(MessageHandler.getMessage("game-player-list").replace("%0%", Integer.valueOf(g.getPlayingUsers()).toString()).replace("%1%", g.getAlivePlayers()));
            event.setCancelled(true);
        } else if(message.startsWith("/vote")) {
            p.chat("/sg " + message.replace("/", ""));
            event.setCancelled(true);
        } else {
            event.setCancelled(true);
            p.sendMessage(MessageHandler.getMessage("forbidden-command"));
        }
    }
}
项目:askyblock    文件:PlayerEvents.java   
/**
 * Prevents teleporting when falling based on setting by stopping commands
 * 
 * @param e
 */
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onPlayerTeleport(final PlayerCommandPreprocessEvent e) {
    if (DEBUG) {
        plugin.getLogger().info(e.getEventName());
    }
    if (!IslandGuard.inWorld(e.getPlayer()) || Settings.allowTeleportWhenFalling || e.getPlayer().isOp()
            || !e.getPlayer().getGameMode().equals(GameMode.SURVIVAL)
            || plugin.getPlayers().isInTeleport(e.getPlayer().getUniqueId())) {
        return;
    }
    // Check commands
    // plugin.getLogger().info("DEBUG: falling command: '" +
    // e.getMessage().substring(1).toLowerCase() + "'");
    if (isFalling(e.getPlayer().getUniqueId()) && (Settings.fallingCommandBlockList.contains("*") || Settings.fallingCommandBlockList.contains(e.getMessage().substring(1).toLowerCase()))) {
        // Sorry you are going to die
        Util.sendMessage(e.getPlayer(), plugin.myLocale(e.getPlayer().getUniqueId()).errorNoPermission); 
        Util.sendMessage(e.getPlayer(), plugin.myLocale(e.getPlayer().getUniqueId()).islandcannotTeleport);
        e.setCancelled(true);
    }
}