mirror of
https://github.com/webbukkit/dynmap.git
synced 2024-12-24 01:27:37 +01:00
Add Sponge permissions for 1.11.2, 1.12.2, extract
permissions.yml.example
This commit is contained in:
parent
24b2a00d23
commit
2718feb137
@ -19,6 +19,7 @@ dependencies {
|
||||
compile project(path: ":DynmapCore", configuration: "shadow")
|
||||
compile 'com.googlecode.json-simple:json-simple:1.1.1'
|
||||
compile 'org.yaml:snakeyaml:1.23'
|
||||
compile 'org.spongepowered:spongeapi:7.0.0'
|
||||
}
|
||||
|
||||
sourceCompatibility = 1.8
|
||||
@ -30,6 +31,10 @@ repositories {
|
||||
name = 'forge'
|
||||
url = 'http://files.minecraftforge.net/maven'
|
||||
}
|
||||
maven {
|
||||
name = 'sponge'
|
||||
url = 'https://repo.spongepowered.org/maven'
|
||||
}
|
||||
}
|
||||
minecraft {
|
||||
version = "1.11.2-13.20.0.2315"
|
||||
|
@ -99,6 +99,7 @@ import org.dynmap.forge_1_11_2.DynmapMod;
|
||||
import org.dynmap.forge_1_11_2.permissions.FilePermissions;
|
||||
import org.dynmap.forge_1_11_2.permissions.OpPermissions;
|
||||
import org.dynmap.forge_1_11_2.permissions.PermissionProvider;
|
||||
import org.dynmap.forge_1_11_2.permissions.Sponge7Permissions;
|
||||
import org.dynmap.forge_1_11_2.ForgeWorld;
|
||||
import org.dynmap.forge_1_11_2.DynmapPlugin.WorldUpdateTracker;
|
||||
import org.dynmap.permissions.PermissionsHandler;
|
||||
@ -1467,8 +1468,11 @@ public class DynmapPlugin
|
||||
/* Set up player login/quit event handler */
|
||||
registerPlayerLoginListener();
|
||||
/* Initialize permissions handler */
|
||||
permissions = FilePermissions.create();
|
||||
if(permissions == null) {
|
||||
permissions = FilePermissions.create();
|
||||
if (permissions == null) {
|
||||
permissions = Sponge7Permissions.create();
|
||||
}
|
||||
if (permissions == null) {
|
||||
permissions = new OpPermissions(new String[] { "webchat", "marker.icons", "marker.list", "webregister", "stats", "hide.self", "show.self" });
|
||||
}
|
||||
/* Get and initialize data folder */
|
||||
@ -1499,6 +1503,10 @@ public class DynmapPlugin
|
||||
{
|
||||
return;
|
||||
}
|
||||
// Extract default permission example, if needed
|
||||
File filepermexample = new File(core.getDataFolder(), "permissions.yml.example");
|
||||
core.createDefaultFileFromResource("/permissions.yml.example", filepermexample);
|
||||
|
||||
DynmapCommonAPIListener.apiInitialized(core);
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,68 @@
|
||||
package org.dynmap.forge_1_11_2.permissions;
|
||||
|
||||
import java.util.HashSet;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
|
||||
import org.dynmap.Log;
|
||||
import org.spongepowered.api.Sponge;
|
||||
import org.spongepowered.api.entity.living.player.Player;
|
||||
|
||||
import net.minecraft.command.ICommandSender;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
|
||||
public class Sponge7Permissions implements PermissionProvider {
|
||||
|
||||
public static Sponge7Permissions create() {
|
||||
try {
|
||||
Class.forName("org.spongepowered.api.Sponge"); /* See if class exists */
|
||||
} catch (ClassNotFoundException cnfx) {
|
||||
return null;
|
||||
}
|
||||
Log.info("Using Sponge Permissions for access control");
|
||||
Log.info("Web interface permissions only available for online users");
|
||||
Log.info("Note: you may need to give users permissions for base commands (e.g. dynmap.command.* on LuckPerms) as well as for specific actions");
|
||||
return new Sponge7Permissions();
|
||||
}
|
||||
|
||||
private Sponge7Permissions() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean has(ICommandSender sender, String permission) {
|
||||
return sender.canUseCommand(4, "dynmap." + permission);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPermissionNode(ICommandSender sender, String permission) {
|
||||
return sender.canUseCommand(4, "dynmap." + permission);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<String> hasOfflinePermissions(String player, Set<String> perms) {
|
||||
HashSet<String> rslt = new HashSet<String>();
|
||||
Optional<Player> p = Sponge.getServer().getPlayer(player);
|
||||
if (p.isPresent()) {
|
||||
Player plyr = p.get();
|
||||
for (String perm : perms) {
|
||||
if (plyr.hasPermission("dynmap." + perm)) {
|
||||
rslt.add(perm);
|
||||
}
|
||||
}
|
||||
}
|
||||
return rslt;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasOfflinePermission(String player, String perm) {
|
||||
Optional<Player> p = Sponge.getServer().getPlayer(player);
|
||||
if (p.isPresent()) {
|
||||
Player plyr = p.get();
|
||||
return plyr.hasPermission("dynmap." + perm);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
@ -1475,9 +1475,9 @@ public class DynmapPlugin
|
||||
/* Set up player login/quit event handler */
|
||||
registerPlayerLoginListener();
|
||||
/* Initialize permissions handler */
|
||||
permissions = Sponge7Permissions.create();
|
||||
permissions = FilePermissions.create();
|
||||
if (permissions == null) {
|
||||
permissions = FilePermissions.create();
|
||||
permissions = Sponge7Permissions.create();
|
||||
}
|
||||
if(permissions == null) {
|
||||
permissions = new OpPermissions(new String[] { "webchat", "marker.icons", "marker.list", "webregister", "stats", "hide.self", "show.self" });
|
||||
@ -1510,6 +1510,10 @@ public class DynmapPlugin
|
||||
{
|
||||
return;
|
||||
}
|
||||
// Extract default permission example, if needed
|
||||
File filepermexample = new File(core.getDataFolder(), "permissions.yml.example");
|
||||
core.createDefaultFileFromResource("/permissions.yml.example", filepermexample);
|
||||
|
||||
DynmapCommonAPIListener.apiInitialized(core);
|
||||
}
|
||||
|
||||
|
@ -24,6 +24,7 @@ public class Sponge7Permissions implements PermissionProvider {
|
||||
}
|
||||
Log.info("Using Sponge Permissions for access control");
|
||||
Log.info("Web interface permissions only available for online users");
|
||||
Log.info("Note: you may need to give users permissions for base commands (e.g. dynmap.command.* on LuckPerms) as well as for specific actions");
|
||||
return new Sponge7Permissions();
|
||||
}
|
||||
|
||||
|
@ -1456,6 +1456,10 @@ public class DynmapPlugin
|
||||
{
|
||||
return;
|
||||
}
|
||||
// Extract default permission example, if needed
|
||||
File filepermexample = new File(core.getDataFolder(), "permissions.yml.example");
|
||||
core.createDefaultFileFromResource("/permissions.yml.example", filepermexample);
|
||||
|
||||
DynmapCommonAPIListener.apiInitialized(core);
|
||||
}
|
||||
|
||||
|
@ -1485,6 +1485,10 @@ public class DynmapPlugin
|
||||
{
|
||||
return;
|
||||
}
|
||||
// Extract default permission example, if needed
|
||||
File filepermexample = new File(core.getDataFolder(), "permissions.yml.example");
|
||||
core.createDefaultFileFromResource("/permissions.yml.example", filepermexample);
|
||||
|
||||
DynmapCommonAPIListener.apiInitialized(core);
|
||||
}
|
||||
|
||||
|
@ -1485,6 +1485,10 @@ public class DynmapPlugin
|
||||
{
|
||||
return;
|
||||
}
|
||||
// Extract default permission example, if needed
|
||||
File filepermexample = new File(core.getDataFolder(), "permissions.yml.example");
|
||||
core.createDefaultFileFromResource("/permissions.yml.example", filepermexample);
|
||||
|
||||
DynmapCommonAPIListener.apiInitialized(core);
|
||||
}
|
||||
|
||||
|
@ -1482,6 +1482,10 @@ public class DynmapPlugin
|
||||
{
|
||||
return;
|
||||
}
|
||||
// Extract default permission example, if needed
|
||||
File filepermexample = new File(core.getDataFolder(), "permissions.yml.example");
|
||||
core.createDefaultFileFromResource("/permissions.yml.example", filepermexample);
|
||||
|
||||
DynmapCommonAPIListener.apiInitialized(core);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user