SteamWar/BauSystem2.0
Archiviert
12
0

Merge pull request '1.18' (#77) from 1.18 into master
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful

Reviewed-on: #77
Reviewed-by: YoyoNow <jwsteam@nidido.de>
Dieser Commit ist enthalten in:
YoyoNow 2022-03-30 11:21:06 +02:00
Commit ae942179c1
26 geänderte Dateien mit 850 neuen und 55 gelöschten Zeilen

Datei anzeigen

@ -24,6 +24,7 @@ import de.steamwar.bausystem.entities.DetonatorEntity15;
import de.steamwar.bausystem.entities.SimulatorEntity15; import de.steamwar.bausystem.entities.SimulatorEntity15;
import de.steamwar.bausystem.entities.TraceEntity15; import de.steamwar.bausystem.entities.TraceEntity15;
import de.steamwar.bausystem.features.detonator.AbstractDetonatorEntity; import de.steamwar.bausystem.features.detonator.AbstractDetonatorEntity;
import de.steamwar.bausystem.features.other.NoClipCommand;
import de.steamwar.bausystem.features.simulator.AbstractSimulatorEntity; import de.steamwar.bausystem.features.simulator.AbstractSimulatorEntity;
import de.steamwar.bausystem.features.tracer.AbstractTraceEntity; import de.steamwar.bausystem.features.tracer.AbstractTraceEntity;
import de.steamwar.bausystem.features.warp.AbstractWarpEntity; import de.steamwar.bausystem.features.warp.AbstractWarpEntity;
@ -31,6 +32,8 @@ import de.steamwar.bausystem.entities.WarpEntity15;
import net.minecraft.server.v1_15_R1.*; import net.minecraft.server.v1_15_R1.*;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.GameMode; import org.bukkit.GameMode;
import org.bukkit.Material;
import org.bukkit.Particle;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.craftbukkit.v1_15_R1.entity.CraftEntity; 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.entity.CraftPlayer;
@ -46,7 +49,7 @@ import java.util.function.LongSupplier;
public class NMSWrapper15 implements NMSWrapper.INMSWrapper { public class NMSWrapper15 implements NMSWrapper.INMSWrapper {
private static final Reflection.FieldAccessor<EnumGamemode> playerGameMode = Reflection.getField(PlayerInteractManager.class, "gamemode", EnumGamemode.class); private static final Reflection.FieldAccessor<EnumGamemode> playerGameMode = Reflection.getField(PlayerInteractManager.class, EnumGamemode.class, 0);
@Override @Override
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
public void setInternalGameMode(Player player, GameMode gameMode) { public void setInternalGameMode(Player player, GameMode gameMode) {
@ -84,6 +87,28 @@ 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);
}
@Override
public void setPlayerBuildAbilities(Player player) {
((CraftPlayer) player).getHandle().abilities.mayBuild = true;
((CraftPlayer) player).getHandle().abilities.canInstantlyBuild = true;
}
@Override
public Particle tntPositionParticle() {
return Particle.BARRIER;
}
@Override
public Material pathMaterial() {
return Material.GRASS_PATH;
}
private static final int threshold = 2048; private static final int threshold = 2048;
@Override @Override
public boolean checkItemStack(ItemStack item) { public boolean checkItemStack(ItemStack item) {

63
BauSystem_18/build.gradle Normale Datei
Datei anzeigen

@ -0,0 +1,63 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2020 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/>.
*/
plugins {
id 'base'
id 'java'
}
group 'steamwar'
version '1.0'
compileJava.options.encoding = 'UTF-8'
sourceCompatibility = 1.8
targetCompatibility = 1.8
sourceSets {
main {
java {
srcDirs = ['src/']
}
resources {
srcDirs = ['src/']
exclude '**/*.java', '**/*.kt'
}
}
}
dependencies {
compileOnly 'org.projectlombok:lombok:1.18.22'
testCompileOnly 'org.projectlombok:lombok:1.18.22'
annotationProcessor 'org.projectlombok:lombok:1.18.22'
testAnnotationProcessor 'org.projectlombok:lombok:1.18.22'
implementation project(":BauSystem_Main")
compileOnly 'org.spigotmc:spigot-api:1.18-R0.1-SNAPSHOT'
compileOnly files("${projectDir}/../lib/Spigot-1.18.jar")
compileOnly 'it.unimi.dsi:fastutil:8.5.6'
compileOnly 'com.mojang:datafixerupper:4.0.26'
compileOnly 'io.netty:netty-all:4.1.68.Final'
compileOnly 'com.mojang:authlib:1.5.25'
compileOnly 'com.mojang:brigadier:1.0.18'
compileOnly files("${projectDir}/../lib/WorldEdit-1.15.jar")
compileOnly files("${projectDir}/../lib/SpigotCore.jar")
}

20
BauSystem_18/settings.gradle Normale Datei
Datei anzeigen

@ -0,0 +1,20 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2020 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/>.
*/
rootProject.name = 'BauSystem_18'

Datei anzeigen

@ -0,0 +1,95 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2021 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.entities;
import de.steamwar.bausystem.features.detonator.AbstractDetonatorEntity;
import net.minecraft.network.protocol.game.PacketPlayOutEntityDestroy;
import net.minecraft.network.protocol.game.PacketPlayOutEntityMetadata;
import net.minecraft.network.protocol.game.PacketPlayOutSpawnEntity;
import net.minecraft.server.network.PlayerConnection;
import net.minecraft.world.entity.EntityTypes;
import net.minecraft.world.entity.item.EntityFallingBlock;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.phys.Vec3D;
import org.bukkit.World;
import org.bukkit.craftbukkit.v1_18_R2.CraftWorld;
import org.bukkit.craftbukkit.v1_18_R2.entity.CraftPlayer;
import org.bukkit.entity.Player;
import org.bukkit.util.Vector;
public class DetonatorEntity18 extends EntityFallingBlock implements AbstractDetonatorEntity {
private static final Vec3D ZERO = new Vec3D(0, 0, 0);
private final Vector position;
private int references = 0;
public DetonatorEntity18(World world, Vector position) {
super(((CraftWorld) world).getHandle(), position.getX(), position.getY(), position.getZ(), Blocks.du.n());
this.position = position;
this.h(true);
this.e(true);
this.S = -12000;
}
@Override
public int getId() {
return ae();
}
@Override
public void display(Player player) {
if (references++ > 0)
return;
PacketPlayOutSpawnEntity packetPlayOutSpawnEntity = new PacketPlayOutSpawnEntity(getId(), cm(), position.getX(), position.getY(), position.getZ(), 0, 0, EntityTypes.C, Block.i(Blocks.du.n()), ZERO);
PlayerConnection playerConnection = ((CraftPlayer) player).getHandle().b;
playerConnection.a(packetPlayOutSpawnEntity);
PacketPlayOutEntityMetadata packetPlayOutEntityMetadata = new PacketPlayOutEntityMetadata(getId(), Y, true);
playerConnection.a(packetPlayOutEntityMetadata);
}
@Override
public boolean hide(Player player, boolean force) {
if (!force && --references > 0)
return false;
sendDestroy(player);
ag();
return true;
}
private void sendDestroy(Player player) {
PacketPlayOutEntityDestroy packetPlayOutEntityDestroy = new PacketPlayOutEntityDestroy(getId());
((CraftPlayer) player).getHandle().b.a(packetPlayOutEntityDestroy);
}
@Override
public void sendEntity(Player player) {
display(player);
}
@Override
public void sendEntityDestroy(Player player) {
hide(player, false);
}
}

Datei anzeigen

@ -0,0 +1,71 @@
/*
This file is a part of the SteamWar software.
Copyright (C) 2020 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.entities;
import de.steamwar.bausystem.features.simulator.AbstractSimulatorEntity;
import de.steamwar.bausystem.shared.BaseEntity18;
import de.steamwar.bausystem.shared.ReferenceCounter;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.entity.Player;
import org.bukkit.util.Vector;
public class SimulatorEntity18 extends BaseEntity18 implements AbstractSimulatorEntity {
private ReferenceCounter referenceCounter = new ReferenceCounter();
public SimulatorEntity18(World world, Vector position, boolean highlight) {
super(world, position, highlight ? Material.WHITE_STAINED_GLASS : Material.TNT);
this.e(true);
this.S = -12000;
}
@Override
public int getId() {
return ae();
}
@Override
public void display(Player player) {
if (referenceCounter.increment() > 0) {
return;
}
sendEntity(player);
}
@Override
public void setPosition(Vector position) {
this.position = position;
e(position.getX(), position.getY(), position.getZ());
}
@Override
public boolean hide(Player player, boolean force) {
if (!force && referenceCounter.decrement() > 0) {
return false;
}
sendEntityDestroy(player);
ag();
return true;
}
}

Datei anzeigen

@ -0,0 +1,73 @@
/*
This file is a part of the SteamWar software.
Copyright (C) 2020 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.entities;
import de.steamwar.bausystem.features.tracer.AbstractTraceEntity;
import de.steamwar.bausystem.shared.BaseEntity18;
import de.steamwar.bausystem.shared.ReferenceCounter;
import net.minecraft.network.chat.ChatComponentText;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.entity.Player;
import org.bukkit.util.Vector;
public class TraceEntity18 extends BaseEntity18 implements AbstractTraceEntity {
private boolean exploded = false;
private ReferenceCounter referenceCounter = new ReferenceCounter();
public TraceEntity18(World world, Vector position, boolean tnt) {
super(world, position, tnt ? Material.TNT : Material.WHITE_STAINED_GLASS);
this.e(true);
this.S = -12000;
}
@Override
public void display(Player player, boolean exploded, int ticks) {
if (ticks != -1) {
this.n(true);
this.a(new ChatComponentText(ticks + ""));
}
if (!this.exploded && exploded) {
this.n(true);
this.a(new ChatComponentText("Bumm"));
this.exploded = true;
if (referenceCounter.increment() > 0) {
sendEntityDestroy(player);
}
} else if (referenceCounter.increment() > 0) {
return;
}
sendEntity(player);
}
@Override
public boolean hide(Player player, boolean force) {
if (!force && referenceCounter.decrement() > 0) {
return false;
}
sendEntityDestroy(player);
ag();
return true;
}
}

Datei anzeigen

@ -0,0 +1,60 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2021 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.entities;
import de.steamwar.bausystem.features.warp.AbstractWarpEntity;
import de.steamwar.bausystem.shared.BaseArmorStand18;
import net.minecraft.network.chat.ChatComponentText;
import org.bukkit.World;
import org.bukkit.entity.Player;
import org.bukkit.util.Vector;
public class WarpEntity18 extends BaseArmorStand18 implements AbstractWarpEntity {
private String name;
public WarpEntity18(World world, Vector position, String name) {
super(world, position);
this.j(true);
this.a(true);
this.name = name;
this.e(true);
this.S = -12000;
}
@Override
public void display(Player player) {
this.n(true);
this.a(new ChatComponentText(name));
sendEntity(player);
}
@Override
public void setName(String name) {
this.name = name;
}
@Override
public boolean hide(Player player) {
sendEntityDestroy(player);
ag();
return true;
}
}

Datei anzeigen

@ -0,0 +1,62 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2021 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.shared;
import net.minecraft.network.protocol.game.PacketPlayOutEntityDestroy;
import net.minecraft.network.protocol.game.PacketPlayOutEntityMetadata;
import net.minecraft.network.protocol.game.PacketPlayOutSpawnEntity;
import net.minecraft.server.network.PlayerConnection;
import net.minecraft.world.entity.EntityTypes;
import net.minecraft.world.entity.decoration.EntityArmorStand;
import net.minecraft.world.phys.Vec3D;
import org.bukkit.World;
import org.bukkit.craftbukkit.v1_18_R2.CraftWorld;
import org.bukkit.craftbukkit.v1_18_R2.entity.CraftPlayer;
import org.bukkit.entity.Player;
import org.bukkit.util.Vector;
public class BaseArmorStand18 extends EntityArmorStand implements AbstractEntity {
private static final Vec3D ZERO = new Vec3D(0, 0, 0);
protected Vector position;
public BaseArmorStand18(World world, Vector position) {
super(((CraftWorld) world).getHandle(), position.getX(), position.getY(), position.getZ());
this.position = position;
e(true);
S = -12000;
}
public void sendEntity(Player player) {
PacketPlayOutSpawnEntity packetPlayOutSpawnEntity = new PacketPlayOutSpawnEntity(ae(), cm(), position.getX(), position.getY(), position.getZ(), 0, 0, EntityTypes.c, 0, ZERO);
PlayerConnection playerConnection = ((CraftPlayer) player).getHandle().b;
playerConnection.a(packetPlayOutSpawnEntity);
PacketPlayOutEntityMetadata packetPlayOutEntityMetadata = new PacketPlayOutEntityMetadata(ae(), Y, true);
playerConnection.a(packetPlayOutEntityMetadata);
}
public void sendEntityDestroy(Player player) {
PacketPlayOutEntityDestroy packetPlayOutEntityDestroy = new PacketPlayOutEntityDestroy(ae());
((CraftPlayer) player).getHandle().b.a(packetPlayOutEntityDestroy);
}
}

Datei anzeigen

@ -0,0 +1,68 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2021 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.shared;
import net.minecraft.network.protocol.game.PacketPlayOutEntityDestroy;
import net.minecraft.network.protocol.game.PacketPlayOutEntityMetadata;
import net.minecraft.network.protocol.game.PacketPlayOutSpawnEntity;
import net.minecraft.server.network.PlayerConnection;
import net.minecraft.world.entity.EntityTypes;
import net.minecraft.world.entity.item.EntityFallingBlock;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.IBlockData;
import net.minecraft.world.phys.Vec3D;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.craftbukkit.v1_18_R2.CraftWorld;
import org.bukkit.craftbukkit.v1_18_R2.block.data.CraftBlockData;
import org.bukkit.craftbukkit.v1_18_R2.entity.CraftPlayer;
import org.bukkit.entity.Player;
import org.bukkit.util.Vector;
public class BaseEntity18 extends EntityFallingBlock implements AbstractEntity {
private static final Vec3D ZERO = new Vec3D(0, 0, 0);
private final IBlockData iBlockData;
protected Vector position;
public BaseEntity18(World world, Vector position, Material blockType) {
super(((CraftWorld) world).getHandle(), position.getX(), position.getY(), position.getZ(), ((CraftBlockData) blockType.createBlockData()).getState());
this.iBlockData = ((CraftBlockData) blockType.createBlockData()).getState();
this.position = position;
this.e(true);
this.S = -12000;
}
public void sendEntity(Player player) {
PacketPlayOutSpawnEntity packetPlayOutSpawnEntity = new PacketPlayOutSpawnEntity(ae(), cm(), position.getX(), position.getY(), position.getZ(), 0, 0, EntityTypes.C, Block.i(iBlockData), ZERO);
PlayerConnection playerConnection = ((CraftPlayer) player).getHandle().b;
playerConnection.a(packetPlayOutSpawnEntity);
PacketPlayOutEntityMetadata packetPlayOutEntityMetadata = new PacketPlayOutEntityMetadata(ae(), Y, true);
playerConnection.a(packetPlayOutEntityMetadata);
}
public void sendEntityDestroy(Player player) {
PacketPlayOutEntityDestroy packetPlayOutEntityDestroy = new PacketPlayOutEntityDestroy(ae());
((CraftPlayer) player).getHandle().b.a(packetPlayOutEntityDestroy);
}
}

Datei anzeigen

@ -0,0 +1,177 @@
/*
* 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.utils;
import com.comphenix.tinyprotocol.Reflection;
import com.comphenix.tinyprotocol.TinyProtocol;
import de.steamwar.bausystem.entities.DetonatorEntity18;
import de.steamwar.bausystem.entities.SimulatorEntity18;
import de.steamwar.bausystem.entities.TraceEntity18;
import de.steamwar.bausystem.entities.WarpEntity18;
import de.steamwar.bausystem.features.detonator.AbstractDetonatorEntity;
import de.steamwar.bausystem.features.other.NoClipCommand;
import de.steamwar.bausystem.features.simulator.AbstractSimulatorEntity;
import de.steamwar.bausystem.features.tracer.AbstractTraceEntity;
import de.steamwar.bausystem.features.warp.AbstractWarpEntity;
import net.minecraft.SystemUtils;
import net.minecraft.nbt.NBTBase;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.network.protocol.Packet;
import net.minecraft.network.protocol.game.PacketPlayOutEntityMetadata;
import net.minecraft.network.protocol.game.PacketPlayOutEntityTeleport;
import net.minecraft.network.protocol.game.PacketPlayOutEntityVelocity;
import net.minecraft.network.protocol.game.PacketPlayOutGameStateChange;
import net.minecraft.server.level.PlayerInteractManager;
import net.minecraft.world.level.EnumGamemode;
import net.minecraft.world.phys.Vec3D;
import org.bukkit.*;
import org.bukkit.craftbukkit.v1_18_R2.entity.CraftEntity;
import org.bukkit.craftbukkit.v1_18_R2.entity.CraftPlayer;
import org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack;
import org.bukkit.entity.Player;
import org.bukkit.entity.TNTPrimed;
import org.bukkit.inventory.ItemStack;
import org.bukkit.util.Vector;
import java.util.ArrayList;
import java.util.List;
import java.util.function.LongSupplier;
public class NMSWrapper18 implements NMSWrapper.INMSWrapper {
private static final Reflection.FieldAccessor<EnumGamemode> playerGameMode = Reflection.getField(PlayerInteractManager.class, EnumGamemode.class, 0);
@Override
@SuppressWarnings("deprecation")
public void setInternalGameMode(Player player, GameMode gameMode) {
playerGameMode.set(((CraftPlayer) player).getHandle().d, EnumGamemode.a(gameMode.getValue()));
}
@Override
public void init(LongSupplier longSupplier) {
SystemUtils.a = () -> System.nanoTime() + longSupplier.getAsLong();
}
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();
world.getEntities().stream().filter(entity -> !(entity instanceof Player)).forEach(entity -> {
packets.add(new PacketPlayOutEntityVelocity(entity.getEntityId(), noMotion));
packets.add(new PacketPlayOutEntityTeleport(((CraftEntity) entity).getHandle()));
if (entity instanceof TNTPrimed) {
net.minecraft.world.entity.Entity serverEntity = ((CraftEntity) entity).getHandle();
packets.add(new PacketPlayOutEntityMetadata(serverEntity.ae(), serverEntity.ai(), true));
}
});
}
@Override
public void sendTickPackets() {
Bukkit.getOnlinePlayers().forEach(player -> {
for (Packet<?> p : packets) {
TinyProtocol.instance.sendPacket(player, p);
}
});
}
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().fs().d = true;
((CraftPlayer) player).getHandle().fs().e = true;
}
@Override
public Particle tntPositionParticle() {
return Particle.BLOCK_MARKER;
}
@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.t();
if (tag != null && 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))
continue;
NBTTagCompound slot = (NBTTagCompound) nbtBase;
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;
}
@Override
public AbstractWarpEntity createWarp(World world, Vector position, String name) {
return new WarpEntity18(world, position, name);
}
@Override
public AbstractSimulatorEntity createSimulator(World world, Vector tntPosition, boolean highlight) {
return new SimulatorEntity18(world, tntPosition, highlight);
}
@Override
public AbstractDetonatorEntity constructDetonator(World world, Vector position) {
return new DetonatorEntity18(world, position);
}
@Override
public AbstractTraceEntity createTrace(World world, Vector tntPosition, boolean tnt) {
return new TraceEntity18(world, tntPosition, tnt);
}
}

Datei anzeigen

@ -56,7 +56,10 @@ dependencies {
annotationProcessor 'org.atteo.classindex:classindex:3.11' annotationProcessor 'org.atteo.classindex:classindex:3.11'
testAnnotationProcessor 'org.atteo.classindex:classindex:3.11' testAnnotationProcessor 'org.atteo.classindex:classindex:3.11'
compileOnly files("${projectDir}/../lib/Spigot-1.15.jar") compileOnly 'org.spigotmc:spigot-api:1.18-R0.1-SNAPSHOT'
compileOnly files("${projectDir}/../lib/Spigot-1.18.jar")
compileOnly 'com.mojang:authlib:1.5.25'
compileOnly 'io.netty:netty-all:4.1.68.Final'
compileOnly files("${projectDir}/../lib/WorldEdit-1.15.jar") compileOnly files("${projectDir}/../lib/WorldEdit-1.15.jar")
compileOnly files("${projectDir}/../lib/SpigotCore.jar") compileOnly files("${projectDir}/../lib/SpigotCore.jar")
} }

Datei anzeigen

@ -19,12 +19,12 @@
package de.steamwar.bausystem; package de.steamwar.bausystem;
import com.comphenix.tinyprotocol.TinyProtocol;
import de.steamwar.bausystem.configplayer.Config; import de.steamwar.bausystem.configplayer.Config;
import de.steamwar.bausystem.linkage.LinkageUtils; import de.steamwar.bausystem.linkage.LinkageUtils;
import de.steamwar.bausystem.region.loader.PrototypeLoader; import de.steamwar.bausystem.region.loader.PrototypeLoader;
import de.steamwar.bausystem.region.loader.RegionLoader; import de.steamwar.bausystem.region.loader.RegionLoader;
import de.steamwar.bausystem.region.loader.Updater; import de.steamwar.bausystem.region.loader.Updater;
import de.steamwar.bausystem.utils.ProtocolAPI;
import de.steamwar.bausystem.worlddata.WorldData; import de.steamwar.bausystem.worlddata.WorldData;
import de.steamwar.message.Message; import de.steamwar.message.Message;
import de.steamwar.scoreboard.SWScoreboard; import de.steamwar.scoreboard.SWScoreboard;
@ -89,7 +89,7 @@ public class BauSystem extends JavaPlugin implements Listener {
WorldData.write(); WorldData.write();
Config.getInstance().saveAll(); Config.getInstance().saveAll();
ProtocolAPI.tinyProtocol.close(); TinyProtocol.instance.close();
} }
private void fixLogging() { private void fixLogging() {

Datei anzeigen

@ -45,7 +45,7 @@ import java.util.Set;
@Linked(LinkageType.LISTENER) @Linked(LinkageType.LISTENER)
public class DetonatorListener implements Listener { public class DetonatorListener implements Listener {
public static final Class<?> useEntity = Reflection.getClass("{nms}.PacketPlayInUseEntity"); public static final Class<?> useEntity = Reflection.getClass("{nms.network.protocol.game}.PacketPlayInUseEntity");
private static final Reflection.FieldAccessor<Integer> entityIdFieldAccessor = Reflection.getField(useEntity, int.class, 0); private static final Reflection.FieldAccessor<Integer> entityIdFieldAccessor = Reflection.getField(useEntity, int.class, 0);
private static final Set<Player> HAS_UPDATED = new HashSet<>(); private static final Set<Player> HAS_UPDATED = new HashSet<>();

Datei anzeigen

@ -19,6 +19,7 @@
package de.steamwar.bausystem.features.observer; package de.steamwar.bausystem.features.observer;
import com.comphenix.tinyprotocol.Reflection;
import de.steamwar.bausystem.region.Point; import de.steamwar.bausystem.region.Point;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
@ -29,7 +30,6 @@ import org.bukkit.block.data.Bisected;
import org.bukkit.block.data.BlockData; import org.bukkit.block.data.BlockData;
import org.bukkit.block.data.type.Observer; import org.bukkit.block.data.type.Observer;
import org.bukkit.block.data.type.*; import org.bukkit.block.data.type.*;
import org.bukkit.craftbukkit.v1_15_R1.block.impl.CraftPoweredRail;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import java.util.*; import java.util.*;
@ -170,6 +170,7 @@ public class ObserverTracer {
} }
} }
private static final Class<?> craftPoweredRail = Reflection.getClass("{obc}.block.impl.CraftPoweredRail");
private boolean checkAllowed(Block block, BlockData blockData) { private boolean checkAllowed(Block block, BlockData blockData) {
if (checkMaterial(block)) return true; if (checkMaterial(block)) return true;
if (block.getType() == Material.BELL) { if (block.getType() == Material.BELL) {
@ -178,7 +179,7 @@ public class ObserverTracer {
return blockData instanceof Door return blockData instanceof Door
|| blockData instanceof Gate || blockData instanceof Gate
|| blockData instanceof CraftPoweredRail || craftPoweredRail.isInstance(blockData)
|| blockData instanceof TrapDoor || blockData instanceof TrapDoor
|| blockData instanceof GlassPane; || blockData instanceof GlassPane;
} }

Datei anzeigen

@ -20,6 +20,7 @@
package de.steamwar.bausystem.features.other; package de.steamwar.bausystem.features.other;
import com.comphenix.tinyprotocol.Reflection; import com.comphenix.tinyprotocol.Reflection;
import com.comphenix.tinyprotocol.TinyProtocol;
import com.mojang.authlib.GameProfile; import com.mojang.authlib.GameProfile;
import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.features.tpslimit.TPSUtils; import de.steamwar.bausystem.features.tpslimit.TPSUtils;
@ -28,9 +29,9 @@ import de.steamwar.bausystem.linkage.Linked;
import de.steamwar.bausystem.utils.NMSWrapper; import de.steamwar.bausystem.utils.NMSWrapper;
import de.steamwar.bausystem.utils.ProtocolAPI; import de.steamwar.bausystem.utils.ProtocolAPI;
import de.steamwar.command.SWCommand; import de.steamwar.command.SWCommand;
import de.steamwar.core.Core;
import lombok.Getter; import lombok.Getter;
import org.bukkit.GameMode; import org.bukkit.GameMode;
import org.bukkit.craftbukkit.v1_15_R1.entity.CraftPlayer;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
@ -46,28 +47,26 @@ import java.util.function.BiFunction;
@Linked(LinkageType.LISTENER) @Linked(LinkageType.LISTENER)
public class NoClipCommand extends SWCommand implements Listener { public class NoClipCommand extends SWCommand implements Listener {
private static final Class<?> playerInfoPacket = Reflection.getClass("{nms}.PacketPlayOutPlayerInfo"); private static final Class<?> playerInfoPacket = Reflection.getClass("{nms.network.protocol.game}.PacketPlayOutPlayerInfo");
private static final Reflection.ConstructorInvoker playerInfoConstructor = Reflection.getConstructor(playerInfoPacket); private static final Class<?> playerInfoActionClass = Reflection.getClass("{nms.network.protocol.game}.PacketPlayOutPlayerInfo$EnumPlayerInfoAction");
private static final Class<?> playerInfoActionClass = Reflection.getClass("{nms}.PacketPlayOutPlayerInfo$EnumPlayerInfoAction");
private static final Reflection.FieldAccessor<?> playerInfoAction = Reflection.getField(playerInfoPacket, playerInfoActionClass, 0); private static final Reflection.FieldAccessor<?> playerInfoAction = Reflection.getField(playerInfoPacket, playerInfoActionClass, 0);
private static final Object updateGamemode = playerInfoActionClass.getEnumConstants()[1]; private static final Object updateGamemode = playerInfoActionClass.getEnumConstants()[1];
private static final Reflection.FieldAccessor<List> playerInfoData = Reflection.getField(playerInfoPacket, List.class, 0); private static final Reflection.FieldAccessor<List> playerInfoData = Reflection.getField(playerInfoPacket, List.class, 0);
private static final Class<?> playerInfoDataClass = Reflection.getClass("{nms}.PacketPlayOutPlayerInfo$PlayerInfoData"); private static final Class<?> playerInfoDataClass = Reflection.getClass("{nms.network.protocol.game}.PacketPlayOutPlayerInfo$PlayerInfoData");
private static final Class<?> enumGamemode = Reflection.getClass("{nms}.EnumGamemode"); private static final Class<?> enumGamemode = Reflection.getClass("{nms.world.level}.EnumGamemode");
private static final Object spectator = enumGamemode.getEnumConstants()[4]; private static final Object spectator = enumGamemode.getEnumConstants()[Core.getVersion() > 15 ? 3 : 4];
private static final Class<?> iChatBaseComponent = Reflection.getClass("{nms}.IChatBaseComponent"); private static final Class<?> iChatBaseComponent = Reflection.getClass("{nms.network.chat}.IChatBaseComponent");
private static final Reflection.ConstructorInvoker playerInfoDataConstructor = Reflection.getConstructor(playerInfoDataClass, playerInfoPacket, GameProfile.class, int.class, enumGamemode, iChatBaseComponent); private static final Reflection.ConstructorInvoker playerInfoDataConstructor = Core.getVersion() > 15 ? Reflection.getConstructor(playerInfoDataClass, GameProfile.class, int.class, enumGamemode, iChatBaseComponent) : Reflection.getConstructor(playerInfoDataClass, playerInfoPacket, GameProfile.class, int.class, enumGamemode, iChatBaseComponent);
private static final Class<?> gameStateChange = Reflection.getClass("{nms}.PacketPlayOutGameStateChange"); public static final Class<?> gameStateChange = Reflection.getClass("{nms.network.protocol.game}.PacketPlayOutGameStateChange");
private static final Reflection.FieldAccessor<Integer> integerFieldAccessor = Reflection.getField(gameStateChange, int.class, 0);
private static final Reflection.FieldAccessor<Float> floatFieldAccessor = Reflection.getField(gameStateChange, float.class, 0); private static final Reflection.FieldAccessor<Float> floatFieldAccessor = Reflection.getField(gameStateChange, float.class, 0);
private static final Class<?> position = Reflection.getClass("{nms}.PacketPlayInFlying$PacketPlayInPosition"); private static final Class<?> position = Reflection.getClass("{nms.network.protocol.game}.PacketPlayInFlying$PacketPlayInPosition");
private static final Class<?> positionLook = Reflection.getClass("{nms}.PacketPlayInFlying$PacketPlayInPositionLook"); private static final Class<?> positionLook = Reflection.getClass("{nms.network.protocol.game}.PacketPlayInFlying$PacketPlayInPositionLook");
private static final Class<?> useItem = Reflection.getClass("{nms}.PacketPlayInUseItem"); private static final Class<?> useItem = Reflection.getClass("{nms.network.protocol.game}.PacketPlayInUseItem");
private static final Class<?> blockDig = Reflection.getClass("{nms}.PacketPlayInBlockDig"); private static final Class<?> blockDig = Reflection.getClass("{nms.network.protocol.game}.PacketPlayInBlockDig");
private static final Class<?> windowClick = Reflection.getClass("{nms}.PacketPlayInWindowClick"); private static final Class<?> windowClick = Reflection.getClass("{nms.network.protocol.game}.PacketPlayInWindowClick");
@Getter @Getter
private static final List<Player> NOCLIPS = new ArrayList<>(); private static final List<Player> NOCLIPS = new ArrayList<>();
@ -106,16 +105,15 @@ public class NoClipCommand extends SWCommand implements Listener {
player.setGameMode(GameMode.CREATIVE); player.setGameMode(GameMode.CREATIVE);
} else { } else {
player.setGameMode(GameMode.SPECTATOR); player.setGameMode(GameMode.SPECTATOR);
((CraftPlayer) player).getHandle().abilities.mayBuild = true; NMSWrapper.impl.setPlayerBuildAbilities(player);
((CraftPlayer) player).getHandle().abilities.canInstantlyBuild = true;
Object gameStateChangeObject = Reflection.newInstance(gameStateChange); Object gameStateChangeObject = Reflection.newInstance(gameStateChange);
integerFieldAccessor.set(gameStateChangeObject, 3); NMSWrapper.impl.setGameStateChangeReason(gameStateChangeObject);
floatFieldAccessor.set(gameStateChangeObject, 1F); floatFieldAccessor.set(gameStateChangeObject, 1F);
NOCLIPS.add(player); NOCLIPS.add(player);
BauSystem.MESSAGE.send("OTHER_NOCLIP_SLOT_INFO", player); BauSystem.MESSAGE.send("OTHER_NOCLIP_SLOT_INFO", player);
ProtocolAPI.tinyProtocol.sendPacket(player, gameStateChangeObject); TinyProtocol.instance.sendPacket(player, gameStateChangeObject);
pseudoSpectator(player); pseudoSpectator(player);
} }
} }
@ -154,13 +152,13 @@ public class NoClipCommand extends SWCommand implements Listener {
} }
private static void pseudoSpectator(Player player) { private static void pseudoSpectator(Player player) {
ProtocolAPI.tinyProtocol.sendPacket(player, playerInfoPacket(updateGamemode, new GameProfile(player.getUniqueId(), player.getName()), spectator)); TinyProtocol.instance.sendPacket(player, playerInfoPacket(updateGamemode, new GameProfile(player.getUniqueId(), player.getName()), spectator));
} }
private static Object playerInfoPacket(Object action, GameProfile profile, Object mode) { private static Object playerInfoPacket(Object action, GameProfile profile, Object mode) {
Object packet = playerInfoConstructor.invoke(); Object packet = Reflection.newInstance(playerInfoPacket);
playerInfoAction.set(packet, action); playerInfoAction.set(packet, action);
playerInfoData.set(packet, Collections.singletonList(playerInfoDataConstructor.invoke(packet, profile, 0, mode, null))); playerInfoData.set(packet, Collections.singletonList(Core.getVersion() > 15 ? playerInfoDataConstructor.invoke(profile, 0, mode, null) : playerInfoDataConstructor.invoke(packet, profile, 0, mode, null)));
return packet; return packet;
} }
} }

Datei anzeigen

@ -19,6 +19,7 @@
package de.steamwar.bausystem.features.slaves.laufbau; package de.steamwar.bausystem.features.slaves.laufbau;
import de.steamwar.bausystem.utils.NMSWrapper;
import de.steamwar.inventory.SWItem; import de.steamwar.inventory.SWItem;
import lombok.Getter; import lombok.Getter;
import lombok.ToString; import lombok.ToString;
@ -86,7 +87,7 @@ public class BlockBoundingBox {
addPixel(Material.AIR.createBlockData(), 0, 0, 0, 0, 0, 0, null); addPixel(Material.AIR.createBlockData(), 0, 0, 0, 0, 0, 0, null);
addPixel(Material.END_STONE.createBlockData(), 0, 0, 0, 16, 16, 16, null); addPixel(Material.END_STONE.createBlockData(), 0, 0, 0, 16, 16, 16, null);
addPixel(Material.GRASS_PATH.createBlockData(), 0, 0, 0, 16, 15, 16, createItem("LAUFBAU_BLOCK_GRASS_PATH", Material.GRASS_PATH)); addPixel(NMSWrapper.impl.pathMaterial().createBlockData(), 0, 0, 0, 16, 15, 16, createItem("LAUFBAU_BLOCK_GRASS_PATH", NMSWrapper.impl.pathMaterial()));
addPixel(Material.SOUL_SAND.createBlockData(), 0, 0, 0, 16, 14, 16, createItem("LAUFBAU_BLOCK_SOUL_SAND", Material.SOUL_SAND)); addPixel(Material.SOUL_SAND.createBlockData(), 0, 0, 0, 16, 14, 16, createItem("LAUFBAU_BLOCK_SOUL_SAND", Material.SOUL_SAND));
Cocoa cocoaNorth = (Cocoa) Material.COCOA.createBlockData(); Cocoa cocoaNorth = (Cocoa) Material.COCOA.createBlockData();

Datei anzeigen

@ -24,9 +24,11 @@ import de.steamwar.bausystem.features.slaves.laufbau.Cuboid;
import de.steamwar.bausystem.linkage.Enable; import de.steamwar.bausystem.linkage.Enable;
import de.steamwar.bausystem.linkage.LinkageType; import de.steamwar.bausystem.linkage.LinkageType;
import de.steamwar.bausystem.linkage.Linked; import de.steamwar.bausystem.linkage.Linked;
import de.steamwar.core.Core;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.block.BlockFace; import org.bukkit.block.BlockFace;
import org.bukkit.block.data.type.Fence; import org.bukkit.block.data.type.Fence;
import org.bukkit.block.data.type.Wall;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -39,6 +41,50 @@ public class WallBoundingBox implements Enable {
@Override @Override
public void enable() { public void enable() {
if (Core.getVersion() > 15) {
v18();
} else {
v15();
}
}
private void v18() {
for (int nx = 0; nx < 2; nx++) {
for (int nz = 0; nz < 2; nz++) {
for (int px = 0; px < 2; px++) {
for (int pz = 0; pz < 2; pz++) {
Wall fence = (Wall) Material.END_STONE_BRICK_WALL.createBlockData();
List<String> lore = new ArrayList<>();
List<Cuboid> cuboidList = new ArrayList<>();
cuboidList.add(pixelCuboid(4, 0, 4, 8, 24, 8));
if (nz == 1) {
lore.add("LAUFBAU_CONNECTION_NORTH");
fence.setHeight(BlockFace.NORTH, Wall.Height.LOW);
cuboidList.add(pixelCuboid(5, 0, 0, 6, 24, 4));
}
if (pz == 1) {
lore.add("LAUFBAU_CONNECTION_SOUTH");
fence.setHeight(BlockFace.SOUTH, Wall.Height.LOW);
cuboidList.add(pixelCuboid(5, 0, 12, 6, 24, 4));
}
if (nx == 1) {
lore.add("LAUFBAU_CONNECTION_WEST");
fence.setHeight(BlockFace.WEST, Wall.Height.LOW);
cuboidList.add(pixelCuboid(0, 0, 5, 4, 24, 6));
}
if (px == 1) {
lore.add("LAUFBAU_CONNECTION_EAST");
fence.setHeight(BlockFace.EAST, Wall.Height.LOW);
cuboidList.add(pixelCuboid(12, 0, 5, 4, 24, 6));
}
new BlockBoundingBox(fence, cuboidList, createItem("LAUFBAU_BLOCK_END_STONE_BRICK_WALL", Material.END_STONE_BRICK_WALL, lore.toArray(new String[0])));
}
}
}
}
}
private void v15() {
for (int nx = 0; nx < 2; nx++) { for (int nx = 0; nx < 2; nx++) {
for (int nz = 0; nz < 2; nz++) { for (int nz = 0; nz < 2; nz++) {
for (int px = 0; px < 2; px++) { for (int px = 0; px < 2; px++) {

Datei anzeigen

@ -19,12 +19,11 @@
package de.steamwar.bausystem.features.tpslimit; package de.steamwar.bausystem.features.tpslimit;
import com.comphenix.tinyprotocol.Reflection;
import lombok.Getter; import lombok.Getter;
import lombok.experimental.UtilityClass; import lombok.experimental.UtilityClass;
import net.minecraft.server.v1_15_R1.WorldServer;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.craftbukkit.v1_15_R1.CraftWorld;
import yapion.utils.ReflectionsUtils; import yapion.utils.ReflectionsUtils;
import java.lang.reflect.Field; import java.lang.reflect.Field;
@ -35,13 +34,16 @@ public class FreezeUtils {
private static final Field field; private static final Field field;
public static final boolean freezeEnabled; public static final boolean freezeEnabled;
private static final Reflection.MethodInvoker getWorldHandle = Reflection.getTypedMethod(Reflection.getClass("{obc}.CraftWorld"), "getHandle", null);
@Getter @Getter
private static boolean frozen = false; private static boolean frozen = false;
private static final World world; private static final World world;
static { static {
field = ReflectionsUtils.getField(WorldServer.class, "freezed");
field = ReflectionsUtils.getField(Reflection.getClass("{nms.server.level}.WorldServer"), "freezed");
if (field != null) field.setAccessible(true); if (field != null) field.setAccessible(true);
freezeEnabled = field != null; freezeEnabled = field != null;
world = Bukkit.getWorlds().get(0); world = Bukkit.getWorlds().get(0);
@ -62,7 +64,7 @@ public class FreezeUtils {
private void setFreeze(World world, boolean state) { private void setFreeze(World world, boolean state) {
if (freezeEnabled) { if (freezeEnabled) {
try { try {
field.set(((CraftWorld) world).getHandle(), state); field.set(getWorldHandle.invoke(world), state);
frozen = state; frozen = state;
} catch (IllegalAccessException e) { } catch (IllegalAccessException e) {
// Ignored; // Ignored;

Datei anzeigen

@ -23,8 +23,8 @@ import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.features.tracer.TNTPosition; import de.steamwar.bausystem.features.tracer.TNTPosition;
import de.steamwar.bausystem.features.tracer.show.ShowModeParameter; import de.steamwar.bausystem.features.tracer.show.ShowModeParameter;
import de.steamwar.bausystem.shared.ShowMode; import de.steamwar.bausystem.shared.ShowMode;
import de.steamwar.bausystem.utils.NMSWrapper;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Particle;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitTask; import org.bukkit.scheduler.BukkitTask;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
@ -57,7 +57,7 @@ public class ParticleShowMode implements ShowMode<TNTPosition> {
positionSet.add(position.getLocation()); positionSet.add(position.getLocation());
if (bukkitTask == null) { if (bukkitTask == null) {
bukkitTask = Bukkit.getScheduler().runTaskTimer(BauSystem.getInstance(), () -> { bukkitTask = Bukkit.getScheduler().runTaskTimer(BauSystem.getInstance(), () -> {
positionSet.forEach(p -> player.spawnParticle(Particle.BARRIER, p.toLocation(player.getWorld()), 1, 0, 0, 0, 0)); positionSet.forEach(p -> player.spawnParticle(NMSWrapper.impl.tntPositionParticle(), p.toLocation(player.getWorld()), 1, 0, 0, 0, 0));
}, 40L, 40L); }, 40L, 40L);
} }
} }

Datei anzeigen

@ -35,7 +35,7 @@ public class NightVisionCommand extends SWCommand {
super("nightvision", "nv", "light"); super("nightvision", "nv", "light");
} }
@Register(description = "VISION_COMMAND_HELP") @Register(description = "NIGHT_VISION_HELP")
public void genericCommand(Player p) { public void genericCommand(Player p) {
if (p.hasPotionEffect(PotionEffectType.NIGHT_VISION)) { if (p.hasPotionEffect(PotionEffectType.NIGHT_VISION)) {
p.removePotionEffect(PotionEffectType.NIGHT_VISION); p.removePotionEffect(PotionEffectType.NIGHT_VISION);

Datei anzeigen

@ -20,14 +20,13 @@
package de.steamwar.bausystem.features.world; package de.steamwar.bausystem.features.world;
import com.comphenix.tinyprotocol.Reflection; import com.comphenix.tinyprotocol.Reflection;
import com.comphenix.tinyprotocol.TinyProtocol;
import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.linkage.LinkageType; import de.steamwar.bausystem.linkage.LinkageType;
import de.steamwar.bausystem.linkage.Linked; import de.steamwar.bausystem.linkage.Linked;
import de.steamwar.bausystem.utils.ProtocolAPI; import de.steamwar.bausystem.utils.ProtocolAPI;
import net.minecraft.server.v1_15_R1.BlockPosition;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.block.Sign; import org.bukkit.block.Sign;
@ -36,16 +35,23 @@ import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.event.block.Action; import org.bukkit.event.block.Action;
import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.util.Vector;
@Linked(LinkageType.LISTENER) @Linked(LinkageType.LISTENER)
public class SignEdit implements Listener { public class SignEdit implements Listener {
public static final Class<?> openSign = Reflection.getClass("{nms}.PacketPlayOutOpenSignEditor"); private static final Class<?> blockPosition = Reflection.getClass("{nms.core}.BlockPosition");
private static final Reflection.FieldAccessor<net.minecraft.server.v1_15_R1.BlockPosition> blockPositionFieldAccessor = Reflection.getField(openSign, net.minecraft.server.v1_15_R1.BlockPosition.class, 0); private static final Class<?> craftBlock = Reflection.getClass("{obc}.block.CraftBlock");
private static final Class<?> craftWorld = Reflection.getClass("{obc}.CraftWorld");
private static final Class<?> generatorAccess = Reflection.getClass("{nms.world.level}.GeneratorAccess");
private static final Reflection.MethodInvoker getPosition = Reflection.getTypedMethod(craftBlock, "getPosition", blockPosition);
private static final Reflection.MethodInvoker getWorldHandle = Reflection.getTypedMethod(craftWorld, "getHandle", null);
private static final Reflection.MethodInvoker at = Reflection.getTypedMethod(craftBlock, "at", craftBlock, generatorAccess, blockPosition);
public static final Class<?> updateSign = Reflection.getClass("{nms}.PacketPlayInUpdateSign"); private static final Class<?> openSign = Reflection.getClass("{nms.network.protocol.game}.PacketPlayOutOpenSignEditor");
private static final Reflection.FieldAccessor<BlockPosition> getBlockPositionFieldAccessor = Reflection.getField(updateSign, BlockPosition.class, 0); private static final Reflection.FieldAccessor<?> blockPositionFieldAccessor = Reflection.getField(openSign, blockPosition, 0);
private static final Class<?> updateSign = Reflection.getClass("{nms.network.protocol.game}.PacketPlayInUpdateSign");
private static final Reflection.FieldAccessor<?> getBlockPositionFieldAccessor = Reflection.getField(updateSign, blockPosition, 0);
private static final Reflection.FieldAccessor<String[]> stringFieldAccessor = Reflection.getField(updateSign, String[].class, 0); private static final Reflection.FieldAccessor<String[]> stringFieldAccessor = Reflection.getField(updateSign, String[].class, 0);
@EventHandler @EventHandler
@ -66,18 +72,16 @@ public class SignEdit implements Listener {
sign.update(); sign.update();
Object openSignObject = Reflection.newInstance(openSign); Object openSignObject = Reflection.newInstance(openSign);
Vector vector = event.getClickedBlock().getLocation().toVector(); blockPositionFieldAccessor.set(openSignObject, getPosition.invoke(event.getClickedBlock()));
blockPositionFieldAccessor.set(openSignObject, new BlockPosition(vector.getBlockX(), vector.getBlockY(), vector.getBlockZ())); TinyProtocol.instance.sendPacket(player, openSignObject);
ProtocolAPI.tinyProtocol.sendPacket(player, openSignObject);
} }
{ {
ProtocolAPI.setIncomingHandler(updateSign, (player, o) -> { ProtocolAPI.setIncomingHandler(updateSign, (player, o) -> {
Bukkit.getScheduler().runTask(BauSystem.getInstance(), () -> { Bukkit.getScheduler().runTask(BauSystem.getInstance(), () -> {
BlockPosition position = getBlockPositionFieldAccessor.get(o);
String[] lines = stringFieldAccessor.get(o); String[] lines = stringFieldAccessor.get(o);
Block signLoc = new Location(player.getWorld(), position.getX(), position.getY(), position.getZ()).getBlock(); Block signLoc = (Block) at.invoke(null, getWorldHandle.invoke(player.getWorld()), getBlockPositionFieldAccessor.get(o));
if (!signLoc.getType().name().contains("SIGN")) if (!signLoc.getType().name().contains("SIGN"))
return; return;

Datei anzeigen

@ -26,6 +26,8 @@ import de.steamwar.bausystem.features.tracer.AbstractTraceEntity;
import de.steamwar.bausystem.features.warp.AbstractWarpEntity; import de.steamwar.bausystem.features.warp.AbstractWarpEntity;
import de.steamwar.core.VersionDependent; import de.steamwar.core.VersionDependent;
import org.bukkit.GameMode; import org.bukkit.GameMode;
import org.bukkit.Material;
import org.bukkit.Particle;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
@ -45,6 +47,12 @@ public class NMSWrapper {
void createTickCache(World world); void createTickCache(World world);
void sendTickPackets(); void sendTickPackets();
void setGameStateChangeReason(Object packet);
void setPlayerBuildAbilities(Player player);
Particle tntPositionParticle();
Material pathMaterial();
boolean checkItemStack(ItemStack item); boolean checkItemStack(ItemStack item);
AbstractWarpEntity createWarp(World world, Vector position, String name); AbstractWarpEntity createWarp(World world, Vector position, String name);

Datei anzeigen

@ -34,8 +34,6 @@ public class ProtocolAPI {
private static final Map<Class<?>, BiFunction<Player, Object, Object>> outgoingHandler = new HashMap<>(); private static final Map<Class<?>, BiFunction<Player, Object, Object>> outgoingHandler = new HashMap<>();
private static final Map<Class<?>, BiFunction<Player, Object, Object>> incomingHandler = new HashMap<>(); private static final Map<Class<?>, BiFunction<Player, Object, Object>> incomingHandler = new HashMap<>();
public static final TinyProtocol tinyProtocol = TinyProtocol.instance;
static { static {
TinyProtocol.instance.setOutFilter((receiver, channel, packet) -> { TinyProtocol.instance.setOutFilter((receiver, channel, packet) -> {
BiFunction<Player, Object, Object> handler = outgoingHandler.get(packet.getClass()); BiFunction<Player, Object, Object> handler = outgoingHandler.get(packet.getClass());
@ -70,6 +68,6 @@ public class ProtocolAPI {
} }
public static void broadcastPacket(Object packet) { public static void broadcastPacket(Object packet) {
Bukkit.getOnlinePlayers().stream().map(tinyProtocol::getChannel).filter(tinyProtocol::hasInjected).forEach(channel -> tinyProtocol.sendPacket(channel, packet)); Bukkit.getOnlinePlayers().stream().map(TinyProtocol.instance::getChannel).filter(TinyProtocol.instance::hasInjected).forEach(channel -> TinyProtocol.instance.sendPacket(channel, packet));
} }
} }

Datei anzeigen

@ -62,8 +62,8 @@ ext {
compileJava.options.encoding = 'UTF-8' compileJava.options.encoding = 'UTF-8'
compileJava.options.compilerArgs << '-parameter' compileJava.options.compilerArgs << '-parameter'
sourceCompatibility = 1.8 sourceCompatibility = 11
targetCompatibility = 1.8 targetCompatibility = 11
mainClassName = '' mainClassName = ''
@ -75,12 +75,25 @@ allprojects {
maven { maven {
url = uri("https://raw.githubusercontent.com/yoyosource/YAPION/master/releases") url = uri("https://raw.githubusercontent.com/yoyosource/YAPION/master/releases")
} }
maven {
url = uri("https://repo.codemc.io/repository/maven-snapshots/")
}
maven {
url = uri('https://hub.spigotmc.org/nexus/content/repositories/snapshots/')
}
maven {
url = uri('https://libraries.minecraft.net')
}
} }
} }
dependencies { dependencies {
implementation project(":BauSystem_Main") implementation project(":BauSystem_Main")
implementation project(":BauSystem_15") implementation project(":BauSystem_15")
implementation project(":BauSystem_18")
} }
task buildResources(type: Copy) { task buildResources(type: Copy) {

Datei anzeigen

@ -20,4 +20,5 @@
rootProject.name = 'BauSystem2.0' rootProject.name = 'BauSystem2.0'
include 'BauSystem_15' include 'BauSystem_15'
include 'BauSystem_18'
include 'BauSystem_Main' include 'BauSystem_Main'

Datei anzeigen

@ -223,6 +223,12 @@
creator(TheBreadBeard) creator(TheBreadBeard)
schematic(sections4/custom/Prestige AirShip/ASArena.schem) schematic(sections4/custom/Prestige AirShip/ASArena.schem)
testblockSchematic(sections4/custom/Prestige AirShip/ASTestblock.schem) testblockSchematic(sections4/custom/Prestige AirShip/ASTestblock.schem)
},
{
name(Absturz AS)
creator(TheBreadBeard)
schematic(sections4/custom/Absturz AS/ASArena.schem)
testblockSchematic(sections4/custom/Absturz AS/ASTestblock.schem)
} }
] ]
sizeX(121) sizeX(121)