Here are the examples of the java api org.bukkit.Bukkit.getPlayer() taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
565 Examples
19
Source : GUIAbstract.java
with GNU General Public License v3.0
from weihao
with GNU General Public License v3.0
from weihao
public void open() {
Bukkit.getPlayer(playerName).openInventory(inventory);
}
19
Source : InventoryManager.java
with GNU General Public License v3.0
from Thatsmusic99
with GNU General Public License v3.0
from Thatsmusic99
public void open(InventoryType type, HashMap<String, String> context) {
// Check if a new inventory is being opened and reset the page
if (type == null) {
Bukkit.getPlayer(player).closeInventory();
return;
}
if (type != this.type) {
currentPage = 1;
section = null;
}
context.put("page", String.valueOf(currentPage));
if (context.containsKey("section")) {
section = context.get("section");
} else {
context.put("section", section);
}
try {
inventory = inventories.get(type).getConstructor(Player.clreplaced, HashMap.clreplaced).newInstance(Bukkit.getPlayer(player), context);
this.type = type;
} catch (InvocationTargetException ex) {
// Invoked constructor threw an exception
ex.getTargetException().printStackTrace();
} catch (IllegalAccessException | InstantiationException | NoSuchMethodException e) {
e.printStackTrace();
}
}
19
Source : IconClickEvent.java
with GNU General Public License v3.0
from Thatsmusic99
with GNU General Public License v3.0
from Thatsmusic99
public Player getPlayer() {
return Bukkit.getPlayer(this.player);
}
19
Source : UUIDAccount.java
with MIT License
from SkytAsul
with MIT License
from SkytAsul
public Player getPlayer() {
return Bukkit.getPlayer(id);
}
19
Source : ReflectionUtil.java
with MIT License
from Simplix-Softworks
with MIT License
from Simplix-Softworks
public static void sendListPacket(@NonNull List<String> players, @NonNull Object packet) {
try {
for (String name : players) {
Object nmsPlayer = nmsPlayer(Bukkit.getPlayer(name));
Object connection = nmsPlayer.getClreplaced().getField(PLAYER_CONNECTION).get(nmsPlayer);
connection.getClreplaced().getMethod(SEND_PACKET, ReflectionUtil.getClreplaced(NMS_PACKET)).invoke(connection, packet);
}
} catch (Exception exception) {
log.error(EXCEPTION_OCCURRED, exception);
}
}
19
Source : PlayerData.java
with GNU General Public License v3.0
from ShaneBeeStudios
with GNU General Public License v3.0
from ShaneBeeStudios
/**
* Get the {@link Player Bukkit Player} belonging to this player data
*
* @return Player belonging to this player data
*/
public Player getBukkitPlayer() {
return Bukkit.getPlayer(this.uuid);
}
19
Source : MiscUtils.java
with GNU Lesser General Public License v3.0
from ScreamingSandals
with GNU Lesser General Public License v3.0
from ScreamingSandals
public List<Player> getOnlinePlayers(Collection<UUID> uuids) {
if (uuids == null) {
return Collections.emptyList();
}
final List<Player> players = new ArrayList<>();
uuids.forEach(uuid -> {
final var pl = Bukkit.getPlayer(uuid);
if (pl != null && pl.isOnline()) {
players.add(pl);
}
});
return players;
}
19
Source : PlayerInterlayer.java
with GNU General Public License v3.0
from SCLeoX
with GNU General Public License v3.0
from SCLeoX
public static PlayerInterlayer getPlayerByName(String name) {
return PlayerInterlayer.getInstanceFor(Bukkit.getPlayer(name));
}
19
Source : GamePlayer.java
with GNU General Public License v3.0
from SamaGames
with GNU General Public License v3.0
from SamaGames
/**
* Returns the Bukkit's {@link Player} object representing the underlying player,
* if he is online; {@code null} else.
*
* @return The {@link Player} object.
*/
public Player getPlayerIfOnline() {
return Bukkit.getPlayer(this.uuid);
}
19
Source : SBAUtil.java
with GNU General Public License v3.0
from pronze
with GNU General Public License v3.0
from pronze
public static Optional<Player> getPlayer(UUID uuid) {
return Optional.ofNullable(Bukkit.getPlayer(uuid));
}
19
Source : ArenaEvents.java
with GNU General Public License v3.0
from Plugily-Projects
with GNU General Public License v3.0
from Plugily-Projects
@EventHandler
public void onEnreplacedyDamage(EnreplacedyDamageEvent event) {
if (!(event.getEnreplacedy() instanceof IronGolem || event.getEnreplacedy() instanceof Wolf)) {
return;
}
for (Arena arena : ArenaRegistry.getArenas()) {
switch(event.getEnreplacedyType()) {
case IRON_GOLEM:
if (!arena.getIronGolems().contains(event.getEnreplacedy())) {
continue;
}
if (((org.bukkit.enreplacedy.Creature) event.getEnreplacedy()).getHealth() <= event.getDamage()) {
event.setCancelled(true);
event.setDamage(0);
arena.removeIronGolem((IronGolem) event.getEnreplacedy());
}
return;
case WOLF:
if (!arena.getWolves().contains(event.getEnreplacedy())) {
continue;
}
if (((org.bukkit.enreplacedy.Creature) event.getEnreplacedy()).getHealth() <= event.getDamage()) {
event.setCancelled(true);
event.setDamage(0);
Wolf wolf = ((Wolf) event.getEnreplacedy());
java.util.UUID ownerUUID = plugin.isPaper() ? wolf.getOwnerUniqueId() : (wolf.getOwner() != null) ? wolf.getOwner().getUniqueId() : null;
if (ownerUUID != null && Bukkit.getPlayer(ownerUUID) != null) {
Bukkit.getPlayer(ownerUUID).sendMessage(plugin.getChatManager().getPrefix() + plugin.getChatManager().colorMessage(Messages.WOLF_DIED));
}
arena.removeWolf((Wolf) event.getEnreplacedy());
}
return;
default:
return;
}
}
}
19
Source : PrivateArena.java
with GNU General Public License v2.0
from PatoTheBest
with GNU General Public License v2.0
from PatoTheBest
public Player getOwner() {
return Bukkit.getPlayer(owner);
}
19
Source : GPlayer.java
with GNU Lesser General Public License v3.0
from nsporillo
with GNU Lesser General Public License v3.0
from nsporillo
/**
* @return player-record if online, NULL otherwise
*/
public Player getOnlinePlayer() {
return Bukkit.getPlayer(uuid);
}
19
Source : Arguments.java
with GNU General Public License v3.0
from Maxlego08
with GNU General Public License v3.0
from Maxlego08
/**
* @param index
* @return
*/
protected Player argAsPlayer(int index) {
return Bukkit.getPlayer(argreplacedtring(index));
}
19
Source : AuthMeApi.java
with Apache License 2.0
from isstac
with Apache License 2.0
from isstac
/**
* Unregister a player from AuthMe by name.
*
* @param name the name of the player (case-insensitive)
*/
public void forceUnregister(String name) {
management.performUnregisterByAdmin(null, name, Bukkit.getPlayer(name));
}
19
Source : FactionUser.java
with MIT License
from IPVP-MC
with MIT License
from IPVP-MC
public Player getPlayer() {
return Bukkit.getPlayer(userUUID);
}
19
Source : PvpClassManager.java
with MIT License
from IPVP-MC
with MIT License
from IPVP-MC
public void onDisable() {
for (Map.Entry<UUID, PvpClreplaced> entry : new HashMap<>(equippedClreplacedMap).entrySet()) {
this.setEquippedClreplaced(Bukkit.getPlayer(entry.getKey()), null);
}
this.pvpClreplacedes.clear();
this.equippedClreplacedMap.clear();
}
19
Source : FactionMember.java
with MIT License
from IPVP-MC
with MIT License
from IPVP-MC
/**
* Converts this {@link Player} to a {@link Player}.
*
* @return the {@link Player} or null if not found
*/
public Player toOnlinePlayer() {
return Bukkit.getPlayer(uniqueID);
}
19
Source : Guild.java
with MIT License
from guilds-plugin
with MIT License
from guilds-plugin
/**
* Get all online members as players
* @return list of players
*/
public List<Player> getOnlineAsPlayers() {
return getOnlineMembers().stream().map(m -> Bukkit.getPlayer(m.getUuid())).collect(Collectors.toList());
}
19
Source : PlayerViewSession.java
with Apache License 2.0
from GorgeousOne
with Apache License 2.0
from GorgeousOne
public Player getPlayer() {
return Bukkit.getPlayer(playerId);
}
19
Source : PSPlayer.java
with GNU General Public License v3.0
from espidev
with GNU General Public License v3.0
from espidev
/**
* Get the wrapped Bukkit player.
* It may return null if the object wraps a UUID that does not exist.
*
* @return the player, or null
*/
public Player getPlayer() {
if (p == null)
return Bukkit.getPlayer(uuid);
return p;
}
19
Source : GroupMember.java
with MIT License
from Avicus
with MIT License
from Avicus
public Player getPlayer() {
return Bukkit.getPlayer(this.uuid);
}
18
Source : DebugCommand.java
with GNU General Public License v3.0
from zachbr
with GNU General Public License v3.0
from zachbr
private void subOrUnsub(CommandSender sender, String[] args, boolean add) {
CommandSender target = null;
if (args.length >= 1) {
Player search = Bukkit.getPlayer(args[0]);
if (search != null) {
target = search;
} else {
sender.sendMessage("Cannot find player with name: " + args[0]);
return;
}
}
if (target == null && sender instanceof ConsoleCommandSender) {
sender.sendMessage(ChatColor.RED + "Debug messages are always sent to the console");
return;
}
if (target == null) {
target = sender;
}
final boolean contains = this.debugListeners.contains(target);
if (add) {
if (contains) {
sender.sendMessage(target.getName() + " is already subscribed to debug messages");
} else {
this.debugListeners.add(target);
sender.sendMessage("Subscribed " + target.getName() + " to debug messages");
}
} else {
if (contains) {
this.debugListeners.remove(target);
sender.sendMessage("Unsubscribed " + target.getName() + " to debug messages");
} else {
sender.sendMessage(target.getName() + " is not subscribed to debug messages");
}
}
}
18
Source : Cache.java
with GNU General Public License v3.0
from YiC200333
with GNU General Public License v3.0
from YiC200333
public static Player getplayer(String name) {
UUID u = translateUUID(name, null);
Player mainp = null;
if (u != null) {
mainp = Bukkit.getPlayer(u);
if (mainp == null && ServerINFO.IsSemiOnlineMode) {
UUID subu = CacheSemiOnline.CacheSubUUID_getsubuuid(u.toString());
if (subu != null) {
Player subp = Bukkit.getPlayer(subu);
if (subp != null) {
return subp;
}
}
}
}
return mainp;
}
18
Source : Util.java
with GNU General Public License v3.0
from weihao
with GNU General Public License v3.0
from weihao
/**
* Sends a colored message to a player.
*
* @param msg
* @param player
*/
public static void sendMessage(String msg, String player) {
Player p = Bukkit.getPlayer(player);
String message = Util.toColor(msg);
if (p != null) {
p.sendMessage(pluginTag() + message);
}
}
18
Source : v1_9_R2_NMS.java
with MIT License
from Thatsmusic99
with MIT License
from Thatsmusic99
@Override
public Player getPlayer(String name) {
return Bukkit.getPlayer(name);
}
18
Source : MessageSender.java
with Apache License 2.0
from tboba
with Apache License 2.0
from tboba
public <T extends User> void sendTo(T user) {
Validate.notNull(user, "User cannot be null!");
this.sendTo(Bukkit.getPlayer(user.getIdentifier()));
}
18
Source : GuideWayData.java
with MIT License
from TabooLib
with MIT License
from TabooLib
public void display() {
Player player = Bukkit.getPlayer(owner);
if (player != null) {
player.spawnParticle(Version.isAfter(Version.v1_9) ? Particle.END_ROD : Particle.CLOUD, target, 500, 0, 100, 0, 0);
}
}
18
Source : ChairManager.java
with MIT License
from SpraxDev
with MIT License
from SpraxDev
public boolean hasChairsDisabled(UUID uuid) {
Boolean value = disabled.get(uuid);
if (value == null) {
if (Settings.REMEMBER_IF_PLAYER_DISABLED_CHAIRS.getValueAsBoolean()) {
value = new File(disabledForDir, uuid.toString()).exists();
} else {
value = false;
}
if (Bukkit.getPlayer(uuid).isOnline()) {
this.disabled.put(uuid, value);
}
}
return value;
}
18
Source : TutorialChapter.java
with GNU General Public License v3.0
from SamaGames
with GNU General Public License v3.0
from SamaGames
/**
* Teleports the given player to the watching point of this chapter.
*
* @param uuid The UUID of the player.
*/
public void teleport(UUID uuid) {
teleport(Bukkit.getPlayer(uuid));
}
18
Source : ActionBarAPI.java
with GNU General Public License v3.0
from SamaGames
with GNU General Public License v3.0
from SamaGames
/**
* Sends an action-bar message to the given player.
* <p/>
* This message will remain approximately three seconds.
*
* @param playerUUID The player's UUID.
* @param message The message.
*/
public static void sendMessage(UUID playerUUID, String message) {
sendMessage(Bukkit.getPlayer(playerUUID), message);
}
18
Source : Camera.java
with GNU General Public License v3.0
from SamaGames
with GNU General Public License v3.0
from SamaGames
void remove(Location backPosition) {
this.viewers.keySet().stream().filter(viewer -> Bukkit.getPlayer(viewer) != null).forEach(viewer -> this.removeViewer(Bukkit.getPlayer(viewer), backPosition));
this.enreplacedyCamera.die();
}
18
Source : KelpPlayer.java
with MIT License
from PXAV
with MIT License
from PXAV
public static KelpPlayer from(String name) {
Player player = Bukkit.getPlayer(name);
if (player == null) {
return null;
}
return KelpPlayer.from(player);
}
18
Source : MischievousWereWolf.java
with Apache License 2.0
from Ph1Lou
with Apache License 2.0
from Ph1Lou
@EventHandler
public void onNight(NightEvent event) {
if (!game.getPlayersWW().get(getPlayerUUID()).isState(State.ALIVE)) {
return;
}
Player player = Bukkit.getPlayer(getPlayerUUID());
if (player == null) {
return;
}
player.sendMessage(game.translate("werewolf.role.little_girl.remove_armor"));
player.addPotionEffect(new PotionEffect(PotionEffectType.INCREASE_DAMAGE, Integer.MAX_VALUE, -1, false, false));
}
18
Source : MischievousWereWolf.java
with Apache License 2.0
from Ph1Lou
with Apache License 2.0
from Ph1Lou
@EventHandler
public void onDayWillCome(DayWillComeEvent event) {
Player player = Bukkit.getPlayer(getPlayerUUID());
if (!game.getPlayersWW().get(getPlayerUUID()).isState(State.ALIVE)) {
return;
}
if (player == null) {
return;
}
player.sendMessage(game.translate("werewolf.role.little_girl.soon_to_be_day"));
}
18
Source : LittleGirl.java
with Apache License 2.0
from Ph1Lou
with Apache License 2.0
from Ph1Lou
@EventHandler
public void onDayWillCome(DayWillComeEvent event) {
if (!game.getPlayersWW().get(getPlayerUUID()).isState(State.ALIVE)) {
return;
}
Player player = Bukkit.getPlayer(getPlayerUUID());
if (player == null) {
return;
}
player.sendMessage(game.translate("werewolf.role.little_girl.soon_to_be_day"));
}
18
Source : LittleGirl.java
with Apache License 2.0
from Ph1Lou
with Apache License 2.0
from Ph1Lou
@EventHandler
public void onNight(NightEvent event) {
if (!game.getPlayersWW().get(getPlayerUUID()).isState(State.ALIVE)) {
return;
}
Player player = Bukkit.getPlayer(getPlayerUUID());
if (player == null) {
return;
}
player.sendMessage(game.translate("werewolf.role.little_girl.remove_armor"));
}
18
Source : SSuperiorPlayer.java
with GNU General Public License v3.0
from OmerBenGera
with GNU General Public License v3.0
from OmerBenGera
@Override
public Player asPlayer() {
return Bukkit.getPlayer(uuid);
}
18
Source : Arguments.java
with MIT License
from NyaaCat
with MIT License
from NyaaCat
public Player nextPlayerByName() {
String name = next();
if (name == null)
throw new BadCommandException("internal.error.no_more_player");
Player p = Bukkit.getPlayer(name);
if (p == null)
throw new BadCommandException("internal.error.player_not_found", name);
return p;
}
18
Source : ArrowTurret.java
with GNU General Public License v3.0
from Multitallented
with GNU General Public License v3.0
from Multitallented
public static void shootArrow(Region r, UUID uuid, String vars, boolean runUpkeep) {
shootArrow(r, Bukkit.getPlayer(uuid), vars, runUpkeep);
}
18
Source : Civilian.java
with GNU General Public License v3.0
from Multitallented
with GNU General Public License v3.0
from Multitallented
public boolean isInCombat() {
if (lastDamage < 0) {
return false;
}
Player player = Bukkit.getPlayer(uuid);
if (player == null || player.isDead()) {
lastDamager = null;
lastDamage = -1;
return false;
}
if (lastDamager != null && (Bukkit.getPlayer(lastDamager) == null || Bukkit.getPlayer(lastDamager).isDead())) {
lastDamager = null;
lastDamage = -1;
return false;
}
int combatTagDuration = ConfigManager.getInstance().getCombatTagDuration();
combatTagDuration *= 1000;
if (lastDamage + combatTagDuration < System.currentTimeMillis()) {
lastDamager = null;
lastDamage = -1;
return false;
}
return true;
}
18
Source : Civilian.java
with GNU General Public License v3.0
from Multitallented
with GNU General Public License v3.0
from Multitallented
private void updateExpBar() {
Player player = Bukkit.getPlayer(uuid);
if (mana > 99 || mana < 1) {
player.setTotalExperience(expOrbs);
return;
}
player.setTotalExperience(mana + 1288 + (mana > 33 ? 1 : 0) + (mana > 66 ? 1 : 0));
}
18
Source : InventoryManager.java
with Apache License 2.0
from MinusKube
with Apache License 2.0
from MinusKube
public List<Player> getOpenedPlayers(SmartInventory inv) {
List<Player> list = new ArrayList<>();
this.inventories.forEach((player, playerInv) -> {
if (inv.equals(playerInv))
list.add(Bukkit.getPlayer(player));
});
return list;
}
18
Source : UhcPlayer.java
with GNU General Public License v3.0
from Mezy
with GNU General Public License v3.0
from Mezy
public Player getPlayer() throws UhcPlayerNotOnlineException {
Player player = Bukkit.getPlayer(uuid);
if (player != null)
return player;
throw new UhcPlayerNotOnlineException(name);
}
18
Source : UhcPlayer.java
with GNU General Public License v3.0
from Mezy
with GNU General Public License v3.0
from Mezy
public Boolean isOnline() {
Player player = Bukkit.getPlayer(uuid);
return player != null;
}
18
Source : Arguments.java
with GNU General Public License v3.0
from Maxlego08
with GNU General Public License v3.0
from Maxlego08
/**
* @param index
* @param defaultValue
* @return
*/
protected Player argAsPlayer(int index, Player defaultValue) {
try {
return Bukkit.getPlayer(argreplacedtring(index));
} catch (Exception e) {
return defaultValue;
}
}
18
Source : PlayerData.java
with GNU General Public License v3.0
from MagmaGuy
with GNU General Public License v3.0
from MagmaGuy
public static String getDisplayName(UUID uuid) {
if (!isInMemory(uuid))
return getDatabaseString(uuid, "DisplayName");
return Bukkit.getPlayer(uuid).getCustomName();
}
18
Source : CurrencyCommandsHandler.java
with GNU General Public License v3.0
from MagmaGuy
with GNU General Public License v3.0
from MagmaGuy
public static void subtractCommand(String playerName, double amount) {
EconomyHandler.subtractCurrency(Bukkit.getPlayer(playerName).getUniqueId(), amount);
}
18
Source : GuildManager.java
with GNU General Public License v3.0
from Lix3nn53
with GNU General Public License v3.0
from Lix3nn53
public static void updateTablistOfMembers(Player player) {
if (playerToGuild.containsKey(player)) {
Guild guild = playerToGuild.get(player);
for (UUID uuid : guild.getMembers()) {
Player member = Bukkit.getPlayer(uuid);
if (member != null) {
TablistUtils.updateTablist(member);
}
}
}
}
18
Source : SideBukkit.java
with GNU General Public License v3.0
from HeartAge
with GNU General Public License v3.0
from HeartAge
@Override
public void Send(String data, String player, Boolean isplay) {
Send(Bukkit.getPlayer(player), data, isplay);
}
See More Examples