Update LuckPerms and bStats

This commit is contained in:
Sijmen Schoon 2019-12-01 03:38:05 +01:00
parent 1be9f663c7
commit 9e7174dcde
No known key found for this signature in database
GPG Key ID: DAF7821E067D9C48
4 changed files with 54 additions and 50 deletions

View File

@ -13,7 +13,7 @@ allprojects {
maven { url "http://repo.mikeprimm.com" }
maven { url "http://repo.maven.apache.org/maven2" }
maven { url "https://hub.spigotmc.org/nexus/content/repositories/snapshots/" }
maven { url "http://repo.bstats.org/content/repositories/releases/" }
maven { url "https://repo.codemc.org/repository/maven-public/" }
}
apply plugin: 'java'

View File

@ -4,14 +4,14 @@ description = 'dynmap'
dependencies {
compile group: 'org.bukkit', name: 'bukkit', version:'1.7.10-R0.1-SNAPSHOT'
compile 'com.nijikokun.bukkit:Permissions:3.1.6'
compile 'me.lucko.luckperms:luckperms-api:4.3'
compile 'net.luckperms:api:5.0'
compile project(":dynmap-api")
compile project(path: ":DynmapCore", configuration: "shadow")
compile group: 'ru.tehkode', name: 'PermissionsEx', version:'1.19.1'
compile group: 'de.bananaco', name: 'bPermissions', version:'2.9.1'
compile group: 'com.platymuus.bukkit.permissions', name: 'PermissionsBukkit', version:'1.6'
compile group: 'org.anjocaido', name: 'EssentialsGroupManager', version:'2.10.1'
compile group: 'org.bstats', name: 'bstats-bukkit', version:'1.1'
compile group: 'org.bstats', name: 'bstats-bukkit', version:'1.5'
compile group: 'com.googlecode.json-simple', name: 'json-simple', version:'1.1.1'
compile group: 'com.google.code.gson', name: 'gson', version:'2.8.2'
compile project(':bukkit-helper')

View File

@ -16,7 +16,7 @@ import java.util.concurrent.CancellationException;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
import org.bstats.Metrics;
import org.bstats.bukkit.Metrics;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Chunk;
@ -1585,35 +1585,31 @@ public class DynmapPlugin extends JavaPlugin implements DynmapAPI {
private void initMetrics() {
metrics = new Metrics(this);
metrics.addCustomChart(new Metrics.MultiLineChart("features_used") {
@Override
public HashMap<String, Integer> getValues(HashMap<String, Integer> hashMap) {
hashMap.put("internal_web_server", core.configuration.getBoolean("disable-webserver", false) ? 0 : 1);
hashMap.put("login_security", core.configuration.getBoolean("login-enabled", false) ? 1 : 0);
hashMap.put("player_info_protected", core.player_info_protected ? 1 : 0);
for (String mod : modsused)
hashMap.put(mod + "_blocks", 1);
return hashMap;
}
});
metrics.addCustomChart(new Metrics.MultiLineChart("features_used", () -> {
Map<String, Integer> hashMap = new HashMap<>();
hashMap.put("internal_web_server", core.configuration.getBoolean("disable-webserver", false) ? 0 : 1);
hashMap.put("login_security", core.configuration.getBoolean("login-enabled", false) ? 1 : 0);
hashMap.put("player_info_protected", core.player_info_protected ? 1 : 0);
for (String mod : modsused)
hashMap.put(mod + "_blocks", 1);
return hashMap;
}));
metrics.addCustomChart(new Metrics.MultiLineChart("map_data") {
@Override
public HashMap<String, Integer> getValues(HashMap<String, Integer> hashMap) {
hashMap.put("worlds", core.mapManager != null ? core.mapManager.getWorlds().size() : 0);
int maps = 0, hdmaps = 0;
if (core.mapManager != null)
for (DynmapWorld w : core.mapManager.getWorlds()) {
for (MapType mt : w.maps)
if (mt instanceof HDMap)
++hdmaps;
maps += w.maps.size();
}
hashMap.put("maps", maps);
hashMap.put("hd_maps", hdmaps);
return hashMap;
}
});
metrics.addCustomChart(new Metrics.MultiLineChart("map_data", () -> {
Map<String, Integer> hashMap = new HashMap<>();
hashMap.put("worlds", core.mapManager != null ? core.mapManager.getWorlds().size() : 0);
int maps = 0, hdmaps = 0;
if (core.mapManager != null)
for (DynmapWorld w : core.mapManager.getWorlds()) {
for (MapType mt : w.maps)
if (mt instanceof HDMap)
++hdmaps;
maps += w.maps.size();
}
hashMap.put("maps", maps);
hashMap.put("hd_maps", hdmaps);
return hashMap;
}));
}
@Override
public void processSignChange(int blkid, String world, int x, int y, int z,

View File

@ -6,9 +6,12 @@ import java.util.UUID;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
import me.lucko.luckperms.api.LuckPermsApi;
import me.lucko.luckperms.api.User;
import me.lucko.luckperms.api.caching.PermissionData;
import net.luckperms.api.LuckPerms;
import net.luckperms.api.model.user.User;
import net.luckperms.api.model.user.UserManager;
import net.luckperms.api.cacheddata.CachedPermissionData;
import net.luckperms.api.cacheddata.CachedDataManager;
import net.luckperms.api.query.QueryOptions;
import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;
@ -18,19 +21,19 @@ import org.dynmap.Log;
public class LuckPermsPermissions implements PermissionProvider {
String name;
LuckPermsApi luckPerms;
LuckPerms luckPerms;
public static LuckPermsPermissions create(Server server, String name) {
if (!server.getPluginManager().isPluginEnabled("LuckPerms"))
return null;
LuckPermsApi luckPerms = server.getServicesManager().load(LuckPermsApi.class);
LuckPerms luckPerms = server.getServicesManager().load(LuckPerms.class);
if (luckPerms == null)
return null;
Log.info("Using LuckPerms " + luckPerms.getPlatformInfo().getVersion() + " for access control");
Log.info("Using LuckPerms " + luckPerms.getPluginMetadata().getVersion() + " for access control");
return new LuckPermsPermissions(name, luckPerms);
}
public LuckPermsPermissions(String name, LuckPermsApi luckPerms) {
public LuckPermsPermissions(String name, LuckPerms luckPerms) {
this.name = name;
this.luckPerms = luckPerms;
}
@ -43,10 +46,10 @@ public class LuckPermsPermissions implements PermissionProvider {
@Override
public Set<String> hasOfflinePermissions(String player, Set<String> perms) {
Set<String> result = new HashSet<>();
PermissionData user = getUser(player);
CachedPermissionData user = getUser(player);
if (user != null) {
for (String p : perms) {
if (user.getPermissionValue(name + "." + p).asBoolean())
if (user.checkPermission(name + "." + p).asBoolean())
result.add(p);
}
}
@ -55,34 +58,39 @@ public class LuckPermsPermissions implements PermissionProvider {
@Override
public boolean hasOfflinePermission(String player, String perm) {
PermissionData user = getUser(player);
CachedPermissionData user = getUser(player);
if (user == null)
return false;
return user.getPermissionValue(name + "." + perm).asBoolean();
return user.checkPermission(name + "." + perm).asBoolean();
}
private PermissionData getUser(String username) {
private CachedPermissionData getUser(String username) {
OfflinePlayer offlinePlayer = Bukkit.getOfflinePlayer(username);
UUID uuid;
if (offlinePlayer != null && offlinePlayer.getUniqueId() != null)
uuid = offlinePlayer.getUniqueId();
else
uuid = joinFuture(luckPerms.getStorage().getUUID(username));
uuid = joinFuture(luckPerms.getUserManager().lookupUniqueId(username));
if (uuid == null)
return null;
User user = luckPerms.getUser(uuid);
User user = luckPerms.getUserManager().getUser(uuid);
if (user == null) {
joinFuture(luckPerms.getStorage().loadUser(uuid));
user = luckPerms.getUser(uuid);
joinFuture(luckPerms.getUserManager().loadUser(uuid));
user = luckPerms.getUserManager().getUser(uuid);
}
if (user == null)
return null;
return user.getCachedData().getPermissionData(luckPerms.getContextManager().getStaticContexts());
CachedDataManager data = user.getCachedData();
return luckPerms
.getContextManager()
.getQueryOptions(user)
.map(queryOptions -> data.getPermissionData(queryOptions))
.orElse(null);
}
private static <T> T joinFuture(Future<T> future) {