diff --git a/build.gradle.kts b/build.gradle.kts index 724ca0ab8..36780ad1d 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -24,7 +24,8 @@ dependencies { implementation("org.jetbrains:annotations:24.1.0") implementation("com.j256.ormlite:ormlite-core:6.1") implementation("com.j256.ormlite:ormlite-jdbc:6.1") - implementation("com.iridium:IridiumTeams:2.4.4") + //implementation("com.iridium:IridiumTeams:2.4.4") + implementation(files("build/depend/IridiumTeams-2.4.4.jar")) // Other dependencies that are not required or already available at runtime compileOnly("org.projectlombok:lombok:1.18.32") diff --git a/src/main/java/com/iridium/iridiumskyblock/IridiumSkyblock.java b/src/main/java/com/iridium/iridiumskyblock/IridiumSkyblock.java index dd69c1565..d379b6db0 100644 --- a/src/main/java/com/iridium/iridiumskyblock/IridiumSkyblock.java +++ b/src/main/java/com/iridium/iridiumskyblock/IridiumSkyblock.java @@ -1,11 +1,8 @@ package com.iridium.iridiumskyblock; import com.comphenix.protocol.PacketType; -import com.comphenix.protocol.ProtocolLib; import com.comphenix.protocol.ProtocolLibrary; -import com.comphenix.protocol.ProtocolManager; import com.comphenix.protocol.events.ListenerPriority; -import com.comphenix.protocol.events.PacketAdapter; import com.iridium.iridiumcore.dependencies.xseries.XMaterial; import com.iridium.iridiumskyblock.configs.*; import com.iridium.iridiumskyblock.database.Island; @@ -25,7 +22,6 @@ import net.milkbowl.vault.economy.Economy; import org.bukkit.Bukkit; import org.bukkit.World; -import org.bukkit.event.Listener; import org.bukkit.generator.ChunkGenerator; import org.bukkit.plugin.PluginDescriptionFile; import org.bukkit.plugin.RegisteredServiceProvider; @@ -67,8 +63,6 @@ public class IridiumSkyblock extends IridiumTeams { private UserPlaceholderBuilder userPlaceholderBuilder; private TeamChatPlaceholderBuilder teamChatPlaceholderBuilder; - @Getter - private ProtocolManager protocolManager; private IslandManager teamManager; private UserManager userManager; private CommandManager commandManager; @@ -140,7 +134,6 @@ public void onEnable() { this.teamManager.createWorld(World.Environment.NETHER, configuration.worldName + "_nether"); this.teamManager.createWorld(World.Environment.THE_END, configuration.worldName + "_the_end"); - setProtocolManager(); this.schematicManager = new SchematicManager(); this.userManager = new UserManager(); this.commandManager = new CommandManager("iridiumskyblock"); @@ -195,6 +188,10 @@ public void registerListeners() { Bukkit.getPluginManager().registerEvents(new PlayerInteractListener(), this); Bukkit.getPluginManager().registerEvents(new EntityDamageListener(), this); if(!XMaterial.supports(15)) Bukkit.getPluginManager().registerEvents(new PortalCreateListener(), this); + + if (Bukkit.getPluginManager().isPluginEnabled("ProtocolLib")) { + new ProtocolLibPacketListener().registerListeners(); + } else if (IridiumSkyblock.getInstance().getConfiguration().fixHorizon) IridiumSkyblock.getInstance().getLogger().warning("ProtocolLib is not installed - features will be limited."); } @Override @@ -341,18 +338,6 @@ private void setMcVersion() { this.mcVersion = version; } - private void setProtocolManager() { - if (Bukkit.getPluginManager().isPluginEnabled("ProtocolLib")) { - try { - this.protocolManager = ProtocolLibrary.getProtocolManager(); - protocolManager.addPacketListener(new IridiumPacketAdapter(this, ListenerPriority.HIGH, PacketType.Play.Server.LOGIN)); - protocolManager.addPacketListener(new IridiumPacketAdapter(this, ListenerPriority.HIGH, PacketType.Play.Server.RESPAWN)); - } catch (NoClassDefFoundError ignored) { - if (configuration.fixHorizon) getLogger().warning("ProtocolLib is not installed - features will be limited."); - } - } - } - @Override public ChunkGenerator getDefaultWorldGenerator(String worldName, String id) { return this.chunkGenerator; diff --git a/src/main/java/com/iridium/iridiumskyblock/generators/FlatGenerator.java b/src/main/java/com/iridium/iridiumskyblock/generators/FlatGenerator.java index c6319a4f9..7aef53334 100644 --- a/src/main/java/com/iridium/iridiumskyblock/generators/FlatGenerator.java +++ b/src/main/java/com/iridium/iridiumskyblock/generators/FlatGenerator.java @@ -42,6 +42,7 @@ public class FlatGenerator extends ChunkGenerator { // Generate dirt layer for (int y = floorHeight - 4; y < floorHeight; y++) { + if(chunkData.getType(x, y, z) == Material.BEDROCK) continue; chunkData.setBlock(x, y, z, Objects.requireNonNull(getFlatGenerator(world.getEnvironment()).underFloor.parseMaterial()) ); diff --git a/src/main/java/com/iridium/iridiumskyblock/generators/FlatGeneratorLegacy.java b/src/main/java/com/iridium/iridiumskyblock/generators/FlatGeneratorLegacy.java index 4ef628854..0ce911bbc 100644 --- a/src/main/java/com/iridium/iridiumskyblock/generators/FlatGeneratorLegacy.java +++ b/src/main/java/com/iridium/iridiumskyblock/generators/FlatGeneratorLegacy.java @@ -44,6 +44,7 @@ public class FlatGeneratorLegacy extends ChunkGenerator { // Generate dirt layer for (int y = floorHeight - 4; y < floorHeight; y++) { + if(chunkData.getType(x, y, z) == Material.BEDROCK) continue; chunkData.setBlock(x, y, z, Objects.requireNonNull(getFlatGenerator(world.getEnvironment()).underFloor.parseMaterial()) ); @@ -126,7 +127,9 @@ && getFlatGenerator(world.getEnvironment()).floor.parseMaterial() != null) { } // Generate lakes, trees, grass, mineral deposits, etc. - if (getFlatGenerator(world.getEnvironment()).decorate) shouldGenerateDecorations(); + if (getFlatGenerator(world.getEnvironment()).decorate) { + + } } @Override @@ -134,7 +137,7 @@ public boolean canSpawn(@NotNull World world, int x, int z) { return getFlatGenerator(world.getEnvironment()).canSpawnEntities; } - private Generators.FlatGeneratorWorld getFlatGenerator(Environment environment) { + public Generators.FlatGeneratorWorld getFlatGenerator(Environment environment) { switch (environment) { case NETHER: { return IridiumSkyblock.getInstance().getGenerators().flatGenerator.nether; diff --git a/src/main/java/com/iridium/iridiumskyblock/listeners/ProtocolLibPacketListener.java b/src/main/java/com/iridium/iridiumskyblock/listeners/ProtocolLibPacketListener.java new file mode 100644 index 000000000..7d7e31cdd --- /dev/null +++ b/src/main/java/com/iridium/iridiumskyblock/listeners/ProtocolLibPacketListener.java @@ -0,0 +1,21 @@ +package com.iridium.iridiumskyblock.listeners; + +import com.comphenix.protocol.PacketType; +import com.comphenix.protocol.ProtocolLibrary; +import com.comphenix.protocol.ProtocolManager; +import com.comphenix.protocol.events.ListenerPriority; +import com.iridium.iridiumskyblock.IridiumSkyblock; +import com.iridium.iridiumskyblock.utils.ProtocolLibUtils.IridiumPacketAdapter; + +public class ProtocolLibPacketListener { + + public void registerListeners() { + try { + ProtocolManager protocolManager = ProtocolLibrary.getProtocolManager(); + protocolManager.addPacketListener(new IridiumPacketAdapter(IridiumSkyblock.getInstance(), ListenerPriority.HIGH, PacketType.Play.Server.LOGIN)); + protocolManager.addPacketListener(new IridiumPacketAdapter(IridiumSkyblock.getInstance(), ListenerPriority.HIGH, PacketType.Play.Server.RESPAWN)); + } catch (NoClassDefFoundError e) { + IridiumSkyblock.getInstance().getLogger().severe(e.getMessage()); + } + } +} diff --git a/src/main/java/com/iridium/iridiumskyblock/managers/IslandManager.java b/src/main/java/com/iridium/iridiumskyblock/managers/IslandManager.java index f03423090..5dffa0591 100644 --- a/src/main/java/com/iridium/iridiumskyblock/managers/IslandManager.java +++ b/src/main/java/com/iridium/iridiumskyblock/managers/IslandManager.java @@ -1,5 +1,6 @@ package com.iridium.iridiumskyblock.managers; +import com.iridium.iridiumcore.dependencies.nbtapi.NBT; import com.iridium.iridiumcore.dependencies.nbtapi.NBTCompound; import com.iridium.iridiumcore.dependencies.nbtapi.NBTFile; import com.iridium.iridiumcore.dependencies.nbtapi.NBTItem; @@ -404,10 +405,10 @@ public void regenerateTerrain (Island island, World world, int y, CompletableFut for (int x = pos1.getBlockX(); x <= pos2.getBlockX(); x++) { for (int z = pos1.getBlockZ(); z <= pos2.getBlockZ(); z++) { - BlockData blockA = regenWorld.getBlockData(x, y, z); + Block blockA = regenWorld.getBlockAt(x, y ,z); Block blockB = world.getBlockAt(x, y, z); - blockB.setBlockData(blockA, false); + blockB.setType(blockA.getType()); } } diff --git a/src/main/java/com/iridium/iridiumskyblock/utils/ProtocolLibUtils/IridiumPacketAdapter.java b/src/main/java/com/iridium/iridiumskyblock/utils/ProtocolLibUtils/IridiumPacketAdapter.java index a321cdf1b..8c4ba13f3 100644 --- a/src/main/java/com/iridium/iridiumskyblock/utils/ProtocolLibUtils/IridiumPacketAdapter.java +++ b/src/main/java/com/iridium/iridiumskyblock/utils/ProtocolLibUtils/IridiumPacketAdapter.java @@ -6,14 +6,13 @@ import com.comphenix.protocol.events.PacketContainer; import com.comphenix.protocol.events.PacketEvent; import com.comphenix.protocol.reflect.StructureModifier; -import com.comphenix.protocol.wrappers.PlayerInfoData; import com.iridium.iridiumskyblock.IridiumSkyblock; import org.bukkit.World; import org.bukkit.WorldType; -import org.bukkit.entity.Entity; import org.bukkit.entity.Player; import org.bukkit.plugin.Plugin; +import java.lang.reflect.Field; import java.util.List; public class IridiumPacketAdapter extends PacketAdapter { @@ -81,7 +80,7 @@ private void editPacketForHorizon(PacketEvent packetEvent, boolean fallback) { if(packetType == PacketType.Play.Server.LOGIN) flatWorldIndex = 4; if(packetType == PacketType.Play.Server.RESPAWN) flatWorldIndex = 1; - StructureModifier commonPlayerSpawnInfo = packet.getModifier(); + Field commonPlayerSpawnInfo = packet.getModifier().getField(9); int getCommonPlayerSpawnInfoIndex = 0; if(packetType == PacketType.Play.Server.LOGIN) getCommonPlayerSpawnInfoIndex = 9; @@ -93,10 +92,7 @@ private void editPacketForHorizon(PacketEvent packetEvent, boolean fallback) { IridiumSkyblock.getInstance().getLogger().info("[DEBUG] PACKET FIELDS: " + packet.getStructures().getFields()); IridiumSkyblock.getInstance().getLogger().info("[DEBUG] =+=+=+=+=+=+=+=+=+=+=+=+="); IridiumSkyblock.getInstance().getLogger().info("[DEBUG] PACKET OBJECT: " + commonPlayerSpawnInfo); - for(int i = 0; i < commonPlayerSpawnInfo.size(); i++) { - IridiumSkyblock.getInstance().getLogger().info("[DEBUG] MAPPED TO: " + commonPlayerSpawnInfo.getField(i).getName()); - } - IridiumSkyblock.getInstance().getLogger().info("[DEBUG] PRE-MUTATION VALUES: " + commonPlayerSpawnInfo.getValues()); + IridiumSkyblock.getInstance().getLogger().info("[DEBUG] PRE-MUTATION VALUES: " + commonPlayerSpawnInfo.toString()); IridiumSkyblock.getInstance().getLogger().info("[DEBUG] =+=+=+=+=+=+=+=+=+=+=+=+="); //booleans.write(flatWorldIndex, true);