Java Code Examples for org.spongepowered.api.entity.living.player.Player#equals()
The following examples show how to use
org.spongepowered.api.entity.living.player.Player#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: FactionKickListener.java From EagleFactions with MIT License | 6 votes |
@Listener(order = Order.POST) @IsCancelled(value = Tristate.FALSE) public void onPlayerFactionKick(final FactionKickEvent event) { final Faction faction = event.getFaction(); final FactionPlayer kickedPlayer = event.getKickedPlayer(); final List<Player> onlineFactionPlayers = super.getPlugin().getFactionLogic().getOnlinePlayers(faction); for(final Player player : onlineFactionPlayers) { if (player.equals(event.getCreator())) continue; if(player.getName().equals(kickedPlayer.getName())) continue; player.sendMessage(Text.of(PluginInfo.PLUGIN_PREFIX, "Player " + kickedPlayer.getName() + " has been kicked from the faction.")); } }
Example 2
Source File: PlayerFreezeExecutor.java From EssentialCmds with MIT License | 6 votes |
@Override public void executeAsync(CommandSource src, CommandContext ctx) { Player targetPlayer = ctx.<Player> getOne("player").get(); if(targetPlayer.equals(src)) { src.sendMessage(Text.of(TextColors.DARK_RED, "Error! ", TextColors.RED, "You cannot freeze yourself!")); return; } if(EssentialCmds.frozenPlayers.contains(targetPlayer.getUniqueId())) { EssentialCmds.frozenPlayers.remove(targetPlayer.getUniqueId()); src.sendMessage(Text.of(TextColors.GREEN, "Success! ", TextColors.YELLOW, "Un-froze player.")); } else { EssentialCmds.frozenPlayers.add(targetPlayer.getUniqueId()); src.sendMessage(Text.of(TextColors.GREEN, "Success! ", TextColors.YELLOW, "Froze player.")); } }
Example 3
Source File: UCJedisLoader.java From UltimateChat with GNU General Public License v3.0 | 5 votes |
public void sendTellMessage(CommandSource sender, String tellReceiver, Text msg) { Builder text = Text.builder(); text.append(UCUtil.toText(this.thisId)); //send spy if (!sender.hasPermission("uchat.chat-spy.bypass")) { for (Player receiver : Sponge.getServer().getOnlinePlayers()) { if (!receiver.getName().equals(tellReceiver) && !receiver.equals(sender) && UChat.get().isSpy.contains(receiver.getName()) && UChat.get().getPerms().hasSpyPerm(receiver, "private")) { String spyformat = UChat.get().getConfig().root().general.spy_format; spyformat = spyformat.replace("{output}", UCUtil.stripColor('&', UCMessages.sendMessage(sender, tellReceiver, msg, new UCChannel("tell")).toPlain())); receiver.sendMessage(UCUtil.toText(spyformat)); } } } text.append(UCMessages.sendMessage(sender, tellReceiver, msg, new UCChannel("tell"))); tellPlayers.put(tellReceiver, sender.getName()); if (Arrays.asList(channels).contains("tellsend")) { Sponge.getScheduler().createAsyncExecutor(UChat.get()).execute(() -> { Jedis jedis = pool.getResource(); try { //string 0 1 2 jedis.publish("tellsend", this.thisId + "$" + tellReceiver + "$" + TextSerializers.JSON.serialize(text.build())); } catch (JedisConnectionException e) { e.printStackTrace(); } }); } }
Example 4
Source File: CommandHandlers.java From RedProtect with GNU General Public License v3.0 | 5 votes |
public static void handleRemoveAdmin(CommandSource src, String sVictim, Region r) { if (src instanceof Player) { Player p = (Player) src; r = RedProtect.get().rm.getTopRegion(p.getLocation(), CommandHandlers.class.getName()); if (r == null) { RedProtect.get().lang.sendMessage(p, "cmdmanager.region.todo.that"); return; } } if (RedProtect.get().ph.hasRegionPermAdmin(src, "removeadmin", r)) { Player pVictim = null; if (RedProtect.get().getServer().getPlayer(sVictim).isPresent()) { pVictim = RedProtect.get().getServer().getPlayer(sVictim).get(); } if (RedProtect.get().getUtil().PlayerToUUID(sVictim) == null) { RedProtect.get().lang.sendMessage(src, RedProtect.get().lang.get("cmdmanager.noplayer.thisname").replace("{player}", sVictim)); return; } if (r.isAdmin(sVictim)) { RedProtect.get().lang.sendMessage(src, RedProtect.get().lang.get("general.color") + sVictim + " " + RedProtect.get().lang.get("cmdmanager.region.member.added") + " " + r.getName()); r.removeAdmin(sVictim); RedProtect.get().logger.addLog("(World " + r.getWorld() + ") Player " + src.getName() + " DEMOTED TO MEMBER " + sVictim + " to region " + r.getName()); if (pVictim != null && pVictim.isOnline() && !pVictim.equals(src)) { RedProtect.get().lang.sendMessage(pVictim, RedProtect.get().lang.get("cmdmanager.region.admin.youdemoted").replace("{region}", r.getName()) + " " + src.getName()); } } else { RedProtect.get().lang.sendMessage(src, "&c" + sVictim + " " + RedProtect.get().lang.get("cmdmanager.region.admin.notadmin")); } } else if (src instanceof Player) { RedProtect.get().lang.sendMessage(src, "no.permission"); } }
Example 5
Source File: CommandHandlers.java From RedProtect with GNU General Public License v3.0 | 5 votes |
public static void handleRemoveMember(CommandSource src, String sVictim, Region r) { if (src instanceof Player) { Player p = (Player) src; r = RedProtect.get().rm.getTopRegion(p.getLocation(), CommandHandlers.class.getName()); if (r == null) { RedProtect.get().lang.sendMessage(p, "cmdmanager.region.todo.that"); return; } } if (RedProtect.get().ph.hasRegionPermAdmin(src, "removemember", r)) { Player pVictim = null; if (RedProtect.get().getServer().getPlayer(sVictim).isPresent()) { pVictim = RedProtect.get().getServer().getPlayer(sVictim).get(); } if (RedProtect.get().getUtil().PlayerToUUID(sVictim) == null) { RedProtect.get().lang.sendMessage(src, RedProtect.get().lang.get("cmdmanager.noplayer.thisname").replace("{player}", sVictim)); return; } if ((r.isMember(sVictim) || r.isAdmin(sVictim)) && !r.isLeader(sVictim)) { RedProtect.get().lang.sendMessage(src, RedProtect.get().lang.get("general.color") + sVictim + " " + RedProtect.get().lang.get("cmdmanager.region.member.removed") + " " + r.getName()); r.removeMember(sVictim); RedProtect.get().logger.addLog("(World " + r.getWorld() + ") Player " + src.getName() + " REMOVED MEMBER " + sVictim + " to region " + r.getName()); if (pVictim != null && pVictim.isOnline() && !pVictim.equals(src)) { RedProtect.get().lang.sendMessage(pVictim, RedProtect.get().lang.get("cmdmanager.region.member.youremoved").replace("{region}", r.getName()) + " " + src.getName()); } } else { RedProtect.get().lang.sendMessage(src, "&c" + sVictim + " " + RedProtect.get().lang.get("cmdmanager.region.member.notmember")); } } else if (src instanceof Player) { RedProtect.get().lang.sendMessage(src, "no.permission"); } }
Example 6
Source File: FlagGui.java From RedProtect with GNU General Public License v3.0 | 5 votes |
public void open() { for (Player player : Sponge.getServer().getOnlinePlayers()) { if (player.getOpenInventory().isPresent() && player.getOpenInventory().get().getName().get().equals(this.inv.getName().get())) { Region r = RedProtect.get().rm.getTopRegion(player.getLocation(), this.getClass().getName()); if (r != null && r.equals(this.region) && !player.equals(this.player)) { RedProtect.get().lang.sendMessage(this.player, "cmdmanager.region.rpgui-other", new Replacer[]{new Replacer("{player}", player.getName())}); return; } } } //Register Listener Sponge.getGame().getEventManager().registerListeners(RedProtect.get().container, this); RedProtect.get().getVersionHelper().openInventory(this.inv, this.player); }
Example 7
Source File: TeleportaskallhereCommand.java From UltimateCore with MIT License | 5 votes |
@Override public CommandResult execute(CommandSource sender, CommandContext args) throws CommandException { checkIfPlayer(sender); checkPermission(sender, getPermission()); Player p = (Player) sender; List<Player> ts = new ArrayList<>(Sponge.getServer().getOnlinePlayers()); for (Player t : ts) { if (t.equals(sender)) continue; UUID tpid = UUID.randomUUID(); Teleportation tel = UltimateCore.get().getTeleportService().createTeleportation(sender, Arrays.asList(t), p::getTransform, tele -> { Messages.send(p, "teleport.command.teleportaskhere.accept", "%player%", t); }, (tele, reason) -> { if (reason.equalsIgnoreCase("tpdeny")) { Messages.send(p, "teleport.command.teleportaskhere.deny", "%player%", t); } }, true, false); HashMap<UUID, TpaRequest> tels = GlobalData.get(TeleportKeys.TELEPORT_ASKHERE_REQUESTS).get(); tels.put(tpid, new TpaRequest(p, t, tel)); GlobalData.offer(TeleportKeys.TELEPORT_ASKHERE_REQUESTS, tels); Messages.send(t, "teleport.command.teleportaskhere.receive", "%player%", sender, "%tpid%", tpid); } Messages.send(sender, "teleport.command.teleportaskallhere.self"); return CommandResult.success(); }
Example 8
Source File: KickallCommand.java From UltimateCore with MIT License | 5 votes |
@Override public CommandResult execute(CommandSource sender, CommandContext args) throws CommandException { checkPermission(sender, KickPermissions.UC_KICK_KICKALL_BASE); Text reason = args.hasAny("reason") ? Text.of(args.getOne("reason")) : Messages.getFormatted(sender, "kick.command.kickall.defaultreason"); for (Player p : Sponge.getServer().getOnlinePlayers()) { if (p.equals(sender)) { continue; } p.kick(Messages.getFormatted("kick.command.kickall.message", "%kicker%", sender, "%reason%", reason)); } Messages.send(sender, "kick.command.kickall.success"); return CommandResult.success(); }
Example 9
Source File: CommandHandlers.java From RedProtect with GNU General Public License v3.0 | 4 votes |
public static void handleAddLeader(CommandSource src, String sVictim, Region r) { if (src instanceof Player) { Player p = (Player) src; r = RedProtect.get().rm.getTopRegion(p.getLocation(), CommandHandlers.class.getName()); if (r == null) { RedProtect.get().lang.sendMessage(p, "cmdmanager.region.todo.that"); return; } } if (RedProtect.get().ph.hasRegionPermLeader(src, "addleader", r)) { Player pVictim = null; if (RedProtect.get().getServer().getPlayer(sVictim).isPresent()) { pVictim = RedProtect.get().getServer().getPlayer(sVictim).get(); } if ((pVictim == null || !pVictim.isOnline()) && !src.hasPermission("redprotect.command.admin.addleader")) { RedProtect.get().lang.sendMessage(src, RedProtect.get().lang.get("cmdmanager.noplayer.online").replace("{player}", sVictim)); return; } if (!src.hasPermission("redprotect.command.admin.addleader")) { int claimLimit = RedProtect.get().ph.getPlayerClaimLimit(pVictim); int claimused = RedProtect.get().rm.getPlayerRegions(pVictim.getName(), pVictim.getWorld().getName()); boolean claimUnlimited = RedProtect.get().ph.hasPerm(src, "redprotect.limits.claim.unlimited"); if (claimused >= claimLimit && claimLimit >= 0 && !claimUnlimited) { RedProtect.get().lang.sendMessage(src, RedProtect.get().lang.get("cmdmanager.region.addleader.limit").replace("{player}", pVictim.getName())); return; } } if (!r.isLeader(sVictim)) { if (src.hasPermission("redprotect.command.admin.addleader")) { r.addLeader(sVictim); RedProtect.get().logger.addLog("(World " + r.getWorld() + ") Player " + src.getName() + " ADDED LEADER " + sVictim + " to region " + r.getName()); RedProtect.get().lang.sendMessage(src, RedProtect.get().lang.get("general.color") + sVictim + " " + RedProtect.get().lang.get("cmdmanager.region.leader.added") + " " + r.getName()); if (pVictim != null && pVictim.isOnline() && !pVictim.equals(src)) { RedProtect.get().lang.sendMessage(pVictim, RedProtect.get().lang.get("cmdmanager.region.leader.youadded").replace("{region}", r.getName()) + " " + src.getName()); } return; } RedProtect.get().lang.sendMessage(src, RedProtect.get().lang.get("cmdmanager.region.leader.yousendrequest").replace("{player}", pVictim.getName())); RedProtect.get().lang.sendMessage(pVictim, RedProtect.get().lang.get("cmdmanager.region.leader.sendrequestto").replace("{region}", r.getName()).replace("{player}", src.getName())); RedProtect.get().alWait.put(pVictim, r.getID() + "@" + src.getName()); final Player pVictimf = pVictim; Sponge.getScheduler().createSyncExecutor(RedProtect.get().container).schedule(() -> { if (RedProtect.get().alWait.containsKey(pVictimf)) { RedProtect.get().alWait.remove(pVictimf); if (src instanceof Player && ((Player) src).isOnline()) { RedProtect.get().lang.sendMessage(src, RedProtect.get().lang.get("cmdmanager.region.leader.requestexpired").replace("{player}", pVictimf.getName())); } } }, RedProtect.get().config.configRoot().region_settings.leadership_request_time, TimeUnit.SECONDS); } else { RedProtect.get().lang.sendMessage(src, "&c" + sVictim + " " + RedProtect.get().lang.get("cmdmanager.region.leader.already")); } } else if (src instanceof Player) { RedProtect.get().lang.sendMessage(src, "no.permission"); } }
Example 10
Source File: CommandHandlers.java From RedProtect with GNU General Public License v3.0 | 4 votes |
public static void handleRemoveLeader(CommandSource src, String sVictim, Region r) { Region rLow = null; Map<Integer, Region> regions = new HashMap<>(); if (src instanceof Player) { Player p = (Player) src; r = RedProtect.get().rm.getTopRegion(p.getLocation(), CommandHandlers.class.getName()); rLow = RedProtect.get().rm.getLowRegion(p.getLocation()); regions = RedProtect.get().rm.getGroupRegion(p.getLocation()); if (r == null) { RedProtect.get().lang.sendMessage(p, "cmdmanager.region.todo.that"); return; } } if (RedProtect.get().ph.hasRegionPermLeader(src, "removeleader", r)) { Player pVictim = null; if (RedProtect.get().getServer().getPlayer(sVictim).isPresent()) { pVictim = RedProtect.get().getServer().getPlayer(sVictim).get(); } if (RedProtect.get().getUtil().PlayerToUUID(sVictim) == null) { RedProtect.get().lang.sendMessage(src, RedProtect.get().lang.get("cmdmanager.noplayer.thisname").replace("{player}", sVictim)); return; } if (rLow != null && rLow != r && ((!RedProtect.get().ph.hasRegionPermLeader(src, "removeleader", rLow) || (regions.size() > 1 && rLow.isLeader(sVictim))))) { RedProtect.get().lang.sendMessage(src, RedProtect.get().lang.get("cmdmanager.region.leader.cantremove.lowregion").replace("{player}", sVictim) + " " + rLow.getName()); return; } if (r.isLeader(sVictim)) { if (r.leaderSize() > 1) { RedProtect.get().lang.sendMessage(src, RedProtect.get().lang.get("general.color") + sVictim + " " + RedProtect.get().lang.get("cmdmanager.region.admin.added") + " " + r.getName()); r.removeLeader(sVictim); RedProtect.get().logger.addLog("(World " + r.getWorld() + ") Player " + src.getName() + " DEMOTED TO ADMIN " + sVictim + " to region " + r.getName()); if (pVictim != null && pVictim.isOnline() && !pVictim.equals(src)) { RedProtect.get().lang.sendMessage(pVictim, RedProtect.get().lang.get("cmdmanager.region.leader.youdemoted").replace("{region}", r.getName()) + " " + src.getName()); } } else { RedProtect.get().lang.sendMessage(src, RedProtect.get().lang.get("cmdmanager.region.leader.cantremove").replace("{player}", sVictim)); } } else { RedProtect.get().lang.sendMessage(src, "&c" + sVictim + " " + RedProtect.get().lang.get("cmdmanager.region.leader.notleader")); } } else if (src instanceof Player) { RedProtect.get().lang.sendMessage(src, "no.permission"); } }
Example 11
Source File: CommandHandlers.java From RedProtect with GNU General Public License v3.0 | 4 votes |
public static void handleAddAdmin(CommandSource src, String sVictim, Region r) { if (src instanceof Player) { Player p = (Player) src; r = RedProtect.get().rm.getTopRegion(p.getLocation(), CommandHandlers.class.getName()); if (r == null) { RedProtect.get().lang.sendMessage(p, "cmdmanager.region.todo.that"); return; } } if (RedProtect.get().ph.hasRegionPermAdmin(src, "addadmin", r)) { Player pVictim = null; if (RedProtect.get().getServer().getPlayer(sVictim).isPresent()) { pVictim = RedProtect.get().getServer().getPlayer(sVictim).get(); } if (RedProtect.get().getUtil().PlayerToUUID(sVictim) == null) { RedProtect.get().lang.sendMessage(src, RedProtect.get().lang.get("cmdmanager.noplayer.thisname").replace("{player}", sVictim)); return; } if (r.isLeader(sVictim)) { RedProtect.get().lang.sendMessage(src, "&c" + sVictim + " " + RedProtect.get().lang.get("cmdmanager.region.leader.already")); return; } if (!r.isAdmin(sVictim)) { r.addAdmin(sVictim); RedProtect.get().logger.addLog("(World " + r.getWorld() + ") Player " + src.getName() + " ADDED ADMIN " + sVictim + " to region " + r.getName()); RedProtect.get().lang.sendMessage(src, RedProtect.get().lang.get("general.color") + sVictim + " " + RedProtect.get().lang.get("cmdmanager.region.admin.added") + " " + r.getName()); if (pVictim != null && pVictim.isOnline() && !pVictim.equals(src)) { RedProtect.get().lang.sendMessage(pVictim, RedProtect.get().lang.get("cmdmanager.region.admin.youadded").replace("{region}", r.getName()) + " " + src.getName()); } } else { RedProtect.get().lang.sendMessage(src, "&c" + sVictim + " " + RedProtect.get().lang.get("cmdmanager.region.admin.already")); } } else if (src instanceof Player) { RedProtect.get().lang.sendMessage(src, "no.permission"); } }
Example 12
Source File: CommandHandlers.java From RedProtect with GNU General Public License v3.0 | 4 votes |
public static void handleAddMember(CommandSource src, String sVictim, Region r) { if (src instanceof Player) { Player p = (Player) src; r = RedProtect.get().rm.getTopRegion(p.getLocation(), CommandHandlers.class.getName()); if (r == null) { RedProtect.get().lang.sendMessage(p, "cmdmanager.region.todo.that"); return; } } if (RedProtect.get().ph.hasRegionPermAdmin(src, "addmember", r)) { if (RedProtect.get().getUtil().PlayerToUUID(sVictim) == null) { RedProtect.get().lang.sendMessage(src, RedProtect.get().lang.get("cmdmanager.noplayer.thisname").replace("{player}", sVictim)); return; } Player pVictim = null; if (RedProtect.get().getServer().getPlayer(sVictim).isPresent()) { pVictim = RedProtect.get().getServer().getPlayer(sVictim).get(); } if (r.isAdmin(sVictim)) { r.addMember(sVictim); RedProtect.get().logger.addLog("(World " + r.getWorld() + ") Player " + src.getName() + " ADDED MEMBER " + sVictim + " to region " + r.getName()); RedProtect.get().lang.sendMessage(src, RedProtect.get().lang.get("general.color") + sVictim + " " + RedProtect.get().lang.get("cmdmanager.region.member.demoted") + " " + r.getName()); if (pVictim != null && pVictim.isOnline()) { RedProtect.get().lang.sendMessage(pVictim, RedProtect.get().lang.get("cmdmanager.region.admin.youdemoted").replace("{region}", r.getName()) + " " + src.getName()); } } else if (!r.isMember(sVictim)) { r.addMember(sVictim); RedProtect.get().logger.addLog("(World " + r.getWorld() + ") Player " + src.getName() + " ADDED MEMBER " + sVictim + " to region " + r.getName()); RedProtect.get().lang.sendMessage(src, RedProtect.get().lang.get("general.color") + sVictim + " " + RedProtect.get().lang.get("cmdmanager.region.member.added") + " " + r.getName()); if (pVictim != null && pVictim.isOnline() && !pVictim.equals(src)) { RedProtect.get().lang.sendMessage(pVictim, RedProtect.get().lang.get("cmdmanager.region.member.youadded").replace("{region}", r.getName()) + " " + src.getName()); } } else { RedProtect.get().lang.sendMessage(src, "&c" + sVictim + " " + RedProtect.get().lang.get("cmdmanager.region.member.already")); } } else if (src instanceof Player) { RedProtect.get().lang.sendMessage(src, "no.permission"); } }
Example 13
Source File: GlobalListener.java From RedProtect with GNU General Public License v3.0 | 4 votes |
@Listener(order = Order.FIRST, beforeModifications = true) public void onProjectileHit(CollideEntityEvent event, @Root Projectile proj) { RedProtect.get().logger.debug(LogLevel.ENTITY, "Is CollideEntityEvent(onProjectileHit) event."); RedProtect.get().logger.debug(LogLevel.ENTITY, "Projectile: " + proj.getType().getName()); if (RedProtect.get().rm.getTopRegion(proj.getLocation(), this.getClass().getName()) != null) return; for (Entity ent : event.getEntities()) { RedProtect.get().logger.debug(LogLevel.ENTITY, "Entity: " + ent.getType().getName()); if (proj.getShooter() instanceof Player) { Player p = (Player) proj.getShooter(); if (ent instanceof Player) { if (!p.equals(ent) && !RedProtect.get().config.globalFlagsRoot().worlds.get(ent.getWorld().getName()).pvp && !p.hasPermission("redprotect.world.bypass")) { event.setCancelled(true); return; } } if (ent instanceof Animal || ent instanceof Villager || ent instanceof Golem || ent instanceof Ambient) { if (!RedProtect.get().config.globalFlagsRoot().worlds.get(ent.getWorld().getName()).player_hurt_passives && !p.hasPermission("redprotect.world.bypass")) { event.setCancelled(true); return; } } if (ent instanceof Monster) { if (!RedProtect.get().config.globalFlagsRoot().worlds.get(ent.getWorld().getName()).player_hurt_monsters && !p.hasPermission("redprotect.world.bypass")) { event.setCancelled(true); return; } } if (ent instanceof Hanging || ent instanceof ArmorStand) { if (!RedProtect.get().config.globalFlagsRoot().worlds.get(ent.getWorld().getName()).build && !p.hasPermission("redprotect.world.bypass")) { event.setCancelled(true); } } } else { if (ent instanceof Hanging || ent instanceof ArmorStand) { if (!RedProtect.get().config.globalFlagsRoot().worlds.get(ent.getWorld().getName()).entity_block_damage) { event.setCancelled(true); return; } } } } }