mirror of
https://github.com/MilkBowl/Vault.git
synced 2024-09-30 14:27:31 +02:00
added very basic iChat support, it loads last as iChat functions as a
Pass-through if any other perms systems are detected with Chat support.
This commit is contained in:
parent
b1cc568653
commit
9e04122c9f
BIN
lib/iChat.jar
Normal file
BIN
lib/iChat.jar
Normal file
Binary file not shown.
@ -27,6 +27,7 @@ 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_bPermissions;
|
||||
import net.milkbowl.vault.chat.plugins.Chat_iChat;
|
||||
import net.milkbowl.vault.chat.plugins.Chat_mChat;
|
||||
import net.milkbowl.vault.economy.Economy;
|
||||
import net.milkbowl.vault.economy.plugins.Economy_3co;
|
||||
@ -116,6 +117,13 @@ public class Vault extends JavaPlugin {
|
||||
getServer().getServicesManager().register(Chat.class, nPerms, this, ServicePriority.High);
|
||||
log.info(String.format("[%s][Chat] Permissions 3 (Yeti) found: %s", getDescription().getName(), nPerms.isEnabled() ? "Loaded" : "Waiting"));
|
||||
}
|
||||
|
||||
// Try to load iChat
|
||||
if (packageExists(new String[] { "ru.tehkode.permissions.bukkit.PermissionsEx" })) {
|
||||
Chat iChat = new Chat_iChat(this, perms);
|
||||
getServer().getServicesManager().register(Chat.class, iChat, this, ServicePriority.Lowest);
|
||||
log.info(String.format("[%s][Chat] PermissionsEx found: %s", getDescription().getName(), iChat.isEnabled() ? "Loaded" : "Waiting"));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
253
src/net/milkbowl/vault/chat/plugins/Chat_iChat.java
Normal file
253
src/net/milkbowl/vault/chat/plugins/Chat_iChat.java
Normal file
@ -0,0 +1,253 @@
|
||||
package net.milkbowl.vault.chat.plugins;
|
||||
|
||||
import java.util.logging.Logger;
|
||||
|
||||
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.TheDgtl.iChat.iChatAPI;
|
||||
import net.TheDgtl.iChat.iChat;
|
||||
import net.milkbowl.vault.chat.Chat;
|
||||
import net.milkbowl.vault.permission.Permission;
|
||||
|
||||
public class Chat_iChat extends Chat {
|
||||
|
||||
private static final Logger log = Logger.getLogger("Minecraft");
|
||||
private final String name = "iChat";
|
||||
private Plugin plugin = null;
|
||||
private PluginManager pluginManager = null;
|
||||
private iChatAPI iChat = null;
|
||||
private PermissionServerListener permissionServerListener = null;
|
||||
|
||||
public Chat_iChat(Plugin plugin, Permission perms) {
|
||||
super(perms);
|
||||
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 (iChat == null) {
|
||||
Plugin chat = plugin.getServer().getPluginManager().getPlugin("mChat");
|
||||
if (chat != null) {
|
||||
iChat = ((iChat) plugin).API;
|
||||
log.info(String.format("[%s][Chat] %s hooked.", plugin.getDescription().getName(), "mChat"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class PermissionServerListener extends ServerListener {
|
||||
Chat_iChat chat = null;
|
||||
|
||||
public PermissionServerListener(Chat_iChat chat) {
|
||||
this.chat = chat;
|
||||
}
|
||||
|
||||
public void onPluginEnable(PluginEnableEvent event) {
|
||||
if (this.chat.iChat == null) {
|
||||
Plugin chat = plugin.getServer().getPluginManager().getPlugin("iChat");
|
||||
if (chat != null) {
|
||||
this.chat.iChat = ((iChat) plugin).API;
|
||||
log.info(String.format("[%s][Chat] %s hooked.", plugin.getDescription().getName(), "iChat"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void onPluginDisable(PluginDisableEvent event) {
|
||||
if (this.chat.iChat != null) {
|
||||
if (event.getPlugin().getDescription().getName().equals("iChat")) {
|
||||
this.chat.iChat = null;
|
||||
log.info(String.format("[%s][Chat] %s un-hooked.", plugin.getDescription().getName(), "iChat"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
return iChat != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPlayerPrefix(String world, String player) {
|
||||
Player p = plugin.getServer().getPlayer(player);
|
||||
if (p == null)
|
||||
throw new UnsupportedOperationException("iChat does not support offline player info nodes!");
|
||||
|
||||
if (!p.getWorld().getName().equals(world))
|
||||
return null;
|
||||
|
||||
return iChat.getPrefix(p);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayerPrefix(String world, String player, String prefix) {
|
||||
throw new UnsupportedOperationException("iChat does not support mutable info nodes!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPlayerSuffix(String world, String player) {
|
||||
Player p = plugin.getServer().getPlayer(player);
|
||||
if (p == null)
|
||||
throw new UnsupportedOperationException("iChat does not support offline player info nodes!");
|
||||
|
||||
if (!p.getWorld().getName().equals(world))
|
||||
return null;
|
||||
|
||||
return iChat.getSuffix(p);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayerSuffix(String world, String player, String suffix) {
|
||||
throw new UnsupportedOperationException("iChat does not support mutable info nodes!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGroupPrefix(String world, String group) {
|
||||
throw new UnsupportedOperationException("iChat does not support group info nodes!");
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setGroupPrefix(String world, String group, String prefix) {
|
||||
throw new UnsupportedOperationException("iChat does not support mutable info nodes!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGroupSuffix(String world, String group) {
|
||||
throw new UnsupportedOperationException("iChat does not support group info nodes!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGroupSuffix(String world, String group, String suffix) {
|
||||
throw new UnsupportedOperationException("iChat does not support mutable info nodes!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPlayerInfoInteger(String world, String player, String node, int defaultValue) {
|
||||
String val = getPlayerInfoString(world, player, node, null);
|
||||
if (val == null)
|
||||
return defaultValue;
|
||||
|
||||
Integer i = defaultValue;
|
||||
try {
|
||||
i = Integer.valueOf(val);
|
||||
return i;
|
||||
} catch (NumberFormatException e) {
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayerInfoInteger(String world, String player, String node, int value) {
|
||||
throw new UnsupportedOperationException("iChat does not support mutable info nodes!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getGroupInfoInteger(String world, String group, String node, int defaultValue) {
|
||||
throw new UnsupportedOperationException("iChat does not support group info nodes!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGroupInfoInteger(String world, String group, String node, int value) {
|
||||
throw new UnsupportedOperationException("iChat does not support mutable info nodes!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getPlayerInfoDouble(String world, String player, String node, double defaultValue) {
|
||||
String val = getPlayerInfoString(world, player, node, null);
|
||||
if (val == null)
|
||||
return defaultValue;
|
||||
|
||||
double d = defaultValue;
|
||||
try {
|
||||
d = Double.valueOf(val);
|
||||
return d;
|
||||
} catch (NumberFormatException e) {
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayerInfoDouble(String world, String player, String node, double value) {
|
||||
throw new UnsupportedOperationException("iChat does not support mutable info nodes!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getGroupInfoDouble(String world, String group, String node, double defaultValue) {
|
||||
throw new UnsupportedOperationException("iChat does not support group info nodes!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGroupInfoDouble(String world, String group, String node, double value) {
|
||||
throw new UnsupportedOperationException("iChat does not support mutable info nodes!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getPlayerInfoBoolean(String world, String player, String node, boolean defaultValue) {
|
||||
String val = getPlayerInfoString(world, player, node, null);
|
||||
if (val == null)
|
||||
return defaultValue;
|
||||
|
||||
return Boolean.valueOf(val);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayerInfoBoolean(String world, String player, String node, boolean value) {
|
||||
throw new UnsupportedOperationException("iChat does not support mutable info nodes!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getGroupInfoBoolean(String world, String group, String node, boolean defaultValue) {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGroupInfoBoolean(String world, String group, String node, boolean value) {
|
||||
throw new UnsupportedOperationException("iChat does not support mutable info nodes!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPlayerInfoString(String world, String player, String node, String defaultValue) {
|
||||
Player p = plugin.getServer().getPlayer(player);
|
||||
if (p == null)
|
||||
throw new UnsupportedOperationException("iChat does not support offline player info nodes!");
|
||||
|
||||
if (!p.getWorld().getName().equals(world))
|
||||
return null;
|
||||
|
||||
String val = iChat.getInfo(p, node);
|
||||
|
||||
return val != null ? val : defaultValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayerInfoString(String world, String player, String node, String value) {
|
||||
throw new UnsupportedOperationException("iChat does not support mutable info nodes!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGroupInfoString(String world, String group, String node, String defaultValue) {
|
||||
throw new UnsupportedOperationException("iChat does not support group info nodes!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGroupInfoString(String world, String group, String node, String value) {
|
||||
throw new UnsupportedOperationException("iChat does not support mutable info nodes!");
|
||||
}
|
||||
}
|
@ -70,6 +70,7 @@ public class Chat_mChat extends Chat {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
|
Loading…
Reference in New Issue
Block a user