当前位置: 首页>>代码示例>>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;未经允许,请勿转载。