diff --git a/pom.xml b/pom.xml
index 29c9764..8d4fc4e 100644
--- a/pom.xml
+++ b/pom.xml
@@ -6,7 +6,7 @@
de.themoep
entitydetection
- 1.1.3
+ 1.2.0
Bukkit plugin to find groups of mobs, animals or other (tile) entities.
EntityDetection
@@ -22,6 +22,10 @@
spigot-repo
https://hub.spigotmc.org/nexus/content/groups/public/
+
+ enginehub-repo
+ https://maven.enginehub.org/repo/
+
@@ -29,6 +33,13 @@
org.spigotmc
spigot-api
1.13.2-R0.1-SNAPSHOT
+ provided
+
+
+ com.sk89q.worldguard
+ worldguard-bukkit
+ 7.0.2
+ provided
diff --git a/src/main/java/de/themoep/entitydetection/EntityDetection.java b/src/main/java/de/themoep/entitydetection/EntityDetection.java
index f3915e8..8038bf1 100644
--- a/src/main/java/de/themoep/entitydetection/EntityDetection.java
+++ b/src/main/java/de/themoep/entitydetection/EntityDetection.java
@@ -16,7 +16,6 @@
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
-import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
@@ -49,9 +48,9 @@ public class EntityDetection extends JavaPlugin {
private EntitySearch currentSearch;
- private Map results = new HashMap();
- private Map customResults = new HashMap();
- private Map lastResultViewed = new HashMap();
+ private Map> results = new HashMap<>();
+ private Map> customResults = new HashMap<>();
+ private Map> lastResultViewed = new HashMap<>();
private boolean serverIsSpigot = true;
@@ -84,7 +83,7 @@ public boolean stopSearch(String stopper) {
return true;
}
- public void addResult(SearchResult result) {
+ public void addResult(SearchResult> result) {
if(result.getType() == SearchType.CUSTOM && result.getSearched().size() == 1) {
Set searchedEntities = result.getSearched();
customResults.put(searchedEntities.toArray(new String[searchedEntities.size()])[0], result);
@@ -97,12 +96,12 @@ public EntitySearch getCurrentSearch() {
return currentSearch;
}
- public void send(CommandSender sender, SearchResult result) {
+ public void send(CommandSender sender, SearchResult> result) {
send(sender, result, 0);
}
- public void send(CommandSender sender, SearchResult result, int page) {
+ public void send(CommandSender sender, SearchResult> result, int page) {
lastResultViewed.put(sender.getName(), result);
String dateStr = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date(result.getEndTime()));
@@ -124,10 +123,10 @@ public void send(CommandSender sender, SearchResult result, int page) {
.append("from " + dateStr + ":")
.color(net.md_5.bungee.api.ChatColor.WHITE);
- List results = result.getSortedEntries();
+ List extends SearchResultEntry>> results = result.getSortedEntries();
if(results.size() > 0) {
for(int line = start; line < start + 10 && line < results.size(); line++) {
- SearchResultEntry entry = results.get(line);
+ SearchResultEntry> entry = results.get(line);
builder.append("\n")
.retain(ComponentBuilder.FormatRetention.NONE)
@@ -142,7 +141,7 @@ public void send(CommandSender sender, SearchResult result, int page) {
)
)
.event(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/detect tp " + (line + 1)))
- .append(entry.getChunk() + " ")
+ .append(entry.getLocation() + " ")
.color(net.md_5.bungee.api.ChatColor.YELLOW)
.append(entry.getSize() + " ")
.color(net.md_5.bungee.api.ChatColor.RED);
@@ -171,12 +170,12 @@ public void send(CommandSender sender, SearchResult result, int page) {
List msg = new ArrayList();
msg.add(ChatColor.GREEN + Utils.enumToHumanName(result.getType()) + " search " + ChatColor.WHITE + "from " + dateStr + ":");
- List chunkEntries = result.getSortedEntries();
+ List extends SearchResultEntry>> chunkEntries = result.getSortedEntries();
if(chunkEntries.size() > 0) {
for(int line = start; line < start + 10 && line < chunkEntries.size(); line++) {
- SearchResultEntry chunkEntry = chunkEntries.get(line);
+ SearchResultEntry> chunkEntry = chunkEntries.get(line);
- String lineText = ChatColor.WHITE + " " + (line + 1) + ": " + ChatColor.YELLOW + chunkEntry.getChunk() + " " + ChatColor.RED + chunkEntry.getSize() + " ";
+ String lineText = ChatColor.WHITE + " " + (line + 1) + ": " + ChatColor.YELLOW + chunkEntry.getLocation() + " " + ChatColor.RED + chunkEntry.getSize() + " ";
int entitiesListed = 0;
for(Entry entityEntry : chunkEntry.getEntryCount()) {
@@ -195,15 +194,15 @@ public void send(CommandSender sender, SearchResult result, int page) {
}
}
- public SearchResult getResult(CommandSender sender) {
+ public SearchResult> getResult(CommandSender sender) {
return lastResultViewed.get(sender.getName());
}
- public SearchResult getResult(String type) {
+ public SearchResult> getResult(String type) {
return customResults.get(type);
}
- public SearchResult getResult(SearchType type) {
+ public SearchResult> getResult(SearchType type) {
return results.get(type);
}
}
diff --git a/src/main/java/de/themoep/entitydetection/commands/ListSubCommand.java b/src/main/java/de/themoep/entitydetection/commands/ListSubCommand.java
index c9a8206..8e99e90 100644
--- a/src/main/java/de/themoep/entitydetection/commands/ListSubCommand.java
+++ b/src/main/java/de/themoep/entitydetection/commands/ListSubCommand.java
@@ -39,7 +39,7 @@ public ListSubCommand(EntityDetection plugin) {
@Override
public boolean execute(CommandSender sender, String[] args) {
- SearchResult result = getPlugin().getResult(sender);
+ SearchResult> result = getPlugin().getResult(sender);
int page = 1;
String lastName = sender.getName();
if(args.length > 0) {
diff --git a/src/main/java/de/themoep/entitydetection/commands/SearchSubCommand.java b/src/main/java/de/themoep/entitydetection/commands/SearchSubCommand.java
index 58f6be2..f99e807 100644
--- a/src/main/java/de/themoep/entitydetection/commands/SearchSubCommand.java
+++ b/src/main/java/de/themoep/entitydetection/commands/SearchSubCommand.java
@@ -3,10 +3,12 @@
import de.themoep.entitydetection.EntityDetection;
import de.themoep.entitydetection.searcher.EntitySearch;
import de.themoep.entitydetection.searcher.SearchType;
+import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.EntityType;
+import org.bukkit.plugin.Plugin;
/**
* Copyright 2016 Max Lee (https://github.com/Phoenix616/)
@@ -36,6 +38,17 @@ public boolean execute(CommandSender sender, String[] args) {
EntitySearch search = new EntitySearch(getPlugin(), sender);
if(args.length > 0) {
for(String arg : args) {
+ if ("--regions".equalsIgnoreCase(arg)) {
+ Plugin plugin = Bukkit.getPluginManager().getPlugin("WorldGuard");
+ if (plugin != null && plugin.isEnabled() && plugin.getDescription().getVersion().startsWith("7"))
+ search.setWorldGuardRegion(true);
+ else {
+ sender.sendMessage(ChatColor.RED + "Unable to start WorldGuard search. WorldGuard not enabled or outdated!");
+ return true;
+ }
+ if (args.length == 1) search.setType(SearchType.MONSTER);
+ continue;
+ }
if (arg.endsWith("s")) {
arg = arg.substring(0, arg.length() - 1);
}
diff --git a/src/main/java/de/themoep/entitydetection/commands/TpSubCommand.java b/src/main/java/de/themoep/entitydetection/commands/TpSubCommand.java
index 90adeb9..4200c79 100644
--- a/src/main/java/de/themoep/entitydetection/commands/TpSubCommand.java
+++ b/src/main/java/de/themoep/entitydetection/commands/TpSubCommand.java
@@ -46,7 +46,10 @@ public boolean execute(CommandSender sender, String[] args) {
if(args.length == 0) {
return false;
}
- SearchResult lastResult = getPlugin().getResult(sender);
+ return teleport((Player)sender, args[0], getPlugin().getResult(sender));
+ }
+
+ private boolean teleport(Player sender, String page, SearchResult lastResult) {
if(lastResult == null) {
sender.sendMessage(ChatColor.RED + "You have to view a search result before teleporting to an entry! Use /detect search or /detect list []");
return true;
@@ -54,53 +57,19 @@ public boolean execute(CommandSender sender, String[] args) {
int i;
try {
- i = Integer.parseInt(args[0]);
+ i = Integer.parseInt(page);
} catch(NumberFormatException e) {
- sender.sendMessage(ChatColor.YELLOW + args[0] + ChatColor.RED + " is not a proper number input!");
+ sender.sendMessage(ChatColor.YELLOW + page + ChatColor.RED + " is not a proper number input!");
return false;
}
if(i == 0 || lastResult.getSortedEntries().size() < i) {
- sender.sendMessage(ChatColor.RED + "Result " + ChatColor.YELLOW + args[0] + ChatColor.RED + " is not in the list!");
+ sender.sendMessage(ChatColor.RED + "Result " + ChatColor.YELLOW + page + ChatColor.RED + " is not in the list!");
return true;
}
- SearchResultEntry entry = lastResult.getSortedEntries().get(i - 1);
-
- try {
- Chunk chunk = entry.getChunk().toBukkit(getPlugin().getServer());
-
- Location loc = null;
-
- for(Entity e : chunk.getEntities()) {
- if(e.getType().toString().equals(entry.getEntryCount().get(0).getKey())) {
- loc = e.getLocation();
- break;
- }
- }
-
- for (BlockState b : chunk.getTileEntities()) {
- if(b.getType().toString().equals(entry.getEntryCount().get(0).getKey())) {
- loc = b.getLocation().add(0, 1, 0);
- break;
- }
- }
-
- if (loc == null) {
- loc = chunk.getWorld().getHighestBlockAt(chunk.getX() * 16 + 8, chunk.getZ() * 16 + 8).getLocation().add(0, 2, 0);
- }
-
- ((Player) sender).teleport(loc, PlayerTeleportEvent.TeleportCause.PLUGIN);
- sender.sendMessage(
- ChatColor.GREEN + "Teleported to entry " + ChatColor.WHITE + i + ": " +
- ChatColor.YELLOW + entry.getChunk() + " " + ChatColor.RED + entry.getSize() + " " +
- ChatColor.GREEN + Utils.enumToHumanName(entry.getEntryCount().get(0).getKey()) + "[" +
- ChatColor.WHITE + entry.getEntryCount().get(0).getValue() + ChatColor.GREEN + "]"
- );
-
- } catch(IllegalArgumentException e) {
- sender.sendMessage(ChatColor.RED + e.getMessage());
- }
+ SearchResultEntry entry = lastResult.getSortedEntries().get(i - 1);
+ lastResult.teleport(sender, entry, i);
return true;
}
}
diff --git a/src/main/java/de/themoep/entitydetection/searcher/ChunkSearchResult.java b/src/main/java/de/themoep/entitydetection/searcher/ChunkSearchResult.java
new file mode 100644
index 0000000..07ef724
--- /dev/null
+++ b/src/main/java/de/themoep/entitydetection/searcher/ChunkSearchResult.java
@@ -0,0 +1,76 @@
+package de.themoep.entitydetection.searcher;
+
+import de.themoep.entitydetection.ChunkLocation;
+import de.themoep.entitydetection.Utils;
+import org.bukkit.Bukkit;
+import org.bukkit.ChatColor;
+import org.bukkit.Chunk;
+import org.bukkit.Location;
+import org.bukkit.block.BlockState;
+import org.bukkit.entity.Entity;
+import org.bukkit.entity.Player;
+import org.bukkit.event.player.PlayerTeleportEvent;
+
+public class ChunkSearchResult extends SearchResult {
+ public ChunkSearchResult(EntitySearch search) {
+ super(search);
+ }
+
+ @Override
+ public void addEntity(Entity entity) {
+ add(entity.getLocation(), entity.getType().toString());
+ }
+
+ @Override
+ public void addBlockState(BlockState blockState) {
+ add(blockState.getLocation(), blockState.getType().toString());
+ }
+
+ @Override
+ public void add(Location location, String type) {
+ ChunkLocation chunkLocation = new ChunkLocation(location);
+
+ if(!resultEntryMap.containsKey(chunkLocation)) {
+ resultEntryMap.put(chunkLocation, new SearchResultEntry<>(chunkLocation));
+ }
+ resultEntryMap.get(chunkLocation).increment(type);
+ }
+
+ @Override
+ public void teleport(Player sender, SearchResultEntry entry, int i) {
+ try {
+ Chunk chunk = entry.getLocation().toBukkit(Bukkit.getServer());
+
+ Location loc = null;
+
+ for(Entity e : chunk.getEntities()) {
+ if(e.getType().toString().equals(entry.getEntryCount().get(0).getKey())) {
+ loc = e.getLocation();
+ break;
+ }
+ }
+
+ for (BlockState b : chunk.getTileEntities()) {
+ if(b.getType().toString().equals(entry.getEntryCount().get(0).getKey())) {
+ loc = b.getLocation().add(0, 1, 0);
+ break;
+ }
+ }
+
+ if (loc == null) {
+ loc = chunk.getWorld().getHighestBlockAt(chunk.getX() * 16 + 8, chunk.getZ() * 16 + 8).getLocation().add(0, 2, 0);
+ }
+
+ sender.teleport(loc, PlayerTeleportEvent.TeleportCause.PLUGIN);
+ sender.sendMessage(
+ ChatColor.GREEN + "Teleported to entry " + ChatColor.WHITE + i + ": " +
+ ChatColor.YELLOW + entry.getLocation() + " " + ChatColor.RED + entry.getSize() + " " +
+ ChatColor.GREEN + Utils.enumToHumanName(entry.getEntryCount().get(0).getKey()) + "[" +
+ ChatColor.WHITE + entry.getEntryCount().get(0).getValue() + ChatColor.GREEN + "]"
+ );
+
+ } catch(IllegalArgumentException e) {
+ sender.sendMessage(ChatColor.RED + e.getMessage());
+ }
+ }
+}
diff --git a/src/main/java/de/themoep/entitydetection/searcher/EntitySearch.java b/src/main/java/de/themoep/entitydetection/searcher/EntitySearch.java
index cd4a2c4..0c54061 100644
--- a/src/main/java/de/themoep/entitydetection/searcher/EntitySearch.java
+++ b/src/main/java/de/themoep/entitydetection/searcher/EntitySearch.java
@@ -46,6 +46,8 @@ public class EntitySearch extends BukkitRunnable {
private List entities = new ArrayList();
private List blockStates = new ArrayList();
+ private boolean isWorldGuardRegion = false;
+
public EntitySearch(EntityDetection plugin, CommandSender sender) {
this.plugin = plugin;
owner = sender;
@@ -100,6 +102,13 @@ public long getStartTime() {
return startTime;
}
+ public boolean isWorldGuardRegion() {
+ return this.isWorldGuardRegion;
+ }
+
+ public void setWorldGuardRegion(boolean value) {
+ this.isWorldGuardRegion = value;
+ }
/**
* Get the duration since this search started
* @return The duration in seconds
@@ -138,7 +147,9 @@ public void stop(String name) {
public void run() {
startTime = System.currentTimeMillis();
- SearchResult result = new SearchResult(this);
+ SearchResult> result;
+ if(isWorldGuardRegion) result = new WGSearchResult(this);
+ else result = new ChunkSearchResult(this);
for(Entity e : entities) {
if(!running) {
@@ -159,7 +170,7 @@ public void run() {
}
result.sort();
- plugin.addResult(result);;
+ plugin.addResult(result);
plugin.send(owner, result);
running = false;
}
diff --git a/src/main/java/de/themoep/entitydetection/searcher/SearchResult.java b/src/main/java/de/themoep/entitydetection/searcher/SearchResult.java
index ee0d6e3..a61648c 100644
--- a/src/main/java/de/themoep/entitydetection/searcher/SearchResult.java
+++ b/src/main/java/de/themoep/entitydetection/searcher/SearchResult.java
@@ -1,10 +1,11 @@
package de.themoep.entitydetection.searcher;
-import de.themoep.entitydetection.ChunkLocation;
+import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.BlockState;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
+import org.bukkit.entity.Player;
import java.util.ArrayList;
import java.util.Collections;
@@ -29,7 +30,7 @@
* You should have received a copy of the Mozilla Public License v2.0
* along with this program. If not, see .
*/
-public class SearchResult {
+public abstract class SearchResult {
private SearchType type;
private Set searched;
private long startTime;
@@ -38,12 +39,12 @@ public class SearchResult {
/**
* Working search map, use resultEntryList after sorting this result!
*/
- private Map resultEntryMap = new HashMap();
+ protected Map> resultEntryMap = new HashMap<>();
/**
* Sorted, highest entity count per chunks first, only propagated after running .sort()
*/
- private List resultEntryList = new ArrayList();
+ protected List> resultEntryList = new ArrayList<>();
public SearchResult(EntitySearch search) {
type = search.getType();
@@ -64,24 +65,15 @@ public SearchResult(EntitySearch search) {
* Add an entity to this result
* @param entity The entity to add
*/
- public void addEntity(Entity entity) {
- add(new ChunkLocation(entity.getLocation()), entity.getType().toString());
- }
+ public abstract void addEntity(Entity entity);
/**
* Add a BlockState to this result
* @param blockState The entity to add
*/
- public void addBlockState(BlockState blockState) {
- add(new ChunkLocation(blockState.getLocation()), blockState.getType().toString());
- }
+ public abstract void addBlockState(BlockState blockState);
- public void add(ChunkLocation chunkLoc, String type) {
- if(!resultEntryMap.containsKey(chunkLoc)) {
- resultEntryMap.put(chunkLoc, new SearchResultEntry(chunkLoc));
- }
- resultEntryMap.get(chunkLoc).increment(type);
- }
+ public abstract void add(Location location, String type);
public SearchType getType() {
return type;
@@ -107,7 +99,7 @@ public Set getSearched() {
* Get a list of entries for every chunk, only propagated after calling sort()
* @return An ArrayList of the chunks sorted from the highest
*/
- public List getSortedEntries() {
+ public List> getSortedEntries() {
return resultEntryList;
}
@@ -115,13 +107,14 @@ public List getSortedEntries() {
* Sort the results and set the end time
*/
public void sort() {
- for(SearchResultEntry chunkEntry : resultEntryMap.values()) {
+ for(SearchResultEntry> chunkEntry : resultEntryMap.values()) {
chunkEntry.sort();
}
- resultEntryList = new ArrayList(resultEntryMap.values());
+ resultEntryList = new ArrayList<>(resultEntryMap.values());
Collections.sort(resultEntryList, Collections.reverseOrder());
endTime = System.currentTimeMillis();
}
+ public abstract void teleport(Player sender, SearchResultEntry entry, int i);
}
diff --git a/src/main/java/de/themoep/entitydetection/searcher/SearchResultEntry.java b/src/main/java/de/themoep/entitydetection/searcher/SearchResultEntry.java
index 47b75c5..2c9da1d 100644
--- a/src/main/java/de/themoep/entitydetection/searcher/SearchResultEntry.java
+++ b/src/main/java/de/themoep/entitydetection/searcher/SearchResultEntry.java
@@ -1,7 +1,5 @@
package de.themoep.entitydetection.searcher;
-import de.themoep.entitydetection.ChunkLocation;
-
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
@@ -24,14 +22,14 @@
* You should have received a copy of the Mozilla Public License v2.0
* along with this program. If not, see .
*/
-public class SearchResultEntry implements Comparable {
- private ChunkLocation chunk;
+public class SearchResultEntry implements Comparable> {
+ private T location;
private Map entryCount = new HashMap();
private List> finalList = new ArrayList>();
private int size = 0;
- SearchResultEntry(ChunkLocation chunk) {
- this.chunk = chunk;
+ SearchResultEntry(T location) {
+ this.location = location;
}
public void increment(String type) {
@@ -47,8 +45,8 @@ public int getSize() {
return size;
}
- public ChunkLocation getChunk() {
- return chunk;
+ public T getLocation() {
+ return location;
}
public List> getEntryCount() {
@@ -56,12 +54,8 @@ public List> getEntryCount() {
}
public void sort() {
- finalList = new ArrayList>(entryCount.entrySet());
- Collections.sort(finalList, Collections.reverseOrder(new Comparator>() {
- public int compare(Map.Entry o1, Map.Entry o2) {
- return Integer.compare(o1.getValue(), o2.getValue());
- }
- }));
+ finalList = new ArrayList<>(entryCount.entrySet());
+ finalList.sort(Collections.reverseOrder(Comparator.comparingInt(Map.Entry::getValue)));
}
public int compareTo(SearchResultEntry o) {
diff --git a/src/main/java/de/themoep/entitydetection/searcher/WGSearchResult.java b/src/main/java/de/themoep/entitydetection/searcher/WGSearchResult.java
new file mode 100644
index 0000000..dea4bcb
--- /dev/null
+++ b/src/main/java/de/themoep/entitydetection/searcher/WGSearchResult.java
@@ -0,0 +1,108 @@
+package de.themoep.entitydetection.searcher;
+
+import com.sk89q.worldedit.bukkit.BukkitAdapter;
+import com.sk89q.worldguard.WorldGuard;
+import com.sk89q.worldguard.protection.ApplicableRegionSet;
+import com.sk89q.worldguard.protection.flags.Flags;
+import com.sk89q.worldguard.protection.regions.ProtectedRegion;
+import com.sk89q.worldguard.protection.regions.RegionQuery;
+import de.themoep.entitydetection.Utils;
+import org.bukkit.ChatColor;
+import org.bukkit.Location;
+import org.bukkit.World;
+import org.bukkit.block.BlockState;
+import org.bukkit.entity.Entity;
+import org.bukkit.entity.Player;
+import org.bukkit.event.player.PlayerTeleportEvent;
+
+import java.lang.ref.WeakReference;
+import java.util.Objects;
+
+public class WGSearchResult extends SearchResult {
+ public WGSearchResult(EntitySearch search) {
+ super(search);
+ }
+
+ @Override
+ public void addEntity(Entity entity) {
+ add(entity.getLocation(), entity.getType().toString());
+ }
+
+ @Override
+ public void addBlockState(BlockState blockState) {
+ add(blockState.getLocation(), blockState.getType().toString());
+ }
+
+ @Override
+ public void add(Location location, String type) {
+ RegionQuery query = WorldGuard.getInstance().getPlatform().getRegionContainer().createQuery();
+ ApplicableRegionSet applicableRegions = query.getApplicableRegions(BukkitAdapter.adapt(location));
+
+ applicableRegions.forEach(region -> {
+ ProtectedRegionEntry protectedRegionEntry = new ProtectedRegionEntry(location.getWorld(), region);
+ if(!resultEntryMap.containsKey(protectedRegionEntry)) {
+ resultEntryMap.put(protectedRegionEntry, new SearchResultEntry<>(protectedRegionEntry));
+ }
+ resultEntryMap.get(protectedRegionEntry).increment(type);
+ });
+ }
+
+ @Override
+ public void teleport(Player sender, SearchResultEntry entry, int i) {
+ com.sk89q.worldedit.util.Location wgLocation = entry.getLocation().region.getFlag(Flags.TELE_LOC);
+ try {
+ World world = entry.getLocation().world.get();
+ if(world == null) {
+ sender.sendMessage(ChatColor.RED + "World " + ChatColor.WHITE + entry.getLocation().worldName + ChatColor.RED + " is not loaded anymore.");
+ return;
+ }
+ Location loc = wgLocation != null ? BukkitAdapter.adapt(wgLocation) : null;
+ if(loc == null) {
+ loc = BukkitAdapter.adapt(world, entry.getLocation().region.getMinimumPoint().add(
+ entry.getLocation().region.getMaximumPoint().subtract(entry.getLocation().region.getMinimumPoint()).divide(2)));
+ }
+
+ sender.teleport(loc, PlayerTeleportEvent.TeleportCause.PLUGIN);
+ sender.sendMessage(
+ ChatColor.GREEN + "Teleported to entry " + ChatColor.WHITE + i + ": " +
+ ChatColor.YELLOW + entry.getLocation().region.getId() + " " + ChatColor.RED + entry.getSize() + " " +
+ ChatColor.GREEN + Utils.enumToHumanName(entry.getEntryCount().get(0).getKey()) + "[" +
+ ChatColor.WHITE + entry.getEntryCount().get(0).getValue() + ChatColor.GREEN + "]"
+ );
+ } catch(IllegalArgumentException e) {
+ sender.sendMessage(ChatColor.RED + e.getMessage());
+ }
+ }
+
+ public static class ProtectedRegionEntry {
+ String worldName;
+ WeakReference world;
+ ProtectedRegion region;
+
+ public ProtectedRegionEntry(World world, ProtectedRegion region) {
+ this.worldName = world.getName();
+ this.world = new WeakReference<>(world);
+ this.region = region;
+ }
+
+ @Override
+ public String toString() {
+ World w = world.get();
+ return "w: " + worldName + (w == null ? " (unloaded)" : "") + ", r: " + region.getId();
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+ ProtectedRegionEntry that = (ProtectedRegionEntry) o;
+ return Objects.equals(world, that.world) &&
+ Objects.equals(region, that.region);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(world, region);
+ }
+ }
+}
diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml
index 43bc67c..0da981f 100644
--- a/src/main/resources/plugin.yml
+++ b/src/main/resources/plugin.yml
@@ -3,6 +3,7 @@ main: de.themoep.entitydetection.EntityDetection
version: '${minecraft.plugin.version}'
api-version: 1.13
description: '${project.description}'
+softdepend: ["WorldGuard"]
authors: [Phoenix616]
commands:
entitydetection: