本文整理汇总了Java中org.bukkit.event.player.PlayerCommandPreprocessEvent.setMessage方法的典型用法代码示例。如果您正苦于以下问题:Java PlayerCommandPreprocessEvent.setMessage方法的具体用法?Java PlayerCommandPreprocessEvent.setMessage怎么用?Java PlayerCommandPreprocessEvent.setMessage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.event.player.PlayerCommandPreprocessEvent
的用法示例。
在下文中一共展示了PlayerCommandPreprocessEvent.setMessage方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onCommand
import org.bukkit.event.player.PlayerCommandPreprocessEvent; //导入方法依赖的package包/类
@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");
}
}
示例2: 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;
}
}
}
示例3: 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;
}
}
}
}
示例4: onCommand
import org.bukkit.event.player.PlayerCommandPreprocessEvent; //导入方法依赖的package包/类
@EventHandler
public void onCommand(PlayerCommandPreprocessEvent e) {
String cmd = e.getMessage().substring(1);
String[] args = new String[] {};
if (cmd.contains(" ")) {
cmd = cmd.split(" ")[0];
args = e.getMessage().substring(e.getMessage().indexOf(' ') + 1).split(" ");
}
EyeCommand command = commands.get(cmd.toLowerCase());
ClientCore client = new ClientCore(e.getPlayer());
if (client == null) {
e.setCancelled(true);
e.getPlayer().sendMessage(D.M("Message", "Unable to process your request!"));
return;
}
if (command != null) {
if (client.GetRank().getPower() >= command.getRank().getPower()) {
e.setCancelled(true);
command.setUsedAlias(cmd.toLowerCase());
command.setName(command.getName());
command.execute(client, args);
} else {
e.setCancelled(true);
e.setMessage(Rank.perm(command.getRank()));
}
}
}
示例5: 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);
}
示例6: on
import org.bukkit.event.player.PlayerCommandPreprocessEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.LOWEST)
public void on(PlayerCommandPreprocessEvent event)
{
String command = event.getMessage();
if (intercept(event.getPlayer(), event.getMessage(), event))
{
event.setMessage(collapse(command));
}
}
示例7: onCommandExecute
import org.bukkit.event.player.PlayerCommandPreprocessEvent; //导入方法依赖的package包/类
@EventHandler
public void onCommandExecute(PlayerCommandPreprocessEvent event) {
String cmd = event.getMessage().substring(1, event.getMessage().length());
if(cmd.contains(" ")) {
String[] split = org.apache.commons.lang.StringUtils.split(cmd, ' ');
cmd = split[0];
}
final NovaPlayer nPlayer = PlayerManager.getPlayer(event.getPlayer());
if(!nPlayer.getPreferences().getBypass() && Config.REGION_BLOCKEDCMDS.getStringList().contains(cmd.toLowerCase())
&& nPlayer.isAtRegion()
&& (!nPlayer.hasGuild() || !nPlayer.getAtRegion().getGuild().isMember(nPlayer) && !nPlayer.getAtRegion().getGuild().isAlly(nPlayer.getGuild()))) {
Message.CHAT_REGION_BLOCKEDCMD.send(event.getPlayer());
event.setCancelled(true);
}
if(plugin.getCommandManager().existsAlias(cmd)) {
event.setMessage(event.getMessage().replaceFirst(cmd, plugin.getCommandManager().getMainCommand(cmd)));
}
//Essentials vanish status change detect
if(plugin.getDependencyManager().isEnabled(Dependency.ESSENTIALS)
&& (cmd.equalsIgnoreCase("vanish")
|| cmd.equalsIgnoreCase("v")
|| cmd.equalsIgnoreCase("essentials:vanish")
|| cmd.equalsIgnoreCase("essentials:v"))) {
NovaGuilds.runTask(new Runnable() {
@Override
public void run() {
plugin.getRegionManager().checkAtRegionChange(nPlayer);
}
});
}
}
示例8: onCommandPreprocessed
import org.bukkit.event.player.PlayerCommandPreprocessEvent; //导入方法依赖的package包/类
/**
* <ul>
* <li>Prevents a command being executed if the player is a spectator and the option is set in the config;</li>
* <li>Catches /me commands to show them in the spectator chat (if the user isn't shouting);</li>
* <li>Allows specified commands from the whitelist section to be executed.</li>
*/
@EventHandler (priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onCommandPreprocessed(PlayerCommandPreprocessEvent ev)
{
final Spectator spectator = p.getPlayerData(ev.getPlayer());
if (!spectator.isSpectating())
return;
if (Toggles.CHAT_ENABLED.get() && ev.getMessage().toLowerCase().startsWith("/me "))
{
// Spectators with the appropriate permission can shout /me messages too (e.g. "/me !hi")
if(Toggles.CHAT_SHOUT_ENABLED.get()
&& ev.getMessage().startsWith("/me " + Toggles.CHAT_SHOUT_PREFIX.get())
&& Permissions.CHAT_SHOUT.grantedTo(ev.getPlayer()))
{
// Spectator SHOUT - trim off the SHOUT_PREFIX leaving the actual message
ev.setMessage(ev.getMessage().replaceFirst(Toggles.CHAT_SHOUT_PREFIX.get(), ""));
}
else
{
// Spectator CHAT (action)
ev.setCancelled(true);
p.getSpectatorsManager().getChatManager().sendSpectatorsChatMessage(ev.getPlayer(), ev.getMessage().substring(4), true);
}
}
else if (Toggles.CHAT_BLOCKCOMMANDS_ENABLED.get() && !p.getSpectatorsManager().getChatManager().isCommandWhitelisted(ev.getMessage(), ev.getPlayer()))
{
ev.setCancelled(true);
p.sendMessage(ev.getPlayer(), "You are not allowed to send this command while in spectator mode.", true);
}
}
示例9: onCommand
import org.bukkit.event.player.PlayerCommandPreprocessEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void onCommand(PlayerCommandPreprocessEvent event) {
event.setMessage("/" + attemptRebind(event.getMessage().substring(1)));
}
示例10: onPlayerCommand
import org.bukkit.event.player.PlayerCommandPreprocessEvent; //导入方法依赖的package包/类
@EventHandler
public void onPlayerCommand(PlayerCommandPreprocessEvent e) {
for (Player p : Vars.main.getServer().getOnlinePlayers()) {
CommandFilter filter = Vars.commandSpy.get(p);
if (filter != null) {
if (filter.canPass(e)) {
p.sendMessage(ChatColor.RED + e.getPlayer().getName() + ChatColor.GRAY + " performed the command: " + ChatColor.GREEN + e.getMessage());
}
}
}
if (Util.startsWithIgnoreCase(e.getMessage(), "/suicide")) {
e.setCancelled(true);
e.getPlayer().setHealth(0);
Bukkit.getServer().broadcastMessage(ChatColor.BLUE + e.getPlayer().getName() + ChatColor.DARK_PURPLE + " took the easy way out!");
}
if (Util.startsWithIgnoreCase(e.getMessage(), "/reload")){
e.setCancelled(true);
e.getPlayer().sendMessage(ChatColor.RED + "This command is currently disabled.");
}
if (Util.startsWithIgnoreCase(e.getMessage(), "/plots ") || Util.startsWithIgnoreCase(e.getMessage(), "/cr")) {
e.setCancelled(true);
e.getPlayer().performCommand("warp plots");
}
if (Util.startsWithIgnoreCase(e.getMessage(), "/info")) {
e.setCancelled(true);
Bukkit.dispatchCommand(e.getPlayer(), "warp info");
}
if (Util.startsWithIgnoreCase(e.getMessage(), "/p ") && !e.getPlayer().hasPermission("voxelsniper.sniper")) {
e.setMessage("/plotsquared:" + e.getMessage().substring(1,e.getMessage().length()));
}
if (Util.startsWithIgnoreCase(e.getMessage(), "/pex")) {
Bukkit.getScheduler().scheduleSyncDelayedTask(Util.getMain(), new Runnable() {
public void run() {
Util.updatePlayerList();
}
}, 20L);
}
}
示例11: onCommandSent
import org.bukkit.event.player.PlayerCommandPreprocessEvent; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
@EventHandler
public void onCommandSent(final PlayerCommandPreprocessEvent e) {
if (e.getMessage().toLowerCase().startsWith("/plot")) {
if (e.getPlayer().getWorld().getName().equals("Build")) {
if (!e.getMessage().toLowerCase().startsWith("/plotme"))
e.setMessage("/plotme" + e.getMessage().substring(5, e.getMessage().length()));
final boolean tp;
if (e.getMessage().toLowerCase().startsWith("/plotme auto")) {
tp = true;
} else {
tp = false;
}
final Location playerLoc = e.getPlayer().getLocation();
plugin.getServer().getScheduler()
.scheduleAsyncDelayedTask(plugin, new Runnable() {
@Override
public void run() {
if (tp && e.getPlayer().getLocation() != playerLoc)
e.getPlayer().teleport(
e.getPlayer().getLocation().clone()
.add(0, 0, 5));
attemptConnection(e.getPlayer());
}
}, 5);
if (e.getMessage().toLowerCase().startsWith("/plotme update")) {
e.getPlayer().sendMessage(
ChatColor.BLUE + "[PlotMe] " + ChatColor.WHITE
+ "Plot updated relative to plots around it.");
e.setCancelled(true);
}
if (e.getMessage().toLowerCase().startsWith("/plotme clear")) {
if (e.getPlayer().hasPermission("plotme.admin")) {
e.getPlayer().sendMessage(
ChatColor.BLUE + "[PlotMe] " + ChatColor.WHITE
+ "Plot resetting...");
Bukkit.getServer().dispatchCommand(e.getPlayer(), "plotme claim");
Bukkit.getServer().dispatchCommand(e.getPlayer(), "plotme clear");
Bukkit.getServer().dispatchCommand(e.getPlayer(), "plotme dispose");
e.setCancelled(true);
}
}
if (e.getMessage().toLowerCase().startsWith("/plotme dispose")) {
Bukkit.getServer().dispatchCommand(e.getPlayer(), "plotme clear");
}
}
}
}
示例12: onPreprocess
import org.bukkit.event.player.PlayerCommandPreprocessEvent; //导入方法依赖的package包/类
@EventHandler
public void onPreprocess(PlayerCommandPreprocessEvent e) {
if(e.getMessage().startsWith("/")) {
e.setMessage(ipcheck(e.getMessage(), pl.getManagers().getPlayerManager().getPlayer(e.getPlayer().getName())));
}
}
示例13: onCmd
import org.bukkit.event.player.PlayerCommandPreprocessEvent; //导入方法依赖的package包/类
@EventHandler
public void onCmd(PlayerCommandPreprocessEvent e) {
if (getPlugin().aliases.contains(e.getMessage().replace("/", "")
.toLowerCase()))
e.setMessage("/da toggle");
}
示例14: onPlayerCommand
import org.bukkit.event.player.PlayerCommandPreprocessEvent; //导入方法依赖的package包/类
@EventHandler(priority=EventPriority.LOWEST)
private void onPlayerCommand(PlayerCommandPreprocessEvent event) {
IArenaPlayer player = ArenaPlayer.get(event.getPlayer());
if (player == null)
return;
IArena arena = player.getArena();
if (arena == null)
return;
Set<String> pvStarCommands = PVStarAPI.getPlugin().getDescription().getCommands().keySet();
String[] comp = TextUtils.PATTERN_SPACE.split(event.getMessage());
Matcher matcher = TextUtils.PATTERN_FILEPATH_SLASH.matcher(comp[0]);
String command = matcher.replaceFirst("").toLowerCase();
PlayerCommandEvent cmdEvent = new PlayerCommandEvent(
arena, player, player.getContextManager(), command, !pvStarCommands.contains(command));
arena.getEventManager().call(this, cmdEvent);
if (cmdEvent.isCancelled()) {
event.setMessage("/");
event.setCancelled(true);
Msg.tell(event.getPlayer(), Lang.get(_COMMAND_NOT_IN_ARENA));
}
}