forked from SteamWar/SteamWar
Bausystem geht™️
This commit is contained in:
@@ -232,21 +232,9 @@ public class FlatteningWrapper14 implements FlatteningWrapper.IFlatteningWrapper
|
||||
scoreboardName.set(packet, ChatWrapper.impl.stringToChatComponent(title));
|
||||
}
|
||||
|
||||
private static final Class<?> scoreActionEnum;
|
||||
private static final Reflection.FieldAccessor<?> scoreAction;
|
||||
private static final Object scoreActionChange;
|
||||
|
||||
static {
|
||||
if (Core.getVersion() < 21) {
|
||||
scoreActionEnum = Reflection.getClass("{nms.server}.ScoreboardServer$Action");
|
||||
scoreAction = Reflection.getField(FlatteningWrapper.scoreboardScore, scoreActionEnum, 0);
|
||||
scoreActionChange = scoreActionEnum.getEnumConstants()[0];
|
||||
} else {
|
||||
scoreActionEnum = null;
|
||||
scoreAction = null;
|
||||
scoreActionChange = null;
|
||||
}
|
||||
}
|
||||
private static final Class<?> scoreActionEnum = Core.getVersion() < 21 ? Reflection.getClass("{nms.server}.ScoreboardServer$Action") : null;
|
||||
private static final Reflection.FieldAccessor<?> scoreAction = Core.getVersion() < 21 ? Reflection.getField(FlatteningWrapper.scoreboardScore, scoreActionEnum, 0) : null;
|
||||
private static final Object scoreActionChange = Core.getVersion() < 21 ? scoreActionEnum.getEnumConstants()[0] : null;
|
||||
|
||||
@Override
|
||||
public void setScoreAction(Object packet) {
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2024 SteamWar.de-Serverteam
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.core;
|
||||
|
||||
import org.bukkit.Material;
|
||||
|
||||
public class TrickyTrialsWrapper14 extends TrickyTrialsWrapper8 {
|
||||
|
||||
@Override
|
||||
public Material getTurtleScute() {
|
||||
return Material.SCUTE;
|
||||
}
|
||||
}
|
||||
@@ -54,8 +54,8 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
public class WorldEditWrapper14 implements WorldEditWrapper.IWorldEditWrapper {
|
||||
|
||||
private static final ClipboardFormat SCHEMATIC = ClipboardFormats.findByAlias("schematic");
|
||||
private static final ClipboardFormat SCHEM = ClipboardFormats.findByAlias("schem");
|
||||
private static final ClipboardFormat SCHEMATIC = BuiltInClipboardFormat.MCEDIT_SCHEMATIC;
|
||||
private static final ClipboardFormat SCHEM = BuiltInClipboardFormat.SPONGE_SCHEMATIC;
|
||||
|
||||
@Override
|
||||
public InputStream getPlayerClipboard(Player player, boolean schemFormat) {
|
||||
|
||||
@@ -19,10 +19,8 @@
|
||||
|
||||
package de.steamwar.core;
|
||||
|
||||
import com.sk89q.jnbt.NBTInputStream;
|
||||
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
||||
import com.sk89q.worldedit.extent.clipboard.io.MCEditSchematicReader;
|
||||
import com.sk89q.worldedit.extent.clipboard.io.SpongeSchematicReader;
|
||||
import com.sk89q.worldedit.extent.clipboard.io.BuiltInClipboardFormat;
|
||||
import de.steamwar.sql.NoClipboardException;
|
||||
|
||||
import java.io.IOException;
|
||||
@@ -34,9 +32,8 @@ public class WorldEditWrapper18 extends WorldEditWrapper14 {
|
||||
@SuppressWarnings("removal")
|
||||
public Clipboard getClipboard(InputStream is, boolean schemFormat) throws IOException {
|
||||
//Use FAWE reader due to FAWE capability of reading corrupt FAWE schems
|
||||
NBTInputStream nbtStream = new NBTInputStream(is);
|
||||
try {
|
||||
return (schemFormat ? new SpongeSchematicReader(nbtStream) : new MCEditSchematicReader(nbtStream)).read();
|
||||
return (schemFormat ? BuiltInClipboardFormat.FAST.getReader(is) : BuiltInClipboardFormat.MCEDIT_SCHEMATIC.getReader(is)).read();
|
||||
} catch (NullPointerException e) {
|
||||
throw new NoClipboardException();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2024 SteamWar.de-Serverteam
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.core;
|
||||
|
||||
import net.minecraft.network.chat.IChatMutableComponent;
|
||||
import net.minecraft.network.chat.contents.LiteralContents;
|
||||
import net.minecraft.network.protocol.game.PacketPlayOutEntityMetadata;
|
||||
import net.minecraft.network.syncher.DataWatcher;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class ChatWrapper21 implements ChatWrapper {
|
||||
@Override
|
||||
public Object stringToChatComponent(String text) {
|
||||
return IChatMutableComponent.a(LiteralContents.a(text));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getDataWatcherPacket(int entityId, Object... dataWatcherKeyValues) {
|
||||
ArrayList<DataWatcher.c<?>> nativeWatchers = new ArrayList<>(1);
|
||||
for(int i = 0; i < dataWatcherKeyValues.length; i+=2) {
|
||||
nativeWatchers.add(((DataWatcher.Item<?>) BountifulWrapper.impl.getDataWatcherItem(dataWatcherKeyValues[i], dataWatcherKeyValues[i+1])).e());
|
||||
}
|
||||
|
||||
return new PacketPlayOutEntityMetadata(entityId, nativeWatchers);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2024 SteamWar.de-Serverteam
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.core;
|
||||
|
||||
import com.comphenix.tinyprotocol.Reflection;
|
||||
import com.comphenix.tinyprotocol.TinyProtocol;
|
||||
import net.minecraft.network.protocol.game.ClientboundLevelChunkWithLightPacket;
|
||||
import net.minecraft.world.level.World;
|
||||
import net.minecraft.world.level.chunk.Chunk;
|
||||
import net.minecraft.world.level.chunk.status.ChunkStatus;
|
||||
import net.minecraft.world.level.lighting.LevelLightEngine;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class CraftbukkitWrapper21 implements CraftbukkitWrapper.ICraftbukkitWrapper {
|
||||
|
||||
private static final Reflection.MethodInvoker getHandle = Reflection.getMethod("{obc}.CraftChunk", "getHandle", ChunkStatus.class);
|
||||
private static final Reflection.MethodInvoker getLightEngine = Reflection.getTypedMethod(World.class, null, LevelLightEngine.class);
|
||||
|
||||
@Override
|
||||
public void sendChunk(Player p, int chunkX, int chunkZ) {
|
||||
Chunk chunk = (Chunk) getHandle.invoke(p.getWorld().getChunkAt(chunkX, chunkZ), ChunkStatus.n);
|
||||
TinyProtocol.instance.sendPacket(p, new ClientboundLevelChunkWithLightPacket(chunk, (LevelLightEngine) getLightEngine.invoke(chunk.r), null, null, true));
|
||||
}
|
||||
}
|
||||
@@ -19,8 +19,11 @@
|
||||
|
||||
package de.steamwar.core;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Particle;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.inventory.InventoryView;
|
||||
|
||||
public class TrickyTrialsWrapper21 implements TrickyTrialsWrapper {
|
||||
@Override
|
||||
@@ -32,4 +35,19 @@ public class TrickyTrialsWrapper21 implements TrickyTrialsWrapper {
|
||||
public Enchantment getUnbreakingEnchantment() {
|
||||
return Enchantment.UNBREAKING;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Material getTurtleScute() {
|
||||
return Material.TURTLE_SCUTE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Particle getVillagerHappyParticle() {
|
||||
return Particle.HAPPY_VILLAGER;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInventoryTitle(InventoryView view) {
|
||||
return view.getTitle();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,8 +19,10 @@
|
||||
|
||||
package de.steamwar.core;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.inventory.InventoryView;
|
||||
|
||||
public class TrickyTrialsWrapper8 implements TrickyTrialsWrapper {
|
||||
@Override
|
||||
@@ -32,4 +34,14 @@ public class TrickyTrialsWrapper8 implements TrickyTrialsWrapper {
|
||||
public Enchantment getUnbreakingEnchantment() {
|
||||
return Enchantment.DURABILITY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Material getTurtleScute() {
|
||||
return Material.STONE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInventoryTitle(InventoryView view) {
|
||||
return view.getTitle();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,6 +43,7 @@ import java.io.*;
|
||||
import java.util.*;
|
||||
import java.util.logging.Level;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.zip.GZIPInputStream;
|
||||
|
||||
public class WorldEditWrapper8 implements WorldEditWrapper.IWorldEditWrapper {
|
||||
|
||||
@@ -88,7 +89,7 @@ public class WorldEditWrapper8 implements WorldEditWrapper.IWorldEditWrapper {
|
||||
WorldData world = new BukkitWorld(player.getWorld()).getWorldData();
|
||||
Clipboard clipboard;
|
||||
try {
|
||||
clipboard = getClipboard(is, schemFormat);
|
||||
clipboard = getClipboard(new GZIPInputStream(is), schemFormat);
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
@@ -32,12 +32,7 @@ dependencies {
|
||||
|
||||
compileOnly(libs.worldedit12)
|
||||
|
||||
compileOnly(libs.paperapi21) {
|
||||
attributes {
|
||||
// Very Hacky, but it works
|
||||
attribute(TargetJvmVersion.TARGET_JVM_VERSION_ATTRIBUTE, 21)
|
||||
}
|
||||
}
|
||||
compileOnly(libs.spigotapi)
|
||||
compileOnly(libs.netty)
|
||||
compileOnly(libs.authlib)
|
||||
compileOnly(libs.viaapi)
|
||||
|
||||
@@ -19,8 +19,11 @@
|
||||
|
||||
package de.steamwar.core;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Particle;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.inventory.InventoryView;
|
||||
|
||||
public interface TrickyTrialsWrapper {
|
||||
TrickyTrialsWrapper impl = VersionDependent.getVersionImpl(Core.getInstance());
|
||||
@@ -28,4 +31,12 @@ public interface TrickyTrialsWrapper {
|
||||
EntityType getTntEntityType();
|
||||
|
||||
Enchantment getUnbreakingEnchantment();
|
||||
|
||||
Material getTurtleScute();
|
||||
|
||||
default Particle getVillagerHappyParticle() {
|
||||
return Particle.VILLAGER_HAPPY;
|
||||
}
|
||||
|
||||
String getInventoryTitle(InventoryView view);
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
package de.steamwar.inventory;
|
||||
|
||||
import de.steamwar.core.Core;
|
||||
import de.steamwar.core.TrickyTrialsWrapper;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -138,7 +139,7 @@ public class SWInventory implements Listener {
|
||||
|
||||
public void open() {
|
||||
InventoryView view = player.openInventory(inventory);
|
||||
title = view.getTitle();
|
||||
title = TrickyTrialsWrapper.impl.getInventoryTitle(view);
|
||||
Core.getInstance().getLogger().info("[SWINV] Opened " + title + " for " + player.getName());
|
||||
if(!open) {
|
||||
Bukkit.getPluginManager().registerEvents(this, Core.getInstance());
|
||||
@@ -153,7 +154,7 @@ public class SWInventory implements Listener {
|
||||
|
||||
if (callbacks.containsKey(e.getRawSlot()) && callbacks.get(e.getRawSlot()) != null) {
|
||||
e.setCancelled(true);
|
||||
Core.getInstance().getLogger().info("[SWINV] " + e.getWhoClicked().getName() + " " + e.getClick().name() + " clicked " + e.getRawSlot() + " on " + (e.getCurrentItem() != null ? e.getCurrentItem().getItemMeta().getDisplayName() : "[EMPTY]") + " in " + e.getView().getTitle());
|
||||
Core.getInstance().getLogger().info("[SWINV] " + e.getWhoClicked().getName() + " " + e.getClick().name() + " clicked " + e.getRawSlot() + " on " + (e.getCurrentItem() != null ? e.getCurrentItem().getItemMeta().getDisplayName() : "[EMPTY]") + " in " + TrickyTrialsWrapper.impl.getInventoryTitle(e.getView()));
|
||||
callbacks.get(e.getRawSlot()).accept(e);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user