Java Code Examples for org.bukkit.OfflinePlayer#hasPlayedBefore()
The following examples show how to use
org.bukkit.OfflinePlayer#hasPlayedBefore() .
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: DiscordBanListener.java From DiscordSRV with GNU General Public License v3.0 | 6 votes |
@Override public void onGuildBan(GuildBanEvent event) { UUID linkedUuid = DiscordSRV.getPlugin().getAccountLinkManager().getUuid(event.getUser().getId()); if (linkedUuid == null) { DiscordSRV.debug("Not handling ban for user " + event.getUser() + " because they didn't have a linked account"); return; } OfflinePlayer offlinePlayer = Bukkit.getOfflinePlayer(linkedUuid); if (!offlinePlayer.hasPlayedBefore()) return; if (!DiscordSRV.config().getBoolean("BanSynchronizationDiscordToMinecraft")) { DiscordSRV.debug("Not handling ban for user " + event.getUser() + " because doing so is disabled in the config"); return; } Bukkit.getBanList(BanList.Type.NAME).addBan(offlinePlayer.getName(), LangUtil.Message.BAN_DISCORD_TO_MINECRAFT.toString(), null, "Discord"); }
Example 2
Source File: DiscordBanListener.java From DiscordSRV with GNU General Public License v3.0 | 6 votes |
@Override public void onGuildUnban(GuildUnbanEvent event) { UUID linkedUuid = DiscordSRV.getPlugin().getAccountLinkManager().getUuid(event.getUser().getId()); if (linkedUuid == null) { DiscordSRV.debug("Not handling unban for user " + event.getUser() + " because they didn't have a linked account"); return; } OfflinePlayer offlinePlayer = Bukkit.getOfflinePlayer(linkedUuid); if (!offlinePlayer.hasPlayedBefore()) return; if (!DiscordSRV.config().getBoolean("BanSynchronizationDiscordToMinecraft")) { DiscordSRV.debug("Not handling unban for user " + event.getUser() + " because doing so is disabled in the config"); return; } String playerName = offlinePlayer.getName(); if (StringUtils.isNotBlank(playerName)) //this literally should not happen but intellij likes bitching about not null checking Bukkit.getBanList(BanList.Type.NAME).pardon(playerName); }
Example 3
Source File: PlayerUtils.java From SaneEconomy with GNU General Public License v3.0 | 6 votes |
/** * Get an online or offline player from Bukkit. * This is guaranteed to be a player who has played before, but is not guaranteed to be currently online. * @param playerNameOrUUID The player's name or UUID * @return OfflinePlayer object, or null if never played */ public static OfflinePlayer getOfflinePlayer(String playerNameOrUUID) { OfflinePlayer player = tryGetFromUUID(playerNameOrUUID); if ((player != null) && (player.hasPlayedBefore() || player.isOnline())) { return player; } //noinspection ReuseOfLocalVariable player = Bukkit.getServer().getPlayer(playerNameOrUUID); if (player == null) { player = Bukkit.getServer().getOfflinePlayer(playerNameOrUUID); } if ((player != null) && (!player.hasPlayedBefore() && !player.isOnline())) { return null; } return player; }
Example 4
Source File: RegionMenu.java From Civs with GNU General Public License v3.0 | 5 votes |
private void sellRegion(Civilian civilian, Region region) { Player player = Bukkit.getPlayer(civilian.getUuid()); if (Civs.econ == null || !Civs.econ.has(player, region.getForSale())) { player.sendMessage(Civs.getPrefix() + LocaleManager.getInstance().getTranslationWithPlaceholders(player, "not-enough-money").replace("$1", Util.getNumberFormat(region.getForSale(), civilian.getLocale()))); return; } region.getRawPeople().clear(); region.getRawPeople().put(civilian.getUuid(), Constants.OWNER); RegionType regionType = (RegionType) ItemManager.getInstance().getItemType(region.getType()); Civs.econ.withdrawPlayer(player, region.getForSale()); String localName = LocaleManager.getInstance().getTranslationWithPlaceholders(player, regionType.getProcessedName() + LocaleConstants.NAME_SUFFIX); Set<UUID> owners = region.getOwners(); int split = owners.size(); if (split > 0 && Civs.econ != null) { double cutOfTheSale = region.getForSale() / (double) split; for (UUID ownerUuid : owners) { OfflinePlayer offlinePlayer = Bukkit.getOfflinePlayer(ownerUuid); if (offlinePlayer.hasPlayedBefore()) { Civs.econ.depositPlayer(offlinePlayer, cutOfTheSale); if (offlinePlayer.isOnline()) { Civilian ownerCiv = CivilianManager.getInstance().getCivilian(offlinePlayer.getUniqueId()); ((Player) offlinePlayer).sendMessage(Civs.getPrefix() + LocaleManager.getInstance().getTranslationWithPlaceholders( offlinePlayer, "region-sold").replace("$1", localName) .replace("$2", player.getDisplayName()).replace("$3", Util.getNumberFormat(cutOfTheSale, ownerCiv.getLocale()))); } } } } player.sendMessage(Civs.getPrefix() + LocaleManager.getInstance().getTranslationWithPlaceholders(player, "region-bought").replace("$1", localName) .replace("$2", Util.getNumberFormat(region.getForSale(), civilian.getLocale()))); region.setForSale(-1); RegionManager.getInstance().saveRegion(region); }
Example 5
Source File: BukkitUserImportRefiner.java From Plan with GNU Lesser General Public License v3.0 | 5 votes |
@SuppressWarnings("deprecation") private String getUuidByOfflinePlayer(String name) { OfflinePlayer player = plugin.getServer().getOfflinePlayer(name); if (!player.hasPlayedBefore()) { return null; } return player.getUniqueId().toString(); }
Example 6
Source File: BukkitUserImportRefiner.java From Plan with GNU Lesser General Public License v3.0 | 5 votes |
private String getNameByOfflinePlayer(String uuid) { OfflinePlayer player = plugin.getServer().getOfflinePlayer(UUID.fromString(uuid)); if (!player.hasPlayedBefore()) { return null; } return player.getName(); }
Example 7
Source File: NovaPlayerImpl.java From NovaGuilds with GNU General Public License v3.0 | 5 votes |
@Override public double getMoney() { OfflinePlayer oPlayer = CompatibilityUtils.getOfflinePlayer(getUUID()); if(!oPlayer.hasPlayedBefore() || oPlayer.getName() == null) { return 0D; } return NovaGuilds.getInstance().getDependencyManager().getEconomy().getBalance(oPlayer); }
Example 8
Source File: NovaPlayerImpl.java From NovaGuilds with GNU General Public License v3.0 | 5 votes |
@Override public void addMoney(double money) { OfflinePlayer oPlayer = CompatibilityUtils.getOfflinePlayer(getUUID()); if(!oPlayer.hasPlayedBefore() || oPlayer.getName() == null) { return; } NovaGuilds.getInstance().getDependencyManager().getEconomy().depositPlayer(oPlayer, money); }
Example 9
Source File: NovaPlayerImpl.java From NovaGuilds with GNU General Public License v3.0 | 5 votes |
@Override public void takeMoney(double money) { OfflinePlayer oPlayer = CompatibilityUtils.getOfflinePlayer(getUUID()); if(!oPlayer.hasPlayedBefore() || oPlayer.getName() == null) { return; } NovaGuilds.getInstance().getDependencyManager().getEconomy().withdrawPlayer(oPlayer, money); }
Example 10
Source File: TrustCommand.java From uSkyBlock with GNU General Public License v3.0 | 5 votes |
@Override protected boolean doExecute(final String alias, final Player player, final PlayerInfo pi, final IslandInfo island, Map<String, Object> data, String... args) { if (args.length == 0) { player.sendMessage(tr("\u00a7eThe following players are trusted on your island:")); player.sendMessage(tr("\u00a74{0}", island.getTrustees())); player.sendMessage(tr("\u00a7eThe following leaders trusts you:")); player.sendMessage(tr("\u00a74{0}", getLeaderNames(pi))); player.sendMessage(tr("\u00a7eTo trust/untrust from your island, use /island trust <player>")); return true; } else if (args.length == 1) { final String name = args[0]; if (island.getMembers().contains(name)) { player.sendMessage(tr("\u00a74Members are already trusted!")); return true; } //noinspection deprecation OfflinePlayer offlinePlayer = Bukkit.getOfflinePlayer(name); if (!offlinePlayer.hasPlayedBefore() && !offlinePlayer.isOnline()) { player.sendMessage(tr("\u00a74Unknown player {0}", name)); return true; } if (alias.equals("trust")) { island.trustPlayer(offlinePlayer, player); if (offlinePlayer.isOnline()) { offlinePlayer.getPlayer().sendMessage(tr("\u00a7eYou are now trusted on \u00a74{0}''s \u00a7eisland.", pi.getDisplayName())); } island.sendMessageToIslandGroup(true, marktr("\u00a7a{0} trusted {1} on the island"), player.getName(), name); } else { island.untrustPlayer(offlinePlayer, player); if (offlinePlayer.isOnline()) { offlinePlayer.getPlayer().sendMessage(tr("\u00a7eYou are no longer trusted on \u00a74{0}''s \u00a7eisland.", pi.getDisplayName())); } island.sendMessageToIslandGroup(true, marktr("\u00a7c{0} revoked trust in {1} on the island"), player.getName(), name); } WorldGuardHandler.updateRegion(island); return true; } return false; }
Example 11
Source File: UtilityBukkit.java From LunaChat with GNU Lesser General Public License v3.0 | 5 votes |
/** * 指定された名前のオフラインプレイヤーを取得する * @param name プレイヤー名 * @return オフラインプレイヤー */ @SuppressWarnings("deprecation") public static OfflinePlayer getOfflinePlayer(String name) { if (name == null) return null; OfflinePlayer player = Bukkit.getOfflinePlayer(name); if (player == null || (!player.hasPlayedBefore() && !player.isOnline())) return null; return player; }
Example 12
Source File: BackpackCommand.java From Slimefun4 with GNU General Public License v3.0 | 4 votes |
@Override public void onExecute(CommandSender sender, String[] args) { if (!(sender instanceof Player) || !sender.hasPermission("slimefun.command.backpack")) { SlimefunPlugin.getLocalization().sendMessage(sender, "messages.no-permission", true); return; } if (args.length != 3) { SlimefunPlugin.getLocalization().sendMessage(sender, "messages.usage", true, msg -> msg.replace("%usage%", "/sf backpack <Player> <ID>")); return; } if (!PatternUtils.NUMERIC.matcher(args[2]).matches()) { SlimefunPlugin.getLocalization().sendMessage(sender, "commands.backpack.invalid-id"); return; } @SuppressWarnings("deprecation") OfflinePlayer backpackOwner = Bukkit.getOfflinePlayer(args[1]); if (!(backpackOwner instanceof Player) && !backpackOwner.hasPlayedBefore()) { SlimefunPlugin.getLocalization().sendMessage(sender, "commands.backpack.player-never-joined"); return; } int id = Integer.parseInt(args[2]); PlayerProfile.get(backpackOwner, profile -> { if (!profile.getBackpack(id).isPresent()) { SlimefunPlugin.getLocalization().sendMessage(sender, "commands.backpack.backpack-does-not-exist"); return; } Slimefun.runSync(() -> { ItemStack item = SlimefunItems.RESTORED_BACKPACK.clone(); SlimefunPlugin.getBackpackListener().setBackpackId(backpackOwner, item, 2, id); ((Player) sender).getInventory().addItem(item); SlimefunPlugin.getLocalization().sendMessage(sender, "commands.backpack.restored-backpack-given"); }); }); }
Example 13
Source File: DeleteCommand.java From PlayerVaults with GNU General Public License v3.0 | 4 votes |
@Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { if (VaultOperations.isLocked()) { sender.sendMessage(Lang.TITLE + Lang.LOCKED.toString()); return true; } switch (args.length) { case 1: if (sender instanceof Player) { VaultOperations.deleteOwnVault((Player) sender, args[0]); } else { sender.sendMessage(Lang.TITLE.toString() + ChatColor.RED + Lang.PLAYER_ONLY); } break; case 2: OfflinePlayer searchPlayer = Bukkit.getOfflinePlayer(args[0]); String target = args[0]; if (searchPlayer != null && searchPlayer.hasPlayedBefore()) { target = searchPlayer.getUniqueId().toString(); } // TODO: fix the stupid message inconsistencies where sometimes this class sends, sometimes vaultops does. if (args[1].equalsIgnoreCase("all")) { if (sender.hasPermission("playervaults.delete.all")) { VaultManager.getInstance().deleteAllVaults(target); sender.sendMessage(Lang.TITLE.toString() + Lang.DELETE_OTHER_VAULT_ALL.toString().replaceAll("%p", target)); PlayerVaults.getInstance().getLogger().info(String.format("%s deleted ALL vaults belonging to %s", sender.getName(), target)); } else { sender.sendMessage(Lang.TITLE.toString() + Lang.NO_PERMS); } } VaultOperations.deleteOtherVault(sender, target, args[1]); break; default: sender.sendMessage(Lang.TITLE + "/" + label + " <number>"); sender.sendMessage(Lang.TITLE + "/" + label + " <player> <number>"); sender.sendMessage(Lang.TITLE + "/" + label + " <player> all"); } return true; }