Java Code Examples for org.spongepowered.api.entity.living.player.Player#getName()
The following examples show how to use
org.spongepowered.api.entity.living.player.Player#getName() .
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: 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 2
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 3
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 4
Source File: CachedPlayer.java From Web-API with MIT License | 5 votes |
public CachedPlayer(Player player) { super(player); this.uuid = UUID.fromString(player.getUniqueId().toString()); this.name = player.getName(); this.isOnline = true; this.location = new CachedLocation(player.getLocation()); this.rotation = player.getRotation().clone(); this.velocity = player.getVelocity().clone(); this.scale = player.getScale().clone(); this.address = player.getConnection().getAddress().toString(); this.latency = player.getConnection().getLatency(); // Collect unlocked advancements for (AdvancementTree tree : player.getUnlockedAdvancementTrees()) { addUnlockedAdvancements(player, tree.getRootAdvancement()); } // This will be moved to the other constructor once Sponge implements the offline inventory API this.helmet = player.getHelmet().map(ItemStack::copy).orElse(null); this.chestplate = player.getChestplate().map(ItemStack::copy).orElse(null); this.leggings = player.getLeggings().map(ItemStack::copy).orElse(null); this.boots = player.getBoots().map(ItemStack::copy).orElse(null); this.inventory = new CachedInventory(player.getInventory()); }
Example 5
Source File: Utils.java From EssentialCmds with MIT License | 5 votes |
public static String getNick(Player player) { CommentedConfigurationNode node = Configs.getConfig(mainConfig).getNode("nick", player.getUniqueId().toString()); if (configManager.getString(node).isPresent()) return node.getString(); else return player.getName(); }
Example 6
Source File: VirtualChestInventory.java From VirtualChest with GNU Lesser General Public License v3.0 | 4 votes |
private CompletableFuture<Boolean> runCommand(ClickInventoryEvent e, Player player, int slotIndex) { CompletableFuture<Boolean> future = new CompletableFuture<>(); List<VirtualChestItem> items = VirtualChestInventory.this.items.get(slotIndex); int size = items.size(); List<CompletableFuture<?>> setFutures = new ArrayList<>(size); List<Supplier<CompletableFuture<?>>> clearFutures = new ArrayList<>(size); try (Timing ignored = VirtualChestTimings.updateAndRefreshMapping(name, slotIndex).startTiming()) { String playerName = player.getName(); ClickStatus status = new ClickStatus(e); String keyString = slotIndexToKey(slotIndex); VirtualChestPermissionManager permissionManager = plugin.getPermissionManager(); logger.debug("Player {} tries to click the chest GUI at {} with {}", playerName, keyString, status); for (VirtualChestItem item : items) { UUID actionUUID = UUID.randomUUID(); List<String> list = item.getIgnoredPermissions(); setFutures.add(permissionManager.setIgnored(player, actionUUID, list)); clearFutures.add(() -> { if (future.isDone() || !item.matchRequirements(player, slotIndex, playerName)) { return permissionManager.clearIgnored(player, actionUUID); } boolean record = recordManager.filter(name, VirtualChestInventory.this); Optional<VirtualChestActionDispatcher> optional = item.getAction(status); if (record) { recordManager.recordSlotClick(actionUUID, name, slotIndex, status, player); logger.debug("Player {} now submits an action: {}", playerName, actionUUID); } if (!optional.isPresent()) { future.complete(true); return permissionManager.clearIgnored(player, actionUUID); } Tuple<Boolean, CompletableFuture<CommandResult>> tuple; tuple = optional.get().runCommand(plugin, actionUUID, player, record); future.complete(tuple.getFirst()); return tuple.getSecond().thenCompose(r -> permissionManager.clearIgnored(player, actionUUID)); }); } } CompletableFuture.allOf(setFutures.toArray(new CompletableFuture<?>[0])) .thenComposeAsync(v -> CompletableFuture.allOf(clearFutures.stream().map(Supplier::get) .toArray(CompletableFuture[]::new)), executorService).thenRun(() -> future.complete(true)); return future; }
Example 7
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 8
Source File: WEHook.java From RedProtect with GNU General Public License v3.0 | 4 votes |
public static Region pasteWithWE(Player p, File file) { Location<World> loc = p.getLocation(); Region r = null; if (p.getLocation().getBlockRelative(Direction.DOWN).getBlock().getType().equals(BlockTypes.WATER) || p.getLocation().getBlockRelative(Direction.DOWN).getBlock().getType().equals(BlockTypes.FLOWING_WATER)) { RedProtect.get().lang.sendMessage(p, "playerlistener.region.needground"); return null; } SpongePlayer sp = SpongeWorldEdit.inst().wrapPlayer(p); SpongeWorld ws = SpongeWorldEdit.inst().getWorld(p.getWorld()); LocalSession session = SpongeWorldEdit.inst().getSession(p); Closer closer = Closer.create(); try { ClipboardFormat format = ClipboardFormat.findByAlias("schematic"); FileInputStream fis = closer.register(new FileInputStream(file)); BufferedInputStream bis = closer.register(new BufferedInputStream(fis)); ClipboardReader reader = format.getReader(bis); WorldData worldData = ws.getWorldData(); Clipboard clipboard = reader.read(ws.getWorldData()); session.setClipboard(new ClipboardHolder(clipboard, worldData)); Vector bmin = clipboard.getMinimumPoint(); Vector bmax = clipboard.getMaximumPoint(); Location<World> min = loc.add(bmin.getX(), bmin.getY(), bmin.getZ()); Location<World> max = loc.add(bmax.getX(), bmax.getY(), bmax.getZ()); PlayerRegion leader = new PlayerRegion(p.getUniqueId().toString(), p.getName()); RegionBuilder rb2 = new DefineRegionBuilder(p, min, max, "", leader, new HashSet<>(), false); if (rb2.ready()) { r = rb2.build(); } ClipboardHolder holder = session.getClipboard(); Operation op = holder.createPaste(session.createEditSession(sp), ws.getWorldData()).to(session.getPlacementPosition(sp)).build(); Operations.completeLegacy(op); } catch (IOException | EmptyClipboardException | IncompleteRegionException | MaxChangedBlocksException e) { CoreUtil.printJarVersion(); e.printStackTrace(); } return r; }
Example 9
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()); }