Cleans up permissions a lot and adds missing permissions to plugin.yml
Removes the checking of both parent and child by adding the child permissions to plugin.yml Cleans comments in the PermissionHelper class Renames hasPermDeep to hasPermissionImplicit as I finally understand how it's supposed to work Adds missing unmock() to prevent test errors Adds a ton of permissions which were mentioned in the code, but did not exist in the plugin.yml
This commit is contained in:
parent
3fc0e6963a
commit
544384f69b
@ -119,7 +119,7 @@ public class Stargate extends JavaPlugin {
|
||||
* @param message <p>A message describing what happened</p>
|
||||
*/
|
||||
public static void debug(String route, String message) {
|
||||
if (Stargate.stargateConfig.isDebuggingEnabled()) {
|
||||
if (stargateConfig == null || stargateConfig.isDebuggingEnabled()) {
|
||||
logger.info("[Stargate::" + route + "] " + message);
|
||||
} else {
|
||||
logger.log(Level.FINEST, "[Stargate::" + route + "] " + message);
|
||||
@ -132,7 +132,7 @@ public class Stargate extends JavaPlugin {
|
||||
* @param message <p>The message to log</p>
|
||||
*/
|
||||
public static void logInfo(String message) {
|
||||
logger.info(Stargate.getBackupString("prefix") + message);
|
||||
logger.info(getBackupString("prefix") + message);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -160,7 +160,7 @@ public class Stargate extends JavaPlugin {
|
||||
* @param message <p>The message to log</p>
|
||||
*/
|
||||
private static void log(Level severity, String message) {
|
||||
logger.log(severity, Stargate.getBackupString("prefix") + message);
|
||||
logger.log(severity, getBackupString("prefix") + message);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -280,8 +280,8 @@ public class Stargate extends JavaPlugin {
|
||||
pluginManager = getServer().getPluginManager();
|
||||
FileConfiguration newConfig = this.getConfig();
|
||||
logger = Logger.getLogger("Minecraft");
|
||||
Stargate.server = getServer();
|
||||
Stargate.stargate = this;
|
||||
server = getServer();
|
||||
stargate = this;
|
||||
|
||||
stargateConfig = new StargateConfig(logger);
|
||||
stargateConfig.finishSetup();
|
||||
|
@ -292,8 +292,7 @@ public final class EconomyConfig {
|
||||
return 0;
|
||||
}
|
||||
//Player gets free gate use
|
||||
if (PermissionHelper.hasPermission(player, "stargate.free") ||
|
||||
PermissionHelper.hasPermission(player, "stargate.free.use")) {
|
||||
if (PermissionHelper.hasPermission(player, "stargate.free.use")) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -353,8 +352,7 @@ public final class EconomyConfig {
|
||||
* @return <p></p>
|
||||
*/
|
||||
private boolean isFree(Player player, String permissionNode) {
|
||||
return !useEconomy() || PermissionHelper.hasPermission(player, "stargate.free") ||
|
||||
PermissionHelper.hasPermission(player, "stargate.free." + permissionNode);
|
||||
return !useEconomy() || PermissionHelper.hasPermission(player, "stargate.free." + permissionNode);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -185,7 +185,6 @@ public class BlockEventListener implements Listener {
|
||||
Block block = event.getBlock();
|
||||
Portal portal = null;
|
||||
|
||||
// Handle keeping portal material and buttons around
|
||||
if (block.getType() == Material.NETHER_PORTAL) {
|
||||
portal = PortalHandler.getByEntrance(block);
|
||||
} else if (MaterialHelper.isButtonCompatible(block.getType())) {
|
||||
|
@ -235,7 +235,7 @@ public class PlayerEventListener implements Listener {
|
||||
private boolean cannotAccessPortal(Player player, Portal portal) {
|
||||
boolean deny = PermissionHelper.cannotAccessNetwork(player, portal.getNetwork());
|
||||
|
||||
if (PermissionHelper.cannotAccessPortal(player, portal, deny)) {
|
||||
if (PermissionHelper.portalAccessDenied(player, portal, deny)) {
|
||||
Stargate.getMessageSender().sendErrorMessage(player, Stargate.getString("denyMsg"));
|
||||
return true;
|
||||
}
|
||||
@ -255,7 +255,6 @@ public class PlayerEventListener implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
// Implement right-click to toggle a stargate, gets around spawn protection problem.
|
||||
if (MaterialHelper.isButtonCompatible(block.getType())) {
|
||||
//Prevent a double click caused by a Spigot bug
|
||||
if (clickIsBug(event, block)) {
|
||||
@ -267,7 +266,7 @@ public class PlayerEventListener implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
// Cancel item use
|
||||
//Prevent the held item from being placed
|
||||
event.setUseItemInHand(Event.Result.DENY);
|
||||
event.setUseInteractedBlock(Event.Result.DENY);
|
||||
|
||||
|
@ -14,8 +14,9 @@ public final class EntityHelper {
|
||||
/**
|
||||
* Gets the max size of an entity along its x and z axis
|
||||
*
|
||||
* <p>This function gets the ceiling of the max size of an entity, thus calculating the smallest square needed to
|
||||
* contain the entity.</p>
|
||||
* <p>This function gets the ceiling of the max size of an entity, thus calculating the smallest box, using whole
|
||||
* blocks as unit, needed to contain the entity. Assuming n is returned, an (n x n) box is needed to contain the
|
||||
* entity.</p>
|
||||
*
|
||||
* @param entity <p>The entity to get max size for</p>
|
||||
* @return <p>The max size of the entity</p>
|
||||
|
@ -25,10 +25,13 @@ public final class FileHelper {
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a buffered reader from a string pointing to a file
|
||||
* Gets an input stream from a string pointing to an internal file
|
||||
*
|
||||
* <p>This is used for getting an input stream for reading a file contained within the compiled .jar file. The file
|
||||
* should be in the resources directory, and the file path should start with a forward slash ("/") character.</p>
|
||||
*
|
||||
* @param file <p>The file to read</p>
|
||||
* @return <p>A buffered reader reading the file</p>
|
||||
* @return <p>An input stream for the file</p>
|
||||
*/
|
||||
public static InputStream getInputStreamForInternalFile(String file) {
|
||||
return FileHelper.class.getResourceAsStream(file);
|
||||
@ -47,10 +50,10 @@ public final class FileHelper {
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a buffered reader from an input stream
|
||||
* Gets a buffered reader given an input stream
|
||||
*
|
||||
* @param inputStream <p>The input stream to read</p>
|
||||
* @return <p>A buffered reader reading the stream</p>
|
||||
* @return <p>A buffered reader reading the input stream</p>
|
||||
*/
|
||||
public static BufferedReader getBufferedReaderFromInputStream(InputStream inputStream) {
|
||||
InputStreamReader inputStreamReader = new InputStreamReader(inputStream, StandardCharsets.UTF_8);
|
||||
@ -71,20 +74,19 @@ public final class FileHelper {
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads key value pairs from an input stream
|
||||
* Reads key/value pairs from an input stream
|
||||
*
|
||||
* @param bufferedReader <p>The buffered reader to read</p>
|
||||
* @return <p>A map containing the read pairs</p>
|
||||
* @throws IOException <p>If unable to read from the stream</p>
|
||||
*/
|
||||
public static Map<String, String> readKeyValuePairs(BufferedReader bufferedReader) throws IOException {
|
||||
|
||||
Map<String, String> readPairs = new HashMap<>();
|
||||
|
||||
String line = bufferedReader.readLine();
|
||||
boolean firstLine = true;
|
||||
while (line != null) {
|
||||
// Strip UTF BOM
|
||||
//Strip UTF BOM from the first line
|
||||
if (firstLine) {
|
||||
line = removeUTF8BOM(line);
|
||||
firstLine = false;
|
||||
|
@ -26,34 +26,29 @@ public final class PermissionHelper {
|
||||
public static void openPortal(Player player, Portal portal) {
|
||||
Portal destination = portal.getPortalActivator().getDestination();
|
||||
|
||||
//Always-open portal -- Do nothing
|
||||
if (portal.getOptions().isAlwaysOn()) {
|
||||
//For an always open portal, no action is necessary
|
||||
if (portal.getOptions().isAlwaysOn() || portal.getOptions().isRandom() || portal.getOptions().isBungee()) {
|
||||
return;
|
||||
}
|
||||
|
||||
//Random portal -- Do nothing
|
||||
if (portal.getOptions().isRandom()) {
|
||||
return;
|
||||
}
|
||||
|
||||
//Invalid destination
|
||||
if ((destination == null) || (destination == portal)) {
|
||||
//Destination is invalid or the same portal. Send an error message
|
||||
if (destination == null || destination == portal) {
|
||||
Stargate.getMessageSender().sendErrorMessage(player, Stargate.getString("invalidMsg"));
|
||||
return;
|
||||
}
|
||||
|
||||
//Portal is already open
|
||||
if (portal.isOpen()) {
|
||||
//Close if this player opened the portal
|
||||
//Close the portal if this player opened the portal
|
||||
if (portal.getActivePlayer() == player) {
|
||||
portal.getPortalOpener().closePortal(false);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
//Portal is used by another player -- Deny access
|
||||
if ((!portal.getOptions().isFixed()) && portal.getPortalActivator().isActive() &&
|
||||
(portal.getActivePlayer() != player)) {
|
||||
//Deny access if another player has activated the portal, and it's still in use
|
||||
if (!portal.getOptions().isFixed() && portal.getPortalActivator().isActive() &&
|
||||
portal.getActivePlayer() != player) {
|
||||
Stargate.getMessageSender().sendErrorMessage(player, Stargate.getString("denyMsg"));
|
||||
return;
|
||||
}
|
||||
@ -64,27 +59,27 @@ public final class PermissionHelper {
|
||||
return;
|
||||
}
|
||||
|
||||
//Destination blocked
|
||||
if ((destination.isOpen()) && (!destination.getOptions().isAlwaysOn())) {
|
||||
//Destination is currently in use by another player, blocking teleportation
|
||||
if (destination.isOpen() && !destination.getOptions().isAlwaysOn()) {
|
||||
Stargate.getMessageSender().sendErrorMessage(player, Stargate.getString("blockMsg"));
|
||||
return;
|
||||
}
|
||||
|
||||
//Open gate
|
||||
//Open the portal
|
||||
portal.getPortalOpener().openPortal(player, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a StargateAccessPortal and gives the result
|
||||
* Creates a StargateAccessEvent and gets the updated deny value
|
||||
*
|
||||
* <p>The event is used for other plugins to bypass the permission checks</p>
|
||||
* <p>The event is used for other plugins to bypass the permission checks.</p>
|
||||
*
|
||||
* @param player <p>The player trying to use the portal</p>
|
||||
* @param portal <p>The portal the player is trying to use</p>
|
||||
* @param deny <p>Whether the player's access has already been denied by a check</p>
|
||||
* @param deny <p>Whether the player's access has already been denied by a previous check</p>
|
||||
* @return <p>False if the player should be allowed through the portal</p>
|
||||
*/
|
||||
public static boolean cannotAccessPortal(Player player, Portal portal, boolean deny) {
|
||||
public static boolean portalAccessDenied(Player player, Portal portal, boolean deny) {
|
||||
StargateAccessEvent event = new StargateAccessEvent(player, portal, deny);
|
||||
Stargate.server.getPluginManager().callEvent(event);
|
||||
return event.getDeny();
|
||||
@ -95,25 +90,29 @@ public final class PermissionHelper {
|
||||
*
|
||||
* @param player <p>The player to check</p>
|
||||
* @param entrancePortal <p>The portal the user wants to enter</p>
|
||||
* @param destination <p>The portal the user wants to exit</p>
|
||||
* @param destination <p>The portal the user wants to exit from</p>
|
||||
* @return <p>False if the user is allowed to access the portal</p>
|
||||
*/
|
||||
public static boolean cannotAccessPortal(Player player, Portal entrancePortal, Portal destination) {
|
||||
boolean deny = false;
|
||||
// Check if player has access to this server for Bungee gates
|
||||
if (entrancePortal.getOptions().isBungee() && !PermissionHelper.canAccessServer(player,
|
||||
entrancePortal.getNetwork())) {
|
||||
Stargate.debug("cannotAccessPortal", "Cannot access server");
|
||||
deny = true;
|
||||
|
||||
if (entrancePortal.getOptions().isBungee()) {
|
||||
if (!PermissionHelper.canAccessServer(player, entrancePortal.getNetwork())) {
|
||||
//If the portal is a bungee portal, and the player cannot access the server, deny
|
||||
Stargate.debug("cannotAccessPortal", "Cannot access server");
|
||||
deny = true;
|
||||
}
|
||||
} else if (PermissionHelper.cannotAccessNetwork(player, entrancePortal.getNetwork())) {
|
||||
//If the player does not have access to the network, deny
|
||||
Stargate.debug("cannotAccessPortal", "Cannot access network");
|
||||
deny = true;
|
||||
} else if (!entrancePortal.getOptions().isBungee() && PermissionHelper.cannotAccessWorld(player,
|
||||
destination.getWorld().getName())) {
|
||||
} else if (PermissionHelper.cannotAccessWorld(player, destination.getWorld().getName())) {
|
||||
//If the player does not have access to the portal's world, deny
|
||||
Stargate.debug("cannotAccessPortal", "Cannot access world");
|
||||
deny = true;
|
||||
}
|
||||
return cannotAccessPortal(player, entrancePortal, deny);
|
||||
//Allow other plugins to override whether the player can access the portal
|
||||
return portalAccessDenied(player, entrancePortal, deny);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -127,31 +126,32 @@ public final class PermissionHelper {
|
||||
*/
|
||||
public static boolean hasPermission(Player player, String permission) {
|
||||
if (Stargate.getStargateConfig().isPermissionDebuggingEnabled()) {
|
||||
Stargate.debug("hasPerm::SuperPerm(" + player.getName() + ")", permission + " => " +
|
||||
Stargate.debug("hasPerm::Permission(" + player.getName() + ")", permission + " => " +
|
||||
player.hasPermission(permission));
|
||||
}
|
||||
return player.hasPermission(permission);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check a deep permission, this will check to see if the permissions is defined for this use
|
||||
* Check if a player has been given a permission implicitly
|
||||
*
|
||||
* <p>If using Permissions it will return the same as hasPerm. If using SuperPerms will return true if the node
|
||||
* isn't defined, or the value of the node if it is</p>
|
||||
* <p>This should be run if a player has a parent permission to check for the child permission. It is assumed the
|
||||
* player has the child permission unless it's explicitly set to false.</p>
|
||||
*
|
||||
* @param player <p>The player to check</p>
|
||||
* @param permission <p>The permission to check</p>
|
||||
* @return <p>True if the player has the permission or it is not set</p>
|
||||
* @return <p>True if the player has the permission implicitly or explicitly</p>
|
||||
*/
|
||||
public static boolean hasPermDeep(Player player, String permission) {
|
||||
public static boolean hasPermissionImplicit(Player player, String permission) {
|
||||
if (!player.isPermissionSet(permission)) {
|
||||
if (Stargate.getStargateConfig().isPermissionDebuggingEnabled()) {
|
||||
Stargate.debug("hasPermDeep::SuperPerm", permission + " => true");
|
||||
Stargate.debug("hasPermissionImplicit::Permission", permission + " => implicitly true");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (Stargate.getStargateConfig().isPermissionDebuggingEnabled()) {
|
||||
Stargate.debug("hasPermDeep::SuperPerms", permission + " => " + player.hasPermission(permission));
|
||||
Stargate.debug("hasPermissionImplicit::Permission", permission + " => " +
|
||||
player.hasPermission(permission));
|
||||
}
|
||||
return player.hasPermission(permission);
|
||||
}
|
||||
@ -164,12 +164,12 @@ public final class PermissionHelper {
|
||||
* @return <p>False if the player should be allowed to access the world</p>
|
||||
*/
|
||||
public static boolean cannotAccessWorld(Player player, String world) {
|
||||
// Can use all stargate player features or access all worlds
|
||||
if (hasPermission(player, "stargate.use") || hasPermission(player, "stargate.world")) {
|
||||
// Do a deep check to see if the player lacks this specific world node
|
||||
return !hasPermDeep(player, "stargate.world." + world);
|
||||
//The player can access all worlds
|
||||
if (hasPermission(player, "stargate.world")) {
|
||||
//Check if the world permission has been explicitly denied
|
||||
return !hasPermissionImplicit(player, "stargate.world." + world);
|
||||
}
|
||||
// Can access dest world
|
||||
//The player can access the destination world
|
||||
return !hasPermission(player, "stargate.world." + world);
|
||||
}
|
||||
|
||||
@ -181,10 +181,10 @@ public final class PermissionHelper {
|
||||
* @return <p>True if the player is denied from accessing the network</p>
|
||||
*/
|
||||
public static boolean cannotAccessNetwork(Player player, String network) {
|
||||
// Can user all stargate player features, or access all networks
|
||||
if (hasPermission(player, "stargate.use") || hasPermission(player, "stargate.network")) {
|
||||
// Do a deep check to see if the player lacks this specific network node
|
||||
return !hasPermDeep(player, "stargate.network." + network);
|
||||
//The player can access all networks
|
||||
if (hasPermission(player, "stargate.network")) {
|
||||
//Check if the world permission has been explicitly denied
|
||||
return !hasPermissionImplicit(player, "stargate.network." + network);
|
||||
}
|
||||
//Check if the player can access this network
|
||||
if (hasPermission(player, "stargate.network." + network)) {
|
||||
@ -206,12 +206,12 @@ public final class PermissionHelper {
|
||||
* @return <p>True if the player is allowed to access the given server</p>
|
||||
*/
|
||||
public static boolean canAccessServer(Player player, String server) {
|
||||
//Can user all stargate player features, or access all servers
|
||||
if (hasPermission(player, "stargate.use") || hasPermission(player, "stargate.servers")) {
|
||||
//Do a deep check to see if the player lacks this specific server node
|
||||
return hasPermDeep(player, "stargate.server." + server);
|
||||
//The player can access all servers
|
||||
if (hasPermission(player, "stargate.server")) {
|
||||
//Check if the server permission has been explicitly denied
|
||||
return hasPermissionImplicit(player, "stargate.server." + server);
|
||||
}
|
||||
//Can access this server
|
||||
//The player can access the destination server
|
||||
return hasPermission(player, "stargate.server." + server);
|
||||
}
|
||||
|
||||
@ -224,15 +224,15 @@ public final class PermissionHelper {
|
||||
* @return <p>True if the player can travel for free</p>
|
||||
*/
|
||||
public static boolean isFree(Player player, Portal src, Portal dest) {
|
||||
// This gate is free
|
||||
//This portal is free
|
||||
if (src.getOptions().isFree()) {
|
||||
return true;
|
||||
}
|
||||
// Player gets free use
|
||||
if (hasPermission(player, "stargate.free") || hasPermission(player, "stargate.free.use")) {
|
||||
//Player can use this portal for free
|
||||
if (hasPermission(player, "stargate.free.use")) {
|
||||
return true;
|
||||
}
|
||||
// Don't charge for free destination gates
|
||||
//Don't charge for free destinations unless specified in the config
|
||||
return dest != null && !Stargate.getEconomyConfig().chargeFreeDestination() && dest.getOptions().isFree();
|
||||
}
|
||||
|
||||
@ -246,15 +246,15 @@ public final class PermissionHelper {
|
||||
* @return <p>True if the given player can see the given portal</p>
|
||||
*/
|
||||
public static boolean canSeePortal(Player player, Portal portal) {
|
||||
// The gate is not hidden
|
||||
//The portal is not hidden
|
||||
if (!portal.getOptions().isHidden()) {
|
||||
return true;
|
||||
}
|
||||
// The player is an admin with the ability to see hidden gates
|
||||
if (hasPermission(player, "stargate.admin") || hasPermission(player, "stargate.admin.hidden")) {
|
||||
//The player can see all hidden portals
|
||||
if (hasPermission(player, "stargate.admin.hidden")) {
|
||||
return true;
|
||||
}
|
||||
// The player is the owner of the gate
|
||||
//The player is the owner of the portal
|
||||
return portal.isOwner(player);
|
||||
}
|
||||
|
||||
@ -271,7 +271,7 @@ public final class PermissionHelper {
|
||||
return true;
|
||||
}
|
||||
//The player is an admin with the ability to use private gates
|
||||
return hasPermission(player, "stargate.admin") || hasPermission(player, "stargate.admin.private");
|
||||
return hasPermission(player, "stargate.admin.private");
|
||||
}
|
||||
|
||||
/**
|
||||
@ -282,11 +282,6 @@ public final class PermissionHelper {
|
||||
* @return <p>True if the player is allowed to create a portal with the given option</p>
|
||||
*/
|
||||
public static boolean canUseOption(Player player, PortalOption option) {
|
||||
//Check if the player can use all options
|
||||
if (hasPermission(player, "stargate.option") || option == PortalOption.BUNGEE) {
|
||||
return true;
|
||||
}
|
||||
//Check if they can use this specific option
|
||||
return hasPermission(player, option.getPermissionString());
|
||||
}
|
||||
|
||||
@ -298,16 +293,12 @@ public final class PermissionHelper {
|
||||
* @return <p>True if the player is allowed to create the new gate</p>
|
||||
*/
|
||||
public static boolean canCreateNetworkGate(Player player, String network) {
|
||||
//Check for general create
|
||||
if (hasPermission(player, "stargate.create")) {
|
||||
return true;
|
||||
}
|
||||
//Check for all network create permission
|
||||
//Check if the player is allowed to create a portal on any network
|
||||
if (hasPermission(player, "stargate.create.network")) {
|
||||
// Do a deep check to see if the player lacks this specific network node
|
||||
return hasPermDeep(player, "stargate.create.network." + network);
|
||||
//Check if the network has been explicitly denied
|
||||
return hasPermissionImplicit(player, "stargate.create.network." + network);
|
||||
}
|
||||
//Check for this specific network
|
||||
//Check if the player is allowed to create on this specific network
|
||||
return hasPermission(player, "stargate.create.network." + network);
|
||||
}
|
||||
|
||||
@ -318,11 +309,6 @@ public final class PermissionHelper {
|
||||
* @return <p>True if the player is allowed</p>
|
||||
*/
|
||||
public static boolean canCreatePersonalPortal(Player player) {
|
||||
//Check for general create
|
||||
if (hasPermission(player, "stargate.create")) {
|
||||
return true;
|
||||
}
|
||||
//Check for personal
|
||||
return hasPermission(player, "stargate.create.personal");
|
||||
}
|
||||
|
||||
@ -334,16 +320,12 @@ public final class PermissionHelper {
|
||||
* @return <p>True if the player is allowed to create a portal with the given gate layout</p>
|
||||
*/
|
||||
public static boolean canCreatePortal(Player player, String gate) {
|
||||
//Check for general create
|
||||
if (hasPermission(player, "stargate.create")) {
|
||||
return true;
|
||||
}
|
||||
//Check for all gate create permissions
|
||||
//Check if the player is allowed to create all gates
|
||||
if (hasPermission(player, "stargate.create.gate")) {
|
||||
// Do a deep check to see if the player lacks this specific gate node
|
||||
return hasPermDeep(player, "stargate.create.gate." + gate);
|
||||
//Check if the gate type has been explicitly denied
|
||||
return hasPermissionImplicit(player, "stargate.create.gate." + gate);
|
||||
}
|
||||
//Check for this specific gate
|
||||
//Check if the player can create the specific gate type
|
||||
return hasPermission(player, "stargate.create.gate." + gate);
|
||||
}
|
||||
|
||||
@ -356,20 +338,22 @@ public final class PermissionHelper {
|
||||
*/
|
||||
public static boolean canDestroyPortal(Player player, Portal portal) {
|
||||
String network = portal.getNetwork();
|
||||
//Check for general destroy
|
||||
if (hasPermission(player, "stargate.destroy")) {
|
||||
return true;
|
||||
|
||||
//Use a special check for bungee portals
|
||||
if (portal.getOptions().isBungee()) {
|
||||
return hasPermission(player, "stargate.admin.bungee");
|
||||
}
|
||||
//Check for all network destroy permission
|
||||
|
||||
//Check if the player is allowed to destroy on all networks
|
||||
if (hasPermission(player, "stargate.destroy.network")) {
|
||||
//Do a deep check to see if the player lacks permission for this network node
|
||||
return hasPermDeep(player, "stargate.destroy.network." + network);
|
||||
//Check if the network has been explicitly denied
|
||||
return hasPermissionImplicit(player, "stargate.destroy.network." + network);
|
||||
}
|
||||
//Check for this specific network
|
||||
//Check if the player is allowed to destroy on the network
|
||||
if (hasPermission(player, "stargate.destroy.network." + network)) {
|
||||
return true;
|
||||
}
|
||||
//Check for personal gate
|
||||
//Check if personal portal and if the player is allowed to destroy it
|
||||
return portal.isOwner(player) && hasPermission(player, "stargate.destroy.personal");
|
||||
}
|
||||
|
||||
@ -383,12 +367,12 @@ public final class PermissionHelper {
|
||||
* @return <p>True if the player cannot teleport. False otherwise</p>
|
||||
*/
|
||||
public static boolean playerCannotTeleport(Portal entrancePortal, Portal destination, Player player, PlayerMoveEvent event) {
|
||||
// No portal or not open
|
||||
//No portal or not open
|
||||
if (entrancePortal == null || !entrancePortal.isOpen()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Not open for this player
|
||||
//Not open for this player
|
||||
if (!entrancePortal.getPortalOpener().isOpenFor(player)) {
|
||||
Stargate.getMessageSender().sendErrorMessage(player, Stargate.getString("denyMsg"));
|
||||
new PlayerTeleporter(entrancePortal, player).teleport(entrancePortal, event);
|
||||
|
@ -15,7 +15,120 @@ commands:
|
||||
usage: /<command> <reload/about> - Used to see stargate info or reload the plugin
|
||||
permissions:
|
||||
stargate.*:
|
||||
description: Wildcard permission
|
||||
description: Wildcard permission. Same as stargate.admin
|
||||
default: op
|
||||
children:
|
||||
stargate.admin: true
|
||||
stargate.reload:
|
||||
description: Allows reloading the plugin
|
||||
default: false
|
||||
stargate.use:
|
||||
description: Allow use of all stargates linking to any world in any network
|
||||
default: true
|
||||
children:
|
||||
stargate.world: true
|
||||
stargate.network: true
|
||||
stargate.server: true
|
||||
stargate.world:
|
||||
description: Allow use of stargates in any world
|
||||
default: false
|
||||
stargate.network:
|
||||
description: Allows use of stargates in any network
|
||||
default: false
|
||||
stargate.create:
|
||||
description: Allow creating gates on any network
|
||||
default: op
|
||||
children:
|
||||
stargate.create.personal: true
|
||||
stargate.create.network: true
|
||||
stargate.create.gate: true
|
||||
stargate.create.personal:
|
||||
description: Allows the creation of a personal stargate if a player is missing permission for the given network
|
||||
default: false
|
||||
stargate.create.network:
|
||||
description: Allows the creation of a stargate on any network
|
||||
default: false
|
||||
stargate.create.gate:
|
||||
description: Allows the creation of a stargate using any gate type
|
||||
default: false
|
||||
stargate.destroy:
|
||||
description: Allows the destruction of all stargates
|
||||
default: op
|
||||
children:
|
||||
stargate.destroy.network: true
|
||||
stargate.destroy.personal: true
|
||||
stargate.destroy.network:
|
||||
description: Allows the destruction of stargates on any network
|
||||
default: false
|
||||
stargate.destroy.personal:
|
||||
description: Allows the destruction of any personal stargates the player has created
|
||||
default: false
|
||||
stargate.free:
|
||||
description: Allow free use/creation/destruction of stargates
|
||||
default: op
|
||||
children:
|
||||
stargate.free.use: true
|
||||
stargate.free.create: true
|
||||
stargate.free.destroy: true
|
||||
stargate.free.use:
|
||||
description: Allows free usage of all stargates
|
||||
default: false
|
||||
stargate.free.create:
|
||||
description: Allows creating stargates for free
|
||||
default: false
|
||||
stargate.free.destroy:
|
||||
description: Allows destroying stargates for free
|
||||
default: false
|
||||
stargate.option:
|
||||
description: Allows use of all options
|
||||
default: op
|
||||
children:
|
||||
stargate.option.hidden: true
|
||||
stargate.option.alwayson: true
|
||||
stargate.option.private: true
|
||||
stargate.option.free: true
|
||||
stargate.option.backwards: true
|
||||
stargate.option.show: true
|
||||
stargate.option.nonetwork: true
|
||||
stargate.option.random: true
|
||||
stargate.option.hidden:
|
||||
description: Allows the creation of a hidden stargate
|
||||
default: false
|
||||
stargate.option.alwayson:
|
||||
description: Allows the creation of an always open stargate
|
||||
default: false
|
||||
stargate.option.private:
|
||||
description: Allows the creation of a private stargate
|
||||
default: false
|
||||
stargate.option.free:
|
||||
description: Allows the creation of a stargate which is free regardless of any set prices
|
||||
default: false
|
||||
stargate.option.backwards:
|
||||
description: Allows the creation of a stargate where players will exit through the back
|
||||
default: false
|
||||
stargate.option.show:
|
||||
description: Allows the creation of a stargate which is shown on the network, even if always on
|
||||
default: false
|
||||
stargate.option.nonetwork:
|
||||
description: Allows the creation of a stargate with a hidden network name
|
||||
default: false
|
||||
stargate.option.random:
|
||||
description: Allows the creation of a stargate with a random destination
|
||||
default: false
|
||||
stargate.admin.hidden:
|
||||
description: Allows this player to see all hidden stargates
|
||||
default: false
|
||||
stargate.admin.private:
|
||||
description: Allows this player to use all private stargates
|
||||
default: false
|
||||
stargate.admin.bungee:
|
||||
description: Allows the creation and destruction of a stargate between BungeeCord servers
|
||||
default: false
|
||||
stargate.server:
|
||||
description: Allows the creation of a BungeeCord stargate going to any server
|
||||
default: false
|
||||
stargate.admin:
|
||||
description: Allow all features and admin commands
|
||||
default: op
|
||||
children:
|
||||
stargate.use: true
|
||||
@ -25,26 +138,7 @@ permissions:
|
||||
stargate.option: true
|
||||
stargate.admin: true
|
||||
stargate.reload: true
|
||||
stargate.reload:
|
||||
description: Allows reloading the plugin
|
||||
default: false
|
||||
stargate.use:
|
||||
description: Allow use of all gates linking to any world in any network
|
||||
default: true
|
||||
stargate.create:
|
||||
description: Allow creating gates on any network
|
||||
default: op
|
||||
stargate.destroy:
|
||||
description: Allow destruction gates on any network
|
||||
default: op
|
||||
stargate.free:
|
||||
description: Allow free use/creation/destruction of gates
|
||||
default: op
|
||||
stargate.option:
|
||||
description: Allow use of all options
|
||||
default: op
|
||||
stargate.admin:
|
||||
description: Allow all admin features (Hidden/Private only so far)
|
||||
default: op
|
||||
children:
|
||||
stargate.reload: true
|
||||
stargate.admin.hidden: true
|
||||
stargate.admin.private: true
|
||||
stargate.admin.bungee: true
|
||||
stargate.server: true
|
@ -6,6 +6,7 @@ import be.seeseemelk.mockbukkit.WorldMock;
|
||||
import net.knarcraft.stargate.Stargate;
|
||||
import net.knarcraft.stargate.container.RelativeBlockVector;
|
||||
import org.bukkit.Material;
|
||||
import org.junit.jupiter.api.AfterAll;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
@ -27,6 +28,11 @@ public class GateLayoutTest {
|
||||
layout = GateHandler.getGateByName("nethergate.gate").getLayout();
|
||||
}
|
||||
|
||||
@AfterAll
|
||||
public static void tearDown() {
|
||||
MockBukkit.unmock();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void gateLayoutExitTest() {
|
||||
assertEquals(new RelativeBlockVector(1, 3, 0), layout.getExit());
|
||||
|
@ -2,6 +2,7 @@ package net.knarcraft.stargate.utility;
|
||||
|
||||
import be.seeseemelk.mockbukkit.MockBukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.junit.jupiter.api.AfterAll;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Test;
|
||||
@ -13,6 +14,11 @@ public class MaterialHelperTest {
|
||||
MockBukkit.mock();
|
||||
}
|
||||
|
||||
@AfterAll
|
||||
public static void tearDown() {
|
||||
MockBukkit.unmock();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isWallCoralTest() {
|
||||
Assertions.assertTrue(MaterialHelper.isWallCoral(Material.DEAD_BRAIN_CORAL_WALL_FAN));
|
||||
|
Loading…
x
Reference in New Issue
Block a user