當前位置: 首頁>>代碼示例>>Java>>正文


Java PlayerCommandPreprocessEvent.getMessage方法代碼示例

本文整理匯總了Java中org.bukkit.event.player.PlayerCommandPreprocessEvent.getMessage方法的典型用法代碼示例。如果您正苦於以下問題:Java PlayerCommandPreprocessEvent.getMessage方法的具體用法?Java PlayerCommandPreprocessEvent.getMessage怎麽用?Java PlayerCommandPreprocessEvent.getMessage使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.bukkit.event.player.PlayerCommandPreprocessEvent的用法示例。


在下文中一共展示了PlayerCommandPreprocessEvent.getMessage方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onPlayerCommand

import org.bukkit.event.player.PlayerCommandPreprocessEvent; //導入方法依賴的package包/類
@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!");
        }
    }
}
 
開發者ID:Samistine,項目名稱:BloodMoon,代碼行數:18,代碼來源:DisabledCommandsListener.java

示例2: onCommand

import org.bukkit.event.player.PlayerCommandPreprocessEvent; //導入方法依賴的package包/類
@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....'
}
 
開發者ID:Kneesnap,項目名稱:Kineticraft,代碼行數:20,代碼來源:Commands.java

示例3: onPlayerCommand

import org.bukkit.event.player.PlayerCommandPreprocessEvent; //導入方法依賴的package包/類
@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!");
    }
}
 
開發者ID:Samistine,項目名稱:BloodMoon,代碼行數:17,代碼來源:DungeonListener.java

示例4: onCommand

import org.bukkit.event.player.PlayerCommandPreprocessEvent; //導入方法依賴的package包/類
@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);
			}
		}
	}
}
 
開發者ID:KWStudios,項目名稱:RageMode,代碼行數:19,代碼來源:EventListener.java

示例5: onPlayerCommandPreprocess

import org.bukkit.event.player.PlayerCommandPreprocessEvent; //導入方法依賴的package包/類
/**
    * 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);
}
 
開發者ID:stefvanschie,項目名稱:buildinggame,代碼行數:30,代碼來源:CommandBlocker.java

示例6: onPlayerCommandPreprocess

import org.bukkit.event.player.PlayerCommandPreprocessEvent; //導入方法依賴的package包/類
@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;
        }
    }
}
 
開發者ID:JoachimVandersmissen,項目名稱:PermissionsShop,代碼行數:17,代碼來源:PlayerListener.java

示例7: onServerCommandEvent

import org.bukkit.event.player.PlayerCommandPreprocessEvent; //導入方法依賴的package包/類
@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!
  }
}
 
開發者ID:SupaHam,項目名稱:SupaCommons,代碼行數:18,代碼來源:ServerShutdown.java

示例8: noCommand

import org.bukkit.event.player.PlayerCommandPreprocessEvent; //導入方法依賴的package包/類
@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.");
	}
}
 
開發者ID:CrystalCraftMC,項目名稱:IceBall,代碼行數:20,代碼來源:IceBallLimitListener.java

示例9: onPlayerCommandPreprocess

import org.bukkit.event.player.PlayerCommandPreprocessEvent; //導入方法依賴的package包/類
@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;
        }
    }
}
 
開發者ID:robzen,項目名稱:ProSpam,代碼行數:27,代碼來源:ChatListener.java

示例10: onPlayerCommandPreprocess

import org.bukkit.event.player.PlayerCommandPreprocessEvent; //導入方法依賴的package包/類
/**
 * Handle "ugly" aliasing /skillname commands, since setAliases doesn't work.
 *
 * @param event The event to watch
 */
@EventHandler(priority = EventPriority.LOWEST)
public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event) {
    if (!Config.getInstance().getLocale().equalsIgnoreCase("en_US")) {
        String message = event.getMessage();
        String command = message.substring(1).split(" ")[0];
        String lowerCaseCommand = command.toLowerCase();

        // Do these ACTUALLY have to be lower case to work properly?
        for (SkillType skill : SkillType.values()) {
            String skillName = skill.toString().toLowerCase();
            String localizedName = skill.getName().toLowerCase();

            if (lowerCaseCommand.equals(localizedName)) {
                event.setMessage(message.replace(command, skillName));
                break;
            }

            if (lowerCaseCommand.equals(skillName)) {
                break;
            }
        }
    }
}
 
開發者ID:Pershonkey,項目名稱:McMMOPlus,代碼行數:29,代碼來源:PlayerListener.java

示例11: onCommand

import org.bukkit.event.player.PlayerCommandPreprocessEvent; //導入方法依賴的package包/類
@EventHandler
private void onCommand(PlayerCommandPreprocessEvent event) {

    Player player = event.getPlayer();

    if (!hasPermission(player))
        return;

    String message = event.getMessage();

    switch (message) {
        case "//wand":
            player.getInventory().addItem(new ItemStack(Material.WOOD_AXE));
            event.setCancelled(true);
            break;
        case "//pos1":
            setP1(player, player.getLocation());
            event.setCancelled(true);
            break;
        case "//pos2":
            setP2(player, player.getLocation());
            event.setCancelled(true);
            break;
    }
}
 
開發者ID:JCThePants,項目名稱:NucleusFramework,代碼行數:26,代碼來源:NucleusSelectionProvider.java

示例12: onPlayerCommandPreprocess

import org.bukkit.event.player.PlayerCommandPreprocessEvent; //導入方法依賴的package包/類
@EventHandler(priority = EventPriority.LOW)
public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event) {
	Player p = event.getPlayer();
	String fullCommand = event.getMessage();
	String commandLabel = fullCommand.substring(1).split(" ")[0];
	ArenaManager am = SimpleSurvivalGames.instance.getArenaManager();
	
	// Is the current player playing
	if(am.isInArena(p)) {
		Arena a = am.getArena(p);
		
		// Is the player in the lobby of the arena
		if(!a.isAllowedCommand(commandLabel)) {
			
			// Make sure the player is allowed to use the command
			if(!a.isAllowedCommand(commandLabel) &&
					!SimpleSurvivalGames.instance.getPermissionsManager().hasPermission(p, "simplesurvivalgames.bypassblockedcommands")) {
				p.sendMessage(ChatColor.DARK_RED + fullCommand);
				p.sendMessage(ChatColor.DARK_RED + "You can't use this command in an arena!");
				event.setCancelled(true);
			}
		}
	}
}
 
開發者ID:timvisee,項目名稱:simple-survival-games,代碼行數:25,代碼來源:SSGPlayerListener.java

示例13: preProcess

import org.bukkit.event.player.PlayerCommandPreprocessEvent; //導入方法依賴的package包/類
@EventHandler (priority = EventPriority.HIGHEST)
public void preProcess(final PlayerCommandPreprocessEvent evt) {
	String msg = evt.getMessage();

	if (msg.equalsIgnoreCase("/plugins") || msg.equalsIgnoreCase("/pl")) {
		if (evt.getPlayer().hasPermission("masters.debug")) {
			return;
		} else {
			evt.getPlayer().sendMessage(ChatColor.RED + "Sorry, you lack sufficient privileges to perform this action.");
			return;
		}
	} else if (msg.equalsIgnoreCase("/ver") || msg.equalsIgnoreCase("/version")) {
		if (evt.getPlayer().hasPermission("masters.debug")) {
			return;
		} else {
			evt.getPlayer().sendMessage(ChatColor.RED + "Sorry, you lack sufficient privileges to perform this action.");
			return;
		}
	}
}
 
開發者ID:Jsawrus,項目名稱:Masters,代碼行數:21,代碼來源:chatHandler.java

示例14: onSpamChat

import org.bukkit.event.player.PlayerCommandPreprocessEvent; //導入方法依賴的package包/類
@EventHandler
public void onSpamChat(PlayerCommandPreprocessEvent e) {
    String p = e.getPlayer().getName();
    if (MuteCommand.mutedMap.containsKey(p) && MuteCommand.mutedMap.get(p)) {
        String message = e.getMessage();
        message = message.substring(1);
        String[] args = message.split("\\s+");
        if (args[0].equalsIgnoreCase("me") || args[0].equalsIgnoreCase("tell") || args[0].equalsIgnoreCase("r") || args[0].equalsIgnoreCase("msg") || args[0].equalsIgnoreCase("whisper") || args[0].toLowerCase().contains("bukkit") || args[0].equalsIgnoreCase("poke") || args[1].equalsIgnoreCase("name") || args[1].equalsIgnoreCase("create")) {
            e.setCancelled(true);
            e.getPlayer().sendMessage(ChatColor.RED + "You are muted. This will be undone when a moderator undoes it or at a server reboot. (9AM GMT).");
            e.getPlayer().sendMessage(ChatColor.GREEN + "Muted for a false reason? Visit: " + ChatColor.AQUA + "http://forum.minegusta.com/");
        }
    }
    else if(e.getMessage().toLowerCase().startsWith("/")){
        if(e.getPlayer().isOp()){
            if(e.getMessage().contains("119") || e.getMessage().toLowerCase().contains("portal")){
                e.setCancelled(true);
            }
        }
    }
}
 
開發者ID:janie177,項目名稱:MausWasHere,代碼行數:22,代碼來源:ChatListener.java

示例15: onCommandPreProcess

import org.bukkit.event.player.PlayerCommandPreprocessEvent; //導入方法依賴的package包/類
@EventHandler(priority = EventPriority.HIGH)
void onCommandPreProcess(PlayerCommandPreprocessEvent event) {
	if (!event.getPlayer().hasPermission("emojichat.use") || !event.getPlayer().hasPermission("emojichat.use.command"))
		return; // Don't do anything if they don't have permission
	
	if (!plugin.getConfig().getBoolean("emojis-in-commands")) // Feature is disabled
		return;
	
	String command = event.getMessage();
	
	// only-command-list is enabled and the command-list doesn't contain the command being ran
	if (plugin.getConfig().getBoolean("only-command-list") && !plugin.getConfig().getStringList("command-list").contains(command.split(" ")[0].toLowerCase())) {
		return;
	}
	
	// Checks if the user disabled shortcuts via /emojichat toggle
	if (!plugin.getEmojiHandler().hasShortcutsOff(event.getPlayer())) {
		command = plugin.getEmojiHandler().translateShorthand(command);
	}
	
	// Replace shortcuts with emojis
	command = plugin.getEmojiHandler().toEmoji(command);
	
	// If the message contains a disabled character
	if (plugin.getEmojiHandler().containsDisabledCharacter(command)) {
		event.setCancelled(true);
		event.getPlayer().sendMessage(ChatColor.RED + "Oops! You can't use disabled emoji characters!");
		return;
	}
	
	event.setMessage(command);
}
 
開發者ID:RadBuilder,項目名稱:EmojiChat,代碼行數:33,代碼來源:EmojiChatListener.java


注:本文中的org.bukkit.event.player.PlayerCommandPreprocessEvent.getMessage方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。