mirror of
https://github.com/essentials/Essentials.git
synced 2025-08-11 17:15:07 +02:00
Move creaturespawn options to worldoptions
This commit is contained in:
@@ -42,7 +42,7 @@ public class Commandspawner extends EssentialsCommand
|
||||
@Cleanup
|
||||
ISettings settings = ess.getSettings();
|
||||
settings.acquireReadLock();
|
||||
if (settings.getData().getGeneral().getPreventSpawn(mob.getType().toString().toLowerCase(Locale.ENGLISH)))
|
||||
if (settings.getData().getWorldOptions(user.getWorld().getName()).getPreventSpawn(mob.getType().toString().toLowerCase(Locale.ENGLISH)))
|
||||
{
|
||||
throw new Exception(_("disabledToSpawnMob"));
|
||||
}
|
||||
|
@@ -134,7 +134,7 @@ public class EssentialsEntityListener implements Listener
|
||||
event.setDeathMessage("");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@EventHandler(priority = EventPriority.LOW)
|
||||
public void onPlayerDeathExpEvent(final PlayerDeathEvent event)
|
||||
{
|
||||
@@ -173,7 +173,7 @@ public class EssentialsEntityListener implements Listener
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onCreatureSpawn(final CreatureSpawnEvent event)
|
||||
{
|
||||
@@ -186,11 +186,11 @@ public class EssentialsEntityListener implements Listener
|
||||
{
|
||||
return;
|
||||
}
|
||||
final ISettings settings = ess.getSettings();
|
||||
final ISettings settings = ess.getSettings();
|
||||
settings.acquireReadLock();
|
||||
try
|
||||
{
|
||||
final Boolean prevent = settings.getData().getGeneral().getPreventSpawn(creature);
|
||||
final Boolean prevent = settings.getData().getWorldOptions(event.getLocation().getWorld().getName()).getPreventSpawn(creature);
|
||||
if (prevent != null && prevent)
|
||||
{
|
||||
event.setCancelled(true);
|
||||
|
@@ -1,16 +1,48 @@
|
||||
package net.ess3.settings;
|
||||
|
||||
import net.ess3.storage.Comment;
|
||||
import net.ess3.storage.StorageObject;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import net.ess3.storage.Comment;
|
||||
import net.ess3.storage.StorageObject;
|
||||
import org.bukkit.entity.EntityType;
|
||||
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public class WorldOptions implements StorageObject
|
||||
{
|
||||
public WorldOptions()
|
||||
{
|
||||
//Populate creature spawn values
|
||||
for (EntityType t : EntityType.values())
|
||||
{
|
||||
if (t.isAlive())
|
||||
{
|
||||
creatureSpawn.put(t, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Comment("Disables godmode for all players if they teleport to this world.")
|
||||
private boolean godmode = true;
|
||||
|
||||
@Comment("Prevent creatures spawning")
|
||||
private Map<EntityType, Boolean> creatureSpawn = new HashMap<EntityType, Boolean>();
|
||||
|
||||
public boolean getPreventSpawn(String creatureName)
|
||||
{
|
||||
return getPreventSpawn(EntityType.fromName(creatureName));
|
||||
}
|
||||
|
||||
public boolean getPreventSpawn(EntityType creature)
|
||||
{
|
||||
if (creatureSpawn == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return creatureSpawn.get(creature);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -1,6 +1,5 @@
|
||||
package net.ess3.protect;
|
||||
|
||||
import net.ess3.api.ISettings;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
@@ -237,8 +236,6 @@ public class EssentialsProtectEntityListener implements Listener
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onEntityTarget(final EntityTargetEvent event)
|
||||
{
|
||||
|
Reference in New Issue
Block a user