add stacker methods to get min entity stack

This commit is contained in:
jascotty2 2019-10-09 19:52:46 -05:00
parent aeafb31b04
commit fa7d5a5974
4 changed files with 36 additions and 0 deletions

View File

@ -1,6 +1,7 @@
package com.songoda.core.hooks.stackers;
import org.bukkit.Bukkit;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Item;
import org.bukkit.entity.LivingEntity;
import uk.antiperson.stackmob.api.EntityManager;
@ -72,4 +73,10 @@ public class StackMob extends Stacker {
StackedEntity stackedEntity = plugin.getStackedEntity(entity);
stackedEntity.setSize(stackedEntity.getSize() + amount);
}
@Override
public int minimumEntityStack(EntityType type) {
return 0;
}
}

View File

@ -1,6 +1,7 @@
package com.songoda.core.hooks.stackers;
import com.songoda.core.hooks.Hook;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Item;
import org.bukkit.entity.LivingEntity;
@ -29,4 +30,7 @@ public abstract class Stacker implements Hook {
}
public abstract void add(LivingEntity entity, int amount);
public abstract int minimumEntityStack(EntityType type);
}

View File

@ -3,8 +3,10 @@ package com.songoda.core.hooks.stackers;
import com.songoda.ultimatestacker.entity.EntityStack;
import com.songoda.ultimatestacker.utils.Methods;
import java.lang.reflect.Method;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Item;
import org.bukkit.entity.LivingEntity;
import org.bukkit.plugin.Plugin;
public class UltimateStacker extends Stacker {
@ -80,4 +82,9 @@ public class UltimateStacker extends Stacker {
public void add(LivingEntity entity, int amount) {
plugin.getEntityStackManager().getStack(entity).addAmount(amount);
}
@Override
public int minimumEntityStack(EntityType type) {
return ((Plugin) plugin).getConfig().getInt("Entities.Min Stack Amount");
}
}

View File

@ -2,11 +2,19 @@ package com.songoda.core.hooks.stackers;
import com.bgsoftware.wildstacker.api.WildStackerAPI;
import com.bgsoftware.wildstacker.api.objects.StackedEntity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Item;
import org.bukkit.entity.LivingEntity;
import org.bukkit.plugin.Plugin;
public class WildStacker extends Stacker {
final Plugin plugin;
public WildStacker(Plugin plugin) {
this.plugin = plugin;
}
@Override
public String getName() {
return "WildStacker";
@ -58,4 +66,14 @@ public class WildStacker extends Stacker {
StackedEntity stackedEntity = WildStackerAPI.getStackedEntity(entity);
stackedEntity.setStackAmount(stackedEntity.getStackAmount() + amount, true);
}
@Override
public int minimumEntityStack(EntityType type) {
int min = plugin.getConfig().getInt("entities.minimum-limits." + type.name(), -1);
if (min == -1) {
min = plugin.getConfig().getInt("entities.minimum-limits.all", -1);
}
return min == -1 ? 0 : min;
}
}