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


Java PlayerCommandPreprocessEvent.getPlayer方法代碼示例

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


在下文中一共展示了PlayerCommandPreprocessEvent.getPlayer方法的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: onPlayerPreCommand

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

示例3: helpMessage

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

示例4: 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

示例5: onCmd

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

示例6: onCommand

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

示例7: onCommandProcess

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

示例8: onEvent

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

示例9: 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

示例10: PlayerCommand

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

示例11: 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

示例12: 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

示例13: 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

示例14: 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

示例15: onPlayerCommand

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


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