This commit is contained in:
Brianna 2019-09-07 17:55:16 -04:00
parent 1fd965c369
commit c0bc2d8cf3
16 changed files with 340 additions and 340 deletions

View File

@ -27,7 +27,7 @@ import com.songoda.ultimatestacker.hook.StackerHook;
import com.songoda.ultimatestacker.hook.hooks.JobsHook;
import com.songoda.ultimatestacker.listeners.*;
import com.songoda.ultimatestacker.lootables.LootablesManager;
import com.songoda.ultimatestacker.settings.Setting;
import com.songoda.ultimatestacker.settings.Settings;
import com.songoda.ultimatestacker.spawner.SpawnerStack;
import com.songoda.ultimatestacker.spawner.SpawnerStackManager;
import com.songoda.ultimatestacker.storage.Storage;
@ -99,10 +99,10 @@ public class UltimateStacker extends SongodaPlugin {
SongodaCore.registerPlugin(this, 16, LegacyMaterials.IRON_INGOT);
// Setup Config
Setting.setupConfig();
this.setLocale(Setting.LANGUGE_MODE.getString(), false);
whitelist = Setting.ITEM_WHITELIST.getStringList();
blacklist = Setting.ITEM_BLACKLIST.getStringList();
Settings.setupConfig();
this.setLocale(Settings.LANGUGE_MODE.getString(), false);
whitelist = Settings.ITEM_WHITELIST.getStringList();
blacklist = Settings.ITEM_BLACKLIST.getStringList();
// Setup plugin commands
this.commandManager = new CommandManager(this);
@ -165,7 +165,7 @@ public class UltimateStacker extends SongodaPlugin {
pluginManager.registerEvents(new SpawnerListeners(this), this);
pluginManager.registerEvents(new SheepDyeListeners(this), this);
if (Setting.CLEAR_LAG.getBoolean() && pluginManager.isPluginEnabled("ClearLag"))
if (Settings.CLEAR_LAG.getBoolean() && pluginManager.isPluginEnabled("ClearLag"))
pluginManager.registerEvents(new ClearLagListeners(this), this);
// Register Hooks
@ -203,13 +203,13 @@ public class UltimateStacker extends SongodaPlugin {
// Database stuff, go!
try {
if (Setting.MYSQL_ENABLED.getBoolean()) {
String hostname = Setting.MYSQL_HOSTNAME.getString();
int port = Setting.MYSQL_PORT.getInt();
String database = Setting.MYSQL_DATABASE.getString();
String username = Setting.MYSQL_USERNAME.getString();
String password = Setting.MYSQL_PASSWORD.getString();
boolean useSSL = Setting.MYSQL_USE_SSL.getBoolean();
if (Settings.MYSQL_ENABLED.getBoolean()) {
String hostname = Settings.MYSQL_HOSTNAME.getString();
int port = Settings.MYSQL_PORT.getInt();
String database = Settings.MYSQL_DATABASE.getString();
String username = Settings.MYSQL_USERNAME.getString();
String password = Settings.MYSQL_PASSWORD.getString();
boolean useSSL = Settings.MYSQL_USE_SSL.getBoolean();
this.databaseConnector = new MySQLConnector(this, hostname, port, database, username, password, useSSL);
this.getLogger().info("Data handler connected using MySQL.");
@ -228,7 +228,7 @@ public class UltimateStacker extends SongodaPlugin {
this.dataMigrationManager.runMigrations();
Bukkit.getScheduler().runTaskLater(this, () -> {
final boolean useHolo = Setting.SPAWNER_HOLOGRAMS.getBoolean();
final boolean useHolo = Settings.SPAWNER_HOLOGRAMS.getBoolean();
this.dataManager.getSpawners((spawners) -> {
this.spawnerStackManager.addSpawners(spawners);
if (useHolo)
@ -250,8 +250,8 @@ public class UltimateStacker extends SongodaPlugin {
@Override
public void onConfigReload() {
whitelist = Setting.ITEM_WHITELIST.getStringList();
blacklist = Setting.ITEM_BLACKLIST.getStringList();
whitelist = Settings.ITEM_WHITELIST.getStringList();
blacklist = Settings.ITEM_BLACKLIST.getStringList();
this.setLocale(getConfig().getString("System.Language Mode"), true);
this.locale.reloadMessages();
@ -268,7 +268,7 @@ public class UltimateStacker extends SongodaPlugin {
}
public boolean spawnersEnabled() {
return !this.getServer().getPluginManager().isPluginEnabled("EpicSpawners") && Setting.SPAWNERS_ENABLED.getBoolean();
return !this.getServer().getPluginManager().isPluginEnabled("EpicSpawners") && Settings.SPAWNERS_ENABLED.getBoolean();
}
public CommandManager getCommandManager() {
@ -332,7 +332,7 @@ public class UltimateStacker extends SongodaPlugin {
public void updateHologram(SpawnerStack stack) {
// are holograms enabled?
if(!Setting.SPAWNER_HOLOGRAMS.getBoolean() || !HologramManager.getManager().isEnabled()) return;
if(!Settings.SPAWNER_HOLOGRAMS.getBoolean() || !HologramManager.getManager().isEnabled()) return;
// verify that this is a spawner stack
if (stack.getLocation().getBlock().getType() != LegacyMaterials.SPAWNER.getMaterial()) return;
// grab the spawner block
@ -346,7 +346,7 @@ public class UltimateStacker extends SongodaPlugin {
// verify that this is a spawner
if (block.getType() != LegacyMaterials.SPAWNER.getMaterial()) return;
// are holograms enabled?
if(!Setting.SPAWNER_HOLOGRAMS.getBoolean() || !HologramManager.getManager().isEnabled()) return;
if(!Settings.SPAWNER_HOLOGRAMS.getBoolean() || !HologramManager.getManager().isEnabled()) return;
// update this hologram in a tick
SpawnerStack spawner = getSpawnerStackManager().getSpawner(block);
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(this, () -> updateHologram(spawner), 10L);
@ -387,10 +387,10 @@ public class UltimateStacker extends SongodaPlugin {
}
item.setItemStack(itemStack);
if ((blacklisted && !Setting.ITEM_HOLOGRAM_BLACKLIST.getBoolean())
if ((blacklisted && !Settings.ITEM_HOLOGRAM_BLACKLIST.getBoolean())
|| !INSTANCE.getItemFile().getBoolean("Items." + material + ".Has Hologram")
|| !Setting.ITEM_HOLOGRAMS.getBoolean()
|| newAmount == 1 && !Setting.ITEM_HOLOGRAM_SINGLE.getBoolean())
|| !Settings.ITEM_HOLOGRAMS.getBoolean()
|| newAmount == 1 && !Settings.ITEM_HOLOGRAM_SINGLE.getBoolean())
return;
item.setCustomName(name);

View File

@ -4,7 +4,7 @@ import com.songoda.core.compatibility.LegacyMaterials;
import com.songoda.core.compatibility.ServerVersion;
import com.songoda.lootables.loot.Drop;
import com.songoda.ultimatestacker.UltimateStacker;
import com.songoda.ultimatestacker.settings.Setting;
import com.songoda.ultimatestacker.settings.Settings;
import com.songoda.ultimatestacker.utils.DropUtils;
import com.songoda.ultimatestacker.utils.Methods;
import org.bukkit.Bukkit;
@ -39,14 +39,14 @@ public class EntityStack {
}
public void updateStack() {
if (!Setting.ENTITY_HOLOGRAMS.getBoolean()) return;
if (!Settings.ENTITY_HOLOGRAMS.getBoolean()) return;
Bukkit.getScheduler().scheduleSyncDelayedTask(UltimateStacker.getInstance(), () -> {
Entity entit = getEntityByUniqueId(this.entity);
if (entit == null ||
!UltimateStacker.getInstance().getEntityStackManager().isStacked(entity)) return;
entit.setCustomNameVisible(!Setting.HOLOGRAMS_ON_LOOK_ENTITY.getBoolean());
entit.setCustomNameVisible(!Settings.HOLOGRAMS_ON_LOOK_ENTITY.getBoolean());
entit.setCustomName(Methods.compileEntityName(entit, amount));
}, entity == null ? 1L : 0L);
@ -142,7 +142,7 @@ public class EntityStack {
if (killed.getType() == EntityType.PIG_ZOMBIE)
newEntity.getEquipment().setItemInHand(LegacyMaterials.GOLDEN_SWORD.getItem());
if (Setting.CARRY_OVER_METADATA_ON_DEATH.getBoolean()) {
if (Settings.CARRY_OVER_METADATA_ON_DEATH.getBoolean()) {
if (killed.hasMetadata("ES"))
newEntity.setMetadata("ES", killed.getMetadata("ES").get(0));
@ -169,20 +169,20 @@ public class EntityStack {
killed.setCustomNameVisible(true);
killed.setCustomName(Methods.formatText("&7"));
boolean killWholeStack = Setting.KILL_WHOLE_STACK_ON_DEATH.getBoolean()
boolean killWholeStack = Settings.KILL_WHOLE_STACK_ON_DEATH.getBoolean()
|| plugin.getMobFile().getBoolean("Mobs." + killed.getType().name() + ".Kill Whole Stack");
if (killWholeStack && getAmount() != 1) {
handleWholeStackDeath(killed, drops, custom, droppedExp);
} else if (getAmount() != 1) {
List<String> reasons = Setting.INSTANT_KILL.getStringList();
List<String> reasons = Settings.INSTANT_KILL.getStringList();
EntityDamageEvent lastDamageCause = killed.getLastDamageCause();
if (lastDamageCause != null) {
EntityDamageEvent.DamageCause cause = lastDamageCause.getCause();
for (String s : reasons) {
if (!cause.name().equalsIgnoreCase(s)) continue;
handleWholeStackDeath(killed, drops, custom, Setting.NO_EXP_INSTANT_KILL.getBoolean() ? 0 : droppedExp);
handleWholeStackDeath(killed, drops, custom, Settings.NO_EXP_INSTANT_KILL.getBoolean() ? 0 : droppedExp);
return;
}
}
@ -192,7 +192,7 @@ public class EntityStack {
public void updateHealth(LivingEntity entity) {
if (entity == null) return;
entity.setHealth(Setting.STACK_ENTITY_HEALTH.getBoolean()
entity.setHealth(Settings.STACK_ENTITY_HEALTH.getBoolean()
&& !this.health.isEmpty() ? this.health.removeFirst() : entity.getMaxHealth());
}

View File

@ -4,7 +4,7 @@ import com.songoda.core.compatibility.LegacyMaterials;
import com.songoda.ultimatestacker.UltimateStacker;
import com.songoda.ultimatestacker.events.SpawnerBreakEvent;
import com.songoda.ultimatestacker.events.SpawnerPlaceEvent;
import com.songoda.ultimatestacker.settings.Setting;
import com.songoda.ultimatestacker.settings.Settings;
import com.songoda.ultimatestacker.spawner.SpawnerStack;
import com.songoda.ultimatestacker.utils.Methods;
import org.apache.commons.lang.math.NumberUtils;
@ -45,7 +45,7 @@ public class BlockListeners implements Listener {
|| item.getType() != LegacyMaterials.SPAWNER.getMaterial()
|| event.getAction() == Action.LEFT_CLICK_BLOCK) return;
List<String> disabledWorlds = Setting.DISABLED_WORLDS.getStringList();
List<String> disabledWorlds = Settings.DISABLED_WORLDS.getStringList();
if (disabledWorlds.stream().anyMatch(worldStr -> event.getPlayer().getWorld().getName().equalsIgnoreCase(worldStr))) return;
if (!plugin.spawnersEnabled()) return;
@ -57,7 +57,7 @@ public class BlockListeners implements Listener {
int itemAmount = getSpawnerAmount(item);
int specific = plugin.getSpawnerFile().getInt("Spawners." + cs.getSpawnedType().name() + ".Max Stack Size");
int maxStackSize = specific == -1 ? Setting.MAX_STACK_SPAWNERS.getInt() : specific;
int maxStackSize = specific == -1 ? Settings.MAX_STACK_SPAWNERS.getInt() : specific;
cs = (CreatureSpawner) block.getState();
@ -155,7 +155,7 @@ public class BlockListeners implements Listener {
int amt = 1;
boolean remove = false;
if (player.isSneaking() && Setting.SNEAK_FOR_STACK.getBoolean()) {
if (player.isSneaking() && Settings.SNEAK_FOR_STACK.getBoolean()) {
amt = stack.getAmount();
remove = true;
} else if (stack.getAmount() <= 1) {

View File

@ -5,7 +5,7 @@ import com.songoda.core.compatibility.ServerVersion;
import com.songoda.lootables.loot.Drop;
import com.songoda.ultimatestacker.UltimateStacker;
import com.songoda.ultimatestacker.entity.EntityStack;
import com.songoda.ultimatestacker.settings.Setting;
import com.songoda.ultimatestacker.settings.Settings;
import com.songoda.ultimatestacker.utils.DropUtils;
import org.bukkit.Material;
import org.bukkit.enchantments.Enchantment;
@ -40,7 +40,7 @@ public class DeathListeners implements Listener {
public void onEntityDeath(EntityDeathEvent event) {
if (event.getEntity() instanceof Player) return;
boolean custom = Setting.CUSTOM_DROPS.getBoolean();
boolean custom = Settings.CUSTOM_DROPS.getBoolean();
List<Drop> drops = custom ? instance.getLootablesManager().getDrops(event.getEntity()) : new ArrayList<>();
if (!custom) {
@ -112,7 +112,7 @@ public class DeathListeners implements Listener {
if (!instance.getEntityStackManager().isStacked(event.getEntity())) return;
EntityStack stack = instance.getEntityStackManager().getStack(event.getEntity());
if (Setting.KILL_WHOLE_STACK_ON_DEATH.getBoolean() && Setting.REALISTIC_DAMAGE.getBoolean()) {
if (Settings.KILL_WHOLE_STACK_ON_DEATH.getBoolean() && Settings.REALISTIC_DAMAGE.getBoolean()) {
Player player = (Player) event.getDamager();
ItemStack tool = player.getInventory().getItemInMainHand();
if (tool.getType().getMaxDurability() < 1 || (tool.getItemMeta() != null && (tool.getItemMeta().isUnbreakable()

View File

@ -4,7 +4,7 @@ import com.songoda.core.compatibility.LegacyMaterials;
import com.songoda.ultimatestacker.UltimateStacker;
import com.songoda.ultimatestacker.entity.EntityStack;
import com.songoda.ultimatestacker.entity.EntityStackManager;
import com.songoda.ultimatestacker.settings.Setting;
import com.songoda.ultimatestacker.settings.Settings;
import com.songoda.ultimatestacker.spawner.SpawnerStack;
import com.songoda.ultimatestacker.utils.Methods;
import java.util.ArrayList;
@ -90,14 +90,14 @@ public class EntityListeners implements Listener {
SpawnerStack spawner = plugin.getSpawnerStackManager().getSpawner(block);
if (Setting.SPAWNERS_DONT_EXPLODE.getBoolean())
if (Settings.SPAWNERS_DONT_EXPLODE.getBoolean())
toCancel.add(block);
else {
String chance = "";
if (event.getEntity() instanceof Creeper)
chance = Setting.EXPLOSION_DROP_CHANCE_TNT.getString();
chance = Settings.EXPLOSION_DROP_CHANCE_TNT.getString();
else if (event.getEntity() instanceof TNTPrimed)
chance = Setting.EXPLOSION_DROP_CHANCE_CREEPER.getString();
chance = Settings.EXPLOSION_DROP_CHANCE_CREEPER.getString();
int ch = Integer.parseInt(chance.replace("%", ""));
double rand = Math.random() * 100;
if (rand - ch < 0 || ch == 100) {

View File

@ -5,7 +5,7 @@ import com.songoda.core.compatibility.ServerVersion;
import com.songoda.ultimatestacker.UltimateStacker;
import com.songoda.ultimatestacker.entity.EntityStack;
import com.songoda.ultimatestacker.entity.Split;
import com.songoda.ultimatestacker.settings.Setting;
import com.songoda.ultimatestacker.settings.Settings;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.entity.Ageable;
@ -46,9 +46,9 @@ public class InteractListeners implements Listener {
if (stack.getAmount() <= 1
|| item.getType() == Material.NAME_TAG
&& Setting.SPLIT_CHECKS.getStringList().stream().noneMatch(line -> Split.valueOf(line) == Split.NAME_TAG)
&& Settings.SPLIT_CHECKS.getStringList().stream().noneMatch(line -> Split.valueOf(line) == Split.NAME_TAG)
|| item.getType() != Material.NAME_TAG
&& Setting.SPLIT_CHECKS.getStringList().stream().noneMatch(line -> Split.valueOf(line) == Split.ENTITY_BREED))
&& Settings.SPLIT_CHECKS.getStringList().stream().noneMatch(line -> Split.valueOf(line) == Split.ENTITY_BREED))
return;
if (item.getType() == Material.NAME_TAG)

View File

@ -4,7 +4,7 @@ import com.songoda.core.compatibility.CompatibleSounds;
import com.songoda.core.compatibility.ServerVersion;
import com.songoda.core.utils.BlockUtils;
import com.songoda.ultimatestacker.UltimateStacker;
import com.songoda.ultimatestacker.settings.Setting;
import com.songoda.ultimatestacker.settings.Settings;
import com.songoda.ultimatestacker.utils.Methods;
import org.apache.commons.lang.StringUtils;
import org.bukkit.block.BlockState;
@ -28,8 +28,8 @@ public class ItemListeners implements Listener {
@EventHandler
public void onMerge(ItemMergeEvent event) {
int maxItemStackSize = Setting.MAX_STACK_ITEMS.getInt();
if (!Setting.STACK_ITEMS.getBoolean()) return;
int maxItemStackSize = Settings.MAX_STACK_ITEMS.getInt();
if (!Settings.STACK_ITEMS.getBoolean()) return;
Item item = event.getTarget();
ItemStack itemStack = item.getItemStack();
@ -58,7 +58,7 @@ public class ItemListeners implements Listener {
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void onInvPickup(InventoryPickupItemEvent event) {
if (!Setting.STACK_ITEMS.getBoolean() || !Methods.hasCustomAmount(event.getItem())) return;
if (!Settings.STACK_ITEMS.getBoolean() || !Methods.hasCustomAmount(event.getItem())) return;
event.setCancelled(true);
Methods.updateInventory(event.getItem(), event.getInventory());
@ -68,7 +68,7 @@ public class ItemListeners implements Listener {
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void onExist(ItemSpawnEvent event) {
if (!Setting.STACK_ITEMS.getBoolean()) return;
if (!Settings.STACK_ITEMS.getBoolean()) return;
ItemStack itemStack = event.getEntity().getItemStack();
@ -82,7 +82,7 @@ public class ItemListeners implements Listener {
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void onPickup(PlayerPickupItemEvent event) {
if (!Setting.STACK_ITEMS.getBoolean()) return;
if (!Settings.STACK_ITEMS.getBoolean()) return;
if (event.getItem().getItemStack().getAmount() < 32) return;
event.setCancelled(true);

View File

@ -3,7 +3,7 @@ package com.songoda.ultimatestacker.listeners;
import com.songoda.ultimatestacker.UltimateStacker;
import com.songoda.ultimatestacker.entity.EntityStackManager;
import com.songoda.ultimatestacker.entity.Split;
import com.songoda.ultimatestacker.settings.Setting;
import com.songoda.ultimatestacker.settings.Settings;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.LivingEntity;
@ -29,9 +29,9 @@ public class ShearListeners implements Listener {
if (!stackManager.isStacked(entity)) return;
if (event.getEntity().getType() == EntityType.SHEEP
&& Setting.SPLIT_CHECKS.getStringList().stream().noneMatch(line -> Split.valueOf(line) == Split.SHEEP_SHEAR)
&& Settings.SPLIT_CHECKS.getStringList().stream().noneMatch(line -> Split.valueOf(line) == Split.SHEEP_SHEAR)
|| event.getEntity().getType() == EntityType.MUSHROOM_COW
&& Setting.SPLIT_CHECKS.getStringList().stream().noneMatch(line -> Split.valueOf(line) == Split.MUSHROOM_SHEAR))
&& Settings.SPLIT_CHECKS.getStringList().stream().noneMatch(line -> Split.valueOf(line) == Split.MUSHROOM_SHEAR))
return;
plugin.getEntityUtils().splitFromStack((LivingEntity)entity);

View File

@ -3,7 +3,7 @@ package com.songoda.ultimatestacker.listeners;
import com.songoda.ultimatestacker.UltimateStacker;
import com.songoda.ultimatestacker.entity.EntityStackManager;
import com.songoda.ultimatestacker.entity.Split;
import com.songoda.ultimatestacker.settings.Setting;
import com.songoda.ultimatestacker.settings.Settings;
import org.bukkit.entity.*;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
@ -25,7 +25,7 @@ public class SheepDyeListeners implements Listener {
EntityStackManager stackManager = plugin.getEntityStackManager();
if (!stackManager.isStacked(entity)) return;
if (Setting.SPLIT_CHECKS.getStringList().stream().noneMatch(line -> Split.valueOf(line) == Split.SHEEP_DYE))
if (Settings.SPLIT_CHECKS.getStringList().stream().noneMatch(line -> Split.valueOf(line) == Split.SHEEP_DYE))
return;
plugin.getEntityUtils().splitFromStack(entity);

View File

@ -3,7 +3,7 @@ package com.songoda.ultimatestacker.listeners;
import com.songoda.core.compatibility.ServerVersion;
import com.songoda.ultimatestacker.UltimateStacker;
import com.songoda.ultimatestacker.entity.EntityStack;
import com.songoda.ultimatestacker.settings.Setting;
import com.songoda.ultimatestacker.settings.Settings;
import com.songoda.ultimatestacker.spawner.SpawnerStack;
import com.songoda.ultimatestacker.spawner.SpawnerStackManager;
import com.songoda.ultimatestacker.utils.Methods;
@ -33,7 +33,7 @@ public class SpawnerListeners implements Listener {
@EventHandler
public void onSpawn(SpawnerSpawnEvent event) {
if (!Setting.STACK_ENTITIES.getBoolean()
if (!Settings.STACK_ENTITIES.getBoolean()
|| !plugin.spawnersEnabled()
|| plugin.getStackingTask().isWorldDisabled(event.getLocation().getWorld())) return;
SpawnerStackManager spawnerStackManager = plugin.getSpawnerStackManager();
@ -67,7 +67,7 @@ public class SpawnerListeners implements Listener {
event.setCancelled(true);
if (!Setting.EGGS_CONVERT_SPAWNERS.getBoolean()
if (!Settings.EGGS_CONVERT_SPAWNERS.getBoolean()
|| (event.getItem().hasItemMeta() && event.getItem().getItemMeta().hasDisplayName())) {
return;
}

View File

@ -6,7 +6,7 @@ import com.songoda.lootables.Lootables;
import com.songoda.lootables.Modify;
import com.songoda.lootables.loot.*;
import com.songoda.ultimatestacker.UltimateStacker;
import com.songoda.ultimatestacker.settings.Setting;
import com.songoda.ultimatestacker.settings.Settings;
import org.bukkit.Material;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.*;
@ -41,7 +41,7 @@ public class LootablesManager {
? entity.getKiller().getItemInHand().getEnchantmentLevel(Enchantment.LOOT_BONUS_MOBS)
: 0;
int rerollChance = Setting.REROLL.getBoolean() ? looting / (looting + 1) : 0;
int rerollChance = Settings.REROLL.getBoolean() ? looting / (looting + 1) : 0;
for (Loot loot : lootable.getRegisteredLoot())
toDrop.addAll(runLoot(entity, loot, rerollChance, looting));

View File

@ -9,7 +9,7 @@ import java.util.Arrays;
import java.util.Collections;
import java.util.stream.Collectors;
public class Setting {
public class Settings {
static final Config config = UltimateStacker.getInstance().getConfig().getCoreConfig();

View File

@ -2,7 +2,7 @@ package com.songoda.ultimatestacker.spawner;
import com.songoda.core.compatibility.ServerVersion;
import com.songoda.ultimatestacker.UltimateStacker;
import com.songoda.ultimatestacker.settings.Setting;
import com.songoda.ultimatestacker.settings.Settings;
import com.songoda.ultimatestacker.utils.Reflection;
import org.bukkit.Bukkit;
import org.bukkit.Location;
@ -34,7 +34,7 @@ public class SpawnerStack {
Bukkit.getScheduler().runTaskLater(plugin, () -> {
if (!(location.getBlock().getState() instanceof CreatureSpawner)) return;
int count = Setting.STACK_ENTITIES.getBoolean()
int count = Settings.STACK_ENTITIES.getBoolean()
&& !plugin.getStackingTask().isWorldDisabled(location.getWorld()) ? 1 : calculateSpawnCount();
int maxNearby = amount > 6 ? amount + 3 : 6;
CreatureSpawner creatureSpawner = (CreatureSpawner) location.getBlock().getState();

View File

@ -3,7 +3,7 @@ package com.songoda.ultimatestacker.tasks;
import com.songoda.ultimatestacker.UltimateStacker;
import com.songoda.ultimatestacker.entity.EntityStack;
import com.songoda.ultimatestacker.entity.EntityStackManager;
import com.songoda.ultimatestacker.settings.Setting;
import com.songoda.ultimatestacker.settings.Settings;
import com.songoda.ultimatestacker.utils.Methods;
import org.bukkit.Bukkit;
import org.bukkit.Location;
@ -25,23 +25,23 @@ public class StackingTask extends BukkitRunnable {
private List<UUID> processed = new ArrayList<>();
private int maxEntityStackSize = Setting.MAX_STACK_ENTITIES.getInt();
private int minEntityStackSize = Setting.MIN_STACK_ENTITIES.getInt();
private int maxEntityStackSize = Settings.MAX_STACK_ENTITIES.getInt();
private int minEntityStackSize = Settings.MIN_STACK_ENTITIES.getInt();
private int maxPerTypeStacksPerChunk = Setting.MAX_PER_TYPE_STACKS_PER_CHUNK.getInt();
private int maxPerTypeStacksPerChunk = Settings.MAX_PER_TYPE_STACKS_PER_CHUNK.getInt();
public StackingTask(UltimateStacker plugin) {
this.plugin = plugin;
this.stackManager = plugin.getEntityStackManager();
// Start stacking task.
runTaskTimer(plugin, 0, Setting.STACK_SEARCH_TICK_SPEED.getInt());
runTaskTimer(plugin, 0, Settings.STACK_SEARCH_TICK_SPEED.getInt());
}
@Override
public void run() {
// Should entities be stacked?
if (!Setting.STACK_ENTITIES.getBoolean()) return;
if (!Settings.STACK_ENTITIES.getBoolean()) return;
// Loop through each world.
for (World world : Bukkit.getWorlds()) {
@ -76,7 +76,7 @@ public class StackingTask extends BukkitRunnable {
}
public boolean isWorldDisabled(World world) {
List<String> disabledWorlds = Setting.DISABLED_WORLDS.getStringList();
List<String> disabledWorlds = Settings.DISABLED_WORLDS.getStringList();
return disabledWorlds.stream().anyMatch(worldStr -> world.getName().equalsIgnoreCase(worldStr));
}
@ -96,11 +96,11 @@ public class StackingTask extends BukkitRunnable {
// Allow spawn if stackreasons are set and match, or if from a spawner
final String spawnReason = entity.hasMetadata("US_REASON") ? entity.getMetadata("US_REASON").get(0).asString() : null;
List<String> stackReasons;
if (Setting.ONLY_STACK_FROM_SPAWNERS.getBoolean()) {
if (Settings.ONLY_STACK_FROM_SPAWNERS.getBoolean()) {
// If only stack from spawners is enabled, make sure the entity spawned from a spawner.
if (!"SPAWNER".equals(spawnReason))
return false;
} else if (!(stackReasons = Setting.STACK_REASONS.getStringList()).isEmpty() && !stackReasons.contains(spawnReason))
} else if (!(stackReasons = Settings.STACK_REASONS.getStringList()).isEmpty() && !stackReasons.contains(spawnReason))
// Only stack if on the list of events to stack
return false;
@ -108,7 +108,7 @@ public class StackingTask extends BukkitRunnable {
LivingEntity livingEntity = (LivingEntity) entity;
// If only stack on surface is enabled make sure the entity is on a surface then entity is stackable.
return !Setting.ONLY_STACK_ON_SURFACE.getBoolean()
return !Settings.ONLY_STACK_ON_SURFACE.getBoolean()
|| Methods.canFly(livingEntity)
|| entity.getType().name().equals("SHULKER")
|| (livingEntity.isOnGround() || location.getBlock().isLiquid());
@ -169,7 +169,7 @@ public class StackingTask extends BukkitRunnable {
fixHealth(entity, livingEntity);
if (Setting.STACK_ENTITY_HEALTH.getBoolean())
if (Settings.STACK_ENTITY_HEALTH.getBoolean())
entity.setHealth(entity.getMaxHealth() < livingEntity.getHealth()
? entity.getMaxHealth() : livingEntity.getHealth());
@ -183,7 +183,7 @@ public class StackingTask extends BukkitRunnable {
&& isStack
&& (stack.getAmount() + 1) <= maxEntityStackSize
&& Methods.canFly(entity)
&& Setting.ONLY_STACK_FLYING_DOWN.getBoolean()
&& Settings.ONLY_STACK_FLYING_DOWN.getBoolean()
&& location.getY() > entity.getLocation().getY()) {
// Create a new stack with the current stacks amount and add one to it.
@ -193,7 +193,7 @@ public class StackingTask extends BukkitRunnable {
newStack.mergeHealth(stack);
newStack.addHealth(livingEntity.getHealth());
fixHealth(livingEntity, entity);
if (Setting.STACK_ENTITY_HEALTH.getBoolean())
if (Settings.STACK_ENTITY_HEALTH.getBoolean())
entity.setHealth(entity.getHealth());
// Remove our entities stack from the stack manager.
@ -259,7 +259,7 @@ public class StackingTask extends BukkitRunnable {
}
private void updateHealth(EntityStack stack) {
if (Setting.STACK_ENTITY_HEALTH.getBoolean())
if (Settings.STACK_ENTITY_HEALTH.getBoolean())
stack.updateHealth(stack.getEntity());
}
@ -285,7 +285,7 @@ public class StackingTask extends BukkitRunnable {
private void fixHealth(LivingEntity entity, LivingEntity initialEntity) {
if (!Setting.STACK_ENTITY_HEALTH.getBoolean() && Setting.CARRY_OVER_LOWEST_HEALTH.getBoolean() && initialEntity.getHealth() < entity.getHealth())
if (!Settings.STACK_ENTITY_HEALTH.getBoolean() && Settings.CARRY_OVER_LOWEST_HEALTH.getBoolean() && initialEntity.getHealth() < entity.getHealth())
entity.setHealth(initialEntity.getHealth());
}

View File

@ -4,7 +4,7 @@ import com.songoda.core.compatibility.ServerVersion;
import com.songoda.ultimatestacker.UltimateStacker;
import com.songoda.ultimatestacker.entity.Check;
import com.songoda.ultimatestacker.entity.EntityStack;
import com.songoda.ultimatestacker.settings.Setting;
import com.songoda.ultimatestacker.settings.Settings;
import org.bukkit.Chunk;
import org.bukkit.Location;
import org.bukkit.World;
@ -17,12 +17,12 @@ public class EntityUtils {
UltimateStacker plugin = UltimateStacker.getInstance();
private List<String> checks = Setting.STACK_CHECKS.getStringList();
private boolean stackFlyingDown = Setting.ONLY_STACK_FLYING_DOWN.getBoolean();
private boolean keepFire = Setting.KEEP_FIRE.getBoolean();
private boolean keepPotion = Setting.KEEP_POTION.getBoolean();
private boolean stackWholeChunk = Setting.STACK_WHOLE_CHUNK.getBoolean();
private int searchRadius = Setting.SEARCH_RADIUS.getInt();
private List<String> checks = Settings.STACK_CHECKS.getStringList();
private boolean stackFlyingDown = Settings.ONLY_STACK_FLYING_DOWN.getBoolean();
private boolean keepFire = Settings.KEEP_FIRE.getBoolean();
private boolean keepPotion = Settings.KEEP_POTION.getBoolean();
private boolean stackWholeChunk = Settings.STACK_WHOLE_CHUNK.getBoolean();
private int searchRadius = Settings.SEARCH_RADIUS.getInt();
private final Map<CachedChunk, Entity[]> cachedChunks = new HashMap<>();

View File

@ -4,7 +4,7 @@ import com.songoda.core.compatibility.LegacyMaterials;
import com.songoda.core.compatibility.ServerVersion;
import com.songoda.core.utils.TextUtils;
import com.songoda.ultimatestacker.UltimateStacker;
import com.songoda.ultimatestacker.settings.Setting;
import com.songoda.ultimatestacker.settings.Settings;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
@ -91,18 +91,18 @@ public class Methods {
}
public static String compileItemName(ItemStack item, int amount) {
String nameFormat = Setting.NAME_FORMAT_ITEM.getString();
String nameFormat = Settings.NAME_FORMAT_ITEM.getString();
String displayName = Methods.formatText(UltimateStacker.getInstance().getItemFile()
.getString("Items." + item.getType().name() + ".Display Name"));
if (item.hasItemMeta() && item.getItemMeta().hasDisplayName())
displayName = Setting.NAME_FORMAT_RESET.getBoolean() ?
displayName = Settings.NAME_FORMAT_RESET.getBoolean() ?
ChatColor.stripColor(item.getItemMeta().getDisplayName()) : item.getItemMeta().getDisplayName();
nameFormat = nameFormat.replace("{TYPE}", displayName);
nameFormat = nameFormat.replace("{AMT}", Integer.toString(amount));
if (amount == 1 && !Setting.SHOW_STACK_SIZE_SINGLE.getBoolean()) {
if (amount == 1 && !Settings.SHOW_STACK_SIZE_SINGLE.getBoolean()) {
nameFormat = nameFormat.replaceAll("\\[.*?]", "");
} else {
nameFormat = nameFormat.replace("[", "").replace("]", "");
@ -141,7 +141,7 @@ public class Methods {
}
public static String compileEntityName(Entity entity, int amount) {
String nameFormat = Setting.NAME_FORMAT_ENTITY.getString();
String nameFormat = Settings.NAME_FORMAT_ENTITY.getString();
String displayName = Methods.formatText(UltimateStacker.getInstance().getMobFile().getString("Mobs." + entity.getType().name() + ".Display Name"));
nameFormat = nameFormat.replace("{TYPE}", displayName);