send help ._.

This commit is contained in:
2024-11-27 00:26:06 +01:00
parent d6202f9596
commit 510aec048b
20 changed files with 266 additions and 56 deletions

View File

@ -0,0 +1,17 @@
plugins {
steamwar.java
}
java {
sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21
}
dependencies {
compileOnly(project(":BauSystem:BauSystem_Main", "default"))
compileOnly(project(":SpigotCore", "default"))
compileOnly(libs.paperapi21)
compileOnly(libs.nms21)
}

View File

@ -0,0 +1,151 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2024 SteamWar.de-Serverteam
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.bausystem.utils;
import com.comphenix.tinyprotocol.Reflection;
import de.steamwar.bausystem.features.util.NoClipCommand;
import net.minecraft.core.Holder;
import net.minecraft.core.component.DataComponents;
import net.minecraft.core.particles.ParticleParam;
import net.minecraft.nbt.NBTBase;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.network.protocol.game.PacketPlayInSetCreativeSlot;
import net.minecraft.network.protocol.game.PacketPlayOutExplosion;
import net.minecraft.network.protocol.game.PacketPlayOutGameStateChange;
import net.minecraft.world.item.component.CustomData;
import net.minecraft.world.level.EnumGamemode;
import net.minecraft.world.level.Explosion;
import org.bukkit.GameMode;
import org.bukkit.Material;
import org.bukkit.craftbukkit.v1_21_R1.entity.CraftPlayer;
import org.bukkit.craftbukkit.v1_21_R1.inventory.CraftItemStack;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import java.util.List;
public class NMSWrapper21 implements NMSWrapper {
@Override
public void setInternalGameMode(Player player, GameMode gameMode) {
((CraftPlayer) player).getHandle().e.a(EnumGamemode.a(gameMode.getValue()));
}
@Override
public void setSlotToItemStack(Player player, Object o) {
PacketPlayInSetCreativeSlot packetPlayInSetCreativeSlot = (PacketPlayInSetCreativeSlot) o;
int index = packetPlayInSetCreativeSlot.b();
if (index >= 36 && index <= 44) {
index -= 36;
} else if (index > 44) {
index -= 5;
} else if (index <= 8) {
index = index - 8 + 36;
}
player.getInventory().setItem(index, CraftItemStack.asBukkitCopy(packetPlayInSetCreativeSlot.e()));
if (index < 9) player.getInventory().setHeldItemSlot(index);
player.updateInventory();
}
private static final Reflection.FieldAccessor<PacketPlayOutGameStateChange.a> gameStateChangeReason = Reflection.getField(NoClipCommand.gameStateChange, PacketPlayOutGameStateChange.a.class, 12);
@Override
public void setGameStateChangeReason(Object packet) {
gameStateChangeReason.set(packet, PacketPlayOutGameStateChange.d);
}
@Override
public void setPlayerBuildAbilities(Player player) {
((CraftPlayer) player).getHandle().fZ().d = true;
((CraftPlayer) player).getHandle().fZ().e = true;
}
@Override
public Material pathMaterial() {
return Material.DIRT_PATH;
}
private static final int threshold = 2048;
@Override
public boolean checkItemStack(ItemStack item) {
net.minecraft.world.item.ItemStack nmsItem = CraftItemStack.asNMSCopy(item);
NBTTagCompound tag = nmsItem.a(DataComponents.b, CustomData.a).c();
if (tag.e("BlockEntityTag")) {
NBTTagCompound blockTag = tag.p("BlockEntityTag");
if (blockTag.e("Items")) {
return drillDown(blockTag.c("Items", 10), 0, 0) > threshold;
}
}
return false;
}
private int drillDown(NBTTagList items, int layer, int start) {
if (layer > 2) return start + threshold;
int invalid = start;
for (NBTBase nbtBase : items) {
if (!(nbtBase instanceof NBTTagCompound slot))
continue;
if (slot.e("tag")) {
invalid += slot.f("Count");
NBTTagCompound iTag = slot.p("tag");
if (iTag.e("BlockEntityTag")) {
NBTTagCompound blockTag = iTag.p("BlockEntityTag");
if (blockTag.e("Items")) {
invalid = drillDown(blockTag.c("Items", 10), layer + 1, invalid);
}
}
}
if (invalid > threshold)
break;
}
return invalid;
}
private final Class<?> explosionPacket = Reflection.getClass("{nms.network.protocol.game}.PacketPlayOutExplosion");
private final Reflection.FieldAccessor<Double> a = Reflection.getField(explosionPacket, double.class, 0);
private final Reflection.FieldAccessor<Double> b = Reflection.getField(explosionPacket, double.class, 1);
private final Reflection.FieldAccessor<Double> c = Reflection.getField(explosionPacket, double.class, 2);
private final Reflection.FieldAccessor<Float> d = Reflection.getField(explosionPacket, float.class, 0);
private final Reflection.FieldAccessor<List> e = Reflection.getField(explosionPacket, List.class, 0);
private final Reflection.FieldAccessor<Explosion.Effect> f = Reflection.getField(explosionPacket, Explosion.Effect.class, 0);
private final Reflection.FieldAccessor<ParticleParam> g = Reflection.getField(explosionPacket, ParticleParam.class, 0);
private final Reflection.FieldAccessor<ParticleParam> h = Reflection.getField(explosionPacket, ParticleParam.class, 1);
private final Reflection.FieldAccessor<Holder> i = Reflection.getField(explosionPacket, Holder.class, 0);
@Override
public Object resetExplosionKnockback(Object packet) {
PacketPlayOutExplosion packetPlayOutExplosion = (PacketPlayOutExplosion) packet;
return new PacketPlayOutExplosion(
a.get(packetPlayOutExplosion),
b.get(packetPlayOutExplosion),
c.get(packetPlayOutExplosion),
d.get(packetPlayOutExplosion),
e.get(packetPlayOutExplosion),
null,
f.get(packetPlayOutExplosion),
g.get(packetPlayOutExplosion),
h.get(packetPlayOutExplosion),
i.get(packetPlayOutExplosion)
);
}
}

View File

@ -20,6 +20,7 @@
package de.steamwar.bausystem.features.loadtimer; package de.steamwar.bausystem.features.loadtimer;
import de.steamwar.bausystem.region.Region; import de.steamwar.bausystem.region.Region;
import de.steamwar.core.TrickyTrialsWrapper;
import de.steamwar.linkage.Linked; import de.steamwar.linkage.Linked;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.entity.EntityType; import org.bukkit.entity.EntityType;
@ -57,7 +58,7 @@ public class LoadtimerListener implements Listener {
@EventHandler @EventHandler
public void onEntitySpawn(EntitySpawnEvent event) { public void onEntitySpawn(EntitySpawnEvent event) {
if (!getTimers().isEmpty() && event.getEntityType() == EntityType.PRIMED_TNT) { if (!getTimers().isEmpty() && event.getEntityType() == TrickyTrialsWrapper.impl.getTntEntityType()) {
Region r = Region.getRegion(event.getLocation()); Region r = Region.getRegion(event.getLocation());
if (hasTimer(r)) { if (hasTimer(r)) {
getTimer(r).onTntSpawn(); getTimer(r).onTntSpawn();
@ -67,7 +68,7 @@ public class LoadtimerListener implements Listener {
@EventHandler @EventHandler
public void onEntityExplode(EntityExplodeEvent event) { public void onEntityExplode(EntityExplodeEvent event) {
if (!getTimers().isEmpty() && event.getEntityType() == EntityType.PRIMED_TNT) { if (!getTimers().isEmpty() && event.getEntityType() == TrickyTrialsWrapper.impl.getTntEntityType()) {
Region r = Region.getRegion(event.getLocation()); Region r = Region.getRegion(event.getLocation());
if (hasTimer(r)) { if (hasTimer(r)) {
getTimer(r).onTntExplode(event); getTimer(r).onTntExplode(event);

View File

@ -6,6 +6,7 @@ import de.steamwar.bausystem.region.flags.Flag;
import de.steamwar.bausystem.region.flags.flagvalues.FreezeMode; import de.steamwar.bausystem.region.flags.flagvalues.FreezeMode;
import de.steamwar.bausystem.utils.ScoreboardElement; import de.steamwar.bausystem.utils.ScoreboardElement;
import de.steamwar.core.Core; import de.steamwar.core.Core;
import de.steamwar.core.TrickyTrialsWrapper;
import de.steamwar.linkage.Linked; import de.steamwar.linkage.Linked;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Material; import org.bukkit.Material;
@ -31,7 +32,7 @@ public class FreezeListener implements Listener, ScoreboardElement {
return; return;
} }
e.setCancelled(true); e.setCancelled(true);
if (e.getEntityType() == EntityType.PRIMED_TNT) { if (e.getEntityType() == TrickyTrialsWrapper.impl.getTntEntityType()) {
Bukkit.getScheduler().runTaskLater(BauSystem.getInstance(), () -> { Bukkit.getScheduler().runTaskLater(BauSystem.getInstance(), () -> {
e.getLocation().getBlock().setType(Material.TNT, false); e.getLocation().getBlock().setType(Material.TNT, false);
}, 1L); }, 1L);

View File

@ -28,6 +28,7 @@ import de.steamwar.bausystem.features.tpslimit.TPSUtils;
import de.steamwar.bausystem.region.Region; import de.steamwar.bausystem.region.Region;
import de.steamwar.bausystem.region.utils.RegionExtensionType; import de.steamwar.bausystem.region.utils.RegionExtensionType;
import de.steamwar.bausystem.region.utils.RegionType; import de.steamwar.bausystem.region.utils.RegionType;
import de.steamwar.core.TrickyTrialsWrapper;
import de.steamwar.linkage.Linked; import de.steamwar.linkage.Linked;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Material; import org.bukkit.Material;
@ -161,7 +162,7 @@ public class EventListener implements Listener {
@EventHandler(priority = EventPriority.LOWEST) @EventHandler(priority = EventPriority.LOWEST)
public void onEntityExplode(EntityExplodeEvent event) { public void onEntityExplode(EntityExplodeEvent event) {
if (event.getEntityType() != EntityType.PRIMED_TNT) { if (event.getEntityType() != TrickyTrialsWrapper.impl.getTntEntityType()) {
return; return;
} }
Region tntRegion = Region.getRegion(event.getLocation()); Region tntRegion = Region.getRegion(event.getLocation());

View File

@ -32,4 +32,5 @@ dependencies {
implementation(project(":BauSystem:BauSystem_18")) implementation(project(":BauSystem:BauSystem_18"))
implementation(project(":BauSystem:BauSystem_19")) implementation(project(":BauSystem:BauSystem_19"))
implementation(project(":BauSystem:BauSystem_20")) implementation(project(":BauSystem:BauSystem_20"))
implementation(project(":BauSystem:BauSystem_21"))
} }

View File

@ -19,6 +19,7 @@
package de.steamwar.fightsystem.event; package de.steamwar.fightsystem.event;
import de.steamwar.core.TrickyTrialsWrapper;
import de.steamwar.fightsystem.Config; import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.FightSystem; import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.countdown.Countdown; import de.steamwar.fightsystem.countdown.Countdown;
@ -97,13 +98,13 @@ public class HellsBells {
currentDropping = Bukkit.getScheduler().runTaskTimer(FightSystem.getPlugin(), () -> { currentDropping = Bukkit.getScheduler().runTaskTimer(FightSystem.getPlugin(), () -> {
for (int w = 0; w < width; w++) { for (int w = 0; w < width; w++) {
if (direction.isNorthOrWest()) { if (direction.isNorthOrWest()) {
Config.world.spawnEntity(redStart.addAndToLocation(Config.world, -1 * (direction.dx * length.get() + w * direction.other().dx), 0, -1 * (direction.dz * length.get() + w * direction.other().dz)), EntityType.PRIMED_TNT); Config.world.spawnEntity(redStart.addAndToLocation(Config.world, -1 * (direction.dx * length.get() + w * direction.other().dx), 0, -1 * (direction.dz * length.get() + w * direction.other().dz)), TrickyTrialsWrapper.impl.getTntEntityType());
Config.world.spawnEntity(blueStart.addAndToLocation(Config.world, direction.dx * length.get() + w * direction.other().dx, 0, direction.dz * length.get() + w * direction.other().dz), EntityType.PRIMED_TNT); Config.world.spawnEntity(blueStart.addAndToLocation(Config.world, direction.dx * length.get() + w * direction.other().dx, 0, direction.dz * length.get() + w * direction.other().dz), TrickyTrialsWrapper.impl.getTntEntityType());
} else { } else {
Config.world.spawnEntity(redStart.addAndToLocation(Config.world, direction.dx * length.get() + w * direction.other().dx, 0, direction.dz * length.get() + w * direction.other().dz), EntityType.PRIMED_TNT); Config.world.spawnEntity(redStart.addAndToLocation(Config.world, direction.dx * length.get() + w * direction.other().dx, 0, direction.dz * length.get() + w * direction.other().dz), TrickyTrialsWrapper.impl.getTntEntityType());
Config.world.spawnEntity(blueStart.addAndToLocation(Config.world, -1 * (direction.dx * length.get() + w * direction.other().dx), 0, -1 * (direction.dz * length.get() + w * direction.other().dz)), EntityType.PRIMED_TNT); Config.world.spawnEntity(blueStart.addAndToLocation(Config.world, -1 * (direction.dx * length.get() + w * direction.other().dx), 0, -1 * (direction.dz * length.get() + w * direction.other().dz)), TrickyTrialsWrapper.impl.getTntEntityType());
} }
} }
if (length.addAndGet(-2) <= 0) { if (length.addAndGet(-2) <= 0) {

View File

@ -21,6 +21,7 @@ package de.steamwar.fightsystem.listener;
import com.comphenix.tinyprotocol.Reflection; import com.comphenix.tinyprotocol.Reflection;
import com.comphenix.tinyprotocol.TinyProtocol; import com.comphenix.tinyprotocol.TinyProtocol;
import de.steamwar.core.TrickyTrialsWrapper;
import de.steamwar.fightsystem.ArenaMode; import de.steamwar.fightsystem.ArenaMode;
import de.steamwar.fightsystem.FightSystem; import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.events.TeamDeathEvent; import de.steamwar.fightsystem.events.TeamDeathEvent;
@ -221,7 +222,7 @@ public class Recording implements Listener {
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void onTNTSpawn(EntitySpawnEvent e){ public void onTNTSpawn(EntitySpawnEvent e){
if(e.getEntityType() != EntityType.PRIMED_TNT) if(e.getEntityType() != TrickyTrialsWrapper.impl.getTntEntityType())
return; return;
GlobalRecorder.getInstance().tntSpawn(e.getEntity()); GlobalRecorder.getInstance().tntSpawn(e.getEntity());
@ -229,7 +230,7 @@ public class Recording implements Listener {
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void onExplosion(EntityExplodeEvent e){ public void onExplosion(EntityExplodeEvent e){
if(e.getEntityType() != EntityType.PRIMED_TNT) if(e.getEntityType() != TrickyTrialsWrapper.impl.getTntEntityType())
return; return;
Location loc = e.getLocation(); Location loc = e.getLocation();

View File

@ -19,6 +19,7 @@
package de.steamwar.fightsystem.listener; package de.steamwar.fightsystem.listener;
import de.steamwar.core.TrickyTrialsWrapper;
import de.steamwar.fightsystem.ArenaMode; import de.steamwar.fightsystem.ArenaMode;
import de.steamwar.fightsystem.Config; import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.fight.Fight; import de.steamwar.fightsystem.fight.Fight;
@ -56,7 +57,7 @@ public class WaterRemover implements Listener {
@EventHandler @EventHandler
public void handleEntitySpawn(EntitySpawnEvent event) { public void handleEntitySpawn(EntitySpawnEvent event) {
if(event.getEntityType() != EntityType.PRIMED_TNT) if(event.getEntityType() != TrickyTrialsWrapper.impl.getTntEntityType())
return; return;
Location location = event.getLocation(); Location location = event.getLocation();

View File

@ -21,6 +21,7 @@ package de.steamwar.fightsystem.record;
import com.sk89q.worldedit.extent.clipboard.Clipboard; import com.sk89q.worldedit.extent.clipboard.Clipboard;
import de.steamwar.core.Core; import de.steamwar.core.Core;
import de.steamwar.core.TrickyTrialsWrapper;
import de.steamwar.entity.REntity; import de.steamwar.entity.REntity;
import de.steamwar.entity.REntityServer; import de.steamwar.entity.REntityServer;
import de.steamwar.entity.RPlayer; import de.steamwar.entity.RPlayer;
@ -298,7 +299,7 @@ public class PacketProcessor implements Listener {
private void tntSpawn() throws IOException { private void tntSpawn() throws IOException {
int entityId = source.readInt(); int entityId = source.readInt();
execSync(() -> addREntity(entityId, new REntity(entityServer, EntityType.PRIMED_TNT, Config.SpecSpawn))); execSync(() -> addREntity(entityId, new REntity(entityServer, TrickyTrialsWrapper.impl.getTntEntityType(), Config.SpecSpawn)));
} }
private void entityVelocity() throws IOException { private void entityVelocity() throws IOException {

View File

@ -19,6 +19,7 @@
package de.steamwar.fightsystem.winconditions; package de.steamwar.fightsystem.winconditions;
import de.steamwar.core.TrickyTrialsWrapper;
import de.steamwar.fightsystem.countdown.Countdown; import de.steamwar.fightsystem.countdown.Countdown;
import de.steamwar.fightsystem.fight.Fight; import de.steamwar.fightsystem.fight.Fight;
import de.steamwar.fightsystem.fight.FightTeam; import de.steamwar.fightsystem.fight.FightTeam;
@ -70,7 +71,7 @@ public class WinconditionTimeTechKO extends Wincondition implements Listener {
@EventHandler @EventHandler
public void onSpawn(EntitySpawnEvent e) { public void onSpawn(EntitySpawnEvent e) {
if(e.getEntityType() != EntityType.PRIMED_TNT) if(e.getEntityType() != TrickyTrialsWrapper.impl.getTntEntityType())
return; return;
Location location = e.getLocation(); Location location = e.getLocation();
@ -84,7 +85,7 @@ public class WinconditionTimeTechKO extends Wincondition implements Listener {
@EventHandler @EventHandler
public void onExplode(EntityExplodeEvent e) { public void onExplode(EntityExplodeEvent e) {
if(e.getEntityType() != EntityType.PRIMED_TNT) if(e.getEntityType() != TrickyTrialsWrapper.impl.getTntEntityType())
return; return;
FightTeam spawn = spawnLocations.remove(e.getEntity().getEntityId()); FightTeam spawn = spawnLocations.remove(e.getEntity().getEntityId());

View File

@ -232,9 +232,21 @@ public class FlatteningWrapper14 implements FlatteningWrapper.IFlatteningWrapper
scoreboardName.set(packet, ChatWrapper.impl.stringToChatComponent(title)); scoreboardName.set(packet, ChatWrapper.impl.stringToChatComponent(title));
} }
private static final Class<?> scoreActionEnum = Reflection.getClass("{nms.server}.ScoreboardServer$Action"); private static final Class<?> scoreActionEnum;
private static final Reflection.FieldAccessor<?> scoreAction = Reflection.getField(FlatteningWrapper.scoreboardScore, scoreActionEnum, 0); private static final Reflection.FieldAccessor<?> scoreAction;
private static final Object scoreActionChange = scoreActionEnum.getEnumConstants()[0]; private static final Object scoreActionChange;
static {
if (Core.getVersion() < 21) {
scoreActionEnum = Reflection.getClass("{nms.server}.ScoreboardServer$Action");
scoreAction = Reflection.getField(FlatteningWrapper.scoreboardScore, scoreActionEnum, 0);
scoreActionChange = scoreActionEnum.getEnumConstants()[0];
} else {
scoreActionEnum = null;
scoreAction = null;
scoreActionChange = null;
}
}
@Override @Override
public void setScoreAction(Object packet) { public void setScoreAction(Object packet) {

View File

@ -30,4 +30,10 @@ dependencies {
attribute(TargetJvmVersion.TARGET_JVM_VERSION_ATTRIBUTE, 21) attribute(TargetJvmVersion.TARGET_JVM_VERSION_ATTRIBUTE, 21)
} }
} }
compileOnly(libs.nms21) {
attributes {
// Very Hacky, but it works
attribute(TargetJvmVersion.TARGET_JVM_VERSION_ATTRIBUTE, 21)
}
}
} }

View File

@ -17,22 +17,19 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
package de.steamwar.inventory; package de.steamwar.core;
import org.bukkit.enchantments.Enchantment; import org.bukkit.enchantments.Enchantment;
import org.bukkit.inventory.ItemFlag; import org.bukkit.entity.EntityType;
import java.util.Collection; public class TrickyTrialsWrapper21 implements TrickyTrialsWrapper {
import java.util.EnumSet;
public class SWItem21 implements SWItem.ISWItem {
@Override @Override
public Collection<ItemFlag> getHideFlags() { public EntityType getTntEntityType() {
return EnumSet.allOf(ItemFlag.class); return EntityType.TNT;
} }
@Override @Override
public Enchantment getDurabilityEnchantment() { public Enchantment getUnbreakingEnchantment() {
return Enchantment.UNBREAKING; return Enchantment.UNBREAKING;
} }
} }

View File

@ -96,7 +96,7 @@ public class FlatteningWrapper8 implements FlatteningWrapper.IFlatteningWrapper
private static final Reflection.FieldAccessor<Integer> spawnLivingType = Reflection.getField(ProtocolWrapper.spawnLivingPacket, int.class, 1); private static final Reflection.FieldAccessor<Integer> spawnLivingType = Reflection.getField(ProtocolWrapper.spawnLivingPacket, int.class, 1);
private static final Map<EntityType, Object> types = new HashMap<>(); private static final Map<EntityType, Object> types = new HashMap<>();
static { static {
types.put(EntityType.PRIMED_TNT, 50); types.put(TrickyTrialsWrapper.impl.getTntEntityType(), 50);
types.put(EntityType.ARMOR_STAND, 30); types.put(EntityType.ARMOR_STAND, 30);
types.put(EntityType.ARROW, 60); types.put(EntityType.ARROW, 60);
types.put(EntityType.FIREBALL, 63); types.put(EntityType.FIREBALL, 63);

View File

@ -17,29 +17,19 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
package de.steamwar.inventory; package de.steamwar.core;
import org.bukkit.enchantments.Enchantment; import org.bukkit.enchantments.Enchantment;
import org.bukkit.inventory.ItemFlag; import org.bukkit.entity.EntityType;
import java.util.Collection; public class TrickyTrialsWrapper8 implements TrickyTrialsWrapper {
import java.util.EnumSet;
public class SWItem8 implements SWItem.ISWItem {
@Override @Override
public Collection<ItemFlag> getHideFlags() { public EntityType getTntEntityType() {
return EnumSet.of( return EntityType.PRIMED_TNT;
ItemFlag.HIDE_ATTRIBUTES,
ItemFlag.HIDE_DESTROYS,
ItemFlag.HIDE_UNBREAKABLE,
ItemFlag.HIDE_ENCHANTS,
ItemFlag.HIDE_PLACED_ON,
ItemFlag.HIDE_POTION_EFFECTS
);
} }
@Override @Override
public Enchantment getDurabilityEnchantment() { public Enchantment getUnbreakingEnchantment() {
return Enchantment.DURABILITY; return Enchantment.DURABILITY;
} }
} }

View File

@ -0,0 +1,31 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2024 SteamWar.de-Serverteam
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.core;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.EntityType;
public interface TrickyTrialsWrapper {
TrickyTrialsWrapper impl = VersionDependent.getVersionImpl(Core.getInstance());
EntityType getTntEntityType();
Enchantment getUnbreakingEnchantment();
}

View File

@ -23,6 +23,7 @@ import com.google.gson.JsonArray;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
import de.steamwar.core.Core; import de.steamwar.core.Core;
import de.steamwar.core.FlatteningWrapper; import de.steamwar.core.FlatteningWrapper;
import de.steamwar.core.TrickyTrialsWrapper;
import de.steamwar.core.VersionDependent; import de.steamwar.core.VersionDependent;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.OfflinePlayer; import org.bukkit.OfflinePlayer;
@ -33,12 +34,11 @@ import org.bukkit.inventory.meta.ItemMeta;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.EnumSet;
import java.util.List; import java.util.List;
public class SWItem { public class SWItem {
private static final ISWItem impl = VersionDependent.getVersionImpl(Core.getInstance());
private ItemStack itemStack; private ItemStack itemStack;
private ItemMeta itemMeta; private ItemMeta itemMeta;
private InvCallback callback; private InvCallback callback;
@ -112,7 +112,7 @@ public class SWItem {
itemMeta.setDisplayName(name); itemMeta.setDisplayName(name);
if (lore != null && !lore.isEmpty()) itemMeta.setLore(lore); if (lore != null && !lore.isEmpty()) itemMeta.setLore(lore);
if (enchanted) itemMeta.addEnchant(impl.getDurabilityEnchantment() , 10, true); if (enchanted) itemMeta.addEnchant(TrickyTrialsWrapper.impl.getUnbreakingEnchantment(), 10, true);
itemStack.setItemMeta(itemMeta); itemStack.setItemMeta(itemMeta);
} }
callback = c; callback = c;
@ -149,7 +149,7 @@ public class SWItem {
private void hideAttributes() { private void hideAttributes() {
if (itemMeta == null) return; if (itemMeta == null) return;
for (ItemFlag flag : impl.getHideFlags()) { for (ItemFlag flag : EnumSet.allOf(ItemFlag.class)) {
itemMeta.addItemFlags(flag); itemMeta.addItemFlags(flag);
} }
} }
@ -194,16 +194,10 @@ public class SWItem {
public void setEnchanted(boolean enchanted) { public void setEnchanted(boolean enchanted) {
if (enchanted){ if (enchanted){
itemMeta.addEnchant(impl.getDurabilityEnchantment() , 10, true); itemMeta.addEnchant(TrickyTrialsWrapper.impl.getUnbreakingEnchantment() , 10, true);
} else { } else {
itemMeta.removeEnchant(impl.getDurabilityEnchantment()); itemMeta.removeEnchant(TrickyTrialsWrapper.impl.getUnbreakingEnchantment());
} }
itemStack.setItemMeta(itemMeta); itemStack.setItemMeta(itemMeta);
} }
public interface ISWItem {
Collection<ItemFlag> getHideFlags();
Enchantment getDurabilityEnchantment();
}
} }

View File

@ -20,6 +20,7 @@
package de.steamwar.teamserver.listener; package de.steamwar.teamserver.listener;
import de.steamwar.core.Core; import de.steamwar.core.Core;
import de.steamwar.core.TrickyTrialsWrapper;
import de.steamwar.teamserver.Builder; import de.steamwar.teamserver.Builder;
import net.md_5.bungee.api.ChatMessageType; import net.md_5.bungee.api.ChatMessageType;
import net.md_5.bungee.api.chat.BaseComponent; import net.md_5.bungee.api.chat.BaseComponent;
@ -55,7 +56,7 @@ public class FreezeListener implements Listener {
public void onEntitySpawn(EntitySpawnEvent e) { public void onEntitySpawn(EntitySpawnEvent e) {
if (!freeze) return; if (!freeze) return;
e.setCancelled(true); e.setCancelled(true);
if (e.getEntityType() == EntityType.PRIMED_TNT) { if (e.getEntityType() == TrickyTrialsWrapper.impl.getTntEntityType()) {
Bukkit.getScheduler().runTaskLater(Builder.getInstance(), () -> { Bukkit.getScheduler().runTaskLater(Builder.getInstance(), () -> {
e.getLocation().getBlock().setType(Material.TNT, false); e.getLocation().getBlock().setType(Material.TNT, false);
}, 1L); }, 1L);

View File

@ -130,6 +130,7 @@ dependencyResolutionManagement {
library("nms18", "de.steamwar:spigot:1.18") library("nms18", "de.steamwar:spigot:1.18")
library("nms19", "de.steamwar:spigot:1.19") library("nms19", "de.steamwar:spigot:1.19")
library("nms20", "de.steamwar:spigot:1.20") library("nms20", "de.steamwar:spigot:1.20")
library("nms21", "de.steamwar:spigot:1.21")
library("axiom", "de.steamwar:axiompaper:RELEASE") library("axiom", "de.steamwar:axiompaper:RELEASE")
library("worldedit12", "de.steamwar:worldedit:1.12") library("worldedit12", "de.steamwar:worldedit:1.12")
@ -173,6 +174,7 @@ include(
"BauSystem:BauSystem_18", "BauSystem:BauSystem_18",
"BauSystem:BauSystem_19", "BauSystem:BauSystem_19",
"BauSystem:BauSystem_20", "BauSystem:BauSystem_20",
"BauSystem:BauSystem_21",
"BauSystem:BauSystem_Main" "BauSystem:BauSystem_Main"
) )