Wildstacker support, better EpicSpawners support. Spawners in /is level

This commit is contained in:
Esophose 2019-04-10 03:32:39 -06:00
parent 25fdc33b4c
commit a37df2001a
13 changed files with 612 additions and 43 deletions

View File

@ -49,6 +49,11 @@
<artifactId>epicspawners</artifactId> <artifactId>epicspawners</artifactId>
<version>5.7.1</version> <version>5.7.1</version>
</dependency> </dependency>
<dependency>
<groupId>com.bgsoftware</groupId>
<artifactId>wildstacker-api</artifactId>
<version>b14</version>
</dependency>
<dependency> <dependency>
<groupId>org.spigotmc</groupId> <groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId> <artifactId>spigot</artifactId>

View File

@ -152,6 +152,11 @@ public class SkyBlock extends JavaPlugin {
pluginManager.registerEvents(new Spawner(this), this); pluginManager.registerEvents(new Spawner(this), this);
pluginManager.registerEvents(new Food(this), this); pluginManager.registerEvents(new Food(this), this);
if (pluginManager.isPluginEnabled("EpicSpawners"))
pluginManager.registerEvents(new EpicSpawners(this), this);
if (pluginManager.isPluginEnabled("WildStacker"))
pluginManager.registerEvents(new WildStacker(this), this);
pluginManager.registerEvents(new Rollback(), this); pluginManager.registerEvents(new Rollback(), this);
pluginManager.registerEvents(new Levelling(), this); pluginManager.registerEvents(new Levelling(), this);
pluginManager.registerEvents(new Generator(), this); pluginManager.registerEvents(new Generator(), this);

View File

@ -89,9 +89,10 @@ public class CommandManager implements CommandExecutor, TabCompleter {
new me.goodandevil.skyblock.command.commands.admin.GeneratorCommand(), new me.goodandevil.skyblock.command.commands.admin.GeneratorCommand(),
new me.goodandevil.skyblock.command.commands.admin.LevelCommand(), new me.goodandevil.skyblock.command.commands.admin.LevelCommand(),
new me.goodandevil.skyblock.command.commands.admin.OwnerCommand(), new me.goodandevil.skyblock.command.commands.admin.OwnerCommand(),
new me.goodandevil.skyblock.command.commands.admin.RefreshHologramsCommand(),
new me.goodandevil.skyblock.command.commands.admin.ReloadCommand(),
new me.goodandevil.skyblock.command.commands.admin.RemoveHologramCommand(), new me.goodandevil.skyblock.command.commands.admin.RemoveHologramCommand(),
new me.goodandevil.skyblock.command.commands.admin.RemoveUpgradeCommand(), new me.goodandevil.skyblock.command.commands.admin.RemoveUpgradeCommand(),
new me.goodandevil.skyblock.command.commands.admin.ReloadCommand(),
new me.goodandevil.skyblock.command.commands.admin.SetHologramCommand(), new me.goodandevil.skyblock.command.commands.admin.SetHologramCommand(),
new me.goodandevil.skyblock.command.commands.admin.SetSizeCommand(), new me.goodandevil.skyblock.command.commands.admin.SetSizeCommand(),
new me.goodandevil.skyblock.command.commands.admin.SetSpawnCommand(), new me.goodandevil.skyblock.command.commands.admin.SetSpawnCommand(),

View File

@ -0,0 +1,73 @@
package me.goodandevil.skyblock.command.commands.admin;
import me.goodandevil.skyblock.command.SubCommand;
import me.goodandevil.skyblock.config.FileManager;
import me.goodandevil.skyblock.config.FileManager.Config;
import me.goodandevil.skyblock.hologram.Hologram;
import me.goodandevil.skyblock.hologram.HologramManager;
import me.goodandevil.skyblock.hologram.HologramType;
import me.goodandevil.skyblock.leaderboard.LeaderboardManager;
import me.goodandevil.skyblock.message.MessageManager;
import me.goodandevil.skyblock.sound.SoundManager;
import me.goodandevil.skyblock.utils.version.Sounds;
import org.apache.commons.lang3.text.WordUtils;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
import org.bukkit.command.ConsoleCommandSender;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.Player;
import java.io.File;
import java.io.IOException;
public class RefreshHologramsCommand extends SubCommand {
@Override
public void onCommandByPlayer(Player player, String[] args) {
onCommand(player, args);
}
@Override
public void onCommandByConsole(ConsoleCommandSender sender, String[] args) {
onCommand(sender, args);
}
public void onCommand(CommandSender sender, String[] args) {
MessageManager messageManager = skyblock.getMessageManager();
SoundManager soundManager = skyblock.getSoundManager();
FileManager fileManager = skyblock.getFileManager();
Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml"));
FileConfiguration configLoad = config.getFileConfiguration();
LeaderboardManager leaderboardManager = skyblock.getLeaderboardManager();
leaderboardManager.clearLeaderboard();
leaderboardManager.resetLeaderboard();
leaderboardManager.setupLeaderHeads();
skyblock.getHologramManager().resetHologram();
messageManager.sendMessage(sender, configLoad.getString("Command.Island.Admin.RefreshHolograms.Refreshed.Message"));
soundManager.playSound(sender, Sounds.NOTE_PLING.bukkitSound(), 1.0F, 1.0F);
}
@Override
public String getName() {
return "refreshholograms";
}
@Override
public String getInfoMessagePath() {
return "Command.Island.Admin.RefreshHolograms.Info.Message";
}
@Override
public String[] getAliases() {
return new String[0];
}
@Override
public String[] getArguments() {
return new String[0];
}
}

View File

@ -39,8 +39,8 @@ public class ReloadCommand extends SubCommand {
SoundManager soundManager = skyblock.getSoundManager(); SoundManager soundManager = skyblock.getSoundManager();
FileManager fileManager = skyblock.getFileManager(); FileManager fileManager = skyblock.getFileManager();
messageManager.sendMessage(sender, "&cPlease note that this command is not supported and may" + messageManager.sendMessage(sender, "&cPlease note that this command is not supported and may " +
"cause issues that will make the status of the plugin unrecoverable. " + "cause issues that could put the plugin in an unstable state. " +
"If you encounter any issues please stop your server, edit the configuration files, " + "If you encounter any issues please stop your server, edit the configuration files, " +
"and then start your server again. This command does NOT reload all the plugin files, only " + "and then start your server again. This command does NOT reload all the plugin files, only " +
"the config.yml, language.yml, generators.yml, and levelling.yml."); "the config.yml, language.yml, generators.yml, and levelling.yml.");
@ -86,18 +86,15 @@ public class ReloadCommand extends SubCommand {
levellingManager.unregisterMaterials(); levellingManager.unregisterMaterials();
levellingManager.registerMaterials(); levellingManager.registerMaterials();
Bukkit.getServer().getScheduler().runTask(skyblock, new Runnable() { Bukkit.getServer().getScheduler().runTask(skyblock, () -> {
@Override for (HologramType hologramTypeList : HologramType.values()) {
public void run() { Hologram hologram = hologramManager.getHologram(hologramTypeList);
for (HologramType hologramTypeList : HologramType.values()) {
Hologram hologram = hologramManager.getHologram(hologramTypeList);
if (hologram != null) { if (hologram != null) {
hologramManager.removeHologram(hologram); hologramManager.removeHologram(hologram);
}
hologramManager.spawnHologram(hologramTypeList);
} }
hologramManager.spawnHologram(hologramTypeList);
} }
}); });

View File

@ -13,7 +13,9 @@ import me.goodandevil.skyblock.utils.version.NMSUtil;
import me.goodandevil.skyblock.utils.version.Sounds; import me.goodandevil.skyblock.utils.version.Sounds;
import me.goodandevil.skyblock.world.WorldManager; import me.goodandevil.skyblock.world.WorldManager;
import org.bukkit.*; import org.bukkit.*;
import org.bukkit.block.CreatureSpawner;
import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable; import org.bukkit.scheduler.BukkitRunnable;
@ -65,6 +67,9 @@ public class LevellingManager {
} }
} }
boolean isEpicSpawnersEnabled = Bukkit.getPluginManager().isPluginEnabled("EpicSpawners");
boolean isWildStackerEnabled = Bukkit.getPluginManager().isPluginEnabled("WildStacker");
Map<LevellingData, Long> levellingData = new HashMap<>(); Map<LevellingData, Long> levellingData = new HashMap<>();
for (ChunkSnapshot chunkSnapshotList : chunk.getChunkSnapshots()) { for (ChunkSnapshot chunkSnapshotList : chunk.getChunkSnapshots()) {
@ -74,6 +79,7 @@ public class LevellingManager {
try { try {
org.bukkit.Material blockMaterial = org.bukkit.Material.AIR; org.bukkit.Material blockMaterial = org.bukkit.Material.AIR;
int blockData = 0; int blockData = 0;
EntityType spawnerType = null;
if (NMSVersion > 12) { if (NMSVersion > 12) {
if (getBlockTypeMethod == null) { if (getBlockTypeMethod == null) {
@ -109,26 +115,54 @@ public class LevellingManager {
continue; continue;
long amount = 1; long amount = 1;
if (blockMaterial == Materials.SPAWNER.parseMaterial()
&& Bukkit.getPluginManager().isPluginEnabled("EpicSpawners")) { if (blockMaterial == Materials.SPAWNER.parseMaterial()) {
World world = Bukkit.getWorld(chunkSnapshotList.getWorldName()); World world = Bukkit.getWorld(chunkSnapshotList.getWorldName());
com.songoda.epicspawners.api.EpicSpawners epicSpawners =
com.songoda.epicspawners.api.EpicSpawnersAPI.getImplementation();
Location location = new Location(world, chunkSnapshotList.getX() * 16 + x, y, chunkSnapshotList.getZ() * 16 + z); Location location = new Location(world, chunkSnapshotList.getX() * 16 + x, y, chunkSnapshotList.getZ() * 16 + z);
if (epicSpawners.getSpawnerManager().isSpawner(location)) {
amount = epicSpawners.getSpawnerManager() if (isEpicSpawnersEnabled) {
.getSpawnerFromWorld(location).getSpawnerDataCount(); com.songoda.epicspawners.api.EpicSpawners epicSpawners = com.songoda.epicspawners.api.EpicSpawnersAPI.getImplementation();
if (epicSpawners.getSpawnerManager().isSpawner(location)) {
com.songoda.epicspawners.api.spawner.Spawner spawner = epicSpawners.getSpawnerManager().getSpawnerFromWorld(location);
amount = spawner.getSpawnerDataCount();
spawnerType = spawner.getCreatureSpawner().getSpawnedType();
}
} else if (isWildStackerEnabled) {
com.bgsoftware.wildstacker.api.handlers.SystemManager wildStacker = com.bgsoftware.wildstacker.api.WildStackerAPI.getWildStacker().getSystemManager();
if (wildStacker.isStackedSpawner(location.getBlock())) {
com.bgsoftware.wildstacker.api.objects.StackedSpawner spawner = wildStacker.getStackedSpawner(location);
amount = spawner.getStackAmount();
spawnerType = spawner.getSpawnedType();
}
} else {
spawnerType = ((CreatureSpawner) location.getBlock().getState()).getSpawnedType();
} }
} else if (stackableManager != null && stackableManager.getStackableMaterials().contains(blockMaterial)) { } else {
World world = Bukkit.getWorld(chunkSnapshotList.getWorldName()); if (isWildStackerEnabled) {
Location location = new Location(world, chunkSnapshotList.getX() * 16 + x, y, chunkSnapshotList.getZ() * 16 + z); World world = Bukkit.getWorld(chunkSnapshotList.getWorldName());
if (stackableManager.isStacked(location)) { Location location = new Location(world, chunkSnapshotList.getX() * 16 + x, y, chunkSnapshotList.getZ() * 16 + z);
Stackable stackable = stackableManager.getStack(location, blockMaterial); com.bgsoftware.wildstacker.api.handlers.SystemManager wildStacker = com.bgsoftware.wildstacker.api.WildStackerAPI.getWildStacker().getSystemManager();
amount = stackable.getSize(); if (wildStacker.isStackedBarrel(location.getBlock())) {
com.bgsoftware.wildstacker.api.objects.StackedBarrel barrel = wildStacker.getStackedBarrel(location.getBlock());
amount = barrel.getStackAmount();
blockMaterial = barrel.getType();
blockData = barrel.getData();
if (NMSUtil.getVersionNumber() > 12 && blockMaterial.name().startsWith("LEGACY_")) {
blockMaterial = Material.matchMaterial(blockMaterial.name().replace("LEGACY_", ""));
blockData = 0;
}
}
} else if (stackableManager != null && stackableManager.getStackableMaterials().contains(blockMaterial)) {
World world = Bukkit.getWorld(chunkSnapshotList.getWorldName());
Location location = new Location(world, chunkSnapshotList.getX() * 16 + x, y, chunkSnapshotList.getZ() * 16 + z);
if (stackableManager.isStacked(location)) {
Stackable stackable = stackableManager.getStack(location, blockMaterial);
amount = stackable.getSize();
}
} }
} }
LevellingData data = new LevellingData(blockMaterial, (byte)blockData); LevellingData data = new LevellingData(blockMaterial, (byte)blockData, spawnerType);
Long totalAmountInteger = levellingData.get(data); Long totalAmountInteger = levellingData.get(data);
long totalAmount = totalAmountInteger == null ? amount : totalAmountInteger + amount; long totalAmount = totalAmountInteger == null ? amount : totalAmountInteger + amount;
levellingData.put(data, totalAmount); levellingData.put(data, totalAmount);
@ -233,10 +267,12 @@ public class LevellingManager {
private class LevellingData { private class LevellingData {
private final Material material; private final Material material;
private final byte data; private final byte data;
private final EntityType spawnerType;
private LevellingData(Material material, byte data) { private LevellingData(Material material, byte data, EntityType spawnerType) {
this.material = material; this.material = material;
this.data = data; this.data = data;
this.spawnerType = spawnerType;
} }
@Override @Override
@ -244,15 +280,19 @@ public class LevellingManager {
if (!(obj instanceof LevellingData)) return false; if (!(obj instanceof LevellingData)) return false;
LevellingData data = (LevellingData)obj; LevellingData data = (LevellingData)obj;
if (this == obj) return true; if (this == obj) return true;
return this.material == data.material && this.data == data.data; return this.material == data.material && this.data == data.data && this.spawnerType == data.spawnerType;
} }
@Override @Override
public int hashCode() { public int hashCode() {
return Objects.hash(this.material, this.data); return Objects.hash(this.material, this.data, this.spawnerType);
} }
private Materials getMaterials() { private Materials getMaterials() {
if (this.spawnerType != null) {
return Materials.fromString("SPAWNER_" + this.spawnerType.name());
}
if (NMSUtil.getVersionNumber() > 12) { if (NMSUtil.getVersionNumber() > 12) {
try { try {
return Materials.fromString(material.name()); return Materials.fromString(material.name());

View File

@ -0,0 +1,93 @@
package me.goodandevil.skyblock.listeners;
import com.songoda.epicspawners.api.events.SpawnerBreakEvent;
import com.songoda.epicspawners.api.events.SpawnerPlaceEvent;
import me.goodandevil.skyblock.SkyBlock;
import me.goodandevil.skyblock.config.FileManager;
import me.goodandevil.skyblock.island.Island;
import me.goodandevil.skyblock.island.IslandLevel;
import me.goodandevil.skyblock.island.IslandManager;
import me.goodandevil.skyblock.utils.version.Materials;
import me.goodandevil.skyblock.world.WorldManager;
import org.bukkit.Location;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.EntityType;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import java.io.File;
public class EpicSpawners implements Listener {
private final SkyBlock skyblock;
public EpicSpawners(SkyBlock skyblock) {
this.skyblock = skyblock;
}
@EventHandler
public void onSpawnerPlace(SpawnerPlaceEvent event) {
IslandManager islandManager = skyblock.getIslandManager();
WorldManager worldManager = skyblock.getWorldManager();
Location location = event.getSpawner().getLocation();
if (!worldManager.isIslandWorld(location.getWorld())) return;
Island island = islandManager.getIslandAtLocation(location);
int amount = event.getSpawner().getFirstStack().getStackSize();
EntityType spawnerType = event.getSpawner().getCreatureSpawner().getSpawnedType();
FileManager.Config config = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml"));
FileConfiguration configLoad = config.getFileConfiguration();
if (configLoad.getBoolean("Island.Block.Level.Enable")) {
Materials materials = Materials.getSpawner(spawnerType);
if (materials != null) {
IslandLevel level = island.getLevel();
long materialAmount = 0;
if (level.hasMaterial(materials.name())) {
materialAmount = level.getMaterialAmount(materials.name());
}
level.setMaterialAmount(materials.name(), materialAmount + amount);
}
}
}
@EventHandler
public void onSpawnerBreak(SpawnerBreakEvent event) {
IslandManager islandManager = skyblock.getIslandManager();
WorldManager worldManager = skyblock.getWorldManager();
Location location = event.getSpawner().getLocation();
if (!worldManager.isIslandWorld(location.getWorld())) return;
Island island = islandManager.getIslandAtLocation(location);
int amount = event.getSpawner().getFirstStack().getStackSize();
EntityType spawnerType = event.getSpawner().getCreatureSpawner().getSpawnedType();
FileManager.Config config = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml"));
FileConfiguration configLoad = config.getFileConfiguration();
if (configLoad.getBoolean("Island.Block.Level.Enable")) {
Materials materials = Materials.getSpawner(spawnerType);
if (materials != null) {
IslandLevel level = island.getLevel();
if (level.hasMaterial(materials.name())) {
long materialAmount = level.getMaterialAmount(materials.name());
if (materialAmount - amount <= 0) {
level.removeMaterial(materials.name());
} else {
level.setMaterialAmount(materials.name(), materialAmount - amount);
}
}
}
}
}
}

View File

@ -0,0 +1,150 @@
package me.goodandevil.skyblock.listeners;
import com.bgsoftware.wildstacker.api.events.BarrelUnstackEvent;
import com.bgsoftware.wildstacker.api.events.SpawnerUnstackEvent;
import me.goodandevil.skyblock.SkyBlock;
import me.goodandevil.skyblock.config.FileManager;
import me.goodandevil.skyblock.island.Island;
import me.goodandevil.skyblock.island.IslandLevel;
import me.goodandevil.skyblock.island.IslandManager;
import me.goodandevil.skyblock.utils.version.Materials;
import me.goodandevil.skyblock.utils.version.NMSUtil;
import me.goodandevil.skyblock.world.WorldManager;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.EntityType;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import java.io.File;
public class WildStacker implements Listener {
private final SkyBlock skyblock;
public WildStacker(SkyBlock skyblock) {
this.skyblock = skyblock;
}
@EventHandler
public void onBarrelUnstack(BarrelUnstackEvent event) {
IslandManager islandManager = skyblock.getIslandManager();
WorldManager worldManager = skyblock.getWorldManager();
Location location = event.getBarrel().getLocation();
if (!worldManager.isIslandWorld(location.getWorld())) return;
Island island = islandManager.getIslandAtLocation(location);
Material material = event.getBarrel().getType();
byte data = (byte) event.getBarrel().getData();
if (NMSUtil.getVersionNumber() > 12 && material.name().startsWith("LEGACY_")) {
material = Material.matchMaterial(material.name().replace("LEGACY_", ""));
data = 0;
}
FileManager.Config config = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml"));
FileConfiguration configLoad = config.getFileConfiguration();
if (configLoad.getBoolean("Island.Block.Level.Enable")) {
Materials materials = Materials.getMaterials(material, data);
if (materials != null) {
IslandLevel level = island.getLevel();
if (level.hasMaterial(materials.name())) {
long materialAmount = level.getMaterialAmount(materials.name());
if (materialAmount - event.getAmount() <= 0) {
level.removeMaterial(materials.name());
} else {
level.setMaterialAmount(materials.name(), materialAmount - event.getAmount());
}
}
}
}
}
@EventHandler
public void onSpawnerUnstack(SpawnerUnstackEvent event) {
IslandManager islandManager = skyblock.getIslandManager();
WorldManager worldManager = skyblock.getWorldManager();
Location location = event.getSpawner().getLocation();
if (!worldManager.isIslandWorld(location.getWorld())) return;
Island island = islandManager.getIslandAtLocation(location);
EntityType spawnerType = event.getSpawner().getSpawnedType();
FileManager.Config config = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml"));
FileConfiguration configLoad = config.getFileConfiguration();
if (configLoad.getBoolean("Island.Block.Level.Enable")) {
Materials materials = Materials.getSpawner(spawnerType);
if (materials != null) {
IslandLevel level = island.getLevel();
if (level.hasMaterial(materials.name())) {
long materialAmount = level.getMaterialAmount(materials.name());
if (materialAmount - event.getAmount() <= 0) {
level.removeMaterial(materials.name());
} else {
level.setMaterialAmount(materials.name(), materialAmount - event.getAmount());
}
}
}
}
}
// TODO: Readd after WildStacker 2.7.4 is released. A feature is being added that will let us multiply the drops by 2x.
// @EventHandler
// public void onMobStack(EntityStackEvent event) {
// LivingEntity livingEntity = event.getEntity().getLivingEntity();
//
// // Certain entities shouldn't drop twice the amount
// if (livingEntity instanceof Player ||
// livingEntity instanceof ArmorStand ||
// livingEntity instanceof Horse) {
// return;
// }
//
// if (NMSUtil.getVersionNumber() > 8) {
// if (livingEntity instanceof Donkey || livingEntity instanceof Mule)
// return;
// }
//
// if (livingEntity.hasMetadata("SkyBlock")) {
// return;
// }
//
// IslandManager islandManager = skyblock.getIslandManager();
//
// if (skyblock.getWorldManager().isIslandWorld(livingEntity.getWorld())) {
// Island island = islandManager.getIslandAtLocation(livingEntity.getLocation());
//
// if (island != null) {
// List<Upgrade> upgrades = skyblock.getUpgradeManager().getUpgrades(Upgrade.Type.Drops);
//
// if (upgrades != null && upgrades.size() > 0 && upgrades.get(0).isEnabled()
// && island.isUpgrade(Upgrade.Type.Drops)) {
// StackedEntity entity = event.getEntity();
// StackedEntity target = event.getTarget();
//
// List<ItemStack> drops = target.getDrops(0);
// for (ItemStack item : drops) {
// item.setAmount(item.getAmount() * 2);
// }
//
// List<ItemStack> newDrops = entity.getDrops(0);
// newDrops.addAll(drops);
//
// entity.setTempLootTable(newDrops);
// }
// }
// }
// }
}

View File

@ -2,8 +2,10 @@ package me.goodandevil.skyblock.menus;
import java.io.File; import java.io.File;
import java.util.HashMap; import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.stream.Collectors;
import org.apache.commons.lang3.text.WordUtils; import org.apache.commons.lang3.text.WordUtils;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
@ -194,30 +196,34 @@ public class Levelling {
IslandLevel level = island.getLevel(); IslandLevel level = island.getLevel();
Map<String, Long> testIslandMaterials = level.getMaterials(); Map<String, Long> testIslandMaterials = level.getMaterials();
Map<String, Long> islandMaterials = new HashMap<>(); List<String> testIslandMaterialKeysOrdered = testIslandMaterials.keySet().stream().sorted().collect(Collectors.toList());
LinkedHashMap<String, Long> islandMaterials = new LinkedHashMap<>();
Config mainConfig = fileManager.getConfig(new File(skyblock.getDataFolder(), "levelling.yml")); Config mainConfig = fileManager.getConfig(new File(skyblock.getDataFolder(), "levelling.yml"));
Config settingsConfig = fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")); Config settingsConfig = fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml"));
// Filter out ItemStacks that can't be displayed in the inventory // Filter out ItemStacks that can't be displayed in the inventory
Inventory testInventory = Bukkit.createInventory(null, 9); Inventory testInventory = Bukkit.createInventory(null, 9);
for (String materialName : testIslandMaterials.keySet()) { for (String materialName : testIslandMaterialKeysOrdered) {
if (mainConfig.getFileConfiguration().getString("Materials." + materialName + ".Points") == null) if (mainConfig.getFileConfiguration().getString("Materials." + materialName + ".Points") == null)
continue; continue;
if (!settingsConfig.getFileConfiguration().getBoolean("Island.Levelling.IncludeEmptyPointsInList") && if (!settingsConfig.getFileConfiguration().getBoolean("Island.Levelling.IncludeEmptyPointsInList") &&
mainConfig.getFileConfiguration().getInt("Materials." + materialName + ".Points") <= 0) mainConfig.getFileConfiguration().getInt("Materials." + materialName + ".Points") <= 0)
continue; continue;
long value = testIslandMaterials.get(materialName);
Materials materials = Materials.fromString(materialName); Materials materials = Materials.fromString(materialName);
ItemStack is = materials.parseItem(); ItemStack is = materials.parseItem();
is.setAmount(Math.min(Math.toIntExact(testIslandMaterials.get(materialName)), 64));
if (is == null || is.getItemMeta() == null) continue;
is.setAmount(Math.min(Math.toIntExact(value), 64));
is.setType(MaterialUtil.correctMaterial(is.getType())); is.setType(MaterialUtil.correctMaterial(is.getType()));
if (is == null || is.getItemMeta() == null) continue;
testInventory.clear(); testInventory.clear();
testInventory.setItem(0, is); testInventory.setItem(0, is);
if (testInventory.getItem(0) != null) { if (testInventory.getItem(0) != null) {
islandMaterials.put(materialName, testIslandMaterials.get(materialName)); islandMaterials.put(materialName, value);
} }
} }
@ -285,18 +291,23 @@ public class Levelling {
is.setAmount(Math.min(Math.toIntExact(materialAmount), 64)); is.setAmount(Math.min(Math.toIntExact(materialAmount), 64));
is.setType(MaterialUtil.correctMaterial(is.getType())); is.setType(MaterialUtil.correctMaterial(is.getType()));
String name;
if (materials.isSpawner() && materials != Materials.SPAWNER) {
name = "Spawner: " + WordUtils.capitalize(material.replace("SPAWNER_", "").toLowerCase().replace("_", " ")).trim();
} else {
name = WordUtils.capitalize(material.toLowerCase().replace("_", " ")).trim();
}
List<String> lore = configLoad.getStringList("Menu.Levelling.Item.Material.Lore"); List<String> lore = configLoad.getStringList("Menu.Levelling.Item.Material.Lore");
lore.replaceAll(x -> x.replace("%points", NumberUtil.formatNumberByDecimal(pointsEarned)) lore.replaceAll(x -> x.replace("%points", NumberUtil.formatNumberByDecimal(pointsEarned))
.replace("%blocks", NumberUtil.formatNumberByDecimal(materialAmount)) .replace("%blocks", NumberUtil.formatNumberByDecimal(materialAmount))
.replace("%material", .replace("%material", name));
WordUtils.capitalize(material.toLowerCase().replace("_", " ")).trim()));
nInv.addItem(nInv.createItem(is, configLoad nInv.addItem(nInv.createItem(is, configLoad
.getString("Menu.Levelling.Item.Material.Displayname") .getString("Menu.Levelling.Item.Material.Displayname")
.replace("%points", NumberUtil.formatNumberByDecimal(pointsEarned)) .replace("%points", NumberUtil.formatNumberByDecimal(pointsEarned))
.replace("%blocks", NumberUtil.formatNumberByDecimal(materialAmount)) .replace("%blocks", NumberUtil.formatNumberByDecimal(materialAmount))
.replace("%material", .replace("%material", name),
WordUtils.capitalize(material.toLowerCase().replace("_", " ")).trim()),
lore, null, null, null), inventorySlot); lore, null, null, null), inventorySlot);
} }
} }

View File

@ -5,6 +5,7 @@ import java.util.HashMap;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.entity.EntityType;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
public enum Materials { public enum Materials {
@ -767,6 +768,63 @@ public enum Materials {
SNOW_BLOCK("SNOW_BLOCK", 0), SNOW_BLOCK("SNOW_BLOCK", 0),
SOUL_SAND("SOUL_SAND", 0), SOUL_SAND("SOUL_SAND", 0),
SPAWNER("MOB_SPAWNER", 0), SPAWNER("MOB_SPAWNER", 0),
SPAWNER_BAT(null, -1),
SPAWNER_BLAZE(null, -1),
SPAWNER_CAVE_SPIDER(null, -1),
SPAWNER_CHICKEN(null, -1),
SPAWNER_COD(null, -1),
SPAWNER_COW(null, -1),
SPAWNER_CREEPER(null, -1),
SPAWNER_DOLPHIN(null, -1),
SPAWNER_DONKEY(null, -1),
SPAWNER_DROWNED(null, -1),
SPAWNER_ELDER_GUARDIAN(null, -1),
SPAWNER_ENDER_DRAGON(null, -1),
SPAWNER_ENDERMAN(null, -1),
SPAWNER_ENDERMITE(null, -1),
SPAWNER_EVOKER(null, -1),
SPAWNER_GHAST(null, -1),
SPAWNER_GIANT(null, -1),
SPAWNER_GUARDIAN(null, -1),
SPAWNER_HORSE(null, -1),
SPAWNER_HUSK(null, -1),
SPAWNER_ILLUSIONER(null, -1),
SPAWNER_IRON_GOLEM(null, -1),
SPAWNER_LLAMA(null, -1),
SPAWNER_MAGMA_CUBE(null, -1),
SPAWNER_MULE(null, -1),
SPAWNER_MUSHROOM_COW(null, -1),
SPAWNER_OCELOT(null, -1),
SPAWNER_PARROT(null, -1),
SPAWNER_PHANTOM(null, -1),
SPAWNER_PIG(null, -1),
SPAWNER_PIG_ZOMBIE(null, -1),
SPAWNER_POLAR_BEAR(null, -1),
SPAWNER_PUFFERFISH(null, -1),
SPAWNER_RABBIT(null, -1),
SPAWNER_SALMON(null, -1),
SPAWNER_SHEEP(null, -1),
SPAWNER_SHULKER(null, -1),
SPAWNER_SILVERFISH(null, -1),
SPAWNER_SKELETON(null, -1),
SPAWNER_SKELETON_HORSE(null, -1),
SPAWNER_SLIME(null, -1),
SPAWNER_SNOWMAN(null, -1),
SPAWNER_SPIDER(null, -1),
SPAWNER_SQUID(null, -1),
SPAWNER_STRAY(null, -1),
SPAWNER_TROPICAL_FISH(null, -1),
SPAWNER_TURTLE(null, -1),
SPAWNER_VEX(null, -1),
SPAWNER_VILLAGER(null, -1),
SPAWNER_VINDICATOR(null, -1),
SPAWNER_WITCH(null, -1),
SPAWNER_WITHER(null, -1),
SPAWNER_WITHER_SKELETON(null, -1),
SPAWNER_WOLF(null, -1),
SPAWNER_ZOMBIE(null, -1),
SPAWNER_ZOMBIE_HORSE(null, -1),
SPAWNER_ZOMBIE_VILLAGER(null, -1),
SPECTRAL_ARROW("SPECTRAL_ARROW", 0), SPECTRAL_ARROW("SPECTRAL_ARROW", 0),
SPIDER_EYE("SPIDER_EYE", 0), SPIDER_EYE("SPIDER_EYE", 0),
SPIDER_SPAWN_EGG("MONSTER_EGG", 0), SPIDER_SPAWN_EGG("MONSTER_EGG", 0),
@ -942,6 +1000,14 @@ public enum Materials {
* @return True if the Material exists * @return True if the Material exists
*/ */
public boolean isAvailable() { public boolean isAvailable() {
if (this.isSpawner() && this != Materials.SPAWNER) {
String spawnerType = this.name().replace("SPAWNER_", "");
for (EntityType entityType : EntityType.values())
if (entityType.name().equalsIgnoreCase(spawnerType))
return true;
return false;
}
return isNewVersion() || !this.is13only; return isNewVersion() || !this.is13only;
} }
@ -974,6 +1040,14 @@ public enum Materials {
return null; return null;
} }
public boolean isSpawner() {
return this.name().startsWith("SPAWNER");
}
public static Materials getSpawner(EntityType spawnerType) {
return fromString("SPAWNER_" + spawnerType.name());
}
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
public boolean isSameMaterial(ItemStack comp) { public boolean isSameMaterial(ItemStack comp) {
if (isNewVersion()) { if (isNewVersion()) {
@ -1066,6 +1140,9 @@ public enum Materials {
} }
public Material parseMaterial() { public Material parseMaterial() {
if (this.isSpawner() && this != Materials.SPAWNER)
return Materials.SPAWNER.parseMaterial();
Material mat = Material.matchMaterial(this.toString()); Material mat = Material.matchMaterial(this.toString());
if (mat != null) { if (mat != null) {

View File

@ -773,6 +773,11 @@ Command:
Message: "&bSkyBlock &8| &cError&8: &eA location for that hologram has not been set." Message: "&bSkyBlock &8| &cError&8: &eA location for that hologram has not been set."
Removed: Removed:
Message: "&bSkyBlock &8| &aInfo&8: &eYou have removed the '&b%type&e' hologram." Message: "&bSkyBlock &8| &aInfo&8: &eYou have removed the '&b%type&e' hologram."
RefreshHolograms:
Info:
Message: "&f&oRefreshes any existing holograms."
Refreshed:
Message: "&bSkyBlock &8| &aInfo&8: &eRefreshed holograms."
SetSize: SetSize:
Info: Info:
Message: "&f&oSets the size of a players Island." Message: "&f&oSets the size of a players Island."

View File

@ -25,7 +25,6 @@ Materials:
ACACIA_STAIRS: ACACIA_STAIRS:
Points: 2 Points: 2
ACACIA_TRAPDOOR: ACACIA_TRAPDOOR:
Points: 3
ACACIA_WOOD: ACACIA_WOOD:
Points: 1 Points: 1
ACTIVATOR_RAIL: ACTIVATOR_RAIL:
@ -1010,6 +1009,120 @@ Materials:
Points: 1 Points: 1
SPAWNER: SPAWNER:
Points: 10 Points: 10
SPAWNER_BAT:
Points: 10
SPAWNER_BLAZE:
Points: 10
SPAWNER_CAVE_SPIDER:
Points: 10
SPAWNER_CHICKEN:
Points: 10
SPAWNER_COD:
Points: 10
SPAWNER_COW:
Points: 10
SPAWNER_CREEPER:
Points: 10
SPAWNER_DOLPHIN:
Points: 10
SPAWNER_DONKEY:
Points: 10
SPAWNER_DROWNED:
Points: 10
SPAWNER_ELDER_GUARDIAN:
Points: 10
SPAWNER_ENDER_DRAGON:
Points: 10
SPAWNER_ENDERMAN:
Points: 10
SPAWNER_ENDERMITE:
Points: 10
SPAWNER_EVOKER:
Points: 10
SPAWNER_GHAST:
Points: 10
SPAWNER_GIANT:
Points: 10
SPAWNER_GUARDIAN:
Points: 10
SPAWNER_HORSE:
Points: 10
SPAWNER_HUSK:
Points: 10
SPAWNER_ILLUSIONER:
Points: 10
SPAWNER_IRON_GOLEM:
Points: 10
SPAWNER_LLAMA:
Points: 10
SPAWNER_MAGMA_CUBE:
Points: 10
SPAWNER_MULE:
Points: 10
SPAWNER_MUSHROOM_COW:
Points: 10
SPAWNER_OCELOT:
Points: 10
SPAWNER_PARROT:
Points: 10
SPAWNER_PHANTOM:
Points: 10
SPAWNER_PIG:
Points: 10
SPAWNER_PIG_ZOMBIE:
Points: 10
SPAWNER_POLAR_BEAR:
Points: 10
SPAWNER_PUFFERFISH:
Points: 10
SPAWNER_RABBIT:
Points: 10
SPAWNER_SALMON:
Points: 10
SPAWNER_SHEEP:
Points: 10
SPAWNER_SHULKER:
Points: 10
SPAWNER_SILVERFISH:
Points: 10
SPAWNER_SKELETON:
Points: 10
SPAWNER_SKELETON_HORSE:
Points: 10
SPAWNER_SLIME:
Points: 10
SPAWNER_SNOWMAN:
Points: 10
SPAWNER_SPIDER:
Points: 10
SPAWNER_SQUID:
Points: 10
SPAWNER_STRAY:
Points: 10
SPAWNER_TROPICAL_FISH:
Points: 10
SPAWNER_TURTLE:
Points: 10
SPAWNER_VEX:
Points: 10
SPAWNER_VILLAGER:
Points: 10
SPAWNER_VINDICATOR:
Points: 10
SPAWNER_WITCH:
Points: 10
SPAWNER_WITHER:
Points: 10
SPAWNER_WITHER_SKELETON:
Points: 10
SPAWNER_WOLF:
Points: 10
SPAWNER_ZOMBIE:
Points: 10
SPAWNER_ZOMBIE_HORSE:
Points: 10
SPAWNER_ZOMBIE_VILLAGER:
Points: 10
SPONGE: SPONGE:
Points: 10 Points: 10
SPRUCE_BUTTON: SPRUCE_BUTTON:

View File

@ -4,12 +4,11 @@ version: maven-version-number
api-version: 1.13 api-version: 1.13
description: A unique SkyBlock plugin description: A unique SkyBlock plugin
author: Songoda author: Songoda
softdepend: [PlaceholderAPI, MVdWPlaceholderAPI, Vault, LeaderHeads] softdepend: [PlaceholderAPI, MVdWPlaceholderAPI, Vault, LeaderHeads, WildStacker]
loadbefore: [Multiverse-Core] loadbefore: [Multiverse-Core]
commands: commands:
island: island:
description: Island command description: Island command
aliases: [is] aliases: [is]
skyblock: skyblock:
description: Skyblock info command. description: Skyblock info command.