|
@@ -7,9 +7,11 @@ import me.lethunderhawk.clans.ClanModule;
|
|
|
import me.lethunderhawk.clans.claim.Claim;
|
|
import me.lethunderhawk.clans.claim.Claim;
|
|
|
import me.lethunderhawk.clans.gui.ClanGUI;
|
|
import me.lethunderhawk.clans.gui.ClanGUI;
|
|
|
import me.lethunderhawk.clans.rules.Rule;
|
|
import me.lethunderhawk.clans.rules.Rule;
|
|
|
|
|
+import me.lethunderhawk.custom.item.concrete.ClaimTool;
|
|
|
import me.lethunderhawk.main.Main;
|
|
import me.lethunderhawk.main.Main;
|
|
|
import net.kyori.adventure.text.Component;
|
|
import net.kyori.adventure.text.Component;
|
|
|
import net.kyori.adventure.text.format.NamedTextColor;
|
|
import net.kyori.adventure.text.format.NamedTextColor;
|
|
|
|
|
+import net.kyori.adventure.text.format.TextDecoration;
|
|
|
import org.bukkit.Bukkit;
|
|
import org.bukkit.Bukkit;
|
|
|
import org.bukkit.command.Command;
|
|
import org.bukkit.command.Command;
|
|
|
import org.bukkit.command.CommandExecutor;
|
|
import org.bukkit.command.CommandExecutor;
|
|
@@ -47,7 +49,7 @@ public class ClanCommand implements CommandExecutor, TabCompleter {
|
|
|
CommandNode claimNode = registerCommand("claim", "Claim land for your clan", this::handleClaim);
|
|
CommandNode claimNode = registerCommand("claim", "Claim land for your clan", this::handleClaim);
|
|
|
claimNode.registerSubCommand("info", "Get information about your claims", this::infoClaims);
|
|
claimNode.registerSubCommand("info", "Get information about your claims", this::infoClaims);
|
|
|
claimNode.registerSubCommand("removeAll", "Remove all current claims", this::removeAllClaims);
|
|
claimNode.registerSubCommand("removeAll", "Remove all current claims", this::removeAllClaims);
|
|
|
-
|
|
|
|
|
|
|
+ claimNode.registerSubCommand("tool", "Get the claimTool", this::getClaimTool);
|
|
|
CommandNode acceptNode = registerCommand("acceptRequest", "Accept a pending request of a player", this::handleAcceptRequest);
|
|
CommandNode acceptNode = registerCommand("acceptRequest", "Accept a pending request of a player", this::handleAcceptRequest);
|
|
|
acceptNode.setTabCompleter(this::completeRequests);
|
|
acceptNode.setTabCompleter(this::completeRequests);
|
|
|
|
|
|
|
@@ -71,25 +73,36 @@ public class ClanCommand implements CommandExecutor, TabCompleter {
|
|
|
registerCommand("create", "Create a new clan", this::handleCreate);
|
|
registerCommand("create", "Create a new clan", this::handleCreate);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ private void getClaimTool(CommandSender sender, String[] strings) {
|
|
|
|
|
+ if(!(sender instanceof Player p)) return;
|
|
|
|
|
+ p.getInventory().addItem(new ClaimTool(Main.getInstance()).createItem());
|
|
|
|
|
+ ClanModule.sendText(p, Component.text("The tool magically appears in your inventory! How convenient!"));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
private void handleSave(CommandSender sender, String[] strings) {
|
|
private void handleSave(CommandSender sender, String[] strings) {
|
|
|
if(!sender.isOp()) return;
|
|
if(!sender.isOp()) return;
|
|
|
Main.getInstance().getClanModule().getClanManager().saveClans();
|
|
Main.getInstance().getClanModule().getClanManager().saveClans();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private void removeAllClaims(CommandSender sender, String[] strings) {
|
|
private void removeAllClaims(CommandSender sender, String[] strings) {
|
|
|
- if(!(sender instanceof Player player)) return;
|
|
|
|
|
|
|
+ if(!(sender instanceof Player player) || !sender.isOp()) return;
|
|
|
Main.getInstance().getClanModule().getClaimManager().removeAllClaims();
|
|
Main.getInstance().getClanModule().getClaimManager().removeAllClaims();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private void infoClaims(CommandSender sender, String[] strings) {
|
|
private void infoClaims(CommandSender sender, String[] strings) {
|
|
|
if(!(sender instanceof Player player)) return;
|
|
if(!(sender instanceof Player player)) return;
|
|
|
UUID uuid = player.getUniqueId();
|
|
UUID uuid = player.getUniqueId();
|
|
|
- if(manager.getMyClan(uuid) == null) return;
|
|
|
|
|
- for(Claim claim : manager.getMyClan(uuid).getClaims()){
|
|
|
|
|
- ClanModule.sendText(player, "info about your claim");
|
|
|
|
|
- ClanModule.sendText(player, claim.getVolume()+" is this volume");
|
|
|
|
|
|
|
+ Clan myClan = manager.getMyClan(uuid);
|
|
|
|
|
+ if(myClan == null) return;
|
|
|
|
|
+ ClanModule.sendText(player, Component.text("List of all claims in clan " + myClan.getName(), NamedTextColor.GREEN, TextDecoration.UNDERLINED));
|
|
|
|
|
+ for(Claim claim : myClan.getClaims()){
|
|
|
|
|
+ ClanModule.sendText(player, Component.text("Claim: " + claim.getName(), NamedTextColor.GOLD));
|
|
|
|
|
+ ClanModule.sendText(player, Component.text("This claim spans from X: " + claim.getMaxX() + " to X: " + claim.getMinX(), NamedTextColor.GRAY)
|
|
|
|
|
+ .appendNewline()
|
|
|
|
|
+ .append(Component.text( " and from Z: " + claim.getMaxZ() + " to Z: " + claim.getMinZ(), NamedTextColor.GRAY)));
|
|
|
|
|
+
|
|
|
|
|
+ ClanModule.sendText(player, "Volume of this claim is " + claim.getVolume() + " Blocks");
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private void handleClaim(CommandSender sender, String[] strings) {
|
|
private void handleClaim(CommandSender sender, String[] strings) {
|
|
@@ -107,16 +120,23 @@ public class ClanCommand implements CommandExecutor, TabCompleter {
|
|
|
if (!(sender instanceof Player player) || strings[0] == null || strings[0].isEmpty()) return;
|
|
if (!(sender instanceof Player player) || strings[0] == null || strings[0].isEmpty()) return;
|
|
|
UUID uuid = player.getUniqueId();
|
|
UUID uuid = player.getUniqueId();
|
|
|
Clan clan = manager.getMyClan(uuid);
|
|
Clan clan = manager.getMyClan(uuid);
|
|
|
- clan.denyRequest(uuid, strings[0]);
|
|
|
|
|
- ClanModule.sendText(player, "You declined the request from " + strings[0] + ".");
|
|
|
|
|
|
|
+ if(clan.denyRequest(uuid, strings[0])){
|
|
|
|
|
+ ClanModule.sendText(player, "You declined the request from " + strings[0] + ".");
|
|
|
|
|
+ }else{
|
|
|
|
|
+ ClanModule.sendText(player, "You are not the owner, or " + strings[0] + " hasn't requested to join your clan.");
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private void handleAcceptRequest(CommandSender sender, String[] strings) {
|
|
private void handleAcceptRequest(CommandSender sender, String[] strings) {
|
|
|
if (!(sender instanceof Player player) || strings[0] == null || strings[0].isEmpty()) return;
|
|
if (!(sender instanceof Player player) || strings[0] == null || strings[0].isEmpty()) return;
|
|
|
UUID uuid = player.getUniqueId();
|
|
UUID uuid = player.getUniqueId();
|
|
|
Clan clan = manager.getMyClan(uuid);
|
|
Clan clan = manager.getMyClan(uuid);
|
|
|
- clan.acceptRequest(uuid, strings[0]);
|
|
|
|
|
- ClanModule.sendText(player, "You accepted the request from " + strings[0] + ".");
|
|
|
|
|
|
|
+ if(clan.acceptRequest(uuid, strings[0])){
|
|
|
|
|
+ ClanModule.sendText(player, "You accepted the request from " + strings[0] + ".");
|
|
|
|
|
+ }else{
|
|
|
|
|
+ ClanModule.sendText(player, "You are not the owner, or " + strings[0] + " hasn't requested to join your clan.");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private void handleShowMembers(CommandSender sender, String[] strings) {
|
|
private void handleShowMembers(CommandSender sender, String[] strings) {
|
|
@@ -130,7 +150,9 @@ public class ClanCommand implements CommandExecutor, TabCompleter {
|
|
|
Component.text("Owner: ", NamedTextColor.RED)
|
|
Component.text("Owner: ", NamedTextColor.RED)
|
|
|
.append(Component.text(owner.getName(), NamedTextColor.GRAY)));
|
|
.append(Component.text(owner.getName(), NamedTextColor.GRAY)));
|
|
|
for(UUID member : clan.getMembers()){
|
|
for(UUID member : clan.getMembers()){
|
|
|
- ClanModule.sendText(player, Bukkit.getPlayer(member).getName());
|
|
|
|
|
|
|
+ Player p = Bukkit.getPlayer(member);
|
|
|
|
|
+ if(p == null) continue;
|
|
|
|
|
+ ClanModule.sendText(player, p.getName());
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|