use of com.iridium.iridiumskyblock.gui.InventoryConfigGUI in project IridiumSkyblock by Iridium-Development.
the class CommandManager method onCommand.
/**
* Method which handles command execution for all sub-commands.
* Automatically checks if a User can execute the command.
* All parameters are provided by Bukkit.
*
* @param commandSender The sender which executes this command
* @param cmd The Bukkit {@link org.bukkit.command.Command} representation
* @param label The label of this command. Not used.
* @param args The arguments of this command
* @return true if this command was executed successfully
*/
@Override
public boolean onCommand(@NotNull CommandSender commandSender, org.bukkit.command.@NotNull Command cmd, @NotNull String label, String[] args) {
if (args.length == 0) {
if (commandSender instanceof Player) {
Player player = (Player) commandSender;
User user = IridiumSkyblock.getInstance().getUserManager().getUser(player);
Optional<Island> island = user.getIsland();
if (island.isPresent()) {
if (IridiumSkyblock.getInstance().getConfiguration().islandMenu) {
player.openInventory(new InventoryConfigGUI(IridiumSkyblock.getInstance().getInventories().islandMenu, player.getOpenInventory().getTopInventory()).getInventory());
} else {
IridiumSkyblock.getInstance().getCommands().helpCommand.execute(player, new String[] {});
}
} else {
IridiumSkyblock.getInstance().getCommands().createCommand.execute(player, new String[] {});
}
} else {
IridiumSkyblock.getInstance().getCommands().helpCommand.execute(commandSender, new String[] {});
}
return true;
}
for (Command command : commands) {
// We don't want to execute other commands or ones that are disabled
if (!(command.aliases.contains(args[0]))) {
continue;
}
Command executingCommand = findExecutingCommand(command, args);
if (executionBlocked(executingCommand, commandSender)) {
return false;
}
boolean success = executingCommand.execute(commandSender, args);
if (success)
executingCommand.getCooldownProvider().applyCooldown(commandSender);
return true;
}
// Unknown command message
commandSender.sendMessage(StringUtils.color(IridiumSkyblock.getInstance().getMessages().unknownCommand.replace("%prefix%", IridiumSkyblock.getInstance().getConfiguration().prefix)));
return false;
}
use of com.iridium.iridiumskyblock.gui.InventoryConfigGUI in project IridiumSkyblock by Iridium-Development.
the class MissionCommand method execute.
/**
* Executes the command for the specified {@link CommandSender} with the provided arguments.
* Not called when the command execution was invalid (no permission, no player or command disabled).
*
* @param sender The CommandSender which executes this command
* @param args The arguments used with this command. They contain the sub-command
*/
@Override
public boolean execute(CommandSender sender, String[] args) {
Player player = (Player) sender;
User user = IridiumSkyblock.getInstance().getUserManager().getUser(player);
Optional<Island> island = user.getIsland();
if (!island.isPresent()) {
player.sendMessage(StringUtils.color(IridiumSkyblock.getInstance().getMessages().noIsland.replace("%prefix%", IridiumSkyblock.getInstance().getConfiguration().prefix)));
return false;
}
if (args.length != 2) {
player.openInventory(new InventoryConfigGUI(IridiumSkyblock.getInstance().getInventories().missionSelectGUI, player.getOpenInventory().getTopInventory()).getInventory());
return true;
}
switch(Mission.MissionType.getMission(args[1])) {
case ONCE:
player.openInventory(new IslandMissionsGUI(island.get(), player.getOpenInventory().getTopInventory()).getInventory());
return true;
case DAILY:
player.openInventory(new DailyIslandMissionsGUI(island.get(), player.getOpenInventory().getTopInventory()).getInventory());
return true;
default:
player.sendMessage(StringUtils.color(IridiumSkyblock.getInstance().getMessages().invalidMissionType.replace("%prefix%", IridiumSkyblock.getInstance().getConfiguration().prefix)));
return false;
}
}
use of com.iridium.iridiumskyblock.gui.InventoryConfigGUI in project IridiumSkyblock by Iridium-Development.
the class BlockValueCommand method execute.
/**
* Executes the command for the specified {@link CommandSender} with the provided arguments.
* Not called when the command execution was invalid (no permission, no player or command disabled).
* Shows all the valuable blocks and spawners.
*
* @param sender The CommandSender which executes this command
* @param arguments The arguments used with this command. They contain the sub-command
*/
@Override
public boolean execute(CommandSender sender, String[] arguments) {
Player player = (Player) sender;
if (arguments.length != 2) {
player.openInventory(new InventoryConfigGUI(IridiumSkyblock.getInstance().getInventories().blockValueSelectGUI, player.getOpenInventory().getTopInventory()).getInventory());
return true;
}
BlockValueGUI.BlockValueType blockValueType = BlockValueGUI.BlockValueType.getType(arguments[1]);
if (blockValueType == null) {
player.openInventory(new InventoryConfigGUI(IridiumSkyblock.getInstance().getInventories().blockValueSelectGUI, player.getOpenInventory().getTopInventory()).getInventory());
return true;
}
player.openInventory(new BlockValueGUI(blockValueType, player.getOpenInventory().getTopInventory()).getInventory());
return true;
}
use of com.iridium.iridiumskyblock.gui.InventoryConfigGUI in project IridiumSkyblock by Iridium-Development.
the class BorderCommand method execute.
/**
* Executes the command for the specified {@link CommandSender} with the provided arguments.
* Not called when the command execution was invalid (no permission, no player or command disabled).
* Changes the Island Border
*
* @param sender The CommandSender which executes this command
* @param args The arguments used with this command. They contain the sub-command
*/
@Override
public boolean execute(CommandSender sender, String[] args) {
Player player = (Player) sender;
User user = IridiumSkyblock.getInstance().getUserManager().getUser(player);
Optional<Island> island = user.getIsland();
if (!island.isPresent()) {
player.sendMessage(StringUtils.color(IridiumSkyblock.getInstance().getMessages().noIsland.replace("%prefix%", IridiumSkyblock.getInstance().getConfiguration().prefix)));
return false;
}
if (!IridiumSkyblock.getInstance().getIslandManager().getIslandPermission(island.get(), IridiumSkyblock.getInstance().getUserManager().getUser(player), PermissionType.BORDER)) {
player.sendMessage(StringUtils.color(IridiumSkyblock.getInstance().getMessages().cannotManageBorder.replace("%prefix%", IridiumSkyblock.getInstance().getConfiguration().prefix)));
return false;
}
if (args.length != 2) {
player.openInventory(new InventoryConfigGUI(IridiumSkyblock.getInstance().getInventories().islandBorder, player.getOpenInventory().getTopInventory()).getInventory());
return true;
}
Color color = Color.getColor(args[1]);
if (color == null) {
player.sendMessage(StringUtils.color(IridiumSkyblock.getInstance().getMessages().notAColor.replace("%prefix%", IridiumSkyblock.getInstance().getConfiguration().prefix)));
return false;
}
if (!IridiumSkyblock.getInstance().getBorder().enabled.getOrDefault(color, true)) {
player.sendMessage(StringUtils.color(IridiumSkyblock.getInstance().getMessages().borderColorDisabled.replace("%prefix%", IridiumSkyblock.getInstance().getConfiguration().prefix)));
return false;
}
island.get().setColor(color);
island.get().getMembers().stream().map(islandUser -> Bukkit.getPlayer(islandUser.getUuid())).filter(Objects::nonNull).forEach(islandPlayer -> islandPlayer.sendMessage(StringUtils.color(IridiumSkyblock.getInstance().getMessages().islandBorderChanged.replace("%player%", player.getName()).replace("%color%", color.toString()).replace("%prefix%", IridiumSkyblock.getInstance().getConfiguration().prefix))));
return true;
}
Aggregations