org.bukkit.OfflinePlayer Java Examples
The following examples show how to use
org.bukkit.OfflinePlayer.
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: ContainerShop.java From QuickShop-Reremake with GNU General Public License v3.0 | 6 votes |
/** * Changes the owner of this shop to the given player. * * @param owner the new owner */ @Override public void setOwner(@NotNull UUID owner) { OfflinePlayer offlinePlayer = Bukkit.getOfflinePlayer(owner); //Get the sign at first List<Sign> signs = this.getSigns(); //then setOwner this.moderator.setOwner(owner); //then change the sign for (Sign shopSign : signs) { shopSign.setLine(0, MsgUtil.getMessageOfflinePlayer("signs.header", offlinePlayer, ownerName(false))); //Don't forgot update it shopSign.update(true); } //Event Bukkit.getPluginManager().callEvent(new ShopModeratorChangedEvent(this, this.moderator)); update(); }
Example #2
Source File: NametagManager.java From NametagEdit with GNU General Public License v3.0 | 6 votes |
private FakeTeam reset(String player, FakeTeam fakeTeam) { if (fakeTeam != null && fakeTeam.getMembers().remove(player)) { boolean delete; Player removing = Bukkit.getPlayerExact(player); if (removing != null) { delete = removePlayerFromTeamPackets(fakeTeam, removing.getName()); } else { OfflinePlayer toRemoveOffline = Bukkit.getOfflinePlayer(player); delete = removePlayerFromTeamPackets(fakeTeam, toRemoveOffline.getName()); } plugin.debug(player + " was removed from " + fakeTeam.getName()); if (delete) { removeTeamPackets(fakeTeam); TEAMS.remove(fakeTeam.getName()); plugin.debug("FakeTeam " + fakeTeam.getName() + " has been deleted. Size: " + TEAMS.size()); } } return fakeTeam; }
Example #3
Source File: RentRegion.java From AreaShop with GNU General Public License v3.0 | 6 votes |
@Override public boolean checkInactive() { if(isDeleted() || !isRented()) { return false; } long inactiveSetting = getInactiveTimeUntilUnrent(); OfflinePlayer player = Bukkit.getOfflinePlayer(getRenter()); if(inactiveSetting <= 0 || player.isOp()) { return false; } long lastPlayed = getLastActiveTime(); //AreaShop.debug("currentTime=" + Calendar.getInstance().getTimeInMillis() + ", getLastPlayed()=" + lastPlayed + ", timeInactive=" + (Calendar.getInstance().getTimeInMillis()-player.getLastPlayed()) + ", inactiveSetting=" + inactiveSetting); if(Calendar.getInstance().getTimeInMillis() > (lastPlayed + inactiveSetting)) { AreaShop.info("Region " + getName() + " unrented because of inactivity for player " + getPlayerName()); AreaShop.debug("currentTime=" + Calendar.getInstance().getTimeInMillis() + ", getLastPlayed()=" + lastPlayed + ", timeInactive=" + (Calendar.getInstance().getTimeInMillis() - player.getLastPlayed()) + ", inactiveSetting=" + inactiveSetting); return this.unRent(true, null); } return false; }
Example #4
Source File: BuyRegion.java From AreaShop with GNU General Public License v3.0 | 6 votes |
@Override public boolean checkInactive() { if(isDeleted() || !isSold()) { return false; } long inactiveSetting = getInactiveTimeUntilSell(); OfflinePlayer player = Bukkit.getOfflinePlayer(getBuyer()); if(inactiveSetting <= 0 || player.isOp()) { return false; } long lastPlayed = getLastActiveTime(); //AreaShop.debug("currentTime=" + Calendar.getInstance().getTimeInMillis() + ", getLastPlayed()=" + lastPlayed + ", timeInactive=" + (Calendar.getInstance().getTimeInMillis()-player.getLastPlayed()) + ", inactiveSetting=" + inactiveSetting); if(Calendar.getInstance().getTimeInMillis() > (lastPlayed + inactiveSetting)) { AreaShop.info("Region " + getName() + " unrented because of inactivity for player " + getPlayerName()); AreaShop.debug("currentTime=" + Calendar.getInstance().getTimeInMillis() + ", getLastPlayed()=" + lastPlayed + ", timeInactive=" + (Calendar.getInstance().getTimeInMillis() - player.getLastPlayed()) + ", inactiveSetting=" + inactiveSetting); return this.sell(true, null); } return false; }
Example #5
Source File: Script.java From Slimefun4 with GNU General Public License v3.0 | 6 votes |
private Script(Config config) { Validate.notNull(config); this.config = config; this.name = config.getString("name"); this.code = config.getString("code"); String uuid = config.getString("author"); Validate.notNull(name); Validate.notNull(code); Validate.notNull(uuid); Validate.notNull(config.getStringList("rating.positive")); Validate.notNull(config.getStringList("rating.negative")); OfflinePlayer player = Bukkit.getOfflinePlayer(UUID.fromString(uuid)); this.author = player.getName() != null ? player.getName() : config.getString("author_name"); }
Example #6
Source File: ExprUUID.java From Skript with GNU General Public License v3.0 | 6 votes |
@Override @Nullable public String convert(final Object o) { if (o instanceof OfflinePlayer) { if (offlineUUIDSupported) { try { return ((OfflinePlayer) o).getUniqueId().toString(); } catch (UnsupportedOperationException e) { // Some plugins (ProtocolLib) try to emulate offline players, but fail miserably // They will throw this exception... and somehow server may freeze when this happens Skript.warning("A script tried to get uuid of an offline player, which was faked by another plugin (probably ProtocolLib)."); e.printStackTrace(); return null; } } else return ((Player) o).getUniqueId().toString(); } else if (o instanceof Entity) { return ((Entity)o).getUniqueId().toString(); } else if (o instanceof World) { return ((World) o).getUID().toString(); } return null; }
Example #7
Source File: GroupSynchronizationManager.java From DiscordSRV with GNU General Public License v3.0 | 6 votes |
@SuppressWarnings({"deprecation", "ConstantConditions"}) // 2013 Bukkit private void checkCommand(String message) { if (!DiscordSRV.getPlugin().isGroupRoleSynchronizationEnabled()) return; OfflinePlayer target = patterns.stream() .map(pattern -> pattern.matcher(message)) .filter(Matcher::find) .map(matcher -> matcher.group(1)) .filter(Objects::nonNull) .map(input -> { OfflinePlayer offlinePlayer = Bukkit.getOfflinePlayer(input); if (offlinePlayer != null) return offlinePlayer; try { return Bukkit.getOfflinePlayer(UUID.fromString(input)); } catch (IllegalArgumentException ignored) {} return null; }) .findAny().orElse(null); // run task later so that this command has time to execute & change the group state Bukkit.getScheduler().runTaskLaterAsynchronously(DiscordSRV.getPlugin(), () -> resync(target, SyncDirection.TO_DISCORD), 5 ); }
Example #8
Source File: ValueCommand.java From IridiumSkyblock with GNU General Public License v2.0 | 6 votes |
@Override public void execute(CommandSender sender, String[] args) { Player p = (Player) sender; User user = User.getUser(p); Island island; if (args.length == 2) { OfflinePlayer player = Bukkit.getOfflinePlayer(args[1]); island = User.getUser(player).getIsland(); } else { island = user.getIsland(); } if (island != null) { p.sendMessage(Utils.color(IridiumSkyblock.getMessages().islandValue.replace("%value%", island.getValue() + "").replace("%rank%", Utils.getIslandRank(island) + "").replace("%prefix%", IridiumSkyblock.getConfiguration().prefix))); } else { p.sendMessage(Utils.color(IridiumSkyblock.getMessages().noIsland.replace("%prefix%", IridiumSkyblock.getConfiguration().prefix))); } }
Example #9
Source File: MsgUtil.java From QuickShop-Reremake with GNU General Public License v3.0 | 6 votes |
/** * getMessage in messages.yml * * @param loc location * @param player The sender will send the message to * @param args args * @return message */ public static String getMessageOfflinePlayer( @NotNull String loc, @Nullable OfflinePlayer player, @NotNull String... args) { try { Optional<String> raw = messagei18n.getString(loc); if (!raw.isPresent()) { return invaildMsg + ": " + loc; } String filled = fillArgs(raw.get(), args); if (player != null) { if (plugin.getPlaceHolderAPI() != null && plugin.getPlaceHolderAPI().isEnabled() && plugin.getConfig().getBoolean("plugin.PlaceHolderAPI")) { filled = PlaceholderAPI.setPlaceholders(player, filled); Util.debugLog("Processed message " + filled + " by PlaceHolderAPI."); } } return filled; } catch (Throwable th) { plugin.getSentryErrorReporter().ignoreThrow(); th.printStackTrace(); return "Cannot load language key: " + loc + " because something not right, check the console for details."; } }
Example #10
Source File: GeneralRegion.java From AreaShop with GNU General Public License v3.0 | 6 votes |
/** * Get the landlord of this region (the player that receives any revenue from this region). * @return The UUID of the landlord of this region */ public UUID getLandlord() { String landlord = getStringSetting("general.landlord"); if(landlord != null && !landlord.isEmpty()) { try { return UUID.fromString(landlord); } catch(IllegalArgumentException e) { // Incorrect UUID } } String landlordName = getStringSetting("general.landlordName"); if(landlordName != null && !landlordName.isEmpty()) { @SuppressWarnings("deprecation") OfflinePlayer offlinePlayer = Bukkit.getOfflinePlayer(landlordName); if(offlinePlayer != null) { return offlinePlayer.getUniqueId(); } } return null; }
Example #11
Source File: InviteCommand.java From DungeonsXL with GNU General Public License v3.0 | 6 votes |
@Override public void onExecute(String[] args, CommandSender sender) { ResourceWorld resource = plugin.getMapRegistry().get(args[2]); OfflinePlayer player = Bukkit.getOfflinePlayer(args[1]); if (resource != null) { if (player != null) { resource.addInvitedPlayer(player); MessageUtil.sendMessage(sender, DMessage.CMD_INVITE_SUCCESS.getMessage(args[1], args[2])); } else { MessageUtil.sendMessage(sender, DMessage.ERROR_NO_SUCH_PLAYER.getMessage(args[2])); } } else { MessageUtil.sendMessage(sender, DMessage.ERROR_NO_SUCH_MAP.getMessage(args[2])); } }
Example #12
Source File: DefaultMapManager.java From MapManager with MIT License | 5 votes |
@Override public Set<Short> getOccupiedIdsFor(OfflinePlayer player) { Set<Short> ids = new HashSet<>(); for (MapWrapper wrapper : MANAGED_MAPS) { short s; if ((s = wrapper.getController().getMapId(player)) >= 0) { ids.add(s); } } return ids; }
Example #13
Source File: CoopCommand.java From IridiumSkyblock with GNU General Public License v2.0 | 5 votes |
@Override public void admin(CommandSender sender, String[] args, Island island) { Player p = (Player) sender; if (island != null) { if (args.length != 4) { p.openInventory(island.getCoopGUI().getInventory()); return; } OfflinePlayer player = Bukkit.getOfflinePlayer(args[3]); if (player != null) { User u = User.getUser(player); if (!island.equals(u.getIsland()) && u.getIsland() != null) { if (island.coopInvites.contains(u.islandID)) { island.coopInvites.remove(u.islandID); island.addCoop(u.getIsland()); } else { u.getIsland().inviteCoop(island); sender.sendMessage(Utils.color(IridiumSkyblock.getMessages().coopInviteSent.replace("%player%", User.getUser(u.getIsland().getOwner()).name).replace("%prefix%", IridiumSkyblock.getConfiguration().prefix))); } } 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))); } } else { sender.sendMessage(Utils.color(IridiumSkyblock.getMessages().noIsland.replace("%prefix%", IridiumSkyblock.getConfiguration().prefix))); } }
Example #14
Source File: Players.java From CardinalPGM with MIT License | 5 votes |
public static String getName(ServerOperator who, boolean flairs) { if (who instanceof OfflinePlayer) { OfflinePlayer player = (OfflinePlayer) who; return player.isOnline() ? (flairs ? player.getPlayer().getDisplayName() : Teams.getTeamColorByPlayer(player) + player.getPlayer().getName()) : Rank.getPrefix(player.getUniqueId()) + ChatColor.DARK_AQUA + player.getName(); } else { return ChatColor.GOLD + "\u2756" + ChatColor.DARK_AQUA + "Console"; } }
Example #15
Source File: PermissionsExHandler.java From AuthMeReloaded with GNU General Public License v3.0 | 5 votes |
@Override public boolean addToGroup(OfflinePlayer player, String group) { if (!PermissionsEx.getPermissionManager().getGroupNames().contains(group)) { return false; } PermissionUser user = PermissionsEx.getUser(player.getName()); user.addGroup(group); return true; }
Example #16
Source File: Database.java From MarriageMaster with GNU General Public License v3.0 | 5 votes |
public MarriagePlayerData getPlayer(OfflinePlayer bPlayer) { MarriagePlayerData player = cache.getPlayer(bPlayer.getUniqueId()); if(player == null) { player = new MarriagePlayerData(bPlayer); cache.cache(player); // Let's put the new player into the cache load(player); } return player; }
Example #17
Source File: PurgeBannedPlayersCommandTest.java From AuthMeReloaded with GNU General Public License v3.0 | 5 votes |
private static OfflinePlayer[] offlinePlayersWithNames(String... names) { OfflinePlayer[] players = new OfflinePlayer[names.length]; for (int i = 0; i < names.length; ++i) { OfflinePlayer player = mock(OfflinePlayer.class); given(player.getName()).willReturn(names[i]); players[i] = player; } return players; }
Example #18
Source File: Main.java From PlayTimeTracker with MIT License | 5 votes |
private void printStatistic(CommandSender s, OfflinePlayer p) { s.sendMessage(Locale.get("statistic-for", p.getName())); SessionedRecord rec = updater.getFullRecord(p.getUniqueId()); if (rec.dbRec == null) { s.sendMessage(Locale.get("statistic-no-record")); } else { s.sendMessage(Locale.get("statistic-day", Locale.formatTime(rec.dbRec.dailyTime))); s.sendMessage(Locale.get("statistic-week", Locale.formatTime(rec.dbRec.weeklyTime))); s.sendMessage(Locale.get("statistic-month", Locale.formatTime(rec.dbRec.monthlyTime))); s.sendMessage(Locale.get("statistic-total", Locale.formatTime(rec.dbRec.totalTime))); if (p.isOnline() && rec.getSessionTime() > 0) { s.sendMessage(Locale.get("statistic-session", Locale.formatTime(rec.getSessionTime()))); } } }
Example #19
Source File: CommandClaimOptionPlayer.java From GriefDefender with MIT License | 5 votes |
@CommandCompletion("@gdplayers @gdoptions @gdcontexts @gddummy") @CommandAlias("cop") @Description("Gets/Sets option for a player in claim you are standing in.") @Syntax("<player> <option> <value> [context[key=value]]") @Subcommand("option player") public void execute(Player src, OfflinePlayer player, @Optional String[] args) throws InvalidCommandArgument { this.subject = PermissionHolderCache.getInstance().getOrCreateUser(player); this.friendlySubjectName = player.getName(); super.execute(src, args); }
Example #20
Source File: Database.java From CardinalPGM with MIT License | 5 votes |
private Element getPlayerElement(OfflinePlayer player) { for (Element element : document.getRootElement().getChildren()) { if (element.getAttributeValue("uuid") != null && player.getUniqueId().equals(UUID.fromString(element.getAttributeValue("uuid")))) return element; } Element newPlayer = new Element("player").setAttribute(new Attribute("uuid", player.getUniqueId().toString())); document.getRootElement().addContent(newPlayer); return newPlayer; }
Example #21
Source File: AdminCommand.java From civcraft with GNU General Public License v2.0 | 5 votes |
public void playerreport_cmd() { LinkedList<OfflinePlayer> offplayers = new LinkedList<OfflinePlayer>(); for (OfflinePlayer offplayer : Bukkit.getOfflinePlayers()) { offplayers.add(offplayer); } CivMessage.sendHeading(sender, "Players with Goodies"); CivMessage.send(sender, "Processing (this may take a while)"); TaskMaster.syncTask(new ReportPlayerInventoryTask(sender, offplayers), 0); }
Example #22
Source File: WorldGuard6Hook.java From Skript with GNU General Public License v3.0 | 5 votes |
@SuppressWarnings("deprecation") @Override public boolean isOwner(final OfflinePlayer p) { if (supportsUUIDs) return region.isOwner(plugin.wrapOfflinePlayer(p)); else return region.isOwner(p.getName()); }
Example #23
Source File: PunishmentScheduler.java From Hawk with GNU General Public License v3.0 | 5 votes |
public void authorize(OfflinePlayer p) { UUID uuid = p.getUniqueId(); if(convicts.containsKey(uuid)) { convicts.get(uuid).setValue(true); hawk.broadcastAlertToAdmins(USER_AUTHORIZED.replace("%player%", p.getName())); } else { hawk.broadcastAlertToAdmins(USER_NOT_FOUND.replace("%player%", p.getName())); } }
Example #24
Source File: DefaultMapManager.java From MapManager with MIT License | 5 votes |
@Override public MapWrapper getWrapperForId(OfflinePlayer player, short id) { for (MapWrapper wrapper : getMapsVisibleTo(player)) { if (wrapper.getController().getMapId(player) == id) { return wrapper; } } return null; }
Example #25
Source File: TutorialManager.java From Civs with GNU General Public License v3.0 | 4 votes |
public void completeStep(Civilian civilian, TutorialType type, String param) { if (!ConfigManager.getInstance().isUseTutorial()) { return; } if (civilian.getTutorialIndex() == -1) { return; } TutorialPath path = tutorials.get(civilian.getTutorialPath()); if (path == null) { return; } if (path.getSteps().size() <= civilian.getTutorialIndex()) { return; } TutorialStep step = path.getSteps().get(civilian.getTutorialIndex()); if (step == null) { return; } if (!step.getType().equalsIgnoreCase(type.toString())) { return; } if ((type.equals(TutorialType.BUILD) || type.equals(TutorialType.UPKEEP) || type.equals(TutorialType.BUY)) && !param.equalsIgnoreCase(step.getRegion())) { return; } if (type.equals(TutorialType.KILL) && !param.equals(step.getKillType())) { return; } int progress = civilian.getTutorialProgress(); int maxProgress = step.getTimes(); if (progress + 1 < maxProgress) { civilian.setTutorialProgress(progress + 1); CivilianManager.getInstance().saveCivilian(civilian); // TODO send message of progress made? return; } OfflinePlayer offlinePlayer = Bukkit.getOfflinePlayer(civilian.getUuid()); Player player = null; if (offlinePlayer.isOnline()) { player = offlinePlayer.getPlayer(); } ArrayList<CVItem> itemList = step.getRewardItems(); if (itemList != null && !itemList.isEmpty() && player != null && player.isOnline()) { giveItemsToPlayer(player, itemList); } double money = step.getRewardMoney(); if (money > 0 && Civs.econ != null) { Civs.econ.depositPlayer(offlinePlayer, money); } List<String> permissions = step.getPermissions(); if (Civs.perm != null && !permissions.isEmpty()) { for (String permission : permissions) { PermissionUtil.applyPermission(offlinePlayer, permission); } } List<String> commands = step.getCommands(); if (!commands.isEmpty()) { for (String command : commands) { CommandUtil.performCommand(offlinePlayer, command); } } civilian.setTutorialProgress(0); civilian.setTutorialIndex(civilian.getTutorialIndex() + 1); CivilianManager.getInstance().saveCivilian(civilian); Util.spawnRandomFirework(player); sendMessageForCurrentTutorialStep(civilian, true); }
Example #26
Source File: CraftScoreboard.java From Thermos with GNU General Public License v3.0 | 4 votes |
public void resetScores(OfflinePlayer player) throws IllegalArgumentException { Validate.notNull(player, "OfflinePlayer cannot be null"); board.func_96515_c(player.getName()); }
Example #27
Source File: ProfileDisguiseEvent.java From NickNamer with MIT License | 4 votes |
public ProfileDisguiseEvent(@Nonnull OfflinePlayer disguised, @Nonnull Player receiver, @Nonnull GameProfileWrapper gameProfile, boolean async) { super(disguised, receiver, async); this.gameProfile = gameProfile; }
Example #28
Source File: CraftTeam.java From Thermos with GNU General Public License v3.0 | 4 votes |
public void addPlayer(OfflinePlayer player) throws IllegalStateException, IllegalArgumentException { Validate.notNull(player, "OfflinePlayer cannot be null"); CraftScoreboard scoreboard = checkState(); scoreboard.board.func_151392_a(player.getName(), team.getRegisteredName()); }
Example #29
Source File: Minepacks.java From Minepacks with GNU General Public License v3.0 | 4 votes |
@Override public void openBackpack(@NotNull final Player opener, @NotNull final OfflinePlayer owner, final boolean editable) { openBackpack(opener, owner, editable, null); }
Example #30
Source File: Database.java From CardinalPGM with MIT License | 4 votes |
public String get(OfflinePlayer player, String key) { return getKey(getPlayerElement(player), key).getAttributeValue("value"); }