switched to cb 1.1 - chat implementations now use new events. others

need to be converterd
This commit is contained in:
Sleaker 2012-01-25 14:31:13 -08:00
parent 1d021d944d
commit 4fd18e3962
11 changed files with 297 additions and 324 deletions

Binary file not shown.

View File

@ -11,7 +11,7 @@
<dependency>
<groupId>org.bukkit</groupId>
<artifactId>craftbukkit</artifactId>
<version>1.0.1-R2-SNAPSHOT</version>
<version>1.1-R1</version>
</dependency>
<dependency>
<groupId>org.tyrannyofheaven.bukkit</groupId>

View File

@ -65,12 +65,11 @@ import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.command.ConsoleCommandSender;
import org.bukkit.entity.Player;
import org.bukkit.event.Event.Priority;
import org.bukkit.event.Event.Type;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerListener;
import org.bukkit.event.server.PluginEnableEvent;
import org.bukkit.event.server.ServerListener;
import org.bukkit.plugin.RegisteredServiceProvider;
import org.bukkit.plugin.ServicePriority;
import org.bukkit.plugin.ServicesManager;
@ -109,8 +108,7 @@ public class Vault extends JavaPlugin {
getCommand("vault-info").setExecutor(this);
getCommand("vault-reload").setExecutor(this);
this.getServer().getPluginManager().registerEvent(Type.PLAYER_JOIN, new VaultPlayerListener(), Priority.Monitor, this);
this.getServer().getPluginManager().registerEvent(Type.PLUGIN_ENABLE, new VaultPluginListener(), Priority.Monitor, this);
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.
@ -460,9 +458,9 @@ public class Vault extends JavaPlugin {
return currentVersion;
}
public class VaultPlayerListener extends PlayerListener {
public class VaultListener implements Listener {
@Override
@EventHandler(priority = EventPriority.MONITOR)
public void onPlayerJoin(PlayerJoinEvent event) {
Player player = event.getPlayer();
if (perms.has(player, "vault.admin")) {
@ -477,11 +475,8 @@ public class Vault extends JavaPlugin {
}
}
}
}
public class VaultPluginListener extends ServerListener {
@Override
@EventHandler(priority = EventPriority.MONITOR)
public void onPluginEnable(PluginEnableEvent event) {
if (event.getPlugin().getDescription().getName().equals("Register") && packageExists(new String[] {"com.nijikokun.register.payment.Methods"})) {
if (!Methods.hasMethod()) {

View File

@ -2,39 +2,33 @@ package net.milkbowl.vault.chat.plugins;
import java.util.logging.Logger;
import org.anjocaido.groupmanager.GroupManager;
import org.anjocaido.groupmanager.permissions.AnjoPermissionsHandler;
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.milkbowl.vault.chat.Chat;
import net.milkbowl.vault.permission.Permission;
import org.anjocaido.groupmanager.GroupManager;
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;
@SuppressWarnings("deprecation")
public class Chat_GroupManager extends Chat {
private static final Logger log = Logger.getLogger("Minecraft");
private final String name = "GroupManager - Chat";
private Plugin plugin = null;
private PluginManager pluginManager = null;
private GroupManager groupManager;
private AnjoPermissionsHandler perms;
private PermissionServerListener permissionServerListener = null;
public Chat_GroupManager(Plugin plugin, Permission permissions) {
super(permissions);
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);
Bukkit.getServer().getPluginManager().registerEvents(new PermissionServerListener(this), plugin);
// Load Plugin in case it was loaded before
if (groupManager == null) {
@ -49,13 +43,14 @@ public class Chat_GroupManager extends Chat {
}
}
private class PermissionServerListener extends ServerListener {
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 = plugin.getServer().getPluginManager().getPlugin("GroupManager");
@ -70,6 +65,7 @@ public class Chat_GroupManager extends Chat {
}
}
@EventHandler(priority = EventPriority.MONITOR)
public void onPluginDisable(PluginDisableEvent event) {
if (chat.groupManager != null) {
if (event.getPlugin().getDescription().getName().equals("GroupManager")) {

View File

@ -2,37 +2,32 @@ package net.milkbowl.vault.chat.plugins;
import java.util.logging.Logger;
import org.bukkit.event.Event.Priority;
import org.bukkit.event.Event.Type;
import net.milkbowl.vault.chat.Chat;
import net.milkbowl.vault.permission.Permission;
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.event.server.ServerListener;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginManager;
import com.herocraftonline.herotitles.HeroTitles;
import com.herocraftonline.herotitles.PlayerTitleManager;
import net.milkbowl.vault.chat.Chat;
import net.milkbowl.vault.permission.Permission;
public class Chat_HeroTitles extends Chat {
private final Logger log = Logger.getLogger("Minecraft");
private final String name = "HeroTitles";
private PermissionServerListener permissionServerListener;
private HeroTitles chat;
private Plugin plugin = null;
public Chat_HeroTitles(Plugin plugin, Permission perms) {
super(perms);
this.plugin = plugin;
PluginManager pluginManager = this.plugin.getServer().getPluginManager();
permissionServerListener = new PermissionServerListener(this);
pluginManager.registerEvent(Type.PLUGIN_ENABLE, permissionServerListener, Priority.Monitor, plugin);
pluginManager.registerEvent(Type.PLUGIN_DISABLE, permissionServerListener, Priority.Monitor, plugin);
Bukkit.getServer().getPluginManager().registerEvents(new PermissionServerListener(this), plugin);
// Load Plugin in case it was loaded before
if (this.chat == null) {
@ -44,13 +39,14 @@ public class Chat_HeroTitles extends Chat {
}
}
private class PermissionServerListener extends ServerListener {
public class PermissionServerListener implements Listener {
Chat_HeroTitles chat = null;
public PermissionServerListener(Chat_HeroTitles chat) {
this.chat = chat;
}
@EventHandler(priority = EventPriority.MONITOR)
public void onPluginEnable(PluginEnableEvent event) {
if (this.chat.chat == null) {
Plugin chat = plugin.getServer().getPluginManager().getPlugin("HeroTitles");
@ -61,6 +57,7 @@ public class Chat_HeroTitles extends Chat {
}
}
@EventHandler(priority = EventPriority.MONITOR)
public void onPluginDisable(PluginDisableEvent event) {
if (this.chat.chat != null) {
if (event.getPlugin().getDescription().getName().equals("HeroTitles")) {

View File

@ -2,39 +2,33 @@ package net.milkbowl.vault.chat.plugins;
import java.util.logging.Logger;
import org.bukkit.event.Event.Priority;
import org.bukkit.event.Event.Type;
import net.milkbowl.vault.chat.Chat;
import net.milkbowl.vault.permission.Permission;
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.event.server.ServerListener;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginManager;
import com.nijiko.permissions.PermissionHandler;
import com.nijikokun.bukkit.Permissions.Permissions;
import net.milkbowl.vault.chat.Chat;
import net.milkbowl.vault.permission.Permission;
public class Chat_Permissions3 extends Chat {
private static final Logger log = Logger.getLogger("Minecraft");
private String name = "Permissions 3 (Yeti) - Chat";
private PermissionHandler perms;
private Plugin plugin = null;
private PluginManager pluginManager = null;
private Permissions chat = null;
private PermissionServerListener permissionServerListener = null;
public Chat_Permissions3(Plugin plugin, Permission permissions) {
super(permissions);
this.plugin = plugin;
pluginManager = this.plugin.getServer().getPluginManager();
permissionServerListener = new PermissionServerListener();
this.pluginManager.registerEvent(Type.PLUGIN_ENABLE, permissionServerListener, Priority.Monitor, plugin);
this.pluginManager.registerEvent(Type.PLUGIN_DISABLE, permissionServerListener, Priority.Monitor, plugin);
Bukkit.getServer().getPluginManager().registerEvents(new PermissionServerListener(), plugin);
// Load Plugin in case it was loaded before
if (chat == null) {
@ -48,7 +42,10 @@ public class Chat_Permissions3 extends Chat {
}
}
}
private class PermissionServerListener extends ServerListener {
public class PermissionServerListener implements Listener {
@EventHandler(priority = EventPriority.MONITOR)
public void onPluginEnable(PluginEnableEvent event) {
if (chat == null) {
Plugin perms = event.getPlugin();
@ -61,6 +58,7 @@ public class Chat_Permissions3 extends Chat {
}
}
@EventHandler(priority = EventPriority.MONITOR)
public void onPluginDisable(PluginDisableEvent event) {
if (chat != null) {
if (event.getPlugin().getDescription().getName().equals("Permissions")) {

View File

@ -2,38 +2,33 @@ package net.milkbowl.vault.chat.plugins;
import java.util.logging.Logger;
import org.bukkit.event.Event.Priority;
import org.bukkit.event.Event.Type;
import net.milkbowl.vault.chat.Chat;
import net.milkbowl.vault.permission.Permission;
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.event.server.ServerListener;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginManager;
import ru.tehkode.permissions.PermissionGroup;
import ru.tehkode.permissions.PermissionUser;
import ru.tehkode.permissions.bukkit.PermissionsEx;
import net.milkbowl.vault.chat.Chat;
import net.milkbowl.vault.permission.Permission;
public class Chat_PermissionsEx extends Chat {
private static final Logger log = Logger.getLogger("Minecraft");
private final String name = "PermissionsEx_Chat";
private Plugin plugin = null;
private PluginManager pluginManager = null;
private PermissionsEx chat = null;
private PermissionServerListener permissionServerListener = null;
public Chat_PermissionsEx(Plugin plugin, Permission permissions) {
super(permissions);
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);
Bukkit.getServer().getPluginManager().registerEvents(new PermissionServerListener(this), plugin);
// Load Plugin in case it was loaded before
if (chat == null) {
@ -47,13 +42,14 @@ public class Chat_PermissionsEx extends Chat {
}
}
private class PermissionServerListener extends ServerListener {
public class PermissionServerListener implements Listener {
Chat_PermissionsEx chat = null;
public PermissionServerListener(Chat_PermissionsEx chat) {
this.chat = chat;
}
@EventHandler(priority = EventPriority.MONITOR)
public void onPluginEnable(PluginEnableEvent event) {
if (chat.chat == null) {
Plugin perms = plugin.getServer().getPluginManager().getPlugin("PermissionsEx");
@ -67,6 +63,7 @@ public class Chat_PermissionsEx extends Chat {
}
}
@EventHandler(priority = EventPriority.MONITOR)
public void onPluginDisable(PluginDisableEvent event) {
if (chat.chat != null) {
if (event.getPlugin().getDescription().getName().equals("PermissionsEx")) {

View File

@ -2,38 +2,36 @@ package net.milkbowl.vault.chat.plugins;
import java.util.logging.Logger;
import org.bukkit.event.Event.Priority;
import org.bukkit.event.Event.Type;
import net.milkbowl.vault.Vault;
import net.milkbowl.vault.chat.Chat;
import net.milkbowl.vault.permission.Permission;
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.event.server.ServerListener;
import org.bukkit.plugin.Plugin;
import com.palmergames.bukkit.towny.NotRegisteredException;
import com.palmergames.bukkit.towny.Towny;
import com.palmergames.bukkit.towny.object.Resident;
import net.milkbowl.vault.Vault;
import net.milkbowl.vault.chat.Chat;
import net.milkbowl.vault.permission.Permission;
public class Chat_Towny extends Chat {
private static final Logger log = Logger.getLogger("Minecraft");
private final String name = "Towny";
private Towny towny;
private Vault plugin;
private PermissionServerListener permissionServerListener;
public Chat_Towny(Vault plugin, Permission perms) {
super(perms);
this.plugin = plugin;
Bukkit.getServer().getPluginManager().registerEvents(new PermissionServerListener(this), plugin);
permissionServerListener = new PermissionServerListener(this);
plugin.getServer().getPluginManager().registerEvent(Type.PLUGIN_ENABLE, permissionServerListener, Priority.Monitor, plugin);
plugin.getServer().getPluginManager().registerEvent(Type.PLUGIN_DISABLE, permissionServerListener, Priority.Monitor, plugin);
// Load Plugin in case it was loaded before
if (towny == null) {
Plugin p = plugin.getServer().getPluginManager().getPlugin("Towny");
@ -44,13 +42,14 @@ public class Chat_Towny extends Chat {
}
}
private class PermissionServerListener extends ServerListener {
public class PermissionServerListener implements Listener {
Chat_Towny chat = null;
public PermissionServerListener(Chat_Towny chat) {
this.chat = chat;
}
@EventHandler(priority = EventPriority.MONITOR)
public void onPluginEnable(PluginEnableEvent event) {
if (this.chat.towny == null) {
Plugin towny = plugin.getServer().getPluginManager().getPlugin("Towny");
@ -61,6 +60,7 @@ public class Chat_Towny extends Chat {
}
}
@EventHandler(priority = EventPriority.MONITOR)
public void onPluginDisable(PluginDisableEvent event) {
if (this.chat.towny != null) {
if (event.getPlugin().getDescription().getName().equals("Towny")) {

View File

@ -2,35 +2,32 @@ package net.milkbowl.vault.chat.plugins;
import java.util.logging.Logger;
import org.bukkit.event.Event.Priority;
import org.bukkit.event.Event.Type;
import net.milkbowl.vault.Vault;
import net.milkbowl.vault.chat.Chat;
import net.milkbowl.vault.permission.Permission;
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.event.server.ServerListener;
import org.bukkit.plugin.Plugin;
import de.bananaco.permissions.Permissions;
import de.bananaco.permissions.info.InfoReader;
import net.milkbowl.vault.Vault;
import net.milkbowl.vault.chat.Chat;
import net.milkbowl.vault.permission.Permission;
public class Chat_bPermissions extends Chat {
private static final Logger log = Logger.getLogger("Minecraft");
private final String name = "bInfo";
private Vault plugin = null;
InfoReader chat;
private PermissionServerListener permissionServerListener = null;
public Chat_bPermissions(Vault plugin, Permission perms) {
super(perms);
this.plugin = plugin;
permissionServerListener = new PermissionServerListener(this);
plugin.getServer().getPluginManager().registerEvent(Type.PLUGIN_ENABLE, permissionServerListener, Priority.Monitor, plugin);
plugin.getServer().getPluginManager().registerEvent(Type.PLUGIN_DISABLE, permissionServerListener, Priority.Monitor, plugin);
Bukkit.getServer().getPluginManager().registerEvents(new PermissionServerListener(this), plugin);
// Load Plugin in case it was loaded before
if (chat == null) {
@ -42,13 +39,14 @@ public class Chat_bPermissions extends Chat {
}
}
private class PermissionServerListener extends ServerListener {
public class PermissionServerListener implements Listener {
Chat_bPermissions chat = null;
public PermissionServerListener(Chat_bPermissions chat) {
this.chat = chat;
}
@EventHandler(priority = EventPriority.MONITOR)
public void onPluginEnable(PluginEnableEvent event) {
if (this.chat.chat == null) {
Plugin chat = plugin.getServer().getPluginManager().getPlugin("bPermissions");
@ -59,6 +57,7 @@ public class Chat_bPermissions extends Chat {
}
}
@EventHandler(priority = EventPriority.MONITOR)
public void onPluginDisable(PluginDisableEvent event) {
if (this.chat.chat != null) {
if (event.getPlugin().getDescription().getName().equals("bPermissions")) {

View File

@ -2,38 +2,32 @@ 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.TheDgtl.iChat.iChatAPI;
import net.milkbowl.vault.chat.Chat;
import net.milkbowl.vault.permission.Permission;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
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_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);
Bukkit.getServer().getPluginManager().registerEvents(new PermissionServerListener(this), plugin);
// Load Plugin in case it was loaded before
if (iChat == null) {
@ -45,13 +39,14 @@ public class Chat_iChat extends Chat {
}
}
private class PermissionServerListener extends ServerListener {
public class PermissionServerListener implements Listener {
Chat_iChat chat = null;
public PermissionServerListener(Chat_iChat chat) {
this.chat = chat;
}
@EventHandler(priority = EventPriority.MONITOR)
public void onPluginEnable(PluginEnableEvent event) {
if (this.chat.iChat == null) {
Plugin chat = plugin.getServer().getPluginManager().getPlugin("iChat");
@ -62,6 +57,7 @@ public class Chat_iChat extends Chat {
}
}
@EventHandler(priority = EventPriority.MONITOR)
public void onPluginDisable(PluginDisableEvent event) {
if (this.chat.iChat != null) {
if (event.getPlugin().getDescription().getName().equals("iChat")) {

View File

@ -2,239 +2,234 @@ 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;
import net.milkbowl.vault.permission.Permission;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
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_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, Permission permissions) {
super(permissions);
this.plugin = plugin;
pluginManager = this.plugin.getServer().getPluginManager();
permissionServerListener = new PermissionServerListener(this);
private static final Logger log = Logger.getLogger("Minecraft");
private final String name = "mChat";
private Plugin plugin = null;
private mChatAPI mChat = null;
this.pluginManager.registerEvent(Type.PLUGIN_ENABLE, permissionServerListener, Priority.Monitor, plugin);
this.pluginManager.registerEvent(Type.PLUGIN_DISABLE, permissionServerListener, Priority.Monitor, plugin);
public Chat_mChat(Plugin plugin, Permission permissions) {
super(permissions);
this.plugin = 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;
Bukkit.getServer().getPluginManager().registerEvents(new PermissionServerListener(this), plugin);
public PermissionServerListener(Chat_mChat chat) {
this.chat = chat;
}
// 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"));
}
}
}
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 class PermissionServerListener implements Listener {
Chat_mChat chat = null;
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() {
return name;
}
public PermissionServerListener(Chat_mChat chat) {
this.chat = chat;
}
@Override
public boolean isEnabled() {
return mChat != null;
}
@EventHandler(priority = EventPriority.MONITOR)
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"));
}
}
}
@EventHandler(priority = EventPriority.MONITOR)
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 getPlayerPrefix(String world, String player) {
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 String getName() {
return name;
}
@Override
public void setPlayerPrefix(String world, String player, String prefix) {
throw new UnsupportedOperationException("mChat does not support setting info nodes");
}
@Override
public boolean isEnabled() {
return mChat != null;
}
@Override
public String getPlayerSuffix(String world, String player) {
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 String getPlayerPrefix(String world, String player) {
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 setPlayerSuffix(String world, String player, String suffix) {
throw new UnsupportedOperationException("mChat does not support setting info nodes");
}
@Override
public void setPlayerPrefix(String world, String player, String prefix) {
throw new UnsupportedOperationException("mChat does not support setting info nodes");
}
@Override
public String getGroupPrefix(String world, String group) {
throw new UnsupportedOperationException("mChat does not support group info nodes");
}
@Override
public String getPlayerSuffix(String world, String player) {
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 setGroupPrefix(String world, String group, String prefix) {
throw new UnsupportedOperationException("mChat does not support group info nodes");
}
@Override
public void setPlayerSuffix(String world, String player, String suffix) {
throw new UnsupportedOperationException("mChat does not support setting info nodes");
}
@Override
public String getGroupSuffix(String world, String group) {
throw new UnsupportedOperationException("mChat does not support group info nodes");
}
@Override
public String getGroupPrefix(String world, String group) {
throw new UnsupportedOperationException("mChat does not support group info nodes");
}
@Override
public void setGroupSuffix(String world, String group, String suffix) {
throw new UnsupportedOperationException("mChat does not support group info nodes");
}
@Override
public void setGroupPrefix(String world, String group, String prefix) {
throw new UnsupportedOperationException("mChat does not support group info nodes");
}
@Override
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 String getGroupSuffix(String world, String group) {
throw new UnsupportedOperationException("mChat does not support group info nodes");
}
@Override
public void setPlayerInfoInteger(String world, String player, String node, int value) {
throw new UnsupportedOperationException("mChat does not support setting info nodes");
}
@Override
public void setGroupSuffix(String world, String group, String suffix) {
throw new UnsupportedOperationException("mChat does not support group info nodes");
}
@Override
public int getGroupInfoInteger(String world, String group, String node, int defaultValue) {
throw new UnsupportedOperationException("mChat does not support group info nodes");
}
@Override
public int getPlayerInfoInteger(String world, String player, String node, int defaultValue) {
String s = getPlayerInfoString(world, player, node, null);
if (s == null)
return defaultValue;
@Override
public void setGroupInfoInteger(String world, String group, String node, int value) {
throw new UnsupportedOperationException("mChat does not support group info nodes");
}
try {
return Integer.valueOf(s);
} catch (NumberFormatException e) {
return defaultValue;
}
}
@Override
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 setPlayerInfoInteger(String world, String player, String node, int value) {
throw new UnsupportedOperationException("mChat does not support setting info nodes");
}
@Override
public void setPlayerInfoDouble(String world, String player, String node, double value) {
throw new UnsupportedOperationException("mChat does not support setting info nodes");
}
@Override
public int getGroupInfoInteger(String world, String group, String node, int defaultValue) {
throw new UnsupportedOperationException("mChat does not support group info nodes");
}
@Override
public double getGroupInfoDouble(String world, String group, String node,double defaultValue) {
throw new UnsupportedOperationException("mChat does not support group info nodes");
}
@Override
public void setGroupInfoInteger(String world, String group, String node, int value) {
throw new UnsupportedOperationException("mChat does not support group info nodes");
}
@Override
public void setGroupInfoDouble(String world, String group, String node, double value) {
throw new UnsupportedOperationException("mChat does not support group info nodes");
}
@Override
public double getPlayerInfoDouble(String world, String player, String node, double defaultValue) {
String s = getPlayerInfoString(world, player, node, null);
if (s == null)
return defaultValue;
@Override
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;
}
}
try {
return Double.valueOf(s);
} catch (NumberFormatException e) {
return defaultValue;
}
}
@Override
public void setPlayerInfoBoolean(String world, String player, String node, boolean value) {
throw new UnsupportedOperationException("mChat does not support setting info nodes");
}
@Override
public void setPlayerInfoDouble(String world, String player, String node, double value) {
throw new UnsupportedOperationException("mChat does not support setting info nodes");
}
@Override
public boolean getGroupInfoBoolean(String world, String group, String node, boolean defaultValue) {
throw new UnsupportedOperationException("mChat does not support group info nodes");
}
@Override
public double getGroupInfoDouble(String world, String group, String node,double defaultValue) {
throw new UnsupportedOperationException("mChat does not support group info nodes");
}
@Override
public void setGroupInfoBoolean(String world, String group, String node, boolean value) {
throw new UnsupportedOperationException("mChat does not support group info nodes");
}
@Override
public void setGroupInfoDouble(String world, String group, String node, double value) {
throw new UnsupportedOperationException("mChat does not support group info nodes");
}
@Override
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 boolean getPlayerInfoBoolean(String world, String player, String node, boolean defaultValue) {
String s = getPlayerInfoString(world, player, node, null);
if (s == null)
return defaultValue;
@Override
public void setPlayerInfoString(String world, String player, String node, String value) {
throw new UnsupportedOperationException("mChat does not support setting info nodes");
}
try {
return Boolean.valueOf(s);
} catch (NumberFormatException e) {
return defaultValue;
}
}
@Override
public String getGroupInfoString(String world, String group, String node, String defaultValue) {
throw new UnsupportedOperationException("mChat does not support group info nodes");
}
@Override
public void setPlayerInfoBoolean(String world, String player, String node, boolean value) {
throw new UnsupportedOperationException("mChat does not support setting info nodes");
}
@Override
public void setGroupInfoString(String world, String group, String node, String value) {
throw new UnsupportedOperationException("mChat does not support group info nodes");
}
@Override
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) {
throw new UnsupportedOperationException("mChat does not support group info nodes");
}
@Override
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) {
throw new UnsupportedOperationException("mChat does not support setting info nodes");
}
@Override
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) {
throw new UnsupportedOperationException("mChat does not support group info nodes");
}
}