mirror of
https://github.com/songoda/FabledSkyBlock.git
synced 2025-01-10 09:47:42 +01:00
Allow edit island command alias
This commit is contained in:
parent
57fde643df
commit
f8323af0b7
@ -130,8 +130,11 @@ public class CommandManager implements CommandExecutor, TabCompleter {
|
|||||||
SoundManager soundManager = plugin.getSoundManager();
|
SoundManager soundManager = plugin.getSoundManager();
|
||||||
FileManager fileManager = plugin.getFileManager();
|
FileManager fileManager = plugin.getFileManager();
|
||||||
|
|
||||||
Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml"));
|
Config languageConfig = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml"));
|
||||||
FileConfiguration configLoad = config.getFileConfiguration();
|
FileConfiguration languageConfigLoad = languageConfig.getFileConfiguration();
|
||||||
|
|
||||||
|
Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml"));
|
||||||
|
FileConfiguration mainConfig = config.getFileConfiguration();
|
||||||
|
|
||||||
Player player = null;
|
Player player = null;
|
||||||
|
|
||||||
@ -143,22 +146,21 @@ public class CommandManager implements CommandExecutor, TabCompleter {
|
|||||||
if (player == null) {
|
if (player == null) {
|
||||||
sendConsoleHelpCommands(sender);
|
sendConsoleHelpCommands(sender);
|
||||||
} else {
|
} else {
|
||||||
|
String commandToExecute;
|
||||||
if (plugin.getIslandManager().getIsland(player) == null) {
|
if (plugin.getIslandManager().getIsland(player) == null) {
|
||||||
Bukkit.getServer().getScheduler().runTask(plugin, () -> Bukkit.getServer().dispatchCommand(sender, "island create"));
|
commandToExecute = mainConfig.getString("Command.Island.Aliases.NoIsland", "island create");
|
||||||
} else {
|
} else {
|
||||||
boolean canUseControlPanel = player.hasPermission("fabledskyblock.*")
|
commandToExecute = mainConfig.getString("Command.Island.Aliases.IslandOwned", "island controlpanel");
|
||||||
|| player.hasPermission("fabledskyblock.island.*")
|
|
||||||
|| player.hasPermission("fabledskyblock.island.controlpanel");
|
|
||||||
|
|
||||||
if (!canUseControlPanel) {
|
|
||||||
messageManager.sendMessage(player, configLoad.getString("Command.PermissionDenied.Island.Message"));
|
|
||||||
soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ControlPanel.getInstance().open(player);
|
if(commandToExecute.startsWith("/")) {
|
||||||
soundManager.playSound(player, CompatibleSound.BLOCK_CHEST_OPEN.getSound(), 1.0F, 1.0F);
|
commandToExecute = commandToExecute.substring(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String finalCommandToExecute = commandToExecute;
|
||||||
|
Bukkit.getServer().getScheduler().runTask(plugin, () ->
|
||||||
|
Bukkit.getServer().dispatchCommand(sender,
|
||||||
|
finalCommandToExecute));
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -176,15 +178,14 @@ public class CommandManager implements CommandExecutor, TabCompleter {
|
|||||||
|| player.hasPermission("fabledskyblock.island.help");
|
|| player.hasPermission("fabledskyblock.island.help");
|
||||||
|
|
||||||
if (!canUseHelp) {
|
if (!canUseHelp) {
|
||||||
messageManager.sendMessage(player, configLoad.getString("Command.PermissionDenied.Island.Message"));
|
messageManager.sendMessage(player, languageConfigLoad.getString("Command.PermissionDenied.Island.Message"));
|
||||||
soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
|
soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
int page = -1;
|
int page = -1;
|
||||||
|
|
||||||
if (!fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml"))
|
if (!mainConfig.getBoolean("Command.Help.List")) {
|
||||||
.getFileConfiguration().getBoolean("Command.Help.List")) {
|
|
||||||
page = 1;
|
page = 1;
|
||||||
|
|
||||||
if (args.length == 2) {
|
if (args.length == 2) {
|
||||||
@ -192,7 +193,7 @@ public class CommandManager implements CommandExecutor, TabCompleter {
|
|||||||
page = Integer.valueOf(args[1]);
|
page = Integer.valueOf(args[1]);
|
||||||
} else {
|
} else {
|
||||||
messageManager.sendMessage(player,
|
messageManager.sendMessage(player,
|
||||||
configLoad.getString("Command.Island.Help.Integer.Message"));
|
languageConfigLoad.getString("Command.Island.Help.Integer.Message"));
|
||||||
soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
|
soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -214,7 +215,7 @@ public class CommandManager implements CommandExecutor, TabCompleter {
|
|||||||
|| player.hasPermission("fabledskyblock.admin.help");
|
|| player.hasPermission("fabledskyblock.admin.help");
|
||||||
|
|
||||||
if (!canUseHelp) {
|
if (!canUseHelp) {
|
||||||
messageManager.sendMessage(player, configLoad.getString("Command.PermissionDenied.Admin.Message"));
|
messageManager.sendMessage(player, languageConfigLoad.getString("Command.PermissionDenied.Admin.Message"));
|
||||||
soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
|
soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -230,7 +231,7 @@ public class CommandManager implements CommandExecutor, TabCompleter {
|
|||||||
page = Integer.valueOf(args[2]);
|
page = Integer.valueOf(args[2]);
|
||||||
} else {
|
} else {
|
||||||
messageManager.sendMessage(player,
|
messageManager.sendMessage(player,
|
||||||
configLoad.getString("Command.Island.Help.Integer.Message"));
|
languageConfigLoad.getString("Command.Island.Help.Integer.Message"));
|
||||||
soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F,
|
soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F,
|
||||||
1.0F);
|
1.0F);
|
||||||
|
|
||||||
@ -253,13 +254,13 @@ public class CommandManager implements CommandExecutor, TabCompleter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (subCommand == null) {
|
if (subCommand == null) {
|
||||||
messageManager.sendMessage(sender, configLoad.getString("Command.Island.Argument.Unrecognised.Message"));
|
messageManager.sendMessage(sender, languageConfigLoad.getString("Command.Island.Argument.Unrecognised.Message"));
|
||||||
soundManager.playSound(sender, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F);
|
soundManager.playSound(sender, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!subCommand.hasPermission(sender, isAdmin)) {
|
if (!subCommand.hasPermission(sender, isAdmin)) {
|
||||||
messageManager.sendMessage(sender, configLoad.getString("Command.PermissionDenied." + (isAdmin ? "Admin" : "Island") + ".Message"));
|
messageManager.sendMessage(sender, languageConfigLoad.getString("Command.PermissionDenied." + (isAdmin ? "Admin" : "Island") + ".Message"));
|
||||||
soundManager.playSound(sender, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
|
soundManager.playSound(sender, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,11 @@ Command:
|
|||||||
# Shows all aliases of the commands.
|
# Shows all aliases of the commands.
|
||||||
Aliases:
|
Aliases:
|
||||||
Enable: true
|
Enable: true
|
||||||
|
Island:
|
||||||
|
# What command should be executed on /is or /island
|
||||||
|
Aliases:
|
||||||
|
IslandOwned: "island controlpanel"
|
||||||
|
NoIsland: "island create"
|
||||||
Sound:
|
Sound:
|
||||||
# When disabled all sounds will be disabled.
|
# When disabled all sounds will be disabled.
|
||||||
Enable: true
|
Enable: true
|
||||||
|
Loading…
Reference in New Issue
Block a user