mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2024-11-26 17:05:01 +00:00
Fixed moblimiter
This commit is contained in:
parent
e621290fae
commit
d8f2433c5b
@ -20,9 +20,9 @@ public class Command_mp extends TFM_Command
|
||||
int removed = 0;
|
||||
for (World world : Bukkit.getWorlds())
|
||||
{
|
||||
for (Entity ent : world.getEntities())
|
||||
for (Entity ent : world.getLivingEntities())
|
||||
{
|
||||
if (ent instanceof Creature || ent instanceof Ghast || ent instanceof Slime)
|
||||
if (ent instanceof Creature || ent instanceof Ghast || ent instanceof Slime || ent instanceof EnderDragon)
|
||||
{
|
||||
ent.remove();
|
||||
removed++;
|
||||
|
@ -3,7 +3,14 @@ package me.StevenLawson.TotalFreedomMod.Listener;
|
||||
import me.StevenLawson.TotalFreedomMod.TFM_UserInfo;
|
||||
import me.StevenLawson.TotalFreedomMod.TFM_Util;
|
||||
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Creature;
|
||||
import org.bukkit.entity.EnderDragon;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Ghast;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Slime;
|
||||
import org.bukkit.event.entity.*;
|
||||
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
||||
|
||||
@ -83,11 +90,31 @@ public class TFM_EntityListener extends EntityListener
|
||||
{
|
||||
if (TotalFreedomMod.mobLimiterEnabled)
|
||||
{
|
||||
if (event.getEntity() instanceof Ghast || event.getEntity() instanceof Slime || event.getEntity() instanceof EnderDragon)
|
||||
{
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (TotalFreedomMod.mobLimiterMax > 0)
|
||||
{
|
||||
if (TFM_Util.getMobAmount(event.getEntity().getWorld()) > TotalFreedomMod.mobLimiterMax)
|
||||
int mobcount = 0;
|
||||
|
||||
for (World world : Bukkit.getWorlds())
|
||||
{
|
||||
for (Entity ent : world.getLivingEntities())
|
||||
{
|
||||
if (ent instanceof Creature || ent instanceof Ghast || ent instanceof Slime || ent instanceof EnderDragon)
|
||||
{
|
||||
mobcount++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (mobcount > TotalFreedomMod.mobLimiterMax)
|
||||
{
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -580,18 +580,4 @@ public class TFM_Util
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static int getMobAmount(World world)
|
||||
{
|
||||
List<LivingEntity> mobs = world.getLivingEntities();
|
||||
for (int j = 0; j < mobs.size(); j++)
|
||||
{
|
||||
if (!Creature.class.isInstance(mobs.get(j)))
|
||||
{
|
||||
mobs.remove(j);
|
||||
j--;
|
||||
}
|
||||
}
|
||||
return mobs.size();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user