示例#1
0
 private void deleteIsland(CommandSender sender, PlayerInfo playerInfo) {
   if (playerInfo != null && playerInfo.getIslandLocation() != null) {
     sender.sendMessage(tr("\u00a7eRemoving {0}'s island.", playerInfo.getPlayerName()));
     uSkyBlock.getInstance().deletePlayerIsland(playerInfo.getPlayerName(), null);
   } else {
     sender.sendMessage(tr("Error: That player does not have an island!"));
   }
 }
示例#2
0
 @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;
     }
     OfflinePlayer offlinePlayer = Bukkit.getOfflinePlayer(name);
     if (offlinePlayer == null) {
       player.sendMessage(tr("\u00a74Unknown player {0}", name));
       return true;
     }
     if (alias.equals("trust")) {
       island.trust(name);
       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.untrust(name);
       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(player, island);
     return true;
   }
   return false;
 }
示例#3
0
 private void removePlayerFromIsland(
     CommandSender sender, PlayerInfo playerInfo, IslandInfo islandInfo) {
   if (playerInfo == null) {
     sender.sendMessage(tr("\u00a74No valid player-name supplied."));
     return;
   }
   sender.sendMessage(tr("Removing {0} from island", playerInfo.getPlayerName()));
   islandInfo.removeMember(playerInfo);
   playerInfo.save();
 }
示例#4
0
 public void renamePlayer(
     PlayerInfo playerInfo, Runnable completion, PlayerNameChangedEvent change) {
   List<String> islands = new ArrayList<>();
   islands.add(playerInfo.locationForParty());
   islands.addAll(playerInfo.getBannedFrom());
   for (String islandName : islands) {
     renamePlayer(islandName, change);
   }
   if (completion != null) {
     completion.run();
   }
 }
示例#5
0
 private void setBiome(
     CommandSender sender, PlayerInfo playerInfo, IslandInfo islandInfo, String biome) {
   if (playerInfo == null || !playerInfo.getHasIsland()) {
     sender.sendMessage(tr("\u00a74That player has no island."));
     return;
   }
   if (uSkyBlock.getInstance().setBiome(playerInfo.getIslandLocation(), biome)) {
     islandInfo.setBiome(biome);
     sender.sendMessage(
         tr("\u00a7e{0} has had their biome changed to {1}.", playerInfo.getPlayerName(), biome));
   } else {
     islandInfo.setBiome("OCEAN");
     sender.sendMessage(
         tr("\u00a7e{0} has had their biome changed to OCEAN.", playerInfo.getPlayerName()));
   }
   sender.sendMessage(tr("\u00a7aYou may need to go to spawn, or relog, to see the changes."));
 }
示例#6
0
 public void displayTopTen(final CommandSender sender, int page) {
   synchronized (ranks) {
     int maxpage = ((ranks.size() - 1) / 10) + 1;
     if (page > maxpage) {
       page = maxpage;
     }
     if (page < 1) {
       page = 1;
     }
     sender.sendMessage(tr("\u00a7eWALL OF FAME (page {0} of {1}):", page, maxpage));
     if (ranks == null || ranks.isEmpty()) {
       sender.sendMessage(tr("\u00a74Top ten list is empty! (perhaps the generation failed?)"));
     }
     int place = 1;
     String playerName =
         sender instanceof Player ? ((Player) sender).getDisplayName() : sender.getName();
     PlayerInfo playerInfo = plugin.getPlayerInfo(playerName);
     IslandRank rank = null;
     if (playerInfo != null && playerInfo.getHasIsland()) {
       rank = getRank(playerInfo.locationForParty());
     }
     int offset = (page - 1) * 10;
     place += offset;
     for (final IslandLevel level : ranks.subList(offset, Math.min(ranks.size(), 10 * page))) {
       String members = "";
       if (showMembers && !level.getMembers().isEmpty()) {
         members =
             Arrays.toString(level.getMembers().toArray(new String[level.getMembers().size()]));
       }
       sender.sendMessage(
           String.format(
               tr("\u00a7a#%2d \u00a77(%5.2f): \u00a7e%s \u00a77%s"),
               place,
               level.getScore(),
               level.getLeaderName(),
               members));
       place++;
     }
     if (rank != null) {
       sender.sendMessage(tr("\u00a7eYour rank is: \u00a7f{0}", rank.getRank()));
     }
   }
 }
示例#7
0
 private List<String> getLeaderNames(PlayerInfo pi) {
   List<String> trustedOn = pi.getTrustedOn();
   List<String> leaderNames = new ArrayList<>();
   for (String islandName : trustedOn) {
     us.talabrek.ultimateskyblock.api.IslandInfo islandInfo = plugin.getIslandInfo(islandName);
     if (islandInfo != null && islandInfo.getLeader() != null) {
       leaderNames.add(islandInfo.getLeader());
     }
   }
   return leaderNames;
 }
 @Override
 public boolean execute(
     CommandSender sender, String alias, Map<String, Object> data, String... args) {
   if (args.length == 2) {
     String island = args[0];
     String playerName = args[1];
     PlayerInfo islandPlayer = plugin.getPlayerInfo(island);
     PlayerInfo playerInfo = plugin.getPlayerInfo(playerName);
     if (islandPlayer == null || !islandPlayer.getHasIsland()) {
       sender.sendMessage(tr("\u00a74Player {0} has no island to transfer!", island));
       return false;
     }
     IslandInfo islandInfo = plugin.getIslandInfo(islandPlayer);
     if (islandInfo == null) {
       sender.sendMessage(tr("\u00a74Player {0} has no island to transfer!", island));
       return false;
     }
     if (playerInfo != null && playerInfo.getHasIsland()) {
       sender.sendMessage(
           tr(
               "\u00a7ePlayer \u00a7d{0}\u00a7e already has an island.\u00a7eUse \u00a7d/usb island remove <name>\u00a7e to remove him first.",
               playerName));
       return false;
     }
     playerInfo.setJoinParty(islandInfo.getIslandLocation());
     Location homeLocation = islandPlayer.getHomeLocation();
     islandInfo.removeMember(islandPlayer); // Remove leader
     islandInfo.setupPartyLeader(playerInfo.getPlayerName()); // Promote member
     playerInfo.setHomeLocation(homeLocation);
     islandPlayer.save();
     playerInfo.save();
     WorldGuardHandler.updateRegion(sender, islandInfo);
     islandInfo.sendMessageToIslandGroup(
         tr("\u00a7bLeadership transferred by {0}\u00a7b to {1}", sender.getName(), playerName));
     return true;
   }
   return false;
 }
示例#9
0
 public IslandInfo getIslandInfo(PlayerInfo playerInfo) {
   if (playerInfo != null && playerInfo.getHasIsland()) {
     return getIslandInfo(playerInfo.locationForParty());
   }
   return null;
 }