Add AllowSlimeSplit config to not block slime splitting with limits

This commit is contained in:
Fabrizio La Rosa 2020-06-14 02:51:20 +02:00
parent b3dc23ff73
commit 03670b312e
2 changed files with 18 additions and 6 deletions

View File

@ -2,6 +2,7 @@ package com.songoda.skyblock.listeners;
import com.songoda.core.compatibility.CompatibleMaterial;
import com.songoda.skyblock.SkyBlock;
import com.songoda.skyblock.config.FileManager;
import com.songoda.skyblock.config.FileManager.Config;
import com.songoda.skyblock.island.*;
import com.songoda.skyblock.limit.impl.EntityLimitaton;
@ -513,12 +514,20 @@ public class Entity implements Listener {
EntityType type = entity.getType();
if (limits.isBeingTracked(type)) {
long count = limits.getEntityCount(island, skyblock.getWorldManager().getIslandWorld(entityLocation.getWorld()), type);
FileManager fileManager = skyblock.getFileManager();
Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml"));
FileConfiguration configLoad = config.getFileConfiguration();
if (limits.hasTooMuch(count + 1, type)) {
entity.remove();
event.setCancelled(true);
return;
boolean isSplit = event.getSpawnReason().equals(SpawnReason.SLIME_SPLIT);
boolean splitBypass = configLoad.getBoolean("Island.Challenge.PerIsland", true);
if(!isSplit || splitBypass){
long count = limits.getEntityCount(island, skyblock.getWorldManager().getIslandWorld(entityLocation.getWorld()), type);
if (limits.hasTooMuch(count + 1, type)) {
entity.remove();
event.setCancelled(true);
return;
}
}
}

View File

@ -316,4 +316,7 @@ Island:
PerIsland: true
Teleport:
# Enable or disable Fall damage
FallDamage: true
FallDamage: true
Limits:
# Should slime split bypass limits.yml
AllowSlimeSplit: true