Skip to content

Commit

Permalink
Fix some small issues with tab-complete in biomes command.
Browse files Browse the repository at this point in the history
  • Loading branch information
BONNe committed Aug 29, 2019
1 parent 4513923 commit 8391f53
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@ protected BiomesObject getBiomeObject(List<String> args, int index, User user)
if (args.size() > index)
{
String uniqueID = args.get(index);
String worldName = Utils.getGameMode(this.getWorld());
String addonName = Utils.getGameMode(this.getWorld());

if (!uniqueID.startsWith(worldName))
if (!uniqueID.startsWith(addonName))
{
uniqueID = worldName + "_" + uniqueID;
uniqueID = addonName + "_" + uniqueID;
}

BiomesObject biome = this.addon.getAddonManager().getBiomeFromString(uniqueID);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,13 +222,10 @@ public Optional<List<String>> tabComplete(User user, String alias, List<String>
switch (size)
{
case 3:
String worldName = this.getWorld() != null &&
Utils.getGameMode(this.getWorld()) != null ?
Utils.getGameMode(this.getWorld()) : "";

// Create suggestions with all biomes that is available for users.
this.addon.getAddonManager().getBiomes(worldName).forEach(biomesObject -> {
returnList.add(biomesObject.getUniqueId().substring(worldName.length() + 1));
this.addon.getAddonManager().getBiomes(this.getWorld()).forEach(biomesObject -> {
returnList.add(biomesObject.getUniqueId().substring(Utils.getGameMode(this.getWorld()).length() + 1));
});

break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,13 +118,10 @@ public Optional<List<String>> tabComplete(User user, String alias, List<String>
returnList.addAll(Util.getOnlinePlayerList(user));
break;
case 4:
String worldName = this.getWorld() != null &&
Utils.getGameMode(this.getWorld()) != null ?
Utils.getGameMode(this.getWorld()) : "";

// Create suggestions with all biomes that is available for users.
this.addon.getAddonManager().getBiomes(worldName).forEach(biomesObject -> {
returnList.add(biomesObject.getUniqueId().substring(worldName.length() + 1));
this.addon.getAddonManager().getBiomes(this.getWorld()).forEach(biomesObject -> {
returnList.add(biomesObject.getUniqueId().substring(Utils.getGameMode(this.getWorld()).length() + 1));
});

break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,10 @@ public Optional<List<String>> tabComplete(User user, String alias, List<String>

final List<String> returnList = new ArrayList<>();

String worldName = this.getWorld() != null &&
Utils.getGameMode(this.getWorld()) != null ?
Utils.getGameMode(this.getWorld()) : "";

// Create suggestions with all biomes that is available for users.

this.addon.getAddonManager().getBiomes(worldName).forEach(biomesObject -> {
returnList.add(biomesObject.getUniqueId().replaceFirst(worldName + "_", ""));
this.addon.getAddonManager().getBiomes(this.getWorld()).forEach(biomesObject -> {
returnList.add(biomesObject.getUniqueId().substring(Utils.getGameMode(this.getWorld()).length() + 1));
});

return Optional.of(Util.tabLimit(returnList, args.get(args.size() - 1)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,15 +86,11 @@ public Optional<List<String>> tabComplete(User user, String alias, List<String>
switch (size)
{
case 3:
String worldName = this.getWorld() != null &&
Utils.getGameMode(this.getWorld()) != null ?
Utils.getGameMode(this.getWorld()) : "";

List<BiomesObject> biomes = this.addon.getAddonManager().getBiomes(worldName);
List<BiomesObject> biomes = this.addon.getAddonManager().getBiomes(this.getWorld());

// Create suggestions with all biomes that is available for users.
biomes.forEach(biomesObject -> {
returnList.add(biomesObject.getUniqueId().substring(worldName.length() + 1));
returnList.add(biomesObject.getUniqueId().substring(Utils.getGameMode(this.getWorld()).length() + 1));
});

break;
Expand Down

0 comments on commit 8391f53

Please sign in to comment.