mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-22 21:26:46 +01:00
Changed listener to Highest, reverting some stuff that doesn't work.
This commit is contained in:
parent
a202d6168b
commit
3d699e612a
@ -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;
|
||||
}
|
@ -146,6 +146,7 @@ public class mcBlockListener implements Listener
|
||||
ItemStack inhand = player.getItemInHand();
|
||||
if(event.isCancelled())
|
||||
return;
|
||||
|
||||
if (event instanceof FakeBlockBreakEvent)
|
||||
return;
|
||||
|
||||
|
@ -53,13 +53,9 @@ public class mcEntityListener implements Listener
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOW)
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
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())
|
||||
return;
|
||||
|
||||
@ -70,6 +66,7 @@ public class mcEntityListener implements Listener
|
||||
if(eventb.getEntity() instanceof Player && eventb.getDamager() instanceof Player && !event.getEntity().getWorld().getPVP())
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* CHECK FOR INVULNERABILITY
|
||||
*/
|
||||
|
@ -26,10 +26,8 @@ import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.*;
|
||||
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import com.gmail.nossr50.config.*;
|
||||
import com.gmail.nossr50.datatypes.FakeEntityDamageEvent;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.FakeBlockBreakEvent;
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
@ -147,19 +145,6 @@ public class m
|
||||
}
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
if(player.getItemInHand().getTypeId() == 0)
|
||||
|
Loading…
Reference in New Issue
Block a user