当前位置: 首页>>代码示例>>Java>>正文


Java PlayerCommandPreprocessEvent.isCancelled方法代码示例

本文整理汇总了Java中org.bukkit.event.player.PlayerCommandPreprocessEvent.isCancelled方法的典型用法代码示例。如果您正苦于以下问题:Java PlayerCommandPreprocessEvent.isCancelled方法的具体用法?Java PlayerCommandPreprocessEvent.isCancelled怎么用?Java PlayerCommandPreprocessEvent.isCancelled使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.bukkit.event.player.PlayerCommandPreprocessEvent的用法示例。


在下文中一共展示了PlayerCommandPreprocessEvent.isCancelled方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onCommand

import org.bukkit.event.player.PlayerCommandPreprocessEvent; //导入方法依赖的package包/类
@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?
    }
}
 
开发者ID:CanaryBukkitTeam,项目名称:CanaryBukkit,代码行数:24,代码来源:CanaryPlayerListener.java

示例2: onPlayerCommandPreprocess

import org.bukkit.event.player.PlayerCommandPreprocessEvent; //导入方法依赖的package包/类
@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());
        }

    }
}
 
开发者ID:Vanillacraft,项目名称:vanillacraft,代码行数:17,代码来源:HomeCommand.java

示例3: onPlayerCommandPreprocess

import org.bukkit.event.player.PlayerCommandPreprocessEvent; //导入方法依赖的package包/类
@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");
            }
        }
    }
}
 
开发者ID:Vanillacraft,项目名称:vanillacraft,代码行数:22,代码来源:SpawnCommand.java

示例4: onPlayerCommandPreprocess

import org.bukkit.event.player.PlayerCommandPreprocessEvent; //导入方法依赖的package包/类
@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);
            }
        }
    }
}
 
开发者ID:Vanillacraft,项目名称:vanillacraft,代码行数:24,代码来源:Spy.java

示例5: onPlayerCommandPreprocess

import org.bukkit.event.player.PlayerCommandPreprocessEvent; //导入方法依赖的package包/类
@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);
            }
        }
    }
}
 
开发者ID:Vanillacraft,项目名称:vanillacraft,代码行数:24,代码来源:God.java

示例6: onAction

import org.bukkit.event.player.PlayerCommandPreprocessEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.MONITOR)
public void onAction(PlayerCommandPreprocessEvent e) {
    if (e.isCancelled()) return;
    boolean isAction = false;
    String commandUsed = "";
    for (String start : Config.actionAliases) {
        if (!e.getMessage().startsWith(start)) continue;
        isAction = true;
        commandUsed = start;
        break;
    }
    if (!isAction) return;
    String message = Config.btiAction;
    message = replaceVars(e, message);
    message = message.replace("{message}", e.getMessage().substring(commandUsed.length()));
    plugin.bh.sendMessage(message);
}
 
开发者ID:RoyalDev,项目名称:RoyalIRC,代码行数:18,代码来源:BChatListener.java

示例7: PlayerPreCommandHiddenPassword

import org.bukkit.event.player.PlayerCommandPreprocessEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void PlayerPreCommandHiddenPassword(final PlayerCommandPreprocessEvent event)
{
	if (!plugin.isHidingPasswordsFromConsoleEnabled())
		return;
	final Player player = event.getPlayer();
	final String message = event.getMessage().substring(1).toLowerCase();
	final String[] split = PATTERN_SPACE.split(message);
	final PluginCommand login = plugin.getCommand("login");
	if (event.isCancelled())
		return;
	if ("login".equals(split[0]) || login.getAliases().contains(split[0]))
	{
		login.execute(player, split[0], ChatHelperExtended.shiftArray(split, 1));
		event.setCancelled(true);
		return;
	}
	final PluginCommand register = plugin.getCommand("register");
	if ("register".equals(split[0]) || register.getAliases().contains(split[0]) || message.startsWith("cl password") || message.startsWith("crazylogin password"))
	{
		register.execute(player, split[0], ChatHelperExtended.shiftArray(split, 1));
		event.setCancelled(true);
		return;
	}
}
 
开发者ID:ST-DDT,项目名称:CrazyLogin,代码行数:26,代码来源:DynamicPlayerListener.java

示例8: processCommands

import org.bukkit.event.player.PlayerCommandPreprocessEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.MONITOR)
public void processCommands(PlayerCommandPreprocessEvent evt) {
    if (evt.isCancelled() || evt.isAsynchronous()) return;
    
    Command cmd = CommandFactory.commands.get(evt.getMessage());
    if (cmd == null || cmd instanceof ConsoleOnly) return;
    
    cmd.run(evt.getPlayer());
}
 
开发者ID:Recraft,项目名称:Recreator,代码行数:10,代码来源:Recreator.java

示例9: input

import org.bukkit.event.player.PlayerCommandPreprocessEvent; //导入方法依赖的package包/类
/**
 * Input Listener
 *
 * @param event Event
 */
@EventHandler(priority = EventPriority.HIGHEST)
public void input(PlayerCommandPreprocessEvent event) {
    if (!event.isCancelled() && enabled && input.keySet().contains(event.getPlayer().getUniqueId())) {
        JSONObject json = new JSONObject();
        json.put("message", event.getMessage());
        input.get(event.getPlayer().getUniqueId()).run(json);
        input.remove(event.getPlayer().getUniqueId());
        event.setCancelled(true);
    }
}
 
开发者ID:ME1312,项目名称:SubServers-2,代码行数:16,代码来源:InternalUIHandler.java

示例10: onxAuthLogin

import org.bukkit.event.player.PlayerCommandPreprocessEvent; //导入方法依赖的package包/类
@EventHandler
public void onxAuthLogin(PlayerCommandPreprocessEvent event) {
	if (event.isCancelled())
		return;
	String cmd = event.getMessage().split(" ")[0];
	if (!cmd.equalsIgnoreCase("/register") && !cmd.equalsIgnoreCase("/login"))
		return;
	final Player player = event.getPlayer();
	plugin.getServer().getScheduler().runTaskLater(plugin, new Runnable() {
		public void run() {
			playerLogin(player);
		}
	}, 10L);
}
 
开发者ID:CryLegend,项目名称:AuthMeBridge,代码行数:15,代码来源:xAuthBridgeListener.java

示例11: on

import org.bukkit.event.player.PlayerCommandPreprocessEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void on(PlayerCommandPreprocessEvent e)
{
	if(e.isCancelled())
	{
		return;
	}

	if(processCommand(e.getPlayer(), getParameters(e.getMessage())))
	{
		e.setCancelled(true);
	}
}
 
开发者ID:PhantomAPI,项目名称:Phantom,代码行数:14,代码来源:CommandSVC.java

示例12: onCommandPreprocess

import org.bukkit.event.player.PlayerCommandPreprocessEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.MONITOR)
public void onCommandPreprocess(PlayerCommandPreprocessEvent event) {
    if(!event.isCancelled()) {
        if (event.getPlayer().hasMetadata("SGCmd")) {
            event.getPlayer().performCommand(event.getMessage().substring(1));
            event.getPlayer().removeMetadata("SGCmd", this);
        }
    }
}
 
开发者ID:itstake,项目名称:SteakGUI,代码行数:10,代码来源:SteakGUI.java

示例13: handleCommand

import org.bukkit.event.player.PlayerCommandPreprocessEvent; //导入方法依赖的package包/类
private void handleCommand(String s) {
    org.bukkit.craftbukkit.SpigotTimings.playerCommandTimer.startTiming(); // Spigot
    // CraftBukkit start
    CraftPlayer player = this.getPlayer();

    PlayerCommandPreprocessEvent event = new PlayerCommandPreprocessEvent(player, s, new LazyPlayerSet());
    this.server.getPluginManager().callEvent(event);

    if (event.isCancelled()) {
        org.bukkit.craftbukkit.SpigotTimings.playerCommandTimer.stopTiming(); // Spigot
        return;
    }

    try {
        // Spigot Start
        if ( org.spigotmc.SpigotConfig.logCommands )
        {
            this.minecraftServer.getLogger().info(event.getPlayer().getName() + " issued server command: " + event.getMessage()); // CraftBukkit
        }
        // Spigot end
        if (this.server.dispatchCommand(event.getPlayer(), event.getMessage().substring(1))) {
            org.bukkit.craftbukkit.SpigotTimings.playerCommandTimer.stopTiming(); // Spigot
            return;
        }
    } catch (org.bukkit.command.CommandException ex) {
        player.sendMessage(org.bukkit.ChatColor.RED + "An internal error occurred while attempting to perform this command");
        java.util.logging.Logger.getLogger(PlayerConnection.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        org.bukkit.craftbukkit.SpigotTimings.playerCommandTimer.stopTiming(); // Spigot
        return;
    }
    org.bukkit.craftbukkit.SpigotTimings.playerCommandTimer.stopTiming(); // Spigot
    // CraftBukkit end

    /* CraftBukkit start - No longer needed as we have already handled it in server.dispatchServerCommand above.
    this.minecraftServer.getCommandHandler().a(this.player, s);
    // CraftBukkit end */
}
 
开发者ID:AlmuraDev,项目名称:Almura-Server,代码行数:38,代码来源:PlayerConnection.java

示例14: onPlayerCommandPreprocessEvent

import org.bukkit.event.player.PlayerCommandPreprocessEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.LOWEST)
private final void onPlayerCommandPreprocessEvent(final PlayerCommandPreprocessEvent event) {
	if(event.isCancelled()) {
		return;
	}
	final Player player = event.getPlayer();
	if(!player.hasPermission("commandscosts.bypass")) {
		return;
	}
	final String rawCost = config.commands.get(event.getMessage().substring(1).split(" ")[0]);
	if(rawCost == null) {
		return;
	}
	final Double cost = Utils.doubleTryParse(rawCost);
	if(cost == null) {
		return;
	}
	if(!SkyowalletAPI.hasAccount(player)) {
		player.sendMessage(Skyowallet.messages.message33);
		return;
	}
	final SkyowalletAccount account = SkyowalletAPI.getAccount(player);
	final double wallet = account.getWallet() - cost;
	if(wallet < 0.0) {
		player.sendMessage(PlaceholderFormatter.format(config.message1, new Placeholder("/cost/", String.valueOf(cost)), new CurrencyNamePlaceholder(cost)));
		event.setCancelled(true);
		return;
	}
	account.setWallet(wallet);
}
 
开发者ID:Skyost,项目名称:Skyowallet,代码行数:31,代码来源:CommandsCosts.java

示例15: onPlayerCommand

import org.bukkit.event.player.PlayerCommandPreprocessEvent; //导入方法依赖的package包/类
protected void onPlayerCommand(PlayerCommandPreprocessEvent event) {
    if (event.isCancelled() || !FactionChat.FactionsEnable) {
        return;
    }
    String message = event.getMessage();
    String[] split = message.split(" ");
    if (split.length < 2) {
        return;
    }
    if (split[0].equalsIgnoreCase("/factions") || split[0].equalsIgnoreCase(("/" + plugin.FactionsCommand))) {
        if (split[1].equalsIgnoreCase("chat") || split[1].equalsIgnoreCase("c")) {
            event.setCancelled(true);
            Player player = event.getPlayer();
            String senderFaction = FactionChat.factionsAPI.getFactionName(player);
            if (senderFaction.contains("Wilderness") && !player.hasPermission("FactionChat.UserAssistantChat")
                    && !plugin.isDebugger(player.getName())) {
                //checks if player is in a faction
                //mangaddp juniormoderators FactionChat.JrModChat
                player.sendMessage(ChatColor.RED + Config.messageNotInFaction);
                return;
            }
            if (split.length >= 3) {
                ChatMode.setChatMode(player, split[2]);
            } else {
                ChatMode.NextChatMode(player);
            }
        }
    }
}
 
开发者ID:James137137,项目名称:FactionChat,代码行数:30,代码来源:FactionChatListener.java


注:本文中的org.bukkit.event.player.PlayerCommandPreprocessEvent.isCancelled方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。