mirror of
https://github.com/darksaid98/HuskHomes.git
synced 2026-12-02 06:28:49 +00:00
Better world lookups for map hook, close #215
This commit is contained in:
1 parent
a9e643d199
commit
f80261d919
3 files changed
+63
-22
No files matched your search
@@ -1,7 +1,9 @@
|
||||
package net.william278.huskhomes.hook;
|
||||
|
||||
import net.william278.huskhomes.HuskHomes;
|
||||
import net.william278.huskhomes.HuskHomesException;
|
||||
import net.william278.huskhomes.position.Home;
|
||||
import net.william278.huskhomes.position.SavedPosition;
|
||||
import net.william278.huskhomes.position.Warp;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -73,4 +75,24 @@ public abstract class MapHook extends PluginHook {
|
||||
*/
|
||||
public abstract CompletableFuture<Void> removeWarp(@NotNull Warp warp);
|
||||
|
||||
/**
|
||||
* Returns if the position is valid to be set on this server
|
||||
*
|
||||
* @param position the position to check
|
||||
* @return if the position is valid
|
||||
*/
|
||||
@SuppressWarnings("BooleanMethodIsAlwaysInverted")
|
||||
protected final boolean isValidPosition(@NotNull SavedPosition position) {
|
||||
if (position instanceof Warp && !plugin.getSettings().warpsOnMap) return false;
|
||||
if (position instanceof Home && !plugin.getSettings().publicHomesOnMap) return false;
|
||||
|
||||
try {
|
||||
return position.server.equals(plugin.getPluginServer());
|
||||
} catch (HuskHomesException e) {
|
||||
return plugin.getWorlds().stream()
|
||||
.map(world -> world.uuid)
|
||||
.anyMatch(uuid -> uuid.equals(position.world.uuid));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user