Revert emergency listener to old style

Stops peoples world world burning down if they throw in 2.8, on a 1.0 server.
This commit is contained in:
KHobbits 2012-01-26 21:21:13 +00:00
parent b8944d0b25
commit 9b58b2b9c0
4 changed files with 92 additions and 2 deletions

View File

@ -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;
@Deprecated
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);
}
}

View File

@ -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;
@Deprecated
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);
}
}

View File

@ -0,0 +1,16 @@
package com.earth2me.essentials.protect;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerListener;
@Deprecated
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.");
}
}

View File

@ -9,6 +9,8 @@ import java.util.logging.Level;
import java.util.logging.LogRecord;
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.plugin.Plugin;
import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.java.JavaPlugin;
@ -63,8 +65,22 @@ public class EssentialsProtect extends JavaPlugin implements IProtect
private void enableEmergencyMode(final PluginManager pm)
{
final EmergencyListener emListener = new EmergencyListener();
pm.registerEvents(emListener, this);
//final EmergencyListener emListener = new EmergencyListener();
//pm.registerEvents(emListener, this);
//TODO: Remove deprecated listners in a few weeks.
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.");