mirror of
https://github.com/NLthijs48/AreaShop.git
synced 2024-09-30 16:27:26 +02:00
Fix contains check for WorldGuard regions not version dependend
This commit is contained in:
parent
c95f4e1c6c
commit
2f6874a16e
@ -1,6 +1,7 @@
|
|||||||
package nl.evolutioncoding.areashop.interfaces;
|
package nl.evolutioncoding.areashop.interfaces;
|
||||||
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
|
|
||||||
@ -13,10 +14,40 @@ public abstract class WorldGuardInterface {
|
|||||||
this.pluginInterface = pluginInterface;
|
this.pluginInterface = pluginInterface;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Players set by UUID or name depending on implementation
|
/**
|
||||||
|
* Parse an owner(s) string and set the players as owner of the WorldGuard region (set by UUID or name depending on implementation)
|
||||||
|
* @param region The WorldGuard region to set the owners of
|
||||||
|
* @param input The owner(s) string to parse and set
|
||||||
|
*/
|
||||||
public abstract void setOwners(ProtectedRegion region, String input);
|
public abstract void setOwners(ProtectedRegion region, String input);
|
||||||
// Players set by UUID or name depending on implementation
|
|
||||||
|
/**
|
||||||
|
* Parse a member(s) string and set the players as member of the WorldGuard region (set by UUID or name depending on implementation)
|
||||||
|
* @param region The WorldGuard region to set the members of
|
||||||
|
* @param input The member(s) string to parse and set
|
||||||
|
*/
|
||||||
public abstract void setMembers(ProtectedRegion region, String input);
|
public abstract void setMembers(ProtectedRegion region, String input);
|
||||||
// Looping through the ApplicableRegionSet from WorldGuard is different per implementation
|
|
||||||
|
/**
|
||||||
|
* Get a set of ProtectedRegion's that are present on a certain location
|
||||||
|
* @param location The location to check
|
||||||
|
* @return A set containing all regions present at that location
|
||||||
|
*/
|
||||||
public abstract Set<ProtectedRegion> getApplicableRegionsSet(Location location);
|
public abstract Set<ProtectedRegion> getApplicableRegionsSet(Location location);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if a player is a member of the WorldGuard region
|
||||||
|
* @param region The region to check
|
||||||
|
* @param player The player to check
|
||||||
|
* @return true if the player is a member of the region, otherwise false
|
||||||
|
*/
|
||||||
|
public abstract boolean containsMember(ProtectedRegion region, UUID player);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if a player is an owner of the WorldGuard region
|
||||||
|
* @param region The region to check
|
||||||
|
* @param player The player to check
|
||||||
|
* @return true if the player is an owner of the region, otherwise false
|
||||||
|
*/
|
||||||
|
public abstract boolean containsOwner(ProtectedRegion region, UUID player);
|
||||||
}
|
}
|
@ -105,4 +105,32 @@ public class WorldGuardHandler5 extends WorldGuardInterface {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean containsMember(ProtectedRegion region, UUID player) {
|
||||||
|
if(player == null) {
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
String name = Bukkit.getOfflinePlayer(player).getName();
|
||||||
|
if(name != null) {
|
||||||
|
return region.getMembers().contains(name);
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean containsOwner(ProtectedRegion region, UUID player) {
|
||||||
|
if(player == null) {
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
String name = Bukkit.getOfflinePlayer(player).getName();
|
||||||
|
if(name != null) {
|
||||||
|
return region.getOwners().contains(name);
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -99,4 +99,14 @@ public class WorldGuardHandler6 extends WorldGuardInterface {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean containsMember(ProtectedRegion region, UUID player) {
|
||||||
|
return region.getMembers().contains(player);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean containsOwner(ProtectedRegion region, UUID player) {
|
||||||
|
return region.getOwners().contains(player);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user