updated libs - added mChat to Chat API

This commit is contained in:
Sleaker 2011-10-23 13:18:23 -07:00
parent b508e777fb
commit 60d4d59441
10 changed files with 216 additions and 107 deletions

Binary file not shown.

Binary file not shown.

BIN
lib/bpermissions.jar Normal file

Binary file not shown.

View File

@ -22,6 +22,11 @@ package net.milkbowl.vault;
import java.util.Collection;
import java.util.logging.Logger;
import net.milkbowl.vault.chat.Chat;
import net.milkbowl.vault.chat.plugins.Chat_GroupManager;
import net.milkbowl.vault.chat.plugins.Chat_Permissions3;
import net.milkbowl.vault.chat.plugins.Chat_PermissionsEx;
import net.milkbowl.vault.chat.plugins.Chat_mChat;
import net.milkbowl.vault.economy.Economy;
import net.milkbowl.vault.economy.plugins.Economy_3co;
import net.milkbowl.vault.economy.plugins.Economy_BOSE6;
@ -64,12 +69,64 @@ public class Vault extends JavaPlugin {
// Load Vault Addons
loadEconomy();
loadPermission();
loadChat();
getCommand("vault-info").setExecutor(this);
getCommand("vault-reload").setExecutor(this);
log.info(String.format("[%s] Enabled Version %s", getDescription().getName(), getDescription().getVersion()));
}
/**
* Attempts to load Chat Addons
*/
private void loadChat() {
// Try to load PermissionsEx
if (packageExists(new String[] { "ru.tehkode.permissions.bukkit.PermissionsEx" })) {
Chat eChat = new Chat_PermissionsEx(this);
getServer().getServicesManager().register(net.milkbowl.vault.chat.Chat.class, eChat, this, ServicePriority.Highest);
log.info(String.format("[%s][Chat] PermissionsEx found: %s", getDescription().getName(), eChat.isEnabled() ? "Loaded" : "Waiting"));
} else {
log.info(String.format("[%s][Chat] PermissionsEx not found.", getDescription().getName()));
}
//Try loading mChat
if (packageExists(new String[] {"net.D3GN.MiracleM4n.mChat"} )) {
Chat mChat = new Chat_mChat(this);
getServer().getServicesManager().register(net.milkbowl.vault.chat.Chat.class, mChat, this, ServicePriority.Highest);
log.info(String.format("[%s][Chat] mChat found: %s", getDescription().getName(), mChat.isEnabled() ? "Loaded" : "Waiting"));
} else {
log.info(String.format("[%s][Chat] mChat not found.", getDescription().getName()));
}
// Try to load GroupManager
if (packageExists(new String[] { "org.anjocaido.groupmanager.GroupManager" })) {
Chat gPerms = new Chat_GroupManager(this);
getServer().getServicesManager().register(net.milkbowl.vault.chat.Chat.class, gPerms, this, ServicePriority.High);
log.info(String.format("[%s][Chat] GroupManager found: %s", getDescription().getName(), gPerms.isEnabled() ? "Loaded" : "Waiting"));
} else {
log.info(String.format("[%s][Chat] GroupManager not found.", getDescription().getName()));
}
// Try to load Permissions 3 (Yeti)
if (packageExists(new String[] { "com.nijiko.permissions.ModularControl" })) {
Chat nPerms = new Chat_Permissions3(this);
getServer().getServicesManager().register(net.milkbowl.vault.chat.Chat.class, nPerms, this, ServicePriority.High);
log.info(String.format("[%s][Chat] Permissions 3 (Yeti) found: %s", getDescription().getName(), nPerms.isEnabled() ? "Loaded" : "Waiting"));
} else {
log.info(String.format("[%s][Chat] Permissions 3 (Yeti) not found.", getDescription().getName()));
}
// Try to load Permissions 2 (Phoenix)
if (packageExists(new String[] { "com.nijiko.permissions.Control" })) {
Permission oPerms = new Permission_Permissions2(this);
getServer().getServicesManager().register(net.milkbowl.vault.permission.Permission.class, oPerms, this, ServicePriority.Low);
log.info(String.format("[%s][Chat] Permissions 2 (Phoenix) found: %s", getDescription().getName(), oPerms.isEnabled() ? "Loaded" : "Waiting"));
} else {
log.info(String.format("[%s][Chat] Permissions 2 (Phoenix) not found.", getDescription().getName()));
}
}
/**
* Attempts to load Economy Addons
*/

View File

@ -18,7 +18,7 @@ import net.milkbowl.vault.chat.Chat;
public class Chat_GroupManager extends Chat {
private static final Logger log = Logger.getLogger("Minecraft");
private String name = "GroupManager";
private final String name = "GroupManager - Chat";
private Plugin plugin = null;
private PluginManager pluginManager = null;
private GroupManager groupManager;

View File

@ -18,7 +18,7 @@ import com.nijikokun.bukkit.Permissions.Permissions;
public class Chat_Permissions2 extends Chat {
private static final Logger log = Logger.getLogger("Minecraft");
private String name = "Permissions 2 (Phoenix)";
private String name = "Permissions 2 (Phoenix) - Chat";
private Control perms;
private Plugin plugin = null;
private PluginManager pluginManager = null;

View File

@ -18,7 +18,7 @@ import net.milkbowl.vault.chat.Chat;
public class Chat_Permissions3 extends Chat {
private static final Logger log = Logger.getLogger("Minecraft");
private String name = "Permissions 3 (Yeti)";
private String name = "Permissions 3 (Yeti) - Chat";
private PermissionHandler perms;
private Plugin plugin = null;
private PluginManager pluginManager = null;

View File

@ -1,179 +1,237 @@
package net.milkbowl.vault.chat.plugins;
import java.util.logging.Logger;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.Event.Priority;
import org.bukkit.event.Event.Type;
import org.bukkit.event.server.PluginDisableEvent;
import org.bukkit.event.server.PluginEnableEvent;
import org.bukkit.event.server.ServerListener;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginManager;
import net.D3GN.MiracleM4n.mChat.mChatAPI;
import net.milkbowl.vault.chat.Chat;
public class Chat_mChat extends Chat {
private static final Logger log = Logger.getLogger("Minecraft");
private final String name = "mChat";
private Plugin plugin = null;
private PluginManager pluginManager = null;
private mChatAPI mChat = null;
private PermissionServerListener permissionServerListener = null;
public Chat_mChat(Plugin plugin) {
this.plugin = plugin;
pluginManager = this.plugin.getServer().getPluginManager();
permissionServerListener = new PermissionServerListener(this);
this.pluginManager.registerEvent(Type.PLUGIN_ENABLE, permissionServerListener, Priority.Monitor, plugin);
this.pluginManager.registerEvent(Type.PLUGIN_DISABLE, permissionServerListener, Priority.Monitor, plugin);
// Load Plugin in case it was loaded before
if (mChat == null) {
Plugin chat = plugin.getServer().getPluginManager().getPlugin("mChat");
if (chat != null) {
mChat = net.D3GN.MiracleM4n.mChat.mChat.API;
log.info(String.format("[%s][Chat] %s hooked.", plugin.getDescription().getName(), "mChat"));
}
}
}
private class PermissionServerListener extends ServerListener {
Chat_mChat chat = null;
public PermissionServerListener(Chat_mChat chat) {
this.chat = chat;
}
public void onPluginEnable(PluginEnableEvent event) {
if (this.chat.mChat == null) {
Plugin chat = plugin.getServer().getPluginManager().getPlugin("mChat");
if (chat != null) {
this.chat.mChat = net.D3GN.MiracleM4n.mChat.mChat.API;
log.info(String.format("[%s][Chat] %s hooked.", plugin.getDescription().getName(), "mChat"));
}
}
}
public void onPluginDisable(PluginDisableEvent event) {
if (this.chat.mChat != null) {
if (event.getPlugin().getDescription().getName().equals("mChat")) {
this.chat.mChat = null;
log.info(String.format("[%s][Chat] %s un-hooked.", plugin.getDescription().getName(), "mChat"));
}
}
}
}
@Override
public String getName() {
// TODO Auto-generated method stub
return null;
return name;
}
@Override
public boolean isEnabled() {
// TODO Auto-generated method stub
return false;
return mChat != null;
}
@Override
public String getPlayerPrefix(String world, String player) {
// TODO Auto-generated method stub
return null;
Player p = Bukkit.getServer().getPlayer(player);
if (p ==null) {
throw new UnsupportedOperationException("mChat does not support offline player prefixes");
}
return mChat.getPrefix(p);
}
@Override
public void setPlayerPrefix(String world, String player, String prefix) {
// TODO Auto-generated method stub
throw new UnsupportedOperationException("mChat does not support setting info nodes");
}
@Override
public String getPlayerSuffix(String world, String player) {
// TODO Auto-generated method stub
return null;
Player p = Bukkit.getServer().getPlayer(player);
if (p ==null) {
throw new UnsupportedOperationException("mChat does not support offline player prefixes");
}
return mChat.getSuffix(p);
}
@Override
public void setPlayerSuffix(String world, String player, String suffix) {
// TODO Auto-generated method stub
throw new UnsupportedOperationException("mChat does not support setting info nodes");
}
@Override
public String getGroupPrefix(String world, String group) {
// TODO Auto-generated method stub
return null;
throw new UnsupportedOperationException("mChat does not support group info nodes");
}
@Override
public void setGroupPrefix(String world, String group, String prefix) {
// TODO Auto-generated method stub
throw new UnsupportedOperationException("mChat does not support group info nodes");
}
@Override
public String getGroupSuffix(String world, String group) {
// TODO Auto-generated method stub
return null;
throw new UnsupportedOperationException("mChat does not support group info nodes");
}
@Override
public void setGroupSuffix(String world, String group, String suffix) {
// TODO Auto-generated method stub
throw new UnsupportedOperationException("mChat does not support group info nodes");
}
@Override
public int getPlayerInfoInteger(String world, String player, String node,
int defaultValue) {
// TODO Auto-generated method stub
return 0;
public int getPlayerInfoInteger(String world, String player, String node, int defaultValue) {
String s = getPlayerInfoString(world, player, node, null);
if (s == null)
return defaultValue;
try {
return Integer.valueOf(s);
} catch (NumberFormatException e) {
return defaultValue;
}
}
@Override
public void setPlayerInfoInteger(String world, String player, String node,
int value) {
// TODO Auto-generated method stub
public void setPlayerInfoInteger(String world, String player, String node, int value) {
throw new UnsupportedOperationException("mChat does not support setting info nodes");
}
@Override
public int getGroupInfoInteger(String world, String group, String node,
int defaultValue) {
// TODO Auto-generated method stub
return 0;
public int getGroupInfoInteger(String world, String group, String node, int defaultValue) {
throw new UnsupportedOperationException("mChat does not support group info nodes");
}
@Override
public void setGroupInfoInteger(String world, String group, String node,
int value) {
// TODO Auto-generated method stub
public void setGroupInfoInteger(String world, String group, String node, int value) {
throw new UnsupportedOperationException("mChat does not support group info nodes");
}
@Override
public double getPlayerInfoDouble(String world, String player, String node,
double defaultValue) {
// TODO Auto-generated method stub
return 0;
public double getPlayerInfoDouble(String world, String player, String node, double defaultValue) {
String s = getPlayerInfoString(world, player, node, null);
if (s == null)
return defaultValue;
try {
return Double.valueOf(s);
} catch (NumberFormatException e) {
return defaultValue;
}
}
@Override
public void setPlayerInfoDouble(String world, String player, String node,
double value) {
// TODO Auto-generated method stub
public void setPlayerInfoDouble(String world, String player, String node, double value) {
throw new UnsupportedOperationException("mChat does not support setting info nodes");
}
@Override
public double getGroupInfoDouble(String world, String group, String node,
double defaultValue) {
// TODO Auto-generated method stub
return 0;
public double getGroupInfoDouble(String world, String group, String node,double defaultValue) {
throw new UnsupportedOperationException("mChat does not support group info nodes");
}
@Override
public void setGroupInfoDouble(String world, String group, String node,
double value) {
// TODO Auto-generated method stub
public void setGroupInfoDouble(String world, String group, String node, double value) {
throw new UnsupportedOperationException("mChat does not support group info nodes");
}
@Override
public boolean getPlayerInfoBoolean(String world, String player,
String node, boolean defaultValue) {
// TODO Auto-generated method stub
return false;
public boolean getPlayerInfoBoolean(String world, String player, String node, boolean defaultValue) {
String s = getPlayerInfoString(world, player, node, null);
if (s == null)
return defaultValue;
try {
return Boolean.valueOf(s);
} catch (NumberFormatException e) {
return defaultValue;
}
}
@Override
public void setPlayerInfoBoolean(String world, String player, String node,
boolean value) {
// TODO Auto-generated method stub
public void setPlayerInfoBoolean(String world, String player, String node, boolean value) {
throw new UnsupportedOperationException("mChat does not support setting info nodes");
}
@Override
public boolean getGroupInfoBoolean(String world, String group, String node,
boolean defaultValue) {
// TODO Auto-generated method stub
return false;
public boolean getGroupInfoBoolean(String world, String group, String node, boolean defaultValue) {
throw new UnsupportedOperationException("mChat does not support group info nodes");
}
@Override
public void setGroupInfoBoolean(String world, String group, String node,
boolean value) {
// TODO Auto-generated method stub
public void setGroupInfoBoolean(String world, String group, String node, boolean value) {
throw new UnsupportedOperationException("mChat does not support group info nodes");
}
@Override
public String getPlayerInfoString(String world, String player, String node,
String defaultValue) {
// TODO Auto-generated method stub
return null;
public String getPlayerInfoString(String world, String player, String node, String defaultValue) {
Player p = Bukkit.getServer().getPlayer(player);
if (p ==null) {
throw new UnsupportedOperationException("mChat does not support offline player prefixes");
}
String s = mChat.getInfo(p, node);
return s == null ? defaultValue : s;
}
@Override
public void setPlayerInfoString(String world, String player, String node,
String value) {
// TODO Auto-generated method stub
public void setPlayerInfoString(String world, String player, String node, String value) {
throw new UnsupportedOperationException("mChat does not support setting info nodes");
}
@Override
public String getGroupInfoString(String world, String group, String node,
String defaultValue) {
// TODO Auto-generated method stub
return null;
public String getGroupInfoString(String world, String group, String node, String defaultValue) {
throw new UnsupportedOperationException("mChat does not support group info nodes");
}
@Override
public void setGroupInfoString(String world, String group, String node,
String value) {
// TODO Auto-generated method stub
public void setGroupInfoString(String world, String group, String node, String value) {
throw new UnsupportedOperationException("mChat does not support group info nodes");
}
}

View File

@ -26,7 +26,7 @@ import net.milkbowl.vault.permission.Permission;
public class Permission_PermissionsBukkit extends Permission {
private static final Logger log = Logger.getLogger("Minecraft");
private String name = "PermissionsBukkit";
private final String name = "PermissionsBukkit";
private Plugin plugin = null;
private PluginManager pluginManager = null;
private PermissionsPlugin perms = null;
@ -138,9 +138,6 @@ public class Permission_PermissionsBukkit extends Permission {
@Override
public boolean playerAddTransient(String world, String player, String permission) {
if (world != null) {
throw new UnsupportedOperationException(getName() + " does not support World based transient permissions!");
}
Player p = plugin.getServer().getPlayer(player);
if (p == null) {
throw new UnsupportedOperationException(getName() + " does not support offline player transient permissions!");
@ -169,9 +166,6 @@ public class Permission_PermissionsBukkit extends Permission {
@Override
public boolean playerRemoveTransient(String world, String player, String permission) {
if (world != null) {
throw new UnsupportedOperationException(getName() + " does not support World based transient permissions!");
}
Player p = plugin.getServer().getPlayer(player);
if (p == null) {
throw new UnsupportedOperationException(getName() + " does not support offline player transient permissions!");