Dragon egg fix, island setspawn fix, update EpicSpawners hooks

This commit is contained in:
Esophose 2019-05-25 17:34:54 -06:00
parent 17a0b30161
commit 4214c60fe3
5 changed files with 53 additions and 27 deletions

View File

@ -32,7 +32,7 @@ dependencies {
implementation (group: 'me.robin', name: 'leaderheads', version: '1.0') implementation (group: 'me.robin', name: 'leaderheads', version: '1.0')
// EpicSpawners // EpicSpawners
implementation (group: 'com.songoda', name: 'epicspawners', version: '5.7.1') implementation (group: 'com.songoda', name: 'epicspawners', version: '6-pre4')
// WildStacker // WildStacker
implementation (group: 'com.bgsoftware', name: 'wildstacker-api', version: 'b14') implementation (group: 'com.bgsoftware', name: 'wildstacker-api', version: 'b14')
@ -44,6 +44,9 @@ dependencies {
shade (group: 'org.apache.commons', name: 'commons-lang3', version: '3.0') shade (group: 'org.apache.commons', name: 'commons-lang3', version: '3.0')
shade (group: 'commons-io', name: 'commons-io', version: '2.5') shade (group: 'commons-io', name: 'commons-io', version: '2.5')
// JetBrains Annotations
compile (group: 'org.jetbrains', name: 'annotations', version: '13.0')
// Songoda Updater // Songoda Updater
shade (group: 'com.songoda', name: 'songodaupdater', version: '1') shade (group: 'com.songoda', name: 'songodaupdater', version: '1')

View File

@ -70,7 +70,7 @@ public class SetSpawnCommand extends SubCommand {
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
return; return;
} else if (location.getY() - location.getBlockY() != 0.0D) { } else if (!player.getLocation().clone().subtract(0, 0.1, 0).getBlock().getType().isSolid()) {
messageManager.sendMessage(player, messageManager.sendMessage(player,
configLoad.getString("Command.Island.SetSpawn.Protection.Ground.Message")); configLoad.getString("Command.Island.SetSpawn.Protection.Ground.Message"));
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
@ -92,11 +92,13 @@ public class SetSpawnCommand extends SubCommand {
return; return;
} else { } else {
if (location.getBlock().getType() != Material.AIR && location.getBlock().getType() != Materials.MOVING_PISTON.parseMaterial()) { Material type = location.getBlock().getType();
if (type.isSolid() && type.isOccluding()) {
location.getBlock().breakNaturally(); location.getBlock().breakNaturally();
} }
if (location.clone().add(0.0D, 1.0D, 0.0D).getBlock().getType() != Material.AIR && location.getBlock().getType() != Materials.MOVING_PISTON.parseMaterial()) { Material typeBelow = location.clone().add(0.0D, 1.0D, 0.0D).getBlock().getType();
if (typeBelow.isSolid() && type.isOccluding()) {
location.clone().add(0.0D, 1.0D, 0.0D).getBlock().breakNaturally(); location.clone().add(0.0D, 1.0D, 0.0D).getBlock().breakNaturally();
} }
@ -104,7 +106,7 @@ public class SetSpawnCommand extends SubCommand {
} }
} }
Location newSpawnLocation = new Location(location.getWorld(), location.getBlockX() + 0.5, location.getBlockY(), location.getBlockZ() + 0.5, location.getYaw(), location.getPitch()); Location newSpawnLocation = new Location(location.getWorld(), location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch());
island.setLocation(world, environment, newSpawnLocation); island.setLocation(world, environment, newSpawnLocation);
messageManager.sendMessage(player, messageManager.sendMessage(player,

View File

@ -89,6 +89,7 @@ public class LevellingManager {
Map<LevellingData, Long> levellingData = new HashMap<>(); Map<LevellingData, Long> levellingData = new HashMap<>();
Set<Location> spawnerLocations = new HashSet<>(); // These have to be checked synchronously :( Set<Location> spawnerLocations = new HashSet<>(); // These have to be checked synchronously :(
Set<Location> epicSpawnerLocations = new HashSet<>();
List<Material> blacklistedMaterials = new ArrayList<>(); List<Material> blacklistedMaterials = new ArrayList<>();
blacklistedMaterials.add(Materials.AIR.getPostMaterial()); blacklistedMaterials.add(Materials.AIR.getPostMaterial());
@ -103,7 +104,7 @@ public class LevellingManager {
if (!chunk.isReadyToScan()) return; if (!chunk.isReadyToScan()) return;
if (chunk.isFinished()) { if (chunk.isFinished()) {
Bukkit.getScheduler().scheduleSyncDelayedTask(skyblock, () -> finalizeMaterials(levellingData, spawnerLocations, player, island), 1); Bukkit.getScheduler().scheduleSyncDelayedTask(skyblock, () -> finalizeMaterials(levellingData, spawnerLocations, epicSpawnerLocations, player, island), 1);
cancel(); cancel();
return; return;
} }
@ -157,15 +158,16 @@ public class LevellingManager {
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 (isEpicSpawnersEnabled) { if (isEpicSpawnersEnabled) {
com.songoda.epicspawners.api.EpicSpawners epicSpawners = com.songoda.epicspawners.api.EpicSpawnersAPI.getImplementation(); com.songoda.epicspawners.EpicSpawners epicSpawners = com.songoda.epicspawners.EpicSpawners.getInstance();
if (epicSpawners.getSpawnerManager().isSpawner(location)) { if (epicSpawners.getSpawnerManager().isSpawner(location)) {
com.songoda.epicspawners.api.spawner.Spawner spawner = epicSpawners.getSpawnerManager().getSpawnerFromWorld(location); com.songoda.epicspawners.spawners.spawner.Spawner spawner = epicSpawners.getSpawnerManager().getSpawnerFromWorld(location);
amount = spawner.getSpawnerDataCount(); if (spawner != null)
spawnerType = spawner.getCreatureSpawner().getSpawnedType(); epicSpawnerLocations.add(location);
continue;
} }
} }
if (isWildStackerEnabled && spawnerType == null) { if (isWildStackerEnabled) {
com.bgsoftware.wildstacker.api.handlers.SystemManager wildStacker = com.bgsoftware.wildstacker.api.WildStackerAPI.getWildStacker().getSystemManager(); com.bgsoftware.wildstacker.api.handlers.SystemManager wildStacker = com.bgsoftware.wildstacker.api.WildStackerAPI.getWildStacker().getSystemManager();
com.bgsoftware.wildstacker.api.objects.StackedSpawner spawner = wildStacker.getStackedSpawner(location); com.bgsoftware.wildstacker.api.objects.StackedSpawner spawner = wildStacker.getStackedSpawner(location);
if (spawner != null) { if (spawner != null) {
@ -224,7 +226,7 @@ public class LevellingManager {
}.runTaskTimerAsynchronously(skyblock, 0L, 1L); }.runTaskTimerAsynchronously(skyblock, 0L, 1L);
} }
private void finalizeMaterials(Map<LevellingData, Long> levellingData, Set<Location> spawnerLocations, Player player, Island island) { private void finalizeMaterials(Map<LevellingData, Long> levellingData, Set<Location> spawnerLocations, Set<Location> epicSpawnerLocations, Player player, Island island) {
for (Location location : spawnerLocations) { for (Location location : spawnerLocations) {
if (!(location.getBlock().getState() instanceof CreatureSpawner)) if (!(location.getBlock().getState() instanceof CreatureSpawner))
continue; continue;
@ -238,6 +240,23 @@ public class LevellingManager {
levellingData.put(data, totalAmount); levellingData.put(data, totalAmount);
} }
for (Location location : epicSpawnerLocations) {
com.songoda.epicspawners.EpicSpawners epicSpawners = com.songoda.epicspawners.EpicSpawners.getInstance();
if (epicSpawners.getSpawnerManager().isSpawner(location)) {
com.songoda.epicspawners.spawners.spawner.Spawner spawner = epicSpawners.getSpawnerManager().getSpawnerFromWorld(location);
if (spawner == null)
continue;
int amount = spawner.getFirstStack().getStackSize();
EntityType spawnerType = spawner.getCreatureSpawner().getSpawnedType();
LevellingData data = new LevellingData(Materials.SPAWNER.parseMaterial(), (byte) 0, spawnerType);
Long totalAmountInteger = levellingData.get(data);
long totalAmount = totalAmountInteger == null ? amount : totalAmountInteger + amount;
levellingData.put(data, totalAmount);
}
}
Map<String, Long> materials = new HashMap<>(); Map<String, Long> materials = new HashMap<>();
for (LevellingData data : levellingData.keySet()) { for (LevellingData data : levellingData.keySet()) {
long amount = levellingData.get(data); long amount = levellingData.get(data);

View File

@ -128,10 +128,8 @@ public class Block implements Listener {
Config config = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")); Config config = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml"));
FileConfiguration configLoad = config.getFileConfiguration(); FileConfiguration configLoad = config.getFileConfiguration();
if (LocationUtil.isLocationLocation(block.getLocation(), if (LocationUtil.isLocationLocation(block.getLocation(), island.getLocation(world, IslandEnvironment.Main).clone().subtract(0.0D, 1.0D, 0.0D))
island.getLocation(world, IslandEnvironment.Main) || LocationUtil.isLocationLocation(block.getLocation(), island.getLocation(world, IslandEnvironment.Main).clone())) {
.clone()
.subtract(0.0D, 1.0D, 0.0D))) {
if (configLoad.getBoolean("Island.Spawn.Protection")) { if (configLoad.getBoolean("Island.Spawn.Protection")) {
event.setCancelled(true); event.setCancelled(true);
skyblock.getMessageManager().sendMessage(player, skyblock.getMessageManager().sendMessage(player,

View File

@ -62,6 +62,21 @@ public class Interact implements Listener {
SoundManager soundManager = skyblock.getSoundManager(); SoundManager soundManager = skyblock.getSoundManager();
StackableManager stackableManager = skyblock.getStackableManager(); StackableManager stackableManager = skyblock.getStackableManager();
if (event.getAction() == Action.RIGHT_CLICK_BLOCK || event.getAction() == Action.LEFT_CLICK_BLOCK) {
if (block.getType() == Material.DRAGON_EGG) {
if (!islandManager.hasPermission(player, block.getLocation(), "DragonEggUse")) {
event.setCancelled(true);
messageManager.sendMessage(player,
skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml"))
.getFileConfiguration().getString("Island.Settings.Permission.Message"));
soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
return;
}
}
}
if (event.getAction() == Action.RIGHT_CLICK_BLOCK) { if (event.getAction() == Action.RIGHT_CLICK_BLOCK) {
if (stackableManager != null if (stackableManager != null
&& stackableManager.getStackableMaterials().contains(event.getMaterial()) && stackableManager.getStackableMaterials().contains(event.getMaterial())
@ -322,17 +337,6 @@ public class Interact implements Listener {
.getFileConfiguration().getString("Island.Settings.Permission.Message")); .getFileConfiguration().getString("Island.Settings.Permission.Message"));
soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F); soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
return;
}
} else if (block.getType() == Material.DRAGON_EGG) {
if (!islandManager.hasPermission(player, block.getLocation(), "DragonEggUse")) {
event.setCancelled(true);
messageManager.sendMessage(player,
skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml"))
.getFileConfiguration().getString("Island.Settings.Permission.Message"));
soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
return; return;
} }
} else if (block.getType() == Material.HOPPER) { } else if (block.getType() == Material.HOPPER) {