-
-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Moved and renamed commands (deprecated old ones)
- Loading branch information
1 parent
eb7a953
commit 8703e7c
Showing
9 changed files
with
221 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
src/main/java/world/bentobox/level/commands/admin/AdminLevelCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package world.bentobox.level.commands.admin; | ||
|
||
import world.bentobox.bentobox.api.commands.CompositeCommand; | ||
import world.bentobox.bentobox.api.user.User; | ||
import world.bentobox.level.Level; | ||
|
||
import java.util.List; | ||
import java.util.UUID; | ||
|
||
public class AdminLevelCommand extends CompositeCommand { | ||
|
||
private final Level levelPlugin; | ||
|
||
public AdminLevelCommand(Level levelPlugin, CompositeCommand parent) { | ||
super(parent, "level"); | ||
this.levelPlugin = levelPlugin; | ||
} | ||
|
||
@Override | ||
public void setup() { | ||
this.setPermission("admin.level"); | ||
this.setOnlyPlayer(false); | ||
this.setParametersHelp("admin.level.parameters"); | ||
this.setDescription("admin.level.description"); | ||
} | ||
|
||
@Override | ||
public boolean execute(User user, String label, List<String> args) { | ||
if (args.size() == 1) { | ||
// Asking for another player's level? | ||
// Convert name to a UUID | ||
final UUID playerUUID = getPlugin().getPlayers().getUUID(args.get(0)); | ||
if (playerUUID == null) { | ||
user.sendMessage("general.errors.unknown-player"); | ||
return true; | ||
} else { | ||
levelPlugin.calculateIslandLevel(getWorld(), user, playerUUID); | ||
} | ||
return true; | ||
} else { | ||
showHelp(this, user); | ||
return false; | ||
} | ||
} | ||
} |
67 changes: 67 additions & 0 deletions
67
src/main/java/world/bentobox/level/commands/admin/AdminTopCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
package world.bentobox.level.commands.admin; | ||
|
||
import org.bukkit.World; | ||
import world.bentobox.bentobox.api.commands.CompositeCommand; | ||
import world.bentobox.bentobox.api.user.User; | ||
import world.bentobox.bentobox.database.objects.Island; | ||
import world.bentobox.level.Level; | ||
|
||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.UUID; | ||
|
||
public class AdminTopCommand extends CompositeCommand { | ||
|
||
private final Level levelPlugin; | ||
|
||
public AdminTopCommand(Level levelPlugin, CompositeCommand parent) { | ||
super(parent, "top", "topten"); | ||
this.levelPlugin = levelPlugin; | ||
} | ||
|
||
@Override | ||
public void setup() { | ||
this.setPermission("admin.top"); | ||
this.setOnlyPlayer(false); | ||
this.setDescription("admin.top.description"); | ||
} | ||
|
||
@Override | ||
public boolean execute(User user, String label, List<String> args) { | ||
// Get world | ||
World world; | ||
if (args.isEmpty()) { | ||
if (getPlugin().getIWM().getOverWorlds().size() == 1) { | ||
world = getPlugin().getIWM().getOverWorlds().get(0); | ||
} else { | ||
showHelp(this, user); | ||
return false; | ||
} | ||
} else { | ||
if (getPlugin().getIWM().isOverWorld(args.get(0))) { | ||
world = getPlugin().getIWM().getIslandWorld(args.get(0)); | ||
} else { | ||
user.sendMessage("commands.admin.top.unknown-world"); | ||
return false; | ||
} | ||
|
||
} | ||
int rank = 0; | ||
for (Map.Entry<UUID, Long> topTen : levelPlugin.getTopTen().getTopTenList(world).getTopTen().entrySet()) { | ||
Island island = getPlugin().getIslands().getIsland(world, topTen.getKey()); | ||
if (island != null) { | ||
rank++; | ||
String item = user.getTranslation("admin.topten", | ||
"[rank]", | ||
"[name]", | ||
"[level]", | ||
String.valueOf(rank), | ||
this.getPlugin().getPlayers().getUser(island.getOwner()).getName(), | ||
String.valueOf(topTen.getValue())); | ||
user.sendRawMessage(item); | ||
} | ||
} | ||
|
||
return true; | ||
} | ||
} |
50 changes: 50 additions & 0 deletions
50
src/main/java/world/bentobox/level/commands/island/IslandLevelCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package world.bentobox.level.commands.island; | ||
|
||
import world.bentobox.bentobox.api.commands.CompositeCommand; | ||
import world.bentobox.bentobox.api.user.User; | ||
import world.bentobox.level.Level; | ||
|
||
import java.util.List; | ||
import java.util.UUID; | ||
|
||
public class IslandLevelCommand extends CompositeCommand { | ||
|
||
private final Level levelPlugin; | ||
|
||
public IslandLevelCommand(Level levelPlugin, CompositeCommand parent) { | ||
super(parent, "level"); | ||
this.levelPlugin = levelPlugin; | ||
} | ||
|
||
@Override | ||
public void setup() { | ||
this.setPermission("island.level"); | ||
this.setParametersHelp("island.level.parameters"); | ||
this.setDescription("island.level.description"); | ||
this.setOnlyPlayer(true); | ||
} | ||
|
||
@Override | ||
public boolean execute(User user, String label, List<String> args) { | ||
if (!args.isEmpty()) { | ||
// Asking for another player's level? | ||
// Convert name to a UUID | ||
final UUID playerUUID = getPlugin().getPlayers().getUUID(args.get(0)); | ||
if (playerUUID == null) { | ||
user.sendMessage("general.errors.unknown-player"); | ||
return true; | ||
} else if (user.getUniqueId().equals(playerUUID) ) { | ||
// Self level request | ||
levelPlugin.calculateIslandLevel(getWorld(), user, user.getUniqueId()); | ||
} else { | ||
user.sendMessage("island.level.island-level-is", "[level]", String.valueOf(levelPlugin.getIslandLevel(getWorld(), playerUUID))); | ||
return true; | ||
} | ||
} else { | ||
// Self level request | ||
levelPlugin.calculateIslandLevel(getWorld(), user, user.getUniqueId()); | ||
} | ||
return false; | ||
} | ||
|
||
} |
30 changes: 30 additions & 0 deletions
30
src/main/java/world/bentobox/level/commands/island/IslandTopCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package world.bentobox.level.commands.island; | ||
|
||
import world.bentobox.bentobox.api.commands.CompositeCommand; | ||
import world.bentobox.bentobox.api.user.User; | ||
import world.bentobox.level.Level; | ||
|
||
import java.util.List; | ||
|
||
public class IslandTopCommand extends CompositeCommand { | ||
|
||
private final Level plugin; | ||
|
||
public IslandTopCommand(Level plugin, CompositeCommand parent) { | ||
super(parent, "top", "topten"); | ||
this.plugin = plugin; | ||
} | ||
|
||
@Override | ||
public void setup() { | ||
setPermission("island.top"); | ||
setDescription("island.top.description"); | ||
setOnlyPlayer(true); | ||
} | ||
|
||
@Override | ||
public boolean execute(User user, String label, List<String> list) { | ||
plugin.getTopTen().getGUI(getWorld(), user, getPermissionPrefix()); | ||
return true; | ||
} | ||
} |