mirror of
https://github.com/EssentialsX/Essentials.git
synced 2025-01-05 07:57:59 +01:00
Adding support for two more permission systems.
This commit is contained in:
parent
3dd3fa4519
commit
0c37e091c0
1
.gitignore
vendored
1
.gitignore
vendored
@ -29,3 +29,4 @@
|
|||||||
/Essentials/nbproject/private/
|
/Essentials/nbproject/private/
|
||||||
/Essentials/dist/
|
/Essentials/dist/
|
||||||
/Essentials/build/
|
/Essentials/build/
|
||||||
|
/YamlAnnotations/
|
@ -62,6 +62,7 @@ dist.javadoc.dir=${dist.dir}/javadoc
|
|||||||
endorsed.classpath=
|
endorsed.classpath=
|
||||||
excludes=
|
excludes=
|
||||||
file.reference.BOSEconomy7.jar=../lib/BOSEconomy7.jar
|
file.reference.BOSEconomy7.jar=../lib/BOSEconomy7.jar
|
||||||
|
file.reference.bPermissions.jar=../lib/bPermissions.jar
|
||||||
file.reference.craftbukkit-0.0.1-SNAPSHOT.jar=..\\lib\\craftbukkit-0.0.1-SNAPSHOT.jar
|
file.reference.craftbukkit-0.0.1-SNAPSHOT.jar=..\\lib\\craftbukkit-0.0.1-SNAPSHOT.jar
|
||||||
file.reference.iCo4.jar=../lib/iCo4.jar
|
file.reference.iCo4.jar=../lib/iCo4.jar
|
||||||
file.reference.iCo5.jar=../lib/iCo5.jar
|
file.reference.iCo5.jar=../lib/iCo5.jar
|
||||||
@ -69,6 +70,7 @@ file.reference.iCo6.jar=../lib/iCo6.jar
|
|||||||
file.reference.junit-4.5.jar=..\\lib\\junit_4\\junit-4.5.jar
|
file.reference.junit-4.5.jar=..\\lib\\junit_4\\junit-4.5.jar
|
||||||
file.reference.MultiCurrency.jar=../lib/MultiCurrency.jar
|
file.reference.MultiCurrency.jar=../lib/MultiCurrency.jar
|
||||||
file.reference.Permissions3.jar=../lib/Permissions3.jar
|
file.reference.Permissions3.jar=../lib/Permissions3.jar
|
||||||
|
file.reference.PermissionsBukkit-1.2.jar=../lib/PermissionsBukkit-1.2.jar
|
||||||
file.reference.PermissionsEx.jar=../lib/PermissionsEx.jar
|
file.reference.PermissionsEx.jar=../lib/PermissionsEx.jar
|
||||||
includes=**
|
includes=**
|
||||||
jar.archive.disabled=${jnlp.enabled}
|
jar.archive.disabled=${jnlp.enabled}
|
||||||
@ -82,7 +84,9 @@ javac.classpath=\
|
|||||||
${file.reference.iCo6.jar}:\
|
${file.reference.iCo6.jar}:\
|
||||||
${file.reference.MultiCurrency.jar}:\
|
${file.reference.MultiCurrency.jar}:\
|
||||||
${file.reference.BOSEconomy7.jar}:\
|
${file.reference.BOSEconomy7.jar}:\
|
||||||
${file.reference.PermissionsEx.jar}
|
${file.reference.PermissionsEx.jar}:\
|
||||||
|
${file.reference.bPermissions.jar}:\
|
||||||
|
${file.reference.PermissionsBukkit-1.2.jar}
|
||||||
# Space-separated list of extra javac options
|
# Space-separated list of extra javac options
|
||||||
javac.compilerargs=
|
javac.compilerargs=
|
||||||
javac.deprecation=false
|
javac.deprecation=false
|
||||||
|
@ -17,6 +17,8 @@
|
|||||||
*/
|
*/
|
||||||
package com.earth2me.essentials;
|
package com.earth2me.essentials;
|
||||||
|
|
||||||
|
import com.earth2me.essentials.perm.IPermissionsHandler;
|
||||||
|
import com.earth2me.essentials.perm.ConfigPermissionsHandler;
|
||||||
import com.earth2me.essentials.api.Economy;
|
import com.earth2me.essentials.api.Economy;
|
||||||
import com.earth2me.essentials.commands.EssentialsCommand;
|
import com.earth2me.essentials.commands.EssentialsCommand;
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
|
@ -1,5 +1,10 @@
|
|||||||
package com.earth2me.essentials;
|
package com.earth2me.essentials;
|
||||||
|
|
||||||
|
import com.earth2me.essentials.perm.ConfigPermissionsHandler;
|
||||||
|
import com.earth2me.essentials.perm.BukkitPermissionsHandler;
|
||||||
|
import com.earth2me.essentials.perm.Permissions3Handler;
|
||||||
|
import com.earth2me.essentials.perm.Permissions2Handler;
|
||||||
|
import com.earth2me.essentials.perm.PermissionsExHandler;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
import org.bukkit.event.server.PluginDisableEvent;
|
import org.bukkit.event.server.PluginDisableEvent;
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package com.earth2me.essentials;
|
package com.earth2me.essentials;
|
||||||
|
|
||||||
|
import com.earth2me.essentials.perm.IPermissionsHandler;
|
||||||
import com.earth2me.essentials.register.payment.Methods;
|
import com.earth2me.essentials.register.payment.Methods;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
|
@ -0,0 +1,88 @@
|
|||||||
|
package com.earth2me.essentials.perm;
|
||||||
|
|
||||||
|
import de.bananaco.permissions.Permissions;
|
||||||
|
import de.bananaco.permissions.interfaces.PermissionSet;
|
||||||
|
import de.bananaco.permissions.worlds.WorldPermissionsManager;
|
||||||
|
import java.util.List;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
|
||||||
|
public class BPermissionsHandler implements IPermissionsHandler
|
||||||
|
{
|
||||||
|
private final transient WorldPermissionsManager wpm;
|
||||||
|
|
||||||
|
public BPermissionsHandler()
|
||||||
|
{
|
||||||
|
wpm = Permissions.getWorldPermissionsManager();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getGroup(final Player base)
|
||||||
|
{
|
||||||
|
final PermissionSet pset = wpm.getPermissionSet(base.getWorld());
|
||||||
|
if (pset == null)
|
||||||
|
{
|
||||||
|
return "default";
|
||||||
|
}
|
||||||
|
final List<String> groups = pset.getGroups(base);
|
||||||
|
if (groups == null || groups.isEmpty())
|
||||||
|
{
|
||||||
|
return "default";
|
||||||
|
}
|
||||||
|
return groups.get(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canBuild(Player base, String group)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean inGroup(Player base, String group)
|
||||||
|
{
|
||||||
|
final PermissionSet pset = wpm.getPermissionSet(base.getWorld());
|
||||||
|
if (pset == null)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
final List<String> groups = pset.getGroups(base);
|
||||||
|
if (groups == null || groups.isEmpty())
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return groups.contains(group);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean hasPermission(Player base, String node)
|
||||||
|
{
|
||||||
|
if (base.hasPermission("-" + node))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
final String[] parts = node.split("\\.");
|
||||||
|
final StringBuilder sb = new StringBuilder();
|
||||||
|
for (String part : parts)
|
||||||
|
{
|
||||||
|
if (base.hasPermission(sb.toString() + "*"))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
sb.append(part).append(".");
|
||||||
|
}
|
||||||
|
return base.hasPermission(node);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getPrefix(Player base)
|
||||||
|
{
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getSuffix(Player base)
|
||||||
|
{
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
}
|
@ -1,5 +1,6 @@
|
|||||||
package com.earth2me.essentials;
|
package com.earth2me.essentials.perm;
|
||||||
|
|
||||||
|
import com.earth2me.essentials.IEssentials;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
package com.earth2me.essentials;
|
package com.earth2me.essentials.perm;
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
package com.earth2me.essentials;
|
package com.earth2me.essentials.perm;
|
||||||
|
|
||||||
import com.nijiko.permissions.PermissionHandler;
|
import com.nijiko.permissions.PermissionHandler;
|
||||||
import com.nijikokun.bukkit.Permissions.Permissions;
|
import com.nijikokun.bukkit.Permissions.Permissions;
|
@ -1,4 +1,4 @@
|
|||||||
package com.earth2me.essentials;
|
package com.earth2me.essentials.perm;
|
||||||
|
|
||||||
import com.nijiko.permissions.PermissionHandler;
|
import com.nijiko.permissions.PermissionHandler;
|
||||||
import com.nijikokun.bukkit.Permissions.Permissions;
|
import com.nijikokun.bukkit.Permissions.Permissions;
|
@ -0,0 +1,86 @@
|
|||||||
|
package com.earth2me.essentials.perm;
|
||||||
|
|
||||||
|
import com.platymuus.bukkit.permissions.Group;
|
||||||
|
import com.platymuus.bukkit.permissions.PermissionInfo;
|
||||||
|
import com.platymuus.bukkit.permissions.PermissionsPlugin;
|
||||||
|
import java.util.List;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.plugin.Plugin;
|
||||||
|
|
||||||
|
|
||||||
|
public class PermissionsBukkitHandler implements IPermissionsHandler
|
||||||
|
{
|
||||||
|
private final transient PermissionsPlugin plugin;
|
||||||
|
|
||||||
|
public PermissionsBukkitHandler(Plugin plugin)
|
||||||
|
{
|
||||||
|
this.plugin = (PermissionsPlugin)plugin;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public String getGroup(Player base)
|
||||||
|
{
|
||||||
|
final PermissionInfo info = plugin.getPlayerInfo(base.getName());
|
||||||
|
if (info == null) {
|
||||||
|
return "default";
|
||||||
|
}
|
||||||
|
final List<Group> groups = info.getGroups();
|
||||||
|
if (groups == null || groups.isEmpty()) {
|
||||||
|
return "default";
|
||||||
|
}
|
||||||
|
return groups.get(0).getName();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean canBuild(Player base, String group)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean inGroup(Player base, String group)
|
||||||
|
{
|
||||||
|
final PermissionInfo info = plugin.getPlayerInfo(base.getName());
|
||||||
|
if (info == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
final List<Group> groups = info.getGroups();
|
||||||
|
if (groups == null || groups.isEmpty()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
for (Group group1 : groups)
|
||||||
|
{
|
||||||
|
if(group1.getName().equalsIgnoreCase(group)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasPermission(Player base, String node)
|
||||||
|
{
|
||||||
|
if (base.hasPermission("-" + node))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
final String[] parts = node.split("\\.");
|
||||||
|
final StringBuilder sb = new StringBuilder();
|
||||||
|
for (String part : parts)
|
||||||
|
{
|
||||||
|
if (base.hasPermission(sb.toString() + "*"))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
sb.append(part).append(".");
|
||||||
|
}
|
||||||
|
return base.hasPermission(node);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPrefix(Player base)
|
||||||
|
{
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSuffix(Player base)
|
||||||
|
{
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
}
|
@ -1,4 +1,4 @@
|
|||||||
package com.earth2me.essentials;
|
package com.earth2me.essentials.perm;
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import ru.tehkode.permissions.PermissionManager;
|
import ru.tehkode.permissions.PermissionManager;
|
||||||
@ -6,7 +6,7 @@ import ru.tehkode.permissions.PermissionUser;
|
|||||||
import ru.tehkode.permissions.bukkit.PermissionsEx;
|
import ru.tehkode.permissions.bukkit.PermissionsEx;
|
||||||
|
|
||||||
|
|
||||||
class PermissionsExHandler implements IPermissionsHandler
|
public class PermissionsExHandler implements IPermissionsHandler
|
||||||
{
|
{
|
||||||
private final transient PermissionManager manager;
|
private final transient PermissionManager manager;
|
||||||
|
|
@ -1,9 +1,9 @@
|
|||||||
package com.earth2me.essentials;
|
package com.earth2me.essentials.perm;
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
|
||||||
public class BukkitPermissionsHandler implements IPermissionsHandler
|
public class SuperpermsHandler implements IPermissionsHandler
|
||||||
{
|
{
|
||||||
public String getGroup(Player base)
|
public String getGroup(Player base)
|
||||||
{
|
{
|
||||||
@ -49,3 +49,4 @@ public class BukkitPermissionsHandler implements IPermissionsHandler
|
|||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
BIN
lib/PermissionsBukkit-1.2.jar
Normal file
BIN
lib/PermissionsBukkit-1.2.jar
Normal file
Binary file not shown.
BIN
lib/bPermissions.jar
Normal file
BIN
lib/bPermissions.jar
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user