Skip to content

Commit

Permalink
Add 1.18.2 module
Browse files Browse the repository at this point in the history
  • Loading branch information
Realizedd committed Apr 6, 2022
1 parent 1ea961b commit 6558a5a
Show file tree
Hide file tree
Showing 7 changed files with 58 additions and 20 deletions.
2 changes: 2 additions & 0 deletions arenaregen/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ dependencies {
implementation project(':v1_16_R3')
implementation project(':v1_17_R1')
implementation project(':v1_18_R1')
implementation project(':v1_18_R2')
}

shadowJar {
Expand All @@ -45,6 +46,7 @@ shadowJar {
include(dependency(':v1_16_R3'))
include(dependency(':v1_17_R1'))
include(dependency(':v1_18_R1'))
include(dependency(':v1_18_R2'))
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -384,9 +384,9 @@ public void run() {
for (int z = min.getBlockZ(); z <= max.getBlockZ(); z++) {
final Block block = min.getWorld().getBlockAt(x, y, z);

// if (block.getType() == Material.AIR || BlockUtil.isSurrounded(block)) {
// continue;
// }
if (block.getType() == Material.AIR || BlockUtil.isSurrounded(block)) {
continue;
}

handler.updateLighting(block);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,21 +129,6 @@ public void on(final ChunkUnloadEvent event) {
}
}

@EventHandler
public void on(final PlayerDeathEvent event) {
final Arena arena = arenaManager.get(event.getEntity());
final ResetZone zone;

if (arena == null || (zone = get(arena.getName())) == null) {
return;
}

zone.getSpawnedEntities().removeIf(entity -> {
entity.remove();
return true;
});
}

@EventHandler
public void on(final MatchEndEvent event) {
final Arena arena = event.getMatch().getArena();
Expand All @@ -152,7 +137,11 @@ public void on(final MatchEndEvent event) {
if (zone == null) {
return;
}


for (final Entity entity : zone.getSpawnedEntities()) {
entity.remove();
}

zone.getSpawnedEntities().clear();
zone.reset(null);
}
Expand Down
2 changes: 1 addition & 1 deletion arenaregen/src/main/resources/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ allow-arena-block-break: false

# Allow breaking blocks in the reset zone that is not placed by a player in match.
# default: auto
# available: [auto, fallback, v1_8_R3, v1_8_R3_paper, v1_12_R1, v1_14_R1, v1_15_R1, v1_16_R3, v1_17_R1, v1_18_R1]
# available: [auto, fallback, v1_8_R3, v1_8_R3_paper, v1_12_R1, v1_14_R1, v1_15_R1, v1_16_R3, v1_17_R1, v1_18_R1, v1_18_R2]
block-reset-handler-version: auto

# Remove dropped items in the reset zone when the match ends.
Expand Down
1 change: 1 addition & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ include 'v1_15_R1'
include 'v1_16_R3'
include 'v1_17_R1'
include 'v1_18_R1'
include 'v1_18_R2'

4 changes: 4 additions & 0 deletions v1_18_R2/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
dependencies {
implementation 'org.spigotmc:spigot:1.18.2-R0.1-SNAPSHOT'
implementation project(':nms')
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package me.realized.de.arenaregen.nms.v1_18_R1;

import me.realized.de.arenaregen.nms.NMS;
import net.minecraft.core.BlockPosition;
import net.minecraft.network.protocol.game.ClientboundLevelChunkWithLightPacket;
import net.minecraft.world.level.World;
import net.minecraft.world.level.block.state.IBlockData;
import net.minecraft.world.level.chunk.Chunk;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.craftbukkit.v1_18_R2.CraftChunk;
import org.bukkit.craftbukkit.v1_18_R2.CraftWorld;
import org.bukkit.craftbukkit.v1_18_R2.entity.CraftPlayer;
import org.bukkit.craftbukkit.v1_18_R2.util.CraftMagicNumbers;
import org.bukkit.entity.Player;

public class NMSHandler implements NMS {

@Override
public void sendChunkUpdate(final Player player, final org.bukkit.Chunk chunk) {
final Chunk nmsChunk = ((CraftChunk) chunk).getHandle();
((CraftPlayer) player).getHandle().b.a(new ClientboundLevelChunkWithLightPacket(nmsChunk, nmsChunk.q.l_(), null, null, true));
}

@Override
public void setBlockFast(final Block bukkitBlock, final Material material, final int data) {
final int x = bukkitBlock.getX(), y = bukkitBlock.getY(), z = bukkitBlock.getZ();
final BlockPosition position = new BlockPosition(x, y, z);
final Chunk chunk = ((CraftChunk) bukkitBlock.getChunk()).getHandle();
final net.minecraft.world.level.block.Block block = CraftMagicNumbers.getBlock(material);
final IBlockData blockData = block.n();
chunk.a(position, blockData, true);
}

@Override
public void updateLighting(Block bukkitBlock) {
final int x = bukkitBlock.getX(), y = bukkitBlock.getY(), z = bukkitBlock.getZ();
final BlockPosition position = new BlockPosition(x, y, z);
final World world = ((CraftWorld) bukkitBlock.getWorld()).getHandle();
world.K().n().a(position);
}
}

0 comments on commit 6558a5a

Please sign in to comment.