Changed listener to Highest, reverting some stuff that doesn't work.

This commit is contained in:
nossr50 2012-02-13 09:31:11 -08:00
parent a202d6168b
commit 3d699e612a
4 changed files with 3 additions and 47 deletions

View File

@ -1,27 +0,0 @@
/*
This file is part of mcMMO.
mcMMO is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
mcMMO is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with mcMMO. If not, see <http://www.gnu.org/licenses/>.
*/
package com.gmail.nossr50.datatypes;
import org.bukkit.entity.Entity;
import org.bukkit.event.entity.EntityDamageEvent;
public class FakeEntityDamageEvent extends EntityDamageEvent {
public FakeEntityDamageEvent(Entity damagee, DamageCause cause, int damage) {
super(damagee, cause, damage);
}
private static final long serialVersionUID = 1L;
}

View File

@ -146,6 +146,7 @@ public class mcBlockListener implements Listener
ItemStack inhand = player.getItemInHand(); ItemStack inhand = player.getItemInHand();
if(event.isCancelled()) if(event.isCancelled())
return; return;
if (event instanceof FakeBlockBreakEvent) if (event instanceof FakeBlockBreakEvent)
return; return;

View File

@ -53,13 +53,9 @@ public class mcEntityListener implements Listener
this.plugin = plugin; this.plugin = plugin;
} }
@EventHandler(priority = EventPriority.LOW) @EventHandler(priority = EventPriority.HIGHEST)
public void onEntityDamage(EntityDamageEvent event) public void onEntityDamage(EntityDamageEvent event)
{ {
//Pass around a fake event to see if any plugins cancel it
if(!m.EntityDamageEventSimulate(event.getEntity(), event.getCause(), event.getDamage()))
return;
if(event.isCancelled()) if(event.isCancelled())
return; return;
@ -70,6 +66,7 @@ public class mcEntityListener implements Listener
if(eventb.getEntity() instanceof Player && eventb.getDamager() instanceof Player && !event.getEntity().getWorld().getPVP()) if(eventb.getEntity() instanceof Player && eventb.getDamager() instanceof Player && !event.getEntity().getWorld().getPVP())
return; return;
} }
/* /*
* CHECK FOR INVULNERABILITY * CHECK FOR INVULNERABILITY
*/ */

View File

@ -26,10 +26,8 @@ import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.entity.*; import org.bukkit.entity.*;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import com.gmail.nossr50.config.*; import com.gmail.nossr50.config.*;
import com.gmail.nossr50.datatypes.FakeEntityDamageEvent;
import com.gmail.nossr50.datatypes.PlayerProfile; import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.datatypes.FakeBlockBreakEvent; import com.gmail.nossr50.datatypes.FakeBlockBreakEvent;
import com.gmail.nossr50.datatypes.SkillType; import com.gmail.nossr50.datatypes.SkillType;
@ -146,19 +144,6 @@ public class m
return false; //Return false if something went wrong return false; //Return false if something went wrong
} }
} }
public static boolean EntityDamageEventSimulate(Entity damagee, DamageCause cause, int damage)
{
FakeEntityDamageEvent event = new FakeEntityDamageEvent(damagee, cause, damage);
Bukkit.getServer().getPluginManager().callEvent(event);
if(!event.isCancelled())
{
return true; //Return true if not cancelled
} else {
return false; //Return false if cancelled
}
}
public static void damageTool(Player player, short damage) public static void damageTool(Player player, short damage)
{ {