mirror of
https://github.com/essentials/Essentials.git
synced 2025-08-12 17:45:08 +02:00
Move creaturespawn options to worldoptions
This commit is contained in:
@@ -42,7 +42,7 @@ public class Commandspawner extends EssentialsCommand
|
|||||||
@Cleanup
|
@Cleanup
|
||||||
ISettings settings = ess.getSettings();
|
ISettings settings = ess.getSettings();
|
||||||
settings.acquireReadLock();
|
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"));
|
throw new Exception(_("disabledToSpawnMob"));
|
||||||
}
|
}
|
||||||
|
@@ -190,7 +190,7 @@ public class EssentialsEntityListener implements Listener
|
|||||||
settings.acquireReadLock();
|
settings.acquireReadLock();
|
||||||
try
|
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)
|
if (prevent != null && prevent)
|
||||||
{
|
{
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
|
@@ -1,16 +1,48 @@
|
|||||||
package net.ess3.settings;
|
package net.ess3.settings;
|
||||||
|
|
||||||
import net.ess3.storage.Comment;
|
import java.util.HashMap;
|
||||||
import net.ess3.storage.StorageObject;
|
import java.util.Map;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
|
import net.ess3.storage.Comment;
|
||||||
|
import net.ess3.storage.StorageObject;
|
||||||
|
import org.bukkit.entity.EntityType;
|
||||||
|
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
@EqualsAndHashCode(callSuper = false)
|
@EqualsAndHashCode(callSuper = false)
|
||||||
public class WorldOptions implements StorageObject
|
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.")
|
@Comment("Disables godmode for all players if they teleport to this world.")
|
||||||
private boolean godmode = true;
|
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;
|
package net.ess3.protect;
|
||||||
|
|
||||||
import net.ess3.api.ISettings;
|
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.block.BlockFace;
|
import org.bukkit.block.BlockFace;
|
||||||
@@ -237,8 +236,6 @@ public class EssentialsProtectEntityListener implements Listener
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||||
public void onEntityTarget(final EntityTargetEvent event)
|
public void onEntityTarget(final EntityTargetEvent event)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user