use of com.iridium.iridiumskyblock.gui.ConfirmationGUI in project IridiumSkyblock by Iridium-Development.
the class LeaveCommand 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).
* Allows users to leave their Island.
*
* @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 (user.getIslandRank().equals(IslandRank.OWNER)) {
player.sendMessage(StringUtils.color(IridiumSkyblock.getInstance().getMessages().cannotLeaveIsland.replace("%prefix%", IridiumSkyblock.getInstance().getConfiguration().prefix)));
return false;
}
player.openInventory(new ConfirmationGUI(() -> {
UserLeaveEvent userLeaveEvent = new UserLeaveEvent(island.get(), user);
Bukkit.getPluginManager().callEvent(userLeaveEvent);
if (userLeaveEvent.isCancelled())
return;
user.setIsland(null);
player.sendMessage(StringUtils.color(IridiumSkyblock.getInstance().getMessages().youHaveLeftIsland.replace("%prefix%", IridiumSkyblock.getInstance().getConfiguration().prefix)));
for (User member : island.get().getMembers()) {
Player islandMember = Bukkit.getPlayer(member.getUuid());
if (islandMember != null) {
islandMember.sendMessage(StringUtils.color(IridiumSkyblock.getInstance().getMessages().playerLeftIsland.replace("%player%", player.getName()).replace("%prefix%", IridiumSkyblock.getInstance().getConfiguration().prefix)));
}
}
PlayerUtils.teleportSpawn(player);
IslandLog islandLog = new IslandLog(island.get(), LogAction.USER_LEFT, user, null, 0, "");
IridiumSkyblock.getInstance().getDatabaseManager().getIslandLogTableManager().addEntry(islandLog);
}, getCooldownProvider()).getInventory());
// Always return false because the cooldown is set by the ConfirmationGUI
return false;
}
use of com.iridium.iridiumskyblock.gui.ConfirmationGUI in project IridiumSkyblock by Iridium-Development.
the class ClearDataCommand 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).
* Allows admins to bypass Island restrictions.
*
* @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) {
if (!(sender instanceof Player)) {
execute(sender);
return true;
}
Player player = (Player) sender;
player.openInventory(new ConfirmationGUI(() -> execute(player), getCooldownProvider()).getInventory());
// Return false because the cooldown is set by the ConfirmationGUI
return false;
}
use of com.iridium.iridiumskyblock.gui.ConfirmationGUI in project IridiumSkyblock by Iridium-Development.
the class DeleteCommand 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).
* Deletes a User's Island.
*
* @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) {
if (args.length == 2 && sender.hasPermission("iridiumskyblock.delete.other")) {
Optional<Island> islandOptional = IridiumSkyblockAPI.getInstance().getUser(Bukkit.getOfflinePlayer(args[1])).getIsland();
if (!islandOptional.isPresent()) {
sender.sendMessage(StringUtils.color(IridiumSkyblock.getInstance().getMessages().userNoIsland.replace("%prefix%", IridiumSkyblock.getInstance().getConfiguration().prefix)));
} else {
IridiumSkyblock.getInstance().getIslandManager().deleteIsland(islandOptional.get(), null);
sender.sendMessage(StringUtils.color(IridiumSkyblock.getInstance().getMessages().otherIslandDeleted.replace("%prefix%", IridiumSkyblock.getInstance().getConfiguration().prefix)));
}
return false;
}
if (!(sender instanceof Player)) {
sender.sendMessage(StringUtils.color(IridiumSkyblock.getInstance().getMessages().notAPlayer).replace("%prefix%", IridiumSkyblock.getInstance().getConfiguration().prefix));
return false;
}
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 (!user.getIslandRank().equals(IslandRank.OWNER)) {
player.sendMessage(StringUtils.color(IridiumSkyblock.getInstance().getMessages().cannotDeleteIsland.replace("%prefix%", IridiumSkyblock.getInstance().getConfiguration().prefix)));
return false;
}
player.openInventory(new ConfirmationGUI(() -> IridiumSkyblock.getInstance().getIslandManager().deleteIsland(island.get(), user), getCooldownProvider()).getInventory());
// Always return false because the cooldown is set by the ConfirmationGUI
return false;
}
Aggregations