Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
plugins {
id 'java'
id "com.gradleup.shadow" version "9.4.1"
id "com.gradleup.shadow" version "9.5.1"
id "io.papermc.paperweight.userdev" version "${paperWeightUserDevVersion}"
id("xyz.jpenilla.run-paper") version "3.0.2" // Will use ${minecraftVersion} for the paper version
}
Expand Down Expand Up @@ -51,11 +51,17 @@ repositories {
dependencies {
paperweight.paperDevBundle "${minecraftVersion}.build.+"

compileOnly "com.sk89q.worldguard:worldguard-bukkit:${worldguardVersion}"
compileOnly("com.sk89q.worldguard:worldguard-bukkit:${worldguardVersion}") {
exclude group: 'com.google.guava', module: 'guava'
exclude group: 'com.google.code.gson', module: 'gson'
}
compileOnly "dev.lone:api-itemsadder:${itemsAdderVersion}"
compileOnly "net.luckperms:api:${luckpermsVersion}"
compileOnly "me.clip:placeholderapi:${placeholderApiVersion}"
compileOnly "com.sk89q.worldedit:worldedit-bukkit:${worldeditVersion}"
compileOnly("com.sk89q.worldedit:worldedit-bukkit:${worldeditVersion}") {
exclude group: 'com.google.guava', module: 'guava'
exclude group: 'com.google.code.gson', module: 'gson'
}
compileOnly "de.oliver:FancyNpcs:${fancyNpcsVersion}"
compileOnly "net.dmulloy2:ProtocolLib:${protocolLibVersion}"

Expand Down
12 changes: 6 additions & 6 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
minecraftVersion = 26.1.2
minecraftVersion = 26.2
paperWeightUserDevVersion = 2.0.0-beta.21

# Plugins
Expand All @@ -7,17 +7,17 @@ itemsAdderVersion = 4.0.10
luckpermsVersion = 5.5
placeholderApiVersion = 2.11.7
worldeditVersion = 7.4.0
fancyNpcsVersion = 2.9.0
fancyNpcsVersion = 2.10.0
protocolLibVersion = 5.4.0

# Dependencies
jetbrainsAnnotationsVersion = 26.1.0
revxrsalLampVersion = 4.0.0-rc.16
revxrsalLampVersion = 4.0.0-rc.17
ormVersion = 6.1
lombokVersion = 1.18.46

# Test Dependencies
slf4jVersion = 2.0.17
junitVersion = 6.0.3
mockbukkitVersion = 4.113.1
slf4jVersion = 2.1.0-alpha1
junitVersion = 6.1.1
mockbukkitVersion = 4.114.0
h2DatabaseVersion = 2.4.240
4 changes: 1 addition & 3 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.1-bin.zip
networkTimeout=10000
validateDistributionUrl=true
distributionUrl=https\://services.gradle.org/distributions/gradle-9.6.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import java.nio.file.Path;

public class PackMetadataInjector implements DatapackInjector {
private static final double[] PACK_FORMAT = new double[] {101.1, 1};
private static final double[] PACK_FORMAT = new double[] {107.1, 1};

@Override
public void inject(File rootFile) {
Expand Down
70 changes: 20 additions & 50 deletions src/main/java/fr/openmc/api/scoreboard/SternalBoardHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
import net.minecraft.network.protocol.game.*;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.server.network.ServerGamePacketListenerImpl;
import net.minecraft.world.scores.DisplaySlot;
import net.minecraft.world.scores.Team;
import net.minecraft.world.scores.*;
import net.minecraft.world.scores.criteria.ObjectiveCriteria;
import org.bukkit.ChatColor;
import org.bukkit.craftbukkit.entity.CraftPlayer;
Expand Down Expand Up @@ -64,8 +63,6 @@ public abstract class SternalBoardHandler<T> {
private static final MethodHandle SEND_PACKET;
private static final SternalReflection.PacketConstructor PACKET_SB_OBJ;
private static final SternalReflection.PacketConstructor PACKET_SB_DISPLAY_OBJ;
private static final SternalReflection.PacketConstructor PACKET_SB_TEAM;
private static final SternalReflection.PacketConstructor PACKET_SB_SERIALIZABLE_TEAM;
private static final MethodHandle PACKET_SB_SET_SCORE;
private static final MethodHandle PACKET_SB_RESET_SCORE;
private static final MethodHandle FIXED_NUMBER_FORMAT;
Expand All @@ -79,12 +76,6 @@ public abstract class SternalBoardHandler<T> {

PACKET_SB_OBJ = SternalReflection.findPacketConstructor(ClientboundSetObjectivePacket.class, lookup);
PACKET_SB_DISPLAY_OBJ = SternalReflection.findPacketConstructor(ClientboundSetDisplayObjectivePacket.class, lookup);
PACKET_SB_TEAM = SternalReflection.findPacketConstructor(ClientboundSetPlayerTeamPacket.class, lookup);

Class<?> sbTeamClass = SternalReflection.innerClass(ClientboundSetPlayerTeamPacket.class,
innerClass -> !innerClass.isEnum());
PACKET_SB_SERIALIZABLE_TEAM = sbTeamClass != null ?
SternalReflection.findPacketConstructor(sbTeamClass, lookup) : null;

PACKET_SB_SET_SCORE = lookup.findConstructor(ClientboundSetScorePacket.class,
MethodType.methodType(void.class, String.class, String.class, int.class,
Expand All @@ -98,7 +89,7 @@ public abstract class SternalBoardHandler<T> {

for (Class<?> clazz : Arrays.asList(ClientboundSetObjectivePacket.class,
ClientboundSetDisplayObjectivePacket.class, ClientboundSetScorePacket.class,
ClientboundSetPlayerTeamPacket.class, sbTeamClass)) {
ClientboundSetPlayerTeamPacket.class)) {
if (clazz == null) continue;

Field[] fields = Arrays.stream(clazz.getDeclaredFields())
Expand Down Expand Up @@ -414,52 +405,31 @@ protected void sendTeamPacket(int score, TeamMode mode, T prefix, T suffix) thro
throw new UnsupportedOperationException();
}

Object packet = PACKET_SB_TEAM.invoke();

setField(packet, String.class, this.id + ':' + score);
setField(packet, int.class, mode.ordinal(), 0);
PlayerTeam team = createPlayerTeam(score, prefix, suffix);

if (mode == TeamMode.REMOVE) {
sendPacket(packet);
sendPacket(ClientboundSetPlayerTeamPacket.createRemovePacket(team));
return;
}

Object team = PACKET_SB_SERIALIZABLE_TEAM.invoke();

// Set component fields
setComponentField(team, null, 0); // displayName
setComponentField(team, prefix, 1); // prefix
setComponentField(team, suffix, 2); // suffix

// Set String fields (nametagVisibility and collisionRule)
setField(team, String.class, "always", 0);
setField(team, String.class, "always", 1);

// Set enum fields - only set each once (not twice)
setField(team, Team.Visibility.class, Team.Visibility.ALWAYS, 0);
setField(team, Team.CollisionRule.class, Team.CollisionRule.ALWAYS, 0);

// Try to set NamedTextColor if it exists
try {
setField(team, net.minecraft.ChatFormatting.class, net.minecraft.ChatFormatting.WHITE, 0);
} catch (Exception ignored) {
// Field might not exist or be different type
}

// Try to set int flags if they exist
try {
setField(team, int.class, 0x00, 0);
} catch (Exception ignored) {
// Field might not exist
}
sendPacket(ClientboundSetPlayerTeamPacket.createAddOrModifyPacket(team,
mode == TeamMode.CREATE));
}

setField(packet, Optional.class, Optional.of(team));
private PlayerTeam createPlayerTeam(int score, T prefix, T suffix) throws Throwable {
Scoreboard scoreboard = new Scoreboard();
PlayerTeam team = scoreboard.addPlayerTeam(this.id + ':' + score);

if (mode == TeamMode.CREATE) {
setField(packet, Collection.class, Collections.singletonList(COLOR_CODES[score]));
}
team.setDisplayName((net.minecraft.network.chat.Component) toMinecraftComponent(null));
team.setPlayerPrefix((net.minecraft.network.chat.Component) toMinecraftComponent(prefix));
team.setPlayerSuffix((net.minecraft.network.chat.Component) toMinecraftComponent(suffix));
team.setNameTagVisibility(Team.Visibility.ALWAYS);
team.setCollisionRule(Team.CollisionRule.ALWAYS);
team.setColor(Optional.of(TeamColor.WHITE));
team.unpackOptions((byte) 0x00);
scoreboard.addPlayerToTeam(COLOR_CODES[score], team);

sendPacket(packet);
return team;
}

private void sendPacket(Object packet) throws Throwable {
Expand Down Expand Up @@ -507,4 +477,4 @@ public enum TeamMode {
public enum ScoreboardAction {
CHANGE, REMOVE
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
public class ResourcePacksGenerator {

// https://minecraft.wiki/w/Pack_format
private static final String FORMAT_VERSION = "84";
private static final String FORMAT_VERSION = "88";

/**
* Generate the base structure of a resource pack in the plugin's data folder, with the given name.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package fr.openmc.core.features.city.listeners.protections;

import com.destroystokyo.paper.event.entity.EntityKnockbackByEntityEvent;
import fr.openmc.core.features.city.ProtectionsManager;
import org.bukkit.entity.Enderman;
import org.bukkit.entity.Entity;
Expand Down Expand Up @@ -39,4 +40,10 @@ public void onEntityChangeBlock(EntityChangeBlockEvent event) {
if (!(event.getEntity() instanceof Enderman enderman)) return;
ProtectionsManager.verify(enderman, event, enderman.getLocation());
}

@EventHandler(ignoreCancelled = true)
public void onEntityKnockbackByEntity(EntityKnockbackByEntityEvent event) {
if (!(event.getHitBy() instanceof Player player)) return;
ProtectionsManager.verify(player, event, event.getEntity().getLocation());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ public class ExplodeProtection implements Listener {
EntityType.WITHER,
EntityType.END_CRYSTAL,
EntityType.TNT_MINECART,
EntityType.DRAGON_FIREBALL
EntityType.DRAGON_FIREBALL,
EntityType.SULFUR_CUBE
);

@EventHandler(ignoreCancelled = true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.entity.Entity;
import org.bukkit.entity.ItemFrame;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
Expand All @@ -22,6 +22,9 @@
import org.bukkit.inventory.EquipmentSlot;
import org.bukkit.inventory.ItemStack;

import java.util.HashSet;
import java.util.Set;

public class InteractProtection implements Listener {

@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
Expand Down Expand Up @@ -73,13 +76,19 @@ public void onInteract(PlayerInteractEvent event) {
ProtectionsManager.verify(player, event, location);
}

private final Set<EntityType> INTERACTION_REFUSED = new HashSet<>(Set.of(
EntityType.ITEM_FRAME,
EntityType.GLOW_ITEM_FRAME,
EntityType.SULFUR_CUBE
));

@EventHandler
public void onInteractAtEntity(PlayerInteractAtEntityEvent event) {
if (event.getHand() != EquipmentSlot.HAND) return;

Entity rightClicked = event.getRightClicked();
if (rightClicked instanceof Player) return;
if (!(rightClicked instanceof ItemFrame)) return;
if (!INTERACTION_REFUSED.contains(rightClicked.getType())) return;

if (MascotUtils.canBeAMascot(rightClicked)) return;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import fr.openmc.core.utils.nms.SkullNMS;
import fr.openmc.core.utils.nms.entity.*;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.EntityTypes;
import net.minecraft.world.entity.ai.attributes.AttributeInstance;
import net.minecraft.world.entity.ai.attributes.Attributes;
import net.minecraft.world.entity.decoration.ArmorStand;
Expand Down Expand Up @@ -102,7 +102,7 @@ public void run() {
}

private static void sendGhostTo(Player receiver, Player ghostOf, int entityId, ArmorStand stand) {
EntitySpawnNMS.sendSpawnPacket(receiver, EntityType.ARMOR_STAND, entityId, stand.getUUID(), ghostOf.getLocation());
EntitySpawnNMS.sendSpawnPacket(receiver, EntityTypes.ARMOR_STAND, entityId, stand.getUUID(), ghostOf.getLocation());
EntitySpawnNMS.sendMetaDataEntity(receiver, stand);
EntityEquipmentNMS.sendHelmetPacket(receiver, entityId, SkullNMS.getPlayerSkullNMS(ghostOf));
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package fr.openmc.core.features.events.contents.dailyevents.contents.miraculousfishing.listeners;

import edu.umd.cs.findbugs.annotations.Nullable;
import fr.openmc.core.OMCRegistry;
import fr.openmc.core.registry.items.CustomItem;
import fr.openmc.core.utils.text.messages.TranslationManager;
Expand All @@ -14,6 +13,7 @@
import org.bukkit.inventory.ItemStack;
import org.bukkit.util.Vector;

import javax.annotation.Nullable;
import java.util.Optional;

/**
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/fr/openmc/core/utils/nms/PlayerBiomeNMS.java
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ public static void replaceBiomes(
public static LevelChunk getFakeChunk(LevelChunk original, ServerLevel level, Holder<Biome> biome) {
LevelChunk fakeChunk = new LevelChunk(level, original.getPos());

Strategy<Holder<Biome>> idMap = Strategy.createForBiomes(original.level.registryAccess().lookupOrThrow(Registries.BIOME).asHolderIdMap());
Strategy<Holder<Biome>> idMap = Strategy.createForBiomes(original.getLevel().registryAccess().lookupOrThrow(Registries.BIOME).asHolderIdMap());

LevelChunkSection[] originalSections = original.getSections();
LevelChunkSection[] fakeSections = fakeChunk.getSections();
Expand Down Expand Up @@ -172,10 +172,10 @@ private static LevelChunk getFakeChunkWithMapping(
LevelChunk original,
String keyMappedBiome,
Function<Identifier, Identifier> identifierModifier) {
LevelChunk fake = new LevelChunk(original.level, original.getPos());
LevelChunk fake = new LevelChunk(original.getLevel(), original.getPos());

Registry<Biome> registry = original.level.registryAccess().lookupOrThrow(Registries.BIOME);
Strategy<Holder<Biome>> idMap = Strategy.createForBiomes(original.level.registryAccess().lookupOrThrow(Registries.BIOME).asHolderIdMap());
Registry<Biome> registry = original.getLevel().registryAccess().lookupOrThrow(Registries.BIOME);
Strategy<Holder<Biome>> idMap = Strategy.createForBiomes(original.getLevel().registryAccess().lookupOrThrow(Registries.BIOME).asHolderIdMap());
LevelChunkSection[] originalSections = original.getSections();
LevelChunkSection[] fakeSections = fake.getSections();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,7 @@
import net.minecraft.network.syncher.SynchedEntityData;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.util.Brightness;
import net.minecraft.world.entity.Display;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.PositionMoveRotation;
import net.minecraft.world.entity.*;
import net.minecraft.world.phys.Vec3;
import org.bukkit.Bukkit;
import org.bukkit.Location;
Expand All @@ -39,7 +36,7 @@ public class TextDisplay {
public TextDisplay(Component text, Location location, Vector3f scale) {
this.location = location;

textDisplay = new Display.TextDisplay(EntityType.TEXT_DISPLAY, ((CraftWorld) location.getWorld()).getHandle());
textDisplay = new Display.TextDisplay(EntityTypes.TEXT_DISPLAY, ((CraftWorld) location.getWorld()).getHandle());
textDisplay.setPos(location.getX(), location.getY(), location.getZ());
textDisplay.setRot(location.getYaw(), location.getPitch());
textDisplay.setBillboardConstraints(Display.BillboardConstraints.CENTER);
Expand Down Expand Up @@ -72,7 +69,7 @@ private void addViewer(Player viewer) {
textDisplay.getZ(),
textDisplay.getXRot(),
textDisplay.getYRot(),
EntityType.TEXT_DISPLAY,
EntityTypes.TEXT_DISPLAY,
0,
Vec3.ZERO,
0
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,15 @@
"state": {
"Name": "blue_ice"
}
},
"can_place_feature": {
"type": "minecraft:true"
},
"can_replace_with_air_or_fluid": {
"type": "minecraft:true"
},
"can_replace_with_barrier": {
"type": "minecraft:true"
}
}
}
6 changes: 3 additions & 3 deletions src/main/resources/datapacks/omc_dream/pack.mcmeta
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"pack": {
"description": "Le Pack de données des Rêves d'OpenMC",
"pack_format": 101,
"min_format": 101,
"max_format": 101
"pack_format": 107.1,
"min_format": 107.1,
"max_format": 107.1
}
}
Loading