Change the priorities of the event listeners, this way the protections

and the penalties get applied before the other listener cancels it.
This commit is contained in:
graywolf336 2014-01-21 20:52:19 -06:00
parent 06aa6629b7
commit 1cfd64164c
4 changed files with 13 additions and 22 deletions

View File

@ -15,6 +15,8 @@ With this being version 3 of this plugin, a couple things have changed but the c
ToDo ToDo
=== ===
* About everything * About everything
* Prisoner profiles
* Guards
Done Done
=== ===
@ -24,21 +26,7 @@ Done
* Delete commands are now remove * Delete commands are now remove
* Language system (adding language strings as I use them, be patient with me) * Language system (adding language strings as I use them, be patient with me)
* Handcuffs are now implemented * Handcuffs are now implemented
* Config value ``jailing.jail.defaultJail`` is now used
* Config value ``jailing.jail.defaultTime`` is now used
* The time passed can be represented by time shorthand, aka "3hours" or "15minutes" or etc (defaults to minutes) * The time passed can be represented by time shorthand, aka "3hours" or "15minutes" or etc (defaults to minutes)
* Config value ``jailing.jail.broadcastJailing`` is now used
* Config value ``jailing.jail.logToConsole`` is now used
* Config value ``jailing.jail.deleteInventory`` is now used
* Config value ``jailing.release.backToPreviousPosition`` is now used on jail and unjail
* Config value ``jailing.release.restorePreviousGameMode`` is now used
* Config value ``jailing.jail.gameMode`` is now used
* Config value ``jailing.during.ignoreSleeping`` is now used in one part
* Config value ``jailing.jail.commands`` is now used
* Config value ``jailing.during.maxFoodLevel`` is now used in one part
* Config value ``jailing.during.minFoodLevel`` is now used in one part
* Config value ``jailing.release.teleport`` is used in unjailing
* Config value ``jailing.release.commands`` is now used
[Jail 3.0 JavaDoc](http://ci.graywolf336.com/job/Jail/javadoc) [Jail 3.0 JavaDoc](http://ci.graywolf336.com/job/Jail/javadoc)
==== ====

View File

@ -1,6 +1,7 @@
package com.graywolf336.jail.listeners; package com.graywolf336.jail.listeners;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.BlockPlaceEvent; import org.bukkit.event.block.BlockPlaceEvent;
@ -15,7 +16,7 @@ public class BlockListener implements Listener {
this.pl = plugin; this.pl = plugin;
} }
@EventHandler(ignoreCancelled=true) @EventHandler(ignoreCancelled=true, priority = EventPriority.HIGHEST)
public void blockBreak(BlockBreakEvent event) { public void blockBreak(BlockBreakEvent event) {
//If we're in debugging mode, let's send the player what block they're breaking. //If we're in debugging mode, let's send the player what block they're breaking.
if(pl.inDebug()) event.getPlayer().sendMessage("[Jail Debug]: " + event.getBlock().getType().toString()); if(pl.inDebug()) event.getPlayer().sendMessage("[Jail Debug]: " + event.getBlock().getType().toString());
@ -36,7 +37,7 @@ public class BlockListener implements Listener {
} }
} }
@EventHandler(ignoreCancelled=true) @EventHandler(ignoreCancelled=true, priority = EventPriority.HIGHEST)
public void blockPlace(BlockPlaceEvent event) { public void blockPlace(BlockPlaceEvent event) {
//If we're in debugging mode, let's send the player what block they're placing. //If we're in debugging mode, let's send the player what block they're placing.
if(pl.inDebug()) event.getPlayer().sendMessage("[Jail Debug]: " + event.getBlock().getType().toString()); if(pl.inDebug()) event.getPlayer().sendMessage("[Jail Debug]: " + event.getBlock().getType().toString());

View File

@ -6,6 +6,7 @@ import java.util.Set;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.event.block.Action; import org.bukkit.event.block.Action;
import org.bukkit.event.entity.FoodLevelChangeEvent; import org.bukkit.event.entity.FoodLevelChangeEvent;
@ -49,7 +50,7 @@ public class PlayerListener implements Listener {
} }
} }
@EventHandler(ignoreCancelled=true) @EventHandler(ignoreCancelled=true, priority = EventPriority.LOW)
public void chatting(AsyncPlayerChatEvent event) { public void chatting(AsyncPlayerChatEvent event) {
if(pl.getJailManager().isPlayerJailed(event.getPlayer().getName())) { if(pl.getJailManager().isPlayerJailed(event.getPlayer().getName())) {
if(pl.getJailManager().getPrisoner(event.getPlayer().getName()).isMuted()) { if(pl.getJailManager().getPrisoner(event.getPlayer().getName()).isMuted()) {
@ -100,7 +101,7 @@ public class PlayerListener implements Listener {
} }
} }
@EventHandler @EventHandler(priority = EventPriority.LOW)
public void foodControl(FoodLevelChangeEvent event) { public void foodControl(FoodLevelChangeEvent event) {
if(pl.getConfig().getBoolean(Settings.FOODCONTROL.getPath())) { if(pl.getConfig().getBoolean(Settings.FOODCONTROL.getPath())) {
if(pl.getJailManager().isPlayerJailed(event.getEntity().getName())) { if(pl.getJailManager().isPlayerJailed(event.getEntity().getName())) {

View File

@ -4,6 +4,7 @@ import java.util.concurrent.TimeUnit;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.event.block.Action; import org.bukkit.event.block.Action;
import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.event.block.BlockBreakEvent;
@ -23,7 +24,7 @@ public class ProtectionListener implements Listener {
this.pl = plugin; this.pl = plugin;
} }
@EventHandler(ignoreCancelled=true) @EventHandler(ignoreCancelled=true, priority = EventPriority.LOW)
public void protectionBlockBreaking(BlockBreakEvent event) { public void protectionBlockBreaking(BlockBreakEvent event) {
//Before we check if the player is jailed, let's save a //Before we check if the player is jailed, let's save a
//tiny bit of resources and check if this protection is enabled //tiny bit of resources and check if this protection is enabled
@ -69,7 +70,7 @@ public class ProtectionListener implements Listener {
} }
} }
@EventHandler(ignoreCancelled=true) @EventHandler(ignoreCancelled=true, priority = EventPriority.LOW)
public void protectionBlockPlacing(BlockPlaceEvent event) { public void protectionBlockPlacing(BlockPlaceEvent event) {
//Before we check if the player is jailed, let's save a //Before we check if the player is jailed, let's save a
//tiny bit of resources and check if this protection is enabled //tiny bit of resources and check if this protection is enabled
@ -115,7 +116,7 @@ public class ProtectionListener implements Listener {
} }
} }
@EventHandler(ignoreCancelled=true) @EventHandler(ignoreCancelled=true, priority = EventPriority.LOW)
public void commandProtection(PlayerCommandPreprocessEvent event) { public void commandProtection(PlayerCommandPreprocessEvent event) {
//Before we check if the player is jailed, let's save a //Before we check if the player is jailed, let's save a
//tiny bit of resources and check if this protection is enabled //tiny bit of resources and check if this protection is enabled
@ -161,7 +162,7 @@ public class ProtectionListener implements Listener {
} }
} }
@EventHandler(ignoreCancelled=true) @EventHandler(ignoreCancelled=true, priority = EventPriority.LOW)
public void chestProtection(PlayerInteractEvent event) { public void chestProtection(PlayerInteractEvent event) {
//First thing is first, let's be sure the player we're dealing with is in jail //First thing is first, let's be sure the player we're dealing with is in jail
if(pl.getJailManager().isPlayerJailed(event.getPlayer().getName())) { if(pl.getJailManager().isPlayerJailed(event.getPlayer().getName())) {