diff --git a/FabledSkyBlock/Core/src/main/java/me/goodandevil/skyblock/command/CommandManager.java b/FabledSkyBlock/Core/src/main/java/me/goodandevil/skyblock/command/CommandManager.java index 09653648..2a09cfba 100644 --- a/FabledSkyBlock/Core/src/main/java/me/goodandevil/skyblock/command/CommandManager.java +++ b/FabledSkyBlock/Core/src/main/java/me/goodandevil/skyblock/command/CommandManager.java @@ -88,6 +88,7 @@ public class CommandManager implements CommandExecutor, TabCompleter { new me.goodandevil.skyblock.command.commands.admin.DeleteCommand(), new me.goodandevil.skyblock.command.commands.admin.GeneratorCommand(), new me.goodandevil.skyblock.command.commands.admin.LevelCommand(), + new me.goodandevil.skyblock.command.commands.admin.LevelScanCommand(), new me.goodandevil.skyblock.command.commands.admin.OwnerCommand(), new me.goodandevil.skyblock.command.commands.admin.RefreshHologramsCommand(), new me.goodandevil.skyblock.command.commands.admin.ReloadCommand(), diff --git a/FabledSkyBlock/Core/src/main/java/me/goodandevil/skyblock/command/commands/admin/LevelScanCommand.java b/FabledSkyBlock/Core/src/main/java/me/goodandevil/skyblock/command/commands/admin/LevelScanCommand.java new file mode 100644 index 00000000..518d9a31 --- /dev/null +++ b/FabledSkyBlock/Core/src/main/java/me/goodandevil/skyblock/command/commands/admin/LevelScanCommand.java @@ -0,0 +1,82 @@ +package me.goodandevil.skyblock.command.commands.admin; + +import me.goodandevil.skyblock.command.SubCommand; +import me.goodandevil.skyblock.config.FileManager; +import me.goodandevil.skyblock.island.Island; +import me.goodandevil.skyblock.island.IslandManager; +import me.goodandevil.skyblock.levelling.LevellingManager; +import me.goodandevil.skyblock.message.MessageManager; +import me.goodandevil.skyblock.sound.SoundManager; +import me.goodandevil.skyblock.utils.version.Sounds; +import org.bukkit.Bukkit; +import org.bukkit.OfflinePlayer; +import org.bukkit.command.CommandSender; +import org.bukkit.command.ConsoleCommandSender; +import org.bukkit.configuration.file.FileConfiguration; +import org.bukkit.entity.Player; + +import java.io.File; + +public class LevelScanCommand extends SubCommand { + + @Override + public void onCommandByPlayer(Player player, String[] args) { + this.onCommand(player, args); + } + + @Override + public void onCommandByConsole(ConsoleCommandSender sender, String[] args) { + this.onCommand(sender, args); + } + + private void onCommand(CommandSender sender, String[] args) { + LevellingManager levellingManager = skyblock.getLevellingManager(); + MessageManager messageManager = skyblock.getMessageManager(); + IslandManager islandManager = skyblock.getIslandManager(); + SoundManager soundManager = skyblock.getSoundManager(); + FileManager fileManager = skyblock.getFileManager(); + + FileManager.Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml")); + FileConfiguration configLoad = config.getFileConfiguration(); + + if (args.length == 0) { + messageManager.sendMessage(sender, configLoad.getString("Command.Island.Admin.LevelScan.Invalid.Message")); + soundManager.playSound(sender, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); + return; + } + + OfflinePlayer offlinePlayer = Bukkit.getOfflinePlayer(args[0]); + Island island = islandManager.getIsland(offlinePlayer); + + if (island == null) { + messageManager.sendMessage(sender, configLoad.getString("Command.Island.Admin.LevelScan.NoIsland.Message")); + soundManager.playSound(sender, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); + return; + } + + levellingManager.calculatePoints(sender instanceof Player ? (Player) sender : null, island); + + messageManager.sendMessage(sender, configLoad.getString("Command.Island.Admin.LevelScan.Started.Message")); + soundManager.playSound(sender, Sounds.VILLAGER_YES.bukkitSound(), 1.0F, 1.0F); + } + + @Override + public String getName() { + return "levelscan"; + } + + @Override + public String getInfoMessagePath() { + return "Command.Island.Admin.LevelScan.Info.Message"; + } + + @Override + public String[] getAliases() { + return new String[0]; + } + + @Override + public String[] getArguments() { + return new String[0]; + } +} diff --git a/FabledSkyBlock/Core/src/main/resources/language.yml b/FabledSkyBlock/Core/src/main/resources/language.yml index 4254d550..661beaaa 100644 --- a/FabledSkyBlock/Core/src/main/resources/language.yml +++ b/FabledSkyBlock/Core/src/main/resources/language.yml @@ -292,6 +292,15 @@ Command: Level: Info: Message: '&f&oChange Island level materials and points.' + LevelScan: + Info: + Message: '&f&oLevel scan another player''s island.' + Invalid: + Message: '&bSkyBlock &8| &cError&8: &eInvalid: /island admin levelscan ' + NoIsland: + Message: '&bSkyBlock &8| &cError&8: &eA player with that name does not own an island.' + Started: + Message: '&bSkyBlock &8| &aInfo&8: &eThe level scan has been queued or started.' Owner: Invalid: Message: '&bSkyBlock &8| &cError&8: &eInvalid: /island admin Owner '