mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2024-11-19 13:55:00 +00:00
57 lines
1.3 KiB
Java
57 lines
1.3 KiB
Java
|
package me.totalfreedom.totalfreedommod.fun;
|
||
|
|
||
|
import me.totalfreedom.totalfreedommod.FreedomService;
|
||
|
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
||
|
import org.bukkit.Material;
|
||
|
import org.bukkit.event.EventHandler;
|
||
|
import org.bukkit.event.EventPriority;
|
||
|
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||
|
import org.bukkit.entity.Player;
|
||
|
import org.bukkit.inventory.ItemStack;
|
||
|
|
||
|
public class MobStacker extends FreedomService
|
||
|
{
|
||
|
|
||
|
public MobStacker(TotalFreedomMod plugin)
|
||
|
{
|
||
|
super(plugin);
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
protected void onStart()
|
||
|
{
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
protected void onStop()
|
||
|
{
|
||
|
}
|
||
|
|
||
|
@EventHandler(priority = EventPriority.MONITOR)
|
||
|
public void onEntityDamage(EntityDamageByEntityEvent event)
|
||
|
{
|
||
|
if (event.getEntity() instanceof Player || !(event.getDamager() instanceof Player))
|
||
|
{
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
Player attacker = (Player)event.getDamager();
|
||
|
|
||
|
if (!plugin.al.isSeniorAdmin(attacker))
|
||
|
{
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
ItemStack item = attacker.getInventory().getItemInMainHand();
|
||
|
|
||
|
if (item != null && item.getType().equals(Material.POTATO_ITEM))
|
||
|
{
|
||
|
event.setCancelled(true);
|
||
|
attacker.addPassenger(event.getEntity());
|
||
|
}
|
||
|
|
||
|
|
||
|
}
|
||
|
|
||
|
}
|