forked from SteamWar/SteamWar
Compare commits
3
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
97935de372 | ||
|
|
5eac6a6c61 | ||
|
|
88742f099d |
@@ -11,9 +11,5 @@ steamwar.properties
|
|||||||
.idea
|
.idea
|
||||||
*.iml
|
*.iml
|
||||||
|
|
||||||
# VSCode
|
|
||||||
bin/
|
|
||||||
.vscode
|
|
||||||
|
|
||||||
# Other
|
# Other
|
||||||
lib
|
lib
|
||||||
@@ -27,8 +27,8 @@ java {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compileOnly(project(":BauSystem:BauSystem_Main", "default"))
|
compileOnly(project(":BauSystem:BauSystem_Main"))
|
||||||
compileOnly(project(":SpigotCore", "default"))
|
compileOnly(project(":SpigotCore"))
|
||||||
|
|
||||||
compileOnly(libs.nms15)
|
compileOnly(libs.nms15)
|
||||||
compileOnly(libs.worldedit15)
|
compileOnly(libs.worldedit15)
|
||||||
|
|||||||
@@ -19,21 +19,27 @@
|
|||||||
|
|
||||||
package de.steamwar.bausystem.utils;
|
package de.steamwar.bausystem.utils;
|
||||||
|
|
||||||
import de.steamwar.Reflection;
|
import com.comphenix.tinyprotocol.Reflection;
|
||||||
import de.steamwar.bausystem.features.util.NoClipCommand;
|
import de.steamwar.bausystem.features.util.NoClipCommand;
|
||||||
import net.minecraft.server.v1_15_R1.*;
|
import net.minecraft.server.v1_15_R1.*;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.GameMode;
|
import org.bukkit.GameMode;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
|
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.entity.CraftPlayer;
|
||||||
import org.bukkit.craftbukkit.v1_15_R1.inventory.CraftItemStack;
|
import org.bukkit.craftbukkit.v1_15_R1.inventory.CraftItemStack;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.entity.TNTPrimed;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.function.LongSupplier;
|
||||||
|
|
||||||
public class NMSWrapper15 implements NMSWrapper {
|
public class NMSWrapper15 implements NMSWrapper {
|
||||||
|
|
||||||
private static final Reflection.Field<EnumGamemode> playerGameMode = Reflection.getField(PlayerInteractManager.class, EnumGamemode.class, 0);
|
private static final Reflection.FieldAccessor<EnumGamemode> playerGameMode = Reflection.getField(PlayerInteractManager.class, EnumGamemode.class, 0);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
@@ -57,7 +63,7 @@ public class NMSWrapper15 implements NMSWrapper {
|
|||||||
player.updateInventory();
|
player.updateInventory();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final Reflection.Field<Integer> gameStateChangeReason = Reflection.getField(NoClipCommand.gameStateChange, int.class, 0);
|
private static final Reflection.FieldAccessor<Integer> gameStateChangeReason = Reflection.getField(NoClipCommand.gameStateChange, int.class, 0);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setGameStateChangeReason(Object packet) {
|
public void setGameStateChangeReason(Object packet) {
|
||||||
@@ -114,12 +120,12 @@ public class NMSWrapper15 implements NMSWrapper {
|
|||||||
return invalid;
|
return invalid;
|
||||||
}
|
}
|
||||||
|
|
||||||
private final Class<?> explosionPacket = Reflection.getClass("net.minecraft.network.protocol.game.ClientboundExplodePacket");
|
private final Class<?> explosionPacket = Reflection.getClass("{nms.network.protocol.game}.PacketPlayOutExplosion");
|
||||||
private final Reflection.Field<Double> a = Reflection.getField(explosionPacket, double.class, 0);
|
private final Reflection.FieldAccessor<Double> a = Reflection.getField(explosionPacket, double.class, 0);
|
||||||
private final Reflection.Field<Double> b = Reflection.getField(explosionPacket, double.class, 1);
|
private final Reflection.FieldAccessor<Double> b = Reflection.getField(explosionPacket, double.class, 1);
|
||||||
private final Reflection.Field<Double> c = Reflection.getField(explosionPacket, double.class, 2);
|
private final Reflection.FieldAccessor<Double> c = Reflection.getField(explosionPacket, double.class, 2);
|
||||||
private final Reflection.Field<Float> d = Reflection.getField(explosionPacket, float.class, 0);
|
private final Reflection.FieldAccessor<Float> d = Reflection.getField(explosionPacket, float.class, 0);
|
||||||
private final Reflection.Field<List> e = Reflection.getField(explosionPacket, List.class, 0);
|
private final Reflection.FieldAccessor<List> e = Reflection.getField(explosionPacket, List.class, 0);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object resetExplosionKnockback(Object packet) {
|
public Object resetExplosionKnockback(Object packet) {
|
||||||
|
|||||||
+12
-4
@@ -19,9 +19,12 @@
|
|||||||
|
|
||||||
package de.steamwar.bausystem.utils;
|
package de.steamwar.bausystem.utils;
|
||||||
|
|
||||||
import de.steamwar.Reflection;
|
import com.comphenix.tinyprotocol.Reflection;
|
||||||
|
import de.steamwar.bausystem.utils.PlayerMovementWrapper;
|
||||||
import net.minecraft.server.v1_15_R1.EntityPlayer;
|
import net.minecraft.server.v1_15_R1.EntityPlayer;
|
||||||
import net.minecraft.server.v1_15_R1.PacketPlayInFlying;
|
import net.minecraft.server.v1_15_R1.PacketPlayInFlying;
|
||||||
|
import net.minecraft.server.v1_15_R1.PacketPlayOutEntity;
|
||||||
|
import net.minecraft.server.v1_15_R1.PacketPlayOutEntityTeleport;
|
||||||
import org.bukkit.craftbukkit.v1_15_R1.entity.CraftPlayer;
|
import org.bukkit.craftbukkit.v1_15_R1.entity.CraftPlayer;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@@ -43,9 +46,14 @@ public class PlayerMovementWrapper15 implements PlayerMovementWrapper {
|
|||||||
PacketPlayInFlying packetPlayInFlying = ((PacketPlayInFlying) object);
|
PacketPlayInFlying packetPlayInFlying = ((PacketPlayInFlying) object);
|
||||||
Object packet = Reflection.newInstance(teleportPacket);
|
Object packet = Reflection.newInstance(teleportPacket);
|
||||||
teleportEntity.set(packet, player.getEntityId());
|
teleportEntity.set(packet, player.getEntityId());
|
||||||
teleportPosition.set(packet, packetPlayInFlying.a(0.0), packetPlayInFlying.b(0.0), packetPlayInFlying.c(0.0),
|
teleportPosition.set(packet, packetPlayInFlying.a(0.0), packetPlayInFlying.b(0.0), packetPlayInFlying.c(0.0));
|
||||||
Float.isNaN(packetPlayInFlying.a(Float.NaN)) ? player.getLocation().getYaw() : packetPlayInFlying.a(0.0F),
|
if (Float.isNaN(packetPlayInFlying.a(Float.NaN))) {
|
||||||
Float.isNaN(packetPlayInFlying.b(Float.NaN)) ? player.getLocation().getPitch() : packetPlayInFlying.b(0.0F));
|
teleportYaw.set(packet, rotToByte(player.getLocation().getYaw()));
|
||||||
|
teleportPitch.set(packet, rotToByte(player.getLocation().getPitch()));
|
||||||
|
} else {
|
||||||
|
teleportYaw.set(packet, rotToByte(packetPlayInFlying.a(0.0F)));
|
||||||
|
teleportPitch.set(packet, rotToByte(packetPlayInFlying.b(0.0F)));
|
||||||
|
}
|
||||||
return packet;
|
return packet;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,8 +27,8 @@ java {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compileOnly(project(":BauSystem:BauSystem_Main", "default"))
|
compileOnly(project(":BauSystem:BauSystem_Main"))
|
||||||
compileOnly(project(":SpigotCore", "default"))
|
compileOnly(project(":SpigotCore"))
|
||||||
|
|
||||||
compileOnly(libs.spigotapi)
|
compileOnly(libs.spigotapi)
|
||||||
compileOnly(libs.nms18)
|
compileOnly(libs.nms18)
|
||||||
|
|||||||
@@ -19,26 +19,36 @@
|
|||||||
|
|
||||||
package de.steamwar.bausystem.utils;
|
package de.steamwar.bausystem.utils;
|
||||||
|
|
||||||
import de.steamwar.Reflection;
|
import com.comphenix.tinyprotocol.Reflection;
|
||||||
|
import com.comphenix.tinyprotocol.TinyProtocol;
|
||||||
import de.steamwar.bausystem.features.util.NoClipCommand;
|
import de.steamwar.bausystem.features.util.NoClipCommand;
|
||||||
|
import net.minecraft.SystemUtils;
|
||||||
import net.minecraft.nbt.NBTBase;
|
import net.minecraft.nbt.NBTBase;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
import net.minecraft.nbt.NBTTagList;
|
import net.minecraft.nbt.NBTTagList;
|
||||||
|
import net.minecraft.network.protocol.Packet;
|
||||||
import net.minecraft.network.protocol.game.*;
|
import net.minecraft.network.protocol.game.*;
|
||||||
import net.minecraft.server.level.PlayerInteractManager;
|
import net.minecraft.server.level.PlayerInteractManager;
|
||||||
import net.minecraft.world.level.EnumGamemode;
|
import net.minecraft.world.level.EnumGamemode;
|
||||||
|
import net.minecraft.world.phys.Vec3D;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.GameMode;
|
import org.bukkit.GameMode;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.World;
|
||||||
|
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.entity.CraftPlayer;
|
||||||
import org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack;
|
import org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.entity.TNTPrimed;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.function.LongSupplier;
|
||||||
|
|
||||||
public class NMSWrapper18 implements NMSWrapper {
|
public class NMSWrapper18 implements NMSWrapper {
|
||||||
|
|
||||||
private static final Reflection.Field<EnumGamemode> playerGameMode = Reflection.getField(PlayerInteractManager.class, EnumGamemode.class, 0);
|
private static final Reflection.FieldAccessor<EnumGamemode> playerGameMode = Reflection.getField(PlayerInteractManager.class, EnumGamemode.class, 0);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
@@ -63,7 +73,7 @@ public class NMSWrapper18 implements NMSWrapper {
|
|||||||
player.updateInventory();
|
player.updateInventory();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final Reflection.Field<PacketPlayOutGameStateChange.a> gameStateChangeReason = Reflection.getField(NoClipCommand.gameStateChange, PacketPlayOutGameStateChange.a.class, 12);
|
private static final Reflection.FieldAccessor<PacketPlayOutGameStateChange.a> gameStateChangeReason = Reflection.getField(NoClipCommand.gameStateChange, PacketPlayOutGameStateChange.a.class, 12);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setGameStateChangeReason(Object packet) {
|
public void setGameStateChangeReason(Object packet) {
|
||||||
@@ -120,12 +130,12 @@ public class NMSWrapper18 implements NMSWrapper {
|
|||||||
return invalid;
|
return invalid;
|
||||||
}
|
}
|
||||||
|
|
||||||
private final Class<?> explosionPacket = Reflection.getClass("net.minecraft.network.protocol.game.ClientboundExplodePacket");
|
private final Class<?> explosionPacket = Reflection.getClass("{nms.network.protocol.game}.PacketPlayOutExplosion");
|
||||||
private final Reflection.Field<Double> a = Reflection.getField(explosionPacket, double.class, 0);
|
private final Reflection.FieldAccessor<Double> a = Reflection.getField(explosionPacket, double.class, 0);
|
||||||
private final Reflection.Field<Double> b = Reflection.getField(explosionPacket, double.class, 1);
|
private final Reflection.FieldAccessor<Double> b = Reflection.getField(explosionPacket, double.class, 1);
|
||||||
private final Reflection.Field<Double> c = Reflection.getField(explosionPacket, double.class, 2);
|
private final Reflection.FieldAccessor<Double> c = Reflection.getField(explosionPacket, double.class, 2);
|
||||||
private final Reflection.Field<Float> d = Reflection.getField(explosionPacket, float.class, 0);
|
private final Reflection.FieldAccessor<Float> d = Reflection.getField(explosionPacket, float.class, 0);
|
||||||
private final Reflection.Field<List> e = Reflection.getField(explosionPacket, List.class, 0);
|
private final Reflection.FieldAccessor<List> e = Reflection.getField(explosionPacket, List.class, 0);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object resetExplosionKnockback(Object packet) {
|
public Object resetExplosionKnockback(Object packet) {
|
||||||
|
|||||||
+10
-4
@@ -19,7 +19,8 @@
|
|||||||
|
|
||||||
package de.steamwar.bausystem.utils;
|
package de.steamwar.bausystem.utils;
|
||||||
|
|
||||||
import de.steamwar.Reflection;
|
import com.comphenix.tinyprotocol.Reflection;
|
||||||
|
import de.steamwar.bausystem.utils.PlayerMovementWrapper;
|
||||||
import net.minecraft.network.protocol.game.PacketPlayInFlying;
|
import net.minecraft.network.protocol.game.PacketPlayInFlying;
|
||||||
import net.minecraft.server.level.EntityPlayer;
|
import net.minecraft.server.level.EntityPlayer;
|
||||||
import org.bukkit.craftbukkit.v1_18_R2.entity.CraftPlayer;
|
import org.bukkit.craftbukkit.v1_18_R2.entity.CraftPlayer;
|
||||||
@@ -43,9 +44,14 @@ public class PlayerMovementWrapper18 implements PlayerMovementWrapper {
|
|||||||
PacketPlayInFlying packetPlayInFlying = ((PacketPlayInFlying) object);
|
PacketPlayInFlying packetPlayInFlying = ((PacketPlayInFlying) object);
|
||||||
Object packet = Reflection.newInstance(teleportPacket);
|
Object packet = Reflection.newInstance(teleportPacket);
|
||||||
teleportEntity.set(packet, player.getEntityId());
|
teleportEntity.set(packet, player.getEntityId());
|
||||||
teleportPosition.set(packet, packetPlayInFlying.a, packetPlayInFlying.b, packetPlayInFlying.c,
|
teleportPosition.set(packet, packetPlayInFlying.a, packetPlayInFlying.b, packetPlayInFlying.c);
|
||||||
packetPlayInFlying.h ? player.getLocation().getYaw() : packetPlayInFlying.d,
|
if (packetPlayInFlying.h) {
|
||||||
packetPlayInFlying.h ? player.getLocation().getPitch() : packetPlayInFlying.e);
|
teleportYaw.set(packet, rotToByte(player.getLocation().getYaw()));
|
||||||
|
teleportPitch.set(packet, rotToByte(player.getLocation().getPitch()));
|
||||||
|
} else {
|
||||||
|
teleportYaw.set(packet, rotToByte(packetPlayInFlying.d));
|
||||||
|
teleportPitch.set(packet, rotToByte(packetPlayInFlying.e));
|
||||||
|
}
|
||||||
return packet;
|
return packet;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,8 +27,8 @@ java {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compileOnly(project(":BauSystem:BauSystem_Main", "default"))
|
compileOnly(project(":BauSystem:BauSystem_Main"))
|
||||||
compileOnly(project(":SpigotCore", "default"))
|
compileOnly(project(":SpigotCore"))
|
||||||
|
|
||||||
compileOnly(libs.spigotapi)
|
compileOnly(libs.spigotapi)
|
||||||
compileOnly(libs.paperapi)
|
compileOnly(libs.paperapi)
|
||||||
|
|||||||
@@ -19,26 +19,37 @@
|
|||||||
|
|
||||||
package de.steamwar.bausystem.utils;
|
package de.steamwar.bausystem.utils;
|
||||||
|
|
||||||
import de.steamwar.Reflection;
|
import com.comphenix.tinyprotocol.Reflection;
|
||||||
|
import com.comphenix.tinyprotocol.TinyProtocol;
|
||||||
import de.steamwar.bausystem.features.util.NoClipCommand;
|
import de.steamwar.bausystem.features.util.NoClipCommand;
|
||||||
|
import net.minecraft.SystemUtils;
|
||||||
import net.minecraft.nbt.NBTBase;
|
import net.minecraft.nbt.NBTBase;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
import net.minecraft.nbt.NBTTagList;
|
import net.minecraft.nbt.NBTTagList;
|
||||||
|
import net.minecraft.network.protocol.Packet;
|
||||||
import net.minecraft.network.protocol.game.*;
|
import net.minecraft.network.protocol.game.*;
|
||||||
|
import net.minecraft.network.syncher.DataWatcher;
|
||||||
import net.minecraft.server.level.PlayerInteractManager;
|
import net.minecraft.server.level.PlayerInteractManager;
|
||||||
import net.minecraft.world.level.EnumGamemode;
|
import net.minecraft.world.level.EnumGamemode;
|
||||||
|
import net.minecraft.world.phys.Vec3D;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.GameMode;
|
import org.bukkit.GameMode;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.craftbukkit.v1_19_R2.entity.CraftEntity;
|
||||||
import org.bukkit.craftbukkit.v1_19_R2.entity.CraftPlayer;
|
import org.bukkit.craftbukkit.v1_19_R2.entity.CraftPlayer;
|
||||||
import org.bukkit.craftbukkit.v1_19_R2.inventory.CraftItemStack;
|
import org.bukkit.craftbukkit.v1_19_R2.inventory.CraftItemStack;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.entity.TNTPrimed;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.function.LongSupplier;
|
||||||
|
|
||||||
public class NMSWrapper19 implements NMSWrapper {
|
public class NMSWrapper19 implements NMSWrapper {
|
||||||
|
|
||||||
private static final Reflection.Field<EnumGamemode> playerGameMode = Reflection.getField(PlayerInteractManager.class, EnumGamemode.class, 0);
|
private static final Reflection.FieldAccessor<EnumGamemode> playerGameMode = Reflection.getField(PlayerInteractManager.class, EnumGamemode.class, 0);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
@@ -62,7 +73,7 @@ public class NMSWrapper19 implements NMSWrapper {
|
|||||||
player.updateInventory();
|
player.updateInventory();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final Reflection.Field<PacketPlayOutGameStateChange.a> gameStateChangeReason = Reflection.getField(NoClipCommand.gameStateChange, PacketPlayOutGameStateChange.a.class, 12);
|
private static final Reflection.FieldAccessor<PacketPlayOutGameStateChange.a> gameStateChangeReason = Reflection.getField(NoClipCommand.gameStateChange, PacketPlayOutGameStateChange.a.class, 12);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setGameStateChangeReason(Object packet) {
|
public void setGameStateChangeReason(Object packet) {
|
||||||
@@ -119,12 +130,12 @@ public class NMSWrapper19 implements NMSWrapper {
|
|||||||
return invalid;
|
return invalid;
|
||||||
}
|
}
|
||||||
|
|
||||||
private final Class<?> explosionPacket = Reflection.getClass("net.minecraft.network.protocol.game.ClientboundExplodePacket");
|
private final Class<?> explosionPacket = Reflection.getClass("{nms.network.protocol.game}.PacketPlayOutExplosion");
|
||||||
private final Reflection.Field<Double> a = Reflection.getField(explosionPacket, double.class, 0);
|
private final Reflection.FieldAccessor<Double> a = Reflection.getField(explosionPacket, double.class, 0);
|
||||||
private final Reflection.Field<Double> b = Reflection.getField(explosionPacket, double.class, 1);
|
private final Reflection.FieldAccessor<Double> b = Reflection.getField(explosionPacket, double.class, 1);
|
||||||
private final Reflection.Field<Double> c = Reflection.getField(explosionPacket, double.class, 2);
|
private final Reflection.FieldAccessor<Double> c = Reflection.getField(explosionPacket, double.class, 2);
|
||||||
private final Reflection.Field<Float> d = Reflection.getField(explosionPacket, float.class, 0);
|
private final Reflection.FieldAccessor<Float> d = Reflection.getField(explosionPacket, float.class, 0);
|
||||||
private final Reflection.Field<List> e = Reflection.getField(explosionPacket, List.class, 0);
|
private final Reflection.FieldAccessor<List> e = Reflection.getField(explosionPacket, List.class, 0);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object resetExplosionKnockback(Object packet) {
|
public Object resetExplosionKnockback(Object packet) {
|
||||||
|
|||||||
+14
-4
@@ -19,12 +19,17 @@
|
|||||||
|
|
||||||
package de.steamwar.bausystem.utils;
|
package de.steamwar.bausystem.utils;
|
||||||
|
|
||||||
import de.steamwar.Reflection;
|
import com.comphenix.tinyprotocol.Reflection;
|
||||||
import net.minecraft.network.protocol.game.PacketPlayInFlying;
|
import net.minecraft.network.protocol.game.PacketPlayInFlying;
|
||||||
import net.minecraft.server.level.EntityPlayer;
|
import net.minecraft.server.level.EntityPlayer;
|
||||||
|
import org.bukkit.Location;
|
||||||
import org.bukkit.craftbukkit.v1_19_R2.entity.CraftPlayer;
|
import org.bukkit.craftbukkit.v1_19_R2.entity.CraftPlayer;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
public class PlayerMovementWrapper19 implements PlayerMovementWrapper {
|
public class PlayerMovementWrapper19 implements PlayerMovementWrapper {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -43,9 +48,14 @@ public class PlayerMovementWrapper19 implements PlayerMovementWrapper {
|
|||||||
PacketPlayInFlying packetPlayInFlying = ((PacketPlayInFlying) object);
|
PacketPlayInFlying packetPlayInFlying = ((PacketPlayInFlying) object);
|
||||||
Object packet = Reflection.newInstance(teleportPacket);
|
Object packet = Reflection.newInstance(teleportPacket);
|
||||||
teleportEntity.set(packet, player.getEntityId());
|
teleportEntity.set(packet, player.getEntityId());
|
||||||
teleportPosition.set(packet, packetPlayInFlying.a, packetPlayInFlying.b, packetPlayInFlying.c,
|
teleportPosition.set(packet, packetPlayInFlying.a, packetPlayInFlying.b, packetPlayInFlying.c);
|
||||||
packetPlayInFlying.h ? player.getLocation().getYaw() : packetPlayInFlying.d,
|
if (packetPlayInFlying.h) {
|
||||||
packetPlayInFlying.h ? player.getLocation().getPitch() : packetPlayInFlying.e);
|
teleportYaw.set(packet, rotToByte(player.getLocation().getYaw()));
|
||||||
|
teleportPitch.set(packet, rotToByte(player.getLocation().getPitch()));
|
||||||
|
} else {
|
||||||
|
teleportYaw.set(packet, rotToByte(packetPlayInFlying.d));
|
||||||
|
teleportPitch.set(packet, rotToByte(packetPlayInFlying.e));
|
||||||
|
}
|
||||||
return packet;
|
return packet;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,8 +27,8 @@ java {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compileOnly(project(":BauSystem:BauSystem_Main", "default"))
|
compileOnly(project(":BauSystem:BauSystem_Main"))
|
||||||
compileOnly(project(":SpigotCore", "default"))
|
compileOnly(project(":SpigotCore"))
|
||||||
|
|
||||||
compileOnly(libs.spigotapi)
|
compileOnly(libs.spigotapi)
|
||||||
|
|
||||||
|
|||||||
@@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
package de.steamwar.bausystem.utils;
|
package de.steamwar.bausystem.utils;
|
||||||
|
|
||||||
import de.steamwar.Reflection;
|
import com.comphenix.tinyprotocol.Reflection;
|
||||||
import de.steamwar.bausystem.features.util.NoClipCommand;
|
import de.steamwar.bausystem.features.util.NoClipCommand;
|
||||||
import net.minecraft.nbt.NBTBase;
|
import net.minecraft.nbt.NBTBase;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
@@ -40,7 +40,7 @@ import java.util.List;
|
|||||||
|
|
||||||
public class NMSWrapper20 implements NMSWrapper {
|
public class NMSWrapper20 implements NMSWrapper {
|
||||||
|
|
||||||
private static final Reflection.Field<EnumGamemode> playerGameMode = Reflection.getField(PlayerInteractManager.class, EnumGamemode.class, 0);
|
private static final Reflection.FieldAccessor<EnumGamemode> playerGameMode = Reflection.getField(PlayerInteractManager.class, EnumGamemode.class, 0);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
@@ -64,7 +64,7 @@ public class NMSWrapper20 implements NMSWrapper {
|
|||||||
player.updateInventory();
|
player.updateInventory();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final Reflection.Field<PacketPlayOutGameStateChange.a> gameStateChangeReason = Reflection.getField(NoClipCommand.gameStateChange, PacketPlayOutGameStateChange.a.class, 12);
|
private static final Reflection.FieldAccessor<PacketPlayOutGameStateChange.a> gameStateChangeReason = Reflection.getField(NoClipCommand.gameStateChange, PacketPlayOutGameStateChange.a.class, 12);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setGameStateChangeReason(Object packet) {
|
public void setGameStateChangeReason(Object packet) {
|
||||||
@@ -121,12 +121,12 @@ public class NMSWrapper20 implements NMSWrapper {
|
|||||||
return invalid;
|
return invalid;
|
||||||
}
|
}
|
||||||
|
|
||||||
private final Class<?> explosionPacket = Reflection.getClass("net.minecraft.network.protocol.game.ClientboundExplodePacket");
|
private final Class<?> explosionPacket = Reflection.getClass("{nms.network.protocol.game}.PacketPlayOutExplosion");
|
||||||
private final Reflection.Field<Double> a = Reflection.getField(explosionPacket, double.class, 0);
|
private final Reflection.FieldAccessor<Double> a = Reflection.getField(explosionPacket, double.class, 0);
|
||||||
private final Reflection.Field<Double> b = Reflection.getField(explosionPacket, double.class, 1);
|
private final Reflection.FieldAccessor<Double> b = Reflection.getField(explosionPacket, double.class, 1);
|
||||||
private final Reflection.Field<Double> c = Reflection.getField(explosionPacket, double.class, 2);
|
private final Reflection.FieldAccessor<Double> c = Reflection.getField(explosionPacket, double.class, 2);
|
||||||
private final Reflection.Field<Float> d = Reflection.getField(explosionPacket, float.class, 0);
|
private final Reflection.FieldAccessor<Float> d = Reflection.getField(explosionPacket, float.class, 0);
|
||||||
private final Reflection.Field<List> e = Reflection.getField(explosionPacket, List.class, 0);
|
private final Reflection.FieldAccessor<List> e = Reflection.getField(explosionPacket, List.class, 0);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object resetExplosionKnockback(Object packet) {
|
public Object resetExplosionKnockback(Object packet) {
|
||||||
|
|||||||
+15
-4
@@ -19,12 +19,18 @@
|
|||||||
|
|
||||||
package de.steamwar.bausystem.utils;
|
package de.steamwar.bausystem.utils;
|
||||||
|
|
||||||
import de.steamwar.Reflection;
|
import com.comphenix.tinyprotocol.Reflection;
|
||||||
import net.minecraft.network.protocol.game.PacketPlayInFlying;
|
import net.minecraft.network.protocol.game.PacketPlayInFlying;
|
||||||
|
import net.minecraft.network.protocol.game.PacketPlayOutEntityTeleport;
|
||||||
import net.minecraft.server.level.EntityPlayer;
|
import net.minecraft.server.level.EntityPlayer;
|
||||||
|
import org.bukkit.Location;
|
||||||
import org.bukkit.craftbukkit.v1_20_R1.entity.CraftPlayer;
|
import org.bukkit.craftbukkit.v1_20_R1.entity.CraftPlayer;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
public class PlayerMovementWrapper20 implements PlayerMovementWrapper {
|
public class PlayerMovementWrapper20 implements PlayerMovementWrapper {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -43,9 +49,14 @@ public class PlayerMovementWrapper20 implements PlayerMovementWrapper {
|
|||||||
PacketPlayInFlying packetPlayInFlying = ((PacketPlayInFlying) object);
|
PacketPlayInFlying packetPlayInFlying = ((PacketPlayInFlying) object);
|
||||||
Object packet = Reflection.newInstance(teleportPacket);
|
Object packet = Reflection.newInstance(teleportPacket);
|
||||||
teleportEntity.set(packet, player.getEntityId());
|
teleportEntity.set(packet, player.getEntityId());
|
||||||
teleportPosition.set(packet, packetPlayInFlying.a, packetPlayInFlying.b, packetPlayInFlying.c,
|
teleportPosition.set(packet, packetPlayInFlying.a, packetPlayInFlying.b, packetPlayInFlying.c);
|
||||||
packetPlayInFlying.h ? player.getLocation().getYaw() : packetPlayInFlying.d,
|
if (packetPlayInFlying.h) {
|
||||||
packetPlayInFlying.h ? player.getLocation().getPitch() : packetPlayInFlying.e);
|
teleportYaw.set(packet, rotToByte(player.getLocation().getYaw()));
|
||||||
|
teleportPitch.set(packet, rotToByte(player.getLocation().getPitch()));
|
||||||
|
} else {
|
||||||
|
teleportYaw.set(packet, rotToByte(packetPlayInFlying.d));
|
||||||
|
teleportPitch.set(packet, rotToByte(packetPlayInFlying.e));
|
||||||
|
}
|
||||||
return packet;
|
return packet;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,17 +0,0 @@
|
|||||||
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)
|
|
||||||
}
|
|
||||||
@@ -1,141 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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 de.steamwar.Reflection;
|
|
||||||
import de.steamwar.bausystem.features.util.NoClipCommand;
|
|
||||||
import net.minecraft.core.component.DataComponents;
|
|
||||||
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.server.level.EntityPlayer;
|
|
||||||
import net.minecraft.server.level.PlayerInteractManager;
|
|
||||||
import net.minecraft.world.entity.player.EntityHuman;
|
|
||||||
import net.minecraft.world.entity.player.PlayerAbilities;
|
|
||||||
import net.minecraft.world.item.component.CustomData;
|
|
||||||
import net.minecraft.world.level.EnumGamemode;
|
|
||||||
import org.bukkit.GameMode;
|
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.craftbukkit.v1_21_R2.entity.CraftPlayer;
|
|
||||||
import org.bukkit.craftbukkit.v1_21_R2.inventory.CraftItemStack;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
|
||||||
|
|
||||||
import java.util.Optional;
|
|
||||||
|
|
||||||
public class NMSWrapper21 implements NMSWrapper {
|
|
||||||
|
|
||||||
private static final Reflection.Field<PlayerInteractManager> playerInteractManager = Reflection.getField(EntityPlayer.class, null, PlayerInteractManager.class);
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setInternalGameMode(Player player, GameMode gameMode) {
|
|
||||||
playerInteractManager.get(((CraftPlayer) player).getHandle()).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.Field<PacketPlayOutGameStateChange.a> gameStateChangeReason = Reflection.getField(NoClipCommand.gameStateChange, PacketPlayOutGameStateChange.a.class, 12);
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setGameStateChangeReason(Object packet) {
|
|
||||||
gameStateChangeReason.set(packet, PacketPlayOutGameStateChange.d);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static final Reflection.Field<PlayerAbilities> playerAbilities = Reflection.getField(EntityHuman.class, null, PlayerAbilities.class);
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setPlayerBuildAbilities(Player player) {
|
|
||||||
PlayerAbilities abilities = playerAbilities.get(((CraftPlayer) player).getHandle());
|
|
||||||
abilities.d = true;
|
|
||||||
abilities.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;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object resetExplosionKnockback(Object packet) {
|
|
||||||
PacketPlayOutExplosion explosion = (PacketPlayOutExplosion) packet;
|
|
||||||
|
|
||||||
return new PacketPlayOutExplosion(
|
|
||||||
explosion.b(),
|
|
||||||
Optional.empty(),
|
|
||||||
explosion.f(),
|
|
||||||
explosion.g()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -33,12 +33,14 @@ java {
|
|||||||
dependencies {
|
dependencies {
|
||||||
compileOnly(libs.classindex)
|
compileOnly(libs.classindex)
|
||||||
annotationProcessor(libs.classindex)
|
annotationProcessor(libs.classindex)
|
||||||
compileOnly(project(":SpigotCore", "default"))
|
compileOnly(project(":SpigotCore"))
|
||||||
|
|
||||||
compileOnly(libs.spigotapi)
|
compileOnly(libs.spigotapi)
|
||||||
compileOnly(libs.axiom)
|
compileOnly(libs.axiom)
|
||||||
compileOnly(libs.authlib)
|
compileOnly(libs.authlib)
|
||||||
|
compileOnly(libs.viaapi)
|
||||||
|
|
||||||
|
compileOnly(libs.nms20)
|
||||||
compileOnly(libs.fawe18)
|
compileOnly(libs.fawe18)
|
||||||
|
|
||||||
implementation(libs.luaj)
|
implementation(libs.luaj)
|
||||||
|
|||||||
@@ -271,7 +271,6 @@ SIMULATOR_CHANGE_HELP=§8/§esimulator change §8-§7 Change your simulator wand
|
|||||||
SIMULATOR_DELETE_HELP=§8/§esimulator delete §8[§7name§8] §8-§7 Deletes the simulator
|
SIMULATOR_DELETE_HELP=§8/§esimulator delete §8[§7name§8] §8-§7 Deletes the simulator
|
||||||
SIMULATOR_START_HELP=§8/§esimulator start §8[§7name§8] §8-§7 Starts the simulator
|
SIMULATOR_START_HELP=§8/§esimulator start §8[§7name§8] §8-§7 Starts the simulator
|
||||||
SIMULATOR_COPY_HELP=§8/§esimulator copy §8[§7to-copy§8] §8[§7name§8] §8-§7 Copy the simulator
|
SIMULATOR_COPY_HELP=§8/§esimulator copy §8[§7to-copy§8] §8[§7name§8] §8-§7 Copy the simulator
|
||||||
SIMULATOR_RENAME_HELP=§8/§esimulator rename §8[§7to-rename§8] §8[§7name§8] §8-§7 Rename the simulator
|
|
||||||
SIMULATOR_GUI_ITEM_NAME=§eTNT Simulator
|
SIMULATOR_GUI_ITEM_NAME=§eTNT Simulator
|
||||||
SIMULATOR_NO_SIM_IN_HAND=§cNo simulator item selected
|
SIMULATOR_NO_SIM_IN_HAND=§cNo simulator item selected
|
||||||
SIMULATOR_GUI_SELECT_SIM=Simulator selection
|
SIMULATOR_GUI_SELECT_SIM=Simulator selection
|
||||||
@@ -308,7 +307,6 @@ SIMULATOR_POSITION_Z=§7z-Position
|
|||||||
SIMULATOR_BACK=§eBack
|
SIMULATOR_BACK=§eBack
|
||||||
SIMULATOR_GUI_TOTAL_TNT=§7Total TNT§8: §e{0}
|
SIMULATOR_GUI_TOTAL_TNT=§7Total TNT§8: §e{0}
|
||||||
SIMULATOR_DELETED=§cSimulator deleted
|
SIMULATOR_DELETED=§cSimulator deleted
|
||||||
SIMULATOR_RENAMED=§cSimulator renamed from {0} to {1}
|
|
||||||
## GUI
|
## GUI
|
||||||
SIMULATOR_POSITION_EDIT=§eEdit position
|
SIMULATOR_POSITION_EDIT=§eEdit position
|
||||||
SIMULATOR_POSITION_ADD=§eSet position
|
SIMULATOR_POSITION_ADD=§eSet position
|
||||||
@@ -406,8 +404,6 @@ BLOCK_COUNTER_MESSAGE_SECOND=§7Damage §8> §e{0} §7Blocks §e{1} §7TNT §e
|
|||||||
BLOCK_COUNTER_ENABLE=§7BlockCounter activated
|
BLOCK_COUNTER_ENABLE=§7BlockCounter activated
|
||||||
BLOCK_COUNTER_DISABLE=§7BlockCounter deactivated
|
BLOCK_COUNTER_DISABLE=§7BlockCounter deactivated
|
||||||
# DepthCounter
|
# DepthCounter
|
||||||
DEPTH_COUNTER_DISABLE=§7Depth Counter disabled
|
|
||||||
DEPTH_COUNTER_ENABLE=§7Depth Counter enabled
|
|
||||||
DEPTH_COUNTER_MESSAGE=§7Depth §8> §7
|
DEPTH_COUNTER_MESSAGE=§7Depth §8> §7
|
||||||
DEPTH_COUNTER_COUNT={0}{1}§8×{2}{3}§8×{4}{5}
|
DEPTH_COUNTER_COUNT={0}{1}§8×{2}{3}§8×{4}{5}
|
||||||
DEPTH_COUNTER_HOVER=§7X§8×§7Y§8×§7Z
|
DEPTH_COUNTER_HOVER=§7X§8×§7Y§8×§7Z
|
||||||
@@ -1015,4 +1011,6 @@ XRAY_OFF=§cXray deactivated
|
|||||||
COLORREPLACE_HELP=§8//§ecolorreplace §8[§7color§8] §8[§7color§8] §8- §7Replace all blocks of one color with another
|
COLORREPLACE_HELP=§8//§ecolorreplace §8[§7color§8] §8[§7color§8] §8- §7Replace all blocks of one color with another
|
||||||
TYPEREPLACE_HELP=§8//§etypereplace §8[§7type§8] §8[§7type§8] §8- §7Replace all blocks of one type with another
|
TYPEREPLACE_HELP=§8//§etypereplace §8[§7type§8] §8[§7type§8] §8- §7Replace all blocks of one type with another
|
||||||
# Schematic
|
# Schematic
|
||||||
SCHEMATIC_GUI_ITEM=§eSchematics
|
SCHEMATIC_GUI_ITEM=§eSchematics
|
||||||
|
#VersionAnnouncer
|
||||||
|
SERVER_VERSION=§7This server runs on Minecraft version §e{0}
|
||||||
@@ -254,7 +254,6 @@ SIMULATOR_CHANGE_HELP=§8/§esimulator change §8-§7 Wechsel zu einem anderen S
|
|||||||
SIMULATOR_DELETE_HELP=§8/§esimulator delete §8[§7name§8] §8-§7 Löscht den Simulator
|
SIMULATOR_DELETE_HELP=§8/§esimulator delete §8[§7name§8] §8-§7 Löscht den Simulator
|
||||||
SIMULATOR_START_HELP=§8/§esimulator start §8[§7name§8] §8-§7 Startet die Simulation
|
SIMULATOR_START_HELP=§8/§esimulator start §8[§7name§8] §8-§7 Startet die Simulation
|
||||||
SIMULATOR_COPY_HELP=§8/§esimulator copy §8[§7to-copy§8] §8[§7name§8] §8-§7 Kopiert einen Simulator
|
SIMULATOR_COPY_HELP=§8/§esimulator copy §8[§7to-copy§8] §8[§7name§8] §8-§7 Kopiert einen Simulator
|
||||||
SIMULATOR_RENAME_HELP=§8/§esimulator rename §8[§7to-rename§8] §8[§7name§8] §8-§7 Benennt einen Simulator um
|
|
||||||
SIMULATOR_GUI_ITEM_NAME=§eTNT Simulator
|
SIMULATOR_GUI_ITEM_NAME=§eTNT Simulator
|
||||||
SIMULATOR_NO_SIM_IN_HAND=§cKein Simulator Item gewählt
|
SIMULATOR_NO_SIM_IN_HAND=§cKein Simulator Item gewählt
|
||||||
SIMULATOR_GUI_SELECT_SIM=Simulator wählen
|
SIMULATOR_GUI_SELECT_SIM=Simulator wählen
|
||||||
@@ -291,7 +290,6 @@ SIMULATOR_POSITION_Z=§7z-Position
|
|||||||
SIMULATOR_BACK=§eZurück
|
SIMULATOR_BACK=§eZurück
|
||||||
SIMULATOR_GUI_TOTAL_TNT=§7Gesamt TNT§8: §e{0}
|
SIMULATOR_GUI_TOTAL_TNT=§7Gesamt TNT§8: §e{0}
|
||||||
SIMULATOR_DELETED=§cSimulator gelöscht
|
SIMULATOR_DELETED=§cSimulator gelöscht
|
||||||
SIMULATOR_RENAMED=§cSimulator von {0} zu {1} umbenannt
|
|
||||||
## GUI
|
## GUI
|
||||||
SIMULATOR_POSITION_EDIT=§ePosition bearbeiten
|
SIMULATOR_POSITION_EDIT=§ePosition bearbeiten
|
||||||
SIMULATOR_POSITION_ADD=§ePosition setzen
|
SIMULATOR_POSITION_ADD=§ePosition setzen
|
||||||
@@ -369,8 +367,6 @@ BLOCK_COUNTER_MESSAGE_SECOND=§7Schaden §8> §e{0} §7Blöcke §e{1} §7TNT
|
|||||||
BLOCK_COUNTER_ENABLE=§7BlockCounter angemacht
|
BLOCK_COUNTER_ENABLE=§7BlockCounter angemacht
|
||||||
BLOCK_COUNTER_DISABLE=§7BlockCounter ausgemacht
|
BLOCK_COUNTER_DISABLE=§7BlockCounter ausgemacht
|
||||||
# DepthCounter
|
# DepthCounter
|
||||||
DEPTH_COUNTER_DISABLE=§7Depth Counter deaktiviert
|
|
||||||
DEPTH_COUNTER_ENABLE=§7Depth Counter aktiviert
|
|
||||||
DEPTH_COUNTER_MESSAGE=§7Tiefe §8> §7
|
DEPTH_COUNTER_MESSAGE=§7Tiefe §8> §7
|
||||||
# TPSLimit
|
# TPSLimit
|
||||||
TPSLIMIT_FREEZE_HELP=§8/§etpslimit 0 §8-§7 Friere TPS ein
|
TPSLIMIT_FREEZE_HELP=§8/§etpslimit 0 §8-§7 Friere TPS ein
|
||||||
@@ -956,4 +952,6 @@ XRAY_OFF=§cXray deaktiviert
|
|||||||
COLORREPLACE_HELP=§8//§ecolorreplace §8[§7color§8] §8[§7color§8] §8- §7Ersetzt eine Farbe mit einer anderen
|
COLORREPLACE_HELP=§8//§ecolorreplace §8[§7color§8] §8[§7color§8] §8- §7Ersetzt eine Farbe mit einer anderen
|
||||||
TYPEREPLACE_HELP=§8//§etyreplace §8[§7type§8] §8[§7type§8] §8- §7Ersetzt einen Blockgruppe mit einer anderen
|
TYPEREPLACE_HELP=§8//§etyreplace §8[§7type§8] §8[§7type§8] §8- §7Ersetzt einen Blockgruppe mit einer anderen
|
||||||
# Schematics
|
# Schematics
|
||||||
SCHEMATIC_GUI_ITEM=§eSchematics
|
SCHEMATIC_GUI_ITEM=§eSchematics
|
||||||
|
#VersionAnnouncer
|
||||||
|
SERVER_VERSION=§7Dieser Server läuft auf Minecraft-Version §e{0}
|
||||||
@@ -25,12 +25,9 @@ import de.steamwar.bausystem.configplayer.ConfigConverter;
|
|||||||
import de.steamwar.bausystem.features.gui.BauGUI;
|
import de.steamwar.bausystem.features.gui.BauGUI;
|
||||||
import de.steamwar.bausystem.features.script.lua.SteamWarLuaPlugin;
|
import de.steamwar.bausystem.features.script.lua.SteamWarLuaPlugin;
|
||||||
import de.steamwar.bausystem.features.script.lua.libs.LuaLib;
|
import de.steamwar.bausystem.features.script.lua.libs.LuaLib;
|
||||||
import de.steamwar.bausystem.features.slaves.laufbau.BoundingBoxLoader;
|
|
||||||
import de.steamwar.bausystem.features.slaves.panzern.Panzern;
|
import de.steamwar.bausystem.features.slaves.panzern.Panzern;
|
||||||
import de.steamwar.bausystem.features.slaves.panzern.PanzernAlgorithm;
|
import de.steamwar.bausystem.features.slaves.panzern.PanzernAlgorithm;
|
||||||
import de.steamwar.bausystem.features.tpslimit.TPSFreezeUtils;
|
import de.steamwar.bausystem.features.tpslimit.TPSFreezeUtils;
|
||||||
import de.steamwar.bausystem.features.tracer.TraceManager;
|
|
||||||
import de.steamwar.bausystem.features.tracer.TraceRecorder;
|
|
||||||
import de.steamwar.bausystem.features.world.BauScoreboard;
|
import de.steamwar.bausystem.features.world.BauScoreboard;
|
||||||
import de.steamwar.bausystem.linkage.specific.BauGuiItem;
|
import de.steamwar.bausystem.linkage.specific.BauGuiItem;
|
||||||
import de.steamwar.bausystem.region.loader.PrototypeLoader;
|
import de.steamwar.bausystem.region.loader.PrototypeLoader;
|
||||||
@@ -73,7 +70,7 @@ import java.util.function.Consumer;
|
|||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class BauSystem extends JavaPlugin {
|
public class BauSystem extends JavaPlugin implements Listener {
|
||||||
|
|
||||||
// This should be treated as final!
|
// This should be treated as final!
|
||||||
public static Message MESSAGE;
|
public static Message MESSAGE;
|
||||||
@@ -185,9 +182,6 @@ public class BauSystem extends JavaPlugin {
|
|||||||
if (any instanceof ConfigConverter) {
|
if (any instanceof ConfigConverter) {
|
||||||
Config.addConfigConverter((ConfigConverter) any);
|
Config.addConfigConverter((ConfigConverter) any);
|
||||||
}
|
}
|
||||||
if (any instanceof BoundingBoxLoader) {
|
|
||||||
((BoundingBoxLoader) any).load();
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
instances.forEach((clazz, o) -> {
|
instances.forEach((clazz, o) -> {
|
||||||
@@ -203,9 +197,6 @@ public class BauSystem extends JavaPlugin {
|
|||||||
});
|
});
|
||||||
|
|
||||||
TickListener.impl.init();
|
TickListener.impl.init();
|
||||||
|
|
||||||
TraceManager.instance.init();
|
|
||||||
TraceRecorder.instance.init();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -20,7 +20,6 @@
|
|||||||
package de.steamwar.bausystem.features.cannon.depth;
|
package de.steamwar.bausystem.features.cannon.depth;
|
||||||
|
|
||||||
import de.steamwar.bausystem.BauSystem;
|
import de.steamwar.bausystem.BauSystem;
|
||||||
import de.steamwar.bausystem.configplayer.Config;
|
|
||||||
import de.steamwar.bausystem.region.Region;
|
import de.steamwar.bausystem.region.Region;
|
||||||
import de.steamwar.bausystem.region.RegionUtils;
|
import de.steamwar.bausystem.region.RegionUtils;
|
||||||
import de.steamwar.bausystem.region.utils.RegionExtensionType;
|
import de.steamwar.bausystem.region.utils.RegionExtensionType;
|
||||||
@@ -66,9 +65,7 @@ public class Depth {
|
|||||||
dimensions.setZ(Math.abs(dimensions.getZ()));
|
dimensions.setZ(Math.abs(dimensions.getZ()));
|
||||||
|
|
||||||
RegionUtils.message(region, player -> {
|
RegionUtils.message(region, player -> {
|
||||||
if (Config.getInstance().get(player).getPlainValueOrDefault("depth_message", true)) {
|
player.spigot().sendMessage(getMessage(player, dimensions.getBlockX() + 1, dimensions.getBlockY() + 1, dimensions.getBlockZ() + 1, tntCount));
|
||||||
player.spigot().sendMessage(getMessage(player, dimensions.getBlockX() + 1, dimensions.getBlockY() + 1, dimensions.getBlockZ() + 1, tntCount));
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
-45
@@ -1,45 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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.features.cannon.depth;
|
|
||||||
|
|
||||||
import de.steamwar.bausystem.BauSystem;
|
|
||||||
import de.steamwar.bausystem.configplayer.Config;
|
|
||||||
import de.steamwar.command.SWCommand;
|
|
||||||
import de.steamwar.linkage.Linked;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
@Linked
|
|
||||||
public class DepthCommand extends SWCommand {
|
|
||||||
|
|
||||||
public DepthCommand() {
|
|
||||||
super("depth");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Register
|
|
||||||
public void toggle(Player player) {
|
|
||||||
if (Config.getInstance().get(player).getPlainValueOrDefault("depth_message", true)) {
|
|
||||||
Config.getInstance().get(player).put("depth_message", false);
|
|
||||||
BauSystem.MESSAGE.send("DEPTH_COUNTER_DISABLE", player);
|
|
||||||
} else {
|
|
||||||
Config.getInstance().get(player).put("depth_message", true);
|
|
||||||
BauSystem.MESSAGE.send("DEPTH_COUNTER_ENABLE", player);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
+1
-2
@@ -22,7 +22,6 @@ package de.steamwar.bausystem.features.gui.editor;
|
|||||||
import de.steamwar.bausystem.BauSystem;
|
import de.steamwar.bausystem.BauSystem;
|
||||||
import de.steamwar.bausystem.features.gui.BauGUI;
|
import de.steamwar.bausystem.features.gui.BauGUI;
|
||||||
import de.steamwar.bausystem.linkage.specific.BauGuiItem;
|
import de.steamwar.bausystem.linkage.specific.BauGuiItem;
|
||||||
import de.steamwar.core.TrickyTrialsWrapper;
|
|
||||||
import de.steamwar.inventory.SWItem;
|
import de.steamwar.inventory.SWItem;
|
||||||
import de.steamwar.inventory.SWListInv;
|
import de.steamwar.inventory.SWListInv;
|
||||||
import de.steamwar.linkage.Linked;
|
import de.steamwar.linkage.Linked;
|
||||||
@@ -73,7 +72,7 @@ public class BauGuiEditor implements Listener {
|
|||||||
|
|
||||||
inv.setItem(mapping.getSize() + 5, new SWItem(Material.BARRIER, BauSystem.MESSAGE.parse("GUI_EDITOR_ITEM_TRASH", p), Arrays.asList(BauSystem.MESSAGE.parse("GUI_EDITOR_ITEM_TRASH_LORE", p)), false, clickType -> {
|
inv.setItem(mapping.getSize() + 5, new SWItem(Material.BARRIER, BauSystem.MESSAGE.parse("GUI_EDITOR_ITEM_TRASH", p), Arrays.asList(BauSystem.MESSAGE.parse("GUI_EDITOR_ITEM_TRASH_LORE", p)), false, clickType -> {
|
||||||
}).getItemStack());
|
}).getItemStack());
|
||||||
inv.setItem(mapping.getSize() + 6, new SWItem(TrickyTrialsWrapper.impl.getTurtleScute(), BauSystem.MESSAGE.parse("GUI_EDITOR_ITEM_MORE", p)).getItemStack());
|
inv.setItem(mapping.getSize() + 6, new SWItem(Material.SCUTE, BauSystem.MESSAGE.parse("GUI_EDITOR_ITEM_MORE", p)).getItemStack());
|
||||||
inv.setItem(mapping.getSize() + 8, new SWItem(Material.ARROW, BauSystem.MESSAGE.parse("GUI_EDITOR_ITEM_CLOSE", p)).getItemStack());
|
inv.setItem(mapping.getSize() + 8, new SWItem(Material.ARROW, BauSystem.MESSAGE.parse("GUI_EDITOR_ITEM_CLOSE", p)).getItemStack());
|
||||||
|
|
||||||
p.openInventory(inv);
|
p.openInventory(inv);
|
||||||
|
|||||||
@@ -93,7 +93,6 @@ public class Loader implements Listener {
|
|||||||
element.execute(delay -> waitTime = delay);
|
element.execute(delay -> waitTime = delay);
|
||||||
if (waitTime > 0) {
|
if (waitTime > 0) {
|
||||||
if (element instanceof LoaderTNT) currentElement--;
|
if (element instanceof LoaderTNT) currentElement--;
|
||||||
waitTime--;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-3
@@ -20,7 +20,6 @@
|
|||||||
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;
|
||||||
@@ -58,7 +57,7 @@ public class LoadtimerListener implements Listener {
|
|||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onEntitySpawn(EntitySpawnEvent event) {
|
public void onEntitySpawn(EntitySpawnEvent event) {
|
||||||
if (!getTimers().isEmpty() && event.getEntityType() == TrickyTrialsWrapper.impl.getTntEntityType()) {
|
if (!getTimers().isEmpty() && event.getEntityType() == EntityType.PRIMED_TNT) {
|
||||||
Region r = Region.getRegion(event.getLocation());
|
Region r = Region.getRegion(event.getLocation());
|
||||||
if (hasTimer(r)) {
|
if (hasTimer(r)) {
|
||||||
getTimer(r).onTntSpawn();
|
getTimer(r).onTntSpawn();
|
||||||
@@ -68,7 +67,7 @@ public class LoadtimerListener implements Listener {
|
|||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onEntityExplode(EntityExplodeEvent event) {
|
public void onEntityExplode(EntityExplodeEvent event) {
|
||||||
if (!getTimers().isEmpty() && event.getEntityType() == TrickyTrialsWrapper.impl.getTntEntityType()) {
|
if (!getTimers().isEmpty() && event.getEntityType() == EntityType.PRIMED_TNT) {
|
||||||
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);
|
||||||
|
|||||||
+2
-2
@@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
package de.steamwar.bausystem.features.observer;
|
package de.steamwar.bausystem.features.observer;
|
||||||
|
|
||||||
import de.steamwar.Reflection;
|
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;
|
||||||
@@ -170,7 +170,7 @@ public class ObserverTracer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final Class<?> craftPoweredRail = Reflection.getClass("org.bukkit.craftbukkit.block.impl.CraftPoweredRail");
|
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) {
|
||||||
|
|||||||
+2
-3
@@ -6,7 +6,6 @@ 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;
|
||||||
@@ -32,7 +31,7 @@ public class FreezeListener implements Listener, ScoreboardElement {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
if (e.getEntityType() == TrickyTrialsWrapper.impl.getTntEntityType()) {
|
if (e.getEntityType() == EntityType.PRIMED_TNT) {
|
||||||
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);
|
||||||
@@ -113,8 +112,8 @@ public class FreezeListener implements Listener, ScoreboardElement {
|
|||||||
if (Core.getVersion() < 19) return;
|
if (Core.getVersion() < 19) return;
|
||||||
if (e.getPlayer().getInventory().getItemInMainHand().getType() == Material.DEBUG_STICK) return;
|
if (e.getPlayer().getInventory().getItemInMainHand().getType() == Material.DEBUG_STICK) return;
|
||||||
if (Region.getRegion(e.getBlock().getLocation()).get(Flag.FREEZE) == FreezeMode.ACTIVE) {
|
if (Region.getRegion(e.getBlock().getLocation()).get(Flag.FREEZE) == FreezeMode.ACTIVE) {
|
||||||
|
if (e.isCancelled()) return;
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
e.getBlock().setType(Material.BARRIER, false);
|
|
||||||
e.getBlock().setType(Material.AIR, false);
|
e.getBlock().setType(Material.AIR, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-1
@@ -20,6 +20,7 @@
|
|||||||
package de.steamwar.bausystem.features.region;
|
package de.steamwar.bausystem.features.region;
|
||||||
|
|
||||||
import de.steamwar.bausystem.BauSystem;
|
import de.steamwar.bausystem.BauSystem;
|
||||||
|
import de.steamwar.bausystem.Permission;
|
||||||
import de.steamwar.bausystem.config.BauServer;
|
import de.steamwar.bausystem.config.BauServer;
|
||||||
import de.steamwar.bausystem.region.GlobalRegion;
|
import de.steamwar.bausystem.region.GlobalRegion;
|
||||||
import de.steamwar.bausystem.region.Region;
|
import de.steamwar.bausystem.region.Region;
|
||||||
@@ -30,6 +31,7 @@ import de.steamwar.bausystem.region.utils.RegionExtensionType;
|
|||||||
import de.steamwar.bausystem.region.utils.RegionType;
|
import de.steamwar.bausystem.region.utils.RegionType;
|
||||||
import de.steamwar.bausystem.utils.PasteBuilder;
|
import de.steamwar.bausystem.utils.PasteBuilder;
|
||||||
import de.steamwar.command.SWCommand;
|
import de.steamwar.command.SWCommand;
|
||||||
|
import de.steamwar.command.TypeValidator;
|
||||||
import de.steamwar.linkage.Linked;
|
import de.steamwar.linkage.Linked;
|
||||||
import de.steamwar.linkage.LinkedInstance;
|
import de.steamwar.linkage.LinkedInstance;
|
||||||
import de.steamwar.sql.Punishment;
|
import de.steamwar.sql.Punishment;
|
||||||
@@ -38,6 +40,7 @@ import de.steamwar.sql.SteamwarUser;
|
|||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
@Linked
|
@Linked
|
||||||
@@ -58,7 +61,7 @@ public class ResetCommand extends SWCommand {
|
|||||||
PasteBuilder pasteBuilder = new PasteBuilder(new PasteBuilder.FileProvider(region.getResetFile(RegionType.NORMAL)))
|
PasteBuilder pasteBuilder = new PasteBuilder(new PasteBuilder.FileProvider(region.getResetFile(RegionType.NORMAL)))
|
||||||
.color(region.getPlain(Flag.COLOR, ColorMode.class).getColor());
|
.color(region.getPlain(Flag.COLOR, ColorMode.class).getColor());
|
||||||
region.reset(pasteBuilder, RegionType.NORMAL, RegionExtensionType.NORMAL);
|
region.reset(pasteBuilder, RegionType.NORMAL, RegionExtensionType.NORMAL);
|
||||||
for (Flag value : Flag.getResetFlags()) {
|
for (Flag value : Flag.values()) {
|
||||||
region.set(value, value.getDefaultValue());
|
region.set(value, value.getDefaultValue());
|
||||||
}
|
}
|
||||||
RegionUtils.message(region, "REGION_RESET_RESETED");
|
RegionUtils.message(region, "REGION_RESET_RESETED");
|
||||||
|
|||||||
+6
-6
@@ -24,13 +24,14 @@ import de.steamwar.bausystem.Permission;
|
|||||||
import de.steamwar.bausystem.features.script.ScriptRunner;
|
import de.steamwar.bausystem.features.script.ScriptRunner;
|
||||||
import de.steamwar.bausystem.features.script.lua.SteamWarGlobalLuaPlugin;
|
import de.steamwar.bausystem.features.script.lua.SteamWarGlobalLuaPlugin;
|
||||||
import de.steamwar.bausystem.features.script.lua.libs.StorageLib;
|
import de.steamwar.bausystem.features.script.lua.libs.StorageLib;
|
||||||
|
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;
|
||||||
|
import org.bukkit.entity.EntityType;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
@@ -70,10 +71,9 @@ public class EventListener implements Listener {
|
|||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGH)
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
public void onPlayerQuit(PlayerQuitEvent event) {
|
public void onPlayerQuit(PlayerQuitEvent event) {
|
||||||
if(Permission.BUILD.hasPermission(event.getPlayer())) {
|
|
||||||
ScriptRunner.callEvent(event.getPlayer(), SteamWarGlobalLuaPlugin.EventType.SelfLeave, LuaValue.NIL, event);
|
|
||||||
}
|
|
||||||
StorageLib.removePlayer(event.getPlayer());
|
StorageLib.removePlayer(event.getPlayer());
|
||||||
|
if(!Permission.BUILD.hasPermission(event.getPlayer())) return;
|
||||||
|
ScriptRunner.callEvent(event.getPlayer(), SteamWarGlobalLuaPlugin.EventType.SelfLeave, LuaValue.NIL, event);
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGH)
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
@@ -146,7 +146,7 @@ public class EventListener implements Listener {
|
|||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGH)
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
public void onEntitySpawn(EntitySpawnEvent event) {
|
public void onEntitySpawn(EntitySpawnEvent event) {
|
||||||
if (event.getEntityType() != TrickyTrialsWrapper.impl.getTntEntityType()) {
|
if (event.getEntityType() != EntityType.PRIMED_TNT) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Region tntRegion = Region.getRegion(event.getLocation());
|
Region tntRegion = Region.getRegion(event.getLocation());
|
||||||
@@ -161,7 +161,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() != TrickyTrialsWrapper.impl.getTntEntityType()) {
|
if (event.getEntityType() != EntityType.PRIMED_TNT) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Region tntRegion = Region.getRegion(event.getLocation());
|
Region tntRegion = Region.getRegion(event.getLocation());
|
||||||
|
|||||||
-113
@@ -1,113 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is a part of the SteamWar software.
|
|
||||||
*
|
|
||||||
* Copyright (C) 2023 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.script.lua.libs;
|
|
||||||
|
|
||||||
import de.steamwar.bausystem.features.tracer.TNTPoint;
|
|
||||||
import de.steamwar.bausystem.features.tracer.Trace;
|
|
||||||
import de.steamwar.bausystem.features.tracer.TraceManager;
|
|
||||||
import de.steamwar.linkage.Linked;
|
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.util.Vector;
|
|
||||||
import org.luaj.vm2.LuaTable;
|
|
||||||
import org.luaj.vm2.LuaValue;
|
|
||||||
import org.luaj.vm2.lib.ZeroArgFunction;
|
|
||||||
|
|
||||||
@Linked
|
|
||||||
public class TracerLib implements LuaLib {
|
|
||||||
@Override
|
|
||||||
public String name() {
|
|
||||||
return "tracer";
|
|
||||||
}
|
|
||||||
|
|
||||||
private static LuaTable convertTrace(Trace trace) {
|
|
||||||
LuaTable luaTrace = new LuaTable();
|
|
||||||
|
|
||||||
luaTrace.set("getRecords", new ZeroArgFunction() {
|
|
||||||
@Override
|
|
||||||
public LuaValue call() {
|
|
||||||
return LuaValue.listOf(
|
|
||||||
trace.getHistories()
|
|
||||||
.stream()
|
|
||||||
.map((history) -> LuaValue.listOf(history
|
|
||||||
.stream()
|
|
||||||
.map(TracerLib::convertTntPoint)
|
|
||||||
.toArray(LuaValue[]::new)))
|
|
||||||
.toArray(LuaValue[]::new));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
luaTrace.set("getId", new ZeroArgFunction() {
|
|
||||||
@Override
|
|
||||||
public LuaValue call() {
|
|
||||||
return LuaValue.valueOf(trace.getUuid().toString());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
return luaTrace;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static LuaTable convertTntPoint(TNTPoint tntPoint) {
|
|
||||||
Location pointPos = tntPoint.getLocation();
|
|
||||||
LuaTable luaPos = LuaValue.tableOf(new LuaValue[]{
|
|
||||||
LuaValue.valueOf("x"), LuaValue.valueOf(pointPos.getX()),
|
|
||||||
LuaValue.valueOf("y"), LuaValue.valueOf(pointPos.getY()),
|
|
||||||
LuaValue.valueOf("z"), LuaValue.valueOf(pointPos.getZ()),
|
|
||||||
});
|
|
||||||
|
|
||||||
Vector pointVel = tntPoint.getVelocity();
|
|
||||||
LuaTable luaVel = LuaValue.tableOf(new LuaValue[]{
|
|
||||||
LuaValue.valueOf("x"), LuaValue.valueOf(pointVel.getX()),
|
|
||||||
LuaValue.valueOf("y"), LuaValue.valueOf(pointVel.getY()),
|
|
||||||
LuaValue.valueOf("z"), LuaValue.valueOf(pointVel.getZ()),
|
|
||||||
});
|
|
||||||
|
|
||||||
return LuaValue.tableOf(new LuaValue[]{
|
|
||||||
LuaValue.valueOf("pos"), luaPos,
|
|
||||||
LuaValue.valueOf("vel"), luaVel,
|
|
||||||
LuaValue.valueOf("ticksSinceStart"), LuaValue.valueOf(tntPoint.getTicksSinceStart()),
|
|
||||||
LuaValue.valueOf("fuse"), LuaValue.valueOf(tntPoint.getFuse()),
|
|
||||||
LuaValue.valueOf("isExplosion"), LuaValue.valueOf(tntPoint.isExplosion()),
|
|
||||||
LuaValue.valueOf("isInWater"), LuaValue.valueOf(tntPoint.isInWater()),
|
|
||||||
LuaValue.valueOf("hasDestroyedBuild"), LuaValue.valueOf(tntPoint.isDestroyedBuildArea()),
|
|
||||||
LuaValue.valueOf("hasDestroyedTestblock"), LuaValue.valueOf(tntPoint.isDestroyedTestBlock())
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public LuaTable get(Player player) {
|
|
||||||
LuaTable rootTable = LuaValue.tableOf();
|
|
||||||
|
|
||||||
rootTable.set("getTraces", new ZeroArgFunction() {
|
|
||||||
@Override
|
|
||||||
public LuaValue call() {
|
|
||||||
return LuaValue.listOf(TraceManager.instance.getAll()
|
|
||||||
.stream()
|
|
||||||
.map(TracerLib::convertTrace)
|
|
||||||
.toArray(LuaValue[]::new));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
);
|
|
||||||
|
|
||||||
return rootTable;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
+2
-6
@@ -160,11 +160,6 @@ public class ShieldPrinting implements Listener {
|
|||||||
|
|
||||||
private void paste(Map<Material, BlockDataConfiguration<?>[]> stateConfiguration) {
|
private void paste(Map<Material, BlockDataConfiguration<?>[]> stateConfiguration) {
|
||||||
for (Map.Entry<Vector, BlockData> entry : shieldData.entrySet()) {
|
for (Map.Entry<Vector, BlockData> entry : shieldData.entrySet()) {
|
||||||
BlockData copied = entry.getValue();
|
|
||||||
if (copied.getMaterial().isAir()) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
Block block = entry.getKey().toLocation(WORLD).getBlock();
|
Block block = entry.getKey().toLocation(WORLD).getBlock();
|
||||||
if (entry.getValue().getMaterial() != block.getType()) {
|
if (entry.getValue().getMaterial() != block.getType()) {
|
||||||
block.setBlockData(entry.getValue(), false);
|
block.setBlockData(entry.getValue(), false);
|
||||||
@@ -176,11 +171,12 @@ public class ShieldPrinting implements Listener {
|
|||||||
|
|
||||||
BlockDataConfiguration[] stateConfigurations = stateConfiguration.get(entry.getValue().getMaterial());
|
BlockDataConfiguration[] stateConfigurations = stateConfiguration.get(entry.getValue().getMaterial());
|
||||||
if (stateConfigurations == null) {
|
if (stateConfigurations == null) {
|
||||||
|
block.setBlockData(entry.getValue(), false);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
BlockData worldOriginal = block.getBlockData();
|
BlockData worldOriginal = block.getBlockData();
|
||||||
copied = copied.clone();
|
BlockData copied = entry.getValue().clone();
|
||||||
for (BlockDataConfiguration blockDataConfiguration : stateConfigurations) {
|
for (BlockDataConfiguration blockDataConfiguration : stateConfigurations) {
|
||||||
if (blockDataConfiguration == null) continue;
|
if (blockDataConfiguration == null) continue;
|
||||||
blockDataConfiguration.apply(copied, worldOriginal);
|
blockDataConfiguration.apply(copied, worldOriginal);
|
||||||
|
|||||||
+10
-27
@@ -20,6 +20,7 @@
|
|||||||
package de.steamwar.bausystem.features.simulator;
|
package de.steamwar.bausystem.features.simulator;
|
||||||
|
|
||||||
import de.steamwar.bausystem.BauSystem;
|
import de.steamwar.bausystem.BauSystem;
|
||||||
|
import de.steamwar.bausystem.Permission;
|
||||||
import de.steamwar.bausystem.SWUtils;
|
import de.steamwar.bausystem.SWUtils;
|
||||||
import de.steamwar.bausystem.features.simulator.data.Simulator;
|
import de.steamwar.bausystem.features.simulator.data.Simulator;
|
||||||
import de.steamwar.bausystem.features.simulator.execute.SimulatorExecutor;
|
import de.steamwar.bausystem.features.simulator.execute.SimulatorExecutor;
|
||||||
@@ -62,7 +63,15 @@ public class SimulatorCommand extends SWCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Register(value = "copy", description = "SIMULATOR_COPY_HELP")
|
@Register(value = "copy", description = "SIMULATOR_COPY_HELP")
|
||||||
public void copy(@Validator Player p, @ErrorMessage("SIMULATOR_NOT_EXISTS") Simulator simulator, @Validator("simulatorName") String name) {
|
public void copy(@Validator Player p, @ErrorMessage("SIMULATOR_NOT_EXISTS") Simulator simulator, String name) {
|
||||||
|
if (SimulatorStorage.getSimulator(name) != null) {
|
||||||
|
BauSystem.MESSAGE.send("SIMULATOR_NAME_ALREADY_EXISTS", p);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!name.matches("[a-zA-Z_0-9-]+")) {
|
||||||
|
BauSystem.MESSAGE.send("SIMULATOR_NAME_INVALID", p);
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (!SimulatorStorage.copy(simulator, name)) {
|
if (!SimulatorStorage.copy(simulator, name)) {
|
||||||
BauSystem.MESSAGE.send("SIMULATOR_ERROR_COPY", p);
|
BauSystem.MESSAGE.send("SIMULATOR_ERROR_COPY", p);
|
||||||
}
|
}
|
||||||
@@ -79,17 +88,6 @@ public class SimulatorCommand extends SWCommand {
|
|||||||
SimulatorExecutor.run(simulator);
|
SimulatorExecutor.run(simulator);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Register(value = "rename", description = "SIMULATOR_RENAME_HELP")
|
|
||||||
public void rename(@Validator Player p, @ErrorMessage("SIMULATOR_NOT_EXISTS") Simulator simulator, @Validator("simulatorName") String name) {
|
|
||||||
String oldName = simulator.getName();
|
|
||||||
if (SimulatorStorage.copy(simulator, name)) {
|
|
||||||
SimulatorStorage.delete(simulator);
|
|
||||||
BauSystem.MESSAGE.send("SIMULATOR_RENAMED", p, oldName, name);
|
|
||||||
} else {
|
|
||||||
BauSystem.MESSAGE.send("SIMULATOR_ERROR_COPY", p);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@ClassMapper(value = Simulator.class, local = true)
|
@ClassMapper(value = Simulator.class, local = true)
|
||||||
public TypeMapper<Simulator> allSimulators() {
|
public TypeMapper<Simulator> allSimulators() {
|
||||||
return new TypeMapper<>() {
|
return new TypeMapper<>() {
|
||||||
@@ -104,19 +102,4 @@ public class SimulatorCommand extends SWCommand {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@Validator(value = "simulatorName", local = true)
|
|
||||||
public TypeValidator<String> simulatorName() {
|
|
||||||
return (commandSender, name, messageSender) -> {
|
|
||||||
if (SimulatorStorage.getSimulator(name) != null) {
|
|
||||||
messageSender.send("SIMULATOR_NAME_ALREADY_EXISTS");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (!name.matches("[a-zA-Z_0-9-]+")) {
|
|
||||||
messageSender.send("SIMULATOR_NAME_INVALID");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-4
@@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
package de.steamwar.bausystem.features.simulator;
|
package de.steamwar.bausystem.features.simulator;
|
||||||
|
|
||||||
import de.steamwar.Reflection;
|
import com.comphenix.tinyprotocol.Reflection;
|
||||||
import com.comphenix.tinyprotocol.TinyProtocol;
|
import com.comphenix.tinyprotocol.TinyProtocol;
|
||||||
import de.steamwar.bausystem.BauSystem;
|
import de.steamwar.bausystem.BauSystem;
|
||||||
import de.steamwar.bausystem.Permission;
|
import de.steamwar.bausystem.Permission;
|
||||||
@@ -72,9 +72,9 @@ import java.util.stream.Collectors;
|
|||||||
public class SimulatorCursor implements Listener {
|
public class SimulatorCursor implements Listener {
|
||||||
|
|
||||||
private final World WORLD = Bukkit.getWorlds().get(0);
|
private final World WORLD = Bukkit.getWorlds().get(0);
|
||||||
private Class<?> position = Reflection.getClass("net.minecraft.network.protocol.game.ServerboundMovePlayerPacket$Pos");
|
private Class<?> position = Reflection.getClass("{nms.network.protocol.game}.PacketPlayInFlying$PacketPlayInPosition");
|
||||||
private Class<?> look = Reflection.getClass("net.minecraft.network.protocol.game.ServerboundMovePlayerPacket$Rot");
|
private Class<?> look = Reflection.getClass("{nms.network.protocol.game}.PacketPlayInFlying$PacketPlayInLook");
|
||||||
private Class<?> positionLook = Reflection.getClass("net.minecraft.network.protocol.game.ServerboundMovePlayerPacket$PosRot");
|
private Class<?> positionLook = Reflection.getClass("{nms.network.protocol.game}.PacketPlayInFlying$PacketPlayInPositionLook");
|
||||||
|
|
||||||
private Map<Player, CursorType> cursorType = Collections.synchronizedMap(new HashMap<>());
|
private Map<Player, CursorType> cursorType = Collections.synchronizedMap(new HashMap<>());
|
||||||
private Map<Player, REntityServer> cursors = Collections.synchronizedMap(new HashMap<>());
|
private Map<Player, REntityServer> cursors = Collections.synchronizedMap(new HashMap<>());
|
||||||
|
|||||||
+1
-2
@@ -44,7 +44,6 @@ import org.bukkit.inventory.meta.ItemMeta;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
@Linked
|
@Linked
|
||||||
@MinVersion(19)
|
@MinVersion(19)
|
||||||
@@ -131,7 +130,7 @@ public class SimulatorStorage implements Enable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void openSimulatorSelector(Player player) {
|
public static void openSimulatorSelector(Player player) {
|
||||||
SimulatorPageGui<Simulator> simulatorPageGui = new SimulatorPageGui<Simulator>(player, null, 6 * 9, simulatorMap.values().stream().sorted(Comparator.comparing(Simulator::getName)).collect(Collectors.toList())) {
|
SimulatorPageGui<Simulator> simulatorPageGui = new SimulatorPageGui<Simulator>(player, null, 6 * 9, new ArrayList<>(simulatorMap.values())) {
|
||||||
@Override
|
@Override
|
||||||
public String baseTitle() {
|
public String baseTitle() {
|
||||||
return "Simulators";
|
return "Simulators";
|
||||||
|
|||||||
-10
@@ -53,16 +53,6 @@ public class SimulatorMaterialGui extends SimulatorPageGui<Material> {
|
|||||||
this.back = back;
|
this.back = back;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean shouldOpen() {
|
|
||||||
if (player.getItemOnCursor().getType().isAir()) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
change.accept(player.getItemOnCursor().getType());
|
|
||||||
SimulatorWatcher.update(simulator);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String baseTitle() {
|
public String baseTitle() {
|
||||||
return "Material";
|
return "Material";
|
||||||
|
|||||||
+1
-8
@@ -22,7 +22,6 @@ package de.steamwar.bausystem.features.simulator.gui.base;
|
|||||||
import de.steamwar.bausystem.features.simulator.SimulatorWatcher;
|
import de.steamwar.bausystem.features.simulator.SimulatorWatcher;
|
||||||
import de.steamwar.bausystem.features.simulator.data.Simulator;
|
import de.steamwar.bausystem.features.simulator.data.Simulator;
|
||||||
import de.steamwar.core.Core;
|
import de.steamwar.core.Core;
|
||||||
import de.steamwar.core.TrickyTrialsWrapper;
|
|
||||||
import de.steamwar.inventory.SWInventory;
|
import de.steamwar.inventory.SWInventory;
|
||||||
import de.steamwar.inventory.SWItem;
|
import de.steamwar.inventory.SWItem;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
@@ -46,8 +45,6 @@ public abstract class SimulatorBaseGui {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public final void open() {
|
public final void open() {
|
||||||
if (!shouldOpen()) return;
|
|
||||||
|
|
||||||
String newTitle = title();
|
String newTitle = title();
|
||||||
String originalTitle = player.getOpenInventory().getTitle();
|
String originalTitle = player.getOpenInventory().getTitle();
|
||||||
|
|
||||||
@@ -72,7 +69,7 @@ public abstract class SimulatorBaseGui {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
player.closeInventory();
|
player.getOpenInventory().close();
|
||||||
|
|
||||||
inventory = new SWInventory(player, () -> {
|
inventory = new SWInventory(player, () -> {
|
||||||
inv = Bukkit.createInventory(null, size, title());
|
inv = Bukkit.createInventory(null, size, title());
|
||||||
@@ -88,10 +85,6 @@ public abstract class SimulatorBaseGui {
|
|||||||
inventory.open();
|
inventory.open();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean shouldOpen() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setup() {
|
private void setup() {
|
||||||
for (int i = 0; i < 9; i++) {
|
for (int i = 0; i < 9; i++) {
|
||||||
inventory.setItem(i, new SWItem(Material.GRAY_STAINED_GLASS_PANE, "§8", clickType -> {
|
inventory.setItem(i, new SWItem(Material.GRAY_STAINED_GLASS_PANE, "§8", clickType -> {
|
||||||
|
|||||||
+12
-14
@@ -24,7 +24,6 @@ import de.steamwar.bausystem.BauSystem;
|
|||||||
import de.steamwar.bausystem.features.slaves.laufbau.BlockBoundingBox;
|
import de.steamwar.bausystem.features.slaves.laufbau.BlockBoundingBox;
|
||||||
import de.steamwar.bausystem.features.slaves.laufbau.Cuboid;
|
import de.steamwar.bausystem.features.slaves.laufbau.Cuboid;
|
||||||
import de.steamwar.bausystem.features.tracer.TNTPoint;
|
import de.steamwar.bausystem.features.tracer.TNTPoint;
|
||||||
import de.steamwar.bausystem.features.tracer.Trace;
|
|
||||||
import de.steamwar.bausystem.features.tracer.TraceManager;
|
import de.steamwar.bausystem.features.tracer.TraceManager;
|
||||||
import de.steamwar.bausystem.region.Point;
|
import de.steamwar.bausystem.region.Point;
|
||||||
import de.steamwar.bausystem.utils.FlatteningWrapper;
|
import de.steamwar.bausystem.utils.FlatteningWrapper;
|
||||||
@@ -35,6 +34,7 @@ import org.bukkit.util.Vector;
|
|||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.function.BiPredicate;
|
import java.util.function.BiPredicate;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class ProcessingTracesState implements LaufbauState {
|
public class ProcessingTracesState implements LaufbauState {
|
||||||
|
|
||||||
@@ -45,9 +45,8 @@ public class ProcessingTracesState implements LaufbauState {
|
|||||||
private final List<BlockBoundingBox> elements;
|
private final List<BlockBoundingBox> elements;
|
||||||
private final int factor;
|
private final int factor;
|
||||||
|
|
||||||
private final List<Trace> Traces;
|
private final List<TNTPoint> TNTPoints;
|
||||||
private final List<TNTPoint> TNTPoints = new ArrayList<>();
|
private final int totalTntRecords;
|
||||||
private final int totalTraces;
|
|
||||||
|
|
||||||
private final Set<Point> affectedBlocks = new HashSet<>();
|
private final Set<Point> affectedBlocks = new HashSet<>();
|
||||||
private final Map<Point, Set<Cuboid>> cuboidsPerChunk = new HashMap<>();
|
private final Map<Point, Set<Cuboid>> cuboidsPerChunk = new HashMap<>();
|
||||||
@@ -59,13 +58,18 @@ public class ProcessingTracesState implements LaufbauState {
|
|||||||
this.elements = elements;
|
this.elements = elements;
|
||||||
this.factor = factor;
|
this.factor = factor;
|
||||||
|
|
||||||
Traces = new ArrayList<>(TraceManager.instance.getAll());
|
// TODO: Optimize only retrieving traces inside of the affected regions!
|
||||||
totalTraces = Traces.size();
|
TNTPoints = TraceManager.instance.getAll()
|
||||||
|
.stream()
|
||||||
|
.flatMap(trace -> trace.getHistories().stream())
|
||||||
|
.flatMap(Collection::stream)
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
totalTntRecords = TNTPoints.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String actionBarMessage(Player p) {
|
public String actionBarMessage(Player p) {
|
||||||
return BauSystem.MESSAGE.parse("LAUFBAU_SIMPLE_PROGRESS", p, BauSystem.MESSAGE.parse("LAUFBAU_STATE_PROCESSING_TRACES", p), totalTraces - Traces.size(), totalTraces, eta(p, start, totalTraces - Traces.size(), totalTraces));
|
return BauSystem.MESSAGE.parse("LAUFBAU_SIMPLE_PROGRESS", p, BauSystem.MESSAGE.parse("LAUFBAU_STATE_PROCESSING_TRACES", p), totalTntRecords - TNTPoints.size(), totalTntRecords, eta(p, start, totalTntRecords - TNTPoints.size(), totalTntRecords));
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean inRegion(Vector location, int expansion) {
|
private boolean inRegion(Vector location, int expansion) {
|
||||||
@@ -74,17 +78,11 @@ public class ProcessingTracesState implements LaufbauState {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasNext() {
|
public boolean hasNext() {
|
||||||
return !Traces.isEmpty() || !TNTPoints.isEmpty();
|
return !TNTPoints.isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void next() {
|
public void next() {
|
||||||
if (TNTPoints.isEmpty()) {
|
|
||||||
Trace trace = Traces.remove(0);
|
|
||||||
trace.getHistories().stream().flatMap(Collection::stream).forEach(TNTPoints::add);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
TNTPoint current = TNTPoints.remove(0);
|
TNTPoint current = TNTPoints.remove(0);
|
||||||
if (FlatteningWrapper.impl.inWater(world, current.getLocation().toVector())) return;
|
if (FlatteningWrapper.impl.inWater(world, current.getLocation().toVector())) return;
|
||||||
if (!(inRegion(current.getLocation().toVector(), 1) || (current.getPrevious().isPresent() && inRegion(current.getPrevious().get().getLocation().toVector(), 1))))
|
if (!(inRegion(current.getLocation().toVector(), 1) || (current.getPrevious().isPresent() && inRegion(current.getPrevious().get().getLocation().toVector(), 1))))
|
||||||
|
|||||||
+3
-3
@@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
package de.steamwar.bausystem.features.smartplace;
|
package de.steamwar.bausystem.features.smartplace;
|
||||||
|
|
||||||
import de.steamwar.Reflection;
|
import com.comphenix.tinyprotocol.Reflection;
|
||||||
import com.comphenix.tinyprotocol.TinyProtocol;
|
import com.comphenix.tinyprotocol.TinyProtocol;
|
||||||
import de.steamwar.bausystem.BauSystem;
|
import de.steamwar.bausystem.BauSystem;
|
||||||
import de.steamwar.bausystem.Permission;
|
import de.steamwar.bausystem.Permission;
|
||||||
@@ -81,7 +81,7 @@ public class SmartPlaceListener implements Listener {
|
|||||||
IGNORED.remove(Material.BARRIER);
|
IGNORED.remove(Material.BARRIER);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final Class<?> useItem = Reflection.getClass("net.minecraft.network.protocol.game.ServerboundUseItemOnPacket");
|
private static final Class<?> useItem = Reflection.getClass("{nms.network.protocol.game}.PacketPlayInUseItem");
|
||||||
|
|
||||||
private static final Set<Player> SMART_PLACING = new HashSet<>();
|
private static final Set<Player> SMART_PLACING = new HashSet<>();
|
||||||
private static final Set<Player> WAS_EXECUTED = new HashSet<>();
|
private static final Set<Player> WAS_EXECUTED = new HashSet<>();
|
||||||
@@ -223,7 +223,7 @@ public class SmartPlaceListener implements Listener {
|
|||||||
Block block = event.getBlock().getRelative(BlockFace.DOWN);
|
Block block = event.getBlock().getRelative(BlockFace.DOWN);
|
||||||
BlockState old = block.getState();
|
BlockState old = block.getState();
|
||||||
Bukkit.getScheduler().runTaskLater(BauSystem.getInstance(), () -> {
|
Bukkit.getScheduler().runTaskLater(BauSystem.getInstance(), () -> {
|
||||||
block.setType(Material.GLASS, false);
|
block.setType(Material.GLASS);
|
||||||
old.update(true, false);
|
old.update(true, false);
|
||||||
}, 1);
|
}, 1);
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-3
@@ -23,8 +23,6 @@ import de.steamwar.bausystem.BauSystem;
|
|||||||
import de.steamwar.bausystem.region.Point;
|
import de.steamwar.bausystem.region.Point;
|
||||||
import de.steamwar.bausystem.region.Region;
|
import de.steamwar.bausystem.region.Region;
|
||||||
import de.steamwar.bausystem.region.utils.RegionType;
|
import de.steamwar.bausystem.region.utils.RegionType;
|
||||||
import de.steamwar.core.TrickyParticleWrapper;
|
|
||||||
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.Particle;
|
import org.bukkit.Particle;
|
||||||
@@ -58,7 +56,7 @@ public class BoundaryViewer implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void showRegion(Region region, Player player) {
|
private void showRegion(Region region, Player player) {
|
||||||
drawCuboid(player, TrickyParticleWrapper.impl.getVillagerHappy(), region.getMinPoint(), region.getMaxPoint());
|
drawCuboid(player, Particle.VILLAGER_HAPPY, region.getMinPoint(), region.getMaxPoint());
|
||||||
if (region.hasType(RegionType.TESTBLOCK)) {
|
if (region.hasType(RegionType.TESTBLOCK)) {
|
||||||
drawCuboid(player, Particle.END_ROD, region.getMinPointTestblockExtension(), region.getMaxPointTestblockExtension());
|
drawCuboid(player, Particle.END_ROD, region.getMinPointTestblockExtension(), region.getMaxPointTestblockExtension());
|
||||||
}
|
}
|
||||||
|
|||||||
+10
-10
@@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
package de.steamwar.bausystem.features.tpslimit;
|
package de.steamwar.bausystem.features.tpslimit;
|
||||||
|
|
||||||
import de.steamwar.Reflection;
|
import com.comphenix.tinyprotocol.Reflection;
|
||||||
import com.comphenix.tinyprotocol.TinyProtocol;
|
import com.comphenix.tinyprotocol.TinyProtocol;
|
||||||
import de.steamwar.core.BountifulWrapper;
|
import de.steamwar.core.BountifulWrapper;
|
||||||
import de.steamwar.core.ChatWrapper;
|
import de.steamwar.core.ChatWrapper;
|
||||||
@@ -45,18 +45,18 @@ class PacketCache {
|
|||||||
private static Set<Entity> entities = new HashSet<>();
|
private static Set<Entity> entities = new HashSet<>();
|
||||||
private static BukkitTask task = null;
|
private static BukkitTask task = null;
|
||||||
|
|
||||||
private static Class<?> vec3dClass = Reflection.getClass("net.minecraft.world.phys.Vec3");
|
private static Class<?> vec3dClass = Reflection.getClass("{nms.world.phys}.Vec3D");
|
||||||
private static Reflection.Field<Object> zeroVec3d = (Reflection.Field<Object>) Reflection.getField(vec3dClass, vec3dClass, 0);
|
private static Reflection.FieldAccessor<Object> zeroVec3d = (Reflection.FieldAccessor<Object>) Reflection.getField(vec3dClass, vec3dClass, 0);
|
||||||
private static Object ZERO_VEC3D = zeroVec3d.get(null);
|
private static Object ZERO_VEC3D = zeroVec3d.get(null);
|
||||||
private static Class<?> velocityPacketClass = Reflection.getClass("net.minecraft.network.protocol.game.ClientboundSetEntityMotionPacket");
|
private static Class<?> velocityPacketClass = Reflection.getClass("{nms.network.protocol.game}.PacketPlayOutEntityVelocity");
|
||||||
private static Reflection.Constructor velocityPacketConstructor = Reflection.getConstructor(velocityPacketClass, int.class, vec3dClass);
|
private static Reflection.ConstructorInvoker velocityPacketConstructor = Reflection.getConstructor(velocityPacketClass, int.class, vec3dClass);
|
||||||
|
|
||||||
private static Class<?> teleportPacketClass = Reflection.getClass("net.minecraft.network.protocol.game.ClientboundTeleportEntityPacket");
|
private static Class<?> teleportPacketClass = Reflection.getClass("{nms.network.protocol.game}.PacketPlayOutEntityTeleport");
|
||||||
private static Class<?> entityClass = Reflection.getClass("net.minecraft.world.entity.Entity");
|
private static Class<?> entityClass = Reflection.getClass("{nms.world.entity}.Entity");
|
||||||
private static Reflection.Constructor teleportPacketConstructor = Reflection.getConstructor(teleportPacketClass, entityClass);
|
private static Reflection.ConstructorInvoker teleportPacketConstructor = Reflection.getConstructor(teleportPacketClass, entityClass);
|
||||||
|
|
||||||
private static Class<?> craftEntityClass = Reflection.getClass("org.bukkit.craftbukkit.entity.CraftEntity");
|
private static Class<?> craftEntityClass = Reflection.getClass("{obc}.entity.CraftEntity");
|
||||||
private static Reflection.Method getHandle = Reflection.getMethod(craftEntityClass, "getHandle");
|
private static Reflection.MethodInvoker getHandle = Reflection.getMethod(craftEntityClass, "getHandle");
|
||||||
|
|
||||||
private static Object noGravityDataWatcher = BountifulWrapper.impl.getDataWatcherObject(5, Boolean.class);
|
private static Object noGravityDataWatcher = BountifulWrapper.impl.getDataWatcherObject(5, Boolean.class);
|
||||||
private static Object fuseDataWatcher = BountifulWrapper.impl.getDataWatcherObject(8, Integer.class);
|
private static Object fuseDataWatcher = BountifulWrapper.impl.getDataWatcherObject(8, Integer.class);
|
||||||
|
|||||||
+5
-5
@@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
package de.steamwar.bausystem.features.tpslimit;
|
package de.steamwar.bausystem.features.tpslimit;
|
||||||
|
|
||||||
import de.steamwar.Reflection;
|
import com.comphenix.tinyprotocol.Reflection;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.experimental.UtilityClass;
|
import lombok.experimental.UtilityClass;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
@@ -28,11 +28,11 @@ import org.bukkit.World;
|
|||||||
@UtilityClass
|
@UtilityClass
|
||||||
public class TPSFreezeUtils {
|
public class TPSFreezeUtils {
|
||||||
|
|
||||||
private static Reflection.Field<Boolean> fieldAccessor;
|
private static Reflection.FieldAccessor<Boolean> fieldAccessor;
|
||||||
@Getter
|
@Getter
|
||||||
private static final boolean canFreeze;
|
private static final boolean canFreeze;
|
||||||
|
|
||||||
private static final Reflection.Method getWorldHandle = Reflection.getTypedMethod(Reflection.getClass("org.bukkit.craftbukkit.CraftWorld"), "getHandle", null);
|
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;
|
||||||
@@ -40,9 +40,9 @@ public class TPSFreezeUtils {
|
|||||||
private static final World world = Bukkit.getWorlds().get(0);
|
private static final World world = Bukkit.getWorlds().get(0);
|
||||||
|
|
||||||
static {
|
static {
|
||||||
Reflection.Field<Boolean> fieldAccessor;
|
Reflection.FieldAccessor<Boolean> fieldAccessor;
|
||||||
try {
|
try {
|
||||||
fieldAccessor = Reflection.getField(Reflection.getClass("net.minecraft.server.level.ServerLevel"), "freezed", boolean.class);
|
fieldAccessor = Reflection.getField(Reflection.getClass("{nms.server.level}.WorldServer"), "freezed", boolean.class);
|
||||||
} catch (IllegalArgumentException e) {
|
} catch (IllegalArgumentException e) {
|
||||||
fieldAccessor = null;
|
fieldAccessor = null;
|
||||||
}
|
}
|
||||||
|
|||||||
+6
-3
@@ -19,12 +19,15 @@
|
|||||||
|
|
||||||
package de.steamwar.bausystem.features.tpslimit;
|
package de.steamwar.bausystem.features.tpslimit;
|
||||||
|
|
||||||
import de.steamwar.Reflection;
|
import com.comphenix.tinyprotocol.Reflection;
|
||||||
import com.comphenix.tinyprotocol.TinyProtocol;
|
import com.comphenix.tinyprotocol.TinyProtocol;
|
||||||
|
import de.steamwar.bausystem.SWUtils;
|
||||||
import de.steamwar.bausystem.utils.PlayerMovementWrapper;
|
import de.steamwar.bausystem.utils.PlayerMovementWrapper;
|
||||||
import de.steamwar.core.Core;
|
import de.steamwar.core.Core;
|
||||||
|
import de.steamwar.core.TPSWatcher;
|
||||||
import lombok.experimental.UtilityClass;
|
import lombok.experimental.UtilityClass;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.World;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.scheduler.BukkitTask;
|
import org.bukkit.scheduler.BukkitTask;
|
||||||
|
|
||||||
@@ -101,8 +104,8 @@ public class TPSLimitUtils {
|
|||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
private static final Class<?> position = Reflection.getClass("net.minecraft.network.protocol.game.ServerboundMovePlayerPacket$Pos");
|
private static final Class<?> position = Reflection.getClass("{nms.network.protocol.game}.PacketPlayInFlying$PacketPlayInPosition");
|
||||||
private static final Class<?> positionLook = Reflection.getClass("net.minecraft.network.protocol.game.ServerboundMovePlayerPacket$PosRot");
|
private static final Class<?> positionLook = Reflection.getClass("{nms.network.protocol.game}.PacketPlayInFlying$PacketPlayInPositionLook");
|
||||||
static {
|
static {
|
||||||
BiFunction<Player, Object, Object> positionSetter = (player, o) -> {
|
BiFunction<Player, Object, Object> positionSetter = (player, o) -> {
|
||||||
if (tpsLimiter != null) {
|
if (tpsLimiter != null) {
|
||||||
|
|||||||
@@ -38,7 +38,6 @@ import de.steamwar.inventory.SWAnvilInv;
|
|||||||
import de.steamwar.inventory.SWItem;
|
import de.steamwar.inventory.SWItem;
|
||||||
import de.steamwar.linkage.Linked;
|
import de.steamwar.linkage.Linked;
|
||||||
import de.steamwar.linkage.LinkedInstance;
|
import de.steamwar.linkage.LinkedInstance;
|
||||||
import de.steamwar.linkage.MaxVersion;
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
@@ -52,7 +51,6 @@ import org.bukkit.inventory.ItemStack;
|
|||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
||||||
@Linked
|
@Linked
|
||||||
@MaxVersion(20) // Hotfix for 1.21 tps limit! -> Backport coming later
|
|
||||||
public class TPSSystem implements Listener {
|
public class TPSSystem implements Listener {
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
|
|||||||
@@ -22,8 +22,6 @@ package de.steamwar.bausystem.features.tracer;
|
|||||||
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 lombok.AccessLevel;
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
@@ -41,9 +39,8 @@ import java.util.Optional;
|
|||||||
/**
|
/**
|
||||||
* Recording of a tnt at a specific tick
|
* Recording of a tnt at a specific tick
|
||||||
*/
|
*/
|
||||||
@AllArgsConstructor(access = AccessLevel.PACKAGE)
|
|
||||||
@Getter
|
@Getter
|
||||||
public class TNTPoint{
|
public class TNTPoint implements Externalizable {
|
||||||
/**
|
/**
|
||||||
* Unique number to identify records being of the same tnt
|
* Unique number to identify records being of the same tnt
|
||||||
*/
|
*/
|
||||||
@@ -100,9 +97,12 @@ public class TNTPoint{
|
|||||||
private List<TNTPoint> history;
|
private List<TNTPoint> history;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor for object creation in trace recording
|
* Constructor for deserialization only !! Do not Call !!
|
||||||
*/
|
*/
|
||||||
protected TNTPoint(int tntId, TNTPrimed tnt, boolean explosion, boolean afterFirstExplosion, long ticksSinceStart,
|
public TNTPoint() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public TNTPoint(int tntId, TNTPrimed tnt, boolean explosion, boolean afterFirstExplosion, long ticksSinceStart,
|
||||||
List<TNTPoint> history, List<Block> destroyedBlocks) {
|
List<TNTPoint> history, List<Block> destroyedBlocks) {
|
||||||
this.tntId = tntId;
|
this.tntId = tntId;
|
||||||
this.explosion = explosion;
|
this.explosion = explosion;
|
||||||
@@ -161,6 +161,44 @@ public class TNTPoint{
|
|||||||
this.history = history;
|
this.history = history;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void writeExternal(ObjectOutput objectOutput) throws IOException {
|
||||||
|
objectOutput.writeInt(tntId);
|
||||||
|
objectOutput.writeBoolean(explosion);
|
||||||
|
objectOutput.writeBoolean(inWater);
|
||||||
|
objectOutput.writeBoolean(afterFirstExplosion);
|
||||||
|
objectOutput.writeBoolean(destroyedBuildArea);
|
||||||
|
objectOutput.writeBoolean(destroyedTestBlock);
|
||||||
|
objectOutput.writeLong(ticksSinceStart);
|
||||||
|
objectOutput.writeInt(fuse);
|
||||||
|
objectOutput.writeDouble(location.getX());
|
||||||
|
objectOutput.writeDouble(location.getY());
|
||||||
|
objectOutput.writeDouble(location.getZ());
|
||||||
|
objectOutput.writeDouble(velocity.getX());
|
||||||
|
objectOutput.writeDouble(velocity.getY());
|
||||||
|
objectOutput.writeDouble(velocity.getZ());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void readExternal(ObjectInput objectInput) throws IOException {
|
||||||
|
tntId = objectInput.readInt();
|
||||||
|
explosion = objectInput.readBoolean();
|
||||||
|
inWater = objectInput.readBoolean();
|
||||||
|
afterFirstExplosion = objectInput.readBoolean();
|
||||||
|
destroyedBuildArea = objectInput.readBoolean();
|
||||||
|
destroyedTestBlock = objectInput.readBoolean();
|
||||||
|
ticksSinceStart = objectInput.readLong();
|
||||||
|
fuse = objectInput.readInt();
|
||||||
|
double locX = objectInput.readDouble();
|
||||||
|
double locY = objectInput.readDouble();
|
||||||
|
double locZ = objectInput.readDouble();
|
||||||
|
location = new Location(Bukkit.getWorlds().get(0), locX, locY, locZ);
|
||||||
|
double velX = objectInput.readDouble();
|
||||||
|
double velY = objectInput.readDouble();
|
||||||
|
double velZ = objectInput.readDouble();
|
||||||
|
velocity = new Vector(velX, velY, velZ);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "TNTPoint{" +
|
return "TNTPoint{" +
|
||||||
|
|||||||
@@ -26,16 +26,20 @@ import de.steamwar.bausystem.features.tracer.rendering.ViewFlag;
|
|||||||
import de.steamwar.bausystem.region.Region;
|
import de.steamwar.bausystem.region.Region;
|
||||||
import de.steamwar.entity.REntity;
|
import de.steamwar.entity.REntity;
|
||||||
import de.steamwar.entity.REntityServer;
|
import de.steamwar.entity.REntityServer;
|
||||||
|
import lombok.Cleanup;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
|
||||||
import lombok.SneakyThrows;
|
import lombok.SneakyThrows;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.*;
|
||||||
import java.lang.ref.SoftReference;
|
import java.lang.ref.SoftReference;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
import java.util.logging.Logger;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
import java.util.zip.GZIPInputStream;
|
||||||
|
|
||||||
public class Trace {
|
public class Trace {
|
||||||
/**
|
/**
|
||||||
@@ -73,10 +77,6 @@ public class Trace {
|
|||||||
*/
|
*/
|
||||||
private SoftReference<List<TNTPoint>> records;
|
private SoftReference<List<TNTPoint>> records;
|
||||||
|
|
||||||
@Setter
|
|
||||||
@Getter
|
|
||||||
private int recordsCount;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A map of all REntityServers rendering this trace
|
* A map of all REntityServers rendering this trace
|
||||||
*/
|
*/
|
||||||
@@ -91,25 +91,46 @@ public class Trace {
|
|||||||
@SneakyThrows
|
@SneakyThrows
|
||||||
public Trace(Region region, List<TNTPoint> recordList) {
|
public Trace(Region region, List<TNTPoint> recordList) {
|
||||||
this.uuid = UUID.randomUUID();
|
this.uuid = UUID.randomUUID();
|
||||||
|
recordsSaveFile = new File(TraceManager.tracesFolder, uuid + ".records");
|
||||||
this.region = region;
|
this.region = region;
|
||||||
this.date = new Date();
|
this.date = new Date();
|
||||||
records = new SoftReference<>(recordList);
|
records = new SoftReference<>(recordList);
|
||||||
recordsSaveFile = new File(TraceRepository.tracesFolder, uuid + ".records");
|
metadataSaveFile = new File(TraceManager.tracesFolder, uuid + ".meta");
|
||||||
metadataSaveFile = new File(TraceRepository.tracesFolder, uuid + ".meta");
|
|
||||||
|
@Cleanup
|
||||||
|
ObjectOutputStream outputStream = new ObjectOutputStream(new FileOutputStream(metadataSaveFile));
|
||||||
|
outputStream.writeUTF(uuid.toString());
|
||||||
|
outputStream.writeUTF(region.getName());
|
||||||
|
outputStream.writeObject(date);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor for deserialising a trace from the file system
|
* Constructor for serialising a trace from the file system
|
||||||
|
*
|
||||||
|
* @param metadataSaveFile the file for this traces metadata
|
||||||
*/
|
*/
|
||||||
@SneakyThrows
|
@SneakyThrows
|
||||||
protected Trace(UUID uuid, Region region, Date date, File metadataFile, File recordsFile, int recordsCount) {
|
public Trace(File metadataSaveFile) {
|
||||||
this.metadataSaveFile = metadataFile;
|
String uuid = null;
|
||||||
recordsSaveFile = recordsFile;
|
Region region = null;
|
||||||
this.uuid = uuid;
|
Date date = null;
|
||||||
this.region = region;
|
|
||||||
this.date = date;
|
this.metadataSaveFile = metadataSaveFile;
|
||||||
this.records = new SoftReference<>(null);
|
|
||||||
this.recordsCount = recordsCount;
|
try {
|
||||||
|
@Cleanup
|
||||||
|
ObjectInputStream inputStream = new ObjectInputStream(new FileInputStream(metadataSaveFile));
|
||||||
|
uuid = inputStream.readUTF();
|
||||||
|
region = Region.getREGION_MAP().get(inputStream.readUTF());
|
||||||
|
date = (Date) inputStream.readObject();
|
||||||
|
inputStream.close();
|
||||||
|
} finally {
|
||||||
|
this.uuid = UUID.fromString(uuid);
|
||||||
|
this.region = region;
|
||||||
|
this.date = date;
|
||||||
|
recordsSaveFile = new File(TraceManager.tracesFolder, uuid + ".records");
|
||||||
|
this.records = new SoftReference<>(null);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -152,8 +173,7 @@ public class Trace {
|
|||||||
entityServer = new REntityServer();
|
entityServer = new REntityServer();
|
||||||
entityServer.addPlayer(player);
|
entityServer.addPlayer(player);
|
||||||
entityServer.setCallback((p, rEntity, entityAction) -> {
|
entityServer.setCallback((p, rEntity, entityAction) -> {
|
||||||
if (entityAction != REntityServer.EntityAction.INTERACT)
|
if (entityAction != REntityServer.EntityAction.INTERACT) return;
|
||||||
return;
|
|
||||||
if (rEntity instanceof TraceEntity) {
|
if (rEntity instanceof TraceEntity) {
|
||||||
((TraceEntity) rEntity).printIntoChat(p);
|
((TraceEntity) rEntity).printIntoChat(p);
|
||||||
}
|
}
|
||||||
@@ -175,8 +195,7 @@ public class Trace {
|
|||||||
REntityServer newEntityServer = new REntityServer();
|
REntityServer newEntityServer = new REntityServer();
|
||||||
newEntityServer.addPlayer(k);
|
newEntityServer.addPlayer(k);
|
||||||
newEntityServer.setCallback((p, rEntity, entityAction) -> {
|
newEntityServer.setCallback((p, rEntity, entityAction) -> {
|
||||||
if (entityAction != REntityServer.EntityAction.INTERACT)
|
if (entityAction != REntityServer.EntityAction.INTERACT) return;
|
||||||
return;
|
|
||||||
if (rEntity instanceof TraceEntity) {
|
if (rEntity instanceof TraceEntity) {
|
||||||
((TraceEntity) rEntity).printIntoChat(p);
|
((TraceEntity) rEntity).printIntoChat(p);
|
||||||
}
|
}
|
||||||
@@ -215,8 +234,7 @@ public class Trace {
|
|||||||
List<TraceEntity> entities = new LinkedList<>();
|
List<TraceEntity> entities = new LinkedList<>();
|
||||||
|
|
||||||
for (List<TNTPoint> bundle : bundles) {
|
for (List<TNTPoint> bundle : bundles) {
|
||||||
entities.add(new TraceEntity(entityServer, bundle.get(0).getLocation(), bundle.get(0).isExplosion(), bundle,
|
entities.add(new TraceEntity(entityServer, bundle.get(0).getLocation(), bundle.get(0).isExplosion(), bundle, this));
|
||||||
this));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Apply modifiers
|
// Apply modifiers
|
||||||
@@ -294,7 +312,38 @@ public class Trace {
|
|||||||
* Loads the records of this trace from storage to memory
|
* Loads the records of this trace from storage to memory
|
||||||
*/
|
*/
|
||||||
private void loadRecords() {
|
private void loadRecords() {
|
||||||
records = new SoftReference<>(TraceRepository.readTraceRecords(this));
|
List<TNTPoint> records = new ArrayList<>();
|
||||||
|
long readBytes = 0;
|
||||||
|
try {
|
||||||
|
FileInputStream fileInputStream = new FileInputStream(recordsSaveFile);
|
||||||
|
|
||||||
|
@Cleanup
|
||||||
|
ObjectInputStream inputStream = new ObjectInputStream(new GZIPInputStream(fileInputStream));
|
||||||
|
long fileLenght = recordsSaveFile.length();
|
||||||
|
while (fileInputStream.getChannel().position() < fileLenght) {
|
||||||
|
records.add((TNTPoint) inputStream.readObject());
|
||||||
|
readBytes = fileInputStream.getChannel().position();
|
||||||
|
}
|
||||||
|
} catch (EOFException e) {
|
||||||
|
Logger logger = Bukkit.getLogger();
|
||||||
|
logger.log(Level.WARNING, "EOF in trace read detected in " + uuid);
|
||||||
|
logger.log(Level.WARNING, "Read " + readBytes + "/" + recordsSaveFile.length() + " Bytes");
|
||||||
|
logger.log(Level.WARNING, "Read so far: " + records);
|
||||||
|
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (IOException | ClassNotFoundException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<Integer, List<TNTPoint>> histories = new HashMap<>();
|
||||||
|
for (TNTPoint record : records) {
|
||||||
|
int tntId = record.getTntId();
|
||||||
|
List<TNTPoint> history = histories.computeIfAbsent(tntId, id -> new ArrayList<>());
|
||||||
|
history.add(record);
|
||||||
|
record.setHistory(history);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.records = new SoftReference<>(records);
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized List<TNTPoint> getRecords() {
|
public synchronized List<TNTPoint> getRecords() {
|
||||||
@@ -311,7 +360,6 @@ public class Trace {
|
|||||||
", region=" + region +
|
", region=" + region +
|
||||||
", creationTime=" + date +
|
", creationTime=" + date +
|
||||||
", recordsSaveFile=" + recordsSaveFile.getName() +
|
", recordsSaveFile=" + recordsSaveFile.getName() +
|
||||||
", recordCount=" + recordsCount +
|
|
||||||
", records=" + getRecords() +
|
", records=" + getRecords() +
|
||||||
'}';
|
'}';
|
||||||
}
|
}
|
||||||
|
|||||||
+6
-18
@@ -30,14 +30,11 @@ 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;
|
||||||
import org.bukkit.event.player.PlayerQuitEvent;
|
import org.bukkit.event.player.PlayerQuitEvent;
|
||||||
import org.bukkit.event.server.PluginEnableEvent;
|
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import static de.steamwar.bausystem.features.tracer.TraceRepository.tracesFolder;
|
|
||||||
|
|
||||||
@Linked
|
@Linked
|
||||||
public class TraceManager implements Listener {
|
public class TraceManager implements Listener {
|
||||||
|
|
||||||
@@ -47,9 +44,9 @@ public class TraceManager implements Listener {
|
|||||||
instance = this;
|
instance = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static File tracesFolder = new File(Bukkit.getWorlds().get(0).getWorldFolder(), "traces");
|
||||||
|
|
||||||
|
public TraceManager() {
|
||||||
public void init() {
|
|
||||||
if (!tracesFolder.exists())
|
if (!tracesFolder.exists())
|
||||||
tracesFolder.mkdir();
|
tracesFolder.mkdir();
|
||||||
|
|
||||||
@@ -61,15 +58,7 @@ public class TraceManager implements Listener {
|
|||||||
if (traceFile.getName().contains(".records"))
|
if (traceFile.getName().contains(".records"))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (TraceRepository.getVersion(traceFile) == TraceRepository.SERIALISATION_VERSION) {
|
add(new Trace(traceFile));
|
||||||
add(TraceRepository.readTrace(traceFile));
|
|
||||||
} else {
|
|
||||||
String uuid = traceFile.getName().replace(".meta", "");
|
|
||||||
|
|
||||||
new File(tracesFolder, uuid + ".records").deleteOnExit();
|
|
||||||
new File(tracesFolder, uuid + ".meta").deleteOnExit();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -142,18 +131,17 @@ public class TraceManager implements Listener {
|
|||||||
*
|
*
|
||||||
* @param trace the trace to be removed
|
* @param trace the trace to be removed
|
||||||
*/
|
*/
|
||||||
public void remove(Trace trace) {
|
public boolean remove(Trace trace) {
|
||||||
Map<Integer, Trace> traces = tracesByRegion.getOrDefault(trace.getRegion(), Collections.emptyMap());
|
Map<Integer, Trace> traces = tracesByRegion.getOrDefault(trace.getRegion(), Collections.emptyMap());
|
||||||
Integer traceId = traces.entrySet().stream()
|
Integer traceId = traces.entrySet().stream()
|
||||||
.filter(entry -> entry.getValue() == trace)
|
.filter(entry -> entry.getValue() == trace)
|
||||||
.map(Map.Entry::getKey)
|
.map(Map.Entry::getKey)
|
||||||
.findFirst()
|
.findFirst()
|
||||||
.orElse(null);
|
.orElse(null);
|
||||||
if (traceId == null) throw new RuntimeException("Trace not found while trying to remove see (c978eb98-b0b2-4009-91d8-acfa34e2831a)");
|
if (traceId == null) return false;
|
||||||
traces.remove(traceId);
|
traces.remove(traceId);
|
||||||
trace.hide();
|
trace.hide();
|
||||||
trace.getMetadataSaveFile().delete();
|
return true;
|
||||||
trace.getRecordsSaveFile().delete();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
+4
-4
@@ -31,7 +31,6 @@ import org.bukkit.event.EventPriority;
|
|||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.entity.EntityExplodeEvent;
|
import org.bukkit.event.entity.EntityExplodeEvent;
|
||||||
import org.bukkit.event.entity.EntitySpawnEvent;
|
import org.bukkit.event.entity.EntitySpawnEvent;
|
||||||
import org.bukkit.event.server.PluginEnableEvent;
|
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
@@ -71,7 +70,7 @@ public class TraceRecorder implements Listener {
|
|||||||
*/
|
*/
|
||||||
private final Set<Region> autoTraceRegions = new HashSet<>();
|
private final Set<Region> autoTraceRegions = new HashSet<>();
|
||||||
|
|
||||||
public void init() {
|
public TraceRecorder() {
|
||||||
BauSystem.runTaskTimer(BauSystem.getInstance(), () -> {
|
BauSystem.runTaskTimer(BauSystem.getInstance(), () -> {
|
||||||
record();
|
record();
|
||||||
checkForAutoTraceFinish();
|
checkForAutoTraceFinish();
|
||||||
@@ -171,13 +170,14 @@ public class TraceRecorder implements Listener {
|
|||||||
if (history.size() == 0) {
|
if (history.size() == 0) {
|
||||||
try {
|
try {
|
||||||
historyMap.put(tntPrimed, history);
|
historyMap.put(tntPrimed, history);
|
||||||
} catch (NullPointerException e) {
|
}
|
||||||
|
catch (NullPointerException e) {
|
||||||
Logger logger = Bukkit.getLogger();
|
Logger logger = Bukkit.getLogger();
|
||||||
//TODO remove when no longer neccecary
|
//TODO remove when no longer neccecary
|
||||||
logger.log(Level.WARNING, "Nullpointer thrown by historyMap");
|
logger.log(Level.WARNING, "Nullpointer thrown by historyMap");
|
||||||
logger.log(Level.WARNING, "TNT History: " + history);
|
logger.log(Level.WARNING, "TNT History: " + history);
|
||||||
logger.log(Level.WARNING, "History Map: " + historyMap);
|
logger.log(Level.WARNING, "History Map: " + historyMap);
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
tntID = wrappedTrace.getNextOpenRecordIdAndIncrement();
|
tntID = wrappedTrace.getNextOpenRecordIdAndIncrement();
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
+22
-5
@@ -24,22 +24,28 @@ import de.steamwar.bausystem.region.Region;
|
|||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.SneakyThrows;
|
import lombok.SneakyThrows;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.ObjectOutputStream;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.zip.GZIPOutputStream;
|
||||||
|
|
||||||
public class TraceRecordingWrapper {
|
public class TraceRecordingWrapper {
|
||||||
|
|
||||||
@Getter
|
|
||||||
private final Trace trace;
|
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
private final long startTick;
|
private final long startTick;
|
||||||
private final List<TNTPoint> recordsToAdd;
|
private final List<TNTPoint> recordsToAdd;
|
||||||
private final List<TNTPoint> recordList;
|
private final List<TNTPoint> recordList;
|
||||||
|
private final ObjectOutputStream recordsOutputStream;
|
||||||
private int nextOpenRecordId = 0;
|
private int nextOpenRecordId = 0;
|
||||||
@Getter
|
@Getter
|
||||||
private boolean explosionRecorded = false;
|
private boolean explosionRecorded = false;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
private final Trace trace;
|
||||||
|
|
||||||
@SneakyThrows
|
@SneakyThrows
|
||||||
public TraceRecordingWrapper(Region region) {
|
public TraceRecordingWrapper(Region region) {
|
||||||
startTick = TPSUtils.currentRealTick.get();
|
startTick = TPSUtils.currentRealTick.get();
|
||||||
@@ -47,6 +53,8 @@ public class TraceRecordingWrapper {
|
|||||||
recordList = new ArrayList<>();
|
recordList = new ArrayList<>();
|
||||||
|
|
||||||
trace = new Trace(region, recordList);
|
trace = new Trace(region, recordList);
|
||||||
|
File recordsSaveFile = new File(TraceManager.tracesFolder, trace.getUuid() + ".records");
|
||||||
|
recordsOutputStream = new ObjectOutputStream(new GZIPOutputStream(new FileOutputStream(recordsSaveFile)));
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getNextOpenRecordIdAndIncrement() {
|
public int getNextOpenRecordIdAndIncrement() {
|
||||||
@@ -64,14 +72,23 @@ public class TraceRecordingWrapper {
|
|||||||
public void commitRecorded() {
|
public void commitRecorded() {
|
||||||
TraceManager.instance.showPartial(trace, recordsToAdd);
|
TraceManager.instance.showPartial(trace, recordsToAdd);
|
||||||
|
|
||||||
|
recordsToAdd.forEach(record -> {
|
||||||
|
try {
|
||||||
|
recordsOutputStream.writeObject(record);
|
||||||
|
recordsOutputStream.flush();
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
recordList.addAll(recordsToAdd);
|
recordList.addAll(recordsToAdd);
|
||||||
trace.setRecordsCount(recordList.size());
|
|
||||||
recordsToAdd.clear();
|
recordsToAdd.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
@SneakyThrows
|
@SneakyThrows
|
||||||
protected void finalizeRecording() {
|
protected void finalizeRecording() {
|
||||||
TraceRepository.writeTrace(trace, recordList);
|
recordsOutputStream.flush();
|
||||||
|
recordsOutputStream.close();
|
||||||
TraceManager.instance.add(trace);
|
TraceManager.instance.add(trace);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
-136
@@ -1,136 +0,0 @@
|
|||||||
package de.steamwar.bausystem.features.tracer;
|
|
||||||
|
|
||||||
import de.steamwar.bausystem.region.Region;
|
|
||||||
import lombok.Cleanup;
|
|
||||||
import lombok.SneakyThrows;
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.bukkit.util.Vector;
|
|
||||||
|
|
||||||
import java.io.*;
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
public class TraceRepository {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Increment this when changing serialisation format
|
|
||||||
*/
|
|
||||||
public static final int SERIALISATION_VERSION = 1;
|
|
||||||
public static File tracesFolder = new File(Bukkit.getWorlds().get(0).getWorldFolder(), "traces");
|
|
||||||
|
|
||||||
@SneakyThrows
|
|
||||||
protected static int getVersion(File metadataFile) {
|
|
||||||
@Cleanup
|
|
||||||
ObjectInputStream reader = new ObjectInputStream(new FileInputStream(metadataFile));
|
|
||||||
reader.readUTF();
|
|
||||||
reader.readUTF();
|
|
||||||
reader.readObject();
|
|
||||||
try {
|
|
||||||
int version = reader.readInt();
|
|
||||||
return version;
|
|
||||||
} catch (EOFException e) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@SneakyThrows
|
|
||||||
public static Trace readTrace(File metadataFile) {
|
|
||||||
@Cleanup
|
|
||||||
ObjectInputStream reader = new ObjectInputStream(new FileInputStream(metadataFile));
|
|
||||||
UUID uuid = UUID.fromString(reader.readUTF());
|
|
||||||
Region region = Region.getREGION_MAP().get(reader.readUTF());
|
|
||||||
Date date = (Date) reader.readObject();
|
|
||||||
File recordsFile = new File(tracesFolder,uuid + ".records");
|
|
||||||
int serialisationVersion = reader.readInt();
|
|
||||||
int recordsCount = reader.readInt();
|
|
||||||
|
|
||||||
return new Trace(uuid, region, date, metadataFile, recordsFile, recordsCount);
|
|
||||||
}
|
|
||||||
|
|
||||||
@SneakyThrows
|
|
||||||
protected static void writeTrace(Trace trace, List<TNTPoint> records) {
|
|
||||||
ObjectOutputStream outputStream = new ObjectOutputStream(new FileOutputStream(trace.getMetadataSaveFile()));
|
|
||||||
outputStream.writeUTF(trace.getUuid().toString());
|
|
||||||
outputStream.writeUTF(trace.getRegion().getName());
|
|
||||||
outputStream.writeObject(trace.getDate());
|
|
||||||
outputStream.writeInt(SERIALISATION_VERSION);
|
|
||||||
outputStream.writeInt(records.size());
|
|
||||||
outputStream.flush();
|
|
||||||
outputStream.close();
|
|
||||||
|
|
||||||
|
|
||||||
writeTraceRecords(trace.getRecordsSaveFile(), records);
|
|
||||||
}
|
|
||||||
|
|
||||||
@SneakyThrows
|
|
||||||
protected static void writeTraceRecords(File recordsFile, List<TNTPoint> records) {
|
|
||||||
DataOutputStream outputStream = new DataOutputStream(new FileOutputStream(recordsFile));
|
|
||||||
for (TNTPoint record : records) {
|
|
||||||
outputStream.writeInt(record.getTntId());
|
|
||||||
outputStream.writeBoolean(record.isExplosion());
|
|
||||||
outputStream.writeBoolean(record.isInWater());
|
|
||||||
outputStream.writeBoolean(record.isAfterFirstExplosion());
|
|
||||||
outputStream.writeBoolean(record.isDestroyedBuildArea());
|
|
||||||
outputStream.writeBoolean(record.isDestroyedTestBlock());
|
|
||||||
outputStream.writeLong(record.getTicksSinceStart());
|
|
||||||
outputStream.writeInt(record.getFuse());
|
|
||||||
Location location = record.getLocation();
|
|
||||||
outputStream.writeDouble(location.getX());
|
|
||||||
outputStream.writeDouble(location.getY());
|
|
||||||
outputStream.writeDouble(location.getZ());
|
|
||||||
Vector velocity = record.getVelocity();
|
|
||||||
outputStream.writeDouble(velocity.getX());
|
|
||||||
outputStream.writeDouble(velocity.getY());
|
|
||||||
outputStream.writeDouble(velocity.getZ());
|
|
||||||
}
|
|
||||||
outputStream.flush();
|
|
||||||
outputStream.close();
|
|
||||||
}
|
|
||||||
|
|
||||||
@SneakyThrows
|
|
||||||
protected static TNTPoint readTraceRecord(DataInputStream objectInput) {
|
|
||||||
|
|
||||||
int tntId = objectInput.readInt();
|
|
||||||
boolean explosion = objectInput.readBoolean();
|
|
||||||
boolean inWater = objectInput.readBoolean();
|
|
||||||
boolean afterFirstExplosion = objectInput.readBoolean();
|
|
||||||
boolean destroyedBuildArea = objectInput.readBoolean();
|
|
||||||
boolean destroyedTestBlock = objectInput.readBoolean();
|
|
||||||
long ticksSinceStart = objectInput.readLong();
|
|
||||||
int fuse = objectInput.readInt();
|
|
||||||
|
|
||||||
double locX = objectInput.readDouble();
|
|
||||||
double locY = objectInput.readDouble();
|
|
||||||
double locZ = objectInput.readDouble();
|
|
||||||
Location location = new Location(Bukkit.getWorlds().get(0), locX, locY, locZ);
|
|
||||||
|
|
||||||
double velX = objectInput.readDouble();
|
|
||||||
double velY = objectInput.readDouble();
|
|
||||||
double velZ = objectInput.readDouble();
|
|
||||||
Vector velocity = new Vector(velX, velY, velZ);
|
|
||||||
|
|
||||||
return new TNTPoint(tntId, explosion, inWater, afterFirstExplosion, destroyedBuildArea, destroyedTestBlock, ticksSinceStart, fuse, location, velocity, Collections.emptyList());
|
|
||||||
}
|
|
||||||
|
|
||||||
@SneakyThrows
|
|
||||||
protected static List<TNTPoint> readTraceRecords(Trace trace) {
|
|
||||||
File recordsFile = trace.getRecordsSaveFile();
|
|
||||||
@Cleanup
|
|
||||||
DataInputStream inputStream = new DataInputStream(new FileInputStream(recordsFile));
|
|
||||||
|
|
||||||
List<TNTPoint> records = new ArrayList<>();
|
|
||||||
for (int i = 0; i < trace.getRecordsCount(); i++) {
|
|
||||||
records.add(readTraceRecord(inputStream));
|
|
||||||
}
|
|
||||||
|
|
||||||
Map<Integer, List<TNTPoint>> histories = new HashMap<>();
|
|
||||||
for (TNTPoint record : records) {
|
|
||||||
int tntId = record.getTntId();
|
|
||||||
List<TNTPoint> history = histories.computeIfAbsent(tntId, id -> new ArrayList<>());
|
|
||||||
history.add(record);
|
|
||||||
record.setHistory(history);
|
|
||||||
}
|
|
||||||
|
|
||||||
return records;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
package de.steamwar.bausystem.features.util;
|
package de.steamwar.bausystem.features.util;
|
||||||
|
|
||||||
import de.steamwar.Reflection;
|
import com.comphenix.tinyprotocol.Reflection;
|
||||||
import com.comphenix.tinyprotocol.TinyProtocol;
|
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;
|
||||||
@@ -49,15 +49,15 @@ import java.util.function.BiFunction;
|
|||||||
@Linked
|
@Linked
|
||||||
public class NoClipCommand extends SWCommand implements Listener {
|
public class NoClipCommand extends SWCommand implements Listener {
|
||||||
|
|
||||||
public static final Class<?> gameStateChange = Reflection.getClass("net.minecraft.network.protocol.game.ClientboundGameEventPacket");
|
public static final Class<?> gameStateChange = Reflection.getClass("{nms.network.protocol.game}.PacketPlayOutGameStateChange");
|
||||||
private static final Reflection.Field<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("net.minecraft.network.protocol.game.ServerboundMovePlayerPacket$Pos");
|
private static final Class<?> position = Reflection.getClass("{nms.network.protocol.game}.PacketPlayInFlying$PacketPlayInPosition");
|
||||||
private static final Class<?> positionLook = Reflection.getClass("net.minecraft.network.protocol.game.ServerboundMovePlayerPacket$PosRot");
|
private static final Class<?> positionLook = Reflection.getClass("{nms.network.protocol.game}.PacketPlayInFlying$PacketPlayInPositionLook");
|
||||||
private static final Class<?> useItem = Reflection.getClass("net.minecraft.network.protocol.game.ServerboundUseItemOnPacket");
|
private static final Class<?> useItem = Reflection.getClass("{nms.network.protocol.game}.PacketPlayInUseItem");
|
||||||
private static final Class<?> blockDig = Reflection.getClass("net.minecraft.network.protocol.game.ServerboundPlayerActionPacket");
|
private static final Class<?> blockDig = Reflection.getClass("{nms.network.protocol.game}.PacketPlayInBlockDig");
|
||||||
private static final Class<?> windowClick = Reflection.getClass("net.minecraft.network.protocol.game.ServerboundContainerClickPacket");
|
private static final Class<?> windowClick = Reflection.getClass("{nms.network.protocol.game}.PacketPlayInWindowClick");
|
||||||
private static final Class<?> setSlotStack = Reflection.getClass("net.minecraft.network.protocol.game.ServerboundSetCreativeModeSlotPacket");
|
private static final Class<?> setSlotStack = Reflection.getClass("{nms.network.protocol.game}.PacketPlayInSetCreativeSlot");
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
private static final List<Player> NOCLIPS = new ArrayList<>();
|
private static final List<Player> NOCLIPS = new ArrayList<>();
|
||||||
|
|||||||
@@ -42,15 +42,6 @@ public class SkullCommand extends SWCommand {
|
|||||||
super("skull", "head");
|
super("skull", "head");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Register
|
|
||||||
public void giveCommand(@Validator Player p) {
|
|
||||||
if (p.getName().startsWith(".")) {
|
|
||||||
BauSystem.MESSAGE.send("SKULL_INVALID", p);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
giveCommand(p, p.getName());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Register(description = "SKULL_HELP")
|
@Register(description = "SKULL_HELP")
|
||||||
public void giveCommand(@Validator Player p, @Mapper("player") @ErrorMessage("SKULL_INVALID") String skull) {
|
public void giveCommand(@Validator Player p, @Mapper("player") @ErrorMessage("SKULL_INVALID") String skull) {
|
||||||
ItemStack is = SWItem.getPlayerSkull(skull).getItemStack();
|
ItemStack is = SWItem.getPlayerSkull(skull).getItemStack();
|
||||||
@@ -72,7 +63,7 @@ public class SkullCommand extends SWCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> tabCompletes(CommandSender commandSender, PreviousArguments previousArguments, String s) {
|
public List<String> tabCompletes(CommandSender commandSender, PreviousArguments previousArguments, String s) {
|
||||||
return Bukkit.getOnlinePlayers().stream().map(Player::getName).filter(s1 -> !s1.startsWith(".")).collect(Collectors.toList());
|
return Bukkit.getOnlinePlayers().stream().map(Player::getName).filter(s1 -> !s1.endsWith("⍇")).collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,12 +39,12 @@ public class SpeedCommand extends SWCommand {
|
|||||||
|
|
||||||
@Register
|
@Register
|
||||||
public void speedCommand(Player p, float speed) {
|
public void speedCommand(Player p, float speed) {
|
||||||
if (speed < -10F) {
|
speed = speed / 10F;
|
||||||
|
if (speed < -1F) {
|
||||||
BauSystem.MESSAGE.send("SPEED_TOO_SMALL", p, speed);
|
BauSystem.MESSAGE.send("SPEED_TOO_SMALL", p, speed);
|
||||||
} else if (speed > 10F) {
|
} else if (speed > 1F) {
|
||||||
BauSystem.MESSAGE.send("SPEED_TOO_HIGH", p, speed);
|
BauSystem.MESSAGE.send("SPEED_TOO_HIGH", p, speed);
|
||||||
} else {
|
} else {
|
||||||
speed = speed / 10F;
|
|
||||||
p.setFlySpeed(speed);
|
p.setFlySpeed(speed);
|
||||||
p.setWalkSpeed(Math.min(speed + 0.1F, 1F));
|
p.setWalkSpeed(Math.min(speed + 0.1F, 1F));
|
||||||
BauSystem.MESSAGE.send("SPEED_CURRENT", p, (p.getFlySpeed() * 10F));
|
BauSystem.MESSAGE.send("SPEED_CURRENT", p, (p.getFlySpeed() * 10F));
|
||||||
|
|||||||
+1
@@ -47,6 +47,7 @@ public class NightVisionBauGuiItem extends BauGuiItem {
|
|||||||
PotionMeta meta = (PotionMeta) itemStack.getItemMeta();
|
PotionMeta meta = (PotionMeta) itemStack.getItemMeta();
|
||||||
meta.setColor(PotionEffectType.NIGHT_VISION.getColor());
|
meta.setColor(PotionEffectType.NIGHT_VISION.getColor());
|
||||||
meta.setDisplayName(BauSystem.MESSAGE.parse("NIGHT_VISION_ITEM_ON", player));
|
meta.setDisplayName(BauSystem.MESSAGE.parse("NIGHT_VISION_ITEM_ON", player));
|
||||||
|
meta.addItemFlags(ItemFlag.HIDE_POTION_EFFECTS);
|
||||||
meta.setCustomModelData(1);
|
meta.setCustomModelData(1);
|
||||||
itemStack.setItemMeta(meta);
|
itemStack.setItemMeta(meta);
|
||||||
return itemStack;
|
return itemStack;
|
||||||
|
|||||||
-6
@@ -20,7 +20,6 @@
|
|||||||
package de.steamwar.bausystem.features.world;
|
package de.steamwar.bausystem.features.world;
|
||||||
|
|
||||||
import de.steamwar.bausystem.BauSystem;
|
import de.steamwar.bausystem.BauSystem;
|
||||||
import de.steamwar.core.CRIUWakeupEvent;
|
|
||||||
import de.steamwar.core.CheckpointUtils;
|
import de.steamwar.core.CheckpointUtils;
|
||||||
import de.steamwar.linkage.Linked;
|
import de.steamwar.linkage.Linked;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
@@ -70,9 +69,4 @@ public class AFKStopperListener implements Listener {
|
|||||||
if(Bukkit.getOnlinePlayers().isEmpty() || (Bukkit.getOnlinePlayers().size() == 1 && Bukkit.getOnlinePlayers().contains(event.getPlayer())))
|
if(Bukkit.getOnlinePlayers().isEmpty() || (Bukkit.getOnlinePlayers().size() == 1 && Bukkit.getOnlinePlayers().contains(event.getPlayer())))
|
||||||
CheckpointUtils.freeze();
|
CheckpointUtils.freeze();
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void onCRIUWakeup(CRIUWakeupEvent event) {
|
|
||||||
lastMovementTime = System.currentTimeMillis();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-6
@@ -21,7 +21,6 @@ package de.steamwar.bausystem.features.world;
|
|||||||
|
|
||||||
import de.steamwar.bausystem.BauSystem;
|
import de.steamwar.bausystem.BauSystem;
|
||||||
import de.steamwar.bausystem.config.BauServer;
|
import de.steamwar.bausystem.config.BauServer;
|
||||||
import de.steamwar.core.CRIUWakeupEvent;
|
|
||||||
import de.steamwar.linkage.Linked;
|
import de.steamwar.linkage.Linked;
|
||||||
import de.steamwar.sql.BauweltMember;
|
import de.steamwar.sql.BauweltMember;
|
||||||
import de.steamwar.sql.SteamwarUser;
|
import de.steamwar.sql.SteamwarUser;
|
||||||
@@ -33,6 +32,7 @@ import org.bukkit.event.player.PlayerJoinEvent;
|
|||||||
@Linked
|
@Linked
|
||||||
public class AntiBauAddMemberFix implements Listener {
|
public class AntiBauAddMemberFix implements Listener {
|
||||||
|
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.LOW)
|
@EventHandler(priority = EventPriority.LOW)
|
||||||
public void onPlayerJoin(PlayerJoinEvent event) {
|
public void onPlayerJoin(PlayerJoinEvent event) {
|
||||||
if (BauSystem.DEV_SERVER) return;
|
if (BauSystem.DEV_SERVER) return;
|
||||||
@@ -44,9 +44,4 @@ public class AntiBauAddMemberFix implements Listener {
|
|||||||
throw new SecurityException("The player " + event.getPlayer().getName() + " joined on the server of " + SteamwarUser.get(BauServer.getInstance().getOwnerID()).getUserName() + " without being added!");
|
throw new SecurityException("The player " + event.getPlayer().getName() + " joined on the server of " + SteamwarUser.get(BauServer.getInstance().getOwnerID()).getUserName() + " without being added!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void onCRIUWakeup(CRIUWakeupEvent event) {
|
|
||||||
BauweltMember.clear();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
package de.steamwar.bausystem.features.world;
|
package de.steamwar.bausystem.features.world;
|
||||||
|
|
||||||
import de.steamwar.Reflection;
|
import com.comphenix.tinyprotocol.Reflection;
|
||||||
import com.comphenix.tinyprotocol.TinyProtocol;
|
import com.comphenix.tinyprotocol.TinyProtocol;
|
||||||
import de.steamwar.bausystem.BauSystem;
|
import de.steamwar.bausystem.BauSystem;
|
||||||
import de.steamwar.linkage.Linked;
|
import de.steamwar.linkage.Linked;
|
||||||
@@ -32,7 +32,7 @@ public class AntiCursorReCentering implements Enable {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void enable() {
|
public void enable() {
|
||||||
Class<?> closeWindow = Reflection.getClass("net.minecraft.network.protocol.game.ClientboundContainerClosePacket");
|
Class<?> closeWindow = Reflection.getClass("{nms.network.protocol.game}.PacketPlayOutCloseWindow");
|
||||||
TinyProtocol.instance.addFilter(closeWindow, (player, object) -> {
|
TinyProtocol.instance.addFilter(closeWindow, (player, object) -> {
|
||||||
if (player.getOpenInventory().getTopInventory().getType() == InventoryType.CRAFTING) {
|
if (player.getOpenInventory().getTopInventory().getType() == InventoryType.CRAFTING) {
|
||||||
return object;
|
return object;
|
||||||
|
|||||||
+1
-1
@@ -56,7 +56,7 @@ public class BauScoreboard implements Listener {
|
|||||||
public void handlePlayerJoin(PlayerJoinEvent event) {
|
public void handlePlayerJoin(PlayerJoinEvent event) {
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
|
|
||||||
SWScoreboard.impl.createScoreboard(player, new ScoreboardCallback() {
|
SWScoreboard.createScoreboard(player, new ScoreboardCallback() {
|
||||||
@Override
|
@Override
|
||||||
public HashMap<String, Integer> getData() {
|
public HashMap<String, Integer> getData() {
|
||||||
Region region = Region.getRegion(player.getLocation());
|
Region region = Region.getRegion(player.getLocation());
|
||||||
|
|||||||
+2
-2
@@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
package de.steamwar.bausystem.features.world;
|
package de.steamwar.bausystem.features.world;
|
||||||
|
|
||||||
import de.steamwar.Reflection;
|
import com.comphenix.tinyprotocol.Reflection;
|
||||||
import com.comphenix.tinyprotocol.TinyProtocol;
|
import com.comphenix.tinyprotocol.TinyProtocol;
|
||||||
import de.steamwar.bausystem.utils.NMSWrapper;
|
import de.steamwar.bausystem.utils.NMSWrapper;
|
||||||
import de.steamwar.linkage.Linked;
|
import de.steamwar.linkage.Linked;
|
||||||
@@ -29,7 +29,7 @@ import org.bukkit.GameMode;
|
|||||||
public class NoCreativeKnockback {
|
public class NoCreativeKnockback {
|
||||||
|
|
||||||
public NoCreativeKnockback() {
|
public NoCreativeKnockback() {
|
||||||
TinyProtocol.instance.addFilter(Reflection.getClass("net.minecraft.network.protocol.game.ClientboundExplodePacket"), (player, o) -> {
|
TinyProtocol.instance.addFilter(Reflection.getClass("{nms.network.protocol.game}.PacketPlayOutExplosion"), (player, o) -> {
|
||||||
if (player.getGameMode() != GameMode.CREATIVE) return o;
|
if (player.getGameMode() != GameMode.CREATIVE) return o;
|
||||||
return NMSWrapper.impl.resetExplosionKnockback(o);
|
return NMSWrapper.impl.resetExplosionKnockback(o);
|
||||||
});
|
});
|
||||||
|
|||||||
+14
-14
@@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
package de.steamwar.bausystem.features.world;
|
package de.steamwar.bausystem.features.world;
|
||||||
|
|
||||||
import de.steamwar.Reflection;
|
import com.comphenix.tinyprotocol.Reflection;
|
||||||
import com.comphenix.tinyprotocol.TinyProtocol;
|
import com.comphenix.tinyprotocol.TinyProtocol;
|
||||||
import de.steamwar.bausystem.BauSystem;
|
import de.steamwar.bausystem.BauSystem;
|
||||||
import de.steamwar.bausystem.Permission;
|
import de.steamwar.bausystem.Permission;
|
||||||
@@ -48,21 +48,21 @@ import org.bukkit.util.Vector;
|
|||||||
@MinVersion(20)
|
@MinVersion(20)
|
||||||
public class SignEditFrom20 implements Listener {
|
public class SignEditFrom20 implements Listener {
|
||||||
|
|
||||||
private static final Class<?> blockPosition = Reflection.getClass("net.minecraft.core.BlockPos");
|
private static final Class<?> blockPosition = Reflection.getClass("{nms.core}.BlockPosition");
|
||||||
private static final Class<?> craftBlock = Reflection.getClass("org.bukkit.craftbukkit.block.CraftBlock");
|
private static final Class<?> craftBlock = Reflection.getClass("{obc}.block.CraftBlock");
|
||||||
private static final Class<?> craftWorld = Reflection.getClass("org.bukkit.craftbukkit.CraftWorld");
|
private static final Class<?> craftWorld = Reflection.getClass("{obc}.CraftWorld");
|
||||||
private static final Class<?> generatorAccess = Reflection.getClass("net.minecraft.world.level.LevelAccessor");
|
private static final Class<?> generatorAccess = Reflection.getClass("{nms.world.level}.GeneratorAccess");
|
||||||
private static final Reflection.Method getPosition = Reflection.getTypedMethod(craftBlock, "getPosition", blockPosition);
|
private static final Reflection.MethodInvoker getPosition = Reflection.getTypedMethod(craftBlock, "getPosition", blockPosition);
|
||||||
private static final Reflection.Method getWorldHandle = Reflection.getTypedMethod(craftWorld, "getHandle", null);
|
private static final Reflection.MethodInvoker getWorldHandle = Reflection.getTypedMethod(craftWorld, "getHandle", null);
|
||||||
private static final Reflection.Method at = Reflection.getTypedMethod(craftBlock, "at", craftBlock, generatorAccess, blockPosition);
|
private static final Reflection.MethodInvoker at = Reflection.getTypedMethod(craftBlock, "at", craftBlock, generatorAccess, blockPosition);
|
||||||
|
|
||||||
private static final Class<?> openSign = Reflection.getClass("net.minecraft.network.protocol.game.ClientboundOpenSignEditorPacket");
|
private static final Class<?> openSign = Reflection.getClass("{nms.network.protocol.game}.PacketPlayOutOpenSignEditor");
|
||||||
private static final Reflection.Field<?> blockPositionFieldAccessor = Reflection.getField(openSign, blockPosition, 0);
|
private static final Reflection.FieldAccessor<?> blockPositionFieldAccessor = Reflection.getField(openSign, blockPosition, 0);
|
||||||
private static final Reflection.Field<?> sideFieldAccessor = Reflection.getField(openSign, boolean.class, 0);
|
private static final Reflection.FieldAccessor<?> sideFieldAccessor = Reflection.getField(openSign, boolean.class, 0);
|
||||||
|
|
||||||
private static final Class<?> updateSign = Reflection.getClass("net.minecraft.network.protocol.game.ServerboundSignUpdatePacket");
|
private static final Class<?> updateSign = Reflection.getClass("{nms.network.protocol.game}.PacketPlayInUpdateSign");
|
||||||
private static final Reflection.Field<?> getBlockPositionFieldAccessor = Reflection.getField(updateSign, blockPosition, 0);
|
private static final Reflection.FieldAccessor<?> getBlockPositionFieldAccessor = Reflection.getField(updateSign, blockPosition, 0);
|
||||||
private static final Reflection.Field<String[]> stringFieldAccessor = Reflection.getField(updateSign, String[].class, 0);
|
private static final Reflection.FieldAccessor<String[]> stringFieldAccessor = Reflection.getField(updateSign, String[].class, 0);
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void editSign(PlayerInteractEvent event) {
|
public void editSign(PlayerInteractEvent event) {
|
||||||
|
|||||||
+13
-13
@@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
package de.steamwar.bausystem.features.world;
|
package de.steamwar.bausystem.features.world;
|
||||||
|
|
||||||
import de.steamwar.Reflection;
|
import com.comphenix.tinyprotocol.Reflection;
|
||||||
import com.comphenix.tinyprotocol.TinyProtocol;
|
import com.comphenix.tinyprotocol.TinyProtocol;
|
||||||
import de.steamwar.bausystem.BauSystem;
|
import de.steamwar.bausystem.BauSystem;
|
||||||
import de.steamwar.bausystem.Permission;
|
import de.steamwar.bausystem.Permission;
|
||||||
@@ -40,20 +40,20 @@ import org.bukkit.event.player.PlayerInteractEvent;
|
|||||||
@MaxVersion(19)
|
@MaxVersion(19)
|
||||||
public class SignEditUntil19 implements Listener {
|
public class SignEditUntil19 implements Listener {
|
||||||
|
|
||||||
private static final Class<?> blockPosition = Reflection.getClass("net.minecraft.core.BlockPos");
|
private static final Class<?> blockPosition = Reflection.getClass("{nms.core}.BlockPosition");
|
||||||
private static final Class<?> craftBlock = Reflection.getClass("org.bukkit.craftbukkit.block.CraftBlock");
|
private static final Class<?> craftBlock = Reflection.getClass("{obc}.block.CraftBlock");
|
||||||
private static final Class<?> craftWorld = Reflection.getClass("org.bukkit.craftbukkit.CraftWorld");
|
private static final Class<?> craftWorld = Reflection.getClass("{obc}.CraftWorld");
|
||||||
private static final Class<?> generatorAccess = Reflection.getClass("net.minecraft.world.level.LevelAccessor");
|
private static final Class<?> generatorAccess = Reflection.getClass("{nms.world.level}.GeneratorAccess");
|
||||||
private static final Reflection.Method getPosition = Reflection.getTypedMethod(craftBlock, "getPosition", blockPosition);
|
private static final Reflection.MethodInvoker getPosition = Reflection.getTypedMethod(craftBlock, "getPosition", blockPosition);
|
||||||
private static final Reflection.Method getWorldHandle = Reflection.getTypedMethod(craftWorld, "getHandle", null);
|
private static final Reflection.MethodInvoker getWorldHandle = Reflection.getTypedMethod(craftWorld, "getHandle", null);
|
||||||
private static final Reflection.Method at = Reflection.getTypedMethod(craftBlock, "at", craftBlock, generatorAccess, blockPosition);
|
private static final Reflection.MethodInvoker at = Reflection.getTypedMethod(craftBlock, "at", craftBlock, generatorAccess, blockPosition);
|
||||||
|
|
||||||
private static final Class<?> openSign = Reflection.getClass("net.minecraft.network.protocol.game.ClientboundOpenSignEditorPacket");
|
private static final Class<?> openSign = Reflection.getClass("{nms.network.protocol.game}.PacketPlayOutOpenSignEditor");
|
||||||
private static final Reflection.Field<?> blockPositionFieldAccessor = Reflection.getField(openSign, blockPosition, 0);
|
private static final Reflection.FieldAccessor<?> blockPositionFieldAccessor = Reflection.getField(openSign, blockPosition, 0);
|
||||||
|
|
||||||
private static final Class<?> updateSign = Reflection.getClass("net.minecraft.network.protocol.game.ServerboundSignUpdatePacket");
|
private static final Class<?> updateSign = Reflection.getClass("{nms.network.protocol.game}.PacketPlayInUpdateSign");
|
||||||
private static final Reflection.Field<?> getBlockPositionFieldAccessor = Reflection.getField(updateSign, blockPosition, 0);
|
private static final Reflection.FieldAccessor<?> getBlockPositionFieldAccessor = Reflection.getField(updateSign, blockPosition, 0);
|
||||||
private static final Reflection.Field<String[]> stringFieldAccessor = Reflection.getField(updateSign, String[].class, 0);
|
private static final Reflection.FieldAccessor<String[]> stringFieldAccessor = Reflection.getField(updateSign, String[].class, 0);
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void editSign(PlayerInteractEvent event) {
|
public void editSign(PlayerInteractEvent event) {
|
||||||
|
|||||||
-92
@@ -1,92 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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.features.world;
|
|
||||||
|
|
||||||
import com.sk89q.worldedit.regions.RegionSelector;
|
|
||||||
import de.steamwar.bausystem.BauSystem;
|
|
||||||
import de.steamwar.bausystem.shared.Pair;
|
|
||||||
import de.steamwar.bausystem.utils.WorldEditUtils;
|
|
||||||
import de.steamwar.linkage.Linked;
|
|
||||||
import de.steamwar.linkage.MinVersion;
|
|
||||||
import de.steamwar.sql.SteamwarUser;
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.bukkit.event.EventHandler;
|
|
||||||
import org.bukkit.event.Listener;
|
|
||||||
import org.bukkit.event.player.PlayerJoinEvent;
|
|
||||||
import org.bukkit.event.player.PlayerQuitEvent;
|
|
||||||
import org.checkerframework.checker.units.qual.min;
|
|
||||||
|
|
||||||
import java.io.*;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.logging.Level;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
@Linked
|
|
||||||
@MinVersion(18)
|
|
||||||
public class WorldEditSelectionSaver implements Listener {
|
|
||||||
|
|
||||||
private File WORLD_EDIT_SELECTIONS = new File(Bukkit.getWorlds().get(0).getWorldFolder(), "world_edit_selections");
|
|
||||||
|
|
||||||
{
|
|
||||||
WORLD_EDIT_SELECTIONS.mkdir();
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void onPlayerJoin(PlayerJoinEvent event) {
|
|
||||||
SteamwarUser steamwarUser = SteamwarUser.get(event.getPlayer().getUniqueId());
|
|
||||||
File file = new File(WORLD_EDIT_SELECTIONS, Integer.toString(steamwarUser.getId()));
|
|
||||||
if (!file.exists()) return;
|
|
||||||
try {
|
|
||||||
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(new FileInputStream(file)));
|
|
||||||
Class<? extends RegionSelector> clazz = (Class<? extends RegionSelector>) Class.forName(bufferedReader.readLine());
|
|
||||||
List<Location> locations = bufferedReader.lines()
|
|
||||||
.map(s -> s.split(" "))
|
|
||||||
.map(strings -> strings.length != 3 ? null : new Location(event.getPlayer().getWorld(), Integer.parseInt(strings[0]), Integer.parseInt(strings[1]), Integer.parseInt(strings[2])))
|
|
||||||
.collect(Collectors.toList());
|
|
||||||
WorldEditUtils.setVertices(event.getPlayer(), clazz, locations);
|
|
||||||
} catch (IOException | ClassNotFoundException e) {
|
|
||||||
BauSystem.getInstance().getLogger().log(Level.SEVERE, e.getMessage(), e);
|
|
||||||
file.delete();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void onPlayerQuit(PlayerQuitEvent event) {
|
|
||||||
SteamwarUser steamwarUser = SteamwarUser.get(event.getPlayer().getUniqueId());
|
|
||||||
Pair<Class<? extends RegionSelector>, List<Location>> data = WorldEditUtils.getVertices(event.getPlayer());
|
|
||||||
File file = new File(WORLD_EDIT_SELECTIONS, Integer.toString(steamwarUser.getId()));
|
|
||||||
try {
|
|
||||||
BufferedWriter bufferedWriter = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file)));
|
|
||||||
bufferedWriter.write(data.getKey().getTypeName());
|
|
||||||
for (Location location : data.getValue()) {
|
|
||||||
if (location == null) {
|
|
||||||
bufferedWriter.write("\n");
|
|
||||||
} else {
|
|
||||||
bufferedWriter.write("\n" + location.getBlockX() + " " + location.getBlockY() + " " + location.getBlockZ());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
bufferedWriter.close();
|
|
||||||
} catch (IOException e) {
|
|
||||||
BauSystem.getInstance().getLogger().log(Level.SEVERE, e.getMessage(), e);
|
|
||||||
file.delete();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
package de.steamwar.bausystem.features.xray;
|
package de.steamwar.bausystem.features.xray;
|
||||||
|
|
||||||
import de.steamwar.Reflection;
|
import com.comphenix.tinyprotocol.Reflection;
|
||||||
import com.comphenix.tinyprotocol.TinyProtocol;
|
import com.comphenix.tinyprotocol.TinyProtocol;
|
||||||
import de.steamwar.bausystem.BauSystem;
|
import de.steamwar.bausystem.BauSystem;
|
||||||
import de.steamwar.bausystem.features.techhider.TechHiderCommand;
|
import de.steamwar.bausystem.features.techhider.TechHiderCommand;
|
||||||
@@ -108,8 +108,8 @@ public class XrayCommand extends SWCommand implements Listener, ScoreboardElemen
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final Class<?> position = Reflection.getClass("net.minecraft.network.protocol.game.ServerboundMovePlayerPacket$Pos");
|
private static final Class<?> position = Reflection.getClass("{nms.network.protocol.game}.PacketPlayInFlying$PacketPlayInPosition");
|
||||||
private static final Class<?> positionLook = Reflection.getClass("net.minecraft.network.protocol.game.ServerboundMovePlayerPacket$PosRot");
|
private static final Class<?> positionLook = Reflection.getClass("{nms.network.protocol.game}.PacketPlayInFlying$PacketPlayInPositionLook");
|
||||||
|
|
||||||
{
|
{
|
||||||
BiFunction<Player, Object, Object> positionSetter = (player, o) -> {
|
BiFunction<Player, Object, Object> positionSetter = (player, o) -> {
|
||||||
|
|||||||
@@ -21,40 +21,41 @@ package de.steamwar.bausystem.region.flags;
|
|||||||
|
|
||||||
import de.steamwar.bausystem.region.flags.flagvalues.*;
|
import de.steamwar.bausystem.region.flags.flagvalues.*;
|
||||||
import de.steamwar.bausystem.shared.EnumDisplay;
|
import de.steamwar.bausystem.shared.EnumDisplay;
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
|
||||||
import java.util.EnumSet;
|
import java.util.EnumSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
@AllArgsConstructor
|
|
||||||
public enum Flag implements EnumDisplay {
|
public enum Flag implements EnumDisplay {
|
||||||
|
|
||||||
COLOR("FLAG_COLOR", ColorMode.class, ColorMode.YELLOW, false),
|
COLOR("FLAG_COLOR", ColorMode.class, ColorMode.YELLOW),
|
||||||
TNT("FLAG_TNT", TNTMode.class, TNTMode.ONLY_TB, true),
|
TNT("FLAG_TNT", TNTMode.class, TNTMode.ONLY_TB),
|
||||||
FIRE("FLAG_FIRE", FireMode.class, FireMode.ALLOW, true),
|
FIRE("FLAG_FIRE", FireMode.class, FireMode.ALLOW),
|
||||||
FREEZE("FLAG_FREEZE", FreezeMode.class, FreezeMode.INACTIVE, true),
|
FREEZE("FLAG_FREEZE", FreezeMode.class, FreezeMode.INACTIVE),
|
||||||
PROTECT("FLAG_PROTECT", ProtectMode.class, ProtectMode.ACTIVE, true),
|
PROTECT("FLAG_PROTECT", ProtectMode.class, ProtectMode.ACTIVE),
|
||||||
ITEMS("FLAG_ITEMS", ItemMode.class, ItemMode.INACTIVE, true),
|
ITEMS("FLAG_ITEMS", ItemMode.class, ItemMode.INACTIVE),
|
||||||
NO_GRAVITY("FLAG_NO_GRAVITY", NoGravityMode.class, NoGravityMode.INACTIVE, true),
|
NO_GRAVITY("FLAG_NO_GRAVITY", NoGravityMode.class, NoGravityMode.INACTIVE),
|
||||||
;
|
;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
private static final Set<Flag> flags;
|
private static final Set<Flag> flags;
|
||||||
@Getter
|
|
||||||
private static final Set<Flag> resetFlags;
|
|
||||||
|
|
||||||
static {
|
static {
|
||||||
flags = EnumSet.allOf(Flag.class);
|
flags = EnumSet.allOf(Flag.class);
|
||||||
resetFlags = flags.stream().filter(flag -> flag.reset).collect(Collectors.toUnmodifiableSet());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private final String chatValue;
|
private final String chatValue;
|
||||||
private final Class<? extends Value<?>> valueType;
|
private final Class<? extends Value<?>> valueType;
|
||||||
private final Flag.Value<?> defaultValue;
|
private final Flag.Value<?> defaultValue;
|
||||||
private final boolean reset;
|
private final Value<?>[] values;
|
||||||
|
|
||||||
|
<T extends Enum<T> & Value<T>> Flag(String chatValue, final Class<? extends Value<T>> valueType, final Flag.Value<T> defaultValue) {
|
||||||
|
this.chatValue = chatValue;
|
||||||
|
this.valueType = valueType;
|
||||||
|
this.defaultValue = defaultValue;
|
||||||
|
this.values = defaultValue.getValues();
|
||||||
|
}
|
||||||
|
|
||||||
public Value<?> getFlagValueOf(final String name) {
|
public Value<?> getFlagValueOf(final String name) {
|
||||||
return this.defaultValue.getValueOf(name);
|
return this.defaultValue.getValueOf(name);
|
||||||
|
|||||||
@@ -24,7 +24,6 @@ import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
|||||||
import com.sk89q.worldedit.function.pattern.WaterloggedRemover;
|
import com.sk89q.worldedit.function.pattern.WaterloggedRemover;
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||||
import com.sk89q.worldedit.world.block.BlockType;
|
|
||||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||||
import de.steamwar.bausystem.region.Color;
|
import de.steamwar.bausystem.region.Color;
|
||||||
import de.steamwar.bausystem.region.Point;
|
import de.steamwar.bausystem.region.Point;
|
||||||
@@ -35,7 +34,9 @@ import lombok.NonNull;
|
|||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.*;
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
import java.util.function.BiConsumer;
|
import java.util.function.BiConsumer;
|
||||||
import java.util.function.BiPredicate;
|
import java.util.function.BiPredicate;
|
||||||
|
|
||||||
@@ -105,28 +106,51 @@ public class PasteBuilder {
|
|||||||
public PasteBuilder color(Color color) {
|
public PasteBuilder color(Color color) {
|
||||||
if (color == Color.PINK) return this;
|
if (color == Color.PINK) return this;
|
||||||
|
|
||||||
Map<String, BaseBlock> blockCache = new HashMap<>();
|
BaseBlock WOOL = Objects.requireNonNull(BlockTypes.PINK_WOOL).getDefaultState().toBaseBlock();
|
||||||
|
BaseBlock CLAY = Objects.requireNonNull(BlockTypes.PINK_TERRACOTTA).getDefaultState().toBaseBlock();
|
||||||
|
BaseBlock GLAZED = Objects.requireNonNull(BlockTypes.PINK_GLAZED_TERRACOTTA).getDefaultState().toBaseBlock();
|
||||||
|
BaseBlock GLASS = Objects.requireNonNull(BlockTypes.PINK_STAINED_GLASS).getDefaultState().toBaseBlock();
|
||||||
|
BaseBlock GLASS_PANE = Objects.requireNonNull(BlockTypes.PINK_STAINED_GLASS_PANE).getDefaultState().toBaseBlock();
|
||||||
|
BaseBlock CONCRETE = Objects.requireNonNull(BlockTypes.PINK_CONCRETE).getDefaultState().toBaseBlock();
|
||||||
|
BaseBlock CONCRETE_POWDER = Objects.requireNonNull(BlockTypes.PINK_CONCRETE_POWDER).getDefaultState().toBaseBlock();
|
||||||
|
BaseBlock CARPET = Objects.requireNonNull(BlockTypes.PINK_CARPET).getDefaultState().toBaseBlock();
|
||||||
|
|
||||||
|
BaseBlock wool = Objects.requireNonNull(BlockTypes.get(color.name().toLowerCase() + "_wool")).getDefaultState().toBaseBlock();
|
||||||
|
BaseBlock clay = Objects.requireNonNull(BlockTypes.get(color.name().toLowerCase() + "_terracotta")).getDefaultState().toBaseBlock();
|
||||||
|
BaseBlock glazed = Objects.requireNonNull(BlockTypes.get(color.name().toLowerCase() + "_glazed_terracotta")).getDefaultState().toBaseBlock();
|
||||||
|
BaseBlock glass = Objects.requireNonNull(BlockTypes.get(color.name().toLowerCase() + "_stained_glass")).getDefaultState().toBaseBlock();
|
||||||
|
BaseBlock glassPane = Objects.requireNonNull(BlockTypes.get(color.name().toLowerCase() + "_stained_glass_pane")).getDefaultState().toBaseBlock();
|
||||||
|
BaseBlock carpet = Objects.requireNonNull(BlockTypes.get(color.name().toLowerCase() + "_carpet")).getDefaultState().toBaseBlock();
|
||||||
|
BaseBlock concrete = Objects.requireNonNull(BlockTypes.get(color.name().toLowerCase() + "_concrete")).getDefaultState().toBaseBlock();
|
||||||
|
BaseBlock concretePowder = Objects.requireNonNull(BlockTypes.get(color.name().toLowerCase() + "_concrete_powder")).getDefaultState().toBaseBlock();
|
||||||
|
|
||||||
return map((clipboard, blockVector3) -> {
|
return map((clipboard, blockVector3) -> {
|
||||||
BaseBlock block = clipboard.getFullBlock(blockVector3);
|
BaseBlock block = clipboard.getFullBlock(blockVector3);
|
||||||
if (block.getBlockType().getId().startsWith("minecraft:pink_")) {
|
if (block.equals(WOOL)) {
|
||||||
BaseBlock baseBlock = blockCache.computeIfAbsent(block.getBlockType().getId(), s -> {
|
clipboard.setBlock(blockVector3, wool);
|
||||||
String replaced = s.replace("minecraft:pink_", "minecraft:" + color.name().toLowerCase() + "_");
|
} else if (block.equals(CLAY)) {
|
||||||
BlockType blockType = BlockTypes.get(replaced);
|
clipboard.setBlock(blockVector3, clay);
|
||||||
if (blockType == null) return null;
|
} else if (block.equals(GLAZED)) {
|
||||||
return blockType.getDefaultState().toBaseBlock();
|
clipboard.setBlock(blockVector3, glazed);
|
||||||
});
|
} else if (block.equals(GLASS)) {
|
||||||
if (baseBlock == null) return;
|
clipboard.setBlock(blockVector3, glass);
|
||||||
clipboard.setBlock(blockVector3, baseBlock);
|
} else if (block.equals(GLASS_PANE)) {
|
||||||
|
clipboard.setBlock(blockVector3, glassPane);
|
||||||
|
} else if (block.equals(CARPET)) {
|
||||||
|
clipboard.setBlock(blockVector3, carpet);
|
||||||
|
} else if (block.equals(CONCRETE)) {
|
||||||
|
clipboard.setBlock(blockVector3, concrete);
|
||||||
|
} else if (block.equals(CONCRETE_POWDER)) {
|
||||||
|
clipboard.setBlock(blockVector3, concretePowder);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Can only be used before {@link #color(Color)}.
|
|
||||||
*/
|
|
||||||
public PasteBuilder onlyColors(boolean onlyColors) {
|
public PasteBuilder onlyColors(boolean onlyColors) {
|
||||||
if (!onlyColors) return this;
|
if (!onlyColors) return this;
|
||||||
return only((baseBlock, s) -> s.startsWith("minecraft:pink_"));
|
return only((baseBlock, s) -> {
|
||||||
|
return s.endsWith("_wool") || s.endsWith("_terracotta") || s.endsWith("_glazed_terracotta") || s.endsWith("_stained_glass") || s.endsWith("_stained_glass_pane") || s.endsWith("_carpet") || s.endsWith("_concrete") || s.endsWith("_concrete_powder");
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public PasteBuilder removeTNT(boolean removeTNT) {
|
public PasteBuilder removeTNT(boolean removeTNT) {
|
||||||
|
|||||||
@@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
package de.steamwar.bausystem.utils;
|
package de.steamwar.bausystem.utils;
|
||||||
|
|
||||||
import de.steamwar.Reflection;
|
import com.comphenix.tinyprotocol.Reflection;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.experimental.UtilityClass;
|
import lombok.experimental.UtilityClass;
|
||||||
@@ -81,12 +81,12 @@ public class PlaceItemUtils {
|
|||||||
.collect(Collectors.toSet());
|
.collect(Collectors.toSet());
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final Class<?> blockPosition = Reflection.getClass("net.minecraft.core.BlockPos");
|
private static final Class<?> blockPosition = Reflection.getClass("{nms.core}.BlockPosition");
|
||||||
private static final Reflection.Constructor blockPositionConstructor = Reflection.getConstructor(blockPosition, int.class, int.class, int.class);
|
private static final Reflection.ConstructorInvoker blockPositionConstructor = Reflection.getConstructor(blockPosition, int.class, int.class, int.class);
|
||||||
private static final Class<?> craftBlock = Reflection.getClass("org.bukkit.craftbukkit.block.CraftBlockState");
|
private static final Class<?> craftBlock = Reflection.getClass("{obc}.block.CraftBlockState");
|
||||||
private static final Class<?> craftWorld = Reflection.getClass("org.bukkit.craftbukkit.CraftWorld");
|
private static final Class<?> craftWorld = Reflection.getClass("{obc}.CraftWorld");
|
||||||
private static final Reflection.Field<?> positionAccessor = Reflection.getField(craftBlock, blockPosition, 0);
|
private static final Reflection.FieldAccessor<?> positionAccessor = Reflection.getField(craftBlock, blockPosition, 0);
|
||||||
private static final Reflection.Field<?> worldAccessor = Reflection.getField(craftBlock, craftWorld, 0);
|
private static final Reflection.FieldAccessor<?> worldAccessor = Reflection.getField(craftBlock, craftWorld, 0);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Attempt to place an {@link ItemStack} the {@link Player} is holding against a {@link Block} inside the World.
|
* Attempt to place an {@link ItemStack} the {@link Player} is holding against a {@link Block} inside the World.
|
||||||
|
|||||||
+11
-5
@@ -19,20 +19,26 @@
|
|||||||
|
|
||||||
package de.steamwar.bausystem.utils;
|
package de.steamwar.bausystem.utils;
|
||||||
|
|
||||||
import de.steamwar.Reflection;
|
import com.comphenix.tinyprotocol.Reflection;
|
||||||
import de.steamwar.bausystem.BauSystem;
|
import de.steamwar.bausystem.BauSystem;
|
||||||
import de.steamwar.core.BountifulWrapper;
|
import de.steamwar.core.BountifulWrapper;
|
||||||
|
import de.steamwar.core.Core;
|
||||||
import de.steamwar.core.VersionDependent;
|
import de.steamwar.core.VersionDependent;
|
||||||
import de.steamwar.entity.REntity;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
public interface PlayerMovementWrapper {
|
public interface PlayerMovementWrapper {
|
||||||
Class<?> teleportPacket = REntity.teleportPacket;
|
Class<?> teleportPacket = Reflection.getClass("{nms.network.protocol.game}.PacketPlayOutEntityTeleport");
|
||||||
Reflection.Field<Integer> teleportEntity = REntity.teleportEntity;
|
Reflection.FieldAccessor<Integer> teleportEntity = Reflection.getField(teleportPacket, Integer.TYPE, 0);
|
||||||
BountifulWrapper.PositionSetter teleportPosition = REntity.teleportPosition;
|
BountifulWrapper.PositionSetter teleportPosition = BountifulWrapper.impl.getPositionSetter(teleportPacket, Core.getVersion() == 8 ? 1 : 0);
|
||||||
|
Reflection.FieldAccessor<Byte> teleportYaw = Reflection.getField(teleportPacket, Byte.TYPE, 0);
|
||||||
|
Reflection.FieldAccessor<Byte> teleportPitch = Reflection.getField(teleportPacket, Byte.TYPE, 1);
|
||||||
|
|
||||||
PlayerMovementWrapper impl = VersionDependent.getVersionImpl(BauSystem.getInstance());
|
PlayerMovementWrapper impl = VersionDependent.getVersionImpl(BauSystem.getInstance());
|
||||||
|
|
||||||
void setPosition(Player player, Object object);
|
void setPosition(Player player, Object object);
|
||||||
Object convertToOut(Player player, Object object);
|
Object convertToOut(Player player, Object object);
|
||||||
|
|
||||||
|
default byte rotToByte(float rot) {
|
||||||
|
return (byte)((int)(rot * 256.0F / 360.0F));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,49 @@
|
|||||||
|
/*
|
||||||
|
* 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.viaversion.viaversion.api.Via;
|
||||||
|
import com.viaversion.viaversion.api.ViaAPI;
|
||||||
|
import de.steamwar.bausystem.BauSystem;
|
||||||
|
import de.steamwar.linkage.Linked;
|
||||||
|
import net.md_5.bungee.api.ChatMessageType;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.event.player.PlayerJoinEvent;
|
||||||
|
|
||||||
|
@Linked
|
||||||
|
public class VersionAnnouncer implements Listener {
|
||||||
|
|
||||||
|
private final String versionString = Bukkit.getBukkitVersion().split("-", 2)[0];
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
private final ViaAPI<Player> via = Via.getAPI();
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onJoin(PlayerJoinEvent event) {
|
||||||
|
Player player = event.getPlayer();
|
||||||
|
if(via.getServerVersion().supportedVersions().contains(via.getPlayerVersion(player)))
|
||||||
|
return;
|
||||||
|
|
||||||
|
BauSystem.MESSAGE.sendPrefixless("SERVER_VERSION", player, ChatMessageType.ACTION_BAR, versionString);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -19,21 +19,17 @@
|
|||||||
|
|
||||||
package de.steamwar.bausystem.utils;
|
package de.steamwar.bausystem.utils;
|
||||||
|
|
||||||
import de.steamwar.Reflection;
|
|
||||||
import com.sk89q.worldedit.EditSession;
|
import com.sk89q.worldedit.EditSession;
|
||||||
import com.sk89q.worldedit.IncompleteRegionException;
|
import com.sk89q.worldedit.IncompleteRegionException;
|
||||||
import com.sk89q.worldedit.LocalSession;
|
|
||||||
import com.sk89q.worldedit.WorldEdit;
|
import com.sk89q.worldedit.WorldEdit;
|
||||||
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||||
import com.sk89q.worldedit.extension.factory.PatternFactory;
|
import com.sk89q.worldedit.extension.factory.PatternFactory;
|
||||||
import com.sk89q.worldedit.extension.platform.permission.ActorSelectorLimits;
|
|
||||||
import com.sk89q.worldedit.function.mask.Mask;
|
import com.sk89q.worldedit.function.mask.Mask;
|
||||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||||
import com.sk89q.worldedit.internal.registry.InputParser;
|
import com.sk89q.worldedit.internal.registry.InputParser;
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
import com.sk89q.worldedit.regions.Region;
|
import com.sk89q.worldedit.regions.Region;
|
||||||
import com.sk89q.worldedit.regions.RegionSelector;
|
import com.sk89q.worldedit.regions.RegionSelector;
|
||||||
import com.sk89q.worldedit.regions.selector.limit.SelectorLimits;
|
|
||||||
import de.steamwar.bausystem.shared.Pair;
|
import de.steamwar.bausystem.shared.Pair;
|
||||||
import lombok.SneakyThrows;
|
import lombok.SneakyThrows;
|
||||||
import lombok.experimental.UtilityClass;
|
import lombok.experimental.UtilityClass;
|
||||||
@@ -41,9 +37,6 @@ import org.bukkit.Location;
|
|||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
@UtilityClass
|
@UtilityClass
|
||||||
public class WorldEditUtils {
|
public class WorldEditUtils {
|
||||||
|
|
||||||
@@ -84,40 +77,6 @@ public class WorldEditUtils {
|
|||||||
return WorldEdit.getInstance().getPatternFactory();
|
return WorldEdit.getInstance().getPatternFactory();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Pair<Class<? extends RegionSelector>, List<Location>> getVertices(Player player) {
|
|
||||||
RegionSelector regionSelector = WorldEdit.getInstance()
|
|
||||||
.getSessionManager()
|
|
||||||
.get(BukkitAdapter.adapt(player))
|
|
||||||
.getRegionSelector(BukkitAdapter.adapt(player.getWorld()));
|
|
||||||
return new Pair<>(regionSelector.getClass(), regionSelector.getVertices()
|
|
||||||
.stream()
|
|
||||||
.map(blockVector3 -> blockVector3 == null ? null : adapt(player.getWorld(), blockVector3))
|
|
||||||
.collect(Collectors.toList()));
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setVertices(Player player, Class<? extends RegionSelector> clazz, List<Location> vertices) {
|
|
||||||
LocalSession localSession = WorldEdit.getInstance()
|
|
||||||
.getSessionManager()
|
|
||||||
.get(BukkitAdapter.adapt(player));
|
|
||||||
|
|
||||||
Reflection.Constructor constructorInvoker = Reflection.getConstructor(clazz, com.sk89q.worldedit.world.World.class);
|
|
||||||
RegionSelector regionSelector = (RegionSelector) constructorInvoker.invoke(BukkitAdapter.adapt(player.getWorld()));
|
|
||||||
localSession.setRegionSelector(BukkitAdapter.adapt(player.getWorld()), regionSelector);
|
|
||||||
|
|
||||||
if (vertices.isEmpty()) return;
|
|
||||||
|
|
||||||
SelectorLimits selectorLimits = ActorSelectorLimits.forActor(BukkitAdapter.adapt(player));
|
|
||||||
for (int i = 0; i < vertices.size(); i++) {
|
|
||||||
Location location = vertices.get(i);
|
|
||||||
if (location == null) continue;
|
|
||||||
if (i == 0) {
|
|
||||||
regionSelector.selectPrimary(BukkitAdapter.adapt(location).toBlockPoint(), selectorLimits);
|
|
||||||
} else {
|
|
||||||
regionSelector.selectSecondary(BukkitAdapter.adapt(location).toBlockPoint(), selectorLimits);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public Pair<Location, Location> getSelection(Player player) {
|
public Pair<Location, Location> getSelection(Player player) {
|
||||||
RegionSelector regionSelector = WorldEdit.getInstance()
|
RegionSelector regionSelector = WorldEdit.getInstance()
|
||||||
.getSessionManager()
|
.getSessionManager()
|
||||||
|
|||||||
@@ -2,6 +2,8 @@ name: BauSystem
|
|||||||
authors: [ Lixfel, YoyoNow, Chaoscaot, Zeanon, D4rkr34lm ]
|
authors: [ Lixfel, YoyoNow, Chaoscaot, Zeanon, D4rkr34lm ]
|
||||||
version: "2.0"
|
version: "2.0"
|
||||||
depend: [ WorldEdit, SpigotCore ]
|
depend: [ WorldEdit, SpigotCore ]
|
||||||
|
softdepend:
|
||||||
|
- ViaVersion
|
||||||
load: POSTWORLD
|
load: POSTWORLD
|
||||||
main: de.steamwar.bausystem.BauSystem
|
main: de.steamwar.bausystem.BauSystem
|
||||||
api-version: "1.13"
|
api-version: "1.13"
|
||||||
|
|||||||
@@ -1,419 +0,0 @@
|
|||||||
# SteamWar.de - Script System
|
|
||||||
|
|
||||||
---
|
|
||||||
<!-- TOC -->
|
|
||||||
* [SteamWar.de - Script System](#steamwarde---script-system)
|
|
||||||
* [Einleitung](#einleitung)
|
|
||||||
* [Nutzung mit einer IDE](#nutzung-mit-einer-ide)
|
|
||||||
* [Basis-Apis](#basis-apis)
|
|
||||||
* [SteamWar.de-Api](#steamwarde-api)
|
|
||||||
* [player](#player)
|
|
||||||
* [random](#random)
|
|
||||||
* [region](#region)
|
|
||||||
* [tnt](#tnt)
|
|
||||||
* [trace](#trace)
|
|
||||||
* [server](#server)
|
|
||||||
* [tps](#tps)
|
|
||||||
* [storage](#storage)
|
|
||||||
* [inventory](#inventory)
|
|
||||||
* [SteamWar.de-Global-Api](#steamwarde-global-api)
|
|
||||||
* [Commands](#commands)
|
|
||||||
* [Hotkeys](#hotkeys)
|
|
||||||
* [Eventtypen](#eventtypen)
|
|
||||||
* [BlockEvent](#blockevent)
|
|
||||||
* [InteractEvent](#interactevent)
|
|
||||||
* [Position](#position)
|
|
||||||
* [Instabile APIs](#instabile-apis)
|
|
||||||
* [_worldedit](#worldedit)
|
|
||||||
* [Beispiele](#beispiele)
|
|
||||||
* [Hello, World!](#hello-world)
|
|
||||||
* [Code](#code)
|
|
||||||
* [Ausgabe](#ausgabe)
|
|
||||||
* [BauGUI on DoubleSwap](#baugui-on-doubleswap)
|
|
||||||
* [Code](#code-1)
|
|
||||||
* [SL Command](#sl-command)
|
|
||||||
* [Code](#code-2)
|
|
||||||
* [Paste Hotkey](#paste-hotkey)
|
|
||||||
* [Code](#code-3)
|
|
||||||
* [Inventory](#inventory-1)
|
|
||||||
* [Code](#code-4)
|
|
||||||
<!-- TOC -->
|
|
||||||
|
|
||||||
|
|
||||||
## Einleitung
|
|
||||||
Das Script System auf SteamWar.de basiert auf [Lua](https://www.lua.org/docs.html).
|
|
||||||
Der Code wird einfach in ein Minecraft Buch geschrieben und kann mit einem Links-Klick ausgeführt werden.
|
|
||||||
|
|
||||||
## Nutzung mit einer IDE
|
|
||||||
Im Repository liegen [Lua-Definitionen](sw.def.lua) für [Luanalysis](https://plugins.jetbrains.com/plugin/14698-luanalysis).
|
|
||||||
Diese können in der IDE genutzt werden, um die APIs zu nutzen.
|
|
||||||
|
|
||||||
Einfach die `sw.def.lua` in denselben Ordner wie das Script legen und die IDE sollte die APIs erkennen.
|
|
||||||
|
|
||||||
# Basis-Apis
|
|
||||||
Es werden folgende Standard-Apis zur Verfügung gestellt:
|
|
||||||
- [`math`](https://www.lua.org/manual/5.4/manual.html#6.7)
|
|
||||||
- [`string`](https://www.lua.org/manual/5.4/manual.html#6.4)
|
|
||||||
- [`table`](https://www.lua.org/manual/5.4/manual.html#6.6)
|
|
||||||
- [`bit32`](https://www.lua.org/manual/5.2/manual.html#6.7)
|
|
||||||
|
|
||||||
# SteamWar.de-Api
|
|
||||||
APIs, die mit einem `_` beginnen sind noch nicht stabil und können sich jederzeit ändern.
|
|
||||||
Sie sollten daher nicht verwendet werden, da sie sich noch in der Entwicklung befinden.
|
|
||||||
Diese können auch undokumentierte Funktionen enthalten, die nicht in der Dokumentation aufgeführt sind.
|
|
||||||
|
|
||||||
In den Scripten gibt es dazu noch folgende globale Variablen:
|
|
||||||
- [`player`](#player)
|
|
||||||
- [`random`](#random)
|
|
||||||
- [`region`](#region)
|
|
||||||
- [`server`](#server)
|
|
||||||
- [`storage`](#storage)
|
|
||||||
- [`inventory`](#inventory)
|
|
||||||
- `_worldedit`
|
|
||||||
|
|
||||||
Ohne eine Kategorie sind folgende Funktionen verfügbar, die nicht allgemein sind:
|
|
||||||
|
|
||||||
| Name | Signature | Beschreibung |
|
|
||||||
|-----------|-----------------------------------|-------------------------------------------------------------------------------------------------------------------|
|
|
||||||
| `print` | print(String...) | @see chat(String...) |
|
|
||||||
| `input` | input(String, Function\<String>) | Fragt den User nach einer Eingabe mit der Nachricht und called die zugehörige Funktion nach dieser |
|
|
||||||
| `delayed` | delayed(Number, Function\<Void>) | Wartet die angegebene Anzahl an Ticks und führt danach die zugehörige Funktion aus |
|
|
||||||
| `pos` | pos(Number, Number, Number) | Erstellt aus drei Zahlen eine Position-Table. Die Koordinaten sind unter den Namen `x`, `y` und `z` abgespeichert |
|
|
||||||
| `exec` | exec(String...) | Führt den angegebenen Befehl als Spieler aus |
|
|
||||||
| `length` | length(Any): Int | Gibt die Länge des Objekts zurück |
|
|
||||||
| `join` | length(String, String...): String | Füge die Texte mit den ersten Parameter zusammen |
|
|
||||||
|
|
||||||
### player
|
|
||||||
Das `player`-Modul stellt Funktionen zur Verfügung, die den Spieler betreffen.
|
|
||||||
Es gibt folgende Funktionen:
|
|
||||||
|
|
||||||
| Name | Signature | Beschreibung |
|
|
||||||
|------------------|--------------------------------|---------------------------------------------------------------------------------------------------------------------------|
|
|
||||||
| `name` | name(): String | Gibt den `displayName` des Spielers zurück |
|
|
||||||
| `chat` | chat(String...) | Sendet den Text in den Chat des Spielers |
|
|
||||||
| `actionbar` | actionbar(String...) | Sendet den Text in die ActionBar des Spielers |
|
|
||||||
| `x` | x(Number), x(): Number | Setzt oder gibt die X-Koordinate des Spielers |
|
|
||||||
| `y` | y(Number), y(): Number | Setzt oder gibt die Y-Koordinate des Spielers |
|
|
||||||
| `z` | z(Number), z(): Number | Setzt oder gibt die Z-Koordinate des Spielers |
|
|
||||||
| `yaw` | yaw(Number), yaw(): Number | Setzt oder gibt die Gierung des Spielers |
|
|
||||||
| `pitch` | pitch(Number), pitch(): Number | Setzt oder gibt die Steigung des Spielers |
|
|
||||||
| `sneaking` | sneaking(): Boolean | Wahr, wenn der Spieler am Sneaken ist |
|
|
||||||
| `sprinting` | sprinting(): Boolean | Wahr, wenn der Spieler am Sprinten ist |
|
|
||||||
| `slot` | slot(Number), slot(): Number | Setzt oder gibt den Slot des gehaltenden Items des Spielers [(Wiki)](https://minecraft.fandom.com/wiki/Slot#Java_Edition) |
|
|
||||||
| `item` | item(): String | Gibt den Itemtyp der Main-Hand zurück |
|
|
||||||
| `offHandItem` | offHandItem(): String | Gibt den Itemtyp der Off-Hand zurück |
|
|
||||||
| `closeInventory` | closeInventory() | Schließe das aktuell geöffnete Inventar des Spielers |
|
|
||||||
|
|
||||||
### random
|
|
||||||
Das `random`-Modul stellt Funktionen zur Verfügung, die Zufallszahlen betreffen.
|
|
||||||
Es gibt folgende Funktionen:
|
|
||||||
|
|
||||||
| Name | Signature | Beschreibung |
|
|
||||||
|------------|------------------------------------|-------------------------------------------------------------------------------|
|
|
||||||
| nextInt | nextInt(): Int | Gibt eine Zufallszahl zurück zwischen Integer.MIN_VALUE und Integer.MAX_VALUE |
|
|
||||||
| -"- | nextInt(Int): Int | Gibt eine Zufallszahl zurück zischen 0 und dem Argument |
|
|
||||||
| -"- | nextInt(Int, Int): Int | Gibt eine Zufallszahl zurück zwischen dem ersten und zweiten Argument |
|
|
||||||
| nextDouble | nextDouble(): Double | Gibt eine Zufallszahl zurück zwischen 0 und 1 |
|
|
||||||
| -"- | nextDouble(Double): Double | Gibt eine Zufallszahl zurück zwischen 0 und dem Argument |
|
|
||||||
| -"- | nextDouble(Double, Double): Double | Gibt eine Zufallszahl zurück zwischen ersten und zweiten Argument |
|
|
||||||
| nextBool | nextBool(): Boolean | Gibt true oder false zurück |
|
|
||||||
|
|
||||||
### region
|
|
||||||
Das `region`-Modul stellt Funktion zur Verfügung, die die Region des Spielers betreffen.
|
|
||||||
Es gibt folgende Funktionen:
|
|
||||||
|
|
||||||
| Name | Signature | Beschreibung |
|
|
||||||
|-----------|---------------------|------------------------------------------------------------------------------------------------------------|
|
|
||||||
| `name` | name(): String | Gibt den Regionsnamen |
|
|
||||||
| `type` | type(): String | Gibt den Regionstyp |
|
|
||||||
| `fire` | fire(): Boolean | Gibt den Fire-Modus der Region zurück |
|
|
||||||
| `freeze` | freeze(): Boolean | Gibt den Freeze-Modus der Region zurück |
|
|
||||||
| `protect` | protect(): Boolean | Gibt den Protect-Modus der Region zurück |
|
|
||||||
| `loader` | loader(): String | Gibt den Status des Loaders des Spielers zurück, die Werte sind: `OFF`, `SETUP`, `RUNNING`, `PAUSE`, `END` |
|
|
||||||
| `get` | get(String): Region | Gibt die Region mit dem Namen zurück. Die Region ist gleich aufgebaut wie das Regions-Modul |
|
|
||||||
| `list` | list(): Region[] | Gibt alle Region zurück. Die Region ist gleich aufgebaut wie das Regions-Modul |
|
|
||||||
|
|
||||||
Es gibt folgende weitere Module:
|
|
||||||
|
|
||||||
| Name | Beschreibung |
|
|
||||||
|---------|-----------------|
|
|
||||||
| `tnt` | [tnt](#tnt) |
|
|
||||||
| `trace` | [trace](#trace) |
|
|
||||||
|
|
||||||
#### tnt
|
|
||||||
Das `tnt`-Modul stellt Funktionen zur Verfügung, die den TNT-Modus in der Region des Spielers betreffen.
|
|
||||||
Es gibt folgende Funktionen:
|
|
||||||
|
|
||||||
| Name | Signature | Beschreibung |
|
|
||||||
|-------------|----------------------|-------------------------------------------------------------------------------------|
|
|
||||||
| `mode` | mode(): String | Gibt den Aktuellen TNT-Modus zurück, die werte sind: `ALLOW`, `DENY` oder `ONLY_TB` |
|
|
||||||
| `enabled` | enabled(): Boolean | Gibt zurück, ob der TNT-Modus in der Region des Spielers aktiviert ist oder nicht |
|
|
||||||
| `onlyTb` | onlyTb(): Boolean | Gibt zurück, ob der TNT-Modus auf Only-Tb ist |
|
|
||||||
| `onlyBuild` | onlyBuild(): Boolean | Gibt zurück, ob der TNT-Modus auf Only-Build ist |
|
|
||||||
|
|
||||||
|
|
||||||
#### trace
|
|
||||||
Das `trace`-Modul stellt Funktionen zur Verfügung, die den Status des Tracers der Region betreffen.
|
|
||||||
Es gibt folgende Funktionen:
|
|
||||||
|
|
||||||
| Name | Signature | Beschreibung |
|
|
||||||
|----------|-------------------|--------------------------------------------------------------------------------|
|
|
||||||
| `active` | active(): Boolean | Gibt zurück, ob der Tracer in der Region des Spielers aktiviert ist oder nicht |
|
|
||||||
| `auto` | auto(): Boolean | Gibt zurück, ob der Tracer in der Region ein Auto-Tracer ist |
|
|
||||||
| `status` | status(): String | Gibt den Status des Tracers zurück |
|
|
||||||
| `time` | time(): String | Gibt die Zeit des Tracers zurück |
|
|
||||||
|
|
||||||
## server
|
|
||||||
Das `server`-Modul stellt Funktionen zur Verfügung, die den Server betreffen.
|
|
||||||
Es gibt folgende Funktionen:
|
|
||||||
|
|
||||||
| Name | Signature | Beschreibung |
|
|
||||||
|--------------|-------------------------|---------------------------------------------------------------------|
|
|
||||||
| `time` | time(): String | Gibt die aktuelle Zeit im Format `HH:mm:ss` zurück |
|
|
||||||
| `ticks` | ticks(): Number | Gibt die Ticks seit start des Serverstarts zurück |
|
|
||||||
| `getBlockAt` | getBlockAt(Pos): String | Gibt das Material an der Position zurück |
|
|
||||||
| `setBlockAt` | setBlockAt(Pos, String) | Setzt das Material an der angegebenen Stelle (z.B. Stein = `STONE`) |
|
|
||||||
|
|
||||||
Es gibt folgende weitere Module:
|
|
||||||
|
|
||||||
| Name | Beschreibung |
|
|
||||||
|-------|--------------|
|
|
||||||
| `tps` | [tps](#tps) |
|
|
||||||
|
|
||||||
#### tps
|
|
||||||
Das `tps`-Modul stellt Funktionen zur Verfügung, die die TPS des Servers betreffen.
|
|
||||||
Es gibt folgende Funktionen:
|
|
||||||
|
|
||||||
| Name | Signature | Beschreibung |
|
|
||||||
|--------------|----------------------|-------------------------------------------------------------------|
|
|
||||||
| `current` | current(): Number | Gibt die aktuelle TPS zurück (Das selbe wie `oneSecound()`) |
|
|
||||||
| `oneSecond` | oneSecond(): Number | Gibt die durchschnittliche TPS über die letzte Sekunde zurück |
|
|
||||||
| `tenSecond` | tenSecond(): Number | Gibt die durchschnittliche TPS über die letzte 10 Sekunden zurück |
|
|
||||||
| `oneMinute` | oneMinute(): Number | Gibt die durchschnittliche TPS über die letzte Minute zurück |
|
|
||||||
| `fiveMinute` | fiveMinute(): Number | Gibt die durchschnittliche TPS über die letzte 5 Minuten zurück |
|
|
||||||
| `tenMinute` | tenMinute(): Number | Gibt die durchschnittliche TPS über die letzte 10 Minuten zurück |
|
|
||||||
| `limit` | limit(): Number | Gibt das TPS-Limit zurück |
|
|
||||||
|
|
||||||
## storage
|
|
||||||
Das `storage`-Modul stellt Funktionen zur Verfügung, mit welchen man Werte speichern kann.
|
|
||||||
|
|
||||||
Es gibt folgende Module:
|
|
||||||
|
|
||||||
| Name | Beschreibung |
|
|
||||||
|----------|---------------------|
|
|
||||||
| `player` | Spieler abhängig |
|
|
||||||
| `region` | Region des Spielers |
|
|
||||||
| `global` | Alle Skripte |
|
|
||||||
|
|
||||||
Alle Module haben folgende Funktionen:
|
|
||||||
|
|
||||||
| Name | Signature | Beschreibung |
|
|
||||||
|------------|----------------------------|--------------------------------------------------------|
|
|
||||||
| `get` | get(String): Any | Gibt den Wert des Schlüssels zurück |
|
|
||||||
| `set` | set(String, Any) | Setzt den Wert des Schlüssels auf den angegebenen Wert |
|
|
||||||
| `has` | has(String): Boolean | Prüft ob ein Wert vorhanden ist |
|
|
||||||
| `remove` | remove(String) | Löscht den Schlüssel |
|
|
||||||
| `accessor` | accessor(String): Accessor | Gibt einen Accessor zurück |
|
|
||||||
|
|
||||||
Ein Accessor ist ein Objekt, womit du direkt auf einen Wert zugreifen kannst und es ändern kannst.
|
|
||||||
Es geht wie folgt:
|
|
||||||
```lua
|
|
||||||
keyAccessor = storage.player.accessor("key")
|
|
||||||
|
|
||||||
keyAccessor("Hello World") -- Setzt den Wert auf "Hello World"
|
|
||||||
print(keyAccessor()) -- Gibt den Wert zurück
|
|
||||||
```
|
|
||||||
|
|
||||||
## inventory
|
|
||||||
Das `inventory`-Modul stellt Funktionen zur Verfügung, um ein Inventar zu öffnen.
|
|
||||||
Es gibt folgende Funktionen:
|
|
||||||
|
|
||||||
| Name | Signature | Beschreibung |
|
|
||||||
|----------|-----------------------------------|-------------------------------------------------------------------|
|
|
||||||
| `create` | create(String, Number): Inventory | Erstellt ein Inventar mit dem Title und der Anzahl an Zeilen |
|
|
||||||
|
|
||||||
Das `Inventory`-Objekt hat folgende Funktionen:
|
|
||||||
|
|
||||||
| Name | Signature | Beschreibung |
|
|
||||||
|-------------------|--------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
|
||||||
| `item` | item(Number, String, String, Function\<String>) | Setze ein Item mit dem Typen des ersten Strings an den Slot (Startet bei 0) mit dem Namen des zweiten Strings mit einem Klick-Handler der den Klick-Typen rein gibt (z.B. `LEFT`, `SHIFT_LEFT`, `RIGHT`, `SHIFT_RIGHT`) |
|
|
||||||
| -"- | item(Number, String, String, Function\<String>, List<String>) | Füge eine Lore an das Item hinzu |
|
|
||||||
| -"- | item(Number, String, String, Function\<String>, List<String>, Boolean) | Gebe an, ob das Item enchanted sein soll |
|
|
||||||
| -"- | item(Number, String, String, Function\<String>, List<String>, Boolean, Number) | Gebe die Anzahl der Items an |
|
|
||||||
| `setCloseHandler` | setCloseHandler(Function\<Void>) | Gebe einen Handler an, der beim schließen des Inventares ausgeführt wird |
|
|
||||||
| `open` | open() | Öffne das Inventar |
|
|
||||||
|
|
||||||
Siehe auch: [Inventory Beispiel](#inventory-1)
|
|
||||||
|
|
||||||
Siehe auch: [Liste an Materials](https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Material.html)
|
|
||||||
|
|
||||||
```
|
|
||||||
⚠️⚠️⚠️
|
|
||||||
|
|
||||||
Wenn eine Barrier statt des richtigen Items angezeigt wird, dann ist das angegebene Material nicht gültig.
|
|
||||||
|
|
||||||
⚠️⚠️⚠️
|
|
||||||
```
|
|
||||||
|
|
||||||
# SteamWar.de-Global-Api
|
|
||||||
Mit `/script` kann man Script-Bücher global abspeichern. Diese haben dann zugrif auf die `global`-Api.
|
|
||||||
Die `global`-Api stellt Funktionen zur Verfügung um auf Events, Commands und Hotkeys mit einem Script zu reagieren.
|
|
||||||
|
|
||||||
Es gibt folgende Funktionen:
|
|
||||||
|
|
||||||
| Name | Signature | Beschreibung |
|
|
||||||
|-----------|-----------------------------------|-----------------------------------------------------------------------------|
|
|
||||||
| `event` | event(EventType, Function(Any)) | Registriere einen Event Listener |
|
|
||||||
| `command` | command(String, Function(Args)) | Registriere einen Befehl |
|
|
||||||
| `hotkey` | hotkey(String, Function(Boolean)) | Registriere einen Hotkey, the function gets a boolean if the key is pressed |
|
|
||||||
|
|
||||||
Es gibt folgende Variablen:
|
|
||||||
|
|
||||||
| Name | Beschreibung |
|
|
||||||
|----------|----------------------------------|
|
|
||||||
| `events` | Siehe: [Event Type](#eventtypen) |
|
|
||||||
|
|
||||||
## Commands
|
|
||||||
Der Command Handler kriegt eine Liste aller angegeben argumenten. Die Argumente sind vom Typ `String`. Mit dem Wert gespeichert unter `args.alias` oder `args["alias"]` erhältst du, welcher command eingegeben wurde. Wenn ein handler für mehrere Befehle registriert wurde kannst du es hiermit erkennen.
|
|
||||||
Du kannst `args.hasShortFlag(String)` um herauszufinden ob eine Flag angegeben wurde wie zum Beispiel `-f`. Mit `args.removeShortFlag(String)` kannst du die Flag entfernen und erhältst ob sie angegeben wurde.
|
|
||||||
|
|
||||||
## Hotkeys
|
|
||||||
|
|
||||||
Hotkeys werden im folgenden Format angegeben: `MODIFIER+KEY`. Bei den Hotkey erstellung ist die Großschreibung egal. Es gibt folgende Modifier:
|
|
||||||
- `ctrl`
|
|
||||||
- `shift`
|
|
||||||
- `alt`
|
|
||||||
- `meta`
|
|
||||||
|
|
||||||
Es können auch mehrere Modifier angegeben werden, z.B. `ctrl+shift+alt+c`. Die Reihenfolge der Modifier und des Keys ist egal.
|
|
||||||
|
|
||||||
## Eventtypen
|
|
||||||
Einige Events sind auch abbrechbar, dazu muss die Funktion `setCancelled()` aufgerufen werden.
|
|
||||||
|
|
||||||
| Name | Wenn | Parameter | Abbrechbar |
|
|
||||||
|---------------------|-----------------------------------------------------|---------------------------------|------------|
|
|
||||||
| `DoubleSwap` | Beim Doppelten Drücken der Swap-Hands taste | NIL | false |
|
|
||||||
| `PlaceBlock` | Beim Platzieren von Blöcken | [BlockEvent](#blockevent) | true |
|
|
||||||
| `BreakBlock` | Beim Zerstören von Blöcken | [BlockEvent](#blockevent) | true |
|
|
||||||
| `RightClick` | Beim Rechtsklick | [InteractEvent](#interactevent) | true |
|
|
||||||
| `LeftClick` | Beim Linksklick | [InteractEvent](#interactevent) | true |
|
|
||||||
| `TNTSpawn` | Wenn ein TNT in der aktuellen Region spawnt | NIL | false |
|
|
||||||
| `TNTExplode` | Wenn ein TNT in der aktuellen Region explodiert | [Position](#position) | true |
|
|
||||||
| `TNTExplodeInBuild` | Wenn ein TNT in der aktuellen Bau Region explodiert | [Position](#position) | true |
|
|
||||||
| `SelfJoin` | Wenn man selbst den Server betritt | NIL | false |
|
|
||||||
| `SelfLeave` | Wenn man den Server verlässt | NIL | false |
|
|
||||||
| `DropItem` | Wenn man ein Item droppt | (type: Material) | true |
|
|
||||||
| `EntityDeath` | Wenn ein Entity stirbt | (type: Entity Type) | false |
|
|
||||||
|
|
||||||
### BlockEvent
|
|
||||||
Das übergebene Objekt an den Handler hat folgende Variablen:
|
|
||||||
|
|
||||||
| Name | Beschreibung |
|
|
||||||
|--------|-----------------------------|
|
|
||||||
| `x` | Die X-Koordinate des Blocks |
|
|
||||||
| `y` | Die Y-Koordinate des Blocks |
|
|
||||||
| `z` | Die Z-Koordinate des Blocks |
|
|
||||||
| `type` | Das Material des Blocks |
|
|
||||||
|
|
||||||
### InteractEvent
|
|
||||||
Das übergebene Objekt an den Handler hat folgende Variablen:
|
|
||||||
|
|
||||||
| Name | Beschreibung |
|
|
||||||
|------------|-------------------------------------------------------------------------------------------------------------------------------|
|
|
||||||
| `action` | Die Action die ausgeführt wurde, Mögliche Werte: `RIGHT_CLICK_BLOCK`, `RIGHT_CLICK_AIR`, `LEFT_CLICK_BLOCK`, `LEFT_CLICK_AIR` |
|
|
||||||
| `hand` | Die Hand die zum ausführen genutzt wird, Mögliche Werte: `HAND`, `OFF_HAND`, `null` |
|
|
||||||
| `block` | Der Typ des Items mit dem geklickt wurde |
|
|
||||||
| `hasBlock` | Wahr, wenn auf einen Block geklickt wurde |
|
|
||||||
|
|
||||||
Wenn `hasBlock` wahr ist, gibt es folgende Variablen:
|
|
||||||
|
|
||||||
| Name | Beschreibung |
|
|
||||||
|-------------|-----------------------------------------|
|
|
||||||
| `blockX` | Die X-Koordinate des Blocks |
|
|
||||||
| `blockY` | Die Y-Koordinate des Blocks |
|
|
||||||
| `blockZ` | Die Z-Koordinate des Blocks |
|
|
||||||
| `blockFace` | Die Seite des Blocks die geklickt wurde |
|
|
||||||
|
|
||||||
|
|
||||||
### Position
|
|
||||||
Die Position ist ein Objekt mit folgenden Variablen:
|
|
||||||
|
|
||||||
| Name | Beschreibung |
|
|
||||||
|------|------------------|
|
|
||||||
| `x` | Die X-Koordinate |
|
|
||||||
| `y` | Die Y-Koordinate |
|
|
||||||
| `z` | Die Z-Koordinate |
|
|
||||||
|
|
||||||
# Instabile APIs
|
|
||||||
Hier sind einige APIs aufgelistet, die nicht stabil sind und sich jederzeit ändern können.
|
|
||||||
|
|
||||||
## _worldedit
|
|
||||||
|
|
||||||
| Name | Signatur | Beschreibung |
|
|
||||||
|-------------|-----------------------------------------------------------|-----------------------------------|
|
|
||||||
| `selection` | selection(Liste\<Pos>), selection(): {min: Pos, max: Pos} | Die aktuelle auswahl des Spielers |
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Beispiele
|
|
||||||
|
|
||||||
## Hello, World!
|
|
||||||
Ein einfaches Hello, World!-Script.
|
|
||||||
|
|
||||||
#### Code
|
|
||||||
```lua
|
|
||||||
print("Hello, World!")
|
|
||||||
```
|
|
||||||
|
|
||||||
#### Ausgabe
|
|
||||||
```
|
|
||||||
Hello, World!
|
|
||||||
```
|
|
||||||
|
|
||||||
## BauGUI on DoubleSwap
|
|
||||||
Das Standardskript für das Öffnen des BauGUIs
|
|
||||||
|
|
||||||
#### Code
|
|
||||||
```lua
|
|
||||||
function handler(event)
|
|
||||||
exec("gui")
|
|
||||||
end
|
|
||||||
|
|
||||||
event(events.DoubleSwap, handler)
|
|
||||||
```
|
|
||||||
|
|
||||||
## SL Command
|
|
||||||
Ein einfacher Command Redefiner.
|
|
||||||
|
|
||||||
#### Code
|
|
||||||
```lua
|
|
||||||
function handler(args)
|
|
||||||
exec("stoplag")
|
|
||||||
end
|
|
||||||
|
|
||||||
command("sl", handler)
|
|
||||||
```
|
|
||||||
|
|
||||||
## Paste Hotkey
|
|
||||||
Ein Hotkey zum Pasten des Clipboard-Inhalts.
|
|
||||||
|
|
||||||
#### Code
|
|
||||||
```lua
|
|
||||||
function handler(pressed)
|
|
||||||
if pressed then
|
|
||||||
exec("/paste -o")
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
hotkey("ctrl+v", handler)
|
|
||||||
```
|
|
||||||
|
|
||||||
## Inventory
|
|
||||||
Ein Beispiel für ein Inventar.
|
|
||||||
|
|
||||||
#### Code
|
|
||||||
```lua
|
|
||||||
inv = inventory.create("Test Inv", 3)
|
|
||||||
inv.item(13, "STONE", "Ich bin ein Stein", function(e) player.chat(e) end, {"Die Lore", "Die Zweite Zeile"}, true)
|
|
||||||
inv.open()
|
|
||||||
```
|
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* This file is a part of the SteamWar software.
|
* This file is a part of the SteamWar software.
|
||||||
*
|
*
|
||||||
* Copyright (C) 2024 SteamWar.de-Serverteam
|
* Copyright (C) 2024 SteamWar.de-Serverteam
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU Affero General Public License as published by
|
||||||
@@ -32,5 +32,4 @@ 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"))
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,87 +0,0 @@
|
|||||||
-- This file is a part of the SteamWar software.
|
|
||||||
--
|
|
||||||
-- Copyright (C) 2025 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/>.
|
|
||||||
|
|
||||||
---
|
|
||||||
--- This serves both as an example and a quick start to the Stewamwar Script Api
|
|
||||||
---
|
|
||||||
|
|
||||||
function hotkeys_freeze(pressed)
|
|
||||||
if pressed then
|
|
||||||
exec("/freeze")
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function hotkeys_rgc(pressed)
|
|
||||||
if pressed then
|
|
||||||
exec("/rgc")
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function hotkeys_rgp(pressed)
|
|
||||||
if pressed then
|
|
||||||
exec("/rgp")
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
trace_cycle_counter = 0;
|
|
||||||
function hotkeys_cycle_trace_view(pressed)
|
|
||||||
if not pressed then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
trace_cycle = (trace_cycle + 1) % 3
|
|
||||||
trace_commands = {"trace hide", "trace show", "trace show -e -c"}
|
|
||||||
exec(trace_commands[trace_cycle + 1])
|
|
||||||
end
|
|
||||||
|
|
||||||
function hotkeys_tick_step(pressed)
|
|
||||||
if pressed then
|
|
||||||
exec("tick step")
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function hotkeys_tpslimit(pressed)
|
|
||||||
if not pressed then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
if tps.limit() == 20 then
|
|
||||||
exec("tpslimit 200")
|
|
||||||
else
|
|
||||||
exec("tpslimit 20")
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function hotkeys_tb(pressed)
|
|
||||||
if pressed then
|
|
||||||
exec("tb -e")
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function hotkeys_trace_delete(pressed)
|
|
||||||
if pressed then
|
|
||||||
exec("trace delete")
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
hotkey("ctrl+g", hotkeys_freeze)
|
|
||||||
hotkey("ctrl+c", hotkeys_rgc)
|
|
||||||
hotkey("ctrl+v", hotkeys_rgp)
|
|
||||||
hotkey("ctrl+x", hotkeys_tick_step)
|
|
||||||
hotkey("shift+x", hotkeys_cycle_trace_view)
|
|
||||||
hotkey("ctrl+y", hotkeys_tb)
|
|
||||||
hotkey("ctrl+alt", hotkeys_trace_delete)
|
|
||||||
hotkey("ctrl+h", hotkeys_trace_delete)
|
|
||||||
|
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* This file is a part of the SteamWar software.
|
* This file is a part of the SteamWar software.
|
||||||
*
|
*
|
||||||
* Copyright (C) 2024 SteamWar.de-Serverteam
|
* Copyright (C) 2024 SteamWar.de-Serverteam
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU Affero General Public License as published by
|
||||||
|
|||||||
@@ -21,7 +21,6 @@ package de.steamwar.sql;
|
|||||||
|
|
||||||
import de.steamwar.sql.internal.Field;
|
import de.steamwar.sql.internal.Field;
|
||||||
import de.steamwar.sql.internal.SelectStatement;
|
import de.steamwar.sql.internal.SelectStatement;
|
||||||
import de.steamwar.sql.internal.Statement;
|
|
||||||
import de.steamwar.sql.internal.Table;
|
import de.steamwar.sql.internal.Table;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
@@ -43,11 +42,6 @@ public class Event {
|
|||||||
private static final SelectStatement<Event> byId = table.select(Table.PRIMARY);
|
private static final SelectStatement<Event> byId = table.select(Table.PRIMARY);
|
||||||
private static final SelectStatement<Event> byName = table.select("eventName");
|
private static final SelectStatement<Event> byName = table.select("eventName");
|
||||||
private static final SelectStatement<Event> byComing = new SelectStatement<>(table, "SELECT * FROM Event WHERE Start > now()");
|
private static final SelectStatement<Event> byComing = new SelectStatement<>(table, "SELECT * FROM Event WHERE Start > now()");
|
||||||
private static final SelectStatement<Event> all = new SelectStatement<>(table, "SELECT * FROM Event");
|
|
||||||
|
|
||||||
private static final Statement create = table.insertFields(true, "eventName", "deadline", "start", "end", "maximumTeamMembers", "publicSchemsOnly");
|
|
||||||
private static final Statement update = table.update(Table.PRIMARY, "eventName", "deadline", "start", "end", "schemType", "maximumTeamMembers", "publicSchemsOnly");
|
|
||||||
private static final Statement delete = table.delete(Table.PRIMARY);
|
|
||||||
|
|
||||||
private static Event current = null;
|
private static Event current = null;
|
||||||
|
|
||||||
@@ -59,14 +53,6 @@ public class Event {
|
|||||||
return current;
|
return current;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<Event> getAll(){
|
|
||||||
return all.listSelect();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Event create(String eventName, Timestamp start, Timestamp end){
|
|
||||||
return get(create.insertGetKey(eventName, start, start, end, 5, false));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Event get(int eventID){
|
public static Event get(int eventID){
|
||||||
return byId.select(eventID);
|
return byId.select(eventID);
|
||||||
}
|
}
|
||||||
@@ -101,10 +87,16 @@ public class Event {
|
|||||||
private final SchematicType schemType;
|
private final SchematicType schemType;
|
||||||
@Field
|
@Field
|
||||||
private final boolean publicSchemsOnly;
|
private final boolean publicSchemsOnly;
|
||||||
|
@Deprecated
|
||||||
|
@Field
|
||||||
|
private final boolean spectateSystem;
|
||||||
|
|
||||||
public boolean publicSchemsOnly() {
|
public boolean publicSchemsOnly() {
|
||||||
return publicSchemsOnly;
|
return publicSchemsOnly;
|
||||||
}
|
}
|
||||||
|
public boolean spectateSystem(){
|
||||||
|
return spectateSystem;
|
||||||
|
}
|
||||||
|
|
||||||
public SchematicType getSchematicType() {
|
public SchematicType getSchematicType() {
|
||||||
return schemType;
|
return schemType;
|
||||||
@@ -114,12 +106,4 @@ public class Event {
|
|||||||
Instant now = Instant.now();
|
Instant now = Instant.now();
|
||||||
return now.isAfter(start.toInstant()) && now.isBefore(end.toInstant());
|
return now.isAfter(start.toInstant()) && now.isBefore(end.toInstant());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void update(String eventName, Timestamp deadline, Timestamp start, Timestamp end, SchematicType schemType, int maximumTeamMembers, boolean publicSchemsOnly) {
|
|
||||||
update.update(eventName, deadline, start, end, schemType, maximumTeamMembers, publicSchemsOnly, eventID);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void delete() {
|
|
||||||
delete.update(eventID);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,7 +25,6 @@ import de.steamwar.sql.internal.Statement;
|
|||||||
import de.steamwar.sql.internal.Table;
|
import de.steamwar.sql.internal.Table;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
|
||||||
|
|
||||||
import java.sql.Timestamp;
|
import java.sql.Timestamp;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
@@ -43,11 +42,6 @@ public class EventFight implements Comparable<EventFight> {
|
|||||||
private static final Statement setResult = table.update(Table.PRIMARY, "Ergebnis");
|
private static final Statement setResult = table.update(Table.PRIMARY, "Ergebnis");
|
||||||
private static final Statement setFight = table.update(Table.PRIMARY, "Fight");
|
private static final Statement setFight = table.update(Table.PRIMARY, "Fight");
|
||||||
|
|
||||||
private static final Statement create = table.insertFields(true, "eventID", "startTime", "spielmodus", "map", "teamBlue", "teamRed", "spectatePort");
|
|
||||||
private static final Statement update = table.update(Table.PRIMARY, "startTime", "spielModus", "map", "teamBlue", "teamRed", "spectatePort");
|
|
||||||
private static final Statement delete = table.delete(Table.PRIMARY);
|
|
||||||
|
|
||||||
@Getter
|
|
||||||
private static final Queue<EventFight> fights = new PriorityQueue<>();
|
private static final Queue<EventFight> fights = new PriorityQueue<>();
|
||||||
|
|
||||||
public static EventFight get(int fightID) {
|
public static EventFight get(int fightID) {
|
||||||
@@ -63,8 +57,8 @@ public class EventFight implements Comparable<EventFight> {
|
|||||||
return event.listSelect(eventID);
|
return event.listSelect(eventID);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static EventFight create(int event, Timestamp from, String spielmodus, String map, int blueTeam, int redTeam, Integer spectatePort) {
|
public static Queue<EventFight> getFights() {
|
||||||
return get(create.insertGetKey(event, from, spielmodus, map, blueTeam, redTeam, spectatePort));
|
return fights;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
@@ -74,29 +68,27 @@ public class EventFight implements Comparable<EventFight> {
|
|||||||
@Field(keys = {Table.PRIMARY}, autoincrement = true)
|
@Field(keys = {Table.PRIMARY}, autoincrement = true)
|
||||||
private final int fightID;
|
private final int fightID;
|
||||||
@Getter
|
@Getter
|
||||||
@Setter
|
|
||||||
@Field
|
@Field
|
||||||
private Timestamp startTime;
|
private Timestamp startTime;
|
||||||
@Getter
|
@Getter
|
||||||
@Setter
|
|
||||||
@Field
|
@Field
|
||||||
private String spielmodus;
|
private final String spielmodus;
|
||||||
@Getter
|
@Getter
|
||||||
@Setter
|
|
||||||
@Field
|
@Field
|
||||||
private String map;
|
private final String map;
|
||||||
@Getter
|
@Getter
|
||||||
@Setter
|
|
||||||
@Field
|
@Field
|
||||||
private int teamBlue;
|
private final int teamBlue;
|
||||||
@Getter
|
@Getter
|
||||||
@Setter
|
|
||||||
@Field
|
@Field
|
||||||
private int teamRed;
|
private final int teamRed;
|
||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Field
|
||||||
@Field(nullable = true)
|
@Deprecated
|
||||||
private Integer spectatePort;
|
private final int kampfleiter;
|
||||||
|
@Getter
|
||||||
|
@Field
|
||||||
|
private final int spectatePort;
|
||||||
@Getter
|
@Getter
|
||||||
@Field(def = "0")
|
@Field(def = "0")
|
||||||
private int ergebnis;
|
private int ergebnis;
|
||||||
@@ -141,18 +133,4 @@ public class EventFight implements Comparable<EventFight> {
|
|||||||
public int compareTo(EventFight o) {
|
public int compareTo(EventFight o) {
|
||||||
return startTime.compareTo(o.startTime);
|
return startTime.compareTo(o.startTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void update(Timestamp startTime, String spielmodus, String map, int teamBlue, int teamRed, Integer spectatePort) {
|
|
||||||
update.update(startTime, spielmodus, map, teamBlue, teamRed, spectatePort, fightID);
|
|
||||||
this.startTime = startTime;
|
|
||||||
this.spielmodus = spielmodus;
|
|
||||||
this.map = map;
|
|
||||||
this.teamBlue = teamBlue;
|
|
||||||
this.teamRed = teamRed;
|
|
||||||
this.spectatePort = spectatePort;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void delete() {
|
|
||||||
delete.update(fightID);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,9 +35,8 @@ import java.util.stream.Collectors;
|
|||||||
public class Fight {
|
public class Fight {
|
||||||
|
|
||||||
private static final Table<Fight> table = new Table<>(Fight.class);
|
private static final Table<Fight> table = new Table<>(Fight.class);
|
||||||
private static final SelectStatement<Fight> getPage = new SelectStatement<>(table, "SELECT f.*, (b.NodeId IS NULL OR b.AllowReplay) AND (r.NodeId IS NULL OR r.AllowReplay) AS ReplayAllowed FROM Fight f LEFT OUTER JOIN SchematicNode b ON f.BlueSchem = b.NodeId LEFT OUTER JOIN SchematicNode r ON f.RedSchem = r.NodeId ORDER BY FightID DESC LIMIT ?, ?");
|
private static final SelectStatement<Fight> getPage = new SelectStatement<>(table, "SELECT f.*, (b.NodeId IS NULL OR b.AllowReplay) AND (r.NodeId IS NULL OR r.AllowReplay) AS ReplayAllowed, (SELECT COUNT(1) FROM Replay WHERE Replay.FightID = f.FightID) as ReplayAvailable FROM Fight f LEFT OUTER JOIN SchematicNode b ON f.BlueSchem = b.NodeId LEFT OUTER JOIN SchematicNode r ON f.RedSchem = r.NodeId ORDER BY FightID DESC LIMIT ?, ?");
|
||||||
private static final Statement insert = table.insertFields(true, "GameMode", "Server", "StartTime", "Duration", "BlueLeader", "RedLeader", "BlueSchem", "RedSchem", "Win", "WinCondition");
|
private static final Statement insert = table.insertFields(true, "GameMode", "Server", "StartTime", "Duration", "BlueLeader", "RedLeader", "BlueSchem", "RedSchem", "Win", "WinCondition");
|
||||||
private static final Statement updateReplayAvailable = table.update(Table.PRIMARY, "ReplayAvailable");
|
|
||||||
|
|
||||||
public static List<Fight> getPage(int page, int elementsPerPage) {
|
public static List<Fight> getPage(int page, int elementsPerPage) {
|
||||||
List<Fight> fights = getPage.listSelect(page * elementsPerPage, elementsPerPage);
|
List<Fight> fights = getPage.listSelect(page * elementsPerPage, elementsPerPage);
|
||||||
@@ -55,10 +54,6 @@ public class Fight {
|
|||||||
return insert.insertGetKey(gamemode, server, starttime, duration, blueleader, redleader, blueschem, redschem, win, wincondition);
|
return insert.insertGetKey(gamemode, server, starttime, duration, blueleader, redleader, blueschem, redschem, win, wincondition);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void markReplayAvailable(int fightID) {
|
|
||||||
updateReplayAvailable.update(true, fightID);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
@Field(keys = {Table.PRIMARY}, autoincrement = true)
|
@Field(keys = {Table.PRIMARY}, autoincrement = true)
|
||||||
private final int fightID;
|
private final int fightID;
|
||||||
@@ -85,10 +80,10 @@ public class Fight {
|
|||||||
private final int win;
|
private final int win;
|
||||||
@Field
|
@Field
|
||||||
private final String wincondition;
|
private final String wincondition;
|
||||||
@Field
|
|
||||||
private final boolean replayAvailable;
|
|
||||||
@Field // Virtual field for easy select
|
@Field // Virtual field for easy select
|
||||||
private final boolean replayAllowed;
|
private final boolean replayAllowed;
|
||||||
|
@Field // Virtual field for easy select
|
||||||
|
private final boolean replayAvailable;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
private final List<FightPlayer> bluePlayers = new ArrayList<>();
|
private final List<FightPlayer> bluePlayers = new ArrayList<>();
|
||||||
|
|||||||
@@ -28,14 +28,12 @@ import java.sql.PreparedStatement;
|
|||||||
import java.util.zip.GZIPInputStream;
|
import java.util.zip.GZIPInputStream;
|
||||||
|
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@Getter
|
|
||||||
public class NodeData {
|
public class NodeData {
|
||||||
|
|
||||||
static {
|
static {
|
||||||
new SqlTypeMapper<>(PipedInputStream.class, "BLOB", (rs, identifier) -> { throw new SecurityException("PipedInputStream is write only datatype"); }, PreparedStatement::setBinaryStream);
|
new SqlTypeMapper<>(PipedInputStream.class, "BLOB", (rs, identifier) -> { throw new SecurityException("PipedInputStream is write only datatype"); }, PreparedStatement::setBinaryStream);
|
||||||
new SqlTypeMapper<>(ByteArrayInputStream.class, "BLOB", (rs, identifier) -> { throw new SecurityException("ByteArrayInputStream is write only datatype"); }, PreparedStatement::setBinaryStream);
|
new SqlTypeMapper<>(ByteArrayInputStream.class, "BLOB", (rs, identifier) -> { throw new SecurityException("ByteArrayInputStream is write only datatype"); }, PreparedStatement::setBinaryStream);
|
||||||
new SqlTypeMapper<>(BufferedInputStream.class, "BLOB", (rs, identifier) -> { throw new SecurityException("BufferedInputStream is write only datatype"); }, PreparedStatement::setBinaryStream);
|
new SqlTypeMapper<>(BufferedInputStream.class, "BLOB", (rs, identifier) -> { throw new SecurityException("BufferedInputStream is write only datatype"); }, PreparedStatement::setBinaryStream);
|
||||||
|
|
||||||
SqlTypeMapper.ordinalEnumMapper(SchematicFormat.class);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final Table<NodeData> table = new Table<>(NodeData.class);
|
private static final Table<NodeData> table = new Table<>(NodeData.class);
|
||||||
@@ -50,24 +48,21 @@ public class NodeData {
|
|||||||
throw new IllegalArgumentException("Node is a directory");
|
throw new IllegalArgumentException("Node is a directory");
|
||||||
return get.select(rs -> {
|
return get.select(rs -> {
|
||||||
if(rs.next()) {
|
if(rs.next()) {
|
||||||
return new NodeData(node.getId(), SchematicFormat.values()[rs.getInt("NodeFormat")]);
|
return new NodeData(node.getId(), rs.getBoolean("NodeFormat"));
|
||||||
} else {
|
} else {
|
||||||
return new NodeData(node.getId(), SchematicFormat.MCEDIT);
|
return new NodeData(node.getId(), false);
|
||||||
}
|
}
|
||||||
}, node);
|
}, node);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Getter
|
||||||
@Field(keys = {Table.PRIMARY})
|
@Field(keys = {Table.PRIMARY})
|
||||||
private final int nodeId;
|
private final int nodeId;
|
||||||
|
|
||||||
@Field
|
@Field
|
||||||
private SchematicFormat nodeFormat;
|
private boolean nodeFormat;
|
||||||
|
|
||||||
public InputStream schemData() throws IOException {
|
public InputStream schemData() throws IOException {
|
||||||
return schemData(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
public InputStream schemData(boolean decompress) throws IOException {
|
|
||||||
try {
|
try {
|
||||||
return selSchemData.select(rs -> {
|
return selSchemData.select(rs -> {
|
||||||
rs.next();
|
rs.next();
|
||||||
@@ -76,11 +71,7 @@ public class NodeData {
|
|||||||
if(rs.wasNull() || schemData.available() == 0) {
|
if(rs.wasNull() || schemData.available() == 0) {
|
||||||
throw new SecurityException("SchemData is null");
|
throw new SecurityException("SchemData is null");
|
||||||
}
|
}
|
||||||
if (decompress) {
|
return new GZIPInputStream(schemData);
|
||||||
return new GZIPInputStream(schemData);
|
|
||||||
} else {
|
|
||||||
return schemData;
|
|
||||||
}
|
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new SecurityException("SchemData is wrong", e);
|
throw new SecurityException("SchemData is wrong", e);
|
||||||
}
|
}
|
||||||
@@ -90,18 +81,12 @@ public class NodeData {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void saveFromStream(InputStream blob, SchematicFormat newFormat) {
|
public void saveFromStream(InputStream blob, boolean newFormat) {
|
||||||
updateDatabase.update(nodeId, newFormat, blob);
|
updateDatabase.update(nodeId, newFormat, blob);
|
||||||
nodeFormat = newFormat;
|
nodeFormat = newFormat;
|
||||||
}
|
}
|
||||||
|
|
||||||
@AllArgsConstructor
|
public boolean getNodeFormat() {
|
||||||
@Getter
|
return nodeFormat;
|
||||||
public enum SchematicFormat {
|
|
||||||
MCEDIT(".schematic"),
|
|
||||||
SPONGE_V2(".schem"),
|
|
||||||
SPONGE_V3(".schem");
|
|
||||||
|
|
||||||
private final String fileEnding;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* This file is a part of the SteamWar software.
|
* This file is a part of the SteamWar software.
|
||||||
*
|
*
|
||||||
* Copyright (C) 2025 SteamWar.de-Serverteam
|
* Copyright (C) 2021 SteamWar.de-Serverteam
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU Affero General Public License as published by
|
||||||
@@ -20,11 +20,9 @@
|
|||||||
package de.steamwar.sql;
|
package de.steamwar.sql;
|
||||||
|
|
||||||
import de.steamwar.sql.internal.Field;
|
import de.steamwar.sql.internal.Field;
|
||||||
import de.steamwar.sql.internal.SelectStatement;
|
|
||||||
import de.steamwar.sql.internal.Statement;
|
import de.steamwar.sql.internal.Statement;
|
||||||
import de.steamwar.sql.internal.Table;
|
import de.steamwar.sql.internal.Table;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Getter;
|
|
||||||
|
|
||||||
import java.security.MessageDigest;
|
import java.security.MessageDigest;
|
||||||
import java.security.NoSuchAlgorithmException;
|
import java.security.NoSuchAlgorithmException;
|
||||||
@@ -35,26 +33,16 @@ import java.time.Instant;
|
|||||||
public class NodeDownload {
|
public class NodeDownload {
|
||||||
|
|
||||||
private static final char[] HEX = new char[]{'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' };
|
private static final char[] HEX = new char[]{'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' };
|
||||||
private static final String LINK_BASE = "https://api.steamwar.de/download/";
|
private static final String LINK_BASE = "https://steamwar.de/download.php?schem=";
|
||||||
|
|
||||||
private static final Table<NodeDownload> table = new Table<>(NodeDownload.class);
|
private static final Table<NodeDownload> table = new Table<>(NodeDownload.class);
|
||||||
private static final Statement insert = table.insertFields("NodeId", "Link");
|
private static final Statement insert = table.insertFields("NodeId", "Link");
|
||||||
|
|
||||||
private static final SelectStatement<NodeDownload> select = table.selectFields("link");
|
|
||||||
|
|
||||||
private static final Statement delete = table.delete(Table.PRIMARY);
|
|
||||||
|
|
||||||
public static NodeDownload get(String link) {
|
|
||||||
return select.select(link);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Getter
|
|
||||||
@Field(keys = {Table.PRIMARY})
|
@Field(keys = {Table.PRIMARY})
|
||||||
private final int nodeId;
|
private final int nodeId;
|
||||||
@Field
|
@Field
|
||||||
private final String link;
|
private final String link;
|
||||||
@Field(def = "CURRENT_TIMESTAMP")
|
@Field(def = "CURRENT_TIMESTAMP")
|
||||||
@Getter
|
|
||||||
private final Timestamp timestamp;
|
private final Timestamp timestamp;
|
||||||
|
|
||||||
public static String getLink(SchematicNode schem){
|
public static String getLink(SchematicNode schem){
|
||||||
@@ -72,15 +60,10 @@ public class NodeDownload {
|
|||||||
insert.update(schem.getId(), hash);
|
insert.update(schem.getId(), hash);
|
||||||
return LINK_BASE + hash;
|
return LINK_BASE + hash;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String base16encode(byte[] byteArray) {
|
public static String base16encode(byte[] byteArray) {
|
||||||
StringBuilder hexBuffer = new StringBuilder(byteArray.length * 2);
|
StringBuilder hexBuffer = new StringBuilder(byteArray.length * 2);
|
||||||
for (byte b : byteArray)
|
for (byte b : byteArray)
|
||||||
hexBuffer.append(HEX[(b >>> 4) & 0xF]).append(HEX[b & 0xF]);
|
hexBuffer.append(HEX[(b >>> 4) & 0xF]).append(HEX[b & 0xF]);
|
||||||
return hexBuffer.toString();
|
return hexBuffer.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void delete() {
|
|
||||||
delete.update(nodeId);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -72,10 +72,6 @@ public class NodeMember {
|
|||||||
return new NodeMember(node, member, null);
|
return new NodeMember(node, member, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static NodeMember getNodeMember(int node, SteamwarUser member) {
|
|
||||||
return getNodeMember(node, member.getId());
|
|
||||||
}
|
|
||||||
|
|
||||||
public static NodeMember getNodeMember(int node, int member) {
|
public static NodeMember getNodeMember(int node, int member) {
|
||||||
return getNodeMember.select(node, member);
|
return getNodeMember.select(node, member);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -121,11 +121,11 @@ public class Punishment {
|
|||||||
public enum PunishmentType {
|
public enum PunishmentType {
|
||||||
Ban(false, "BAN_TEAM", "BAN_PERMA", "BAN_UNTIL", "UNBAN_ERROR", "UNBAN"),
|
Ban(false, "BAN_TEAM", "BAN_PERMA", "BAN_UNTIL", "UNBAN_ERROR", "UNBAN"),
|
||||||
Mute( false, "MUTE_TEAM", "MUTE_PERMA", "MUTE_UNTIL", "UNMUTE_ERROR", "UNMUTE"),
|
Mute( false, "MUTE_TEAM", "MUTE_PERMA", "MUTE_UNTIL", "UNMUTE_ERROR", "UNMUTE"),
|
||||||
NoSchemReceiving(true, "NOSCHEMRECEIVING_TEAM", "NOSCHEMRECEIVING_PERMA", "NOSCHEMRECEIVING_UNTIL", "UNNOSCHEMRECEIVING_ERROR", "UNNOSCHEMRECEIVING"),
|
NoSchemReceiving(false, "NOSCHEMRECEIVING_TEAM", "NOSCHEMRECEIVING_PERMA", "NOSCHEMRECEIVING_UNTIL", "UNNOSCHEMRECEIVING_ERROR", "UNNOSCHEMRECEIVING"),
|
||||||
NoSchemSharing(true, "NOSCHEMSHARING_TEAM", "NOSCHEMSHARING_PERMA", "NOSCHEMSHARING_UNTIL", "UNNOSCHEMSHARING_ERROR", "UNNOSCHEMSHARING"),
|
NoSchemSharing(false, "NOSCHEMSHARING_TEAM", "NOSCHEMSHARING_PERMA", "NOSCHEMSHARING_UNTIL", "UNNOSCHEMSHARING_ERROR", "UNNOSCHEMSHARING"),
|
||||||
NoSchemSubmitting(false, "NOSCHEMSUBMITTING_TEAM", "NOSCHEMSUBMITTING_PERMA", "NOSCHEMSUBMITTING_UNTIL", "UNNOSCHEMSUBMITTING_ERROR", "UNNOSCHEMSUBMITTING"),
|
NoSchemSubmitting(true, "NOSCHEMSUBMITTING_TEAM", "NOSCHEMSUBMITTING_PERMA", "NOSCHEMSUBMITTING_UNTIL", "UNNOSCHEMSUBMITTING_ERROR", "UNNOSCHEMSUBMITTING"),
|
||||||
NoDevServer(true, "NODEVSERVER_TEAM", "NODEVSERVER_PERMA", "NODEVSERVER_UNTIL", "UNNODEVSERVER_ERROR", "UNNODEVSERVER"),
|
NoDevServer(true, "NODEVSERVER_TEAM", "NODEVSERVER_PERMA", "NODEVSERVER_UNTIL", "UNNODEVSERVER_ERROR", "UNNODEVSERVER"),
|
||||||
NoFightServer(true, "NOFIGHTSERVER_TEAM", "NOFIGHTSERVER_PERMA", "NOFIGHTSERVER_UNTIL", "UNNOFIGHTSERVER_ERROR", "UNNOFIGHTSERVER"),
|
NoFightServer(false, "NOFIGHTSERVER_TEAM", "NOFIGHTSERVER_PERMA", "NOFIGHTSERVER_UNTIL", "UNNOFIGHTSERVER_ERROR", "UNNOFIGHTSERVER"),
|
||||||
NoTeamServer(true, "NOTEAMSERVER_TEAM", "NOTEAMSERVER_PERMA", "NOTEAMSERVER_UNTIL", "UNNOTEAMSERVER_ERROR", "UNNOTEAMSERVER"),
|
NoTeamServer(true, "NOTEAMSERVER_TEAM", "NOTEAMSERVER_PERMA", "NOTEAMSERVER_UNTIL", "UNNOTEAMSERVER_ERROR", "UNNOTEAMSERVER"),
|
||||||
Note(false, "NOTE_TEAM", null, null, null, null, true);
|
Note(false, "NOTE_TEAM", null, null, null, null, true);
|
||||||
|
|
||||||
|
|||||||
@@ -21,7 +21,6 @@ package de.steamwar.sql;
|
|||||||
|
|
||||||
import de.steamwar.sql.internal.Field;
|
import de.steamwar.sql.internal.Field;
|
||||||
import de.steamwar.sql.internal.SelectStatement;
|
import de.steamwar.sql.internal.SelectStatement;
|
||||||
import de.steamwar.sql.internal.Statement;
|
|
||||||
import de.steamwar.sql.internal.Table;
|
import de.steamwar.sql.internal.Table;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
|
|
||||||
@@ -34,17 +33,6 @@ public class Referee {
|
|||||||
private static final Table<Referee> table = new Table<>(Referee.class);
|
private static final Table<Referee> table = new Table<>(Referee.class);
|
||||||
private static final SelectStatement<Referee> byEvent = table.selectFields("eventID");
|
private static final SelectStatement<Referee> byEvent = table.selectFields("eventID");
|
||||||
|
|
||||||
private static final Statement insert = table.insertAll();
|
|
||||||
private static final Statement delete = table.delete("eventReferee");
|
|
||||||
|
|
||||||
public static void add(int eventID, int userID) {
|
|
||||||
insert.update(eventID, userID);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void remove(int eventID, int userID) {
|
|
||||||
delete.update(eventID, userID);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Set<Integer> get(int eventID) {
|
public static Set<Integer> get(int eventID) {
|
||||||
return byEvent.listSelect(eventID).stream().map(referee -> referee.userID).collect(Collectors.toSet());
|
return byEvent.listSelect(eventID).stream().map(referee -> referee.userID).collect(Collectors.toSet());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,74 @@
|
|||||||
|
/*
|
||||||
|
* 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.sql;
|
||||||
|
|
||||||
|
import de.steamwar.sql.internal.*;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileInputStream;
|
||||||
|
import java.io.FileNotFoundException;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.StandardCopyOption;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class Replay {
|
||||||
|
|
||||||
|
static {
|
||||||
|
new SqlTypeMapper<>(File.class, "BLOB", (rs, identifier) -> {
|
||||||
|
try {
|
||||||
|
File file = File.createTempFile("replay", ".replay");
|
||||||
|
file.deleteOnExit();
|
||||||
|
Files.copy(rs.getBinaryStream(identifier), file.toPath(), StandardCopyOption.REPLACE_EXISTING);
|
||||||
|
return file;
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new SQLException(e);
|
||||||
|
}
|
||||||
|
}, (st, index, value) -> {
|
||||||
|
try {
|
||||||
|
st.setBinaryStream(index, new FileInputStream(value));
|
||||||
|
} catch (FileNotFoundException e) {
|
||||||
|
throw new SQLException(e);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private static final Table<Replay> table = new Table<>(Replay.class);
|
||||||
|
private static final SelectStatement<Replay> get = table.select(Table.PRIMARY);
|
||||||
|
|
||||||
|
public static final Statement insert = table.insertAll();
|
||||||
|
|
||||||
|
public static Replay get(int fightID) {
|
||||||
|
return get.select(fightID);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void save(int fightID, File file) {
|
||||||
|
insert.update(fightID, file);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Field(keys = {Table.PRIMARY})
|
||||||
|
private final int fightID;
|
||||||
|
@Getter
|
||||||
|
@Field
|
||||||
|
private final File replay;
|
||||||
|
}
|
||||||
@@ -31,13 +31,10 @@ public class SchematicNode {
|
|||||||
|
|
||||||
static {
|
static {
|
||||||
SchematicType.Normal.name(); // Ensure SchematicType is loaded.
|
SchematicType.Normal.name(); // Ensure SchematicType is loaded.
|
||||||
new SqlTypeMapper<>(SchematicNode.class, null, (rs, identifier) -> {
|
new SqlTypeMapper<>(SchematicNode.class, null, (rs, identifier) -> { throw new SecurityException("SchematicNode cannot be used as type (recursive select)"); }, (st, index, value) -> st.setInt(index, value.nodeId));
|
||||||
throw new SecurityException("SchematicNode cannot be used as type (recursive select)");
|
|
||||||
}, (st, index, value) -> st.setInt(index, value.nodeId));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final Map<Integer, Map<String, List<String>>> TAB_CACHE = new HashMap<>();
|
private static final Map<Integer, Map<String, List<String>>> TAB_CACHE = new HashMap<>();
|
||||||
|
|
||||||
public static void clear() {
|
public static void clear() {
|
||||||
TAB_CACHE.clear();
|
TAB_CACHE.clear();
|
||||||
}
|
}
|
||||||
@@ -45,60 +42,39 @@ public class SchematicNode {
|
|||||||
private static final String nodeSelector = "SELECT NodeId, NodeOwner, NodeOwner AS EffectiveOwner, NodeName, ParentNode, LastUpdate, NodeItem, NodeType, NodeRank, ReplaceColor, AllowReplay FROM SchematicNode ";
|
private static final String nodeSelector = "SELECT NodeId, NodeOwner, NodeOwner AS EffectiveOwner, NodeName, ParentNode, LastUpdate, NodeItem, NodeType, NodeRank, ReplaceColor, AllowReplay FROM SchematicNode ";
|
||||||
|
|
||||||
private static final Table<SchematicNode> table = new Table<>(SchematicNode.class);
|
private static final Table<SchematicNode> table = new Table<>(SchematicNode.class);
|
||||||
private static final Statement create = table.insertFields(true, "NodeOwner", "NodeName", "ParentNode", "NodeItem",
|
private static final Statement create = table.insertFields(true, "NodeOwner", "NodeName", "ParentNode", "NodeItem", "NodeType");
|
||||||
"NodeType");
|
private static final Statement update = table.update(Table.PRIMARY, "NodeName", "ParentNode", "NodeItem", "NodeType", "NodeRank", "ReplaceColor", "AllowReplay");
|
||||||
private static final Statement update = table.update(Table.PRIMARY, "NodeName", "ParentNode", "NodeItem",
|
|
||||||
"NodeType", "NodeRank", "ReplaceColor", "AllowReplay");
|
|
||||||
private static final Statement delete = table.delete(Table.PRIMARY);
|
private static final Statement delete = table.delete(Table.PRIMARY);
|
||||||
|
|
||||||
private static final SelectStatement<SchematicNode> byId = new SelectStatement<>(table,
|
private static final SelectStatement<SchematicNode> byId = new SelectStatement<>(table, nodeSelector + "WHERE NodeId = ?");
|
||||||
nodeSelector + "WHERE NodeId = ?");
|
private static final SelectStatement<SchematicNode> byOwnerNameParent = new SelectStatement<>(table, nodeSelector + "WHERE NodeOwner = ? AND NodeName = ? AND ParentNode " + Statement.NULL_SAFE_EQUALS + "?");
|
||||||
private static final SelectStatement<SchematicNode> byOwnerNameParent = new SelectStatement<>(table,
|
private static final SelectStatement<SchematicNode> byParent = new SelectStatement<>(table, nodeSelector + "WHERE ParentNode" + Statement.NULL_SAFE_EQUALS + "? ORDER BY NodeName");
|
||||||
nodeSelector + "WHERE NodeOwner = ? AND NodeName = ? AND ParentNode " + Statement.NULL_SAFE_EQUALS + "?");
|
private static final SelectStatement<SchematicNode> dirsByParent = new SelectStatement<>(table, nodeSelector + "WHERE ParentNode" + Statement.NULL_SAFE_EQUALS + "? AND NodeType is NULL ORDER BY NodeName");
|
||||||
private static final SelectStatement<SchematicNode> byParent = new SelectStatement<>(table,
|
private static final SelectStatement<SchematicNode> byOwnerType = new SelectStatement<>(table, nodeSelector + "WHERE NodeOwner = ? AND NodeType = ? ORDER BY NodeName");
|
||||||
nodeSelector + "WHERE ParentNode" + Statement.NULL_SAFE_EQUALS + "? ORDER BY NodeName");
|
private static final SelectStatement<SchematicNode> byType = new SelectStatement<>(table, nodeSelector + "WHERE NodeType = ? ORDER BY NodeName");
|
||||||
private static final SelectStatement<SchematicNode> dirsByParent = new SelectStatement<>(table, nodeSelector
|
private static final SelectStatement<SchematicNode> all = new SelectStatement<>(table, "SELECT * FROM EffectiveSchematicNode WHERE EffectiveOwner = ? ORDER BY NodeName");
|
||||||
+ "WHERE ParentNode" + Statement.NULL_SAFE_EQUALS + "? AND NodeType is NULL ORDER BY NodeName");
|
private static final SelectStatement<SchematicNode> list = new SelectStatement<>(table, "SELECT SchematicNode.NodeId, NodeOwner, ? AS EffectiveOwner, NodeName, NM.ParentId AS ParentNode, LastUpdate, NodeItem, NodeType, NodeRank, ReplaceColor, AllowReplay FROM SchematicNode INNER JOIN NodeMember NM on SchematicNode.NodeId = NM.NodeId WHERE NM.ParentId " + Statement.NULL_SAFE_EQUALS + "? AND NM.UserId = ? UNION ALL SELECT SchematicNode.NodeId, NodeOwner, ? AS EffectiveOwner, NodeName, ParentNode, LastUpdate, NodeItem, NodeType, NodeRank, ReplaceColor, AllowReplay FROM SchematicNode WHERE (? IS NULL AND ParentNode IS NULL AND NodeOwner = ?) OR (? IS NOT NULL AND ParentNode = ?) ORDER BY NodeName");
|
||||||
private static final SelectStatement<SchematicNode> byOwnerType = new SelectStatement<>(table,
|
private static final SelectStatement<SchematicNode> byParentName = new SelectStatement<>(table, "SELECT SchematicNode.NodeId, NodeOwner, ? AS EffectiveOwner, NodeName, NM.ParentId AS ParentNode, LastUpdate, NodeItem, NodeType, NodeRank, ReplaceColor, AllowReplay FROM SchematicNode INNER JOIN NodeMember NM on SchematicNode.NodeId = NM.NodeId WHERE NM.ParentId " + Statement.NULL_SAFE_EQUALS + "? AND NM.UserId = ? AND SchematicNode.NodeName = ? UNION ALL SELECT SchematicNode.NodeId, NodeOwner, ? AS EffectiveOwner, NodeName, ParentNode, LastUpdate, NodeItem, NodeType, NodeRank, ReplaceColor, AllowReplay FROM SchematicNode WHERE ((? IS NULL AND ParentNode IS NULL AND NodeOwner = ?) OR (? IS NOT NULL AND ParentNode = ?)) AND NodeName = ?");
|
||||||
nodeSelector + "WHERE NodeOwner = ? AND NodeType = ? ORDER BY NodeName");
|
private static final SelectStatement<SchematicNode> schematicAccessibleForUser = new SelectStatement<>(table, "SELECT COUNT(DISTINCT NodeId) FROM EffectiveSchematicNode WHERE EffectiveOwner = ? AND NodeId = ?");
|
||||||
private static final SelectStatement<SchematicNode> byType = new SelectStatement<>(table,
|
private static final SelectStatement<SchematicNode> accessibleByUserTypeInParent = new SelectStatement<>(table, "WITH RECURSIVE RSASN AS(WITH RECURSIVE RSAN AS (WITH RSANH AS (WITH RECURSIVE RSA AS (SELECT SN.NodeId, NM.ParentId FROM SchematicNode SN LEFT JOIN NodeMember NM on SN.NodeId = NM.NodeId WHERE NM.UserId = ? UNION SELECT SN.NodeId, SN.ParentNode FROM SchematicNode SN INNER JOIN RSA ON RSA.NodeId = SN.ParentNode) SELECT * FROM RSA UNION SELECT NodeId, ParentNode FROM SchematicNode WHERE NodeOwner = ?) SELECT * FROM RSANH UNION SELECT SN.NodeId, SN.ParentNode FROM RSANH JOIN SchematicNode SN ON SN.ParentNode = RSANH.NodeId) SELECT RSAN.NodeId, RSAN.ParentId FROM RSAN JOIN SchematicNode SN ON SN.NodeId = RSAN.NodeId WHERE NodeType = ? UNION SELECT SN.NodeId, SN.ParentNode FROM SchematicNode SN JOIN RSASN ON SN.NodeId = RSASN.ParentId) SELECT SN.*, ? as EffectiveOwner, RSASN.ParentId AS ParentNode FROM RSASN JOIN SchematicNode SN ON SN.NodeId = RSASN.NodeId WHERE RSASN.ParentId" + Statement.NULL_SAFE_EQUALS + "? ORDER BY NodeName");
|
||||||
nodeSelector + "WHERE NodeType = ? ORDER BY NodeName");
|
private static final SelectStatement<SchematicNode> accessibleByUserType = new SelectStatement<>(table, "WITH RECURSIVE Nodes AS (SELECT NodeId, ParentId as ParentNode FROM NodeMember WHERE UserId = ? UNION SELECT NodeId, ParentNode FROM SchematicNode WHERE NodeOwner = ?), RSN AS ( SELECT NodeId, ParentNode FROM Nodes UNION SELECT SN.NodeId, SN.ParentNode FROM SchematicNode SN, RSN WHERE SN.ParentNode = RSN.NodeId ) SELECT SN.*, ? AS EffectiveOwner FROM RSN INNER JOIN SchematicNode SN ON RSN.NodeId = SN.NodeId WHERE NodeType = ?");
|
||||||
private static final SelectStatement<SchematicNode> all = new SelectStatement<>(table,
|
private static final SelectStatement<SchematicNode> byIdAndUser = new SelectStatement<>(table, "SELECT NodeId, NodeOwner, ? AS EffectiveOwner, NodeName, ParentNode, LastUpdate, NodeItem, NodeType, NodeRank, ReplaceColor, AllowReplay FROM SchematicNode WHERE NodeId = ?");
|
||||||
"WITH RECURSIVE Nodes AS (SELECT NodeId, ParentId as ParentNode FROM NodeMember WHERE UserId = ? UNION SELECT NodeId, ParentNode FROM SchematicNode WHERE NodeOwner = ?), RSN AS ( SELECT NodeId, ParentNode FROM Nodes UNION SELECT SN.NodeId, SN.ParentNode FROM SchematicNode SN, RSN WHERE SN.ParentNode = RSN.NodeId ) SELECT SN.*, ? AS EffectiveOwner FROM RSN INNER JOIN SchematicNode SN ON RSN.NodeId = SN.NodeId");
|
private static final SelectStatement<SchematicNode> allParentsOfNode = new SelectStatement<>(table, "WITH RECURSIVE R AS (SELECT NodeId, ParentNode FROM EffectiveSchematicNode WHERE NodeId = ? AND EffectiveOwner = ? UNION SELECT E.NodeId, E.ParentNode FROM R, EffectiveSchematicNode E WHERE R.ParentNode = E.NodeId AND E.EffectiveOwner = ?) SELECT SN.NodeId, SN.NodeOwner, ? AS EffectiveOwner, SN.NodeName, R.ParentNode, SN.LastUpdate, SN.NodeItem, SN.NodeType, SN.NodeRank, SN.ReplaceColor, SN.AllowReplay FROM R INNER JOIN SchematicNode SN ON SN.NodeId = R.NodeId");
|
||||||
private static final SelectStatement<SchematicNode> list = new SelectStatement<>(table,
|
|
||||||
"SELECT SchematicNode.NodeId, NodeOwner, ? AS EffectiveOwner, NodeName, NM.ParentId AS ParentNode, LastUpdate, NodeItem, NodeType, NodeRank, ReplaceColor, AllowReplay FROM SchematicNode INNER JOIN NodeMember NM on SchematicNode.NodeId = NM.NodeId WHERE NM.ParentId "
|
|
||||||
+ Statement.NULL_SAFE_EQUALS
|
|
||||||
+ "? AND NM.UserId = ? UNION ALL SELECT SchematicNode.NodeId, NodeOwner, ? AS EffectiveOwner, NodeName, ParentNode, LastUpdate, NodeItem, NodeType, NodeRank, ReplaceColor, AllowReplay FROM SchematicNode WHERE (? IS NULL AND ParentNode IS NULL AND NodeOwner = ?) OR (? IS NOT NULL AND ParentNode = ?) ORDER BY NodeName");
|
|
||||||
private static final SelectStatement<SchematicNode> byParentName = new SelectStatement<>(table,
|
|
||||||
"SELECT SchematicNode.NodeId, NodeOwner, ? AS EffectiveOwner, NodeName, NM.ParentId AS ParentNode, LastUpdate, NodeItem, NodeType, NodeRank, ReplaceColor, AllowReplay FROM SchematicNode INNER JOIN NodeMember NM on SchematicNode.NodeId = NM.NodeId WHERE NM.ParentId "
|
|
||||||
+ Statement.NULL_SAFE_EQUALS
|
|
||||||
+ "? AND NM.UserId = ? AND SchematicNode.NodeName = ? UNION ALL SELECT SchematicNode.NodeId, NodeOwner, ? AS EffectiveOwner, NodeName, ParentNode, LastUpdate, NodeItem, NodeType, NodeRank, ReplaceColor, AllowReplay FROM SchematicNode WHERE ((? IS NULL AND ParentNode IS NULL AND NodeOwner = ?) OR (? IS NOT NULL AND ParentNode = ?)) AND NodeName = ?");
|
|
||||||
private static final SelectStatement<SchematicNode> schematicAccessibleForUser = new SelectStatement<>(table,
|
|
||||||
"WITH RECURSIVE Nodes AS (SELECT NodeId, ParentId as ParentNode FROM NodeMember WHERE UserId = ? UNION SELECT NodeId, ParentNode FROM SchematicNode WHERE NodeOwner = ?), RSN AS ( SELECT NodeId, ParentNode FROM Nodes UNION SELECT SN.NodeId, SN.ParentNode FROM SchematicNode SN, RSN WHERE SN.ParentNode = RSN.NodeId ) SELECT SN.*, ? AS EffectiveOwner FROM RSN INNER JOIN SchematicNode SN ON RSN.NodeId = SN.NodeId WHERE NodeId = ?");
|
|
||||||
private static final SelectStatement<SchematicNode> accessibleByUserTypeInParent = new SelectStatement<>(table,
|
|
||||||
"WITH RECURSIVE RSASN AS(WITH RECURSIVE RSAN AS (WITH RSANH AS (WITH RECURSIVE RSA AS (SELECT SN.NodeId, NM.ParentId FROM SchematicNode SN LEFT JOIN NodeMember NM on SN.NodeId = NM.NodeId WHERE NM.UserId = ? UNION SELECT SN.NodeId, SN.ParentNode FROM SchematicNode SN INNER JOIN RSA ON RSA.NodeId = SN.ParentNode) SELECT * FROM RSA UNION SELECT NodeId, ParentNode FROM SchematicNode WHERE NodeOwner = ?) SELECT * FROM RSANH UNION SELECT SN.NodeId, SN.ParentNode FROM RSANH JOIN SchematicNode SN ON SN.ParentNode = RSANH.NodeId) SELECT RSAN.NodeId, RSAN.ParentId FROM RSAN JOIN SchematicNode SN ON SN.NodeId = RSAN.NodeId WHERE NodeType = ? UNION SELECT SN.NodeId, SN.ParentNode FROM SchematicNode SN JOIN RSASN ON SN.NodeId = RSASN.ParentId) SELECT SN.*, ? as EffectiveOwner, RSASN.ParentId AS ParentNode FROM RSASN JOIN SchematicNode SN ON SN.NodeId = RSASN.NodeId WHERE RSASN.ParentId"
|
|
||||||
+ Statement.NULL_SAFE_EQUALS + "? ORDER BY NodeName");
|
|
||||||
private static final SelectStatement<SchematicNode> accessibleByUserType = new SelectStatement<>(table,
|
|
||||||
"WITH RECURSIVE Nodes AS (SELECT NodeId, ParentId as ParentNode FROM NodeMember WHERE UserId = ? UNION SELECT NodeId, ParentNode FROM SchematicNode WHERE NodeOwner = ?), RSN AS ( SELECT NodeId, ParentNode FROM Nodes UNION SELECT SN.NodeId, SN.ParentNode FROM SchematicNode SN, RSN WHERE SN.ParentNode = RSN.NodeId ) SELECT SN.*, ? AS EffectiveOwner FROM RSN INNER JOIN SchematicNode SN ON RSN.NodeId = SN.NodeId WHERE NodeType = ?");
|
|
||||||
private static final SelectStatement<SchematicNode> byIdAndUser = new SelectStatement<>(table,
|
|
||||||
"SELECT NodeId, NodeOwner, ? AS EffectiveOwner, NodeName, ParentNode, LastUpdate, NodeItem, NodeType, NodeRank, ReplaceColor, AllowReplay FROM SchematicNode WHERE NodeId = ?");
|
|
||||||
private static final SelectStatement<SchematicNode> allParentsOfNode = new SelectStatement<>(table,
|
|
||||||
"WITH RECURSIVE R AS (SELECT NodeId, ParentNode FROM EffectiveSchematicNode WHERE NodeId = ? AND EffectiveOwner = ? UNION SELECT E.NodeId, E.ParentNode FROM R, EffectiveSchematicNode E WHERE R.ParentNode = E.NodeId AND E.EffectiveOwner = ?) SELECT SN.NodeId, SN.NodeOwner, ? AS EffectiveOwner, SN.NodeName, R.ParentNode, SN.LastUpdate, SN.NodeItem, SN.NodeType, SN.NodeRank, SN.ReplaceColor, SN.AllowReplay FROM R INNER JOIN SchematicNode SN ON SN.NodeId = R.NodeId");
|
|
||||||
|
|
||||||
static {
|
static {
|
||||||
NodeMember.init();
|
NodeMember.init();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Field(keys = { Table.PRIMARY }, autoincrement = true)
|
@Field(keys = {Table.PRIMARY}, autoincrement = true)
|
||||||
private final int nodeId;
|
private final int nodeId;
|
||||||
@Field(keys = { "OwnerNameParent" })
|
@Field(keys = {"OwnerNameParent"})
|
||||||
private final int nodeOwner;
|
private final int nodeOwner;
|
||||||
@Field(def = "0")
|
@Field(def = "0")
|
||||||
@Getter
|
@Getter
|
||||||
private final int effectiveOwner;
|
private final int effectiveOwner;
|
||||||
@Field(keys = { "OwnerNameParent" })
|
@Field(keys = {"OwnerNameParent"})
|
||||||
private String nodeName;
|
private String nodeName;
|
||||||
@Field(keys = { "OwnerNameParent" }, nullable = true)
|
@Field(keys = {"OwnerNameParent"}, nullable = true)
|
||||||
private Integer parentNode;
|
private Integer parentNode;
|
||||||
@Field(def = "CURRENT_TIMESTAMP")
|
@Field(def = "CURRENT_TIMESTAMP")
|
||||||
private Timestamp lastUpdate;
|
private Timestamp lastUpdate;
|
||||||
@@ -126,7 +102,8 @@ public class SchematicNode {
|
|||||||
SchematicType nodeType,
|
SchematicType nodeType,
|
||||||
int nodeRank,
|
int nodeRank,
|
||||||
boolean replaceColor,
|
boolean replaceColor,
|
||||||
boolean allowReplay) {
|
boolean allowReplay
|
||||||
|
) {
|
||||||
this.nodeId = nodeId;
|
this.nodeId = nodeId;
|
||||||
this.nodeOwner = nodeOwner;
|
this.nodeOwner = nodeOwner;
|
||||||
this.effectiveOwner = effectiveOwner;
|
this.effectiveOwner = effectiveOwner;
|
||||||
@@ -141,7 +118,7 @@ public class SchematicNode {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static List<SchematicNode> getAll(SteamwarUser user) {
|
public static List<SchematicNode> getAll(SteamwarUser user) {
|
||||||
return all.listSelect(user, user, user);
|
return all.listSelect(user);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Map<Integer, List<SchematicNode>> getAllMap(SteamwarUser user) {
|
public static Map<Integer, List<SchematicNode>> getAllMap(SteamwarUser user) {
|
||||||
@@ -153,8 +130,7 @@ public class SchematicNode {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static SchematicNode byParentName(SteamwarUser user, Integer schematicId, String name) {
|
public static SchematicNode byParentName(SteamwarUser user, Integer schematicId, String name) {
|
||||||
return byParentName.select(user, schematicId, user, name, user, schematicId, user, schematicId, schematicId,
|
return byParentName.select(user, schematicId, user, name, user, schematicId, user, schematicId, schematicId, name);
|
||||||
name);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<SchematicNode> accessibleByUserType(SteamwarUser user, SchematicType type) {
|
public static List<SchematicNode> accessibleByUserType(SteamwarUser user, SchematicType type) {
|
||||||
@@ -166,11 +142,10 @@ public class SchematicNode {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static boolean schematicAccessibleForUser(SteamwarUser user, Integer schematicId) {
|
public static boolean schematicAccessibleForUser(SteamwarUser user, Integer schematicId) {
|
||||||
return schematicAccessibleForUser.select(user, user, user, schematicId) != null;
|
return schematicAccessibleForUser.select(user, schematicId) != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<SchematicNode> accessibleByUserTypeParent(SteamwarUser user, SchematicType type,
|
public static List<SchematicNode> accessibleByUserTypeParent(SteamwarUser user, SchematicType type, Integer parentId) {
|
||||||
Integer parentId) {
|
|
||||||
return accessibleByUserTypeInParent.listSelect(user, user, type, user, parentId);
|
return accessibleByUserTypeInParent.listSelect(user, user, type, user, parentId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -185,8 +160,7 @@ public class SchematicNode {
|
|||||||
private static Map<Integer, List<SchematicNode>> map(List<SchematicNode> in) {
|
private static Map<Integer, List<SchematicNode>> map(List<SchematicNode> in) {
|
||||||
Map<Integer, List<SchematicNode>> map = new HashMap<>();
|
Map<Integer, List<SchematicNode>> map = new HashMap<>();
|
||||||
for (SchematicNode effectiveSchematicNode : in) {
|
for (SchematicNode effectiveSchematicNode : in) {
|
||||||
map.computeIfAbsent(effectiveSchematicNode.getOptionalParent().orElse(0), k -> new ArrayList<>())
|
map.computeIfAbsent(effectiveSchematicNode.getOptionalParent().orElse(0), k -> new ArrayList<>()).add(effectiveSchematicNode);
|
||||||
.add(effectiveSchematicNode);
|
|
||||||
}
|
}
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
@@ -244,8 +218,7 @@ public class SchematicNode {
|
|||||||
return byId.select(id);
|
return byId.select(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<SchematicNode> getAccessibleSchematicsOfTypeInParent(int owner, String schemType,
|
public static List<SchematicNode> getAccessibleSchematicsOfTypeInParent(int owner, String schemType, Integer parent) {
|
||||||
Integer parent) {
|
|
||||||
return accessibleByUserTypeParent(SteamwarUser.get(owner), SchematicType.fromDB(schemType), parent);
|
return accessibleByUserTypeParent(SteamwarUser.get(owner), SchematicType.fromDB(schemType), parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -310,12 +283,10 @@ public class SchematicNode {
|
|||||||
}
|
}
|
||||||
if (s.contains("/")) {
|
if (s.contains("/")) {
|
||||||
String[] layers = s.split("/");
|
String[] layers = s.split("/");
|
||||||
Optional<SchematicNode> currentNode = Optional
|
Optional<SchematicNode> currentNode = Optional.ofNullable(SchematicNode.byParentName(user, null, layers[0]));
|
||||||
.ofNullable(SchematicNode.byParentName(user, null, layers[0]));
|
|
||||||
for (int i = 1; i < layers.length; i++) {
|
for (int i = 1; i < layers.length; i++) {
|
||||||
int finalI = i;
|
int finalI = i;
|
||||||
Optional<SchematicNode> node = currentNode.map(effectiveSchematicNode -> SchematicNode
|
Optional<SchematicNode> node = currentNode.map(effectiveSchematicNode -> SchematicNode.byParentName(user, effectiveSchematicNode.getId(), layers[finalI]));
|
||||||
.byParentName(user, effectiveSchematicNode.getId(), layers[finalI]));
|
|
||||||
if (!node.isPresent()) {
|
if (!node.isPresent()) {
|
||||||
return null;
|
return null;
|
||||||
} else {
|
} else {
|
||||||
@@ -394,7 +365,7 @@ public class SchematicNode {
|
|||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public void setType(String type) {
|
public void setType(String type) {
|
||||||
if (isDir())
|
if(isDir())
|
||||||
throw new SecurityException("Node is Directory");
|
throw new SecurityException("Node is Directory");
|
||||||
this.nodeType = SchematicType.fromDB(type);
|
this.nodeType = SchematicType.fromDB(type);
|
||||||
updateDB();
|
updateDB();
|
||||||
@@ -404,14 +375,15 @@ public class SchematicNode {
|
|||||||
return nodeType == null;
|
return nodeType == null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getFileEnding() {
|
@Deprecated
|
||||||
if (isDir())
|
public boolean getSchemFormat() {
|
||||||
|
if(isDir())
|
||||||
throw new SecurityException("Node is Directory");
|
throw new SecurityException("Node is Directory");
|
||||||
return NodeData.get(this).getNodeFormat().getFileEnding();
|
return NodeData.get(this).getNodeFormat();
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getRank() {
|
public int getRank() {
|
||||||
if (isDir())
|
if(isDir())
|
||||||
throw new SecurityException("Node is Directory");
|
throw new SecurityException("Node is Directory");
|
||||||
return nodeRank;
|
return nodeRank;
|
||||||
}
|
}
|
||||||
@@ -422,19 +394,19 @@ public class SchematicNode {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setRank(int rank) {
|
public void setRank(int rank) {
|
||||||
if (isDir())
|
if(isDir())
|
||||||
throw new SecurityException("Node is Directory");
|
throw new SecurityException("Node is Directory");
|
||||||
this.nodeRank = rank;
|
this.nodeRank = rank;
|
||||||
}
|
}
|
||||||
|
|
||||||
public SchematicType getSchemtype() {
|
public SchematicType getSchemtype() {
|
||||||
if (isDir())
|
if(isDir())
|
||||||
throw new SecurityException("Is Directory");
|
throw new SecurityException("Is Directory");
|
||||||
return nodeType;
|
return nodeType;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSchemtype(SchematicType type) {
|
public void setSchemtype(SchematicType type) {
|
||||||
if (isDir())
|
if(isDir())
|
||||||
throw new SecurityException("Is Directory");
|
throw new SecurityException("Is Directory");
|
||||||
this.nodeType = type;
|
this.nodeType = type;
|
||||||
updateDB();
|
updateDB();
|
||||||
@@ -445,7 +417,7 @@ public class SchematicNode {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setReplaceColor(boolean replaceColor) {
|
public void setReplaceColor(boolean replaceColor) {
|
||||||
if (isDir())
|
if(isDir())
|
||||||
throw new SecurityException("Is Directory");
|
throw new SecurityException("Is Directory");
|
||||||
this.replaceColor = replaceColor;
|
this.replaceColor = replaceColor;
|
||||||
updateDB();
|
updateDB();
|
||||||
@@ -456,15 +428,14 @@ public class SchematicNode {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setAllowReplay(boolean allowReplay) {
|
public void setAllowReplay(boolean allowReplay) {
|
||||||
if (isDir())
|
if(isDir())
|
||||||
throw new SecurityException("Is Directory");
|
throw new SecurityException("Is Directory");
|
||||||
this.allowReplay = allowReplay;
|
this.allowReplay = allowReplay;
|
||||||
updateDB();
|
updateDB();
|
||||||
}
|
}
|
||||||
|
|
||||||
public SchematicNode getParentNode() {
|
public SchematicNode getParentNode() {
|
||||||
if (parentNode == null)
|
if(parentNode == null) return null;
|
||||||
return null;
|
|
||||||
return SchematicNode.getSchematicNode(parentNode);
|
return SchematicNode.getSchematicNode(parentNode);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -472,7 +443,7 @@ public class SchematicNode {
|
|||||||
return SchemElo.getElo(this, season);
|
return SchemElo.getElo(this, season);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean accessibleByUser(SteamwarUser user) {
|
public boolean accessibleByUser(int user) {
|
||||||
return NodeMember.getNodeMember(nodeId, user) != null;
|
return NodeMember.getNodeMember(nodeId, user) != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -516,7 +487,7 @@ public class SchematicNode {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String generateBreadcrumbs() {
|
public String generateBreadcrumbs() {
|
||||||
if (brCache == null) {
|
if(brCache == null) {
|
||||||
brCache = generateBreadcrumbs("/");
|
brCache = generateBreadcrumbs("/");
|
||||||
}
|
}
|
||||||
return brCache;
|
return brCache;
|
||||||
@@ -525,39 +496,17 @@ public class SchematicNode {
|
|||||||
public String generateBreadcrumbs(String split) {
|
public String generateBreadcrumbs(String split) {
|
||||||
StringBuilder builder = new StringBuilder(getName());
|
StringBuilder builder = new StringBuilder(getName());
|
||||||
Optional<SchematicNode> currentNode = Optional.of(this);
|
Optional<SchematicNode> currentNode = Optional.of(this);
|
||||||
if (currentNode.map(SchematicNode::isDir).orElse(false)) {
|
if(currentNode.map(SchematicNode::isDir).orElse(false)) {
|
||||||
builder.append(split);
|
builder.append(split);
|
||||||
}
|
}
|
||||||
while (currentNode.isPresent()) {
|
while (currentNode.isPresent()) {
|
||||||
currentNode = currentNode
|
currentNode = currentNode.flatMap(schematicNode -> Optional.ofNullable(NodeMember.getNodeMember(schematicNode.getId(), effectiveOwner)).map(NodeMember::getParent).orElse(schematicNode.getOptionalParent())).map(SchematicNode::getSchematicNode);
|
||||||
.flatMap(schematicNode -> Optional
|
|
||||||
.ofNullable(NodeMember.getNodeMember(schematicNode.getId(), effectiveOwner))
|
|
||||||
.map(NodeMember::getParent).orElse(schematicNode.getOptionalParent()))
|
|
||||||
.map(SchematicNode::getSchematicNode);
|
|
||||||
currentNode.ifPresent(node -> builder.insert(0, split).insert(0, node.getName()));
|
currentNode.ifPresent(node -> builder.insert(0, split).insert(0, node.getName()));
|
||||||
}
|
}
|
||||||
return builder.toString();
|
return builder.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Map.Entry<String, Integer>> generateBreadcrumbsMap(SteamwarUser user) {
|
|
||||||
List<Map.Entry<String, Integer>> map = new ArrayList<>();
|
|
||||||
Optional<SchematicNode> currentNode = Optional.of(this);
|
|
||||||
if (currentNode.map(SchematicNode::isDir).orElse(false)) {
|
|
||||||
map.add(new AbstractMap.SimpleEntry<>(getName(), getId()));
|
|
||||||
}
|
|
||||||
while (currentNode.isPresent()) {
|
|
||||||
currentNode = currentNode
|
|
||||||
.flatMap(schematicNode -> Optional
|
|
||||||
.ofNullable(NodeMember.getNodeMember(schematicNode.getId(), effectiveOwner))
|
|
||||||
.map(NodeMember::getParent).orElse(schematicNode.getOptionalParent()))
|
|
||||||
.map(SchematicNode::getSchematicNode);
|
|
||||||
currentNode.ifPresent(node -> map.add(0, new AbstractMap.SimpleEntry<>(node.getName(), node.getId())));
|
|
||||||
}
|
|
||||||
return map;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static final List<String> FORBIDDEN_NAMES = Collections.unmodifiableList(Arrays.asList("public"));
|
private static final List<String> FORBIDDEN_NAMES = Collections.unmodifiableList(Arrays.asList("public"));
|
||||||
|
|
||||||
public static boolean invalidSchemName(String[] layers) {
|
public static boolean invalidSchemName(String[] layers) {
|
||||||
for (String layer : layers) {
|
for (String layer : layers) {
|
||||||
if (layer.isEmpty()) {
|
if (layer.isEmpty()) {
|
||||||
@@ -574,7 +523,7 @@ public class SchematicNode {
|
|||||||
layer.contains(" ")) {
|
layer.contains(" ")) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (FORBIDDEN_NAMES.contains(layer.toLowerCase())) {
|
if(FORBIDDEN_NAMES.contains(layer.toLowerCase())) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -588,15 +537,14 @@ public class SchematicNode {
|
|||||||
}
|
}
|
||||||
int index = s.lastIndexOf("/");
|
int index = s.lastIndexOf("/");
|
||||||
String cacheKey = index == -1 ? "" : s.substring(0, index);
|
String cacheKey = index == -1 ? "" : s.substring(0, index);
|
||||||
if (TAB_CACHE.containsKey(user.getId()) && TAB_CACHE.get(user.getId()).containsKey(cacheKey)) {
|
if(TAB_CACHE.containsKey(user.getId()) && TAB_CACHE.get(user.getId()).containsKey(cacheKey)) {
|
||||||
return new ArrayList<>(TAB_CACHE.get(user.getId()).get(cacheKey));
|
return new ArrayList<>(TAB_CACHE.get(user.getId()).get(cacheKey));
|
||||||
}
|
}
|
||||||
List<String> list = new ArrayList<>();
|
List<String> list = new ArrayList<>();
|
||||||
if (s.contains("/")) {
|
if (s.contains("/")) {
|
||||||
String preTab = s.substring(0, s.lastIndexOf("/") + 1);
|
String preTab = s.substring(0, s.lastIndexOf("/") + 1);
|
||||||
SchematicNode pa = SchematicNode.getNodeFromPath(user, preTab);
|
SchematicNode pa = SchematicNode.getNodeFromPath(user, preTab);
|
||||||
if (pa == null)
|
if (pa == null) return new ArrayList<>();
|
||||||
return new ArrayList<>();
|
|
||||||
List<SchematicNode> nodes = SchematicNode.list(user, pa.getId());
|
List<SchematicNode> nodes = SchematicNode.list(user, pa.getId());
|
||||||
String br = pa.generateBreadcrumbs();
|
String br = pa.generateBreadcrumbs();
|
||||||
nodes.forEach(node -> list.add((sws ? "/" : "") + br + node.getName() + (node.isDir() ? "/" : "")));
|
nodes.forEach(node -> list.add((sws ? "/" : "") + br + node.getName() + (node.isDir() ? "/" : "")));
|
||||||
|
|||||||
@@ -108,7 +108,7 @@ public class SchematicType {
|
|||||||
return name.toLowerCase();
|
return name.toLowerCase();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static SchematicType fromDB(String input) {
|
public static SchematicType fromDB(String input){
|
||||||
return fromDB.get(input.toLowerCase());
|
return fromDB.get(input.toLowerCase());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ import java.security.SecureRandom;
|
|||||||
import java.security.spec.InvalidKeySpecException;
|
import java.security.spec.InvalidKeySpecException;
|
||||||
import java.sql.Timestamp;
|
import java.sql.Timestamp;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.function.BiConsumer;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
@@ -61,7 +62,6 @@ public class SteamwarUser {
|
|||||||
private static final SelectStatement<SteamwarUser> byDiscord = table.selectFields("DiscordId");
|
private static final SelectStatement<SteamwarUser> byDiscord = table.selectFields("DiscordId");
|
||||||
private static final SelectStatement<SteamwarUser> byTeam = table.selectFields("Team");
|
private static final SelectStatement<SteamwarUser> byTeam = table.selectFields("Team");
|
||||||
private static final SelectStatement<SteamwarUser> getUsersWithPerm = new SelectStatement<>(table, "SELECT S.* FROM UserData S JOIN UserPerm P ON S.id = P.User WHERE P.Perm = ?");
|
private static final SelectStatement<SteamwarUser> getUsersWithPerm = new SelectStatement<>(table, "SELECT S.* FROM UserData S JOIN UserPerm P ON S.id = P.User WHERE P.Perm = ?");
|
||||||
private static final SelectStatement<SteamwarUser> getAll = new SelectStatement<SteamwarUser>(table, "SELECT * FROM UserData");
|
|
||||||
|
|
||||||
private static final Statement updateName = table.update(Table.PRIMARY, "UserName");
|
private static final Statement updateName = table.update(Table.PRIMARY, "UserName");
|
||||||
private static final Statement updatePassword = table.update(Table.PRIMARY, "Password");
|
private static final Statement updatePassword = table.update(Table.PRIMARY, "Password");
|
||||||
@@ -72,7 +72,6 @@ public class SteamwarUser {
|
|||||||
|
|
||||||
private static final Statement getPlaytime = new Statement("SELECT SUM(UNIX_TIMESTAMP(EndTime) - UNIX_TIMESTAMP(StartTime)) as Playtime FROM Session WHERE UserID = ?");
|
private static final Statement getPlaytime = new Statement("SELECT SUM(UNIX_TIMESTAMP(EndTime) - UNIX_TIMESTAMP(StartTime)) as Playtime FROM Session WHERE UserID = ?");
|
||||||
private static final Statement getFirstjoin = new Statement("SELECT MIN(StartTime) AS FirstJoin FROM Session WHERE UserID = ?");
|
private static final Statement getFirstjoin = new Statement("SELECT MIN(StartTime) AS FirstJoin FROM Session WHERE UserID = ?");
|
||||||
private static final Statement getLastonline = new Statement("SELECT MAX(EndTime) AS LastOnline FROM Session WHERE UserID = ?");
|
|
||||||
|
|
||||||
private static final Map<Integer, SteamwarUser> usersById = new HashMap<>();
|
private static final Map<Integer, SteamwarUser> usersById = new HashMap<>();
|
||||||
private static final Map<UUID, SteamwarUser> usersByUUID = new HashMap<>();
|
private static final Map<UUID, SteamwarUser> usersByUUID = new HashMap<>();
|
||||||
@@ -121,12 +120,13 @@ public class SteamwarUser {
|
|||||||
return byDiscord.select(discordId);
|
return byDiscord.select(discordId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static SteamwarUser getOrCreate(UUID uuid, String name, Consumer<UUID> newPlayer) {
|
public static SteamwarUser getOrCreate(UUID uuid, String name, Consumer<UUID> newPlayer, BiConsumer<String, String> nameUpdate) {
|
||||||
SteamwarUser user = get(uuid);
|
SteamwarUser user = get(uuid);
|
||||||
|
|
||||||
if (user != null) {
|
if (user != null) {
|
||||||
if (!user.userName.equals(name)) {
|
if (!user.userName.equals(name)) {
|
||||||
updateName.update(name, user.id);
|
updateName.update(name, user.id);
|
||||||
|
nameUpdate.accept(user.userName, name);
|
||||||
user.userName = name;
|
user.userName = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -275,14 +275,6 @@ public class SteamwarUser {
|
|||||||
}, id);
|
}, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Timestamp getLastOnline() {
|
|
||||||
return getLastonline.select(rs -> {
|
|
||||||
if (rs.next())
|
|
||||||
return rs.getTimestamp("LastOnline");
|
|
||||||
return null;
|
|
||||||
}, id);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void punish(Punishment.PunishmentType punishment, Timestamp time, String banReason, int from, boolean perma) {
|
public void punish(Punishment.PunishmentType punishment, Timestamp time, String banReason, int from, boolean perma) {
|
||||||
initPunishments();
|
initPunishments();
|
||||||
punishments.remove(punishment);
|
punishments.remove(punishment);
|
||||||
@@ -335,7 +327,7 @@ public class SteamwarUser {
|
|||||||
|
|
||||||
public boolean verifyPassword(String password) {
|
public boolean verifyPassword(String password) {
|
||||||
try {
|
try {
|
||||||
if (!hasPassword()) {
|
if (this.password == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -357,10 +349,6 @@ public class SteamwarUser {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasPassword() {
|
|
||||||
return this.password != null;
|
|
||||||
}
|
|
||||||
|
|
||||||
private byte[] generateHash(String password, byte[] salt)
|
private byte[] generateHash(String password, byte[] salt)
|
||||||
throws InvalidKeySpecException {
|
throws InvalidKeySpecException {
|
||||||
PBEKeySpec spec = new PBEKeySpec(password.toCharArray(), salt, 65536, 512);
|
PBEKeySpec spec = new PBEKeySpec(password.toCharArray(), salt, 65536, 512);
|
||||||
@@ -382,8 +370,4 @@ public class SteamwarUser {
|
|||||||
permissions = UserPerm.getPerms(id);
|
permissions = UserPerm.getPerms(id);
|
||||||
prefix = permissions.stream().filter(UserPerm.prefixes::containsKey).findAny().map(UserPerm.prefixes::get).orElse(UserPerm.emptyPrefix);
|
prefix = permissions.stream().filter(UserPerm.prefixes::containsKey).findAny().map(UserPerm.prefixes::get).orElse(UserPerm.emptyPrefix);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<SteamwarUser> getAll() {
|
|
||||||
return getAll.listSelect();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -75,7 +75,15 @@ public class UserElo {
|
|||||||
|
|
||||||
public static void setElo(int userId, String gameMode, int elo) {
|
public static void setElo(int userId, String gameMode, int elo) {
|
||||||
emblemCache.remove(userId);
|
emblemCache.remove(userId);
|
||||||
|
|
||||||
|
int oldPlacement = getPlacement(getElo(userId, gameMode).orElse(0), gameMode);
|
||||||
|
int newPlacement = getPlacement(elo, gameMode);
|
||||||
|
|
||||||
gameModeUserEloCache.getOrDefault(gameMode, Collections.emptyMap()).remove(userId);
|
gameModeUserEloCache.getOrDefault(gameMode, Collections.emptyMap()).remove(userId);
|
||||||
|
if (oldPlacement <= 3 || newPlacement <= 3) {
|
||||||
|
emblemCache.clear();
|
||||||
|
}
|
||||||
|
|
||||||
setElo.update(Season.getSeason(), gameMode, userId, elo);
|
setElo.update(Season.getSeason(), gameMode, userId, elo);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -104,17 +112,27 @@ public class UserElo {
|
|||||||
public static String getEmblemProgression(String gameMode, int userId) {
|
public static String getEmblemProgression(String gameMode, int userId) {
|
||||||
switch (getProgression(userId, gameMode)) {
|
switch (getProgression(userId, gameMode)) {
|
||||||
case -1:
|
case -1:
|
||||||
return "§8❱❱❱❱ ❂";
|
return "§f/ §8∨ ∧ ∨ ∧ ∨ ∧ ❂ III II I";
|
||||||
case 0:
|
case 0:
|
||||||
return "§e❱§8❱❱❱ ❂";
|
return "§8/ §6∨ §8∧ ∨ ∧ ∨ ∧ ❂ III II I";
|
||||||
case 1:
|
case 1:
|
||||||
return "§e❱❱§8❱❱ ❂";
|
return "§8/ ∨ §6∧ §8∨ ∧ ∨ ∧ ❂ III II I";
|
||||||
case 2:
|
case 2:
|
||||||
return "§e❱❱❱§8❱ ❂";
|
return "§8/ ∨ ∧ §7∨ §8∧ ∨ ∧ ❂ III II I";
|
||||||
case 3:
|
case 3:
|
||||||
return "§e❱❱❱❱§8 ❂";
|
return "§8/ ∨ ∧ ∨ §7∧ §8∨ ∧ ❂ III II I";
|
||||||
case 4:
|
case 4:
|
||||||
return "§8❱❱❱❱ §5❂";
|
return "§8/ ∨ ∧ ∨ ∧ §e∨ §8∧ ❂ III II I";
|
||||||
|
case 5:
|
||||||
|
return "§8/ ∨ ∧ ∨ ∧ ∨ §e∧ §8❂ III II I";
|
||||||
|
case 6:
|
||||||
|
return "§8/ ∨ ∧ ∨ ∧ ∨ ∧ §5❂ §8III II I";
|
||||||
|
case 7:
|
||||||
|
return "§8/ ∨ ∧ ∨ ∧ ∨ ∧ ❂ §5III §8II I";
|
||||||
|
case 8:
|
||||||
|
return "§8/ ∨ ∧ ∨ ∧ ∨ ∧ ❂ III §5II §8I";
|
||||||
|
case 9:
|
||||||
|
return "§8/ ∨ ∧ ∨ ∧ ∨ ∧ ❂ III II §5I";
|
||||||
default:
|
default:
|
||||||
throw new SecurityException("Progression is not in range");
|
throw new SecurityException("Progression is not in range");
|
||||||
}
|
}
|
||||||
@@ -124,11 +142,19 @@ public class UserElo {
|
|||||||
int elo = getElo(userId, gameMode).orElse(-1);
|
int elo = getElo(userId, gameMode).orElse(-1);
|
||||||
if (elo < 0) return -1;
|
if (elo < 0) return -1;
|
||||||
|
|
||||||
if (elo < 150) return 0;
|
if (elo <= 100) return 0;
|
||||||
if (elo < 350) return 1;
|
if (elo <= 200) return 1;
|
||||||
if (elo < 600) return 2;
|
if (elo <= 400) return 2;
|
||||||
if (elo < 900) return 3;
|
if (elo <= 600) return 3;
|
||||||
return 4;
|
if (elo <= 900) return 4;
|
||||||
|
if (elo <= 1200) return 5;
|
||||||
|
|
||||||
|
int placement = getPlacement(elo, gameMode);
|
||||||
|
if (placement == 1) return 9;
|
||||||
|
if (placement == 2) return 8;
|
||||||
|
if (placement == 3) return 7;
|
||||||
|
|
||||||
|
return 6;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String toEmblem(int progression) {
|
public static String toEmblem(int progression) {
|
||||||
@@ -136,15 +162,25 @@ public class UserElo {
|
|||||||
case -1:
|
case -1:
|
||||||
return "";
|
return "";
|
||||||
case 0:
|
case 0:
|
||||||
return "§e❱ ";
|
return "§6∨ ";
|
||||||
case 1:
|
case 1:
|
||||||
return "§e❱❱ ";
|
return "§6∧ ";
|
||||||
case 2:
|
case 2:
|
||||||
return "§e❱❱❱ ";
|
return "§7∨ ";
|
||||||
case 3:
|
case 3:
|
||||||
return "§e❱❱❱❱ ";
|
return "§7∧ ";
|
||||||
case 4:
|
case 4:
|
||||||
|
return "§e∨ ";
|
||||||
|
case 5:
|
||||||
|
return "§e∧ ";
|
||||||
|
case 6:
|
||||||
return "§5❂ ";
|
return "§5❂ ";
|
||||||
|
case 7:
|
||||||
|
return "§5III ";
|
||||||
|
case 8:
|
||||||
|
return "§5II ";
|
||||||
|
case 9:
|
||||||
|
return "§5I ";
|
||||||
default:
|
default:
|
||||||
throw new SecurityException("Progression out of range");
|
throw new SecurityException("Progression out of range");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,10 @@
|
|||||||
|
|
||||||
package de.steamwar.sql;
|
package de.steamwar.sql;
|
||||||
|
|
||||||
import de.steamwar.sql.internal.*;
|
import de.steamwar.sql.internal.Field;
|
||||||
|
import de.steamwar.sql.internal.SelectStatement;
|
||||||
|
import de.steamwar.sql.internal.SqlTypeMapper;
|
||||||
|
import de.steamwar.sql.internal.Table;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
|
||||||
@@ -65,21 +68,11 @@ public enum UserPerm {
|
|||||||
|
|
||||||
private static final Table<UserPermTable> table = new Table<>(UserPermTable.class, "UserPerm");
|
private static final Table<UserPermTable> table = new Table<>(UserPermTable.class, "UserPerm");
|
||||||
private static final SelectStatement<UserPermTable> getPerms = table.selectFields("user");
|
private static final SelectStatement<UserPermTable> getPerms = table.selectFields("user");
|
||||||
private static final Statement addPerm = table.insertAll();
|
|
||||||
private static final Statement removePerm = table.delete(Table.PRIMARY);
|
|
||||||
|
|
||||||
public static Set<UserPerm> getPerms(int user) {
|
public static Set<UserPerm> getPerms(int user) {
|
||||||
return getPerms.listSelect(user).stream().map(up -> up.perm).collect(Collectors.toSet());
|
return getPerms.listSelect(user).stream().map(up -> up.perm).collect(Collectors.toSet());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void addPerm(SteamwarUser user, UserPerm perm) {
|
|
||||||
addPerm.update(user, perm);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void removePerm(SteamwarUser user, UserPerm perm) {
|
|
||||||
removePerm.update(user, perm);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public static class Prefix {
|
public static class Prefix {
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ public class Statement implements AutoCloseable {
|
|||||||
String user = properties.getProperty("user");
|
String user = properties.getProperty("user");
|
||||||
String password = properties.getProperty("password");
|
String password = properties.getProperty("password");
|
||||||
|
|
||||||
PRODUCTION_DATABASE = "production".equals(properties.getProperty("database"));
|
PRODUCTION_DATABASE = "core".equals(properties.getProperty("database"));
|
||||||
MAX_CONNECTIONS = SQLConfig.impl.maxConnections();
|
MAX_CONNECTIONS = SQLConfig.impl.maxConnections();
|
||||||
conProvider = () -> {
|
conProvider = () -> {
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -83,11 +83,7 @@ public class Table<T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Statement insertAll() {
|
public Statement insertAll() {
|
||||||
return insertAll(false);
|
return insertFields(false, Arrays.stream(fields).map(f -> f.identifier).toArray(String[]::new));
|
||||||
}
|
|
||||||
|
|
||||||
public Statement insertAll(boolean returnGeneratedKeys) {
|
|
||||||
return insertFields(returnGeneratedKeys, Arrays.stream(fields).map(f -> f.identifier).toArray(String[]::new));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Statement insertFields(String... fields) {
|
public Statement insertFields(String... fields) {
|
||||||
|
|||||||
@@ -22,8 +22,8 @@ plugins {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compileOnly(project(":SpigotCore", "default"))
|
compileOnly(project(":SpigotCore"))
|
||||||
compileOnly(project(":FightSystem:FightSystem_Core", "default"))
|
compileOnly(project(":FightSystem:FightSystem_Core"))
|
||||||
|
|
||||||
compileOnly(libs.nms10)
|
compileOnly(libs.nms10)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,9 +22,9 @@ plugins {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compileOnly(project(":SpigotCore", "default"))
|
compileOnly(project(":SpigotCore"))
|
||||||
compileOnly(project(":FightSystem:FightSystem_Core", "default"))
|
compileOnly(project(":FightSystem:FightSystem_Core"))
|
||||||
compileOnly(project(":FightSystem:FightSystem_8", "default"))
|
compileOnly(project(":FightSystem:FightSystem_8"))
|
||||||
|
|
||||||
compileOnly(libs.nms12)
|
compileOnly(libs.nms12)
|
||||||
compileOnly(libs.worldedit12)
|
compileOnly(libs.worldedit12)
|
||||||
|
|||||||
@@ -22,10 +22,10 @@ plugins {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compileOnly(project(":SpigotCore", "default"))
|
compileOnly(project(":SpigotCore"))
|
||||||
compileOnly(project(":FightSystem:FightSystem_Core", "default"))
|
compileOnly(project(":FightSystem:FightSystem_Core"))
|
||||||
compileOnly(project(":FightSystem:FightSystem_8", "default"))
|
compileOnly(project(":FightSystem:FightSystem_8"))
|
||||||
compileOnly(project(":FightSystem:FightSystem_9", "default"))
|
compileOnly(project(":FightSystem:FightSystem_9"))
|
||||||
|
|
||||||
compileOnly(libs.nms14)
|
compileOnly(libs.nms14)
|
||||||
compileOnly(libs.worldedit15)
|
compileOnly(libs.worldedit15)
|
||||||
|
|||||||
+25
-26
@@ -19,46 +19,45 @@
|
|||||||
|
|
||||||
package de.steamwar.fightsystem.utils;
|
package de.steamwar.fightsystem.utils;
|
||||||
|
|
||||||
import de.steamwar.Reflection;
|
import com.comphenix.tinyprotocol.Reflection;
|
||||||
import de.steamwar.core.Core;
|
import de.steamwar.core.Core;
|
||||||
import de.steamwar.fightsystem.Config;
|
import de.steamwar.fightsystem.Config;
|
||||||
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.entity.Entity;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public class BlockIdWrapper14 implements BlockIdWrapper {
|
public class BlockIdWrapper14 implements BlockIdWrapper {
|
||||||
|
|
||||||
private static final Class<?> chunkProviderServer = Reflection.getClass("net.minecraft.server.level.ServerChunkCache");
|
private static final Class<?> chunkProviderServer = Reflection.getClass("{nms.server.level}.ChunkProviderServer");
|
||||||
private static final Reflection.Method getChunkProvider = Reflection.getTypedMethod(worldServer, null, chunkProviderServer);
|
private static final Reflection.MethodInvoker getChunkProvider = Reflection.getTypedMethod(worldServer, null, chunkProviderServer);
|
||||||
private static final Class<?> playerChunkMap = Reflection.getClass("net.minecraft.server.level.ChunkMap");
|
private static final Class<?> playerChunkMap = Reflection.getClass("{nms.server.level}.PlayerChunkMap");
|
||||||
private static final Reflection.Field<?> getPlayerChunkMap = Reflection.getField(chunkProviderServer, playerChunkMap, 0);
|
private static final Reflection.FieldAccessor<?> getPlayerChunkMap = Reflection.getField(chunkProviderServer, playerChunkMap, 0);
|
||||||
private static final Reflection.Field<? extends Map> entityTrackers = Core.getVersion() > 15 ? Reflection.getField(playerChunkMap, Int2ObjectMap.class, 0) : Reflection.getField(playerChunkMap, org.bukkit.craftbukkit.libs.it.unimi.dsi.fastutil.ints.Int2ObjectMap.class, 0);
|
private static final Reflection.FieldAccessor<? extends Map> entityTrackers = Core.getVersion() > 15 ? Reflection.getField(playerChunkMap, Int2ObjectMap.class, 0) : Reflection.getField(playerChunkMap, org.bukkit.craftbukkit.libs.it.unimi.dsi.fastutil.ints.Int2ObjectMap.class, 0);
|
||||||
private static final Class<?> block = Reflection.getClass("net.minecraft.world.level.block.Block");
|
private static final Class<?> block = Reflection.getClass("{nms.world.level.block}.Block");
|
||||||
private static final Class<?> iBlockData = Reflection.getClass("net.minecraft.world.level.block.state.BlockState");
|
private static final Class<?> iBlockData = Reflection.getClass("{nms.world.level.block.state}.IBlockData");
|
||||||
private static final Class<?> blockPosition = Reflection.getClass("net.minecraft.core.BlockPos");
|
private static final Class<?> blockPosition = Reflection.getClass("{nms.core}.BlockPosition");
|
||||||
|
|
||||||
private final Map trackers;
|
private final Map trackers;
|
||||||
public BlockIdWrapper14() {
|
public BlockIdWrapper14() {
|
||||||
trackers = entityTrackers.get(getPlayerChunkMap.get(getChunkProvider.invoke(getWorldHandle.invoke(Config.world))));
|
trackers = entityTrackers.get(getPlayerChunkMap.get(getChunkProvider.invoke(getWorldHandle.invoke(Config.world))));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final Reflection.Method getCombinedId = Reflection.getTypedMethod(block, null, int.class, iBlockData);
|
private static final Reflection.MethodInvoker getCombinedId = Reflection.getTypedMethod(block, null, int.class, iBlockData);
|
||||||
private static final Reflection.Method getNMS = Reflection.getTypedMethod(Reflection.getClass("org.bukkit.craftbukkit.block.CraftBlock"), "getNMS", iBlockData);
|
private static final Reflection.MethodInvoker getNMS = Reflection.getTypedMethod(Reflection.getClass("{obc}.block.CraftBlock"), "getNMS", iBlockData);
|
||||||
@Override
|
@Override
|
||||||
public int blockToId(Block block) {
|
public int blockToId(Block block) {
|
||||||
return (int) getCombinedId.invoke(null, getNMS.invoke(block));
|
return (int) getCombinedId.invoke(null, getNMS.invoke(block));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final Reflection.Method getByCombinedId = Reflection.getTypedMethod(block, null, iBlockData, int.class);
|
private static final Reflection.MethodInvoker getByCombinedId = Reflection.getTypedMethod(block, null, iBlockData, int.class);
|
||||||
private static final Reflection.Constructor newBlockPosition = Reflection.getConstructor(blockPosition, int.class, int.class, int.class);
|
private static final Reflection.ConstructorInvoker newBlockPosition = Reflection.getConstructor(blockPosition, int.class, int.class, int.class);
|
||||||
private static final Reflection.Method getTypeAndData = Reflection.getMethod(worldServer, null, blockPosition, iBlockData, int.class);
|
private static final Reflection.MethodInvoker getTypeAndData = Reflection.getMethod(worldServer, null, blockPosition, iBlockData, int.class);
|
||||||
private static final Reflection.Method removeTileEntity = Reflection.getMethod(worldServer, Core.getVersion() > 15 ? "m" : "removeTileEntity", blockPosition);
|
private static final Reflection.MethodInvoker removeTileEntity = Reflection.getMethod(worldServer, Core.getVersion() > 15 ? "m" : "removeTileEntity", blockPosition);
|
||||||
private static final Reflection.Method flagDirty = Reflection.getMethod(chunkProviderServer, null, blockPosition);
|
private static final Reflection.MethodInvoker flagDirty = Reflection.getMethod(chunkProviderServer, null, blockPosition);
|
||||||
@Override
|
@Override
|
||||||
public void setBlock(World world, int x, int y, int z, int blockState) {
|
public void setBlock(World world, int x, int y, int z, int blockState) {
|
||||||
Object blockData = getByCombinedId.invoke(null, blockState);
|
Object blockData = getByCombinedId.invoke(null, blockState);
|
||||||
@@ -70,25 +69,25 @@ public class BlockIdWrapper14 implements BlockIdWrapper {
|
|||||||
flagDirty.invoke(getChunkProvider.invoke(nworld), pos);
|
flagDirty.invoke(getChunkProvider.invoke(nworld), pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final Class<?> entityTracker = Reflection.getClass("net.minecraft.server.level.ChunkMap$TrackedEntity");
|
private static final Class<?> entityTracker = Reflection.getClass("{nms.server.level}.PlayerChunkMap$EntityTracker");
|
||||||
private static final Reflection.Method updatePlayer = Reflection.getMethod(entityTracker, Core.getVersion() > 15 ? "b" : "updatePlayer", entityPlayer);
|
private static final Reflection.MethodInvoker updatePlayer = Reflection.getMethod(entityTracker, Core.getVersion() > 15 ? "b" : "updatePlayer", entityPlayer);
|
||||||
@Override
|
@Override
|
||||||
public void trackEntity(Player player, Entity entity) {
|
public void trackEntity(Player player, int entity) {
|
||||||
Object tracker = trackers.get(entity.getEntityId());
|
Object tracker = trackers.get(entity);
|
||||||
if(tracker != null)
|
if(tracker != null)
|
||||||
updatePlayer.invoke(tracker, getPlayer.invoke(player));
|
updatePlayer.invoke(tracker, getPlayer.invoke(player));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final Reflection.Method clearPlayer = Reflection.getMethod(entityTracker, Core.getVersion() > 15 ? "a" : "clear", entityPlayer);
|
private static final Reflection.MethodInvoker clearPlayer = Reflection.getMethod(entityTracker, Core.getVersion() > 15 ? "a" : "clear", entityPlayer);
|
||||||
@Override
|
@Override
|
||||||
public void untrackEntity(Player player, Entity entity) {
|
public void untrackEntity(Player player, int entity) {
|
||||||
Object tracker = trackers.get(entity.getEntityId());
|
Object tracker = trackers.get(entity);
|
||||||
if(tracker != null)
|
if(tracker != null)
|
||||||
clearPlayer.invoke(tracker, getPlayer.invoke(player));
|
clearPlayer.invoke(tracker, getPlayer.invoke(player));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final Reflection.Method getMaterialByBlock = Reflection.getTypedMethod(Reflection.getClass("org.bukkit.craftbukkit.util.CraftMagicNumbers"), "getMaterial", Material.class, block);
|
private static final Reflection.MethodInvoker getMaterialByBlock = Reflection.getTypedMethod(Reflection.getClass("{obc}.util.CraftMagicNumbers"), "getMaterial", Material.class, block);
|
||||||
private static final Reflection.Method getBlockByBlockData = Reflection.getTypedMethod(iBlockData, null, block);
|
private static final Reflection.MethodInvoker getBlockByBlockData = Reflection.getTypedMethod(iBlockData, null, block);
|
||||||
@Override
|
@Override
|
||||||
public Material idToMaterial(int blockState) {
|
public Material idToMaterial(int blockState) {
|
||||||
return (Material)getMaterialByBlock.invoke(null, getBlockByBlockData.invoke(getByCombinedId.invoke(null, blockState)));
|
return (Material)getMaterialByBlock.invoke(null, getBlockByBlockData.invoke(getByCombinedId.invoke(null, blockState)));
|
||||||
|
|||||||
+1
-2
@@ -42,7 +42,6 @@ import com.sk89q.worldedit.world.block.BaseBlock;
|
|||||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||||
import de.steamwar.fightsystem.Config;
|
import de.steamwar.fightsystem.Config;
|
||||||
import de.steamwar.fightsystem.FightSystem;
|
import de.steamwar.fightsystem.FightSystem;
|
||||||
import de.steamwar.sql.NodeData;
|
|
||||||
import de.steamwar.sql.SchematicData;
|
import de.steamwar.sql.SchematicData;
|
||||||
import de.steamwar.sql.SchematicNode;
|
import de.steamwar.sql.SchematicNode;
|
||||||
import org.bukkit.DyeColor;
|
import org.bukkit.DyeColor;
|
||||||
@@ -145,6 +144,6 @@ public class WorldeditWrapper14 implements WorldeditWrapper {
|
|||||||
throw new SecurityException(e);
|
throw new SecurityException(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
new SchematicData(schem).saveFromBytes(outputStream.toByteArray(), NodeData.SchematicFormat.SPONGE_V2);
|
new SchematicData(schem).saveFromBytes(outputStream.toByteArray(), true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,8 +22,8 @@ plugins {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compileOnly(project(":SpigotCore", "default"))
|
compileOnly(project(":SpigotCore"))
|
||||||
compileOnly(project(":FightSystem:FightSystem_Core", "default"))
|
compileOnly(project(":FightSystem:FightSystem_Core"))
|
||||||
|
|
||||||
compileOnly(libs.nms15)
|
compileOnly(libs.nms15)
|
||||||
compileOnly(libs.worldedit15)
|
compileOnly(libs.worldedit15)
|
||||||
|
|||||||
@@ -22,15 +22,13 @@ plugins {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compileOnly(project(":SpigotCore", "default"))
|
compileOnly(project(":SpigotCore"))
|
||||||
compileOnly(project(":FightSystem:FightSystem_Core", "default"))
|
compileOnly(project(":FightSystem:FightSystem_Core"))
|
||||||
compileOnly(project(":FightSystem:FightSystem_14", "default"))
|
|
||||||
|
|
||||||
compileOnly(libs.spigotapi)
|
compileOnly(libs.spigotapi)
|
||||||
|
|
||||||
compileOnly(libs.nms18)
|
compileOnly(libs.nms18)
|
||||||
compileOnly(libs.fawe18)
|
compileOnly(libs.fawe18)
|
||||||
|
|
||||||
compileOnly(libs.authlib)
|
|
||||||
compileOnly(libs.fastutil)
|
compileOnly(libs.fastutil)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,47 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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.fightsystem.utils;
|
|
||||||
|
|
||||||
import com.comphenix.tinyprotocol.TinyProtocol;
|
|
||||||
import com.mojang.authlib.GameProfile;
|
|
||||||
import de.steamwar.core.ProtocolWrapper;
|
|
||||||
import de.steamwar.fightsystem.FightSystem;
|
|
||||||
import org.bukkit.GameMode;
|
|
||||||
import org.bukkit.entity.Entity;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
public class BlockIdWrapper18 extends BlockIdWrapper14 {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void trackEntity(Player player, Entity entity) {
|
|
||||||
if(entity instanceof Player)
|
|
||||||
TinyProtocol.instance.sendPacket(player, ProtocolWrapper.impl.playerInfoPacketConstructor(ProtocolWrapper.PlayerInfoAction.REMOVE, new GameProfile(entity.getUniqueId(), entity.getName()), GameMode.CREATIVE));
|
|
||||||
|
|
||||||
player.showEntity(FightSystem.getPlugin(), entity);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void untrackEntity(Player player, Entity entity) {
|
|
||||||
player.hideEntity(FightSystem.getPlugin(), entity);
|
|
||||||
|
|
||||||
if(entity instanceof Player)
|
|
||||||
TinyProtocol.instance.sendPacket(player, ProtocolWrapper.impl.playerInfoPacketConstructor(ProtocolWrapper.PlayerInfoAction.ADD, new GameProfile(entity.getUniqueId(), entity.getName()), GameMode.CREATIVE));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
+7
-7
@@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
package de.steamwar.fightsystem.utils;
|
package de.steamwar.fightsystem.utils;
|
||||||
|
|
||||||
import de.steamwar.Reflection;
|
import com.comphenix.tinyprotocol.Reflection;
|
||||||
import de.steamwar.fightsystem.Config;
|
import de.steamwar.fightsystem.Config;
|
||||||
import net.minecraft.server.level.WorldServer;
|
import net.minecraft.server.level.WorldServer;
|
||||||
import net.minecraft.world.level.chunk.Chunk;
|
import net.minecraft.world.level.chunk.Chunk;
|
||||||
@@ -33,9 +33,9 @@ import java.util.stream.StreamSupport;
|
|||||||
|
|
||||||
public class CraftbukkitWrapper18 implements CraftbukkitWrapper {
|
public class CraftbukkitWrapper18 implements CraftbukkitWrapper {
|
||||||
|
|
||||||
private static final Reflection.Method getWorld = Reflection.getMethod(Reflection.getClass("org.bukkit.craftbukkit.CraftWorld"), "getHandle");
|
private static final Reflection.MethodInvoker getWorld = Reflection.getMethod(Reflection.getClass("{obc}.CraftWorld"), "getHandle");
|
||||||
private static final Reflection.Method getChunk = Reflection.getTypedMethod(net.minecraft.world.level.World.class, null, Chunk.class, int.class, int.class);
|
private static final Reflection.MethodInvoker getChunk = Reflection.getTypedMethod(net.minecraft.world.level.World.class, null, Chunk.class, int.class, int.class);
|
||||||
private static final Reflection.Method getChunkSections = Reflection.getTypedMethod(Chunk.class, null, ChunkSection[].class);
|
private static final Reflection.MethodInvoker getChunkSections = Reflection.getTypedMethod(Chunk.class, null, ChunkSection[].class);
|
||||||
private ChunkSection[] getChunkSections(World world, int x, int z) {
|
private ChunkSection[] getChunkSections(World world, int x, int z) {
|
||||||
return (ChunkSection[]) getChunkSections.invoke(getChunk.invoke(getWorld.invoke(world), x, z));
|
return (ChunkSection[]) getChunkSections.invoke(getChunk.invoke(getWorld.invoke(world), x, z));
|
||||||
}
|
}
|
||||||
@@ -46,7 +46,7 @@ public class CraftbukkitWrapper18 implements CraftbukkitWrapper {
|
|||||||
System.arraycopy(getChunkSections(backup, x, z), 0, sections, 0, sections.length);
|
System.arraycopy(getChunkSections(backup, x, z), 0, sections, 0, sections.length);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final Reflection.Method getEntity = Reflection.getTypedMethod(Reflection.getClass("org.bukkit.craftbukkit.entity.CraftEntity"), "getHandle", net.minecraft.world.entity.Entity.class);
|
private static final Reflection.MethodInvoker getEntity = Reflection.getTypedMethod(Reflection.getClass("{obc}.entity.CraftEntity"), "getHandle", net.minecraft.world.entity.Entity.class);
|
||||||
protected net.minecraft.world.entity.Entity getEntity(Entity e) {
|
protected net.minecraft.world.entity.Entity getEntity(Entity e) {
|
||||||
return (net.minecraft.world.entity.Entity) getEntity.invoke(e);
|
return (net.minecraft.world.entity.Entity) getEntity.invoke(e);
|
||||||
}
|
}
|
||||||
@@ -56,8 +56,8 @@ public class CraftbukkitWrapper18 implements CraftbukkitWrapper {
|
|||||||
return getEntity(e).ce();
|
return getEntity(e).ce();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final Reflection.Method getWorldEntities = Reflection.getTypedMethod(WorldServer.class, null, LevelEntityGetter.class);
|
private static final Reflection.MethodInvoker getWorldEntities = Reflection.getTypedMethod(WorldServer.class, null, LevelEntityGetter.class);
|
||||||
private static final Reflection.Method getIterable = Reflection.getTypedMethod(LevelEntityGetter.class, null, Iterable.class);
|
private static final Reflection.MethodInvoker getIterable = Reflection.getTypedMethod(LevelEntityGetter.class, null, Iterable.class);
|
||||||
@Override
|
@Override
|
||||||
public Stream<?> entityIterator() {
|
public Stream<?> entityIterator() {
|
||||||
return StreamSupport.stream(((Iterable<?>) getIterable.invoke(getWorldEntities.invoke(getWorld.invoke(Config.world)))).spliterator(), false);
|
return StreamSupport.stream(((Iterable<?>) getIterable.invoke(getWorldEntities.invoke(getWorld.invoke(Config.world)))).spliterator(), false);
|
||||||
|
|||||||
+17
-8
@@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
package de.steamwar.fightsystem.utils;
|
package de.steamwar.fightsystem.utils;
|
||||||
|
|
||||||
import de.steamwar.Reflection;
|
import com.comphenix.tinyprotocol.Reflection;
|
||||||
import de.steamwar.fightsystem.Config;
|
import de.steamwar.fightsystem.Config;
|
||||||
import it.unimi.dsi.fastutil.shorts.Short2ObjectArrayMap;
|
import it.unimi.dsi.fastutil.shorts.Short2ObjectArrayMap;
|
||||||
import net.minecraft.core.BlockPosition;
|
import net.minecraft.core.BlockPosition;
|
||||||
@@ -27,22 +27,31 @@ import net.minecraft.core.SectionPosition;
|
|||||||
import net.minecraft.network.protocol.game.PacketPlayOutBlockChange;
|
import net.minecraft.network.protocol.game.PacketPlayOutBlockChange;
|
||||||
import net.minecraft.network.protocol.game.PacketPlayOutMultiBlockChange;
|
import net.minecraft.network.protocol.game.PacketPlayOutMultiBlockChange;
|
||||||
import net.minecraft.world.level.block.state.IBlockData;
|
import net.minecraft.world.level.block.state.IBlockData;
|
||||||
|
import org.bukkit.block.data.BlockData;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
public class HullHiderWrapper18 implements HullHiderWrapper {
|
public class HullHiderWrapper18 implements HullHiderWrapper {
|
||||||
|
|
||||||
private static final Reflection.Method getState = Reflection.getTypedMethod(Reflection.getClass("org.bukkit.craftbukkit.block.data.CraftBlockData"), "getState", IBlockData.class);
|
private static final Reflection.MethodInvoker getState = Reflection.getTypedMethod(Reflection.getClass("{obc}.block.data.CraftBlockData"), "getState", IBlockData.class);
|
||||||
@Override
|
@Override
|
||||||
public Object generateBlockChangePacket(List<Hull.IntVector> changes) {
|
public Object generateBlockChangePacket(List<Hull.IntVector> changes) {
|
||||||
Object[] blockdata = new Object[changes.size()];
|
List<Object> blockdata = new ArrayList<>(changes.size());
|
||||||
for(int i = 0; i < blockdata.length; i++) {
|
|
||||||
Hull.IntVector change = changes.get(i);
|
|
||||||
blockdata[i] = getState.invoke(Config.world.getBlockData(change.getX(), change.getY(), change.getZ()));
|
|
||||||
}
|
|
||||||
|
|
||||||
return generateBlockChangePacket(changes, blockdata);
|
changes.removeIf(change -> {
|
||||||
|
BlockData data = Config.world.getBlockData(change.getX(), change.getY(), change.getZ());
|
||||||
|
boolean unchanged = data.getMaterial() == Config.ObfuscateWith || Config.HiddenBlocks.contains(data.getMaterial());
|
||||||
|
if(!unchanged)
|
||||||
|
blockdata.add(getState.invoke(data));
|
||||||
|
return unchanged;
|
||||||
|
});
|
||||||
|
|
||||||
|
if(changes.isEmpty())
|
||||||
|
return null;
|
||||||
|
|
||||||
|
return generateBlockChangePacket(changes, blockdata.toArray());
|
||||||
}
|
}
|
||||||
|
|
||||||
private Object generateBlockChangePacket(List<Hull.IntVector> changes, Object[] blockdata) {
|
private Object generateBlockChangePacket(List<Hull.IntVector> changes, Object[] blockdata) {
|
||||||
|
|||||||
@@ -22,8 +22,8 @@ plugins {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compileOnly(project(":FightSystem:FightSystem_Core", "default"))
|
compileOnly(project(":FightSystem:FightSystem_Core"))
|
||||||
compileOnly(project(":FightSystem:FightSystem_18", "default"))
|
compileOnly(project(":FightSystem:FightSystem_18"))
|
||||||
|
|
||||||
compileOnly(libs.spigotapi)
|
compileOnly(libs.spigotapi)
|
||||||
|
|
||||||
|
|||||||
@@ -22,8 +22,8 @@ plugins {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compileOnly(project(":FightSystem:FightSystem_Core", "default"))
|
compileOnly(project(":FightSystem:FightSystem_Core"))
|
||||||
compileOnly(project(":FightSystem:FightSystem_18", "default"))
|
compileOnly(project(":FightSystem:FightSystem_18"))
|
||||||
|
|
||||||
compileOnly(libs.spigotapi)
|
compileOnly(libs.spigotapi)
|
||||||
|
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user