Moved and renamed commands (deprecated old ones)

This commit is contained in:
Florian CUNY 2018-12-23 21:03:08 +01:00
parent eb7a953875
commit 8703e7c262
9 changed files with 221 additions and 14 deletions

View File

@ -6,10 +6,10 @@ import java.util.UUID;
import org.bukkit.World;
import world.bentobox.level.commands.AdminLevel;
import world.bentobox.level.commands.AdminTop;
import world.bentobox.level.commands.IslandLevel;
import world.bentobox.level.commands.IslandTop;
import world.bentobox.level.commands.admin.AdminLevelCommand;
import world.bentobox.level.commands.admin.AdminTopCommand;
import world.bentobox.level.commands.island.IslandLevelCommand;
import world.bentobox.level.commands.island.IslandTopCommand;
import world.bentobox.level.config.Settings;
import world.bentobox.level.objects.LevelsData;
import world.bentobox.level.listeners.JoinLeaveListener;
@ -20,9 +20,8 @@ import world.bentobox.bentobox.api.user.User;
import world.bentobox.bentobox.database.Database;
import world.bentobox.bentobox.database.objects.Island;
/**
* Addon to BSkyBlock that enables island level scoring and top ten functionality
* Addon to BSkyBlock/AcidIsland that enables island level scoring and top ten functionality
* @author tastybento
*
*/
@ -119,22 +118,22 @@ public class Level extends Addon {
this.getPlugin().getAddonsManager().getAddonByName("AcidIsland").ifPresent(a -> {
CompositeCommand acidIslandCmd = getPlugin().getCommandsManager().getCommand(getConfig().getString("acidisland.user-command","ai"));
if (acidIslandCmd != null) {
new IslandLevel(this, acidIslandCmd);
new IslandTop(this, acidIslandCmd);
new IslandLevelCommand(this, acidIslandCmd);
new IslandTopCommand(this, acidIslandCmd);
CompositeCommand acidCmd = getPlugin().getCommandsManager().getCommand(getConfig().getString("acidisland.admin-command","acid"));
new AdminLevel(this, acidCmd);
new AdminTop(this, acidCmd);
new AdminLevelCommand(this, acidCmd);
new AdminTopCommand(this, acidCmd);
}
});
// BSkyBlock hook in
this.getPlugin().getAddonsManager().getAddonByName("BSkyBlock").ifPresent(a -> {
CompositeCommand bsbIslandCmd = getPlugin().getCommandsManager().getCommand(getConfig().getString("bskyblock.user-command","island"));
if (bsbIslandCmd != null) {
new IslandLevel(this, bsbIslandCmd);
new IslandTop(this, bsbIslandCmd);
new IslandLevelCommand(this, bsbIslandCmd);
new IslandTopCommand(this, bsbIslandCmd);
CompositeCommand bsbAdminCmd = getPlugin().getCommandsManager().getCommand(getConfig().getString("bskyblock.admin-command","bsbadmin"));
new AdminLevel(this, bsbAdminCmd);
new AdminTop(this, bsbAdminCmd);
new AdminLevelCommand(this, bsbAdminCmd);
new AdminTopCommand(this, bsbAdminCmd);
}
});

View File

@ -7,6 +7,10 @@ import world.bentobox.level.Level;
import world.bentobox.bentobox.api.commands.CompositeCommand;
import world.bentobox.bentobox.api.user.User;
/**
* @deprecated Renamed and moved to {@link world.bentobox.level.commands.admin.AdminLevelCommand}.
*/
@Deprecated
public class AdminLevel extends CompositeCommand {
private final Level levelPlugin;

View File

@ -11,6 +11,10 @@ import world.bentobox.bentobox.api.commands.CompositeCommand;
import world.bentobox.bentobox.api.user.User;
import world.bentobox.bentobox.database.objects.Island;
/**
* @deprecated Renamed and moved to {@link world.bentobox.level.commands.admin.AdminTopCommand}.
*/
@Deprecated
public class AdminTop extends CompositeCommand {
private final Level levelPlugin;

View File

@ -7,6 +7,10 @@ import world.bentobox.level.Level;
import world.bentobox.bentobox.api.commands.CompositeCommand;
import world.bentobox.bentobox.api.user.User;
/**
* @deprecated Renamed and moved to {@link world.bentobox.level.commands.island.IslandLevelCommand}.
*/
@Deprecated
public class IslandLevel extends CompositeCommand {
private final Level levelPlugin;

View File

@ -6,6 +6,10 @@ import world.bentobox.level.Level;
import world.bentobox.bentobox.api.commands.CompositeCommand;
import world.bentobox.bentobox.api.user.User;
/**
* @deprecated Renamed and moved to {@link world.bentobox.level.commands.island.IslandTopCommand}.
*/
@Deprecated
public class IslandTop extends CompositeCommand {
private final Level plugin;

View File

@ -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;
}
}
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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;
}
}