Fixed blocklevel issue.

Added EpicSpawners support.
This commit is contained in:
Brianna O'Keefe 2019-01-29 22:05:00 -05:00
parent 2ce9e1d187
commit 8e929906df
4 changed files with 193 additions and 173 deletions

View File

@ -49,6 +49,11 @@
<artifactId>leaderheads</artifactId> <artifactId>leaderheads</artifactId>
<version>1.0</version> <version>1.0</version>
</dependency> </dependency>
<dependency>
<groupId>com.songoda</groupId>
<artifactId>epicspawners</artifactId>
<version>LATEST</version>
</dependency>
<dependency> <dependency>
<groupId>org.spigotmc</groupId> <groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId> <artifactId>spigot</artifactId>

View File

@ -1,21 +1,5 @@
package me.goodandevil.skyblock.levelling; package me.goodandevil.skyblock.levelling;
import java.io.File;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.logging.Level;
import org.bukkit.Bukkit;
import org.bukkit.ChunkSnapshot;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.scheduler.BukkitRunnable;
import me.goodandevil.skyblock.SkyBlock; import me.goodandevil.skyblock.SkyBlock;
import me.goodandevil.skyblock.api.event.island.IslandLevelChangeEvent; import me.goodandevil.skyblock.api.event.island.IslandLevelChangeEvent;
import me.goodandevil.skyblock.config.FileManager.Config; import me.goodandevil.skyblock.config.FileManager.Config;
@ -26,6 +10,23 @@ 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.Bukkit;
import org.bukkit.ChunkSnapshot;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.scheduler.BukkitRunnable;
import java.io.File;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.logging.Level;
public class LevellingManager { public class LevellingManager {
@ -51,7 +52,7 @@ public class LevellingManager {
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
@Override @Override
public void run() { public void run() {
if (chunk.isComplete()) { if (!chunk.isComplete()) return;
cancel(); cancel();
Map<String, Integer> materials = new HashMap<>(); Map<String, Integer> materials = new HashMap<>();
@ -109,25 +110,37 @@ 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 (blockMaterial == org.bukkit.Material.AIR) continue;
for (Material materialList : materialStorage) { for (Material materialList : materialStorage) {
if (materialList == null) continue; if (materialList == null) continue;
ItemStack is = materialList.getItemStack(); ItemStack is = materialList.getItemStack();
if (blockMaterial == materialList.getItemStack().getType()) { if (blockMaterial != materialList.getItemStack().getType()) continue;
if (NMSVersion < 13) { if (NMSVersion < 13) {
if (!(blockData == is.getDurability())) { if (!(blockData == is.getDurability())) {
continue; continue;
} }
} }
int amount = 1;
if (blockMaterial == Materials.SPAWNER.parseMaterial()
&& Bukkit.getPluginManager().isPluginEnabled("EpicSpawners")) {
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);
if (epicSpawners.getSpawnerManager().isSpawner(location)) {
amount = epicSpawners.getSpawnerManager()
.getSpawnerFromWorld(location).getSpawnerDataCount();
}
}
if (materials.containsKey(materialList.getMaterials().name())) { if (materials.containsKey(materialList.getMaterials().name())) {
materials.put(materialList.getMaterials().name(), materials.put(materialList.getMaterials().name(),
materials.get(materialList.getMaterials().name()) + 1); materials.get(materialList.getMaterials().name()) + amount);
} else { } else {
materials.put(materialList.getMaterials().name(), 1); materials.put(materialList.getMaterials().name(), amount);
}
}
} }
} }
} catch (IllegalAccessException | IllegalArgumentException } catch (IllegalAccessException | IllegalArgumentException
@ -160,7 +173,6 @@ public class LevellingManager {
} }
} }
} }
}
}.runTaskTimerAsynchronously(skyblock, 0L, 1L); }.runTaskTimerAsynchronously(skyblock, 0L, 1L);
} }

View File

@ -105,6 +105,8 @@ public class Block implements Listener {
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
Materials materials = Materials.getMaterials(block.getType(), block.getData()); Materials materials = Materials.getMaterials(block.getType(), block.getData());
Bukkit.broadcastMessage("testt");
if (materials == null) return; if (materials == null) return;
IslandLevel level = island.getLevel(); IslandLevel level = island.getLevel();
@ -169,7 +171,8 @@ public class Block implements Listener {
} }
} }
if (event.isCancelled() || configLoad.getBoolean("Island.Block.Level.Enable")) return; if (event.isCancelled() || !configLoad.getBoolean("Island.Block.Level.Enable")) return;
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
Materials materials = Materials.getMaterials(block.getType(), block.getData()); Materials materials = Materials.getMaterials(block.getType(), block.getData());

View File

@ -198,7 +198,7 @@ Island:
Level: Level:
# When enabled, any changes to a block will be made to the levelling materials # When enabled, any changes to a block will be made to the levelling materials
# calculated for an island. # calculated for an island.
Enable: false Enable: true
Piston: Piston:
# Prevent Piston blocks being retracted or extended when connected to a circuit # Prevent Piston blocks being retracted or extended when connected to a circuit
# [!] Prevents Pistons extending out of Island border bug # [!] Prevents Pistons extending out of Island border bug