Skip to content

Commit a71a07c

Browse files
committed
Add /where-claim
1 parent 8d584b3 commit a71a07c

5 files changed

Lines changed: 107 additions & 2 deletions

File tree

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,11 @@
6161
- **Permission:** easyguard.get-ip
6262
- **Usage:**
6363
- /get-ip
64+
- where-claim
65+
- **Description:** Shows the location of a claim
66+
- **Permission:** easyguard.where-claim
67+
- **Usage:**
68+
- /where-claim \<claim-name\>
6469
## Permissions
6570
- easyguard.safelist-bypass
6671
- **Description:** Lets players bypass the Safe-list

src/main/java/github/aixoio/easyguard/EasyGuard.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,15 @@
22

33
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
44
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
5-
import github.aixoio.easyguard.commands.*;
5+
import github.aixoio.easyguard.commands.ClaimBoundsCommand;
6+
import github.aixoio.easyguard.commands.ClaimCommand;
7+
import github.aixoio.easyguard.commands.ClaimsCommand;
8+
import github.aixoio.easyguard.commands.CurrentClaimCommand;
9+
import github.aixoio.easyguard.commands.DeleteClaimCommand;
10+
import github.aixoio.easyguard.commands.FlagCommand;
11+
import github.aixoio.easyguard.commands.GetIPCommand;
12+
import github.aixoio.easyguard.commands.TrustCommand;
13+
import github.aixoio.easyguard.commands.WhereClaimCommand;
614
import github.aixoio.easyguard.events.antispam.AntiSpamAsyncPlayerChatEvent;
715
import github.aixoio.easyguard.events.creeperguard.CreeperGuardDamageEvent;
816
import github.aixoio.easyguard.events.creeperguard.CreeperGuardEntityExplodeEvent;
@@ -63,6 +71,7 @@ public void onEnable() {
6371
this.getCommand("flag").setExecutor(new FlagCommand());
6472
this.getCommand("claim-bounds").setExecutor(new ClaimBoundsCommand());
6573
this.getCommand("get-ip").setExecutor(new GetIPCommand());
74+
this.getCommand("where-claim").setExecutor(new WhereClaimCommand());
6675

6776
this.getServer().getPluginManager().registerEvents(new SafeListJoinEvent(), this);
6877
this.getServer().getPluginManager().registerEvents(new SafeListLeaveEvent(), this);

src/main/java/github/aixoio/easyguard/commands/FlagCommand.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
import com.sk89q.worldguard.protection.ApplicableRegionSet;
88
import com.sk89q.worldguard.protection.flags.Flags;
99
import com.sk89q.worldguard.protection.flags.RegionGroup;
10-
import com.sk89q.worldguard.protection.flags.RegionGroupFlag;
1110
import com.sk89q.worldguard.protection.flags.StateFlag;
1211
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
1312
import github.aixoio.easyguard.EasyGuard;
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
package github.aixoio.easyguard.commands;
2+
3+
import com.sk89q.worldedit.math.BlockVector3;
4+
import com.sk89q.worldguard.LocalPlayer;
5+
import com.sk89q.worldguard.WorldGuard;
6+
import com.sk89q.worldguard.protection.ApplicableRegionSet;
7+
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
8+
import github.aixoio.easyguard.EasyGuard;
9+
import org.bukkit.ChatColor;
10+
import org.bukkit.Location;
11+
import org.bukkit.command.Command;
12+
import org.bukkit.command.CommandExecutor;
13+
import org.bukkit.command.CommandSender;
14+
import org.bukkit.entity.Player;
15+
16+
public class WhereClaimCommand implements CommandExecutor {
17+
18+
@Override
19+
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
20+
21+
if (!sender.hasPermission("easyguard.where-claim")) {
22+
23+
sender.sendMessage(ChatColor.DARK_RED + "You do not have the needed permission to use this command!");
24+
return true;
25+
26+
}
27+
28+
if (!(sender instanceof Player)) {
29+
30+
sender.sendMessage(ChatColor.RED + "You have to be a player to use this command!");
31+
return true;
32+
33+
}
34+
35+
if (args.length < 1) return false;
36+
37+
String location = args[0];
38+
39+
Player player = (Player) sender;
40+
41+
LocalPlayer localPlayer = EasyGuard.getWorldGuard().wrapPlayer(player);
42+
43+
try {
44+
45+
Location targetLocaiton = EasyGuard.getPlugin().getConfig().getLocation(String.format("data.%s.%s.location", player.getDisplayName(), location));
46+
47+
if (targetLocaiton == null) {
48+
49+
sender.sendMessage(ChatColor.RED + "Not found!");
50+
return true;
51+
52+
}
53+
54+
55+
BlockVector3 targetLocaitonAsVector = BlockVector3.at(targetLocaiton.getX(), targetLocaiton.getY(), targetLocaiton.getZ());
56+
57+
ApplicableRegionSet applicableRegionSet = WorldGuard
58+
.getInstance()
59+
.getPlatform()
60+
.getRegionContainer()
61+
.get(localPlayer.getWorld())
62+
.getApplicableRegions(
63+
targetLocaitonAsVector
64+
);
65+
66+
for (ProtectedRegion region : applicableRegionSet) {
67+
68+
sender.sendMessage(ChatColor.GREEN + "The location of " + region.getId() + " is X: " + region.getMaximumPoint().getX() +
69+
", Y: " + region.getMaximumPoint().getY() + ", Z: " + region.getMaximumPoint().getZ());
70+
71+
}
72+
73+
} catch (Exception e) {
74+
75+
sender.sendMessage(ChatColor.RED + "Not found!");
76+
77+
EasyGuard.getPlugin().getLogger().info(e.toString());
78+
79+
}
80+
81+
return true;
82+
83+
}
84+
85+
}

src/main/resources/plugin.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@ commands:
4343
description: Shows the ip of a player
4444
usage: /<command> [username]
4545
permission: easyguard.get-ip
46+
where-claim:
47+
description: Shows the location of a claim
48+
usage: /<command> [claim-name]
49+
permission: easyguard.where-claim
4650
permissions:
4751
easyguard.claim:
4852
description: Gives access to /claim
@@ -77,3 +81,6 @@ permissions:
7781
easyguard.bounds:
7882
description: Lets players use /claim-bounds
7983
default: op
84+
easyguard.where-claim:
85+
description: Lets players use /where-claim
86+
default: true

0 commit comments

Comments
 (0)