mirror of
https://github.com/EssentialsX/Essentials.git
synced 2025-01-11 02:47:52 +01:00
Update to Register v1.0
Removed softDepend because of a bukkit bug. git-svn-id: https://svn.java.net/svn/essentials~svn/trunk@1459 e251c2fe-e539-e718-e476-b85c1f46cddb
This commit is contained in:
parent
2b4724dae2
commit
78ce69528f
@ -35,6 +35,7 @@ import org.bukkit.craftbukkit.scheduler.CraftScheduler;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Event.Priority;
|
||||
import org.bukkit.event.Event.Type;
|
||||
import org.bukkit.event.server.ServerListener;
|
||||
import org.bukkit.plugin.*;
|
||||
import org.bukkit.plugin.java.*;
|
||||
|
||||
@ -121,12 +122,6 @@ public class Essentials extends JavaPlugin
|
||||
logger.log(Level.WARNING, Util.format("versionMismatch", plugin.getDescription().getName()));
|
||||
}
|
||||
}
|
||||
if (!paymentMethod.hasMethod() && plugin != this)
|
||||
{
|
||||
if (getPaymentMethod().setMethod(plugin)) {
|
||||
logger.log(Level.INFO, "Payment method found (" + getPaymentMethod().getMethod().getName() + " version: " + getPaymentMethod().getMethod().getVersion() + ")");
|
||||
}
|
||||
}
|
||||
}
|
||||
Matcher versionMatch = Pattern.compile("git-Bukkit-([0-9]+).([0-9]+).([0-9]+)-[0-9]+-[0-9a-z]+-b([0-9]+)jnks.*").matcher(getServer().getVersion());
|
||||
if (versionMatch.matches())
|
||||
@ -143,6 +138,10 @@ public class Essentials extends JavaPlugin
|
||||
}
|
||||
|
||||
|
||||
ServerListener serverListener = new EssentialsPluginListener(paymentMethod);
|
||||
pm.registerEvent(Type.PLUGIN_ENABLE, serverListener, Priority.Low, this);
|
||||
pm.registerEvent(Type.PLUGIN_DISABLE, serverListener, Priority.Low, this);
|
||||
|
||||
playerListener = new EssentialsPlayerListener(this);
|
||||
pm.registerEvent(Type.PLAYER_JOIN, playerListener, Priority.Monitor, this);
|
||||
pm.registerEvent(Type.PLAYER_QUIT, playerListener, Priority.Monitor, this);
|
||||
@ -176,7 +175,7 @@ public class Essentials extends JavaPlugin
|
||||
pm.registerEvent(Type.BLOCK_PLACE, jail, Priority.High, this);
|
||||
pm.registerEvent(Type.PLAYER_INTERACT, jailPlayerListener, Priority.High, this);
|
||||
attachEcoListeners();
|
||||
|
||||
|
||||
if (settings.isNetherEnabled() && getServer().getWorlds().size() < 2)
|
||||
{
|
||||
getServer().createWorld(settings.getNetherName(), World.Environment.NETHER);
|
||||
@ -336,10 +335,10 @@ public class Essentials extends JavaPlugin
|
||||
if ("msg".equals(commandLabel.toLowerCase()) || "mail".equals(commandLabel.toLowerCase()) & sender instanceof CraftPlayer)
|
||||
{
|
||||
StringBuilder str = new StringBuilder();
|
||||
str.append(commandLabel + " ");
|
||||
str.append(commandLabel).append(" ");
|
||||
for (String a : args)
|
||||
{
|
||||
str.append(a + " ");
|
||||
str.append(a).append(" ");
|
||||
}
|
||||
for (Player player : getServer().getOnlinePlayers())
|
||||
{
|
||||
|
@ -0,0 +1,45 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import com.earth2me.essentials.register.payment.Methods;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import org.bukkit.event.server.PluginDisableEvent;
|
||||
import org.bukkit.event.server.PluginEnableEvent;
|
||||
import org.bukkit.event.server.ServerListener;
|
||||
|
||||
|
||||
public class EssentialsPluginListener extends ServerListener
|
||||
{
|
||||
Methods methods;
|
||||
private final Logger logger = Logger.getLogger("Minecraft");
|
||||
|
||||
public EssentialsPluginListener(Methods methods)
|
||||
{
|
||||
this.methods = methods;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPluginEnable(PluginEnableEvent event)
|
||||
{
|
||||
if (!methods.hasMethod())
|
||||
{
|
||||
if (methods.setMethod(event.getPlugin()))
|
||||
{
|
||||
logger.log(Level.INFO, "Payment method found (" + methods.getMethod().getName() + " version: " + methods.getMethod().getVersion() + ")");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPluginDisable(PluginDisableEvent event)
|
||||
{
|
||||
// Check to see if the plugin thats being disabled is the one we are using
|
||||
if (methods != null && methods.hasMethod())
|
||||
{
|
||||
if (methods.checkDisabled(event.getPlugin()))
|
||||
{
|
||||
logger.log(Level.INFO, "Payment method was disabled. No longer accepting payments.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -7,6 +7,7 @@ import org.bukkit.plugin.Plugin;
|
||||
public class MethodFactory {
|
||||
|
||||
private static Set<Method> Methods = new HashSet<Method>();
|
||||
private static Set<String> Dependencies = new HashSet<String>();
|
||||
|
||||
public static Method createMethod(Plugin plugin) {
|
||||
for (Method method: Methods) {
|
||||
@ -19,7 +20,12 @@ public class MethodFactory {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void addMethod(Method method) {
|
||||
public static void addMethod(String name, Method method) {
|
||||
Dependencies.add(name);
|
||||
Methods.add(method);
|
||||
}
|
||||
|
||||
public static Set<String> getDependencies() {
|
||||
return Dependencies;
|
||||
}
|
||||
}
|
||||
|
@ -1,15 +1,30 @@
|
||||
package com.earth2me.essentials.register.payment;
|
||||
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
|
||||
public class Methods {
|
||||
|
||||
private Method Method = null;
|
||||
|
||||
public boolean setMethod(Plugin method) {
|
||||
if (method.isEnabled()) {
|
||||
PluginManager manager = method.getServer().getPluginManager();
|
||||
|
||||
if (method != null && method.isEnabled()) {
|
||||
Method plugin = MethodFactory.createMethod(method);
|
||||
if (plugin != null) Method = plugin;
|
||||
} else {
|
||||
for(String name: MethodFactory.getDependencies()) {
|
||||
if(hasMethod()) break;
|
||||
|
||||
method = manager.getPlugin(name);
|
||||
if(method == null) continue;
|
||||
if(!method.isEnabled()) manager.enablePlugin(method);
|
||||
if(!method.isEnabled()) continue;
|
||||
|
||||
Method plugin = MethodFactory.createMethod(method);
|
||||
if (plugin != null) Method = plugin;
|
||||
}
|
||||
}
|
||||
|
||||
return hasMethod();
|
||||
|
@ -9,7 +9,8 @@ public class BOSE implements Method {
|
||||
private BOSEconomy BOSEconomy;
|
||||
|
||||
static {
|
||||
MethodFactory.addMethod(new BOSE());
|
||||
MethodFactory.addMethod("BOSEconomy", new BOSE());
|
||||
|
||||
}
|
||||
|
||||
public BOSEconomy getPlugin() {
|
||||
|
@ -10,7 +10,7 @@ public class iCo4 implements Method {
|
||||
private iConomy iConomy;
|
||||
|
||||
static {
|
||||
MethodFactory.addMethod(new iCo4());
|
||||
MethodFactory.addMethod("iConomy", new iCo4());
|
||||
}
|
||||
|
||||
public iConomy getPlugin() {
|
||||
|
@ -13,7 +13,7 @@ public class iCo5 implements Method {
|
||||
private iConomy iConomy;
|
||||
|
||||
static {
|
||||
MethodFactory.addMethod(new iCo5());
|
||||
MethodFactory.addMethod("iConomy", new iCo5());
|
||||
}
|
||||
|
||||
public iConomy getPlugin() {
|
||||
|
@ -6,7 +6,6 @@ version: TeamCity
|
||||
website: http://www.earth2me.net:8001/
|
||||
description: Provides an essential, core set of commands for Bukkit.
|
||||
authors: [Zenexer, ementalo, Aelux, Brettflan, KimKandor, snowleo, ceulemans, Xeology]
|
||||
softdepend: [Permissions, iConomy, BOSEconomy]
|
||||
commands:
|
||||
afk:
|
||||
description: Marks you as away-from-keyboard.
|
||||
|
Loading…
Reference in New Issue
Block a user