Java Code Examples for org.bukkit.Bukkit#getPlayer()
The following examples show how to use
org.bukkit.Bukkit#getPlayer() .
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: PermissionEffect.java From Civs with GNU General Public License v3.0 | 6 votes |
private void removePermission(UUID uuid, String permission) { HashSet<String> permissions = permissionMap.get(uuid); if (permissions == null) { return; } Player player = Bukkit.getPlayer(uuid); if (player == null) { permissionMap.remove(uuid); return; } Civs.perm.playerRemove(player, permission); if (permissions.size() < 2) { permissionMap.remove(uuid); return; } permissionMap.get(uuid).remove(permission); }
Example 2
Source File: QPlayer.java From Quests with MIT License | 6 votes |
/** * @return 0 if success, 1 if no permission, 2 is only data loaded, 3 if player not found */ public int openCategory(Category category, QMenuQuest qMenuQuest) { if (onlyDataLoaded) { return 2; } Player player = Bukkit.getPlayer(this.uuid); if (player == null) { return 3; } if (category.isPermissionRequired() && !player.hasPermission("quests.category." + category.getId())) { return 1; } player.openInventory(qMenuQuest.toInventory(1)); EventInventory.track(this.uuid, qMenuQuest); return 0; }
Example 3
Source File: Civilian.java From Civs with GNU General Public License v3.0 | 6 votes |
public int getCountNonStashItems(String name) { Player player = Bukkit.getPlayer(uuid); if (player == null) { return 0; } int count = 0; for (ItemStack is : player.getInventory()) { if (!CVItem.isCivsItem(is)) { continue; } CivItem civItem = CivItem.getFromItemStack(is); if (civItem == null) { continue; } if (!civItem.getProcessedName().equalsIgnoreCase(name) && !civItem.getGroups().contains(name)) { continue; } count += is.getAmount(); } count += getCountRegions(name); return count; }
Example 4
Source File: MuteArgument.java From Hawk with GNU General Public License v3.0 | 5 votes |
@Override public boolean process(CommandSender sender, Command cmd, String label, String[] args) { if (args.length < 4) return false; Player target = Bukkit.getPlayer(args[1]); if (target == null) { sender.sendMessage(ChatColor.RED + "Unknown player \"" + args[1] + "\""); return true; } if (target.hasPermission(Hawk.BASE_PERMISSION + ".admin")) { sender.sendMessage(ChatColor.RED + "You may not mute that player."); return true; } long expireTime = -1; long seconds = -1; try { seconds = Long.parseLong(args[2]); expireTime = seconds * 1000 + System.currentTimeMillis(); } catch (NumberFormatException ignore) { } if (seconds < 1) { sender.sendMessage(ChatColor.RED + "Third argument must be a positive integer."); return true; } List<String> list = (new LinkedList<>(Arrays.asList(args))).subList(3, args.length); String reason = ChatColor.translateAlternateColorCodes('&', String.join(" ", list)); hawk.getMuteManager().mute(target.getUniqueId(), expireTime, reason); target.sendMessage(ChatColor.RED + "You have been muted for the duration of " + seconds + (seconds == 1 ? " second " : " seconds ") + "for: " + reason); sender.sendMessage(ChatColor.GOLD + target.getName() + " has been muted for " + seconds + (seconds == 1 ? " second." : " seconds.")); return true; }
Example 5
Source File: NMS_1_15.java From 1.13-Command-API with Apache License 2.0 | 5 votes |
@Override public Player getPlayer(CommandContext cmdCtx, String str) throws CommandSyntaxException { Player target = Bukkit.getPlayer(((GameProfile) ArgumentProfile.a(cmdCtx, str).iterator().next()).getId()); if (target == null) { throw ArgumentProfile.a.create(); } else { return target; } }
Example 6
Source File: HuntEffect.java From Civs with GNU General Public License v3.0 | 5 votes |
private Player hasValidSign(Location l, RegionType rt, UUID uuid) { Player player = Bukkit.getPlayer(uuid); Civilian civilian = CivilianManager.getInstance().getCivilian(uuid); Block block = l.getBlock().getRelative(BlockFace.UP); BlockState state = block.getState(); if (!(state instanceof Sign)) { return null; } Sign sign = (Sign) state; Player targetPlayer = null; try { targetPlayer = Bukkit.getPlayer(sign.getLine(0)); } catch (Exception e) { block.breakNaturally(); player.sendMessage(Civs.getPrefix() + LocaleManager.getInstance().getTranslation(civilian.getLocale(), "invalid-name")); return null; } if (targetPlayer == null || !targetPlayer.isOnline()) { block.breakNaturally(); player.sendMessage(Civs.getPrefix() + LocaleManager.getInstance().getTranslation(civilian.getLocale(), "invalid-name")); return null; } if (!targetPlayer.getWorld().equals(player.getWorld())) { block.breakNaturally(); player.sendMessage(Civs.getPrefix() + LocaleManager.getInstance().getTranslation(civilian.getLocale(), "target-not-in-world")); return null; } return targetPlayer; }
Example 7
Source File: NotesCmd.java From StaffPlus with GNU General Public License v3.0 | 5 votes |
private void addNote(CommandSender sender, String option, String note) { Player player = Bukkit.getPlayer(option); if(player != null) { userManager.get(player.getUniqueId()).addPlayerNote(note);; message.send(sender, messages.noteAdded.replace("%target%", player.getName()), messages.prefixGeneral); }else message.send(sender, messages.playerOffline, messages.prefixGeneral); }
Example 8
Source File: IntruderEffect.java From Civs with GNU General Public License v3.0 | 5 votes |
@EventHandler public void onSRegionEnter(PlayerEnterTownEvent event) { RegionManager rm = RegionManager.getInstance(); Town town = event.getTown(); if (town == null) { return; } if (town.getPeople().containsKey(event.getUuid())) { return; } Player player = Bukkit.getPlayer(event.getUuid()); if (Civs.perm != null && Civs.perm.has(player, Constants.PVP_EXEMPT_PERMISSION)) { return; } Region r = getIntruderRegion(town); if (r == null) { return; } if (!r.hasUpkeepItems()) { return; } r.runUpkeep(true); broadcastMessageToAllTownMembers(town, true, player.getDisplayName()); }
Example 9
Source File: NMS_1_14_3.java From 1.13-Command-API with Apache License 2.0 | 5 votes |
@Override public Player getPlayer(CommandContext cmdCtx, String str) throws CommandSyntaxException { Player target = Bukkit.getPlayer(((GameProfile) ArgumentProfile.a(cmdCtx, str).iterator().next()).getId()); if (target == null) { throw ArgumentProfile.a.create(); } else { return target; } }
Example 10
Source File: CommandEffect.java From Civs with GNU General Public License v3.0 | 5 votes |
private void sendCommand(UUID uuid, String command) { Player player = Bukkit.getPlayer(uuid); if (player == null) { return; } player.performCommand(command); }
Example 11
Source File: PunishmentCommands.java From CardinalPGM with MIT License | 5 votes |
@Command(aliases = {"freeze"}, usage = "<player>", desc = "Freeze a player", min = 1, max = 1) @CommandPermissions("cardinal.punish.freeze") public static void freeze(CommandContext cmd, CommandSender sender) throws CommandException { Player player = Bukkit.getPlayer(cmd.getString(0)); if (player == null) throw new CommandException(ChatConstant.ERROR_NO_PLAYER_MATCH.getMessage(ChatUtil.getLocale(sender))); FreezeModule freezeModule = GameHandler.getGameHandler().getMatch().getModules().getModule(FreezeModule.class); if (freezeModule.getFrozenPlayers().contains(player)) { throw new CommandException(new LocalizedChatMessage(ChatConstant.ERROR_PLAYER_ALREADY_FROZEN, player.getDisplayName() + ChatColor.RED).getMessage(ChatUtil.getLocale(sender))); } freezeModule.togglePlayerFreeze(player, sender); }
Example 12
Source File: GiveBoosterCommand.java From IridiumSkyblock with GNU General Public License v2.0 | 5 votes |
@Override public void execute(CommandSender sender, String[] args) { if (args.length != 4 && args.length != 3) { sender.sendMessage(Utils.color(IridiumSkyblock.getConfiguration().prefix) + "/is givebooster <player> <booster> <amount>"); return; } if (Bukkit.getPlayer(args[1]) != null) { OfflinePlayer player = Bukkit.getPlayer(args[1]); if (player != null) { Island island = User.getUser(player).getIsland(); if (island != null) { try { int amount = args.length == 3 ? 3600 : Integer.parseInt(args[3]); if (args[2].equalsIgnoreCase("exp")) { island.setExpBooster(amount); } if (args[2].equalsIgnoreCase("farming")) { island.setFarmingBooster(amount); } if (args[2].equalsIgnoreCase("flight")) { island.setFlightBooster(amount); } if (args[2].equalsIgnoreCase("spawner")) { island.setSpawnerBooster(amount); } } catch (Exception e) { sender.sendMessage(args[2] + "is not a number"); } } else { sender.sendMessage(Utils.color(IridiumSkyblock.getMessages().playerNoIsland.replace("%prefix%", IridiumSkyblock.getConfiguration().prefix))); } } else { sender.sendMessage(Utils.color(IridiumSkyblock.getMessages().playerOffline.replace("%prefix%", IridiumSkyblock.getConfiguration().prefix))); } } }
Example 13
Source File: LanguageMenu.java From Civs with GNU General Public License v3.0 | 5 votes |
@Override public boolean doActionAndCancel(Civilian civilian, String actionString, ItemStack clickedItem) { if (actionString.equals("select-lang")) { String itemName = clickedItem.getItemMeta().getDisplayName(); String langKey = clickedItem.getItemMeta().getLore().get(0); civilian.setLocale(langKey); CivilianManager.getInstance().saveCivilian(civilian); Player player = Bukkit.getPlayer(civilian.getUuid()); player.sendMessage(Civs.getPrefix() + LocaleManager.getInstance() .getTranslation(langKey, "language-set").replace("$1", itemName)); return true; } return super.doActionAndCancel(civilian, actionString, clickedItem); }
Example 14
Source File: InviteCommand.java From uSkyBlock with GNU General Public License v3.0 | 4 votes |
@Override protected boolean doExecute(String alias, Player player, PlayerInfo pi, IslandInfo island, Map<String, Object> data, String... args) { if (args.length == 0) { player.sendMessage(I18nUtil.tr("\u00a7eUse\u00a7f /island invite <playername>\u00a7e to invite a player to your island.")); if (!island.isParty()) { return true; } if (!island.isLeader(player) || !island.hasPerm(player, "canInviteOthers")) { player.sendMessage(I18nUtil.tr("\u00a74Only the island''s owner can invite!")); return true; } int diff = island.getMaxPartySize() - island.getPartySize(); if (diff > 0) { player.sendMessage(I18nUtil.tr("\u00a7aYou can invite {0} more players.", diff)); } else { player.sendMessage(I18nUtil.tr("\u00a74You can't invite any more players.")); } } if (args.length == 1) { //noinspection deprecation Player otherPlayer = Bukkit.getPlayer(args[0]); if (!island.hasPerm(player, "canInviteOthers")) { player.sendMessage(I18nUtil.tr("\u00a74You do not have permission to invite others to this island!")); return true; } if (otherPlayer == null || !otherPlayer.isOnline()) { player.sendMessage(I18nUtil.tr("\u00a74That player is offline or doesn't exist.")); return true; } if (player.getName().equalsIgnoreCase(otherPlayer.getName())) { player.sendMessage(I18nUtil.tr("\u00a74You can't invite yourself!")); return true; } if (island.isLeader(otherPlayer)) { player.sendMessage(I18nUtil.tr("\u00a74That player is the leader of your island!")); return true; } plugin.getServer().getPluginManager().callEvent(new InviteEvent(player, island, otherPlayer)); } return true; }
Example 15
Source File: WandCondition.java From BetonQuest with GNU General Public License v3.0 | 4 votes |
@Override protected Boolean execute(String playerID) throws QuestRuntimeException { Player player = PlayerConverter.getPlayer(playerID); int heldAmount; switch (type) { case IS_LOST: for (LostWand lost : api.getLostWands()) { Player owner = Bukkit.getPlayer(UUID.fromString(lost.getOwnerId())); if (owner == null) continue; if (owner.equals(player)) { return true; } } return false; case IN_HAND: ItemStack wandItem = null; wandItem = player.getInventory().getItemInMainHand(); if (!api.isWand(wandItem)) { return false; } Wand wand1 = api.getWand(wandItem); return checkWand(wand1, playerID); case IN_INVENTORY: heldAmount = 0; for (ItemStack item : player.getInventory().getContents()) { if (item == null) continue; if (api.isWand(item)) { Wand wand2 = api.getWand(item); if (checkWand(wand2, playerID)) { heldAmount += item.getAmount(); if (amount == null || heldAmount >= amount.getInt(playerID)) { return true; } } } } return false; default: return false; } }
Example 16
Source File: EnterCommand.java From DungeonsXL with GNU General Public License v3.0 | 4 votes |
@Override public void onExecute(String[] args, CommandSender sender) { Player captain = (Player) sender; String targetName = args.length == 3 ? args[2] : args[1]; PlayerGroup joining = args.length == 3 ? plugin.getGroupCache().get(args[1]) : plugin.getPlayerGroup(captain); PlayerGroup target = plugin.getGroupCache().get(targetName); if (target == null) { Player targetPlayer = Bukkit.getPlayer(targetName); if (targetPlayer != null) { target = plugin.getPlayerGroup(targetPlayer); } } if (target == null) { MessageUtil.sendMessage(sender, DMessage.ERROR_NO_SUCH_GROUP.getMessage(targetName)); return; } Game game = target.getGame(); if (game == null) { MessageUtil.sendMessage(sender, DMessage.ERROR_NOT_IN_GAME.getMessage(targetName)); return; } if (joining != null && joining.getGame() != null) { MessageUtil.sendMessage(sender, DMessage.ERROR_LEAVE_GAME.getMessage()); return; } if (joining == null) { joining = new DGroup(plugin, captain, game.getDungeon()); } if (joining.getLeader() != captain && !DPermission.hasPermission(sender, DPermission.BYPASS)) { MessageUtil.sendMessage(sender, DMessage.ERROR_NOT_LEADER.getMessage()); return; } joining.setGameWorld(game.getWorld()); game.addGroup(joining); joining.sendMessage(DMessage.CMD_ENTER_SUCCESS.getMessage(joining.getName(), target.getName())); for (Player player : joining.getMembers().getOnlinePlayers()) { new DGamePlayer(plugin, player, game.getWorld()); } }
Example 17
Source File: BlueprintsMenu.java From Civs with GNU General Public License v3.0 | 4 votes |
@Override @SuppressWarnings("unchecked") public ItemStack createItemStack(Civilian civilian, MenuIcon menuIcon, int count) { Player player = Bukkit.getPlayer(civilian.getUuid()); if (player == null) { return new ItemStack(Material.AIR); } if (menuIcon.getKey().equals("blueprints")) { Map<String, Integer> stashItems = civilian.getStashItems(); if (stashItems.isEmpty()) { return new ItemStack(Material.AIR); } int page = (int) MenuManager.getData(civilian.getUuid(), Constants.PAGE); int startIndex = page * menuIcon.getIndex().size(); String[] stashArray = new String[stashItems.size()]; stashArray = stashItems.keySet().toArray(stashArray); if (stashArray.length <= startIndex + count) { return new ItemStack(Material.AIR); } String currentStashItemName = stashArray[startIndex + count]; CivItem civItem = ItemManager.getInstance().getItemType(currentStashItemName); if (civItem == null) { civilian.getStashItems().remove(currentStashItemName); CivilianManager.getInstance().saveCivilian(civilian); return new ItemStack(Material.AIR); } CVItem cvItem = civItem.clone(); cvItem.setDisplayName(LocaleManager.getInstance().getTranslationWithPlaceholders(player, civItem.getProcessedName() + LocaleConstants.NAME_SUFFIX)); List<String> lore = new ArrayList<>(); lore.add(civilian.getUuid().toString()); lore.add(civItem.getDisplayName()); boolean isTown = civItem.getItemType().equals(CivItem.ItemType.TOWN); if (isTown) { lore.add(ChatColor.GREEN + Util.parseColors(LocaleManager.getInstance() .getTranslationWithPlaceholders(player, "town-instructions") .replace("$1", civItem.getProcessedName()))); } else { lore.addAll(Util.textWrap(civilian, Util.parseColors(civItem.getDescription(civilian.getLocale())))); } cvItem.setLore(lore); cvItem.setQty(civilian.getStashItems().get(currentStashItemName)); HashMap<String, Integer> itemsInView = (HashMap<String, Integer>) MenuManager.getData(civilian.getUuid(), Constants.ITEMS_IN_VIEW); if (itemsInView == null) { return new ItemStack(Material.AIR); } itemsInView.put(currentStashItemName, civilian.getStashItems().get(currentStashItemName)); ItemStack itemStack = cvItem.createItemStack(); putActions(civilian, menuIcon, itemStack, count); return itemStack; } return super.createItemStack(civilian, menuIcon, count); }
Example 18
Source File: VendorMenu.java From EnchantmentsEnhance with GNU General Public License v3.0 | 4 votes |
@Override public void update() { getInventory().clear(); getActions().clear(); Player player = Bukkit.getPlayer(playerName); }
Example 19
Source File: SubCommandMgr.java From SuperVanish with Mozilla Public License 2.0 | 4 votes |
public void execute(Command cmd, CommandSender sender, String[] args, String label) { try { // invalid usage by default Executable executable = new InvalidUsage(plugin); // vanish self if (args.length == 0) { if (sender instanceof Player) executable = new VanishSelf(plugin); executable.execute(cmd, sender, args, label); return; } if ((args[0].equalsIgnoreCase("on") || args[0].equalsIgnoreCase("off") || args[0].equalsIgnoreCase("vanish") || args[0].equalsIgnoreCase("reappear") || args[0].equalsIgnoreCase("enable") || args[0].equalsIgnoreCase("disable") || args[0].equalsIgnoreCase("-s")) && args.length == 1) { executable = new VanishSelf(plugin); } // if (args[0].equalsIgnoreCase("help") || args[0].equalsIgnoreCase("commands") || args[0].equalsIgnoreCase("?")) { executable = new ShowHelp(plugin); } if (args[0].equalsIgnoreCase("printstacktrace") || args[0].equalsIgnoreCase("logstacktrace") || args[0].equalsIgnoreCase("dumpstacktrace") || args[0].equalsIgnoreCase("stacktrace")) { executable = new PrintStacktrace(plugin); } if (args[0].equalsIgnoreCase("toggleitempickups") || args[0].equalsIgnoreCase("toggleitempickup") || args[0].equalsIgnoreCase("toggleitem") || args[0].equalsIgnoreCase("toggleitems") || args[0].equalsIgnoreCase("togglepickup") || args[0].equalsIgnoreCase("togglepickups") || args[0].equalsIgnoreCase("pickup") || args[0].equalsIgnoreCase("pickups") || args[0].equalsIgnoreCase("tipu") || args[0].equalsIgnoreCase("tip")) { executable = new ToggleItemPickups(plugin); } if (args[0].equalsIgnoreCase("recreatecfg") || args[0].equalsIgnoreCase("rccfg") || args[0].equalsIgnoreCase("recreateconfig") || args[0].equalsIgnoreCase("rcconfig") || args[0].equalsIgnoreCase("updatecfg") || args[0].equalsIgnoreCase("recreate") || args[0].equalsIgnoreCase("recreatefiles") || args[0].equalsIgnoreCase("rf") || args[0].equalsIgnoreCase("rcf") || args[0].equalsIgnoreCase("refi")) { executable = new RecreateFiles(plugin); } if (args[0].equalsIgnoreCase("reload") || args[0].equalsIgnoreCase("rl") || args[0].equalsIgnoreCase("re") || args[0].equalsIgnoreCase("rlc") || args[0].equalsIgnoreCase("rlcfg") || args[0].equalsIgnoreCase("reloadconfig") || args[0].equalsIgnoreCase("rlp") || args[0].equalsIgnoreCase("rlpl") || args[0].equalsIgnoreCase("reloadplugin")) { executable = new Reload(plugin); } if (args[0].equalsIgnoreCase("list")) { executable = new VanishedList(plugin); } if (args[0].equalsIgnoreCase("login")) { executable = new BroadcastLogin(plugin); } if (args[0].equalsIgnoreCase("logout")) { executable = new BroadcastLogout(plugin); } // vanish other if ((args[0].equalsIgnoreCase("on") || args[0].equalsIgnoreCase("off") || args[0].equalsIgnoreCase("vanish") || args[0].equalsIgnoreCase("reappear") || args[0].equalsIgnoreCase("enable") || args[0].equalsIgnoreCase("disable")) && args.length > 1 || Bukkit.getPlayer(args[0]) != null) { executable = Bukkit.getPlayer(args[0]) != null && !(args[0].equalsIgnoreCase("on") || args[0].equalsIgnoreCase("off") || args[0].equalsIgnoreCase("vanish") || args[0].equalsIgnoreCase("reappear") || args[0].equalsIgnoreCase("enable") || args[0].equalsIgnoreCase("disable")) ? new VanishOther(Bukkit.getPlayer(args[0]), plugin) : new VanishOther(plugin); } executable.execute(cmd, sender, args, label); } catch (Exception e) { plugin.logException(e); } }
Example 20
Source File: ChannelMemberPlayer.java From LunaChat with GNU Lesser General Public License v3.0 | 2 votes |
/** * BukkitのPlayerを取得する * @return Player * @see com.github.ucchyocean.lc.channel.ChannelPlayer#getPlayer() */ @Override public Player getPlayer() { return Bukkit.getPlayer(id); }