org.spongepowered.api.entity.living.player.User Java Examples
The following examples show how to use
org.spongepowered.api.entity.living.player.User.
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: NucleusServlet.java From Web-API with MIT License | 6 votes |
@GET @Path("/mail/{player}") @Permission({ "mail", "list" }) @ApiOperation(value = "List mail", notes = "Get a list of all mail messages of a player.") public Collection<CachedMailMessage> listMail( @PathParam("player") @ApiParam("The uuid of the player") CachedPlayer player) throws NotFoundException { Optional<NucleusMailService> optSrv = NucleusAPI.getMailService(); if (!optSrv.isPresent()) { throw new InternalServerErrorException("Nuclues mail service not available"); } NucleusMailService srv = optSrv.get(); Optional<User> optUser = player.getUser(); if (!optUser.isPresent()) { throw new InternalServerErrorException("Could not get user"); } return WebAPI.runOnMain( () -> srv.getMail(optUser.get(), mailMessage -> { return true; }).stream() .map(CachedMailMessage::new) .collect(Collectors.toList()) ); }
Example #2
Source File: UCLanguageService.java From UltimateCore with MIT License | 6 votes |
@Override public String getRaw(CommandSource receiver, String key, Object... vars) { String raw; if (custom.containsKey(key)) { raw = custom.get(key); } else if (english.containsKey(key)) { raw = english.get(key); } else { Messages.log(Text.of(TextColors.RED, "ERROR: Failed to get message for key " + key)); return null; } String first = null; for (Object var : vars) { if (first == null) { first = var.toString(); } else { if (var instanceof Text || var instanceof CommandSource || var instanceof User) { //Will replaced later if needed } else { raw = raw.replace(first, var.toString()); } first = null; } } return raw; }
Example #3
Source File: PermissionHandler.java From RedProtect with GNU General Public License v3.0 | 6 votes |
private int getClaimLimit(User user) { int limit = RedProtect.get().config.configRoot().region_settings.claim.amount_per_player; List<Integer> limits = new ArrayList<>(); if (limit > 0) { if (!user.hasPermission("redprotect.limits.claim.unlimited")) { for (String perm : RedProtect.get().config.configRoot().permissions_limits.claims) { RedProtect.get().logger.debug(LogLevel.DEFAULT, "Perm: " + perm); if (user.hasPermission(perm)) { RedProtect.get().logger.debug(LogLevel.DEFAULT, "Has claim perm: " + perm); String pStr = perm.replaceAll("[^-?0-9]+", ""); if (!pStr.isEmpty()) { limits.add(Integer.parseInt(pStr)); } } } } else { return -1; } } if (limits.size() > 0) { limit = Collections.max(limits); } return limit; }
Example #4
Source File: AddCommand.java From EconomyLite with MIT License | 6 votes |
@Override public void run(CommandSource src, CommandContext args) { if (args.getOne("player").isPresent() && args.getOne("amount").isPresent()) { User target = args.<User>getOne("player").get(); String targetName = target.getName(); BigDecimal toAdd = BigDecimal.valueOf(args.<Double>getOne("amount").get()); Optional<UniqueAccount> uOpt = EconomyLite.getEconomyService().getOrCreateAccount(target.getUniqueId()); if (uOpt.isPresent()) { UniqueAccount targetAccount = uOpt.get(); if (targetAccount.deposit(EconomyLite.getCurrencyService().getCurrentCurrency(), toAdd, Cause.of(EventContext.empty(),(EconomyLite.getInstance()))).getResult().equals(ResultType.SUCCESS)) { src.sendMessage(messageStorage.getMessage("command.econ.addsuccess", "name", targetName)); attemptNotify(target); } else { src.sendMessage(messageStorage.getMessage("command.econ.addfail", "name", targetName)); } } else { src.sendMessage(messageStorage.getMessage("command.error")); } } else { src.sendMessage(messageStorage.getMessage("command.error")); } }
Example #5
Source File: RemoveCommand.java From EconomyLite with MIT License | 6 votes |
@Override public void run(CommandSource src, CommandContext args) { if (args.getOne("player").isPresent() && args.getOne("amount").isPresent()) { User target = args.<User>getOne("player").get(); String targetName = target.getName(); BigDecimal toRemove = BigDecimal.valueOf(args.<Double>getOne("amount").get()); Optional<UniqueAccount> uOpt = EconomyLite.getEconomyService().getOrCreateAccount(target.getUniqueId()); if (uOpt.isPresent()) { UniqueAccount targetAccount = uOpt.get(); if (targetAccount.withdraw(EconomyLite.getCurrencyService().getCurrentCurrency(), toRemove, Cause.of(EventContext.empty(),(EconomyLite.getInstance()))).getResult().equals(ResultType.SUCCESS)) { src.sendMessage(messageStorage.getMessage("command.econ.removesuccess", "name", targetName)); attemptNotify(target); } else { src.sendMessage(messageStorage.getMessage("command.econ.removefail", "name", targetName)); } } else { src.sendMessage(messageStorage.getMessage("command.error")); } } else { src.sendMessage(messageStorage.getMessage("command.error")); } }
Example #6
Source File: CommandPermissionTrust.java From GriefPrevention with MIT License | 6 votes |
@Override public CommandResult execute(CommandSource src, CommandContext ctx) { User user = ctx.<User>getOne("user").orElse(null); String group = null; if (user == null) { group = ctx.<String>getOne("group").orElse(null); if (group.equalsIgnoreCase("public") || group.equalsIgnoreCase("all")) { user = GriefPreventionPlugin.PUBLIC_USER; group = null; } } try { if (user != null) { CommandHelper.handleUserTrustCommand(GriefPreventionPlugin.checkPlayer(src), TrustType.MANAGER, user); } else { CommandHelper.handleGroupTrustCommand(GriefPreventionPlugin.checkPlayer(src), TrustType.MANAGER, group); } } catch (CommandException e) { src.sendMessage(e.getText()); } return CommandResult.success(); }
Example #7
Source File: NbtDataHelper.java From GriefPrevention with MIT License | 6 votes |
public static Optional<User> getOwnerOfEntity(net.minecraft.entity.Entity entity) { NBTTagCompound nbt = new NBTTagCompound(); entity.writeToNBT(nbt); if (nbt.hasKey(FORGE_DATA)) { NBTTagCompound forgeNBT = nbt.getCompoundTag(FORGE_DATA); if (forgeNBT.hasKey(SPONGE_DATA) && forgeNBT.getCompoundTag(SPONGE_DATA).hasKey(SPONGE_ENTITY_CREATOR)) { NBTTagCompound creatorNBT = forgeNBT.getCompoundTag(SPONGE_DATA).getCompoundTag(SPONGE_ENTITY_CREATOR); UUID uuid = new UUID(creatorNBT.getLong("uuid_most"), creatorNBT.getLong("uuid_least")); // get player if online EntityPlayer player = entity.world.getPlayerEntityByUUID(uuid); if (player != null) { return Optional.of((User) player); } // player is not online, get user from storage if one exists return Sponge.getGame().getServiceManager().provide(UserStorageService.class).get().get(uuid); } } return Optional.empty(); }
Example #8
Source File: CommandContainerTrust.java From GriefPrevention with MIT License | 6 votes |
@Override public CommandResult execute(CommandSource src, CommandContext ctx) { User user = ctx.<User>getOne("user").orElse(null); String group = null; if (user == null) { group = ctx.<String>getOne("group").orElse(null); if (group.equalsIgnoreCase("public") || group.equalsIgnoreCase("all")) { user = GriefPreventionPlugin.PUBLIC_USER; group = null; } } try { if (user != null) { CommandHelper.handleUserTrustCommand(GriefPreventionPlugin.checkPlayer(src), TrustType.CONTAINER, user); } else { CommandHelper.handleGroupTrustCommand(GriefPreventionPlugin.checkPlayer(src), TrustType.CONTAINER, group); } } catch (CommandException e) { src.sendMessage(e.getText()); } return CommandResult.success(); }
Example #9
Source File: PayCommand.java From EconomyLite with MIT License | 6 votes |
@Override public void run(Player src, CommandContext args) { if (args.getOne("player").isPresent() && args.getOne("amount").isPresent()) { BigDecimal amount = BigDecimal.valueOf(args.<Double>getOne("amount").get()); if (amount.doubleValue() <= 0) { src.sendMessage(messageStorage.getMessage("command.pay.invalid")); } else { User target = args.<User>getOne("player").get(); if (!EconomyLite.getConfigManager().getValue(Boolean.class, false, "confirm-offline-payments") || target.isOnline()) { // Complete the payment pay(target, amount, src); } else { src.sendMessage(messageStorage.getMessage("command.pay.confirm", "player", target.getName())); // Check if they want to still pay src.sendMessage(TextUtils.yesOrNo(c -> { pay(target, amount, src); }, c -> { src.sendMessage(messageStorage.getMessage("command.pay.confirmno", "player", target.getName())); })); } } } else { src.sendMessage(messageStorage.getMessage("command.error")); } }
Example #10
Source File: CommandClaimFlagPlayer.java From GriefDefender with MIT License | 6 votes |
@CommandCompletion("@gdplayers @gdflags @gdmcids @gdtristates @gdcontexts @gddummy") @CommandAlias("cfp") @Description("Gets/Sets flag permission for a player in claim you are standing in.") @Syntax("<player> <flag> <target> <value> [context[key=value]]") @Subcommand("flag player") public void execute(Player player, User user, @Optional String[] args) throws InvalidCommandArgument { this.subject = PermissionHolderCache.getInstance().getOrCreateUser(user); this.friendlySubjectName = user.getName(); if (user.hasPermission(GDPermissions.COMMAND_ADMIN_CLAIMS) && !player.hasPermission(GDPermissions.SET_ADMIN_FLAGS)) { GriefDefenderPlugin.sendMessage(player, MessageCache.getInstance().PERMISSION_PLAYER_ADMIN_FLAGS); return; } super.execute(player, args); }
Example #11
Source File: CommandUnseparate.java From GriefPrevention with MIT License | 6 votes |
@Override public CommandResult execute(CommandSource src, CommandContext args) { Player player; try { player = GriefPreventionPlugin.checkPlayer(src); } catch (CommandException e) { src.sendMessage(e.getText()); return CommandResult.success(); } final User targetPlayer = args.<User>getOne("player1").get(); final User targetPlayer2 = args.<User>getOne("player2").get(); GriefPreventionPlugin.instance.setIgnoreStatus(player.getWorld(), targetPlayer, targetPlayer2, IgnoreMode.None); GriefPreventionPlugin.instance.setIgnoreStatus(player.getWorld(), targetPlayer2, targetPlayer, IgnoreMode.None); GriefPreventionPlugin.sendMessage(player, GriefPreventionPlugin.instance.messageData.playerUnseparate.toText()); return CommandResult.success(); }
Example #12
Source File: GPDebugData.java From GriefPrevention with MIT License | 6 votes |
public GPDebugData(CommandSource source, User target, boolean verbose) { this.source = source; this.target = target; this.verbose = verbose; this.records = new ArrayList<>(); this.header = new ArrayList<>(); this.header.add("# GriefPrevention Debug Log"); this.header.add("#### This file was automatically generated by [GriefPrevention](https://github.com/MinecraftPortCentral/GriefPrevention) "); this.header.add(""); this.header.add("### Metadata"); this.header.add("| Key | Value |"); this.header.add("|-----|-------|"); this.header.add("| GP Version | " + GriefPreventionPlugin.IMPLEMENTATION_VERSION + "|"); this.header.add("| Sponge Version | " + GriefPreventionPlugin.SPONGE_VERSION + "|"); final PluginContainer lpContainer = Sponge.getPluginManager().getPlugin("luckperms").orElse(null); if (lpContainer != null) { final String version = lpContainer.getVersion().orElse(null); if (version != null) { this.header.add("| LuckPerms Version | " + version); } } this.header.add("| User | " + (this.target == null ? "ALL" : this.target.getName()) + "|"); this.header.add("| Record start | " + DATE_FORMAT.format(new Date(this.startTime)) + "|"); }
Example #13
Source File: UltimateUser.java From UltimateCore with MIT License | 6 votes |
/** * Set the value of a key to the specified value. * * @param key The key to set the value of * @param value The value to set the value to * @param <C> The type of value the key holds * @return Whether the value was accepted */ public <C> boolean offer(Key.User<C> key, C value) { if (!isCompatible(key)) { return false; } Cause cause = getPlayer().isPresent() ? Cause.builder().append(UltimateCore.getContainer()).append(getPlayer().get()).build(EventContext.builder().build()) : Cause.builder().append (UltimateCore.get()).append(getUser()).build(EventContext.builder().build()); DataOfferEvent<C> event = new DataOfferEvent<>(key, (C) this.datas.get(key.getIdentifier()), value, cause); Sponge.getEventManager().post(event); if (event.isCancelled()) { return false; } value = event.getValue().orElse(null); //Save to config if needed if (key.getProvider().isPresent()) { key.getProvider().get().save(this, value); } //Save to map if (value == null) { this.datas.remove(key.getIdentifier()); } else { this.datas.put(key.getIdentifier(), value); } return UltimateCore.get().getUserService().addToCache(this); }
Example #14
Source File: InventoryListener.java From UltimateCore with MIT License | 6 votes |
@Listener @Exclude({ClickInventoryEvent.Close.class, ClickInventoryEvent.Open.class}) public void onInteract(ClickInventoryEvent event, @Root Player p) { try { //Get target inventory owner Inventory inv = event.getTargetInventory(); if (!(inv instanceof CarriedInventory)) return; CarriedInventory cinv = (CarriedInventory) inv; if (!cinv.getCarrier().isPresent() || !(cinv.getCarrier().get() instanceof User)) return; User t = (User) cinv.getCarrier().get(); //Check if player is in invsee & Cancel event if player doesn't have permission UltimateUser up = UltimateCore.get().getUserService().getUser(p); if (up.get(InventoryKeys.INVSEE_TARGET).isPresent() && up.get(InventoryKeys.INVSEE_TARGET).get().equals(t.getUniqueId())) { if (!p.hasPermission("uc.inventory.invsee.modify")) { event.getCursorTransaction().setValid(false); event.setCancelled(true); } } } catch (Exception ignore) { } }
Example #15
Source File: GriefPreventionPlugin.java From GriefPrevention with MIT License | 6 votes |
public static User getOrCreateUser(UUID uuid) { if (uuid == null) { return null; } if (uuid == WORLD_USER_UUID) { return WORLD_USER; } // check the cache Optional<User> player = Sponge.getGame().getServiceManager().provide(UserStorageService.class).get().get(uuid); if (player.isPresent()) { return player.get(); } else { try { GameProfile gameProfile = Sponge.getServer().getGameProfileManager().get(uuid).get(); return Sponge.getGame().getServiceManager().provide(UserStorageService.class).get().getOrCreate(gameProfile); } catch (Exception e) { return null; } } }
Example #16
Source File: PayCommand.java From EconomyLite with MIT License | 5 votes |
private void pay(User target, BigDecimal amount, Player src) { String targetName = target.getName(); if (!target.getUniqueId().equals(src.getUniqueId())) { Optional<UniqueAccount> uOpt = ecoService.getOrCreateAccount(src.getUniqueId()); Optional<UniqueAccount> tOpt = ecoService.getOrCreateAccount(target.getUniqueId()); if (uOpt.isPresent() && tOpt.isPresent()) { if (uOpt.get() .transfer(tOpt.get(), ecoService.getDefaultCurrency(), amount, Cause.of(EventContext.empty(), (EconomyLite.getInstance()))) .getResult().equals(ResultType.SUCCESS)) { Text label = ecoService.getDefaultCurrency().getPluralDisplayName(); if (amount.equals(BigDecimal.ONE)) { label = ecoService.getDefaultCurrency().getDisplayName(); } src.sendMessage(messageStorage.getMessage("command.pay.success", "target", targetName, "amountandlabel", String.format(Locale.ENGLISH, "%,.2f", amount) + " " + label.toPlain())); final Text curLabel = label; Sponge.getServer().getPlayer(target.getUniqueId()).ifPresent(p -> { p.sendMessage(messageStorage.getMessage("command.pay.target", "amountandlabel", String.format(Locale.ENGLISH, "%,.2f", amount) + " " + curLabel.toPlain(), "sender", uOpt.get().getDisplayName().toPlain())); }); } else { src.sendMessage(messageStorage.getMessage("command.pay.failed", "target", targetName)); } } else { src.sendMessage(messageStorage.getMessage("command.error")); } } else { src.sendMessage(messageStorage.getMessage("command.pay.notyou")); } }
Example #17
Source File: InvseeCommand.java From UltimateCore with MIT License | 5 votes |
@Override public CommandResult execute(CommandSource src, CommandContext args) throws CommandException { checkIfPlayer(src); Player p = (Player) src; User user = args.<User>getOne("player").get(); if (!user.isOnline()) checkPermSuffix(src, "offline"); UltimateUser uu = UltimateCore.get().getUserService().getUser(user); uu.offer(InventoryKeys.INVSEE_TARGET, user.getUniqueId()); p.openInventory(user.getInventory()); return CommandResult.success(); }
Example #18
Source File: ModifyBlockListener.java From EagleFactions with MIT License | 5 votes |
@Listener public void onBlockModify(ChangeBlockEvent.Modify event) { User user = null; if(event.getCause().containsType(Player.class)) { user = event.getCause().first(Player.class).get(); } else if(event.getCause().containsType(User.class)) { user = event.getCause().first(User.class).get(); } // if(event.getContext().containsKey(EventContextKeys.OWNER) // && event.getContext().get(EventContextKeys.OWNER).isPresent() // && event.getContext().get(EventContextKeys.OWNER).get() instanceof Player) // { // Player player = (Player) event.getContext().get(EventContextKeys.OWNER).get(); if(user != null) { for (Transaction<BlockSnapshot> transaction : event.getTransactions()) { final Optional<Location<World>> optionalLocation = transaction.getFinal().getLocation(); if(optionalLocation.isPresent() && !super.getPlugin().getProtectionManager().canInteractWithBlock(optionalLocation.get(), user, true).hasAccess()) event.setCancelled(true); } } // } }
Example #19
Source File: CommandAdjustBonusClaimBlocks.java From GriefPrevention with MIT License | 5 votes |
@Override public CommandResult execute(CommandSource src, CommandContext args) { WorldProperties worldProperties = args.<WorldProperties> getOne("world").orElse(Sponge.getServer().getDefaultWorld().get()); if (worldProperties == null) { if (src instanceof Player) { worldProperties = ((Player) src).getWorld().getProperties(); } else { worldProperties = Sponge.getServer().getDefaultWorld().get(); } } if (worldProperties == null || !GriefPreventionPlugin.instance.claimsEnabledForWorld(worldProperties)) { GriefPreventionPlugin.sendMessage(src, GriefPreventionPlugin.instance.messageData.claimDisabledWorld.toText()); return CommandResult.success(); } // parse the adjustment amount int adjustment = args.<Integer>getOne("amount").get(); User user = args.<User>getOne("user").get(); // give blocks to player GPPlayerData playerData = GriefPreventionPlugin.instance.dataStore.getOrCreatePlayerData(worldProperties, user.getUniqueId()); playerData.setBonusClaimBlocks(playerData.getBonusClaimBlocks() + adjustment); playerData.getStorageData().save(); final Text message = GriefPreventionPlugin.instance.messageData.adjustBlocksSuccess .apply(ImmutableMap.of( "player", Text.of(user.getName()), "adjustment", Text.of(adjustment), "total", Text.of(playerData.getBonusClaimBlocks()))).build(); GriefPreventionPlugin .sendMessage(src, message); GriefPreventionPlugin.addLogEntry( src.getName() + " adjusted " + user.getName() + "'s bonus claim blocks by " + adjustment + ".", CustomLogEntryTypes.AdminActivity); return CommandResult.success(); }
Example #20
Source File: UCPerms56.java From UltimateChat with GNU General Public License v3.0 | 5 votes |
public HashMap<Integer, Subject> getPlayerGroups(User player) { HashMap<Integer, Subject> subs = new HashMap<>(); for (Subject sub : player.getParents()) { if (sub.getContainingCollection().equals(getGroups()) && (sub.getIdentifier() != null)) { subs.put(sub.getParents().size(), sub); } } return subs; }
Example #21
Source File: UCPerms8.java From UltimateChat with GNU General Public License v3.0 | 5 votes |
public HashMap<Integer, Subject> getPlayerGroups(User player) throws ExecutionException, InterruptedException { HashMap<Integer, Subject> subs = new HashMap<>(); for (SubjectReference sub : player.getParents()) { if (sub.getCollectionIdentifier().equals(getGroups().getIdentifier()) && (sub.getSubjectIdentifier() != null)) { Subject subj = sub.resolve().get(); subs.put(subj.getParents().size(), subj); } } return subs; }
Example #22
Source File: TempBanExecutor.java From EssentialCmds with MIT License | 5 votes |
public CommandResult execute(CommandSource src, CommandContext ctx) throws CommandException { Game game = EssentialCmds.getEssentialCmds().getGame(); User player = ctx.<User> getOne("player").get(); String time = ctx.<String> getOne("time").get(); String reason = ctx.<String> getOne("reason").orElse("The BanHammer has spoken!"); BanService srv = game.getServiceManager().provide(BanService.class).get(); if (srv.isBanned(player.getProfile())) { src.sendMessage(Text.of(TextColors.RED, "That player has already been banned.")); return CommandResult.empty(); } srv.addBan(Ban.builder() .type(BanTypes.PROFILE) .source(src).profile(player.getProfile()) .expirationDate(getInstantFromString(time)) .reason(TextSerializers.formattingCode('&').deserialize(reason)) .build()); if (player.isOnline()) { player.getPlayer().get().kick(Text.builder() .append(Text.of(TextColors.DARK_RED, "You have been tempbanned!\n", TextColors.RED, "Reason: ")) .append(TextSerializers.formattingCode('&').deserialize(reason), Text.of("\n")) .append(Text.of(TextColors.GOLD, "Time: ", TextColors.GRAY, getFormattedString(time))) .build()); } src.sendMessage(Text.of(TextColors.GREEN, "Success! ", TextColors.YELLOW, player.getName() + " has been banned.")); return CommandResult.success(); }
Example #23
Source File: VariableUtil.java From UltimateCore with MIT License | 5 votes |
public static Text getNameUser(User player) { if (player instanceof Player) { return getNameSource((CommandSource) player); } //TODO language? return Text.builder(player.getName()).onHover(TextActions.showText(Messages.getFormatted("core.variable.player.hover", "%name%", player.getName(), "%rawname%", player.getName(), "%uuid%", player.getUniqueId(), "%language%", "?"))).onClick(TextActions.suggestCommand(Messages.getFormatted("core.variable.player.click", "%player%", player.getName()).toPlain())).build(); }
Example #24
Source File: PlayerCommand.java From EagleFactions with MIT License | 5 votes |
private void showPlayerInfo(CommandSource source, FactionPlayer factionPlayer) { List<Text> playerInfo = new ArrayList<>(); String playerFactionName = ""; if (factionPlayer.getFactionName().isPresent()) playerFactionName = factionPlayer.getFactionName().get(); LocalDateTime lastPlayed = LocalDateTime.now(); final Optional<User> optionalUser = factionPlayer.getUser(); if (optionalUser.isPresent()) { final Optional<JoinData> joinData = optionalUser.get().get(JoinData.class); if (joinData.isPresent()) { final JoinData data = joinData.get(); final Instant instant = data.lastPlayed().get(); lastPlayed = LocalDateTime.ofInstant(instant, ZoneId.systemDefault()); } } String formattedDate = DATE_TIME_FORMATTER.format(lastPlayed); final boolean isOnline = optionalUser.isPresent() && optionalUser.get().isOnline(); final Text online = isOnline ? Text.of(TextColors.GREEN, "ONLINE") : Text.of(TextColors.RED, "OFFLINE"); Text info = Text.builder() .append(Text.of(TextColors.AQUA, Messages.NAME + ": ", TextColors.GOLD, factionPlayer.getName() + "\n")) .append(Text.of(TextColors.AQUA, Messages.PLAYER_STATUS + ": ")).append(online).append(Text.of("\n")) .append(Text.of(TextColors.AQUA, Messages.FACTION + ": ", TextColors.GOLD, playerFactionName + "\n")) .append(Text.of(TextColors.AQUA, Messages.POWER + ": ", TextColors.GOLD, factionPlayer.getPower() + "/" + factionPlayer.getMaxPower() + "\n")) .append(Text.of(TextColors.AQUA, Messages.LAST_PLAYED + ": ", TextColors.GOLD, formattedDate)) .build(); playerInfo.add(info); PaginationList.Builder paginationBuilder = PaginationList.builder().title(Text.of(TextColors.GREEN, Messages.PLAYER_INFO)).padding(Text.of("=")).contents(playerInfo); paginationBuilder.sendTo(source); }
Example #25
Source File: EFPlaceholderService.java From EagleFactions with MIT License | 5 votes |
@Placeholder(id = "faction") public Object faction(@Token(fix = true) @Nullable String token, @Nullable @Source User player) { if(token == null) return ""; switch(token) { case "name": return getFactionName(player); case "tag": return getFactionTag(player); case "power": return getFactionPower(player); case "maxpower": return getFactionMaxPower(player); case "last_online": return getFactionLastOnline(player); case "claims_count": return getFactionClaimCount(player); case "officers_count": return getFactionOfficerCount(player); case "members_count": return getFactionMemberCount(player); case "recruits_count": return getFactionRecruitCount(player); case "alliances": return getFactionAlliances(player); case "enemies": return getFactionEnemies(player); case "truce": return getFactionTruce(player); } return ""; }
Example #26
Source File: CommandUntrustAll.java From GriefPrevention with MIT License | 5 votes |
private void removeAllUserTrust(Claim claim, User user) { GPClaim gpClaim = (GPClaim) claim; Set<Context> contexts = new HashSet<>(); contexts.add(gpClaim.getContext()); for (TrustType type : TrustType.values()) { user.getSubjectData().setPermission(contexts, GPPermissions.getTrustPermission(type), Tristate.UNDEFINED); gpClaim.getUserTrustList(type).remove(user.getUniqueId()); gpClaim.getInternalClaimData().setRequiresSave(true); for (Claim child : gpClaim.children) { this.removeAllUserTrust(child, user); } } }
Example #27
Source File: UCPerms7.java From UltimateChat with GNU General Public License v3.0 | 5 votes |
public HashMap<Integer, Subject> getPlayerGroups(User player) throws ExecutionException, InterruptedException { HashMap<Integer, Subject> subs = new HashMap<>(); for (SubjectReference sub : player.getParents()) { if (sub.getCollectionIdentifier().equals(getGroups().getIdentifier()) && (sub.getSubjectIdentifier() != null)) { Subject subj = sub.resolve().get(); subs.put(subj.getParents().size(), subj); } } return subs; }
Example #28
Source File: ProtectionManagerImpl.java From EagleFactions with MIT License | 5 votes |
private boolean isHoldingEagleFeather(final User user) { return user.getItemInHand(HandTypes.MAIN_HAND).isPresent() && user.getItemInHand(HandTypes.MAIN_HAND).get().getType() == ItemTypes.FEATHER && user.getItemInHand(HandTypes.MAIN_HAND).get().get(Keys.DISPLAY_NAME).isPresent() && user.getItemInHand(HandTypes.MAIN_HAND).get().get(Keys.DISPLAY_NAME).get().equals(EagleFeather.getDisplayName()); }
Example #29
Source File: UCUserService.java From UltimateCore with MIT License | 5 votes |
/** * Retrieve an {@link UltimateUser} by the user's User instance. * * @param user The User instance of the user to get * @return The UltimateUser, or Optional.empty() if not found */ @Override public UltimateUser getUser(User user) { for (UltimateUser use : users) { if (use.getIdentifier().equals(user.getUniqueId())) { return use; } } UltimateUser ucuser = new UltimateUser(user); users.add(ucuser); return ucuser; }
Example #30
Source File: ProtectionManagerImpl.java From EagleFactions with MIT License | 5 votes |
private void notifyPlayer(final User user) { if (this.chatConfig.shouldDisplayProtectionSystemMessages()) { user.getPlayer().ifPresent(x->x.sendMessage(Text.of(PluginInfo.ERROR_PREFIX, TextColors.RED, Messages.YOU_DONT_HAVE_ACCESS_TO_DO_THIS))); } }