2018-07-22 00:45:56 +00:00
|
|
|
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();
|
|
|
|
|
2018-07-25 02:08:29 +00:00
|
|
|
if (item != null && item.getType().equals(Material.POTATO))
|
2018-07-22 00:45:56 +00:00
|
|
|
{
|
|
|
|
event.setCancelled(true);
|
|
|
|
attacker.addPassenger(event.getEntity());
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|