本文整理汇总了Java中org.bukkit.event.player.PlayerCommandPreprocessEvent.setCancelled方法的典型用法代码示例。如果您正苦于以下问题:Java PlayerCommandPreprocessEvent.setCancelled方法的具体用法?Java PlayerCommandPreprocessEvent.setCancelled怎么用?Java PlayerCommandPreprocessEvent.setCancelled使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.event.player.PlayerCommandPreprocessEvent
的用法示例。
在下文中一共展示了PlayerCommandPreprocessEvent.setCancelled方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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!")));
}
}
示例2: 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 + "=================================");
}
}
示例3: onCommandPreprocess
import org.bukkit.event.player.PlayerCommandPreprocessEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.LOWEST)
public void onCommandPreprocess(PlayerCommandPreprocessEvent e)
{
String cmd = e.getMessage().substring(1);
if(cmd.length() <= 0) return;
String[] unprocessedArgs = cmd.split(" ");
String label = unprocessedArgs[0];
String[] args = new String[unprocessedArgs.length - 1];
System.arraycopy(unprocessedArgs, 1, args, 0, args.length);
if(label.equalsIgnoreCase("cmapi"))
{
e.setCancelled(true);
command.onCommand(e.getPlayer(), null, label, args);
}
}
示例4: 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);
}
}
示例5: 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);
}
}
示例6: 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;
}
}
}
}
示例7: 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!");
}
}
示例8: onCommand
import org.bukkit.event.player.PlayerCommandPreprocessEvent; //导入方法依赖的package包/类
@EventHandler
public void onCommand(PlayerCommandPreprocessEvent e) {
if(e.getMessage().trim().isEmpty() || e.getMessage().trim().length() < 2) return;
String command = e.getMessage().substring(1, e.getMessage().length());
Player p = e.getPlayer();
if (!Inventories.exist(command)) return;
e.setCancelled(true);
ModularInventory inventory = Inventories.get(command);
if (!p.hasPermission(inventory.getPermission())) {
p.sendMessage(String.format("§cYou require the permission §a%s§c to be able to open the GUI §6'§r%s§6'§c!", inventory.getPermission(), inventory.getTitle()));
return;
}
Inventories.display(inventory, p);
}
示例9: 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?
}
}
示例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);
}
}
示例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;
}
}
}
示例12: onPlayerCommand
import org.bukkit.event.player.PlayerCommandPreprocessEvent; //导入方法依赖的package包/类
/**
* Prevents players from using commands like /spawner
* @param e
*/
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = false)
public void onPlayerCommand(final PlayerCommandPreprocessEvent e) {
if (DEBUG) {
plugin.getLogger().info("Player command " + e.getEventName() + ": " + e.getMessage());
}
if (e.getPlayer().isOp() || VaultHelper.checkPerm(e.getPlayer(), Settings.PERMPREFIX + "mod.bannedcommands")) {
return;
}
// Check world
if (!inASkyGridWorld(e.getPlayer().getWorld())) {
return;
}
// Check banned commands
//plugin.getLogger().info(Settings.visitorCommandBlockList.toString());
String[] args = e.getMessage().substring(1).toLowerCase().split(" ");
if (Settings.bannedCommandList.contains(args[0])) {
e.getPlayer().sendMessage(ChatColor.RED + plugin.myLocale(e.getPlayer().getUniqueId()).errorNoPermission);
e.setCancelled(true);
}
}
示例13: 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!
}
}
示例14: onPlayerCommandPreprocess
import org.bukkit.event.player.PlayerCommandPreprocessEvent; //导入方法依赖的package包/类
@EventHandler(ignoreCancelled = true)
public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event) {
if (GameManager.getGameManager().getGameForPlayer(event.getPlayer()) == null) {
return;
}
String command = event.getMessage()
.replaceAll("^/*", "") // Remove forward slash if exists
.replaceAll(" .*", ""); // Remove anything after first word
for (String s : GameDispenser.getInstance().getBlacklistedCommands()) {
if (s.equalsIgnoreCase(command)) {
event.getPlayer().sendMessage(FormatUtil.format("&4Cannot use that command while playing a game."));
event.setCancelled(true);
return;
}
}
}
示例15: onPlayerSendsCommand
import org.bukkit.event.player.PlayerCommandPreprocessEvent; //导入方法依赖的package包/类
public void onPlayerSendsCommand(PlayerCommandPreprocessEvent event) {
Player player = event.getPlayer();
if (event.getMessage().startsWith("/back")) {
if (cooldowns.containsKey(player)) {
if (cooldowns.get(player) > (int) (System.currentTimeMillis() / 1000)) {
event.setCancelled(true);
player.sendMessage(ChatColor.RED + "You can't go back for another " + (cooldowns.get(player) - (int) (System.currentTimeMillis() / 1000)) + " seconds!");
} else {
cooldowns.remove(player);
}
}
}
if ((event.getMessage().startsWith("/island") || event.getMessage().startsWith("/skyblock")) && locationInWarzone(player.getLocation())) {
player.sendMessage(ChatColor.RED + "That command is disabled in here!");
event.setCancelled(true);
}
}