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> <dependency>
<groupId>org.bukkit</groupId> <groupId>org.bukkit</groupId>
<artifactId>craftbukkit</artifactId> <artifactId>craftbukkit</artifactId>
<version>1.0.1-R2-SNAPSHOT</version> <version>1.1-R1</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.tyrannyofheaven.bukkit</groupId> <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.CommandSender;
import org.bukkit.command.ConsoleCommandSender; import org.bukkit.command.ConsoleCommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.Event.Priority; import org.bukkit.event.EventHandler;
import org.bukkit.event.Event.Type; import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerListener;
import org.bukkit.event.server.PluginEnableEvent; import org.bukkit.event.server.PluginEnableEvent;
import org.bukkit.event.server.ServerListener;
import org.bukkit.plugin.RegisteredServiceProvider; import org.bukkit.plugin.RegisteredServiceProvider;
import org.bukkit.plugin.ServicePriority; import org.bukkit.plugin.ServicePriority;
import org.bukkit.plugin.ServicesManager; import org.bukkit.plugin.ServicesManager;
@ -109,8 +108,7 @@ public class Vault extends JavaPlugin {
getCommand("vault-info").setExecutor(this); getCommand("vault-info").setExecutor(this);
getCommand("vault-reload").setExecutor(this); getCommand("vault-reload").setExecutor(this);
this.getServer().getPluginManager().registerEvent(Type.PLAYER_JOIN, new VaultPlayerListener(), Priority.Monitor, this); getServer().getPluginManager().registerEvents(new VaultListener(), this);
this.getServer().getPluginManager().registerEvent(Type.PLUGIN_ENABLE, new VaultPluginListener(), Priority.Monitor, this);
// Schedule to check the version every 30 minutes for an update. This is to update the most recent // 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. // version so if an admin reconnects they will be warned about newer versions.
@ -460,9 +458,9 @@ public class Vault extends JavaPlugin {
return currentVersion; return currentVersion;
} }
public class VaultPlayerListener extends PlayerListener { public class VaultListener implements Listener {
@Override @EventHandler(priority = EventPriority.MONITOR)
public void onPlayerJoin(PlayerJoinEvent event) { public void onPlayerJoin(PlayerJoinEvent event) {
Player player = event.getPlayer(); Player player = event.getPlayer();
if (perms.has(player, "vault.admin")) { if (perms.has(player, "vault.admin")) {
@ -477,11 +475,8 @@ public class Vault extends JavaPlugin {
} }
} }
} }
}
@EventHandler(priority = EventPriority.MONITOR)
public class VaultPluginListener extends ServerListener {
@Override
public void onPluginEnable(PluginEnableEvent event) { public void onPluginEnable(PluginEnableEvent event) {
if (event.getPlugin().getDescription().getName().equals("Register") && packageExists(new String[] {"com.nijikokun.register.payment.Methods"})) { if (event.getPlugin().getDescription().getName().equals("Register") && packageExists(new String[] {"com.nijikokun.register.payment.Methods"})) {
if (!Methods.hasMethod()) { if (!Methods.hasMethod()) {

View File

@ -2,39 +2,33 @@ package net.milkbowl.vault.chat.plugins;
import java.util.logging.Logger; 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.chat.Chat;
import net.milkbowl.vault.permission.Permission; 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") @SuppressWarnings("deprecation")
public class Chat_GroupManager extends Chat { public class Chat_GroupManager extends Chat {
private static final Logger log = Logger.getLogger("Minecraft"); private static final Logger log = Logger.getLogger("Minecraft");
private final String name = "GroupManager - Chat"; private final String name = "GroupManager - Chat";
private Plugin plugin = null; private Plugin plugin = null;
private PluginManager pluginManager = null;
private GroupManager groupManager; private GroupManager groupManager;
private AnjoPermissionsHandler perms; private AnjoPermissionsHandler perms;
private PermissionServerListener permissionServerListener = null;
public Chat_GroupManager(Plugin plugin, Permission permissions) { public Chat_GroupManager(Plugin plugin, Permission permissions) {
super(permissions); super(permissions);
this.plugin = plugin; this.plugin = plugin;
pluginManager = this.plugin.getServer().getPluginManager(); Bukkit.getServer().getPluginManager().registerEvents(new PermissionServerListener(this), plugin);
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 // Load Plugin in case it was loaded before
if (groupManager == null) { 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; Chat_GroupManager chat = null;
public PermissionServerListener(Chat_GroupManager chat) { public PermissionServerListener(Chat_GroupManager chat) {
this.chat = chat; this.chat = chat;
} }
@EventHandler(priority = EventPriority.MONITOR)
public void onPluginEnable(PluginEnableEvent event) { public void onPluginEnable(PluginEnableEvent event) {
if (chat.groupManager == null) { if (chat.groupManager == null) {
Plugin perms = plugin.getServer().getPluginManager().getPlugin("GroupManager"); 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) { public void onPluginDisable(PluginDisableEvent event) {
if (chat.groupManager != null) { if (chat.groupManager != null) {
if (event.getPlugin().getDescription().getName().equals("GroupManager")) { 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 java.util.logging.Logger;
import org.bukkit.event.Event.Priority; import net.milkbowl.vault.chat.Chat;
import org.bukkit.event.Event.Type; 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.PluginDisableEvent;
import org.bukkit.event.server.PluginEnableEvent; import org.bukkit.event.server.PluginEnableEvent;
import org.bukkit.event.server.ServerListener;
import org.bukkit.plugin.Plugin; import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginManager;
import com.herocraftonline.herotitles.HeroTitles; import com.herocraftonline.herotitles.HeroTitles;
import com.herocraftonline.herotitles.PlayerTitleManager; import com.herocraftonline.herotitles.PlayerTitleManager;
import net.milkbowl.vault.chat.Chat;
import net.milkbowl.vault.permission.Permission;
public class Chat_HeroTitles extends Chat { public class Chat_HeroTitles extends Chat {
private final Logger log = Logger.getLogger("Minecraft"); private final Logger log = Logger.getLogger("Minecraft");
private final String name = "HeroTitles"; private final String name = "HeroTitles";
private PermissionServerListener permissionServerListener;
private HeroTitles chat; private HeroTitles chat;
private Plugin plugin = null; private Plugin plugin = null;
public Chat_HeroTitles(Plugin plugin, Permission perms) { public Chat_HeroTitles(Plugin plugin, Permission perms) {
super(perms); super(perms);
this.plugin = plugin; this.plugin = plugin;
PluginManager pluginManager = this.plugin.getServer().getPluginManager();
permissionServerListener = new PermissionServerListener(this); Bukkit.getServer().getPluginManager().registerEvents(new PermissionServerListener(this), plugin);
pluginManager.registerEvent(Type.PLUGIN_ENABLE, permissionServerListener, Priority.Monitor, plugin);
pluginManager.registerEvent(Type.PLUGIN_DISABLE, permissionServerListener, Priority.Monitor, plugin);
// Load Plugin in case it was loaded before // Load Plugin in case it was loaded before
if (this.chat == null) { 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; Chat_HeroTitles chat = null;
public PermissionServerListener(Chat_HeroTitles chat) { public PermissionServerListener(Chat_HeroTitles chat) {
this.chat = chat; this.chat = chat;
} }
@EventHandler(priority = EventPriority.MONITOR)
public void onPluginEnable(PluginEnableEvent event) { public void onPluginEnable(PluginEnableEvent event) {
if (this.chat.chat == null) { if (this.chat.chat == null) {
Plugin chat = plugin.getServer().getPluginManager().getPlugin("HeroTitles"); 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) { public void onPluginDisable(PluginDisableEvent event) {
if (this.chat.chat != null) { if (this.chat.chat != null) {
if (event.getPlugin().getDescription().getName().equals("HeroTitles")) { 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 java.util.logging.Logger;
import org.bukkit.event.Event.Priority; import net.milkbowl.vault.chat.Chat;
import org.bukkit.event.Event.Type; 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.PluginDisableEvent;
import org.bukkit.event.server.PluginEnableEvent; import org.bukkit.event.server.PluginEnableEvent;
import org.bukkit.event.server.ServerListener;
import org.bukkit.plugin.Plugin; import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginManager;
import com.nijiko.permissions.PermissionHandler; import com.nijiko.permissions.PermissionHandler;
import com.nijikokun.bukkit.Permissions.Permissions; import com.nijikokun.bukkit.Permissions.Permissions;
import net.milkbowl.vault.chat.Chat;
import net.milkbowl.vault.permission.Permission;
public class Chat_Permissions3 extends Chat { public class Chat_Permissions3 extends Chat {
private static final Logger log = Logger.getLogger("Minecraft"); private static final Logger log = Logger.getLogger("Minecraft");
private String name = "Permissions 3 (Yeti) - Chat"; private String name = "Permissions 3 (Yeti) - Chat";
private PermissionHandler perms; private PermissionHandler perms;
private Plugin plugin = null; private Plugin plugin = null;
private PluginManager pluginManager = null;
private Permissions chat = null; private Permissions chat = null;
private PermissionServerListener permissionServerListener = null;
public Chat_Permissions3(Plugin plugin, Permission permissions) { public Chat_Permissions3(Plugin plugin, Permission permissions) {
super(permissions); super(permissions);
this.plugin = plugin; this.plugin = plugin;
pluginManager = this.plugin.getServer().getPluginManager();
permissionServerListener = new PermissionServerListener(); Bukkit.getServer().getPluginManager().registerEvents(new PermissionServerListener(), plugin);
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 // Load Plugin in case it was loaded before
if (chat == null) { 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) { public void onPluginEnable(PluginEnableEvent event) {
if (chat == null) { if (chat == null) {
Plugin perms = event.getPlugin(); Plugin perms = event.getPlugin();
@ -61,6 +58,7 @@ public class Chat_Permissions3 extends Chat {
} }
} }
@EventHandler(priority = EventPriority.MONITOR)
public void onPluginDisable(PluginDisableEvent event) { public void onPluginDisable(PluginDisableEvent event) {
if (chat != null) { if (chat != null) {
if (event.getPlugin().getDescription().getName().equals("Permissions")) { 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 java.util.logging.Logger;
import org.bukkit.event.Event.Priority; import net.milkbowl.vault.chat.Chat;
import org.bukkit.event.Event.Type; 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.PluginDisableEvent;
import org.bukkit.event.server.PluginEnableEvent; import org.bukkit.event.server.PluginEnableEvent;
import org.bukkit.event.server.ServerListener;
import org.bukkit.plugin.Plugin; import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginManager;
import ru.tehkode.permissions.PermissionGroup; import ru.tehkode.permissions.PermissionGroup;
import ru.tehkode.permissions.PermissionUser; import ru.tehkode.permissions.PermissionUser;
import ru.tehkode.permissions.bukkit.PermissionsEx; import ru.tehkode.permissions.bukkit.PermissionsEx;
import net.milkbowl.vault.chat.Chat;
import net.milkbowl.vault.permission.Permission;
public class Chat_PermissionsEx extends Chat { public class Chat_PermissionsEx extends Chat {
private static final Logger log = Logger.getLogger("Minecraft"); private static final Logger log = Logger.getLogger("Minecraft");
private final String name = "PermissionsEx_Chat"; private final String name = "PermissionsEx_Chat";
private Plugin plugin = null; private Plugin plugin = null;
private PluginManager pluginManager = null;
private PermissionsEx chat = null; private PermissionsEx chat = null;
private PermissionServerListener permissionServerListener = null;
public Chat_PermissionsEx(Plugin plugin, Permission permissions) { public Chat_PermissionsEx(Plugin plugin, Permission permissions) {
super(permissions); super(permissions);
this.plugin = plugin; this.plugin = plugin;
pluginManager = this.plugin.getServer().getPluginManager();
permissionServerListener = new PermissionServerListener(this); Bukkit.getServer().getPluginManager().registerEvents(new PermissionServerListener(this), plugin);
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 // Load Plugin in case it was loaded before
if (chat == null) { 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; Chat_PermissionsEx chat = null;
public PermissionServerListener(Chat_PermissionsEx chat) { public PermissionServerListener(Chat_PermissionsEx chat) {
this.chat = chat; this.chat = chat;
} }
@EventHandler(priority = EventPriority.MONITOR)
public void onPluginEnable(PluginEnableEvent event) { public void onPluginEnable(PluginEnableEvent event) {
if (chat.chat == null) { if (chat.chat == null) {
Plugin perms = plugin.getServer().getPluginManager().getPlugin("PermissionsEx"); 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) { public void onPluginDisable(PluginDisableEvent event) {
if (chat.chat != null) { if (chat.chat != null) {
if (event.getPlugin().getDescription().getName().equals("PermissionsEx")) { 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 java.util.logging.Logger;
import org.bukkit.event.Event.Priority; import net.milkbowl.vault.Vault;
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.PluginDisableEvent;
import org.bukkit.event.server.PluginEnableEvent; import org.bukkit.event.server.PluginEnableEvent;
import org.bukkit.event.server.ServerListener;
import org.bukkit.plugin.Plugin; import org.bukkit.plugin.Plugin;
import com.palmergames.bukkit.towny.NotRegisteredException; import com.palmergames.bukkit.towny.NotRegisteredException;
import com.palmergames.bukkit.towny.Towny; import com.palmergames.bukkit.towny.Towny;
import com.palmergames.bukkit.towny.object.Resident; 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 { public class Chat_Towny extends Chat {
private static final Logger log = Logger.getLogger("Minecraft"); private static final Logger log = Logger.getLogger("Minecraft");
private final String name = "Towny"; private final String name = "Towny";
private Towny towny; private Towny towny;
private Vault plugin; private Vault plugin;
private PermissionServerListener permissionServerListener;
public Chat_Towny(Vault plugin, Permission perms) { public Chat_Towny(Vault plugin, Permission perms) {
super(perms); super(perms);
this.plugin = plugin; 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 // Load Plugin in case it was loaded before
if (towny == null) { if (towny == null) {
Plugin p = plugin.getServer().getPluginManager().getPlugin("Towny"); 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; Chat_Towny chat = null;
public PermissionServerListener(Chat_Towny chat) { public PermissionServerListener(Chat_Towny chat) {
this.chat = chat; this.chat = chat;
} }
@EventHandler(priority = EventPriority.MONITOR)
public void onPluginEnable(PluginEnableEvent event) { public void onPluginEnable(PluginEnableEvent event) {
if (this.chat.towny == null) { if (this.chat.towny == null) {
Plugin towny = plugin.getServer().getPluginManager().getPlugin("Towny"); 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) { public void onPluginDisable(PluginDisableEvent event) {
if (this.chat.towny != null) { if (this.chat.towny != null) {
if (event.getPlugin().getDescription().getName().equals("Towny")) { 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 java.util.logging.Logger;
import org.bukkit.event.Event.Priority; import net.milkbowl.vault.Vault;
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.PluginDisableEvent;
import org.bukkit.event.server.PluginEnableEvent; import org.bukkit.event.server.PluginEnableEvent;
import org.bukkit.event.server.ServerListener;
import org.bukkit.plugin.Plugin; import org.bukkit.plugin.Plugin;
import de.bananaco.permissions.Permissions; import de.bananaco.permissions.Permissions;
import de.bananaco.permissions.info.InfoReader; 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 { public class Chat_bPermissions extends Chat {
private static final Logger log = Logger.getLogger("Minecraft"); private static final Logger log = Logger.getLogger("Minecraft");
private final String name = "bInfo"; private final String name = "bInfo";
private Vault plugin = null; private Vault plugin = null;
InfoReader chat; InfoReader chat;
private PermissionServerListener permissionServerListener = null;
public Chat_bPermissions(Vault plugin, Permission perms) { public Chat_bPermissions(Vault plugin, Permission perms) {
super(perms); super(perms);
this.plugin = plugin; this.plugin = plugin;
permissionServerListener = new PermissionServerListener(this); Bukkit.getServer().getPluginManager().registerEvents(new PermissionServerListener(this), plugin);
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 // Load Plugin in case it was loaded before
if (chat == null) { 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; Chat_bPermissions chat = null;
public PermissionServerListener(Chat_bPermissions chat) { public PermissionServerListener(Chat_bPermissions chat) {
this.chat = chat; this.chat = chat;
} }
@EventHandler(priority = EventPriority.MONITOR)
public void onPluginEnable(PluginEnableEvent event) { public void onPluginEnable(PluginEnableEvent event) {
if (this.chat.chat == null) { if (this.chat.chat == null) {
Plugin chat = plugin.getServer().getPluginManager().getPlugin("bPermissions"); 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) { public void onPluginDisable(PluginDisableEvent event) {
if (this.chat.chat != null) { if (this.chat.chat != null) {
if (event.getPlugin().getDescription().getName().equals("bPermissions")) { 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 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.iChat;
import net.TheDgtl.iChat.iChatAPI;
import net.milkbowl.vault.chat.Chat; import net.milkbowl.vault.chat.Chat;
import net.milkbowl.vault.permission.Permission; 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 { public class Chat_iChat extends Chat {
private static final Logger log = Logger.getLogger("Minecraft"); private static final Logger log = Logger.getLogger("Minecraft");
private final String name = "iChat"; private final String name = "iChat";
private Plugin plugin = null; private Plugin plugin = null;
private PluginManager pluginManager = null;
private iChatAPI iChat = null; private iChatAPI iChat = null;
private PermissionServerListener permissionServerListener = null;
public Chat_iChat(Plugin plugin, Permission perms) { public Chat_iChat(Plugin plugin, Permission perms) {
super(perms); super(perms);
this.plugin = plugin; this.plugin = plugin;
pluginManager = this.plugin.getServer().getPluginManager();
permissionServerListener = new PermissionServerListener(this);
this.pluginManager.registerEvent(Type.PLUGIN_ENABLE, permissionServerListener, Priority.Monitor, plugin); Bukkit.getServer().getPluginManager().registerEvents(new PermissionServerListener(this), plugin);
this.pluginManager.registerEvent(Type.PLUGIN_DISABLE, permissionServerListener, Priority.Monitor, plugin);
// Load Plugin in case it was loaded before // Load Plugin in case it was loaded before
if (iChat == null) { 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; Chat_iChat chat = null;
public PermissionServerListener(Chat_iChat chat) { public PermissionServerListener(Chat_iChat chat) {
this.chat = chat; this.chat = chat;
} }
@EventHandler(priority = EventPriority.MONITOR)
public void onPluginEnable(PluginEnableEvent event) { public void onPluginEnable(PluginEnableEvent event) {
if (this.chat.iChat == null) { if (this.chat.iChat == null) {
Plugin chat = plugin.getServer().getPluginManager().getPlugin("iChat"); 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) { public void onPluginDisable(PluginDisableEvent event) {
if (this.chat.iChat != null) { if (this.chat.iChat != null) {
if (event.getPlugin().getDescription().getName().equals("iChat")) { 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 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.D3GN.MiracleM4n.mChat.mChatAPI;
import net.milkbowl.vault.chat.Chat; import net.milkbowl.vault.chat.Chat;
import net.milkbowl.vault.permission.Permission; 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 { public class Chat_mChat extends Chat {
private static final Logger log = Logger.getLogger("Minecraft"); private static final Logger log = Logger.getLogger("Minecraft");
private final String name = "mChat"; private final String name = "mChat";
private Plugin plugin = null; private Plugin plugin = null;
private PluginManager pluginManager = null; private mChatAPI mChat = 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);
this.pluginManager.registerEvent(Type.PLUGIN_ENABLE, permissionServerListener, Priority.Monitor, plugin); public Chat_mChat(Plugin plugin, Permission permissions) {
this.pluginManager.registerEvent(Type.PLUGIN_DISABLE, permissionServerListener, Priority.Monitor, plugin); super(permissions);
this.plugin = plugin;
// Load Plugin in case it was loaded before Bukkit.getServer().getPluginManager().registerEvents(new PermissionServerListener(this), plugin);
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) { // Load Plugin in case it was loaded before
this.chat = chat; 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) { public class PermissionServerListener implements Listener {
if (this.chat.mChat == null) { Chat_mChat chat = 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) { public PermissionServerListener(Chat_mChat chat) {
if (this.chat.mChat != null) { this.chat = chat;
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;
}
@Override @EventHandler(priority = EventPriority.MONITOR)
public boolean isEnabled() { public void onPluginEnable(PluginEnableEvent event) {
return mChat != null; 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 @Override
public String getPlayerPrefix(String world, String player) { public String getName() {
Player p = Bukkit.getServer().getPlayer(player); return name;
if (p ==null) { }
throw new UnsupportedOperationException("mChat does not support offline player prefixes");
}
return mChat.getPrefix(p);
}
@Override @Override
public void setPlayerPrefix(String world, String player, String prefix) { public boolean isEnabled() {
throw new UnsupportedOperationException("mChat does not support setting info nodes"); return mChat != null;
} }
@Override @Override
public String getPlayerSuffix(String world, String player) { public String getPlayerPrefix(String world, String player) {
Player p = Bukkit.getServer().getPlayer(player); Player p = Bukkit.getServer().getPlayer(player);
if (p ==null) { if (p ==null) {
throw new UnsupportedOperationException("mChat does not support offline player prefixes"); throw new UnsupportedOperationException("mChat does not support offline player prefixes");
} }
return mChat.getSuffix(p); return mChat.getPrefix(p);
} }
@Override @Override
public void setPlayerSuffix(String world, String player, String suffix) { public void setPlayerPrefix(String world, String player, String prefix) {
throw new UnsupportedOperationException("mChat does not support setting info nodes"); throw new UnsupportedOperationException("mChat does not support setting info nodes");
} }
@Override @Override
public String getGroupPrefix(String world, String group) { public String getPlayerSuffix(String world, String player) {
throw new UnsupportedOperationException("mChat does not support group info nodes"); Player p = Bukkit.getServer().getPlayer(player);
} if (p ==null) {
throw new UnsupportedOperationException("mChat does not support offline player prefixes");
}
return mChat.getSuffix(p);
}
@Override @Override
public void setGroupPrefix(String world, String group, String prefix) { public void setPlayerSuffix(String world, String player, String suffix) {
throw new UnsupportedOperationException("mChat does not support group info nodes"); throw new UnsupportedOperationException("mChat does not support setting info nodes");
} }
@Override @Override
public String getGroupSuffix(String world, String group) { public String getGroupPrefix(String world, String group) {
throw new UnsupportedOperationException("mChat does not support group info nodes"); throw new UnsupportedOperationException("mChat does not support group info nodes");
} }
@Override @Override
public void setGroupSuffix(String world, String group, String suffix) { public void setGroupPrefix(String world, String group, String prefix) {
throw new UnsupportedOperationException("mChat does not support group info nodes"); throw new UnsupportedOperationException("mChat does not support group info nodes");
} }
@Override @Override
public int getPlayerInfoInteger(String world, String player, String node, int defaultValue) { public String getGroupSuffix(String world, String group) {
String s = getPlayerInfoString(world, player, node, null); throw new UnsupportedOperationException("mChat does not support group info nodes");
if (s == null) }
return defaultValue;
try {
return Integer.valueOf(s);
} catch (NumberFormatException e) {
return defaultValue;
}
}
@Override @Override
public void setPlayerInfoInteger(String world, String player, String node, int value) { public void setGroupSuffix(String world, String group, String suffix) {
throw new UnsupportedOperationException("mChat does not support setting info nodes"); throw new UnsupportedOperationException("mChat does not support group info nodes");
} }
@Override @Override
public int getGroupInfoInteger(String world, String group, String node, int defaultValue) { public int getPlayerInfoInteger(String world, String player, String node, int defaultValue) {
throw new UnsupportedOperationException("mChat does not support group info nodes"); String s = getPlayerInfoString(world, player, node, null);
} if (s == null)
return defaultValue;
@Override try {
public void setGroupInfoInteger(String world, String group, String node, int value) { return Integer.valueOf(s);
throw new UnsupportedOperationException("mChat does not support group info nodes"); } catch (NumberFormatException e) {
} return defaultValue;
}
}
@Override @Override
public double getPlayerInfoDouble(String world, String player, String node, double defaultValue) { public void setPlayerInfoInteger(String world, String player, String node, int value) {
String s = getPlayerInfoString(world, player, node, null); throw new UnsupportedOperationException("mChat does not support setting info nodes");
if (s == null) }
return defaultValue;
try {
return Double.valueOf(s);
} catch (NumberFormatException e) {
return defaultValue;
}
}
@Override @Override
public void setPlayerInfoDouble(String world, String player, String node, double value) { public int getGroupInfoInteger(String world, String group, String node, int defaultValue) {
throw new UnsupportedOperationException("mChat does not support setting info nodes"); throw new UnsupportedOperationException("mChat does not support group info nodes");
} }
@Override @Override
public double getGroupInfoDouble(String world, String group, String node,double defaultValue) { public void setGroupInfoInteger(String world, String group, String node, int value) {
throw new UnsupportedOperationException("mChat does not support group info nodes"); throw new UnsupportedOperationException("mChat does not support group info nodes");
} }
@Override @Override
public void setGroupInfoDouble(String world, String group, String node, double value) { public double getPlayerInfoDouble(String world, String player, String node, double defaultValue) {
throw new UnsupportedOperationException("mChat does not support group info nodes"); String s = getPlayerInfoString(world, player, node, null);
} if (s == null)
return defaultValue;
@Override try {
public boolean getPlayerInfoBoolean(String world, String player, String node, boolean defaultValue) { return Double.valueOf(s);
String s = getPlayerInfoString(world, player, node, null); } catch (NumberFormatException e) {
if (s == null) return defaultValue;
return defaultValue; }
}
try {
return Boolean.valueOf(s);
} catch (NumberFormatException e) {
return defaultValue;
}
}
@Override @Override
public void setPlayerInfoBoolean(String world, String player, String node, boolean value) { public void setPlayerInfoDouble(String world, String player, String node, double value) {
throw new UnsupportedOperationException("mChat does not support setting info nodes"); throw new UnsupportedOperationException("mChat does not support setting info nodes");
} }
@Override @Override
public boolean getGroupInfoBoolean(String world, String group, String node, boolean defaultValue) { public double getGroupInfoDouble(String world, String group, String node,double defaultValue) {
throw new UnsupportedOperationException("mChat does not support group info nodes"); throw new UnsupportedOperationException("mChat does not support group info nodes");
} }
@Override @Override
public void setGroupInfoBoolean(String world, String group, String node, boolean value) { public void setGroupInfoDouble(String world, String group, String node, double value) {
throw new UnsupportedOperationException("mChat does not support group info nodes"); throw new UnsupportedOperationException("mChat does not support group info nodes");
} }
@Override @Override
public String getPlayerInfoString(String world, String player, String node, String defaultValue) { public boolean getPlayerInfoBoolean(String world, String player, String node, boolean defaultValue) {
Player p = Bukkit.getServer().getPlayer(player); String s = getPlayerInfoString(world, player, node, null);
if (p ==null) { if (s == null)
throw new UnsupportedOperationException("mChat does not support offline player prefixes"); return defaultValue;
}
String s = mChat.getInfo(p, node);
return s == null ? defaultValue : s;
}
@Override try {
public void setPlayerInfoString(String world, String player, String node, String value) { return Boolean.valueOf(s);
throw new UnsupportedOperationException("mChat does not support setting info nodes"); } catch (NumberFormatException e) {
} return defaultValue;
}
}
@Override @Override
public String getGroupInfoString(String world, String group, String node, String defaultValue) { public void setPlayerInfoBoolean(String world, String player, String node, boolean value) {
throw new UnsupportedOperationException("mChat does not support group info nodes"); throw new UnsupportedOperationException("mChat does not support setting info nodes");
} }
@Override @Override
public void setGroupInfoString(String world, String group, String node, String value) { public boolean getGroupInfoBoolean(String world, String group, String node, boolean defaultValue) {
throw new UnsupportedOperationException("mChat does not support group info nodes"); 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");
}
} }