@Override public UUID getUniqueId() { return player.getUniqueId(); }
@Override public String getName() { return this.player.getName(); }
@Override public boolean hasPermission(EntityPlayerMP player, String permission) { return ((Player) player).hasPermission(permission); }
@Override public SessionKey getSessionKey() { return new SessionKeyImpl(player.getUniqueId(), player.getName()); }
@Override public void printRaw(String msg) { for (String part : msg.split("\n")) { this.player.sendMessage(TextSerializers.FORMATTING_CODE.deserialize(part)); } }
@Override public Location getLocation() { org.spongepowered.api.world.Location<World> entityLoc = this.player.getLocation(); Vector3d entityRot = this.player.getRotation(); return SpongeWorldEdit.inst().getAdapter().adapt(entityLoc, entityRot); }
/** * Gets a copy of the current {@link GameModeData} for this {@link Player}. * * @return A copy of the current game mode data */ default GameModeData getGameModeData() { return get(GameModeData.class).get(); }
@Override public void setPosition(Vector3 pos, float pitch, float yaw) { org.spongepowered.api.world.Location<World> loc = new org.spongepowered.api.world.Location<>( this.player.getWorld(), pos.getX(), pos.getY(), pos.getZ() ); this.player.setLocationAndRotation(loc, new Vector3d(pitch, yaw, 0)); }
@Override public com.sk89q.worldedit.world.World getWorld() { return SpongeWorldEdit.inst().getAdapter().getWorld(player.getWorld()); }
@Override public boolean setLocation(Location location) { return player.setLocation(SpongeAdapter.adapt(location)); }
/** * Gets if the {@link Player} has played on the {@link Server} before. Added * as a utility. * * @return True if played before, false otherwise */ default boolean hasPlayedBefore() { return !firstPlayed().equals(lastPlayed()); }
/** * Returns whether this player has an open inventory at the moment * or not. * * @return Whether this player is viewing an inventory or not */ default boolean isViewingInventory() { return getOpenInventory().isPresent(); }
public String[] getGroups(Player player) { return player.getParents().stream() .map(SubjectReference::getSubjectIdentifier) .toArray(String[]::new); } }
/** * Gets the {@link Value} of the {@link Instant} that a {@link Player} * joined the {@link Server} the last time. * * @return The value for the last time a player joined */ default Value<Instant> lastPlayed() { return getValue(Keys.LAST_DATE_PLAYED).get(); }
/** * Gets a copy of the {@link StatisticData} for this user. * * @return A copy of the statistic data */ default StatisticData getStatisticData() { return get(StatisticData.class).get(); }
public boolean hasPermission(Player player, String permission) { return player.hasPermission(permission); }
/** * Gets a copy of the current {@link DisplayNameData} for this * {@link Player}. * * @return A copy of the current display name data */ default DisplayNameData getDisplayNameData() { return get(DisplayNameData.class).get(); }
/** * Gets the current {@link GameMode} for this {@link Player}. * * @return The current game mode value */ default Value<GameMode> gameMode() { return getValue(Keys.GAME_MODE).get(); }
/** * Gets a copy of the current {@link JoinData}. * * <p>Since a {@link Player} is already online, it means that the player * has joined the server at least once, meaning there is a guaranteed * initial join {@link Instant}. Users may not have ever joined a server * before.</p> * * @return A copy of the join data */ default JoinData getJoinData() { return get(JoinData.class).get(); }
/** * Gets the {@link Value} of the {@link Instant} that a {@link Player} * joined the {@link Server} the first time. * * @return The value for the first time a player joined */ default Value<Instant> firstPlayed() { return getValue(Keys.FIRST_DATE_PLAYED).get(); }