mirror of
https://github.com/MilkBowl/Vault.git
synced 2024-12-26 19:08:20 +01:00
Merge pull request #390 from ZerothAngel/master
Add Chat implementation for zPermissions
This commit is contained in:
commit
928a21b5a2
Binary file not shown.
2
pom.xml
2
pom.xml
@ -28,7 +28,7 @@
|
||||
<dependency>
|
||||
<groupId>org.tyrannyofheaven.bukkit</groupId>
|
||||
<artifactId>zPermissions</artifactId>
|
||||
<version>0.9.9</version>
|
||||
<version>0.9.18-SNAPSHOT</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${project.basedir}/lib/zPermissions.jar</systemPath>
|
||||
</dependency>
|
||||
|
@ -34,6 +34,7 @@ import net.milkbowl.vault.chat.plugins.Chat_bPermissions2;
|
||||
import net.milkbowl.vault.chat.plugins.Chat_iChat;
|
||||
import net.milkbowl.vault.chat.plugins.Chat_mChat;
|
||||
import net.milkbowl.vault.chat.plugins.Chat_mChatSuite;
|
||||
import net.milkbowl.vault.chat.plugins.Chat_zPermissions;
|
||||
import net.milkbowl.vault.economy.Economy;
|
||||
import net.milkbowl.vault.economy.plugins.Economy_3co;
|
||||
import net.milkbowl.vault.economy.plugins.Economy_AEco;
|
||||
@ -191,6 +192,9 @@ public class Vault extends JavaPlugin {
|
||||
|
||||
// Try to load iChat
|
||||
hookChat("iChat", Chat_iChat.class, ServicePriority.Low, "net.TheDgtl.iChat.iChat");
|
||||
|
||||
// Try to load zPermissions
|
||||
hookChat("zPermissions", Chat_zPermissions.class, ServicePriority.Normal, "org.tyrannyofheaven.bukkit.zPermissions.model.EntityMetadata");
|
||||
}
|
||||
|
||||
/**
|
||||
|
242
src/net/milkbowl/vault/chat/plugins/Chat_zPermissions.java
Normal file
242
src/net/milkbowl/vault/chat/plugins/Chat_zPermissions.java
Normal file
@ -0,0 +1,242 @@
|
||||
/* 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.bukkit.Bukkit;
|
||||
import org.bukkit.command.ConsoleCommandSender;
|
||||
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;
|
||||
import org.tyrannyofheaven.bukkit.zPermissions.ZPermissionsService;
|
||||
|
||||
public class Chat_zPermissions extends Chat {
|
||||
|
||||
private static final Logger log = Logger.getLogger("Minecraft");
|
||||
|
||||
private final String name = "zPermissions";
|
||||
|
||||
private final Plugin plugin;
|
||||
|
||||
private ZPermissionsService service;
|
||||
|
||||
private final ConsoleCommandSender ccs;
|
||||
|
||||
public Chat_zPermissions(Plugin plugin, Permission perms) {
|
||||
super(perms);
|
||||
this.plugin = plugin;
|
||||
ccs = Bukkit.getServer().getConsoleSender();
|
||||
Bukkit.getServer().getPluginManager().registerEvents(new PermissionServerListener(), plugin);
|
||||
// Load service in case it was loaded before
|
||||
if (service == null) {
|
||||
service = plugin.getServer().getServicesManager().load(ZPermissionsService.class);
|
||||
if (service != null)
|
||||
log.info(String.format("[%s][Chat] %s hooked.", plugin.getDescription().getName(), name));
|
||||
}
|
||||
}
|
||||
|
||||
public class PermissionServerListener implements Listener {
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPluginEnable(PluginEnableEvent event) {
|
||||
if (service == null) {
|
||||
service = plugin.getServer().getServicesManager().load(ZPermissionsService.class);
|
||||
if (service != null)
|
||||
log.info(String.format("[%s][Chat] %s hooked.", plugin.getDescription().getName(), name));
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPluginDisable(PluginDisableEvent event) {
|
||||
if (service != null) {
|
||||
if (event.getPlugin().getDescription().getName().equals("zPermissions")) {
|
||||
service = null;
|
||||
log.info(String.format("[%s][Chat] %s un-hooked.", plugin.getDescription().getName(), name));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
return service != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPlayerPrefix(String world, String player) {
|
||||
return service.getPlayerMetadata(player, "prefix", String.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayerPrefix(String world, String player, String prefix) {
|
||||
plugin.getServer().dispatchCommand(ccs, "permissions player " + player + " metadata set prefix " + prefix);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPlayerSuffix(String world, String player) {
|
||||
return service.getPlayerMetadata(player, "suffix", String.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayerSuffix(String world, String player, String suffix) {
|
||||
plugin.getServer().dispatchCommand(ccs, "permissions player " + player + " metadata set suffix " + suffix);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGroupPrefix(String world, String group) {
|
||||
return service.getGroupMetadata(group, "prefix", String.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGroupPrefix(String world, String group, String prefix) {
|
||||
plugin.getServer().dispatchCommand(ccs, "permissions group " + group + " metadata set prefix " + prefix);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGroupSuffix(String world, String group) {
|
||||
return service.getGroupMetadata(group, "suffix", String.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGroupSuffix(String world, String group, String suffix) {
|
||||
plugin.getServer().dispatchCommand(ccs, "permissions group " + group + " metadata set suffix " + suffix);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPlayerInfoInteger(String world, String player, String node, int defaultValue) {
|
||||
Integer result = service.getPlayerMetadata(player, node, Integer.class);
|
||||
if (result == null)
|
||||
return defaultValue;
|
||||
else
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayerInfoInteger(String world, String player, String node, int value) {
|
||||
plugin.getServer().dispatchCommand(ccs, "permissions player " + player + " metadata setint " + node + " " + value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getGroupInfoInteger(String world, String group, String node, int defaultValue) {
|
||||
Integer result = service.getGroupMetadata(group, node, Integer.class);
|
||||
if (result == null)
|
||||
return defaultValue;
|
||||
else
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGroupInfoInteger(String world, String group, String node, int value) {
|
||||
plugin.getServer().dispatchCommand(ccs, "permissions group " + group + " metadata setint " + node + " " + value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getPlayerInfoDouble(String world, String player, String node, double defaultValue) {
|
||||
Double result = service.getPlayerMetadata(player, node, Double.class);
|
||||
if (result == null)
|
||||
return defaultValue;
|
||||
else
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayerInfoDouble(String world, String player, String node, double value) {
|
||||
plugin.getServer().dispatchCommand(ccs, "permissions player " + player + " metadata setreal " + node + " " + value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getGroupInfoDouble(String world, String group, String node, double defaultValue) {
|
||||
Double result = service.getGroupMetadata(group, node, Double.class);
|
||||
if (result == null)
|
||||
return defaultValue;
|
||||
else
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGroupInfoDouble(String world, String group, String node, double value) {
|
||||
plugin.getServer().dispatchCommand(ccs, "permissions group " + group + " metadata setreal " + node + " " + value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getPlayerInfoBoolean(String world, String player, String node, boolean defaultValue) {
|
||||
Boolean result = service.getPlayerMetadata(player, node, Boolean.class);
|
||||
if (result == null)
|
||||
return defaultValue;
|
||||
else
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayerInfoBoolean(String world, String player, String node, boolean value) {
|
||||
plugin.getServer().dispatchCommand(ccs, "permissions player " + player + " metadata setbool " + node + " " + value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getGroupInfoBoolean(String world, String group, String node, boolean defaultValue) {
|
||||
Boolean result = service.getGroupMetadata(group, node, Boolean.class);
|
||||
if (result == null)
|
||||
return defaultValue;
|
||||
else
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGroupInfoBoolean(String world, String group, String node, boolean value) {
|
||||
plugin.getServer().dispatchCommand(ccs, "permissions group " + group + " metadata setbool " + node + " " + value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPlayerInfoString(String world, String player, String node, String defaultValue) {
|
||||
String result = service.getPlayerMetadata(player, node, String.class);
|
||||
if (result == null)
|
||||
return defaultValue;
|
||||
else
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayerInfoString(String world, String player, String node, String value) {
|
||||
plugin.getServer().dispatchCommand(ccs, "permissions player " + player + " metadata set " + node + " " + value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGroupInfoString(String world, String group, String node, String defaultValue) {
|
||||
String result = service.getGroupMetadata(group, node, String.class);
|
||||
if (result == null)
|
||||
return defaultValue;
|
||||
else
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGroupInfoString(String world, String group, String node, String value) {
|
||||
plugin.getServer().dispatchCommand(ccs, "permissions group " + group + " metadata set " + node + " " + value);
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user