Java Code Examples for org.bukkit.command.CommandSender#equals()

The following examples show how to use org.bukkit.command.CommandSender#equals() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CommandAdminHologramTeleport.java    From NovaGuilds with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void execute(CommandSender sender, String[] args) throws Exception {
	NovaHologram hologram = getParameter();

	Player player = args.length == 0 ? (Player) sender : Bukkit.getPlayer(args[0]);

	if(player == null) {
		Message.CHAT_PLAYER_NOTEXISTS.send(sender);
		return;
	}

	player.teleport(hologram.getLocation());

	Map<VarKey, String> vars = new HashMap<>();
	vars.put(VarKey.PLAYER_NAME, player.getName());
	vars.put(VarKey.NAME, hologram.getName());

	if(sender.equals(player)) {
		Message.CHAT_ADMIN_HOLOGRAM_TELEPORT_SELF.clone().vars(vars).send(sender);
	}
	else {
		Message.CHAT_ADMIN_HOLOGRAM_TELEPORT_OTHER.clone().vars(vars).send(sender);
		Message.CHAT_ADMIN_GUILD_TELEPORTED_SELF.clone().vars(vars).send(player);
	}
}
 
Example 2
Source File: InventoryClearCommand.java    From Minepacks with GNU General Public License v3.0 6 votes vote down vote up
private void clearInventory(Player player, CommandSender sender)
{
	InventoryClearEvent clearEvent = new InventoryClearEvent(player, sender);
	Bukkit.getPluginManager().callEvent(clearEvent);
	if(clearEvent.isCancelled()) return;
	player.getInventory().clear();
	if(sender.equals(player))
	{
		messageOwnInventoryCleared.send(player);
		Bukkit.getPluginManager().callEvent(new InventoryClearedEvent(player, sender));
	}
	else
	{
		messageInventoryWasCleared.send(player, sender.getName(), (sender instanceof Player) ? ((Player) sender).getDisplayName() : ChatColor.GRAY + sender.getName());
		messageOtherInventoryCleared.send(sender, player.getName(), player.getDisplayName());
		Bukkit.getPluginManager().callEvent(new InventoryClearedEvent(player, sender));
	}
}
 
Example 3
Source File: NMS_1_16_R1.java    From 1.13-Command-API with Apache License 2.0 5 votes vote down vote up
@Override
public CommandSender getSenderForCommand(CommandContext cmdCtx) {
	CommandSender sender = getCLW(cmdCtx).getBukkitSender();

	Entity proxyEntity = getCLW(cmdCtx).getEntity();
	if (proxyEntity != null) {
		CommandSender proxy = ((Entity) proxyEntity).getBukkitEntity();

		if (!proxy.equals(sender)) {
			sender = new ProxiedNativeCommandSender(getCLW(cmdCtx), sender, proxy);
		}
	}

	return sender;
}
 
Example 4
Source File: NMS_1_14.java    From 1.13-Command-API with Apache License 2.0 5 votes vote down vote up
@Override
public CommandSender getSenderForCommand(CommandContext cmdCtx) {
	CommandSender sender = getCLW(cmdCtx).getBukkitSender();

	Entity proxyEntity = getCLW(cmdCtx).getEntity();
	if (proxyEntity != null) {
		CommandSender proxy = proxyEntity.getBukkitEntity();

		if (!proxy.equals(sender)) {
			sender = new ProxiedNativeCommandSender(getCLW(cmdCtx), sender, proxy);
		}
	}

	return sender;
}
 
Example 5
Source File: NMS_1_13.java    From 1.13-Command-API with Apache License 2.0 5 votes vote down vote up
@Override
public CommandSender getSenderForCommand(CommandContext cmdCtx) {
    CommandSender sender = getCLW(cmdCtx).getBukkitSender();

    Entity proxyEntity = getCLW(cmdCtx).f();
    if (proxyEntity != null) {
        CommandSender proxy = proxyEntity.getBukkitEntity();

        if (!proxy.equals(sender)) {
            sender = new ProxiedNativeCommandSender(getCLW(cmdCtx), sender, proxy);
        }
    }

    return sender;
}
 
Example 6
Source File: NMS_1_15.java    From 1.13-Command-API with Apache License 2.0 5 votes vote down vote up
@Override
public CommandSender getSenderForCommand(CommandContext cmdCtx) {
	CommandSender sender = getCLW(cmdCtx).getBukkitSender();

	Entity proxyEntity = getCLW(cmdCtx).getEntity();
	if (proxyEntity != null) {
		CommandSender proxy = ((Entity) proxyEntity).getBukkitEntity();

		if (!proxy.equals(sender)) {
			sender = new ProxiedNativeCommandSender(getCLW(cmdCtx), sender, proxy);
		}
	}

	return sender;
}
 
Example 7
Source File: NMS_1_13_2.java    From 1.13-Command-API with Apache License 2.0 5 votes vote down vote up
@Override
public CommandSender getSenderForCommand(CommandContext cmdCtx) {
    CommandSender sender = getCLW(cmdCtx).getBukkitSender();

    Entity proxyEntity = getCLW(cmdCtx).getEntity();
    if (proxyEntity != null) {
        CommandSender proxy = proxyEntity.getBukkitEntity();

        if (!proxy.equals(sender)) {
            sender = new ProxiedNativeCommandSender(getCLW(cmdCtx), sender, proxy);
        }
    }

    return sender;
}
 
Example 8
Source File: NMS_1_14_4.java    From 1.13-Command-API with Apache License 2.0 5 votes vote down vote up
@Override
public CommandSender getSenderForCommand(CommandContext cmdCtx) {
    CommandSender sender = getCLW(cmdCtx).getBukkitSender();

    Entity proxyEntity = getCLW(cmdCtx).getEntity();
    if (proxyEntity != null) {
        CommandSender proxy = ((Entity) proxyEntity).getBukkitEntity();

        if (!proxy.equals(sender)) {
            sender = new ProxiedNativeCommandSender(getCLW(cmdCtx), sender, proxy);
        }
    }

    return sender;
}
 
Example 9
Source File: NMS_1_14_3.java    From 1.13-Command-API with Apache License 2.0 5 votes vote down vote up
@Override
public CommandSender getSenderForCommand(CommandContext cmdCtx) {
    CommandSender sender = getCLW(cmdCtx).getBukkitSender();

    Entity proxyEntity = getCLW(cmdCtx).getEntity();
    if (proxyEntity != null) {
        CommandSender proxy = proxyEntity.getBukkitEntity();

        if (!proxy.equals(sender)) {
            sender = new ProxiedNativeCommandSender(getCLW(cmdCtx), sender, proxy);
        }
    }

    return sender;
}
 
Example 10
Source File: NMS_1_13_1.java    From 1.13-Command-API with Apache License 2.0 5 votes vote down vote up
@Override
public CommandSender getSenderForCommand(CommandContext cmdCtx) {
    CommandSender sender = getCLW(cmdCtx).getBukkitSender();

    Entity proxyEntity = getCLW(cmdCtx).f();
    if (proxyEntity != null) {
        CommandSender proxy = proxyEntity.getBukkitEntity();

        if (!proxy.equals(sender)) {
            sender = new ProxiedNativeCommandSender(getCLW(cmdCtx), sender, proxy);
        }
    }

    return sender;
}
 
Example 11
Source File: UCMessages.java    From UltimateChat with GNU General Public License v3.0 5 votes vote down vote up
public static String mention(Object sender, CommandSender receiver, String msg) {
    if (UChat.get().getUCConfig().getBoolean("mention.enable")) {
        for (Player p : UChat.get().getServer().getOnlinePlayers()) {
            if (!sender.equals(p) && Arrays.stream(msg.split(" ")).anyMatch(p.getName()::equalsIgnoreCase)) {
                if (receiver instanceof Player && receiver.equals(p)) {

                    String mentionc = UChat.get().getUCConfig().getColorStr("mention.color-template").replace("{mentioned-player}", p.getName());
                    mentionc = formatTags("", mentionc, sender, receiver, "", new UCChannel("mention"));

                    if (msg.contains(mentionc) || sender instanceof CommandSender && !UCPerms.hasPerm((CommandSender) sender, "chat.mention")) {
                        msg = msg.replaceAll("(?i)\\b" + p.getName() + "\\b", p.getName());
                        continue;
                    }

                    for (Sound sound : Sound.values()) {
                        if (StringUtils.containsIgnoreCase(sound.toString(), UChat.get().getUCConfig().getString("mention.playsound"))) {
                            p.playSound(p.getLocation(), sound, 1F, 1F);
                            break;
                        }
                    }
                    msg = msg.replace(mentionc, p.getName());
                    msg = msg.replaceAll("(?i)\\b" + p.getName() + "\\b", mentionc);
                } else {
                    msg = msg.replaceAll("(?i)\\b" + p.getName() + "\\b", p.getName());
                }
            }
        }
    }
    return msg;
}