mirror of
https://github.com/EssentialsX/Essentials.git
synced 2024-12-22 09:08:01 +01:00
If Essentials core fails to read one of the configs now, it will disable itself. If other modules detect that Essentials is not enabled, they will be disabled too. EssentialsProtect will go into emergency mode, canceling all events that could hurt your world. Fix the file and either restart or reload the server.
This commit is contained in:
parent
15d8ec6026
commit
5e2123c91e
@ -47,17 +47,21 @@ import org.bukkit.command.PluginCommand;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Event.Priority;
|
||||
import org.bukkit.event.Event.Type;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerListener;
|
||||
import org.bukkit.plugin.InvalidDescriptionException;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.PluginDescriptionFile;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.bukkit.scheduler.BukkitScheduler;
|
||||
import org.yaml.snakeyaml.Yaml;
|
||||
import org.yaml.snakeyaml.error.YAMLException;
|
||||
|
||||
|
||||
public class Essentials extends JavaPlugin implements IEssentials
|
||||
{
|
||||
public static final int BUKKIT_VERSION = 1522;
|
||||
public static final int BUKKIT_VERSION = 1526;
|
||||
private static final Logger LOGGER = Logger.getLogger("Minecraft");
|
||||
private transient ISettings settings;
|
||||
private final transient TNTExplodeListener tntListener = new TNTExplodeListener(this);
|
||||
@ -112,32 +116,6 @@ public class Essentials extends JavaPlugin implements IEssentials
|
||||
i18n = new I18n(this);
|
||||
i18n.onEnable();
|
||||
execTimer.mark("I18n1");
|
||||
final EssentialsUpgrade upgrade = new EssentialsUpgrade(this);
|
||||
upgrade.beforeSettings();
|
||||
execTimer.mark("Upgrade");
|
||||
confList = new ArrayList<IConf>();
|
||||
settings = new Settings(this);
|
||||
confList.add(settings);
|
||||
execTimer.mark("Settings");
|
||||
upgrade.afterSettings();
|
||||
execTimer.mark("Upgrade2");
|
||||
i18n.updateLocale(settings.getLocale());
|
||||
userMap = new UserMap(this);
|
||||
confList.add(userMap);
|
||||
execTimer.mark("Init(Usermap)");
|
||||
spawn = new Spawn(getServer(), this.getDataFolder());
|
||||
confList.add(spawn);
|
||||
warps = new Warps(getServer(), this.getDataFolder());
|
||||
confList.add(warps);
|
||||
execTimer.mark("Init(Spawn/Warp)");
|
||||
worth = new Worth(this.getDataFolder());
|
||||
confList.add(worth);
|
||||
itemDb = new ItemDb(this);
|
||||
confList.add(itemDb);
|
||||
execTimer.mark("Init(Worth/ItemDB)");
|
||||
reload();
|
||||
backup = new Backup(this);
|
||||
|
||||
final PluginManager pm = getServer().getPluginManager();
|
||||
for (Plugin plugin : pm.getPlugins())
|
||||
{
|
||||
@ -153,7 +131,10 @@ public class Essentials extends JavaPlugin implements IEssentials
|
||||
final int versionNumber = Integer.parseInt(versionMatch.group(4));
|
||||
if (versionNumber < BUKKIT_VERSION)
|
||||
{
|
||||
LOGGER.log(Level.WARNING, _("notRecommendedBukkit"));
|
||||
LOGGER.log(Level.SEVERE, _("notRecommendedBukkit"));
|
||||
LOGGER.log(Level.SEVERE, _("requiredBukkit", Integer.toString(BUKKIT_VERSION)));
|
||||
this.setEnabled(false);
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -162,7 +143,62 @@ public class Essentials extends JavaPlugin implements IEssentials
|
||||
LOGGER.log(Level.INFO, getServer().getVersion());
|
||||
LOGGER.log(Level.INFO, getServer().getBukkitVersion());
|
||||
}
|
||||
execTimer.mark("BukkitCheck");
|
||||
try
|
||||
{
|
||||
final EssentialsUpgrade upgrade = new EssentialsUpgrade(this);
|
||||
upgrade.beforeSettings();
|
||||
execTimer.mark("Upgrade");
|
||||
confList = new ArrayList<IConf>();
|
||||
settings = new Settings(this);
|
||||
confList.add(settings);
|
||||
execTimer.mark("Settings");
|
||||
upgrade.afterSettings();
|
||||
execTimer.mark("Upgrade2");
|
||||
i18n.updateLocale(settings.getLocale());
|
||||
userMap = new UserMap(this);
|
||||
confList.add(userMap);
|
||||
execTimer.mark("Init(Usermap)");
|
||||
spawn = new Spawn(getServer(), this.getDataFolder());
|
||||
confList.add(spawn);
|
||||
warps = new Warps(getServer(), this.getDataFolder());
|
||||
confList.add(warps);
|
||||
execTimer.mark("Init(Spawn/Warp)");
|
||||
worth = new Worth(this.getDataFolder());
|
||||
confList.add(worth);
|
||||
itemDb = new ItemDb(this);
|
||||
confList.add(itemDb);
|
||||
execTimer.mark("Init(Worth/ItemDB)");
|
||||
reload();
|
||||
}
|
||||
catch (YAMLException exception)
|
||||
{
|
||||
if (pm.getPlugin("EssentialsUpdate") != null)
|
||||
{
|
||||
LOGGER.log(Level.SEVERE, _("essentialsHelp2"));
|
||||
}
|
||||
else
|
||||
{
|
||||
LOGGER.log(Level.SEVERE, _("essentialsHelp1"));
|
||||
}
|
||||
LOGGER.log(Level.SEVERE, exception.toString());
|
||||
pm.registerEvent(Type.PLAYER_JOIN, new PlayerListener() {
|
||||
|
||||
@Override
|
||||
public void onPlayerJoin(PlayerJoinEvent event)
|
||||
{
|
||||
event.getPlayer().sendMessage("Essentials failed to load, read the log file.");
|
||||
}
|
||||
|
||||
}, Priority.Low, this);
|
||||
for (Player player : getServer().getOnlinePlayers())
|
||||
{
|
||||
player.sendMessage("Essentials failed to load, read the log file.");
|
||||
}
|
||||
this.setEnabled(false);
|
||||
return;
|
||||
}
|
||||
backup = new Backup(this);
|
||||
permissionsHandler = new PermissionsHandler(this, settings.useBukkitPermissions());
|
||||
alternativeCommandsHandler = new AlternativeCommandsHandler(this);
|
||||
final EssentialsPluginListener serverListener = new EssentialsPluginListener(this);
|
||||
@ -275,7 +311,7 @@ public class Essentials extends JavaPlugin implements IEssentials
|
||||
if (pc != null)
|
||||
{
|
||||
alternativeCommandsHandler.executed(commandLabel, pc.getLabel());
|
||||
LOGGER.log(Level.FINE,"Essentials: Alternative command " + commandLabel + " found, using " + pc.getLabel());
|
||||
LOGGER.log(Level.FINE, "Essentials: Alternative command " + commandLabel + " found, using " + pc.getLabel());
|
||||
return pc.execute(sender, commandLabel, args);
|
||||
}
|
||||
}
|
||||
@ -444,7 +480,9 @@ public class Essentials extends JavaPlugin implements IEssentials
|
||||
if (user == null)
|
||||
{
|
||||
user = new User(base, this);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
user.update(base);
|
||||
}
|
||||
return user;
|
||||
|
@ -2,7 +2,6 @@ package com.earth2me.essentials;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import java.io.*;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
@ -112,7 +111,7 @@ public class EssentialsConf extends Configuration
|
||||
}
|
||||
catch (RuntimeException e)
|
||||
{
|
||||
LOGGER.log(Level.INFO, "File: " + configFile.toString());
|
||||
LOGGER.log(Level.SEVERE, "File broken: " + configFile.toString());
|
||||
throw e;
|
||||
}
|
||||
|
||||
|
@ -75,6 +75,8 @@ enchantmentRemoved = \u00a77The enchantment {0} has been removed from your item
|
||||
enchantments = \u00a77Enchantments: {0}
|
||||
errorCallingCommand=Error calling command /{0}
|
||||
errorWithMessage=\u00a7cError: {0}
|
||||
essentialsHelp1=The file is broken and Essentials can't open it. Essentials is now disabled. If you can't fix the file yourself, go to http://tiny.cc/EssentialsChat
|
||||
essentialsHelp2=The file is broken and Essentials can't open it. Essentials is now disabled. If you can't fix the file yourself, either type /essentialshelp in game or go to http://tiny.cc/EssentialsChat
|
||||
essentialsReload=\u00a77Essentials Reloaded {0}
|
||||
extinguish=\u00a77You extinguished yourself.
|
||||
extinguishOthers=\u00a77You extinguished {0}.
|
||||
@ -280,6 +282,7 @@ requestAcceptedFrom=\u00a77{0} accepted your teleport request.
|
||||
requestDenied=\u00a77Teleport request denied.
|
||||
requestDeniedFrom=\u00a77{0} denied your teleport request.
|
||||
requestSent=\u00a77Request sent to {0}\u00a77.
|
||||
requiredBukkit=You need atleast build {0} of CraftBukkit, download it from http://ci.bukkit.org.
|
||||
returnPlayerToJailError=Error occurred when trying to return player to jail.
|
||||
second=second
|
||||
seconds=seconds
|
||||
|
@ -75,6 +75,8 @@ enchantmentRemoved = \u00a77The enchantment {0} has been removed from your item
|
||||
enchantments = \u00a77Enchantments: {0}
|
||||
errorCallingCommand=Fejl ved opkald af kommando /{0}
|
||||
errorWithMessage=\u00a7cFejl: {0}
|
||||
essentialsHelp1=The file is broken and Essentials can't open it. Essentials is now disabled. If you can't fix the file yourself, go to http://tiny.cc/EssentialsChat
|
||||
essentialsHelp2=The file is broken and Essentials can't open it. Essentials is now disabled. If you can't fix the file yourself, either type /essentialshelp in game or go to http://tiny.cc/EssentialsChat
|
||||
essentialsReload=\u00a77Essentials Genindl\u00e6st {0}
|
||||
extinguish=\u00a77Du slukkede dig selv.
|
||||
extinguishOthers=\u00a77Du slukkede {0}.
|
||||
@ -280,6 +282,7 @@ requestAcceptedFrom=\u00a77{0} accepted your teleport request.
|
||||
requestDenied=\u00a77Teleporterings anmodning n\u00e6gtet.
|
||||
requestDeniedFrom=\u00a77{0} denied your teleport request.
|
||||
requestSent=\u00a77Anmodning sendt til {0}\u00a77.
|
||||
requiredBukkit=You need atleast build {0} of CraftBukkit, download it from http://ci.bukkit.org.
|
||||
returnPlayerToJailError=En fejl opstod ved fors\u00f8g p\u00e5 at returnere spiller til f\u00e6ngsel.
|
||||
second=sekunde
|
||||
seconds=sekunder
|
||||
|
@ -75,6 +75,8 @@ enchantmentRemoved = \u00a77The enchantment {0} has been removed from your item
|
||||
enchantments = \u00a77Enchantments: {0}
|
||||
errorCallingCommand=Fehler beim Aufrufen des Befehls /{0}
|
||||
errorWithMessage=\u00a7cFehler: {0}
|
||||
essentialsHelp1=The file is broken and Essentials can't open it. Essentials is now disabled. If you can't fix the file yourself, go to http://tiny.cc/EssentialsChat
|
||||
essentialsHelp2=The file is broken and Essentials can't open it. Essentials is now disabled. If you can't fix the file yourself, either type /essentialshelp in game or go to http://tiny.cc/EssentialsChat
|
||||
essentialsReload=\u00a77Essentials neu geladen {0}
|
||||
extinguish=\u00a77Du hast dich selbst gel\u00f6scht.
|
||||
extinguishOthers=\u00a77Du hast {0} gel\u00f6scht.
|
||||
@ -280,6 +282,7 @@ requestAcceptedFrom=\u00a77{0} hat deine Teleportierungsanfrage angenommen.
|
||||
requestDenied=\u00a77Teleportierungsanfrage verweigert.
|
||||
requestDeniedFrom=\u00a77{0} hat deine Teleportierungsanfrage abgelehnt.
|
||||
requestSent=\u00a77Anfrage gesendet an {0}\u00a77.
|
||||
requiredBukkit=You need atleast build {0} of CraftBukkit, download it from http://ci.bukkit.org.
|
||||
returnPlayerToJailError=Fehler beim Versuch, den Spieler ins Gef\u00e4ngnis zu teleportieren.
|
||||
second=Sekunde
|
||||
seconds=Sekunden
|
||||
|
@ -75,6 +75,8 @@ enchantmentRemoved = \u00a77The enchantment {0} has been removed from your item
|
||||
enchantments = \u00a77Enchantments: {0}
|
||||
errorCallingCommand=Error calling command /{0}
|
||||
errorWithMessage=\u00a7cError: {0}
|
||||
essentialsHelp1=The file is broken and Essentials can't open it. Essentials is now disabled. If you can't fix the file yourself, go to http://tiny.cc/EssentialsChat
|
||||
essentialsHelp2=The file is broken and Essentials can't open it. Essentials is now disabled. If you can't fix the file yourself, either type /essentialshelp in game or go to http://tiny.cc/EssentialsChat
|
||||
essentialsReload=\u00a77Essentials Reloaded {0}
|
||||
extinguish=\u00a77You extinguished yourself.
|
||||
extinguishOthers=\u00a77You extinguished {0}.
|
||||
@ -280,6 +282,7 @@ requestAcceptedFrom=\u00a77{0} accepted your teleport request.
|
||||
requestDenied=\u00a77Teleport request denied.
|
||||
requestDeniedFrom=\u00a77{0} denied your teleport request
|
||||
requestSent=\u00a77Request sent to {0}\u00a77.
|
||||
requiredBukkit=You need atleast build {0} of CraftBukkit, download it from http://ci.bukkit.org.
|
||||
returnPlayerToJailError=Error occurred when trying to return player to jail.
|
||||
second=second
|
||||
seconds=seconds
|
||||
|
@ -75,6 +75,8 @@ enchantmentRemoved = \u00a77The enchantment {0} has been removed from your item
|
||||
enchantments = \u00a77Enchantments: {0}
|
||||
errorCallingCommand=Error al ejecutar el comando /{0}
|
||||
errorWithMessage=\u00a7cError: {0}
|
||||
essentialsHelp1=The file is broken and Essentials can't open it. Essentials is now disabled. If you can't fix the file yourself, go to http://tiny.cc/EssentialsChat
|
||||
essentialsHelp2=The file is broken and Essentials can't open it. Essentials is now disabled. If you can't fix the file yourself, either type /essentialshelp in game or go to http://tiny.cc/EssentialsChat
|
||||
essentialsReload=\u00a77Essentials Recargado {0}
|
||||
extinguish=\u00a77Te has suicidado.
|
||||
extinguishOthers=\u00a77Has matado a {0}.
|
||||
@ -280,6 +282,7 @@ requestAcceptedFrom=\u00a77{0} acepto tu peticion de teletransporte.
|
||||
requestDenied=\u00a77Peticion de teletransporte denegada.
|
||||
requestDeniedFrom=\u00a77{0} ha denegado tu peticion de teletransporte.
|
||||
requestSent=\u00a77Peticion enviada a {0}\u00a77.
|
||||
requiredBukkit=You need atleast build {0} of CraftBukkit, download it from http://ci.bukkit.org.
|
||||
returnPlayerToJailError=Error al intentar quitar al jugador de la carcel.
|
||||
second=segundo
|
||||
seconds=segundos
|
||||
|
@ -75,6 +75,8 @@ enchantmentRemoved = \u00a77The enchantment {0} has been removed from your item
|
||||
enchantments = \u00a77Enchantments : {0}
|
||||
errorCallingCommand=Erreur en appelant la commande /{0}
|
||||
errorWithMessage=\u00a7cErreur : {0}
|
||||
essentialsHelp1=The file is broken and Essentials can't open it. Essentials is now disabled. If you can't fix the file yourself, go to http://tiny.cc/EssentialsChat
|
||||
essentialsHelp2=The file is broken and Essentials can't open it. Essentials is now disabled. If you can't fix the file yourself, either type /essentialshelp in game or go to http://tiny.cc/EssentialsChat
|
||||
essentialsReload=\u00a77Essentials Recharg\u00e9 {0}
|
||||
extinguish=\u00a77Vous cessez de br\u00fbler.
|
||||
extinguishOthers=\u00a77Vous avez \u00e9teint la combustion de {0}.
|
||||
@ -280,6 +282,7 @@ requestAcceptedFrom=\u00a77{0} a accept\u00e9 votre demande de t\u00e9l\u00e9por
|
||||
requestDenied=\u00a77Demande de t\u00e9l\u00e9portation refus\u00e9e.
|
||||
requestDeniedFrom=\u00a77{0} a refus\u00e9 votre demande de t\u00e9l\u00e9portation.
|
||||
requestSent=\u00a77Requ\u00eate envoy\u00e9e \u00e0 {0}\u00a77.
|
||||
requiredBukkit=You need atleast build {0} of CraftBukkit, download it from http://ci.bukkit.org.
|
||||
returnPlayerToJailError=Erreur survenue lors de la tentative d''emprisonner de nouveau un joueur.
|
||||
second=seconde
|
||||
seconds=secondes
|
||||
|
@ -75,6 +75,8 @@ enchantmentRemoved = \u00a77The enchantment {0} has been removed from your item
|
||||
enchantments = \u00a77Enchantments: {0}
|
||||
errorCallingCommand=Fout bij het aanroepen van de opdracht /{0}
|
||||
errorWithMessage=\u00a7cFout: {0}
|
||||
essentialsHelp1=The file is broken and Essentials can't open it. Essentials is now disabled. If you can't fix the file yourself, go to http://tiny.cc/EssentialsChat
|
||||
essentialsHelp2=The file is broken and Essentials can't open it. Essentials is now disabled. If you can't fix the file yourself, either type /essentialshelp in game or go to http://tiny.cc/EssentialsChat
|
||||
essentialsReload=\u00a77Essentials is herladen {0}
|
||||
extinguish=\u00a77Je hebt jezelf geblust.
|
||||
extinguishOthers=\u00a77Je hebt {0} geblust.
|
||||
@ -280,6 +282,7 @@ requestAcceptedFrom=\u00a77{0} accepted your teleport request.
|
||||
requestDenied=\u00a77Teleporteer aanvraag geweigerd.
|
||||
requestDeniedFrom=\u00a77{0} denied your teleport request.
|
||||
requestSent=\u00a77Aanvraag verstuurd naar {0}\u00a77.
|
||||
requiredBukkit=You need atleast build {0} of CraftBukkit, download it from http://ci.bukkit.org.
|
||||
returnPlayerToJailError=Fout opgetreden bij terugzetten van speler in gevangenis.
|
||||
second=seconde
|
||||
seconds=seconde
|
||||
|
@ -21,6 +21,15 @@ public class EssentialsChat extends JavaPlugin
|
||||
{
|
||||
final PluginManager pluginManager = getServer().getPluginManager();
|
||||
final IEssentials ess = (IEssentials)pluginManager.getPlugin("Essentials");
|
||||
if (!this.getDescription().getVersion().equals(ess.getDescription().getVersion()))
|
||||
{
|
||||
LOGGER.log(Level.WARNING, _("versionMismatchAll"));
|
||||
}
|
||||
if (!ess.isEnabled())
|
||||
{
|
||||
this.setEnabled(false);
|
||||
return;
|
||||
}
|
||||
|
||||
chatListener = new HashMap<String, IEssentialsChatListener>();
|
||||
|
||||
@ -30,16 +39,16 @@ public class EssentialsChat extends JavaPlugin
|
||||
pluginManager.registerEvent(Type.PLAYER_CHAT, playerListenerLowest, Priority.Lowest, this);
|
||||
pluginManager.registerEvent(Type.PLAYER_CHAT, playerListenerNormal, Priority.Normal, this);
|
||||
pluginManager.registerEvent(Type.PLAYER_CHAT, playerListenerHighest, Priority.Highest, this);
|
||||
if (!this.getDescription().getVersion().equals(ess.getDescription().getVersion()))
|
||||
{
|
||||
LOGGER.log(Level.WARNING, _("versionMismatchAll"));
|
||||
}
|
||||
|
||||
LOGGER.info(_("loadinfo", this.getDescription().getName(), this.getDescription().getVersion(), "essentials team"));
|
||||
}
|
||||
|
||||
public void onDisable()
|
||||
{
|
||||
chatListener.clear();
|
||||
if (chatListener != null)
|
||||
{
|
||||
chatListener.clear();
|
||||
}
|
||||
}
|
||||
|
||||
public void addEssentialsChatListener(final String plugin, final IEssentialsChatListener listener)
|
||||
|
@ -28,13 +28,17 @@ public class EssentialsGeoIP extends JavaPlugin
|
||||
{
|
||||
final PluginManager pm = getServer().getPluginManager();
|
||||
final IEssentials ess = (IEssentials)pm.getPlugin("Essentials");
|
||||
final EssentialsGeoIPPlayerListener playerListener = new EssentialsGeoIPPlayerListener(getDataFolder(), ess);
|
||||
pm.registerEvent(Type.PLAYER_JOIN, playerListener, Priority.Monitor, this);
|
||||
|
||||
if (!this.getDescription().getVersion().equals(ess.getDescription().getVersion()))
|
||||
{
|
||||
logger.log(Level.WARNING, _("versionMismatchAll"));
|
||||
}
|
||||
if (!ess.isEnabled()) {
|
||||
this.setEnabled(false);
|
||||
return;
|
||||
}
|
||||
final EssentialsGeoIPPlayerListener playerListener = new EssentialsGeoIPPlayerListener(getDataFolder(), ess);
|
||||
pm.registerEvent(Type.PLAYER_JOIN, playerListener, Priority.Monitor, this);
|
||||
|
||||
logger.info(_("loadinfo", this.getDescription().getName(), this.getDescription().getVersion(), "essentials team"));
|
||||
|
||||
logger.log(Level.INFO, "This product includes GeoLite data created by MaxMind, available from http://www.maxmind.com/.");
|
||||
|
@ -0,0 +1,36 @@
|
||||
package com.earth2me.essentials.protect;
|
||||
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.event.block.BlockBurnEvent;
|
||||
import org.bukkit.event.block.BlockFromToEvent;
|
||||
import org.bukkit.event.block.BlockIgniteEvent;
|
||||
import org.bukkit.event.block.BlockListener;
|
||||
|
||||
|
||||
public class EmergencyBlockListener extends BlockListener
|
||||
{
|
||||
|
||||
@Override
|
||||
public void onBlockBurn(final BlockBurnEvent event)
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockIgnite(final BlockIgniteEvent event)
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockFromTo(final BlockFromToEvent event)
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockBreak(final BlockBreakEvent event)
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
package com.earth2me.essentials.protect;
|
||||
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
import org.bukkit.event.entity.EntityExplodeEvent;
|
||||
import org.bukkit.event.entity.EntityListener;
|
||||
|
||||
|
||||
public class EmergencyEntityListener extends EntityListener
|
||||
{
|
||||
|
||||
@Override
|
||||
public void onEntityExplode(final EntityExplodeEvent event)
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEntityDamage(final EntityDamageEvent event)
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
package com.earth2me.essentials.protect;
|
||||
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerListener;
|
||||
|
||||
|
||||
public class EmergencyPlayerListener extends PlayerListener
|
||||
{
|
||||
|
||||
@Override
|
||||
public void onPlayerJoin(PlayerJoinEvent event)
|
||||
{
|
||||
event.getPlayer().sendMessage("Essentials Protect is in emergency mode. Check your log for errors.");
|
||||
}
|
||||
|
||||
}
|
@ -51,6 +51,14 @@ public class EssentialsProtect extends JavaPlugin implements IConf, IProtect
|
||||
{
|
||||
final PluginManager pm = this.getServer().getPluginManager();
|
||||
ess = (IEssentials)pm.getPlugin("Essentials");
|
||||
if (!this.getDescription().getVersion().equals(ess.getDescription().getVersion()))
|
||||
{
|
||||
LOGGER.log(Level.WARNING, _("versionMismatchAll"));
|
||||
}
|
||||
if (!ess.isEnabled()) {
|
||||
enableEmergencyMode(pm);
|
||||
return;
|
||||
}
|
||||
|
||||
final EssentialsProtectPlayerListener playerListener = new EssentialsProtectPlayerListener(this);
|
||||
pm.registerEvent(Type.PLAYER_INTERACT, playerListener, Priority.Low, this);
|
||||
@ -79,13 +87,28 @@ public class EssentialsProtect extends JavaPlugin implements IConf, IProtect
|
||||
|
||||
reloadConfig();
|
||||
ess.addReloadListener(this);
|
||||
if (!this.getDescription().getVersion().equals(ess.getDescription().getVersion()))
|
||||
{
|
||||
LOGGER.log(Level.WARNING, _("versionMismatchAll"));
|
||||
}
|
||||
LOGGER.info(_("loadinfo", this.getDescription().getName(), this.getDescription().getVersion(), "essentials team"));
|
||||
}
|
||||
|
||||
private void enableEmergencyMode(final PluginManager pm)
|
||||
{
|
||||
final EmergencyBlockListener emBlockListener = new EmergencyBlockListener();
|
||||
final EmergencyEntityListener emEntityListener = new EmergencyEntityListener();
|
||||
final EmergencyPlayerListener emPlayerListener = new EmergencyPlayerListener();
|
||||
pm.registerEvent(Type.PLAYER_JOIN, emPlayerListener, Priority.Low, this);
|
||||
pm.registerEvent(Type.BLOCK_BURN, emBlockListener, Priority.Low, this);
|
||||
pm.registerEvent(Type.BLOCK_IGNITE, emBlockListener, Priority.Low, this);
|
||||
pm.registerEvent(Type.BLOCK_FROMTO, emBlockListener, Priority.Low, this);
|
||||
pm.registerEvent(Type.BLOCK_BREAK, emBlockListener, Priority.Low, this);
|
||||
pm.registerEvent(Type.ENTITY_DAMAGE, emEntityListener, Priority.Low, this);
|
||||
pm.registerEvent(Type.ENTITY_EXPLODE, emEntityListener, Priority.Low, this);
|
||||
for (Player player : getServer().getOnlinePlayers())
|
||||
{
|
||||
player.sendMessage("Essentials Protect is in emergency mode. Check your log for errors.");
|
||||
}
|
||||
LOGGER.log(Level.SEVERE, "Essentials not installed or failed to load. Essenials Protect is in emergency mode now.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkProtectionItems(final ProtectConfig list, final int id)
|
||||
{
|
||||
|
@ -6,4 +6,4 @@ version: TeamCity
|
||||
website: http://www.earth2me.net:8001/
|
||||
description: Provides protection for various parts of the world.
|
||||
authors: [Zenexer, ementalo, Aelux, Brettflan, KimKandor, snowleo, ceulemans, Xeology]
|
||||
depend: [Essentials]
|
||||
softdepend: [Essentials]
|
@ -21,15 +21,18 @@ public class EssentialsSpawn extends JavaPlugin
|
||||
{
|
||||
final PluginManager pluginManager = getServer().getPluginManager();
|
||||
ess = (IEssentials)pluginManager.getPlugin("Essentials");
|
||||
final EssentialsSpawnPlayerListener playerListener = new EssentialsSpawnPlayerListener(ess);
|
||||
pluginManager.registerEvent(Type.PLAYER_RESPAWN, playerListener, Priority.Low, this);
|
||||
pluginManager.registerEvent(Type.PLAYER_JOIN, playerListener, Priority.Low, this);
|
||||
|
||||
|
||||
if (!this.getDescription().getVersion().equals(ess.getDescription().getVersion()))
|
||||
{
|
||||
LOGGER.log(Level.WARNING, _("versionMismatchAll"));
|
||||
}
|
||||
if (!ess.isEnabled()) {
|
||||
this.setEnabled(false);
|
||||
return;
|
||||
}
|
||||
final EssentialsSpawnPlayerListener playerListener = new EssentialsSpawnPlayerListener(ess);
|
||||
pluginManager.registerEvent(Type.PLAYER_RESPAWN, playerListener, Priority.Low, this);
|
||||
pluginManager.registerEvent(Type.PLAYER_JOIN, playerListener, Priority.Low, this);
|
||||
|
||||
LOGGER.info(_("loadinfo", this.getDescription().getName(), this.getDescription().getVersion(), "essentials team"));
|
||||
}
|
||||
|
||||
|
@ -36,9 +36,14 @@ public class EssentialsXMPP extends JavaPlugin implements IEssentialsXMPP
|
||||
|
||||
final PluginManager pluginManager = getServer().getPluginManager();
|
||||
ess = (IEssentials)pluginManager.getPlugin("Essentials");
|
||||
if (ess == null)
|
||||
if (!this.getDescription().getVersion().equals(ess.getDescription().getVersion()))
|
||||
{
|
||||
LOGGER.log(Level.SEVERE, "Failed to load Essentials before EssentialsXMPP");
|
||||
LOGGER.log(Level.WARNING, _("versionMismatchAll"));
|
||||
}
|
||||
if (!ess.isEnabled())
|
||||
{
|
||||
this.setEnabled(false);
|
||||
return;
|
||||
}
|
||||
|
||||
final EssentialsXMPPPlayerListener playerListener = new EssentialsXMPPPlayerListener(ess);
|
||||
@ -52,17 +57,16 @@ public class EssentialsXMPP extends JavaPlugin implements IEssentialsXMPP
|
||||
ess.addReloadListener(users);
|
||||
ess.addReloadListener(xmpp);
|
||||
|
||||
if (!this.getDescription().getVersion().equals(ess.getDescription().getVersion()))
|
||||
{
|
||||
LOGGER.log(Level.WARNING, _("versionMismatchAll"));
|
||||
}
|
||||
LOGGER.info(_("loadinfo", this.getDescription().getName(), this.getDescription().getVersion(), "essentials team"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable()
|
||||
{
|
||||
xmpp.disconnect();
|
||||
if (xmpp != null)
|
||||
{
|
||||
xmpp.disconnect();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
Reference in New Issue
Block a user