Java Code Examples for org.spongepowered.api.entity.living.player.Player#getUniqueId()
The following examples show how to use
org.spongepowered.api.entity.living.player.Player#getUniqueId() .
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: PlayerEventHandler.java From GriefDefender with MIT License | 6 votes |
@Listener(order = Order.FIRST) public void onPlayerJoin(ClientConnectionEvent.Join event) { GDTimings.PLAYER_JOIN_EVENT.startTimingIfSync(); Player player = event.getTargetEntity(); if (!GriefDefenderPlugin.getInstance().claimsEnabledForWorld(player.getWorld().getUniqueId())) { GDTimings.PLAYER_JOIN_EVENT.stopTimingIfSync(); return; } UUID playerID = player.getUniqueId(); final GDPlayerData playerData = this.dataStore.getOrCreatePlayerData(player.getWorld(), playerID); final GDClaim claim = this.dataStore.getClaimAtPlayer(playerData, player.getLocation()); if (claim.isInTown()) { playerData.inTown = true; } GDTimings.PLAYER_JOIN_EVENT.stopTimingIfSync(); }
Example 2
Source File: PlayerOnlineListener.java From Plan with GNU Lesser General Public License v3.0 | 6 votes |
private void actOnQuitEvent(ClientConnectionEvent.Disconnect event) { long time = System.currentTimeMillis(); Player player = event.getTargetEntity(); String playerName = player.getName(); UUID playerUUID = player.getUniqueId(); UUID serverUUID = serverInfo.getServerUUID(); JSONCache.invalidate(DataID.SERVER_OVERVIEW, serverUUID); JSONCache.invalidate(DataID.GRAPH_PERFORMANCE, serverUUID); SpongeAFKListener.AFK_TRACKER.loggedOut(playerUUID, time); nicknameCache.removeDisplayName(playerUUID); boolean banned = isBanned(player.getProfile()); dbSystem.getDatabase().executeTransaction(new BanStatusTransaction(playerUUID, () -> banned)); sessionCache.endSession(playerUUID, time) .ifPresent(endedSession -> dbSystem.getDatabase().executeTransaction(new SessionEndTransaction(endedSession))); if (config.isTrue(ExportSettings.EXPORT_ON_ONLINE_STATUS_CHANGE)) { processing.submitNonCritical(() -> exporter.exportPlayerPage(playerUUID, playerName)); } }
Example 3
Source File: VirtualChestInventoryDispatcher.java From VirtualChest with GNU Lesser General Public License v3.0 | 6 votes |
public boolean update(String id, Player player) { UUID uuid = player.getUniqueId(); if (inventories.containsKey(id)) { Tuple<String, WeakReference<Container>> tuple = containers.get(uuid); if (!Objects.isNull(tuple) && this.isInventoryOpening(player, id, tuple)) { // noinspection ConstantConditions inventories.get(id).getUpdaterFor(id, player).accept(tuple.getSecond().get().first()); return true; } } return false; }
Example 4
Source File: GodListener.java From UltimateCore with MIT License | 6 votes |
@Listener public void onDamage(DamageEntityEvent event) { if (!(event.getTargetEntity() instanceof Player)) { return; } Player p = (Player) event.getTargetEntity(); UltimateUser up = UltimateCore.get().getUserService().getUser(p); if (up.get(GodKeys.GOD).orElse(false)) { event.setCancelled(true); //Send error message to player trying to hit, if player Player t = event.getCause().first(Player.class).orElse(null); if (t != null && t.getUniqueId() != p.getUniqueId()) { Messages.send(t, "god.onhit"); } } }
Example 5
Source File: DeafCommand.java From UltimateCore with MIT License | 6 votes |
@Override public CommandResult execute(CommandSource sender, CommandContext args) throws CommandException { checkPermission(sender, DeafPermissions.UC_DEAF_DEAF_BASE); Player t = args.<Player>getOne("player").get(); Long time = args.hasAny("time") ? args.<Long>getOne("time").get() : -1L; Text reason = args.hasAny("reason") ? Text.of(args.<String>getOne("reason").get()) : Messages.getFormatted("deaf.command.deaf.defaultreason"); if ((DeafPermissions.UC_DEAF_EXEMPTPOWER.getIntFor(t) > DeafPermissions.UC_DEAF_POWER.getIntFor(sender)) && sender instanceof Player) { throw new ErrorMessageException(Messages.getFormatted(sender, "deaf.command.deaf.exempt", "%player%", t)); } Long endtime = time == -1L ? -1L : System.currentTimeMillis() + time; Long starttime = System.currentTimeMillis(); UUID deafr = sender instanceof Player ? ((Player) sender).getUniqueId() : UUID.fromString("00000000-0000-0000-0000-000000000000"); UUID deafd = t.getUniqueId(); Deaf deaf = new Deaf(deafd, deafr, endtime, starttime, reason); UltimateUser ut = UltimateCore.get().getUserService().getUser(t); ut.offer(DeafKeys.DEAF, deaf); Messages.send(sender, "deaf.command.deaf.success", "%player%", VariableUtil.getNameEntity(t), "%time%", (time == -1L ? Messages.getFormatted("core.time.ever") : TimeUtil.format(time)), "%reason%", reason); Messages.send(t, "deaf.deafed", "%time%", (time == -1L ? Messages.getFormatted("core.time.ever") : TimeUtil.format(time)), "%reason%", reason); return CommandResult.success(); }
Example 6
Source File: LoanDenyCommand.java From EconomyLite with MIT License | 5 votes |
@Override public void run(Player src, CommandContext args) { UUID uuid = src.getUniqueId(); // Check if the player has a loan being offered if (module.tableLoans.containsKey(uuid)) { module.tableLoans.remove(uuid); src.sendMessage(messages.getMessage("module.loan.no")); } else { src.sendMessage(messages.getMessage("module.loan.noloan")); } }
Example 7
Source File: SkinDownloader.java From ChangeSkin with MIT License | 5 votes |
public SkinDownloader(ChangeSkinSponge plugin, CommandSource invoker, Player receiver, UUID targetUUID , boolean keepSkin) { super(plugin.getCore(), keepSkin, targetUUID, receiver.getUniqueId()); this.plugin = plugin; this.invoker = invoker; this.receiver = receiver; }
Example 8
Source File: LoanPayCommand.java From EconomyLite with MIT License | 5 votes |
@Override public void run(Player src, CommandContext args) { if (args.getOne("amount").isPresent()) { UUID uuid = src.getUniqueId(); double payment = args.<Double>getOne("amount").get(); Currency cur = EconomyLite.getEconomyService().getDefaultCurrency(); Optional<Double> bOpt = module.getLoanManager().getLoanBalance(uuid); if (bOpt.isPresent()) { double loanBal = bOpt.get(); if (payment > loanBal) { // Pay only what is needed if (module.getLoanManager().removeLoanBalance(uuid, loanBal)) { // Successfully payed loan src.sendMessage(messages.getMessage("module.loan.payed", "amount", String.format(Locale.ENGLISH, "%,.2f", loanBal), "label", getPrefix(loanBal, cur))); } else { // Failed to pay src.sendMessage(messages.getMessage("module.loan.payedfail")); } } else { // Pay entire request if (module.getLoanManager().removeLoanBalance(uuid, payment)) { // Successfully payed loan src.sendMessage(messages.getMessage("module.loan.payed", "amount", String.format(Locale.ENGLISH, "%,.2f", payment), "label", getPrefix(payment, cur))); } else { // Failed to pay src.sendMessage(messages.getMessage("module.loan.payedfail")); } } } } else { src.sendMessage(messages.getMessage("command.error")); } }
Example 9
Source File: MuteCommand.java From UltimateCore with MIT License | 5 votes |
@Override public CommandResult execute(CommandSource sender, CommandContext args) throws CommandException { checkPermission(sender, MutePermissions.UC_MUTE_MUTE_BASE); //Get player & Check exempt Player t = args.<Player>getOne("player").get(); if ((MutePermissions.UC_MUTE_EXEMPTPOWER.getIntFor(t) > MutePermissions.UC_MUTE_POWER.getIntFor(sender)) && sender instanceof Player) { throw new ErrorMessageException(Messages.getFormatted(sender, "mute.command.mute.exempt", "%player%", t)); } //Get time & reason Long time = args.hasAny("time") ? args.<Long>getOne("time").get() : -1L; Text reason = args.hasAny("reason") ? Text.of(args.<String>getOne("reason").get()) : Messages.getFormatted("mute.command.mute.defaultreason"); Long endtime = time == -1L ? -1L : System.currentTimeMillis() + time; Long starttime = System.currentTimeMillis(); UUID muter = sender instanceof Player ? ((Player) sender).getUniqueId() : UUID.fromString("00000000-0000-0000-0000-000000000000"); UUID muted = t.getUniqueId(); Mute mute = new Mute(muted, muter, endtime, starttime, reason); UltimateUser ut = UltimateCore.get().getUserService().getUser(t); ut.offer(MuteKeys.MUTE, mute); Messages.send(sender, "mute.command.mute.success", "%player%", VariableUtil.getNameEntity(t), "%time%", (time == -1L ? Messages.getFormatted("core.time.ever") : TimeUtil.format(time)), "%reason%", reason); Messages.send(t, "mute.muted", "%time%", (time == -1L ? Messages.getFormatted("core.time.ever") : TimeUtil.format(time)), "%reason%", reason); return CommandResult.success(); }
Example 10
Source File: SpongeAFKListener.java From Plan with GNU Lesser General Public License v3.0 | 5 votes |
private void performedAction(Player player) { UUID uuid = player.getUniqueId(); long time = System.currentTimeMillis(); boolean ignored = ignorePermissionInfo.computeIfAbsent(uuid, keyUUID -> player.hasPermission(Permissions.IGNORE_AFK.getPermission())); if (ignored) { AFK_TRACKER.hasIgnorePermission(uuid); ignorePermissionInfo.put(uuid, true); return; } else { ignorePermissionInfo.put(uuid, false); } AFK_TRACKER.performedAction(uuid, time); }
Example 11
Source File: PlayerOnlineListener.java From Plan with GNU Lesser General Public License v3.0 | 5 votes |
@Listener(order = Order.DEFAULT) public void beforeQuit(ClientConnectionEvent.Disconnect event) { Player player = event.getTargetEntity(); UUID playerUUID = player.getUniqueId(); String playerName = player.getName(); processing.submitNonCritical(() -> extensionService.updatePlayerValues(playerUUID, playerName, CallEvents.PLAYER_LEAVE)); }
Example 12
Source File: GDPermissionUser.java From GriefDefender with MIT License | 5 votes |
public GDPermissionUser(Player player) { super(player.getUniqueId().toString()); this.uniqueId = player.getUniqueId(); this.worldUniqueId = player.getWorld().getUniqueId(); this.user = player; this.userName = player.getName(); }
Example 13
Source File: SpongeDeathListener.java From Plan with GNU Lesser General Public License v3.0 | 5 votes |
private Runnable handlePlayerKill(long time, UUID victimUUID, Player killer) { Optional<ItemStack> inMainHand = killer.getItemInHand(HandTypes.MAIN_HAND); ItemStack inHand = inMainHand.orElse(killer.getItemInHand(HandTypes.OFF_HAND).orElse(ItemStack.empty())); ItemType type = inHand.isEmpty() ? ItemTypes.AIR : inHand.getType(); return victimUUID != null ? new PlayerKillProcessor(killer.getUniqueId(), time, victimUUID, new ItemNameFormatter().apply(type.getName())) : new MobKillProcessor(killer.getUniqueId()); }
Example 14
Source File: SpongeDeathListener.java From Plan with GNU Lesser General Public License v3.0 | 5 votes |
private Runnable handleProjectileKill(long time, UUID victimUUID, Projectile projectile) { ProjectileSource source = projectile.getShooter(); if (!(source instanceof Player)) { return null; } Player player = (Player) source; String projectileName = new EntityNameFormatter().apply(projectile.getType().getName()); return victimUUID != null ? new PlayerKillProcessor(player.getUniqueId(), time, victimUUID, projectileName) : new MobKillProcessor(player.getUniqueId()); }
Example 15
Source File: PlayerContext.java From ChatUI with MIT License | 4 votes |
public PlayerContext(Player player, int width, int height, boolean forceUnicode, FontData fontData) { this(player.getUniqueId(), width, height, forceUnicode, new TextUtils(fontData, forceUnicode, player.getUniqueId())); checkArgument(height >= 1, "Height must be at least one"); checkArgument(width >= 1, "Width must be at least one"); }
Example 16
Source File: Account.java From FlexibleLogin with MIT License | 4 votes |
public Account(Player player, String password) { this(player.getUniqueId(), player.getName(), password, player.getConnection().getAddress().getAddress()); }
Example 17
Source File: VirtualChestEconomyManager.java From VirtualChest with GNU Lesser General Public License v3.0 | 4 votes |
private UniqueAccount getAccountByPlayer(Player player) { UUID uniqueId = player.getUniqueId(); String message = "Unsupported account for uuid: " + uniqueId.toString(); return economyService.getOrCreateAccount(uniqueId).orElseThrow(() -> new IllegalArgumentException(message)); }
Example 18
Source File: PlayerOnlineListener.java From Plan with GNU Lesser General Public License v3.0 | 4 votes |
private void actOnJoinEvent(ClientConnectionEvent.Join event) { Player player = event.getTargetEntity(); UUID playerUUID = player.getUniqueId(); UUID serverUUID = serverInfo.getServerUUID(); long time = System.currentTimeMillis(); JSONCache.invalidate(DataID.SERVER_OVERVIEW, serverUUID); JSONCache.invalidate(DataID.GRAPH_PERFORMANCE, serverUUID); SpongeAFKListener.AFK_TRACKER.performedAction(playerUUID, time); String world = player.getWorld().getName(); Optional<GameMode> gameMode = player.getGameModeData().get(Keys.GAME_MODE); String gm = gameMode.map(mode -> mode.getName().toUpperCase()).orElse("ADVENTURE"); Database database = dbSystem.getDatabase(); database.executeTransaction(new WorldNameStoreTransaction(serverUUID, world)); InetAddress address = player.getConnection().getAddress().getAddress(); String playerName = player.getName(); String displayName = player.getDisplayNameData().displayName().get().toPlain(); boolean gatheringGeolocations = config.isTrue(DataGatheringSettings.GEOLOCATIONS); if (gatheringGeolocations) { database.executeTransaction( new GeoInfoStoreTransaction(playerUUID, address, time, geolocationCache::getCountry) ); } database.executeTransaction(new PlayerServerRegisterTransaction(playerUUID, () -> time, playerName, serverUUID)); Session session = new Session(playerUUID, serverUUID, time, world, gm); session.putRawData(SessionKeys.NAME, playerName); session.putRawData(SessionKeys.SERVER_NAME, serverInfo.getServer().getIdentifiableName()); sessionCache.cacheSession(playerUUID, session) .ifPresent(previousSession -> database.executeTransaction(new SessionEndTransaction(previousSession))); database.executeTransaction(new NicknameStoreTransaction( playerUUID, new Nickname(displayName, time, serverUUID), (uuid, name) -> nicknameCache.getDisplayName(playerUUID).map(name::equals).orElse(false) )); processing.submitNonCritical(() -> extensionService.updatePlayerValues(playerUUID, playerName, CallEvents.PLAYER_JOIN)); if (config.isTrue(ExportSettings.EXPORT_ON_ONLINE_STATUS_CHANGE)) { processing.submitNonCritical(() -> exporter.exportPlayerPage(playerUUID, playerName)); } }
Example 19
Source File: DefaultChatView.java From ChatUI with MIT License | 4 votes |
public DefaultChatView(Player player) { this.playerUUID = player.getUniqueId(); }
Example 20
Source File: SpongeContextManager.java From LuckPerms with MIT License | 4 votes |
@Override public UUID getUniqueId(Player player) { return player.getUniqueId(); }