mirror of
https://github.com/songoda/FabledSkyBlock.git
synced 2024-09-15 08:28:33 +02:00
Fix version token parsing, spawner & stackable fix, water/lava fix
This commit is contained in:
parent
1b824278ac
commit
b45446d13c
@ -37,8 +37,8 @@ dependencies {
|
|||||||
}
|
}
|
||||||
|
|
||||||
processResources {
|
processResources {
|
||||||
filter ReplaceTokens, tokens: ["version": project.property("version")]
|
from (sourceSets.main.resources.srcDirs) {
|
||||||
from (sourceSets.main.resources.srcDirs) {
|
include '**/*.yml'
|
||||||
include '**/*.yml'
|
filter ReplaceTokens, tokens: ["version": project.property("version")]
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -12,7 +12,11 @@ import me.goodandevil.skyblock.utils.version.Materials;
|
|||||||
import me.goodandevil.skyblock.utils.version.NMSUtil;
|
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.Bukkit;
|
||||||
|
import org.bukkit.ChunkSnapshot;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.World;
|
||||||
import org.bukkit.block.CreatureSpawner;
|
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.EntityType;
|
||||||
@ -22,7 +26,11 @@ import org.bukkit.scheduler.BukkitRunnable;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.util.*;
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Objects;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
public class LevellingManager {
|
public class LevellingManager {
|
||||||
@ -63,6 +71,13 @@ public class LevellingManager {
|
|||||||
|
|
||||||
Map<LevellingData, Long> levellingData = new HashMap<>();
|
Map<LevellingData, Long> levellingData = new HashMap<>();
|
||||||
|
|
||||||
|
List<Material> blacklistedMaterials = new ArrayList<>();
|
||||||
|
blacklistedMaterials.add(Materials.AIR.getPostMaterial());
|
||||||
|
blacklistedMaterials.add(Materials.WATER.getPostMaterial());
|
||||||
|
blacklistedMaterials.add(Materials.LEGACY_STATIONARY_WATER.getPostMaterial());
|
||||||
|
blacklistedMaterials.add(Materials.LAVA.getPostMaterial());
|
||||||
|
blacklistedMaterials.add(Materials.LEGACY_STATIONARY_LAVA.getPostMaterial());
|
||||||
|
|
||||||
new BukkitRunnable() {
|
new BukkitRunnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
@ -118,14 +133,14 @@ public class LevellingManager {
|
|||||||
blockData = (int) getBlockTypeDataMethod.invoke(chunkSnapshotList, x, y, z);
|
blockData = (int) getBlockTypeDataMethod.invoke(chunkSnapshotList, x, y, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (blockMaterial == org.bukkit.Material.AIR)
|
if (blacklistedMaterials.contains(blockMaterial))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
long amount = 1;
|
long amount = 1;
|
||||||
|
|
||||||
if (blockMaterial == Materials.SPAWNER.parseMaterial()) {
|
if (blockMaterial == Materials.SPAWNER.parseMaterial()) {
|
||||||
World world = Bukkit.getWorld(chunkSnapshotList.getWorldName());
|
World world = Bukkit.getWorld(chunkSnapshotList.getWorldName());
|
||||||
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.api.EpicSpawners epicSpawners = com.songoda.epicspawners.api.EpicSpawnersAPI.getImplementation();
|
||||||
@ -134,20 +149,24 @@ public class LevellingManager {
|
|||||||
amount = spawner.getSpawnerDataCount();
|
amount = spawner.getSpawnerDataCount();
|
||||||
spawnerType = spawner.getCreatureSpawner().getSpawnedType();
|
spawnerType = spawner.getCreatureSpawner().getSpawnedType();
|
||||||
}
|
}
|
||||||
} else if (isWildStackerEnabled) {
|
}
|
||||||
|
|
||||||
|
if (isWildStackerEnabled && spawnerType == null) {
|
||||||
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();
|
||||||
if (wildStacker.isStackedSpawner(location.getBlock())) {
|
if (wildStacker.isStackedSpawner(location.getBlock())) {
|
||||||
com.bgsoftware.wildstacker.api.objects.StackedSpawner spawner = wildStacker.getStackedSpawner(location);
|
com.bgsoftware.wildstacker.api.objects.StackedSpawner spawner = wildStacker.getStackedSpawner(location);
|
||||||
amount = spawner.getStackAmount();
|
amount = spawner.getStackAmount();
|
||||||
spawnerType = spawner.getSpawnedType();
|
spawnerType = spawner.getSpawnedType();
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
|
||||||
|
if (spawnerType == null) {
|
||||||
spawnerType = ((CreatureSpawner) location.getBlock().getState()).getSpawnedType();
|
spawnerType = ((CreatureSpawner) location.getBlock().getState()).getSpawnedType();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (isWildStackerEnabled) {
|
if (isWildStackerEnabled) {
|
||||||
World world = Bukkit.getWorld(chunkSnapshotList.getWorldName());
|
World world = Bukkit.getWorld(chunkSnapshotList.getWorldName());
|
||||||
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);
|
||||||
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();
|
||||||
if (wildStacker.isStackedBarrel(location.getBlock())) {
|
if (wildStacker.isStackedBarrel(location.getBlock())) {
|
||||||
com.bgsoftware.wildstacker.api.objects.StackedBarrel barrel = wildStacker.getStackedBarrel(location.getBlock());
|
com.bgsoftware.wildstacker.api.objects.StackedBarrel barrel = wildStacker.getStackedBarrel(location.getBlock());
|
||||||
@ -159,17 +178,19 @@ public class LevellingManager {
|
|||||||
blockData = 0;
|
blockData = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (stackableManager != null && stackableManager.getStackableMaterials().contains(blockMaterial)) {
|
}
|
||||||
|
|
||||||
|
if (stackableManager != null && stackableManager.getStackableMaterials().contains(blockMaterial) && amount == 1) {
|
||||||
World world = Bukkit.getWorld(chunkSnapshotList.getWorldName());
|
World world = Bukkit.getWorld(chunkSnapshotList.getWorldName());
|
||||||
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 (stackableManager.isStacked(location)) {
|
if (stackableManager.isStacked(location)) {
|
||||||
Stackable stackable = stackableManager.getStack(location, blockMaterial);
|
Stackable stackable = stackableManager.getStack(location, blockMaterial);
|
||||||
amount = stackable.getSize();
|
amount += stackable.getSize();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
LevellingData data = new LevellingData(blockMaterial, (byte)blockData, spawnerType);
|
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);
|
||||||
@ -289,7 +310,7 @@ public class LevellingManager {
|
|||||||
@Override
|
@Override
|
||||||
public boolean equals(Object obj) {
|
public boolean equals(Object obj) {
|
||||||
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 && this.spawnerType == data.spawnerType;
|
return this.material == data.material && this.data == data.data && this.spawnerType == data.spawnerType;
|
||||||
}
|
}
|
||||||
@ -307,7 +328,8 @@ public class LevellingManager {
|
|||||||
if (NMSUtil.getVersionNumber() > 12) {
|
if (NMSUtil.getVersionNumber() > 12) {
|
||||||
try {
|
try {
|
||||||
return Materials.fromString(material.name());
|
return Materials.fromString(material.name());
|
||||||
} catch (Exception ignored) {}
|
} catch (Exception ignored) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return Materials.getMaterials(this.material, this.data);
|
return Materials.getMaterials(this.material, this.data);
|
||||||
|
Loading…
Reference in New Issue
Block a user