Signed-off-by: yoyosource <yoyosource@nidido.de>
Dieser Commit ist enthalten in:
Ursprung
a35caa5d37
Commit
8f32793593
@ -37,7 +37,6 @@ import org.bukkit.Particle;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.craftbukkit.v1_15_R1.entity.CraftEntity;
|
||||
import org.bukkit.craftbukkit.v1_15_R1.entity.CraftPlayer;
|
||||
import org.bukkit.craftbukkit.v1_15_R1.inventory.CraftInventory;
|
||||
import org.bukkit.craftbukkit.v1_15_R1.inventory.CraftItemStack;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.TNTPrimed;
|
||||
@ -48,9 +47,10 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.function.LongSupplier;
|
||||
|
||||
public class NMSWrapper15 implements NMSWrapper.INMSWrapper {
|
||||
public class NMSWrapper15 implements NMSWrapper {
|
||||
|
||||
private static final Reflection.FieldAccessor<EnumGamemode> playerGameMode = Reflection.getField(PlayerInteractManager.class, EnumGamemode.class, 0);
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public void setInternalGameMode(Player player, GameMode gameMode) {
|
||||
@ -80,6 +80,7 @@ public class NMSWrapper15 implements NMSWrapper.INMSWrapper {
|
||||
|
||||
private static final List<Packet<?>> packets = new ArrayList<>();
|
||||
private static final Vec3D noMotion = new Vec3D(0, 0, 0);
|
||||
|
||||
@Override
|
||||
public void createTickCache(World world) {
|
||||
packets.clear();
|
||||
@ -105,6 +106,7 @@ public class NMSWrapper15 implements NMSWrapper.INMSWrapper {
|
||||
}
|
||||
|
||||
private static final Reflection.FieldAccessor<Integer> gameStateChangeReason = Reflection.getField(NoClipCommand.gameStateChange, int.class, 0);
|
||||
|
||||
@Override
|
||||
public void setGameStateChangeReason(Object packet) {
|
||||
gameStateChangeReason.set(packet, 3);
|
||||
@ -127,6 +129,7 @@ public class NMSWrapper15 implements NMSWrapper.INMSWrapper {
|
||||
}
|
||||
|
||||
private static final int threshold = 2048;
|
||||
|
||||
@Override
|
||||
public boolean checkItemStack(ItemStack item) {
|
||||
net.minecraft.server.v1_15_R1.ItemStack nmsItem = CraftItemStack.asNMSCopy(item);
|
||||
@ -183,4 +186,17 @@ public class NMSWrapper15 implements NMSWrapper.INMSWrapper {
|
||||
public AbstractTraceEntity createTrace(World world, Vector tntPosition, boolean tnt) {
|
||||
return new TraceEntity15(world, tntPosition, tnt);
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
@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), Vec3D.a);
|
||||
}
|
||||
}
|
||||
|
@ -52,9 +52,10 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.function.LongSupplier;
|
||||
|
||||
public class NMSWrapper18 implements NMSWrapper.INMSWrapper {
|
||||
public class NMSWrapper18 implements NMSWrapper {
|
||||
|
||||
private static final Reflection.FieldAccessor<EnumGamemode> playerGameMode = Reflection.getField(PlayerInteractManager.class, EnumGamemode.class, 0);
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public void setInternalGameMode(Player player, GameMode gameMode) {
|
||||
@ -85,6 +86,7 @@ public class NMSWrapper18 implements NMSWrapper.INMSWrapper {
|
||||
|
||||
private static final List<Packet<?>> packets = new ArrayList<>();
|
||||
private static final Vec3D noMotion = new Vec3D(0, 0, 0);
|
||||
|
||||
@Override
|
||||
public void createTickCache(World world) {
|
||||
packets.clear();
|
||||
@ -109,6 +111,7 @@ public class NMSWrapper18 implements NMSWrapper.INMSWrapper {
|
||||
}
|
||||
|
||||
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);
|
||||
@ -131,6 +134,7 @@ public class NMSWrapper18 implements NMSWrapper.INMSWrapper {
|
||||
}
|
||||
|
||||
private static final int threshold = 2048;
|
||||
|
||||
@Override
|
||||
public boolean checkItemStack(ItemStack item) {
|
||||
net.minecraft.world.item.ItemStack nmsItem = CraftItemStack.asNMSCopy(item);
|
||||
@ -187,4 +191,17 @@ public class NMSWrapper18 implements NMSWrapper.INMSWrapper {
|
||||
public AbstractTraceEntity createTrace(World world, Vector tntPosition, boolean tnt) {
|
||||
return new TraceEntity18(world, tntPosition, tnt);
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
@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);
|
||||
}
|
||||
}
|
||||
|
@ -52,9 +52,10 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.function.LongSupplier;
|
||||
|
||||
public class NMSWrapper19 implements NMSWrapper.INMSWrapper {
|
||||
public class NMSWrapper19 implements NMSWrapper {
|
||||
|
||||
private static final Reflection.FieldAccessor<EnumGamemode> playerGameMode = Reflection.getField(PlayerInteractManager.class, EnumGamemode.class, 0);
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public void setInternalGameMode(Player player, GameMode gameMode) {
|
||||
@ -85,6 +86,7 @@ public class NMSWrapper19 implements NMSWrapper.INMSWrapper {
|
||||
|
||||
private static final List<Packet<?>> packets = new ArrayList<>();
|
||||
private static final Vec3D noMotion = new Vec3D(0, 0, 0);
|
||||
|
||||
@Override
|
||||
public void createTickCache(World world) {
|
||||
packets.clear();
|
||||
@ -109,6 +111,7 @@ public class NMSWrapper19 implements NMSWrapper.INMSWrapper {
|
||||
}
|
||||
|
||||
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);
|
||||
@ -131,6 +134,7 @@ public class NMSWrapper19 implements NMSWrapper.INMSWrapper {
|
||||
}
|
||||
|
||||
private static final int threshold = 2048;
|
||||
|
||||
@Override
|
||||
public boolean checkItemStack(ItemStack item) {
|
||||
net.minecraft.world.item.ItemStack nmsItem = CraftItemStack.asNMSCopy(item);
|
||||
@ -187,4 +191,17 @@ public class NMSWrapper19 implements NMSWrapper.INMSWrapper {
|
||||
public AbstractTraceEntity createTrace(World world, Vector tntPosition, boolean tnt) {
|
||||
return new TraceEntity19(world, tntPosition, tnt);
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
@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);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,45 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2022 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.features.world;
|
||||
|
||||
import com.comphenix.tinyprotocol.Reflection;
|
||||
import de.steamwar.bausystem.linkage.LinkageType;
|
||||
import de.steamwar.bausystem.linkage.Linked;
|
||||
import de.steamwar.bausystem.utils.NMSWrapper;
|
||||
import de.steamwar.bausystem.utils.ProtocolAPI;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.function.BiFunction;
|
||||
|
||||
@Linked(LinkageType.PLAIN)
|
||||
public class NoCreativeKnockback {
|
||||
|
||||
private Class<?> explosionPacket = Reflection.getClass("{nms.network.protocol.game}.PacketPlayOutExplosion");
|
||||
|
||||
{
|
||||
BiFunction<Player, Object, Object> knockbackResetter = (player, o) -> {
|
||||
if (player.getGameMode() != GameMode.CREATIVE) return o;
|
||||
return NMSWrapper.impl.resetExplosionKnockback(o);
|
||||
};
|
||||
|
||||
ProtocolAPI.setOutgoingHandler(explosionPacket, knockbackResetter);
|
||||
}
|
||||
}
|
@ -23,6 +23,7 @@ import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.bausystem.configplayer.Config;
|
||||
import de.steamwar.bausystem.utils.FlatteningWrapper;
|
||||
import de.steamwar.bausystem.utils.NMSWrapper;
|
||||
import de.steamwar.bausystem.utils.ProtocolWrapper;
|
||||
import lombok.experimental.UtilityClass;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
@ -46,7 +47,8 @@ public class LinkageUtils {
|
||||
objectMap.put(Config.class, Config.getInstance());
|
||||
objectMap.put(BauSystem.class, BauSystem.getInstance());
|
||||
objectMap.put(FlatteningWrapper.class, FlatteningWrapper.impl);
|
||||
objectMap.put(NMSWrapper.INMSWrapper.class, NMSWrapper.impl);
|
||||
objectMap.put(NMSWrapper.class, NMSWrapper.impl);
|
||||
objectMap.put(ProtocolWrapper.class, ProtocolWrapper.impl);
|
||||
}
|
||||
|
||||
public void link() {
|
||||
|
@ -35,30 +35,28 @@ import org.bukkit.util.Vector;
|
||||
|
||||
import java.util.function.LongSupplier;
|
||||
|
||||
public class NMSWrapper {
|
||||
private NMSWrapper() {}
|
||||
public interface NMSWrapper {
|
||||
NMSWrapper impl = VersionDependent.getVersionImpl(BauSystem.getInstance());
|
||||
|
||||
public static final INMSWrapper impl = VersionDependent.getVersionImpl(BauSystem.getInstance());
|
||||
void setInternalGameMode(Player player, GameMode gameMode);
|
||||
void setSlotToItemStack(Player player, Object o);
|
||||
|
||||
public interface INMSWrapper {
|
||||
void setInternalGameMode(Player player, GameMode gameMode);
|
||||
void setSlotToItemStack(Player player, Object o);
|
||||
void init(LongSupplier longSupplier);
|
||||
void createTickCache(World world);
|
||||
void sendTickPackets();
|
||||
|
||||
void init(LongSupplier longSupplier);
|
||||
void createTickCache(World world);
|
||||
void sendTickPackets();
|
||||
void setGameStateChangeReason(Object packet);
|
||||
void setPlayerBuildAbilities(Player player);
|
||||
|
||||
void setGameStateChangeReason(Object packet);
|
||||
void setPlayerBuildAbilities(Player player);
|
||||
Particle tntPositionParticle();
|
||||
Material pathMaterial();
|
||||
|
||||
Particle tntPositionParticle();
|
||||
Material pathMaterial();
|
||||
boolean checkItemStack(ItemStack item);
|
||||
|
||||
boolean checkItemStack(ItemStack item);
|
||||
AbstractWarpEntity createWarp(World world, Vector position, String name);
|
||||
AbstractSimulatorEntity createSimulator(World world, Vector tntPosition, boolean highlight);
|
||||
AbstractDetonatorEntity constructDetonator(World world, Vector position);
|
||||
AbstractTraceEntity createTrace(World world, Vector tntPosition, boolean tnt);
|
||||
|
||||
AbstractWarpEntity createWarp(World world, Vector position, String name);
|
||||
AbstractSimulatorEntity createSimulator(World world, Vector tntPosition, boolean highlight);
|
||||
AbstractDetonatorEntity constructDetonator(World world, Vector position);
|
||||
AbstractTraceEntity createTrace(World world, Vector tntPosition, boolean tnt);
|
||||
}
|
||||
Object resetExplosionKnockback(Object packet);
|
||||
}
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren