Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Major permissions overhaul to use the MyHome setup

  • Loading branch information...
commit 8a1529761deb0f8824dfd89e9b00f082b63f7001 1 parent 5376bc5
@spathizilla authored
Showing with 480 additions and 147 deletions.
  1. +10 −5 pom.xml
  2. +2 −0  src/main/java/me/taylorkelly/mywarp/MWBlockListener.java
  3. +2 −0  src/main/java/me/taylorkelly/mywarp/MWPlayerListener.java
  4. +2 −1  src/main/java/me/taylorkelly/mywarp/MyWarp.java
  5. +2 −0  src/main/java/me/taylorkelly/mywarp/Warp.java
  6. +2 −0  src/main/java/me/taylorkelly/mywarp/WarpList.java
  7. +0 −140 src/main/java/me/taylorkelly/mywarp/WarpPermissions.java
  8. +4 −0 src/main/java/me/taylorkelly/mywarp/WarpSettings.java
  9. +23 −0 src/main/java/me/taylorkelly/mywarp/permissions/BPermissionsHandler.java
  10. +27 −0 src/main/java/me/taylorkelly/mywarp/permissions/GroupManagerHandler.java
  11. +8 −0 src/main/java/me/taylorkelly/mywarp/permissions/IPermissionsHandler.java
  12. +15 −0 src/main/java/me/taylorkelly/mywarp/permissions/NullHandler.java
  13. +27 −0 src/main/java/me/taylorkelly/mywarp/permissions/Permissions2Handler.java
  14. +27 −0 src/main/java/me/taylorkelly/mywarp/permissions/Permissions3Handler.java
  15. +26 −0 src/main/java/me/taylorkelly/mywarp/permissions/PermissionsExHandler.java
  16. +95 −0 src/main/java/me/taylorkelly/mywarp/permissions/PermissionsHandler.java
  17. +117 −0 src/main/java/me/taylorkelly/mywarp/permissions/SuperpermsHandler.java
  18. +90 −0 src/main/java/me/taylorkelly/mywarp/permissions/WarpPermissions.java
  19. +1 −1  src/main/resources/plugin.yml
View
15 pom.xml
@@ -3,17 +3,22 @@
<groupId>me.taylorkelly.mywarp</groupId>
<artifactId>MyWarp</artifactId>
<name>MyWarp</name>
- <version>2.0.1</version>
+ <version>2.1</version>
<url>http://www.bukkit.org</url>
<dependencies>
<dependency>
<groupId>org.bukkit</groupId>
<artifactId>bukkit</artifactId>
- <version>0.0.1-SNAPSHOT</version>
+ <version>1.1-R2-SNAPSHOT</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
<dependency>
+ <groupId>me.taylorkelly.help</groupId>
+ <artifactId>Help</artifactId>
+ <version>0.2</version>
+ </dependency>
+ <dependency>
<groupId>ru.tehkode.permissions.bukkit</groupId>
<artifactId>PermissionsEx</artifactId>
<version>1.14</version>
@@ -29,9 +34,9 @@
<version>[1.0-alpha-5],[1.1]</version>
</dependency>
<dependency>
- <groupId>me.taylorkelly.help</groupId>
- <artifactId>Help</artifactId>
- <version>0.2</version>
+ <groupId>de.bananaco.permissions.Permissions</groupId>
+ <artifactId>bPermissions</artifactId>
+ <version>1.7.9.9</version>
</dependency>
</dependencies>
<build>
View
2  src/main/java/me/taylorkelly/mywarp/MWBlockListener.java
@@ -1,5 +1,7 @@
package me.taylorkelly.mywarp;
+import me.taylorkelly.mywarp.permissions.WarpPermissions;
+
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import org.bukkit.event.block.BlockListener;
View
2  src/main/java/me/taylorkelly/mywarp/MWPlayerListener.java
@@ -1,5 +1,7 @@
package me.taylorkelly.mywarp;
+import me.taylorkelly.mywarp.permissions.WarpPermissions;
+
import org.bukkit.Location;
import org.bukkit.Server;
import org.bukkit.Chunk;
View
3  src/main/java/me/taylorkelly/mywarp/MyWarp.java
@@ -10,6 +10,7 @@
import java.util.logging.Logger;
import me.taylorkelly.mywarp.griefcraft.Updater;
+import me.taylorkelly.mywarp.permissions.WarpPermissions;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
@@ -56,7 +57,7 @@ public void onEnable() {
blockListener = new MWBlockListener(warpList);
playerListener = new MWPlayerListener(warpList);
- WarpPermissions.initialize(getServer());
+ WarpPermissions.initialize(this);
WarpHelp.initialize(this);
getServer().getPluginManager().registerEvent(Type.PLAYER_CHAT, playerListener, Priority.Monitor, this);
View
2  src/main/java/me/taylorkelly/mywarp/Warp.java
@@ -2,6 +2,8 @@
import java.util.ArrayList;
+import me.taylorkelly.mywarp.permissions.WarpPermissions;
+
import org.bukkit.*;
import org.bukkit.entity.Player;
View
2  src/main/java/me/taylorkelly/mywarp/WarpList.java
@@ -6,6 +6,8 @@
import java.util.HashMap;
import java.util.List;
+import me.taylorkelly.mywarp.permissions.WarpPermissions;
+
import org.bukkit.*;
import org.bukkit.entity.Player;
View
140 src/main/java/me/taylorkelly/mywarp/WarpPermissions.java
@@ -1,140 +0,0 @@
-package me.taylorkelly.mywarp;
-
-import ru.tehkode.permissions.bukkit.PermissionsEx;
-import com.nijikokun.bukkit.Permissions.Permissions;
-import org.anjocaido.groupmanager.GroupManager;
-
-import me.taylorkelly.mywarp.WarpLogger;
-
-import org.bukkit.Server;
-import org.bukkit.entity.Player;
-import org.bukkit.plugin.Plugin;
-
-public class WarpPermissions {
-
- private enum PermissionHandler {
- PERMISSIONSEX, PERMISSIONS, PERMISSIONS3, GROUPMANAGER, NONE
- }
- private static PermissionHandler handler;
- private static Plugin permissionPlugin;
-
- public static void initialize(Server server) {
- Plugin permissionsEx = server.getPluginManager().getPlugin("PermissionsEx");
- Plugin groupManager = server.getPluginManager().getPlugin("GroupManager");
- Plugin permissions = server.getPluginManager().getPlugin("Permissions");
-
- if (permissionsEx != null) {
- permissionPlugin = permissionsEx;
- handler = PermissionHandler.PERMISSIONSEX;
- String version = permissionsEx.getDescription().getVersion();
- WarpLogger.info("Permissions enabled using: PermissionsEx v" + version);
- } else if (groupManager != null) {
- permissionPlugin = groupManager;
- handler = PermissionHandler.GROUPMANAGER;
- String version = groupManager.getDescription().getVersion();
- WarpLogger.info("Permissions enabled using: GroupManager v" + version);
- } else if (permissions != null) {
- permissionPlugin = permissions;
- String version = permissions.getDescription().getVersion();
- if (version.contains("3.")) {
- handler = PermissionHandler.PERMISSIONS3;
- } else {
- handler = PermissionHandler.PERMISSIONS;
- }
- WarpLogger.info("Permissions enabled using: Permissions v" + version);
- } else {
- handler = PermissionHandler.NONE;
- WarpLogger.warning("A permission plugin isn't loaded.");
- }
- }
-
- public static boolean permission(Player player, String permission, boolean defaultPerm) {
- switch (handler) {
- case PERMISSIONSEX:
- return ((PermissionsEx) permissionPlugin).getPermissionManager().has(player, permission);
- case PERMISSIONS3:
- return ((Permissions) permissionPlugin).getHandler().has(player, permission);
- case PERMISSIONS:
- return ((Permissions) permissionPlugin).getHandler().has(player, permission);
- case GROUPMANAGER:
- return ((GroupManager) permissionPlugin).getWorldsHolder().getWorldPermissions(player).has(player, permission);
- case NONE:
- return defaultPerm;
- default:
- return defaultPerm;
- }
- }
-
-
- public static boolean isAdmin(Player player) {
- return permission(player, "mywarp.admin", player.isOp());
- }
-
- public static boolean warp(Player player) {
- return permission(player, "mywarp.warp.basic.warp", true);
- }
-
- public static boolean delete(Player player) {
- return permission(player, "mywarp.warp.basic.delete", true);
- }
-
- public static boolean list(Player player) {
- return permission(player, "mywarp.warp.basic.list", true);
- }
-
- public static boolean welcome(Player player) {
- return permission(player, "mywarp.warp.basic.welcome", true);
- }
-
- public static boolean search(Player player) {
- return permission(player, "mywarp.warp.basic.search", true);
- }
-
- public static boolean give(Player player) {
- return permission(player, "mywarp.warp.soc.give", true);
- }
-
- public static boolean invite(Player player) {
- return permission(player, "mywarp.warp.soc.invite", true);
- }
-
- public static boolean uninvite(Player player) {
- return permission(player, "mywarp.warp.soc.uninvite", true);
- }
-
- public static boolean canPublic(Player player) {
- return permission(player, "mywarp.warp.soc.public", true);
- }
-
- public static boolean canPrivate(Player player) {
- return permission(player, "mywarp.warp.soc.private", true);
- }
-
- public static boolean signWarp(Player player) {
- return permission(player, "mywarp.warp.sign.warp", true);
- }
-
- public static boolean privateCreate(Player player) {
- return permission(player, "mywarp.warp.basic.createprivate", true);
- }
-
- public static boolean publicCreate(Player player) {
- return permission(player, "mywarp.warp.basic.createpublic", true);
- }
-
- public static boolean compass(Player player) {
- return permission(player, "mywarp.warp.basic.compass", true);
- }
-
- public static int maxPrivateWarps(Player player) {
- return WarpSettings.maxPrivate;
- }
-
- public static int maxPublicWarps(Player player) {
- return WarpSettings.maxPublic;
- }
-
- static boolean createSignWarp(Player player) {
- return permission(player, "mywarp.warp.sign.create", true);
- }
-}
View
4 src/main/java/me/taylorkelly/mywarp/WarpSettings.java
@@ -18,6 +18,8 @@
public static String mySQLpass;
public static String mySQLconn;
+ public static boolean opPermissions;
+
public static void initialize(File dataFolder) {
if(!dataFolder.exists()) {
dataFolder.mkdirs();
@@ -38,6 +40,8 @@ public static void initialize(File dataFolder) {
mySQLuname = file.getString("mySQLuname", "root", "MySQL Username (only if using MySQL)");
mySQLpass = file.getString("mySQLpass", "password", "MySQL Password (only if using MySQL)");
+ opPermissions = file.getBoolean("opPermissions", true, "Enable OP permissions with SuperPerms");
+
file.save();
}
}
View
23 src/main/java/me/taylorkelly/mywarp/permissions/BPermissionsHandler.java
@@ -0,0 +1,23 @@
+package me.taylorkelly.mywarp.permissions;
+
+import org.bukkit.entity.Player;
+import de.bananaco.permissions.info.InfoReader;
+
+public class BPermissionsHandler implements IPermissionsHandler {
+ private final transient InfoReader info;
+
+ public BPermissionsHandler() {
+ info = new InfoReader();
+ info.instantiate();
+ }
+
+ @Override
+ public boolean hasPermission(final Player player, final String node, boolean defaultPerm) {
+ return player.hasPermission(node);
+ }
+
+ public int getInteger(final Player player, final String node, int defaultInt) {
+ int value = Integer.parseInt(info.getValue(player, node));
+ return value;
+ }
+}
View
27 src/main/java/me/taylorkelly/mywarp/permissions/GroupManagerHandler.java
@@ -0,0 +1,27 @@
+package me.taylorkelly.mywarp.permissions;
+
+import org.bukkit.entity.Player;
+import org.bukkit.plugin.Plugin;
+import org.anjocaido.groupmanager.GroupManager;
+import org.anjocaido.groupmanager.permissions.AnjoPermissionsHandler;
+
+public class GroupManagerHandler implements IPermissionsHandler {
+ private final transient GroupManager manager;
+
+ public GroupManagerHandler(final Plugin permissionsPlugin) {
+ manager = ((GroupManager)permissionsPlugin);
+ }
+
+ @Override
+ public boolean hasPermission(final Player player, final String node, final boolean defaultPerm) {
+ AnjoPermissionsHandler handler = manager.getWorldsHolder().getWorldPermissions(player);
+ return handler.has(player, node);
+ }
+
+ @Override
+ public int getInteger(final Player player, final String node, final int defaultInt) {
+ String playername = player.getName();
+ AnjoPermissionsHandler handler = manager.getWorldsHolder().getWorldPermissions(player);
+ return handler.getPermissionInteger(playername, node);
+ }
+}
View
8 src/main/java/me/taylorkelly/mywarp/permissions/IPermissionsHandler.java
@@ -0,0 +1,8 @@
+package me.taylorkelly.mywarp.permissions;
+
+import org.bukkit.entity.Player;
+
+public interface IPermissionsHandler {
+ boolean hasPermission(Player player, String node, boolean defaultPerm);
+ int getInteger(Player player, String node, int defaultInt);
+}
View
15 src/main/java/me/taylorkelly/mywarp/permissions/NullHandler.java
@@ -0,0 +1,15 @@
+package me.taylorkelly.mywarp.permissions;
+
+import org.bukkit.entity.Player;
+
+public class NullHandler implements IPermissionsHandler {
+
+ @Override
+ public boolean hasPermission(final Player player, final String node, boolean defaultPerm) {
+ return false;
+ }
+
+ public int getInteger(final Player player, final String node, int defaultInt) {
+ return defaultInt;
+ }
+}
View
27 src/main/java/me/taylorkelly/mywarp/permissions/Permissions2Handler.java
@@ -0,0 +1,27 @@
+package me.taylorkelly.mywarp.permissions;
+
+import org.bukkit.entity.Player;
+import com.nijiko.permissions.PermissionHandler;
+import com.nijikokun.bukkit.Permissions.Permissions;
+import org.bukkit.plugin.Plugin;
+
+public class Permissions2Handler implements IPermissionsHandler {
+ private final transient PermissionHandler handler;
+
+ public Permissions2Handler(final Plugin permissionsPlugin) {
+ handler = ((Permissions)permissionsPlugin).getHandler();
+ }
+
+ @Override
+ public boolean hasPermission(final Player player, final String node, boolean defaultPerm) {
+ return handler.permission(player, node);
+ }
+
+ @Override
+ public int getInteger(final Player player, final String node, final int defaultInt) {
+ String playername = player.getName();
+ String world = player.getWorld().getName();
+ return handler.getPermissionInteger(world, playername, node);
+ }
+}
+
View
27 src/main/java/me/taylorkelly/mywarp/permissions/Permissions3Handler.java
@@ -0,0 +1,27 @@
+package me.taylorkelly.mywarp.permissions;
+
+import org.bukkit.entity.Player;
+import com.nijiko.permissions.PermissionHandler;
+import com.nijikokun.bukkit.Permissions.Permissions;
+import org.bukkit.plugin.Plugin;
+
+public class Permissions3Handler implements IPermissionsHandler {
+ private final transient PermissionHandler handler;
+
+ public Permissions3Handler(final Plugin permissionsPlugin) {
+ handler = ((Permissions)permissionsPlugin).getHandler();
+ }
+
+ @Override
+ public boolean hasPermission(final Player player, final String node, boolean defaultPerm) {
+ return handler.has(player, node);
+ }
+
+ @Override
+ public int getInteger(final Player player, final String node, final int defaultInt) {
+ String playername = player.getName();
+ String world = player.getWorld().getName();
+ return handler.getPermissionInteger(world, playername, node);
+ }
+}
+
View
26 src/main/java/me/taylorkelly/mywarp/permissions/PermissionsExHandler.java
@@ -0,0 +1,26 @@
+package me.taylorkelly.mywarp.permissions;
+import org.bukkit.entity.Player;
+import ru.tehkode.permissions.PermissionManager;
+import ru.tehkode.permissions.bukkit.PermissionsEx;
+
+public class PermissionsExHandler implements IPermissionsHandler {
+ private final transient PermissionManager manager;
+
+ public PermissionsExHandler() {
+ manager = PermissionsEx.getPermissionManager();
+ }
+
+ @Override
+ public boolean hasPermission(final Player player, final String node, final boolean defaultPerm) {
+ String playername = player.getName();
+ String playerworld = player.getWorld().getName();
+ return manager.has(playername, node, playerworld);
+ }
+
+ @Override
+ public int getInteger(final Player player, final String node, final int defaultInt) {
+ String playername = player.getName();
+ String world = player.getWorld().getName();
+ return manager.getUser(playername).getOptionInteger(node, world, defaultInt);
+ }
+}
View
95 src/main/java/me/taylorkelly/mywarp/permissions/PermissionsHandler.java
@@ -0,0 +1,95 @@
+package me.taylorkelly.mywarp.permissions;
+
+import me.taylorkelly.mywarp.WarpLogger;
+
+import org.bukkit.entity.Player;
+import org.bukkit.plugin.Plugin;
+import org.bukkit.plugin.PluginManager;
+
+public class PermissionsHandler implements IPermissionsHandler {
+ private enum PermHandler {
+ PERMISSIONSEX, PERMISSIONS3, PERMISSIONS2, GROUPMANAGER, BPERMISSIONS, SUPERPERMS, NONE
+ }
+ private static PermHandler permplugin = PermHandler.NONE;
+ private transient IPermissionsHandler handler = new NullHandler();
+ private final transient Plugin plugin;
+
+ public PermissionsHandler(final Plugin plugin) {
+ this.plugin = plugin;
+ checkPermissions();
+ }
+
+ @Override
+ public boolean hasPermission(final Player player, final String node, boolean defaultPerm) {
+ return handler.hasPermission(player, node, defaultPerm);
+ }
+
+ @Override
+ public int getInteger(final Player player, final String node, int defaultInt) {
+ return handler.getInteger(player, node, defaultInt);
+ }
+
+ public void checkPermissions() {
+ final PluginManager pluginManager = plugin.getServer().getPluginManager();
+
+ final Plugin permExPlugin = pluginManager.getPlugin("PermissionsEx");
+ if (permExPlugin != null && permExPlugin.isEnabled()) {
+ if (!(handler instanceof PermissionsExHandler)) {
+ permplugin = PermHandler.PERMISSIONSEX;
+ String version = permExPlugin.getDescription().getVersion();
+ WarpLogger.info("Access Control: Using PermissionsEx v"+ version);
+ handler = new PermissionsExHandler();
+ }
+ return;
+ }
+
+ final Plugin bPermPlugin = pluginManager.getPlugin("bPermissions");
+ if (bPermPlugin != null && bPermPlugin.isEnabled()) {
+ if (!(handler instanceof BPermissionsHandler)) {
+ permplugin = PermHandler.BPERMISSIONS;
+ String version = bPermPlugin.getDescription().getVersion();
+ WarpLogger.info("Access Control: Using bPermissions"+ version);
+ handler = new BPermissionsHandler();
+ }
+ return;
+ }
+
+ final Plugin GMplugin = pluginManager.getPlugin("GroupManager");
+ if (GMplugin != null && GMplugin.isEnabled()) {
+ if (!(handler instanceof GroupManagerHandler)) {
+ permplugin = PermHandler.GROUPMANAGER;
+ String version = GMplugin.getDescription().getVersion();
+ WarpLogger.info("Access Control: Using GroupManager v"+ version);
+ handler = new GroupManagerHandler(GMplugin);
+ }
+ return;
+ }
+
+ final Plugin permPlugin = pluginManager.getPlugin("Permissions");
+ if (permPlugin != null && permPlugin.isEnabled()) {
+ if (permPlugin.getDescription().getVersion().charAt(0) == '3') {
+ if (!(handler instanceof Permissions3Handler)) {
+ permplugin = PermHandler.PERMISSIONS3;
+ String version = permPlugin.getDescription().getVersion();
+ WarpLogger.info("Access Control: Using Permissions v"+ version);
+ handler = new Permissions3Handler(permPlugin);
+ }
+ } else {
+ if (!(handler instanceof Permissions2Handler)) {
+ permplugin = PermHandler.PERMISSIONS2;
+ String version = permPlugin.getDescription().getVersion();
+ WarpLogger.info("Access Control: Using Permissions v"+ version);
+ handler = new Permissions2Handler(permPlugin);
+ }
+ }
+ return;
+ }
+
+ if (permplugin == PermHandler.NONE) {
+ if (!(handler instanceof SuperpermsHandler)) {
+ WarpLogger.info("Access Control: Using SuperPerms");
+ handler = new SuperpermsHandler(this.plugin);
+ }
+ }
+ }
+}
View
117 src/main/java/me/taylorkelly/mywarp/permissions/SuperpermsHandler.java
@@ -0,0 +1,117 @@
+package me.taylorkelly.mywarp.permissions;
+
+import java.util.LinkedHashMap;
+import java.util.Map;
+
+import me.taylorkelly.mywarp.WarpSettings;
+
+import org.bukkit.entity.Player;
+import org.bukkit.permissions.PermissionDefault;
+import org.bukkit.plugin.Plugin;
+import org.bukkit.plugin.PluginManager;
+
+
+public class SuperpermsHandler implements IPermissionsHandler {
+ private static PluginManager pm;
+
+ public SuperpermsHandler(Plugin plugin) {
+ pm = plugin.getServer().getPluginManager();
+ registerPermissions();
+ }
+
+ @Override
+ public boolean hasPermission(final Player player, final String node, boolean defaultPerm) {
+ if(player.isOp() && WarpSettings.opPermissions) {
+ return true;
+ }
+ if (player.hasPermission("-" + node)) {
+ return false;
+ }
+ final String[] parts = node.split("\\.");
+ final StringBuilder strbuilder = new StringBuilder(node.length());
+ for (String part : parts) {
+ strbuilder.append('*');
+ if (player.hasPermission(strbuilder.toString())) {
+ return true;
+ }
+ strbuilder.deleteCharAt(strbuilder.length() - 1);
+ strbuilder.append(part).append('.');
+ }
+ return player.hasPermission(node);
+ }
+
+ @Override
+ public int getInteger(final Player player, final String node, final int defaultInt) {
+ if(player.isOp() && WarpSettings.opPermissions) {
+ return 0;
+ }
+ return defaultInt;
+ }
+
+ private static void registerPermissions() {
+ registerAdminPerms();
+ registerUserPerms();
+ overallPerm();
+ }
+
+ private static void registerAdminPerms() {
+ pm.addPermission(new org.bukkit.permissions.Permission("mywarp.admin", "Admin Permission", PermissionDefault.OP));
+ }
+
+ private static void registerUserPerms() {
+ pm.addPermission(new org.bukkit.permissions.Permission("mywarp.warp.basic.warp", "Usage of /warp", PermissionDefault.TRUE));
+ pm.addPermission(new org.bukkit.permissions.Permission("mywarp.warp.basic.delete", "Can delete warps", PermissionDefault.TRUE));
+ pm.addPermission(new org.bukkit.permissions.Permission("mywarp.warp.basic.list", "Can list warps", PermissionDefault.TRUE));
+ pm.addPermission(new org.bukkit.permissions.Permission("mywarp.warp.basic.welcome", "Can change the welcome message", PermissionDefault.TRUE));
+ pm.addPermission(new org.bukkit.permissions.Permission("mywarp.warp.basic.search", "Can search for a warp", PermissionDefault.TRUE));
+ pm.addPermission(new org.bukkit.permissions.Permission("mywarp.warp.soc.give", "Can give to your /warp", PermissionDefault.TRUE));
+ pm.addPermission(new org.bukkit.permissions.Permission("mywarp.warp.soc.invite", "Can invite to your /warp", PermissionDefault.TRUE));
+ pm.addPermission(new org.bukkit.permissions.Permission("mywarp.warp.soc.uninvite", "Can uninvite people from your /warp", PermissionDefault.TRUE));
+ pm.addPermission(new org.bukkit.permissions.Permission("mywarp.warp.soc.public", "Allow anyone to use your /warp", PermissionDefault.TRUE));
+ pm.addPermission(new org.bukkit.permissions.Permission("mywarp.warp.soc.private", "Disallow anyone to use your /warp", PermissionDefault.TRUE));
+ pm.addPermission(new org.bukkit.permissions.Permission("mywarp.warp.soc.private", "Disallow anyone to use your /warp", PermissionDefault.TRUE));
+ pm.addPermission(new org.bukkit.permissions.Permission("mywarp.warp.sign.warp", "Can use sign warps", PermissionDefault.TRUE));
+ pm.addPermission(new org.bukkit.permissions.Permission("mywarp.warp.sign.create", "Can make sign warps", PermissionDefault.TRUE));
+ pm.addPermission(new org.bukkit.permissions.Permission("mywarp.warp.basic.createprivate", "Allowed to create private warps", PermissionDefault.TRUE));
+ pm.addPermission(new org.bukkit.permissions.Permission("mywarp.warp.basic.createpublic", "Allowed to create public warps", PermissionDefault.TRUE));
+ pm.addPermission(new org.bukkit.permissions.Permission("mywarp.warp.basic.compass", "Compass can be used", PermissionDefault.TRUE));
+ Map<String, Boolean> userbasicmap = new LinkedHashMap<String, Boolean>();
+ Map<String, Boolean> usersocmap = new LinkedHashMap<String, Boolean>();
+ Map<String, Boolean> usersignmap = new LinkedHashMap<String, Boolean>();
+ Map<String, Boolean> userallmap = new LinkedHashMap<String, Boolean>();
+ userbasicmap.put("mywarp.warp.basic.warp", true);
+ userbasicmap.put("mywarp.warp.basic.list", true);
+ userbasicmap.put("mywarp.warp.basic.welcome", true);
+ userbasicmap.put("mywarp.warp.basic.search", true);
+ userbasicmap.put("mywarp.warp.basic.delete", true);
+ userbasicmap.put("mywarp.warp.basic.createpublic", true);
+ userbasicmap.put("mywarp.warp.basic.createprivate", true);
+ userbasicmap.put("mywarp.warp.basic.compass", true);
+ usersocmap.put("mywarp.warp.soc.give", true);
+ usersocmap.put("mywarp.warp.soc.list", true);
+ usersocmap.put("mywarp.warp.soc.invite", true);
+ usersocmap.put("mywarp.warp.soc.uninvite", true);
+ usersocmap.put("mywarp.warp.soc.public", true);
+ usersocmap.put("mywarp.warp.soc.private", true);
+ usersignmap.put("mywarp.warp.sign.warp", true);
+ usersignmap.put("mywarp.warp.sign.create", true);
+ userallmap.putAll(userbasicmap);
+ userallmap.putAll(usersignmap);
+ userallmap.putAll(usersocmap);
+ pm.addPermission(new org.bukkit.permissions.Permission("mywarp.warp.basic.*", "Basic /warp commands", PermissionDefault.TRUE, userbasicmap));
+ pm.addPermission(new org.bukkit.permissions.Permission("mywarp.warp.soc.*", "Social /warp commands", PermissionDefault.TRUE, usersocmap));
+ pm.addPermission(new org.bukkit.permissions.Permission("mywarp.warp.sign.*", "All sign based warp permissions", PermissionDefault.TRUE, usersignmap));
+ pm.addPermission(new org.bukkit.permissions.Permission("mywarp.warp.*", "All user permissions", PermissionDefault.TRUE, userallmap));
+ }
+
+ public static void overallPerm() {
+ Map<String, Boolean> fullmap = new LinkedHashMap<String, Boolean>();
+ fullmap.put("mywarp.warp.soc.*", true);
+ fullmap.put("mywarp.warp.sign.*", true);
+ fullmap.put("mywarp.admin", true);
+ fullmap.put("mywarp.warp.basic.*", true);
+ pm.addPermission(new org.bukkit.permissions.Permission("mywarp.*", "Full access", PermissionDefault.OP, fullmap));
+ }
+
+}
+
View
90 src/main/java/me/taylorkelly/mywarp/permissions/WarpPermissions.java
@@ -0,0 +1,90 @@
+package me.taylorkelly.mywarp.permissions;
+
+import me.taylorkelly.mywarp.WarpSettings;
+
+import org.bukkit.entity.Player;
+import org.bukkit.plugin.Plugin;
+
+public class WarpPermissions {
+ private transient static PermissionsHandler permissionsHandler;
+
+ public static void initialize(Plugin plugin) {
+ permissionsHandler = new PermissionsHandler(plugin);
+ }
+
+ public static int integer(Player player, String node, int defaultInt) {
+ return permissionsHandler.getInteger(player, node, defaultInt);
+ }
+
+ public static boolean isAdmin(Player player) {
+ return permissionsHandler.hasPermission(player, "mywarp.admin", player.isOp());
+ }
+
+ public static boolean warp(Player player) {
+ return permissionsHandler.hasPermission(player, "mywarp.warp.basic.warp", true);
+ }
+
+ public static boolean delete(Player player) {
+ return permissionsHandler.hasPermission(player, "mywarp.warp.basic.delete", true);
+ }
+
+ public static boolean list(Player player) {
+ return permissionsHandler.hasPermission(player, "mywarp.warp.basic.list", true);
+ }
+
+ public static boolean welcome(Player player) {
+ return permissionsHandler.hasPermission(player, "mywarp.warp.basic.welcome", true);
+ }
+
+ public static boolean search(Player player) {
+ return permissionsHandler.hasPermission(player, "mywarp.warp.basic.search", true);
+ }
+
+ public static boolean give(Player player) {
+ return permissionsHandler.hasPermission(player, "mywarp.warp.soc.give", true);
+ }
+
+ public static boolean invite(Player player) {
+ return permissionsHandler.hasPermission(player, "mywarp.warp.soc.invite", true);
+ }
+
+ public static boolean uninvite(Player player) {
+ return permissionsHandler.hasPermission(player, "mywarp.warp.soc.uninvite", true);
+ }
+
+ public static boolean canPublic(Player player) {
+ return permissionsHandler.hasPermission(player, "mywarp.warp.soc.public", true);
+ }
+
+ public static boolean canPrivate(Player player) {
+ return permissionsHandler.hasPermission(player, "mywarp.warp.soc.private", true);
+ }
+
+ public static boolean signWarp(Player player) {
+ return permissionsHandler.hasPermission(player, "mywarp.warp.sign.warp", true);
+ }
+
+ public static boolean privateCreate(Player player) {
+ return permissionsHandler.hasPermission(player, "mywarp.warp.basic.createprivate", true);
+ }
+
+ public static boolean publicCreate(Player player) {
+ return permissionsHandler.hasPermission(player, "mywarp.warp.basic.createpublic", true);
+ }
+
+ public static boolean compass(Player player) {
+ return permissionsHandler.hasPermission(player, "mywarp.warp.basic.compass", true);
+ }
+
+ public static int maxPrivateWarps(Player player) {
+ return WarpSettings.maxPrivate;
+ }
+
+ public static int maxPublicWarps(Player player) {
+ return WarpSettings.maxPublic;
+ }
+
+ public static boolean createSignWarp(Player player) {
+ return permissionsHandler.hasPermission(player, "mywarp.warp.sign.create", true);
+ }
+}
View
2  src/main/resources/plugin.yml
@@ -1,5 +1,5 @@
name: MyWarp
-version: 2.0.1
+version: 2.1
author: spathizilla
authors:
- flames
Please sign in to comment.
Something went wrong with that request. Please try again.