mirror of https://github.com/MilkBowl/Vault.git
Cleanup code
This commit is contained in:
parent
e2f919793f
commit
e3a664e4b3
|
@ -53,8 +53,8 @@
|
|||
verbose="false"
|
||||
author="true"
|
||||
version="true">
|
||||
<link href="http://docs.oracle.com/javase/7/docs/api/" />
|
||||
<link href="http://jd.bukkit.org/apidocs/" />
|
||||
<link href="https://docs.oracle.com/javase/7/docs/api/" />
|
||||
<link href="https://jd.bukkit.org/apidocs/" />
|
||||
|
||||
<classpath>
|
||||
<fileset dir="lib" includes="**/*.jar"/>
|
||||
|
|
10
pom.xml
10
pom.xml
|
@ -1,5 +1,5 @@
|
|||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<properties>
|
||||
|
@ -40,12 +40,12 @@
|
|||
<repository>
|
||||
<id>pub-repo</id>
|
||||
<name>Public Releases</name>
|
||||
<url>http://nexus.hc.to/content/repositories/pub_releases/</url>
|
||||
<url>https://nexus.hc.to/content/repositories/pub_releases/</url>
|
||||
</repository>
|
||||
<snapshotRepository>
|
||||
<id>pub-repo</id>
|
||||
<name>Public Snapshots</name>
|
||||
<url>http://nexus.hc.to/content/repositories/pub_snapshots/</url>
|
||||
<url>https://nexus.hc.to/content/repositories/pub_snapshots/</url>
|
||||
</snapshotRepository>
|
||||
</distributionManagement>
|
||||
|
||||
|
@ -53,7 +53,7 @@
|
|||
<repository>
|
||||
<id>pub-repo</id>
|
||||
<name>Public Releases</name>
|
||||
<url>http://nexus.hc.to/content/repositories/pub_releases/</url>
|
||||
<url>https://nexus.hc.to/content/repositories/pub_releases/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>spigot-repo</id>
|
||||
|
@ -61,7 +61,7 @@
|
|||
</repository>
|
||||
<repository>
|
||||
<id>escapecraft-repo</id>
|
||||
<url>http://dev.escapecraft.com/maven</url>
|
||||
<url>https://dev.escapecraft.com/maven</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>codemc-repo</id>
|
||||
|
|
|
@ -20,7 +20,6 @@ import java.io.InputStreamReader;
|
|||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import java.util.Collection;
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import net.milkbowl.vault.chat.Chat;
|
||||
|
@ -84,8 +83,8 @@ public class Vault extends JavaPlugin {
|
|||
private static Logger log;
|
||||
private Permission perms;
|
||||
private String newVersionTitle = "";
|
||||
private double newVersion = 0;
|
||||
private double currentVersion = 0;
|
||||
private double newVersion;
|
||||
private double currentVersion;
|
||||
private String currentVersionTitle = "";
|
||||
private ServicesManager sm;
|
||||
private Vault plugin;
|
||||
|
@ -102,7 +101,7 @@ public class Vault extends JavaPlugin {
|
|||
plugin = this;
|
||||
log = this.getLogger();
|
||||
currentVersionTitle = getDescription().getVersion().split("-")[0];
|
||||
currentVersion = Double.valueOf(currentVersionTitle.replaceFirst("\\.", ""));
|
||||
currentVersion = Double.parseDouble(currentVersionTitle.replaceFirst("\\.", ""));
|
||||
sm = getServer().getServicesManager();
|
||||
// set defaults
|
||||
getConfig().addDefault("update-check", true);
|
||||
|
@ -117,42 +116,29 @@ public class Vault extends JavaPlugin {
|
|||
getServer().getPluginManager().registerEvents(new VaultListener(), this);
|
||||
// Schedule to check the version every 30 minutes for an update. This is to update the most recent
|
||||
// version so if an admin reconnects they will be warned about newer versions.
|
||||
this.getServer().getScheduler().runTask(this, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
// Programmatically set the default permission value cause Bukkit doesn't handle plugin.yml properly for Load order STARTUP plugins
|
||||
org.bukkit.permissions.Permission perm = getServer().getPluginManager().getPermission("vault.update");
|
||||
if (perm == null)
|
||||
{
|
||||
perm = new org.bukkit.permissions.Permission("vault.update");
|
||||
perm.setDefault(PermissionDefault.OP);
|
||||
plugin.getServer().getPluginManager().addPermission(perm);
|
||||
}
|
||||
perm.setDescription("Allows a user or the console to check for vault updates");
|
||||
|
||||
getServer().getScheduler().runTaskTimerAsynchronously(plugin, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (getServer().getConsoleSender().hasPermission("vault.update") && getConfig().getBoolean("update-check", true)) {
|
||||
try {
|
||||
log.info("Checking for Updates ... ");
|
||||
newVersion = updateCheck(currentVersion);
|
||||
if (newVersion > currentVersion) {
|
||||
log.warning("Stable Version: " + newVersionTitle + " is out!" + " You are still running version: " + currentVersionTitle);
|
||||
log.warning("Update at: https://dev.bukkit.org/projects/vault");
|
||||
} else if (currentVersion > newVersion) {
|
||||
log.info("Stable Version: " + newVersionTitle + " | Current Version: " + currentVersionTitle);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// ignore exceptions
|
||||
}
|
||||
}
|
||||
}
|
||||
}, 0, 432000);
|
||||
|
||||
this.getServer().getScheduler().runTask(this, () -> {
|
||||
// Programmatically set the default permission value cause Bukkit doesn't handle plugin.yml properly for Load order STARTUP plugins
|
||||
org.bukkit.permissions.Permission perm = getServer().getPluginManager().getPermission("vault.update");
|
||||
if (perm == null) {
|
||||
perm = new org.bukkit.permissions.Permission("vault.update");
|
||||
perm.setDefault(PermissionDefault.OP);
|
||||
plugin.getServer().getPluginManager().addPermission(perm);
|
||||
}
|
||||
perm.setDescription("Allows a user or the console to check for vault updates");
|
||||
|
||||
getServer().getScheduler().runTaskTimerAsynchronously(plugin, () -> {
|
||||
if (getServer().getConsoleSender().hasPermission("vault.update") && getConfig().getBoolean("update-check", true)) {
|
||||
log.info("Checking for Updates ... ");
|
||||
newVersion = updateCheck(currentVersion);
|
||||
if (newVersion > currentVersion) {
|
||||
log.warning("Stable Version: " + newVersionTitle + " is out!" + " You are still running version: " + currentVersionTitle);
|
||||
log.warning("Update at: https://dev.bukkit.org/projects/vault");
|
||||
} else if (currentVersion > newVersion) {
|
||||
log.info("Stable Version: " + newVersionTitle + " | Current Version: " + currentVersionTitle);
|
||||
}
|
||||
}
|
||||
}, 0, 432000);
|
||||
|
||||
});
|
||||
|
||||
// Load up the Plugin metrics
|
||||
|
@ -257,7 +243,7 @@ public class Vault extends JavaPlugin {
|
|||
|
||||
Permission perms = new Permission_SuperPerms(this);
|
||||
sm.register(Permission.class, perms, this, ServicePriority.Lowest);
|
||||
log.info(String.format("[Permission] SuperPermissions loaded as backup permission system."));
|
||||
log.info("[Permission] SuperPermissions loaded as backup permission system.");
|
||||
|
||||
this.perms = sm.getRegistration(Permission.class).getProvider();
|
||||
}
|
||||
|
@ -319,7 +305,7 @@ public class Vault extends JavaPlugin {
|
|||
}
|
||||
Economy econ1 = null;
|
||||
Economy econ2 = null;
|
||||
String economies = "";
|
||||
StringBuilder economies = new StringBuilder();
|
||||
for (RegisteredServiceProvider<Economy> econ : econs) {
|
||||
String econName = econ.getProvider().getName().replace(" ", "");
|
||||
if (econName.equalsIgnoreCase(args[0])) {
|
||||
|
@ -328,9 +314,9 @@ public class Vault extends JavaPlugin {
|
|||
econ2 = econ.getProvider();
|
||||
}
|
||||
if (economies.length() > 0) {
|
||||
economies += ", ";
|
||||
economies.append(", ");
|
||||
}
|
||||
economies += econName;
|
||||
economies.append(econName);
|
||||
}
|
||||
|
||||
if (econ1 == null) {
|
||||
|
@ -364,37 +350,37 @@ public class Vault extends JavaPlugin {
|
|||
|
||||
private void infoCommand(CommandSender sender) {
|
||||
// Get String of Registered Economy Services
|
||||
String registeredEcons = null;
|
||||
StringBuilder registeredEcons = null;
|
||||
Collection<RegisteredServiceProvider<Economy>> econs = this.getServer().getServicesManager().getRegistrations(Economy.class);
|
||||
for (RegisteredServiceProvider<Economy> econ : econs) {
|
||||
Economy e = econ.getProvider();
|
||||
if (registeredEcons == null) {
|
||||
registeredEcons = e.getName();
|
||||
registeredEcons = new StringBuilder(e.getName());
|
||||
} else {
|
||||
registeredEcons += ", " + e.getName();
|
||||
registeredEcons.append(", ").append(e.getName());
|
||||
}
|
||||
}
|
||||
|
||||
// Get String of Registered Permission Services
|
||||
String registeredPerms = null;
|
||||
StringBuilder registeredPerms = null;
|
||||
Collection<RegisteredServiceProvider<Permission>> perms = this.getServer().getServicesManager().getRegistrations(Permission.class);
|
||||
for (RegisteredServiceProvider<Permission> perm : perms) {
|
||||
Permission p = perm.getProvider();
|
||||
if (registeredPerms == null) {
|
||||
registeredPerms = p.getName();
|
||||
registeredPerms = new StringBuilder(p.getName());
|
||||
} else {
|
||||
registeredPerms += ", " + p.getName();
|
||||
registeredPerms.append(", ").append(p.getName());
|
||||
}
|
||||
}
|
||||
|
||||
String registeredChats = null;
|
||||
StringBuilder registeredChats = null;
|
||||
Collection<RegisteredServiceProvider<Chat>> chats = this.getServer().getServicesManager().getRegistrations(Chat.class);
|
||||
for (RegisteredServiceProvider<Chat> chat : chats) {
|
||||
Chat c = chat.getProvider();
|
||||
if (registeredChats == null) {
|
||||
registeredChats = c.getName();
|
||||
registeredChats = new StringBuilder(c.getName());
|
||||
} else {
|
||||
registeredChats += ", " + c.getName();
|
||||
registeredChats.append(", ").append(c.getName());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -416,9 +402,9 @@ public class Vault extends JavaPlugin {
|
|||
}
|
||||
// Send user some info!
|
||||
sender.sendMessage(String.format("[%s] Vault v%s Information", getDescription().getName(), getDescription().getVersion()));
|
||||
sender.sendMessage(String.format("[%s] Economy: %s [%s]", getDescription().getName(), econ == null ? "None" : econ.getName(), registeredEcons));
|
||||
sender.sendMessage(String.format("[%s] Permission: %s [%s]", getDescription().getName(), perm == null ? "None" : perm.getName(), registeredPerms));
|
||||
sender.sendMessage(String.format("[%s] Chat: %s [%s]", getDescription().getName(), chat == null ? "None" : chat.getName(), registeredChats));
|
||||
sender.sendMessage(String.format("[%s] Economy: %s %s", getDescription().getName(), econ == null ? "None" : econ.getName(), registeredEcons == null ? "" : "[" + registeredEcons + "]"));
|
||||
sender.sendMessage(String.format("[%s] Permission: %s %s", getDescription().getName(), perm == null ? "None" : perm.getName(), registeredPerms == null ? "" : "[" + registeredPerms + "]"));
|
||||
sender.sendMessage(String.format("[%s] Chat: %s %s", getDescription().getName(), chat == null ? "None" : chat.getName(), registeredChats == null ? "" : "[" + registeredChats + "]"));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -457,7 +443,7 @@ public class Vault extends JavaPlugin {
|
|||
}
|
||||
// Pull the last version from the JSON
|
||||
newVersionTitle = ((String) ((JSONObject) array.get(array.size() - 1)).get("name")).replace("Vault", "").trim();
|
||||
return Double.valueOf(newVersionTitle.replaceFirst("\\.", "").trim());
|
||||
return Double.parseDouble(newVersionTitle.replaceFirst("\\.", "").trim());
|
||||
} catch (Exception e) {
|
||||
log.info("There was an issue attempting to check for the latest version.");
|
||||
}
|
||||
|
@ -472,21 +458,11 @@ public class Vault extends JavaPlugin {
|
|||
econ = rspEcon.getProvider();
|
||||
}
|
||||
final String econName = econ != null ? econ.getName() : "No Economy";
|
||||
metrics.addCustomChart(new SimplePie("economy", new Callable<String>() {
|
||||
@Override
|
||||
public String call() {
|
||||
return econName;
|
||||
}
|
||||
}));
|
||||
metrics.addCustomChart(new SimplePie("economy", () -> econName));
|
||||
|
||||
// Create our Permission Graph and Add our permission Plotters
|
||||
final String permName = Bukkit.getServer().getServicesManager().getRegistration(Permission.class).getProvider().getName();
|
||||
metrics.addCustomChart(new SimplePie("permission", new Callable<String>() {
|
||||
@Override
|
||||
public String call() {
|
||||
return permName;
|
||||
}
|
||||
}));
|
||||
metrics.addCustomChart(new SimplePie("permission", () -> permName));
|
||||
|
||||
// Create our Chat Graph and Add our chat Plotters
|
||||
RegisteredServiceProvider<Chat> rspChat = Bukkit.getServer().getServicesManager().getRegistration(Chat.class);
|
||||
|
@ -495,12 +471,7 @@ public class Vault extends JavaPlugin {
|
|||
chat = rspChat.getProvider();
|
||||
}
|
||||
final String chatName = chat != null ? chat.getName() : "No Chat";
|
||||
metrics.addCustomChart(new SimplePie("chat", new Callable<String>() {
|
||||
@Override
|
||||
public String call() {
|
||||
return chatName;
|
||||
}
|
||||
}));
|
||||
metrics.addCustomChart(new SimplePie("chat", () -> chatName));
|
||||
}
|
||||
|
||||
public class VaultListener implements Listener {
|
||||
|
@ -509,13 +480,9 @@ public class Vault extends JavaPlugin {
|
|||
public void onPlayerJoin(PlayerJoinEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
if (perms.has(player, "vault.update")) {
|
||||
try {
|
||||
if (newVersion > currentVersion) {
|
||||
player.sendMessage("Vault " + newVersionTitle + " is out! You are running " + currentVersionTitle);
|
||||
player.sendMessage("Update Vault at: " + VAULT_BUKKIT_URL);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// Ignore exceptions
|
||||
if (newVersion > currentVersion) {
|
||||
player.sendMessage("Vault " + newVersionTitle + " is out! You are running " + currentVersionTitle);
|
||||
player.sendMessage("Update Vault at: " + VAULT_BUKKIT_URL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,368 +1,362 @@
|
|||
/* This file is part of Vault.
|
||||
|
||||
Vault is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Vault is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with Vault. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package net.milkbowl.vault.chat.plugins;
|
||||
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import net.milkbowl.vault.chat.Chat;
|
||||
import net.milkbowl.vault.permission.Permission;
|
||||
|
||||
import org.anjocaido.groupmanager.GroupManager;
|
||||
import org.anjocaido.groupmanager.data.Group;
|
||||
import org.anjocaido.groupmanager.data.User;
|
||||
import org.anjocaido.groupmanager.dataholder.OverloadedWorldHolder;
|
||||
import org.anjocaido.groupmanager.permissions.AnjoPermissionsHandler;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.server.PluginDisableEvent;
|
||||
import org.bukkit.event.server.PluginEnableEvent;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
public class Chat_GroupManager extends Chat {
|
||||
|
||||
private final Logger log;
|
||||
private final String name = "GroupManager - Chat";
|
||||
private Plugin plugin = null;
|
||||
private GroupManager groupManager;
|
||||
|
||||
public Chat_GroupManager(Plugin plugin, Permission perms) {
|
||||
super(perms);
|
||||
this.plugin = plugin;
|
||||
this.log = plugin.getLogger();
|
||||
Bukkit.getServer().getPluginManager().registerEvents(new PermissionServerListener(this), plugin);
|
||||
|
||||
// Load Plugin in case it was loaded before
|
||||
if (groupManager == null) {
|
||||
Plugin chat = plugin.getServer().getPluginManager().getPlugin("GroupManager");
|
||||
if (chat != null) {
|
||||
if (chat.isEnabled()) {
|
||||
groupManager = (GroupManager) chat;
|
||||
log.info(String.format("[%s][Chat] %s hooked.", plugin.getDescription().getName(), name));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class PermissionServerListener implements Listener {
|
||||
|
||||
Chat_GroupManager chat = null;
|
||||
|
||||
public PermissionServerListener(Chat_GroupManager chat) {
|
||||
this.chat = chat;
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPluginEnable(PluginEnableEvent event) {
|
||||
if (chat.groupManager == null) {
|
||||
Plugin perms = event.getPlugin();
|
||||
|
||||
if (perms.getDescription().getName().equals("GroupManager")) {
|
||||
chat.groupManager = (GroupManager) perms;
|
||||
log.info(String.format("[%s][Chat] %s hooked.", plugin.getDescription().getName(), chat.name));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPluginDisable(PluginDisableEvent event) {
|
||||
if (chat.groupManager != null) {
|
||||
if (event.getPlugin().getDescription().getName().equals("GroupManager")) {
|
||||
chat.groupManager = null;
|
||||
log.info(String.format("[%s][Chat] %s un-hooked.", plugin.getDescription().getName(), chat.name));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
if (groupManager == null) {
|
||||
return false;
|
||||
} else {
|
||||
return groupManager.isEnabled();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPlayerInfoInteger(String worldName, String playerName, String node, int defaultValue) {
|
||||
AnjoPermissionsHandler handler;
|
||||
if (worldName == null) {
|
||||
handler = groupManager.getWorldsHolder().getWorldPermissionsByPlayerName(playerName);
|
||||
} else {
|
||||
handler = groupManager.getWorldsHolder().getWorldPermissions(worldName);
|
||||
}
|
||||
if (handler == null) {
|
||||
return defaultValue;
|
||||
}
|
||||
Integer val = handler.getUserPermissionInteger(playerName, node);
|
||||
return val != null ? val : defaultValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayerInfoInteger(String worldName, String playerName, String node, int value) {
|
||||
setPlayerValue(worldName, playerName, node, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getGroupInfoInteger(String worldName, String groupName, String node, int defaultValue) {
|
||||
AnjoPermissionsHandler handler;
|
||||
if (worldName == null) {
|
||||
handler = groupManager.getWorldsHolder().getDefaultWorld().getPermissionsHandler();
|
||||
} else {
|
||||
handler = groupManager.getWorldsHolder().getWorldPermissions(worldName);
|
||||
}
|
||||
if (handler == null) {
|
||||
return defaultValue;
|
||||
}
|
||||
Integer val = handler.getGroupPermissionInteger(groupName, node);
|
||||
return val != null ? val : defaultValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGroupInfoInteger(String worldName, String groupName, String node, int value) {
|
||||
setGroupValue(worldName, groupName, node, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getPlayerInfoDouble(String worldName, String playerName, String node, double defaultValue) {
|
||||
AnjoPermissionsHandler handler;
|
||||
if (worldName == null) {
|
||||
handler = groupManager.getWorldsHolder().getWorldPermissionsByPlayerName(playerName);
|
||||
} else {
|
||||
handler = groupManager.getWorldsHolder().getWorldPermissions(worldName);
|
||||
}
|
||||
if (handler == null) {
|
||||
return defaultValue;
|
||||
}
|
||||
Double val = handler.getUserPermissionDouble(playerName, node);
|
||||
return val != null ? val : defaultValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayerInfoDouble(String worldName, String playerName, String node, double value) {
|
||||
setPlayerValue(worldName, playerName, node, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getGroupInfoDouble(String worldName, String groupName, String node, double defaultValue) {
|
||||
AnjoPermissionsHandler handler;
|
||||
if (worldName == null) {
|
||||
handler = groupManager.getWorldsHolder().getDefaultWorld().getPermissionsHandler();
|
||||
} else {
|
||||
handler = groupManager.getWorldsHolder().getWorldPermissions(worldName);
|
||||
}
|
||||
if (handler == null) {
|
||||
return defaultValue;
|
||||
}
|
||||
Double val = handler.getGroupPermissionDouble(groupName, node);
|
||||
return val != null ? val : defaultValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGroupInfoDouble(String worldName, String groupName, String node, double value) {
|
||||
setGroupValue(worldName, groupName, node, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getPlayerInfoBoolean(String worldName, String playerName, String node, boolean defaultValue) {
|
||||
AnjoPermissionsHandler handler;
|
||||
if (worldName == null) {
|
||||
handler = groupManager.getWorldsHolder().getWorldPermissionsByPlayerName(playerName);
|
||||
} else {
|
||||
handler = groupManager.getWorldsHolder().getWorldPermissions(worldName);
|
||||
}
|
||||
if (handler == null) {
|
||||
return defaultValue;
|
||||
}
|
||||
Boolean val = handler.getUserPermissionBoolean(playerName, node);
|
||||
return val != null ? val : defaultValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayerInfoBoolean(String worldName, String playerName, String node, boolean value) {
|
||||
setPlayerValue(worldName, playerName, node, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getGroupInfoBoolean(String worldName, String groupName, String node, boolean defaultValue) {
|
||||
AnjoPermissionsHandler handler;
|
||||
if (worldName == null) {
|
||||
handler = groupManager.getWorldsHolder().getDefaultWorld().getPermissionsHandler();
|
||||
} else {
|
||||
handler = groupManager.getWorldsHolder().getWorldPermissions(worldName);
|
||||
}
|
||||
if (handler == null) {
|
||||
return defaultValue;
|
||||
}
|
||||
Boolean val = handler.getGroupPermissionBoolean(groupName, node);
|
||||
return val != null ? val : defaultValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGroupInfoBoolean(String worldName, String groupName, String node, boolean value) {
|
||||
setGroupValue(worldName, groupName, node, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPlayerInfoString(String worldName, String playerName, String node, String defaultValue) {
|
||||
AnjoPermissionsHandler handler;
|
||||
if (worldName == null) {
|
||||
handler = groupManager.getWorldsHolder().getWorldPermissionsByPlayerName(playerName);
|
||||
} else {
|
||||
handler = groupManager.getWorldsHolder().getWorldPermissions(worldName);
|
||||
}
|
||||
if (handler == null) {
|
||||
return defaultValue;
|
||||
}
|
||||
String val = handler.getUserPermissionString(playerName, node);
|
||||
return val != null ? val : defaultValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayerInfoString(String worldName, String playerName, String node, String value) {
|
||||
setPlayerValue(worldName, playerName, node, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGroupInfoString(String worldName, String groupName, String node, String defaultValue) {
|
||||
AnjoPermissionsHandler handler;
|
||||
if (worldName == null) {
|
||||
handler = groupManager.getWorldsHolder().getDefaultWorld().getPermissionsHandler();
|
||||
} else {
|
||||
handler = groupManager.getWorldsHolder().getWorldPermissions(worldName);
|
||||
}
|
||||
if (handler == null) {
|
||||
return defaultValue;
|
||||
}
|
||||
String val = handler.getGroupPermissionString(groupName, node);
|
||||
return val != null ? val : defaultValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGroupInfoString(String worldName, String groupName, String node, String value) {
|
||||
setGroupValue(worldName, groupName, node, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPlayerPrefix(String worldName, String playerName) {
|
||||
AnjoPermissionsHandler handler;
|
||||
if (worldName == null) {
|
||||
handler = groupManager.getWorldsHolder().getWorldPermissionsByPlayerName(playerName);
|
||||
} else {
|
||||
handler = groupManager.getWorldsHolder().getWorldPermissions(worldName);
|
||||
}
|
||||
if (handler == null) {
|
||||
return "";
|
||||
}
|
||||
return handler.getUserPrefix(playerName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPlayerSuffix(String worldName, String playerName) {
|
||||
AnjoPermissionsHandler handler;
|
||||
if (worldName == null) {
|
||||
handler = groupManager.getWorldsHolder().getWorldPermissionsByPlayerName(playerName);
|
||||
} else {
|
||||
handler = groupManager.getWorldsHolder().getWorldPermissions(worldName);
|
||||
}
|
||||
if (handler == null) {
|
||||
return "";
|
||||
}
|
||||
return handler.getUserSuffix(playerName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayerSuffix(String worldName, String player, String suffix) {
|
||||
setPlayerInfoString(worldName, player, "suffix", suffix);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayerPrefix(String worldName, String player, String prefix) {
|
||||
setPlayerInfoString(worldName, player, "prefix", prefix);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGroupPrefix(String worldName, String group) {
|
||||
return getGroupInfoString(worldName, group, "prefix", "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGroupPrefix(String worldName, String group, String prefix) {
|
||||
setGroupInfoString(worldName, group, "prefix", prefix);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGroupSuffix(String worldName, String group) {
|
||||
return getGroupInfoString(worldName, group, "suffix", "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGroupSuffix(String worldName, String group, String suffix) {
|
||||
setGroupInfoString(worldName, group, "suffix", suffix);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPrimaryGroup(String worldName, String playerName) {
|
||||
AnjoPermissionsHandler handler;
|
||||
if (worldName == null) {
|
||||
handler = groupManager.getWorldsHolder().getWorldPermissionsByPlayerName(playerName);
|
||||
} else {
|
||||
handler = groupManager.getWorldsHolder().getWorldPermissions(worldName);
|
||||
}
|
||||
return handler.getGroup(playerName);
|
||||
}
|
||||
|
||||
private void setPlayerValue(String worldName, String playerName, String node, Object value) {
|
||||
OverloadedWorldHolder owh;
|
||||
if (worldName == null) {
|
||||
owh = groupManager.getWorldsHolder().getWorldDataByPlayerName(playerName);
|
||||
} else {
|
||||
owh = groupManager.getWorldsHolder().getWorldData(worldName);
|
||||
}
|
||||
if (owh == null) {
|
||||
return;
|
||||
}
|
||||
User user = owh.getUser(playerName);
|
||||
if (user == null) {
|
||||
return;
|
||||
}
|
||||
user.getVariables().addVar(node, value);
|
||||
}
|
||||
|
||||
private void setGroupValue(String worldName, String groupName, String node, Object value) {
|
||||
OverloadedWorldHolder owh;
|
||||
if (worldName == null) {
|
||||
owh = groupManager.getWorldsHolder().getDefaultWorld();
|
||||
} else {
|
||||
owh = groupManager.getWorldsHolder().getWorldData(worldName);
|
||||
}
|
||||
if (owh == null) {
|
||||
return;
|
||||
}
|
||||
Group group = owh.getGroup(groupName);
|
||||
if (group == null) {
|
||||
return;
|
||||
}
|
||||
group.getVariables().addVar(node, value);
|
||||
}
|
||||
}
|
||||
/* This file is part of Vault.
|
||||
|
||||
Vault is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Vault is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with Vault. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package net.milkbowl.vault.chat.plugins;
|
||||
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import net.milkbowl.vault.chat.Chat;
|
||||
import net.milkbowl.vault.permission.Permission;
|
||||
|
||||
import org.anjocaido.groupmanager.GroupManager;
|
||||
import org.anjocaido.groupmanager.data.Group;
|
||||
import org.anjocaido.groupmanager.data.User;
|
||||
import org.anjocaido.groupmanager.dataholder.OverloadedWorldHolder;
|
||||
import org.anjocaido.groupmanager.permissions.AnjoPermissionsHandler;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.server.PluginDisableEvent;
|
||||
import org.bukkit.event.server.PluginEnableEvent;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
public class Chat_GroupManager extends Chat {
|
||||
|
||||
private final Logger log;
|
||||
private final String name = "GroupManager - Chat";
|
||||
private final Plugin plugin;
|
||||
private GroupManager groupManager;
|
||||
|
||||
public Chat_GroupManager(Plugin plugin, Permission perms) {
|
||||
super(perms);
|
||||
this.plugin = plugin;
|
||||
this.log = plugin.getLogger();
|
||||
Bukkit.getServer().getPluginManager().registerEvents(new PermissionServerListener(this), plugin);
|
||||
|
||||
// Load Plugin in case it was loaded before
|
||||
if (groupManager == null) {
|
||||
Plugin chat = plugin.getServer().getPluginManager().getPlugin("GroupManager");
|
||||
if (chat != null) {
|
||||
if (chat.isEnabled()) {
|
||||
groupManager = (GroupManager) chat;
|
||||
log.info(String.format("[%s][Chat] %s hooked.", plugin.getDescription().getName(), name));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class PermissionServerListener implements Listener {
|
||||
|
||||
Chat_GroupManager chat;
|
||||
|
||||
public PermissionServerListener(Chat_GroupManager chat) {
|
||||
this.chat = chat;
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPluginEnable(PluginEnableEvent event) {
|
||||
if (chat.groupManager == null) {
|
||||
Plugin perms = event.getPlugin();
|
||||
|
||||
if (perms.getDescription().getName().equals("GroupManager")) {
|
||||
chat.groupManager = (GroupManager) perms;
|
||||
log.info(String.format("[%s][Chat] %s hooked.", plugin.getDescription().getName(), chat.name));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPluginDisable(PluginDisableEvent event) {
|
||||
if (chat.groupManager != null) {
|
||||
if (event.getPlugin().getDescription().getName().equals("GroupManager")) {
|
||||
chat.groupManager = null;
|
||||
log.info(String.format("[%s][Chat] %s un-hooked.", plugin.getDescription().getName(), chat.name));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
if (groupManager == null) {
|
||||
return false;
|
||||
} else {
|
||||
return groupManager.isEnabled();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPlayerInfoInteger(String worldName, String playerName, String node, int defaultValue) {
|
||||
AnjoPermissionsHandler handler;
|
||||
if (worldName == null) {
|
||||
handler = groupManager.getWorldsHolder().getWorldPermissionsByPlayerName(playerName);
|
||||
} else {
|
||||
handler = groupManager.getWorldsHolder().getWorldPermissions(worldName);
|
||||
}
|
||||
if (handler == null) {
|
||||
return defaultValue;
|
||||
}
|
||||
return handler.getUserPermissionInteger(playerName, node);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayerInfoInteger(String worldName, String playerName, String node, int value) {
|
||||
setPlayerValue(worldName, playerName, node, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getGroupInfoInteger(String worldName, String groupName, String node, int defaultValue) {
|
||||
AnjoPermissionsHandler handler;
|
||||
if (worldName == null) {
|
||||
handler = groupManager.getWorldsHolder().getDefaultWorld().getPermissionsHandler();
|
||||
} else {
|
||||
handler = groupManager.getWorldsHolder().getWorldPermissions(worldName);
|
||||
}
|
||||
if (handler == null) {
|
||||
return defaultValue;
|
||||
}
|
||||
return handler.getGroupPermissionInteger(groupName, node);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGroupInfoInteger(String worldName, String groupName, String node, int value) {
|
||||
setGroupValue(worldName, groupName, node, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getPlayerInfoDouble(String worldName, String playerName, String node, double defaultValue) {
|
||||
AnjoPermissionsHandler handler;
|
||||
if (worldName == null) {
|
||||
handler = groupManager.getWorldsHolder().getWorldPermissionsByPlayerName(playerName);
|
||||
} else {
|
||||
handler = groupManager.getWorldsHolder().getWorldPermissions(worldName);
|
||||
}
|
||||
if (handler == null) {
|
||||
return defaultValue;
|
||||
}
|
||||
return handler.getUserPermissionDouble(playerName, node);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayerInfoDouble(String worldName, String playerName, String node, double value) {
|
||||
setPlayerValue(worldName, playerName, node, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getGroupInfoDouble(String worldName, String groupName, String node, double defaultValue) {
|
||||
AnjoPermissionsHandler handler;
|
||||
if (worldName == null) {
|
||||
handler = groupManager.getWorldsHolder().getDefaultWorld().getPermissionsHandler();
|
||||
} else {
|
||||
handler = groupManager.getWorldsHolder().getWorldPermissions(worldName);
|
||||
}
|
||||
if (handler == null) {
|
||||
return defaultValue;
|
||||
}
|
||||
return handler.getGroupPermissionDouble(groupName, node);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGroupInfoDouble(String worldName, String groupName, String node, double value) {
|
||||
setGroupValue(worldName, groupName, node, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getPlayerInfoBoolean(String worldName, String playerName, String node, boolean defaultValue) {
|
||||
AnjoPermissionsHandler handler;
|
||||
if (worldName == null) {
|
||||
handler = groupManager.getWorldsHolder().getWorldPermissionsByPlayerName(playerName);
|
||||
} else {
|
||||
handler = groupManager.getWorldsHolder().getWorldPermissions(worldName);
|
||||
}
|
||||
if (handler == null) {
|
||||
return defaultValue;
|
||||
}
|
||||
return handler.getUserPermissionBoolean(playerName, node);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayerInfoBoolean(String worldName, String playerName, String node, boolean value) {
|
||||
setPlayerValue(worldName, playerName, node, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getGroupInfoBoolean(String worldName, String groupName, String node, boolean defaultValue) {
|
||||
AnjoPermissionsHandler handler;
|
||||
if (worldName == null) {
|
||||
handler = groupManager.getWorldsHolder().getDefaultWorld().getPermissionsHandler();
|
||||
} else {
|
||||
handler = groupManager.getWorldsHolder().getWorldPermissions(worldName);
|
||||
}
|
||||
if (handler == null) {
|
||||
return defaultValue;
|
||||
}
|
||||
return handler.getGroupPermissionBoolean(groupName, node);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGroupInfoBoolean(String worldName, String groupName, String node, boolean value) {
|
||||
setGroupValue(worldName, groupName, node, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPlayerInfoString(String worldName, String playerName, String node, String defaultValue) {
|
||||
AnjoPermissionsHandler handler;
|
||||
if (worldName == null) {
|
||||
handler = groupManager.getWorldsHolder().getWorldPermissionsByPlayerName(playerName);
|
||||
} else {
|
||||
handler = groupManager.getWorldsHolder().getWorldPermissions(worldName);
|
||||
}
|
||||
if (handler == null) {
|
||||
return defaultValue;
|
||||
}
|
||||
String val = handler.getUserPermissionString(playerName, node);
|
||||
return val != null ? val : defaultValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayerInfoString(String worldName, String playerName, String node, String value) {
|
||||
setPlayerValue(worldName, playerName, node, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGroupInfoString(String worldName, String groupName, String node, String defaultValue) {
|
||||
AnjoPermissionsHandler handler;
|
||||
if (worldName == null) {
|
||||
handler = groupManager.getWorldsHolder().getDefaultWorld().getPermissionsHandler();
|
||||
} else {
|
||||
handler = groupManager.getWorldsHolder().getWorldPermissions(worldName);
|
||||
}
|
||||
if (handler == null) {
|
||||
return defaultValue;
|
||||
}
|
||||
String val = handler.getGroupPermissionString(groupName, node);
|
||||
return val != null ? val : defaultValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGroupInfoString(String worldName, String groupName, String node, String value) {
|
||||
setGroupValue(worldName, groupName, node, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPlayerPrefix(String worldName, String playerName) {
|
||||
AnjoPermissionsHandler handler;
|
||||
if (worldName == null) {
|
||||
handler = groupManager.getWorldsHolder().getWorldPermissionsByPlayerName(playerName);
|
||||
} else {
|
||||
handler = groupManager.getWorldsHolder().getWorldPermissions(worldName);
|
||||
}
|
||||
if (handler == null) {
|
||||
return "";
|
||||
}
|
||||
return handler.getUserPrefix(playerName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPlayerSuffix(String worldName, String playerName) {
|
||||
AnjoPermissionsHandler handler;
|
||||
if (worldName == null) {
|
||||
handler = groupManager.getWorldsHolder().getWorldPermissionsByPlayerName(playerName);
|
||||
} else {
|
||||
handler = groupManager.getWorldsHolder().getWorldPermissions(worldName);
|
||||
}
|
||||
if (handler == null) {
|
||||
return "";
|
||||
}
|
||||
return handler.getUserSuffix(playerName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayerSuffix(String worldName, String player, String suffix) {
|
||||
setPlayerInfoString(worldName, player, "suffix", suffix);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayerPrefix(String worldName, String player, String prefix) {
|
||||
setPlayerInfoString(worldName, player, "prefix", prefix);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGroupPrefix(String worldName, String group) {
|
||||
return getGroupInfoString(worldName, group, "prefix", "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGroupPrefix(String worldName, String group, String prefix) {
|
||||
setGroupInfoString(worldName, group, "prefix", prefix);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGroupSuffix(String worldName, String group) {
|
||||
return getGroupInfoString(worldName, group, "suffix", "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGroupSuffix(String worldName, String group, String suffix) {
|
||||
setGroupInfoString(worldName, group, "suffix", suffix);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPrimaryGroup(String worldName, String playerName) {
|
||||
AnjoPermissionsHandler handler;
|
||||
if (worldName == null) {
|
||||
handler = groupManager.getWorldsHolder().getWorldPermissionsByPlayerName(playerName);
|
||||
} else {
|
||||
handler = groupManager.getWorldsHolder().getWorldPermissions(worldName);
|
||||
}
|
||||
return handler.getGroup(playerName);
|
||||
}
|
||||
|
||||
private void setPlayerValue(String worldName, String playerName, String node, Object value) {
|
||||
OverloadedWorldHolder owh;
|
||||
if (worldName == null) {
|
||||
owh = groupManager.getWorldsHolder().getWorldDataByPlayerName(playerName);
|
||||
} else {
|
||||
owh = groupManager.getWorldsHolder().getWorldData(worldName);
|
||||
}
|
||||
if (owh == null) {
|
||||
return;
|
||||
}
|
||||
User user = owh.getUser(playerName);
|
||||
if (user == null) {
|
||||
return;
|
||||
}
|
||||
user.getVariables().addVar(node, value);
|
||||
}
|
||||
|
||||
private void setGroupValue(String worldName, String groupName, String node, Object value) {
|
||||
OverloadedWorldHolder owh;
|
||||
if (worldName == null) {
|
||||
owh = groupManager.getWorldsHolder().getDefaultWorld();
|
||||
} else {
|
||||
owh = groupManager.getWorldsHolder().getWorldData(worldName);
|
||||
}
|
||||
if (owh == null) {
|
||||
return;
|
||||
}
|
||||
Group group = owh.getGroup(groupName);
|
||||
if (group == null) {
|
||||
return;
|
||||
}
|
||||
group.getVariables().addVar(node, value);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,7 +37,7 @@ public class Chat_PermissionsEx extends Chat {
|
|||
private final Logger log;
|
||||
private final String name = "PermissionsEx_Chat";
|
||||
|
||||
private Plugin plugin = null;
|
||||
private final Plugin plugin;
|
||||
private PermissionsEx chat = null;
|
||||
|
||||
public Chat_PermissionsEx(Plugin plugin, Permission perms) {
|
||||
|
@ -60,7 +60,7 @@ public class Chat_PermissionsEx extends Chat {
|
|||
}
|
||||
|
||||
public class PermissionServerListener implements Listener {
|
||||
Chat_PermissionsEx chat = null;
|
||||
Chat_PermissionsEx chat;
|
||||
|
||||
public PermissionServerListener(Chat_PermissionsEx chat) {
|
||||
this.chat = chat;
|
||||
|
@ -221,9 +221,7 @@ public class Chat_PermissionsEx extends Chat {
|
|||
@Override
|
||||
public void setGroupInfoInteger(String world, String groupName, String node, int value) {
|
||||
PermissionGroup group = PermissionsEx.getPermissionManager().getGroup(groupName);
|
||||
if (group == null) {
|
||||
return;
|
||||
} else {
|
||||
if (group != null) {
|
||||
group.setOption(node, world, String.valueOf(value));
|
||||
}
|
||||
}
|
||||
|
@ -241,9 +239,7 @@ public class Chat_PermissionsEx extends Chat {
|
|||
@Override
|
||||
public void setGroupInfoDouble(String world, String groupName, String node, double value) {
|
||||
PermissionGroup group = PermissionsEx.getPermissionManager().getGroup(groupName);
|
||||
if (group == null) {
|
||||
return;
|
||||
} else {
|
||||
if (group != null) {
|
||||
group.setOption(node, world, String.valueOf(value));
|
||||
}
|
||||
}
|
||||
|
@ -261,9 +257,7 @@ public class Chat_PermissionsEx extends Chat {
|
|||
@Override
|
||||
public void setGroupInfoBoolean(String world, String groupName, String node, boolean value) {
|
||||
PermissionGroup group = PermissionsEx.getPermissionManager().getGroup(groupName);
|
||||
if (group == null) {
|
||||
return;
|
||||
} else {
|
||||
if (group != null) {
|
||||
group.setOption(node, world, String.valueOf(value));
|
||||
}
|
||||
}
|
||||
|
@ -281,9 +275,7 @@ public class Chat_PermissionsEx extends Chat {
|
|||
@Override
|
||||
public void setGroupInfoString(String world, String groupName, String node, String value) {
|
||||
PermissionGroup group = PermissionsEx.getPermissionManager().getGroup(groupName);
|
||||
if (group == null) {
|
||||
return;
|
||||
} else {
|
||||
if (group != null) {
|
||||
group.setOption(node, world, value);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,8 +34,8 @@ import de.bananaco.bpermissions.api.CalculableType;
|
|||
public class Chat_bPermissions2 extends Chat {
|
||||
private final Logger log;
|
||||
private final String name = "bInfo";
|
||||
private Plugin plugin = null;
|
||||
private boolean hooked = false;
|
||||
private final Plugin plugin;
|
||||
private boolean hooked;
|
||||
|
||||
public Chat_bPermissions2(Plugin plugin, Permission perms) {
|
||||
super(perms);
|
||||
|
@ -55,7 +55,7 @@ public class Chat_bPermissions2 extends Chat {
|
|||
}
|
||||
|
||||
public class PermissionServerListener implements Listener {
|
||||
Chat_bPermissions2 chat = null;
|
||||
Chat_bPermissions2 chat;
|
||||
|
||||
public PermissionServerListener(Chat_bPermissions2 chat) {
|
||||
this.chat = chat;
|
||||
|
@ -140,8 +140,7 @@ public class Chat_bPermissions2 extends Chat {
|
|||
return defaultValue;
|
||||
}
|
||||
try {
|
||||
int i = Integer.valueOf(s);
|
||||
return i;
|
||||
return Integer.parseInt(s);
|
||||
} catch (NumberFormatException e) {
|
||||
return defaultValue;
|
||||
}
|
||||
|
@ -159,8 +158,7 @@ public class Chat_bPermissions2 extends Chat {
|
|||
return defaultValue;
|
||||
}
|
||||
try {
|
||||
int i = Integer.valueOf(s);
|
||||
return i;
|
||||
return Integer.parseInt(s);
|
||||
} catch (NumberFormatException e) {
|
||||
return defaultValue;
|
||||
}
|
||||
|
@ -178,8 +176,7 @@ public class Chat_bPermissions2 extends Chat {
|
|||
return defaultValue;
|
||||
}
|
||||
try {
|
||||
double d = Double.valueOf(s);
|
||||
return d;
|
||||
return Double.parseDouble(s);
|
||||
} catch (NumberFormatException e) {
|
||||
return defaultValue;
|
||||
}
|
||||
|
@ -197,8 +194,7 @@ public class Chat_bPermissions2 extends Chat {
|
|||
return defaultValue;
|
||||
}
|
||||
try {
|
||||
double d = Double.valueOf(s);
|
||||
return d;
|
||||
return Double.parseDouble(s);
|
||||
} catch (NumberFormatException e) {
|
||||
return defaultValue;
|
||||
}
|
||||
|
@ -215,8 +211,7 @@ public class Chat_bPermissions2 extends Chat {
|
|||
if (s == null) {
|
||||
return defaultValue;
|
||||
} else {
|
||||
Boolean val = Boolean.valueOf(s);
|
||||
return val != null ? val : defaultValue;
|
||||
return Boolean.parseBoolean(s);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -231,20 +226,19 @@ public class Chat_bPermissions2 extends Chat {
|
|||
if (s == null) {
|
||||
return defaultValue;
|
||||
} else {
|
||||
Boolean val = Boolean.valueOf(s);
|
||||
return val != null ? val : defaultValue;
|
||||
return Boolean.parseBoolean(s);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGroupInfoBoolean(String world, String group, String node, boolean value) {
|
||||
ApiLayer.setValue(world, CalculableType.GROUP, group, node, String.valueOf(value));;
|
||||
ApiLayer.setValue(world, CalculableType.GROUP, group, node, String.valueOf(value));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPlayerInfoString(String world, String player, String node, String defaultValue) {
|
||||
String val = ApiLayer.getValue(world, CalculableType.USER, player, node);
|
||||
return (val == null || val == "BLANKWORLD" || val == "") ? defaultValue : val;
|
||||
return (val == null || val.equals("BLANKWORLD") || val.equals("")) ? defaultValue : val;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -255,7 +249,7 @@ public class Chat_bPermissions2 extends Chat {
|
|||
@Override
|
||||
public String getGroupInfoString(String world, String group, String node, String defaultValue) {
|
||||
String val = ApiLayer.getValue(world, CalculableType.GROUP, group, node);
|
||||
return (val == null || val == "BLANKWORLD" || val == "") ? defaultValue : val;
|
||||
return (val == null || val.equals("BLANKWORLD") || val.equals("")) ? defaultValue : val;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -56,7 +56,7 @@ public class Permission_GroupManager extends Permission {
|
|||
}
|
||||
|
||||
public class PermissionServerListener implements Listener {
|
||||
Permission_GroupManager permission = null;
|
||||
Permission_GroupManager permission;
|
||||
|
||||
public PermissionServerListener(Permission_GroupManager permission) {
|
||||
this.permission = permission;
|
||||
|
@ -332,7 +332,7 @@ public class Permission_GroupManager extends Permission {
|
|||
|
||||
@Override
|
||||
public String[] getGroups() {
|
||||
Set<String> groupNames = new HashSet<String>();
|
||||
Set<String> groupNames = new HashSet<>();
|
||||
for (World world : Bukkit.getServer().getWorlds()) {
|
||||
OverloadedWorldHolder owh = groupManager.getWorldsHolder().getWorldData(world.getName());
|
||||
if (owh == null) {
|
||||
|
|
|
@ -36,7 +36,7 @@ import ru.tehkode.permissions.bukkit.PermissionsEx;
|
|||
public class Permission_PermissionsEx extends Permission {
|
||||
|
||||
private final String name = "PermissionsEx";
|
||||
private PermissionsEx permission = null;
|
||||
private PermissionsEx permission;
|
||||
|
||||
public Permission_PermissionsEx(Plugin plugin) {
|
||||
this.plugin = plugin;
|
||||
|
@ -48,7 +48,7 @@ public class Permission_PermissionsEx extends Permission {
|
|||
if (perms != null) {
|
||||
if (perms.isEnabled()) {
|
||||
try {
|
||||
if (Double.valueOf(perms.getDescription().getVersion()) < 1.16) {
|
||||
if (Double.parseDouble(perms.getDescription().getVersion()) < 1.16) {
|
||||
log.info(String.format("[%s][Permission] %s below 1.16 is not compatible with Vault! Falling back to SuperPerms only mode. PLEASE UPDATE!", plugin.getDescription().getName(), name));
|
||||
}
|
||||
} catch (NumberFormatException e) {
|
||||
|
@ -71,7 +71,7 @@ public class Permission_PermissionsEx extends Permission {
|
|||
}
|
||||
|
||||
public class PermissionServerListener implements Listener {
|
||||
Permission_PermissionsEx permission = null;
|
||||
Permission_PermissionsEx permission;
|
||||
|
||||
public PermissionServerListener(Permission_PermissionsEx permission) {
|
||||
this.permission = permission;
|
||||
|
@ -83,7 +83,7 @@ public class Permission_PermissionsEx extends Permission {
|
|||
Plugin perms = event.getPlugin();
|
||||
if (perms.getDescription().getName().equals("PermissionsEx")) {
|
||||
try {
|
||||
if (Double.valueOf(perms.getDescription().getVersion()) < 1.16) {
|
||||
if (Double.parseDouble(perms.getDescription().getVersion()) < 1.16) {
|
||||
log.info(String.format("[%s][Permission] %s below 1.16 is not compatible with Vault! Falling back to SuperPerms only mode. PLEASE UPDATE!", plugin.getDescription().getName(), name));
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -41,7 +41,7 @@ public class Permission_SuperPerms extends Permission {
|
|||
@Override
|
||||
public boolean playerHas(String world, String player, String permission) {
|
||||
Player p = plugin.getServer().getPlayer(player);
|
||||
return p != null ? p.hasPermission(permission) : false;
|
||||
return p != null && p.hasPermission(permission);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -39,7 +39,7 @@ import de.bananaco.bpermissions.api.CalculableType;
|
|||
public class Permission_bPermissions2 extends Permission {
|
||||
|
||||
private final String name = "bPermissions2";
|
||||
private boolean hooked = false;
|
||||
private boolean hooked;
|
||||
|
||||
public Permission_bPermissions2(Plugin plugin) {
|
||||
this.plugin = plugin;
|
||||
|
@ -180,8 +180,8 @@ public class Permission_bPermissions2 extends Permission {
|
|||
|
||||
@Override
|
||||
public String[] getGroups() {
|
||||
String[] groups = null;
|
||||
Set<String> gSet = new HashSet<String>();
|
||||
String[] groups;
|
||||
Set<String> gSet = new HashSet<>();
|
||||
for(World world : WorldManager.getInstance().getAllWorlds()) {
|
||||
Set<Calculable> gr = world.getAll(CalculableType.GROUP);
|
||||
for(Calculable c : gr) {
|
||||
|
@ -189,7 +189,7 @@ public class Permission_bPermissions2 extends Permission {
|
|||
}
|
||||
}
|
||||
// Convert to String
|
||||
groups = gSet.toArray(new String[gSet.size()]);
|
||||
groups = gSet.toArray(new String[0]);
|
||||
return groups;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue