diff --git a/src/main/java/net/countercraft/movecraft/warfare/commands/AssaultRepairCommand.java b/src/main/java/net/countercraft/movecraft/warfare/commands/AssaultRepairCommand.java index 2ee8507..14b6797 100644 --- a/src/main/java/net/countercraft/movecraft/warfare/commands/AssaultRepairCommand.java +++ b/src/main/java/net/countercraft/movecraft/warfare/commands/AssaultRepairCommand.java @@ -2,6 +2,8 @@ import net.countercraft.movecraft.warfare.MovecraftWarfare; import net.countercraft.movecraft.warfare.config.Config; +import net.countercraft.movecraft.warfare.features.assault.AssaultData; +import net.countercraft.movecraft.warfare.features.assault.AssaultUtils; import net.countercraft.movecraft.warfare.features.assault.events.AssaultBroadcastEvent; import net.countercraft.movecraft.warfare.localisation.I18nSupport; import net.countercraft.movecraft.worldguard.MovecraftWorldGuard; @@ -10,13 +12,18 @@ import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; +import org.jetbrains.annotations.NotNull; + +import java.util.List; +import java.util.Set; +import java.util.UUID; import static net.countercraft.movecraft.util.ChatUtils.ERROR_PREFIX; import static net.countercraft.movecraft.util.ChatUtils.MOVECRAFT_COMMAND_PREFIX; public class AssaultRepairCommand implements CommandExecutor { @Override - public boolean onCommand(CommandSender commandSender, Command command, String s, String[] args) { + public boolean onCommand(@NotNull CommandSender commandSender, Command command, @NotNull String s, @NotNull String[] args) { if (!command.getName().equalsIgnoreCase("assaultrepair")) return false; @@ -44,12 +51,13 @@ public boolean onCommand(CommandSender commandSender, Command command, String s, } String regionName = args[0]; - if (MovecraftWorldGuard.getInstance().getWGUtils().regionExists(regionName, player.getWorld())) { + if (!MovecraftWorldGuard.getInstance().getWGUtils().regionExists(regionName, player.getWorld())) { player.sendMessage( MOVECRAFT_COMMAND_PREFIX + I18nSupport.getInternationalisedString("Assault - Region Not Found")); return true; } + player.sendMessage(I18nSupport.getInternationalisedString("Assault - Repairing Region")); if (!MovecraftWarfare.getInstance().getAssaultManager().getRepairUtils() .repairRegionRepairState(player.getWorld(), regionName, player)) { String broadcast = ERROR_PREFIX + " " + String @@ -62,8 +70,24 @@ public boolean onCommand(CommandSender commandSender, Command command, String s, Bukkit.getServer().getPluginManager().callEvent(event); } - // TODO: Re-add owners + List data = AssaultUtils.retrieveInfoFile(regionName, player.getWorld().getName()); + if (data != null && !data.isEmpty()) { + Set ownerSet = data.get(0).getOwners(); + if (ownerSet != null && !ownerSet.isEmpty()) { + if (!MovecraftWorldGuard.getInstance().getWGUtils().addOwners(regionName, player.getWorld(), ownerSet)) { + String broadcast = String.format(I18nSupport.getInternationalisedString("Assault - Owners Failed"), + regionName); + Bukkit.getServer().broadcastMessage(broadcast); + + // Note: there is no assault to pass here... + AssaultBroadcastEvent broadcastEvent = new AssaultBroadcastEvent(null, broadcast, + AssaultBroadcastEvent.Type.OWNER_FAIL); + Bukkit.getServer().getPluginManager().callEvent(broadcastEvent); + } + } + } + player.sendMessage(MOVECRAFT_COMMAND_PREFIX + I18nSupport.getInternationalisedString("AssaultRepair - Successful")); return true; } } diff --git a/src/main/resources/localisation/mcwlang_en.properties b/src/main/resources/localisation/mcwlang_en.properties index 9973f4c..ad311d5 100644 --- a/src/main/resources/localisation/mcwlang_en.properties +++ b/src/main/resources/localisation/mcwlang_en.properties @@ -27,6 +27,7 @@ AssaultInfo\ -\ Not\ Assaultable\ -\ Recently\ Assaulted=NOT ASSAULTABLE DUE TO AssaultInfo\ -\ Not\ Assaultable\ -\ Insufficient\ Defenders=NOT ASSAULTABLE DUE TO INSUFFICIENT ONLINE DEFENDERS AssaultInfo\ -\ Not\ Assaultable\ -\ You\ Are\ Member=NOT ASSAULTABLE BECAUSE YOU ARE A MEMBER AssaultInfo\ -\ Assaultable=THIS REGION CAN BE ASSAULTED +AssaultRepair\ -\ Successful=Admin repair successful, please remember to remove the beacon manually Siege\ -\ Siege\ Cost=Cost to siege\: Siege\ -\ Daily\ Income=Daily income\: Siege\ -\ Day\ of\ Week=Day of week\: