Please do not use this method. Instead use * BukkitUtil.getPlayer(Player), as it caches player objects.
* * @param player Bukkit player instance */ public BukkitPlayer(@NotNull final Player player) { this(player, false); } public BukkitPlayer(@NotNull final Player player, final boolean offline) { this(player, offline, true); } public BukkitPlayer(@NotNull final Player player, final boolean offline, final boolean realPlayer) { this.player = player; this.offline = offline; if (realPlayer) { super.populatePersistentMetaMap(); } } @Override public Actor toActor() { return BukkitAdapter.adapt(player); } @Override public Player getPlatformPlayer() { return this.player; } @NotNull @Override public Location getLocation() { final Location location = super.getLocation(); return location == null ? BukkitUtil.getLocation(this.player) : location; } @NotNull @Override public UUID getUUID() { if (Settings.UUID.OFFLINE) { if (Settings.UUID.FORCE_LOWERCASE) { return UUID.nameUUIDFromBytes(("OfflinePlayer:" + getName().toLowerCase()).getBytes(Charsets.UTF_8)); } else { return UUID.nameUUIDFromBytes(("OfflinePlayer:" + getName()).getBytes(Charsets.UTF_8)); } } return player.getUniqueId(); } @Override public long getLastPlayed() { return this.player.getLastPlayed(); } @Override public boolean canTeleport(@NotNull final Location location) { final org.bukkit.Location to = BukkitUtil.getLocation(location); final org.bukkit.Location from = player.getLocation(); PlayerTeleportEvent event = new PlayerTeleportEvent(player, from, to); callEvent(event); if (event.isCancelled() || !event.getTo().equals(to)) { return false; } event = new PlayerTeleportEvent(player, to, from); callEvent(event); return true; } @Override public void sendTitle(String title, String subtitle, int fadeIn, int stay, int fadeOut) { player.sendTitle(title, subtitle, fadeIn, stay, fadeOut); } private void callEvent(@NotNull final Event event) { final RegisteredListener[] listeners = event.getHandlers().getRegisteredListeners(); for (final RegisteredListener listener : listeners) { if (listener.getPlugin().getName().equals(PlotSquared.imp().getPluginName())) { continue; } try { listener.callEvent(event); } catch (final EventException e) { e.printStackTrace(); } } } @Override public boolean hasPermission(final String permission) { if (this.offline && EconHandler.manager != null) { return EconHandler.manager.hasPermission(getName(), permission); } return this.player.hasPermission(permission); } @Override public int hasPermissionRange(final String stub, final int range) { if (hasPermission(Captions.PERMISSION_ADMIN.getTranslated())) { return Integer.MAX_VALUE; } final String[] nodes = stub.split("\\."); final StringBuilder n = new StringBuilder(); for (int i = 0; i < (nodes.length - 1); i++) { n.append(nodes[i]).append("."); if (!stub.equals(n + Captions.PERMISSION_STAR.getTranslated())) { if (hasPermission(n + Captions.PERMISSION_STAR.getTranslated())) { return Integer.MAX_VALUE; } } } if (hasPermission(stub + ".*")) { return Integer.MAX_VALUE; } int max = 0; if (CHECK_EFFECTIVE) { boolean hasAny = false; String stubPlus = stub + "."; final Set