forked from SteamWar/SteamWar
Move ViaVersion to Proxy
This commit is contained in:
@@ -38,7 +38,6 @@ dependencies {
|
|||||||
compileOnly(libs.spigotapi)
|
compileOnly(libs.spigotapi)
|
||||||
compileOnly(libs.axiom)
|
compileOnly(libs.axiom)
|
||||||
compileOnly(libs.authlib)
|
compileOnly(libs.authlib)
|
||||||
compileOnly(libs.viaapi)
|
|
||||||
|
|
||||||
compileOnly(libs.fawe18)
|
compileOnly(libs.fawe18)
|
||||||
|
|
||||||
|
|||||||
@@ -1014,5 +1014,3 @@ COLORREPLACE_HELP=§8//§ecolorreplace §8[§7color§8] §8[§7color§8] §8- §
|
|||||||
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}
|
|
||||||
@@ -955,5 +955,3 @@ COLORREPLACE_HELP=§8//§ecolorreplace §8[§7color§8] §8[§7color§8] §8- §
|
|||||||
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}
|
|
||||||
@@ -1,49 +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 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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -2,8 +2,6 @@ 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"
|
||||||
|
|||||||
@@ -26,6 +26,4 @@ dependencies {
|
|||||||
compileOnly(project(":SpigotCore:SpigotCore_8", "default"))
|
compileOnly(project(":SpigotCore:SpigotCore_8", "default"))
|
||||||
|
|
||||||
compileOnly(libs.nms9)
|
compileOnly(libs.nms9)
|
||||||
|
|
||||||
compileOnly(libs.viaapi)
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,10 +20,8 @@
|
|||||||
package de.steamwar.core;
|
package de.steamwar.core;
|
||||||
|
|
||||||
import com.comphenix.tinyprotocol.Reflection;
|
import com.comphenix.tinyprotocol.Reflection;
|
||||||
import com.viaversion.viaversion.api.Via;
|
|
||||||
import net.md_5.bungee.api.ChatMessageType;
|
import net.md_5.bungee.api.ChatMessageType;
|
||||||
import net.md_5.bungee.api.chat.BaseComponent;
|
import net.md_5.bungee.api.chat.BaseComponent;
|
||||||
import net.minecraft.server.v1_9_R2.PacketPlayOutEntity;
|
|
||||||
import org.bukkit.Sound;
|
import org.bukkit.Sound;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@@ -38,7 +36,7 @@ public class BountifulWrapper9 implements BountifulWrapper.IBountifulWrapper {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void sendMessage(Player player, ChatMessageType type, BaseComponent... msg) {
|
public void sendMessage(Player player, ChatMessageType type, BaseComponent... msg) {
|
||||||
if(type == ChatMessageType.CHAT && Via.getAPI().getPlayerVersion(player.getUniqueId()) >= 759)
|
if(type == ChatMessageType.CHAT)
|
||||||
type = ChatMessageType.SYSTEM;
|
type = ChatMessageType.SYSTEM;
|
||||||
|
|
||||||
player.spigot().sendMessage(type, msg);
|
player.spigot().sendMessage(type, msg);
|
||||||
|
|||||||
@@ -35,7 +35,6 @@ dependencies {
|
|||||||
compileOnly(libs.spigotapi)
|
compileOnly(libs.spigotapi)
|
||||||
compileOnly(libs.netty)
|
compileOnly(libs.netty)
|
||||||
compileOnly(libs.authlib)
|
compileOnly(libs.authlib)
|
||||||
compileOnly(libs.viaapi)
|
|
||||||
compileOnly(libs.fastutil)
|
compileOnly(libs.fastutil)
|
||||||
|
|
||||||
implementation(libs.anvilgui)
|
implementation(libs.anvilgui)
|
||||||
|
|||||||
@@ -21,7 +21,6 @@ package de.steamwar.core;
|
|||||||
|
|
||||||
import com.comphenix.tinyprotocol.Reflection;
|
import com.comphenix.tinyprotocol.Reflection;
|
||||||
import com.comphenix.tinyprotocol.TinyProtocol;
|
import com.comphenix.tinyprotocol.TinyProtocol;
|
||||||
import com.viaversion.viaversion.api.Via;
|
|
||||||
import de.steamwar.sql.internal.Statement;
|
import de.steamwar.sql.internal.Statement;
|
||||||
import io.netty.channel.ChannelFuture;
|
import io.netty.channel.ChannelFuture;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
@@ -99,7 +98,6 @@ class CheckpointUtilsJ9 {
|
|||||||
Statement.closeAll();
|
Statement.closeAll();
|
||||||
|
|
||||||
// Close socket
|
// Close socket
|
||||||
Via.getManager().getInjector().uninject();
|
|
||||||
Object serverConnection = TinyProtocol.getServerConnection(Core.getInstance());
|
Object serverConnection = TinyProtocol.getServerConnection(Core.getInstance());
|
||||||
List<?> channels = channelFutures.get(serverConnection);
|
List<?> channels = channelFutures.get(serverConnection);
|
||||||
for(Object future : channels) {
|
for(Object future : channels) {
|
||||||
@@ -140,7 +138,6 @@ class CheckpointUtilsJ9 {
|
|||||||
((ChannelFuture) future).channel().config().setAutoRead(true);
|
((ChannelFuture) future).channel().config().setAutoRead(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Via.getManager().getInjector().inject();
|
|
||||||
|
|
||||||
Bukkit.getPluginManager().callEvent(new CRIUWakeupEvent());
|
Bukkit.getPluginManager().callEvent(new CRIUWakeupEvent());
|
||||||
Core.getInstance().getLogger().log(Level.INFO, "Checkpoint restored");
|
Core.getInstance().getLogger().log(Level.INFO, "Checkpoint restored");
|
||||||
|
|||||||
@@ -100,9 +100,6 @@ public class Core extends JavaPlugin{
|
|||||||
CheckpointUtils.signalHandler();
|
CheckpointUtils.signalHandler();
|
||||||
new AntiNocom();
|
new AntiNocom();
|
||||||
|
|
||||||
if(Core.getVersion() < 17 && Bukkit.getPluginManager().getPlugin("ViaVersion") != null)
|
|
||||||
new PartialChunkFixer();
|
|
||||||
|
|
||||||
if(Core.getVersion() >= 19)
|
if(Core.getVersion() >= 19)
|
||||||
new ServerDataHandler();
|
new ServerDataHandler();
|
||||||
|
|
||||||
|
|||||||
@@ -1,84 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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.core.events;
|
|
||||||
|
|
||||||
import com.comphenix.tinyprotocol.Reflection;
|
|
||||||
import com.comphenix.tinyprotocol.TinyProtocol;
|
|
||||||
import com.viaversion.viaversion.api.Via;
|
|
||||||
import com.viaversion.viaversion.api.ViaAPI;
|
|
||||||
import de.steamwar.core.Core;
|
|
||||||
import de.steamwar.core.CraftbukkitWrapper;
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* TinyProtocol can't translate BlockEntities during 1.16 to 1.17 conversions du to removed partial chunk update support. This class cancels PartialChunkUpdates for this players and sends them a complete chunk instead.
|
|
||||||
* This class can only be loaded on 1.9 to 1.15 with active ViaVersion.
|
|
||||||
**/
|
|
||||||
public class PartialChunkFixer {
|
|
||||||
|
|
||||||
private static final int PROTOCOL1_17 = 755;
|
|
||||||
private static final Class<?> mapChunk = Reflection.getClass("{nms}.PacketPlayOutMapChunk");
|
|
||||||
private static final Reflection.FieldAccessor<Boolean> fullChunkFlag = Reflection.getField(mapChunk, boolean.class, 0);
|
|
||||||
private static final Reflection.FieldAccessor<Integer> chunkX = Reflection.getField(mapChunk, int.class, 0);
|
|
||||||
private static final Reflection.FieldAccessor<Integer> chunkZ = Reflection.getField(mapChunk, int.class, 1);
|
|
||||||
|
|
||||||
private final ViaAPI<Player> via = Via.getAPI();
|
|
||||||
|
|
||||||
private final List<ResendChunk> chunksToResend = new ArrayList<>();
|
|
||||||
|
|
||||||
public PartialChunkFixer() {
|
|
||||||
TinyProtocol.instance.addFilter(mapChunk, this::chunkFilter);
|
|
||||||
Bukkit.getScheduler().runTaskTimer(Core.getInstance(), () -> {
|
|
||||||
synchronized (chunksToResend) {
|
|
||||||
for(ResendChunk chunk : chunksToResend) {
|
|
||||||
CraftbukkitWrapper.impl.sendChunk(chunk.player, chunk.x, chunk.z);
|
|
||||||
}
|
|
||||||
chunksToResend.clear();
|
|
||||||
}
|
|
||||||
}, 1, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
private Object chunkFilter(Player player, Object packet) {
|
|
||||||
if(via.getPlayerVersion(player) >= PROTOCOL1_17 && !fullChunkFlag.get(packet)) {
|
|
||||||
// partial chunk update
|
|
||||||
synchronized (chunksToResend) {
|
|
||||||
chunksToResend.add(new ResendChunk(player, chunkX.get(packet), chunkZ.get(packet)));
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return packet;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static class ResendChunk {
|
|
||||||
private final Player player;
|
|
||||||
private final int x;
|
|
||||||
private final int z;
|
|
||||||
|
|
||||||
private ResendChunk(Player player, int x, int z) {
|
|
||||||
this.player = player;
|
|
||||||
this.x = x;
|
|
||||||
this.z = z;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -4,7 +4,6 @@ author: Lixfel
|
|||||||
api-version: "1.13"
|
api-version: "1.13"
|
||||||
load: STARTUP
|
load: STARTUP
|
||||||
softdepend:
|
softdepend:
|
||||||
- ViaVersion
|
|
||||||
- WorldEdit
|
- WorldEdit
|
||||||
|
|
||||||
main: de.steamwar.core.Core
|
main: de.steamwar.core.Core
|
||||||
|
|||||||
@@ -225,20 +225,16 @@ public class Subserver {
|
|||||||
if (line.contains("Loading libraries, please wait"))
|
if (line.contains("Loading libraries, please wait"))
|
||||||
sendProgress(2);
|
sendProgress(2);
|
||||||
else if (line.contains("Starting Minecraft server on"))
|
else if (line.contains("Starting Minecraft server on"))
|
||||||
sendProgress(4);
|
sendProgress(5);
|
||||||
else if (line.contains("Preparing start region"))
|
else if (line.contains("Preparing start region"))
|
||||||
sendProgress(6);
|
sendProgress(8);
|
||||||
return line.contains("Finished mapping loading");
|
return line.contains("Done (");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!started)
|
if (!started)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
sendProgress(8);
|
|
||||||
|
|
||||||
Thread.sleep(300);
|
|
||||||
|
|
||||||
sendProgress(10);
|
sendProgress(10);
|
||||||
for (Player cachedPlayer : cachedPlayers) {
|
for (Player cachedPlayer : cachedPlayers) {
|
||||||
sendPlayer(cachedPlayer);
|
sendPlayer(cachedPlayer);
|
||||||
|
|||||||
@@ -47,6 +47,8 @@ java {
|
|||||||
dependencies {
|
dependencies {
|
||||||
annotationProcessor(libs.velocityapi)
|
annotationProcessor(libs.velocityapi)
|
||||||
compileOnly(libs.velocity)
|
compileOnly(libs.velocity)
|
||||||
|
compileOnly(libs.viaapi)
|
||||||
|
compileOnly(libs.viavelocity)
|
||||||
|
|
||||||
compileOnly(project(":VelocityCore:Persistent", "default"))
|
compileOnly(project(":VelocityCore:Persistent", "default"))
|
||||||
|
|
||||||
@@ -61,6 +63,5 @@ dependencies {
|
|||||||
}
|
}
|
||||||
|
|
||||||
implementation(libs.msgpack)
|
implementation(libs.msgpack)
|
||||||
|
|
||||||
implementation(libs.apolloprotos)
|
implementation(libs.apolloprotos)
|
||||||
}
|
}
|
||||||
@@ -728,6 +728,9 @@ MOD_ITEM_BACK=§7Back
|
|||||||
INV_PAGE_BACK=§{0}Seite zurück
|
INV_PAGE_BACK=§{0}Seite zurück
|
||||||
INV_PAGE_NEXT=§{0}Seite vor
|
INV_PAGE_NEXT=§{0}Seite vor
|
||||||
|
|
||||||
|
#VersionAnnouncer
|
||||||
|
SERVER_VERSION=§7This server runs on Minecraft version §e{0}
|
||||||
|
|
||||||
#Discord
|
#Discord
|
||||||
DC_UNLINKED=For this action your Discord account has to be linked to your Minecraft account. To link your accounts go onto the SteamWar Discord to the `regeln-infos` Channel and click on `Minecraft Verknüpfen`.
|
DC_UNLINKED=For this action your Discord account has to be linked to your Minecraft account. To link your accounts go onto the SteamWar Discord to the `regeln-infos` Channel and click on `Minecraft Verknüpfen`.
|
||||||
DC_TITLE_SCHEMINFO=Schematic Info
|
DC_TITLE_SCHEMINFO=Schematic Info
|
||||||
|
|||||||
@@ -681,6 +681,9 @@ ADVENT_CALENDAR_OPEN=§7Du hast §e{0}§7 aus dem Adventskalender erhalten!
|
|||||||
INV_PAGE_BACK=§{0}Page back
|
INV_PAGE_BACK=§{0}Page back
|
||||||
INV_PAGE_NEXT=§{0}Next page
|
INV_PAGE_NEXT=§{0}Next page
|
||||||
|
|
||||||
|
#VersionAnnouncer
|
||||||
|
SERVER_VERSION=§7Dieser Server läuft auf Minecraft-Version §e{0}
|
||||||
|
|
||||||
#Discord
|
#Discord
|
||||||
DC_UNLINKED=Für diese Aktion muss dein Minecraftaccount mit deinem Discordaccount verknüpft sein, gehe dazu auf dem SteamWar-Discord in den `regeln-infos` Channel und Klicke auf `Minecraft Verknüpfen`.
|
DC_UNLINKED=Für diese Aktion muss dein Minecraftaccount mit deinem Discordaccount verknüpft sein, gehe dazu auf dem SteamWar-Discord in den `regeln-infos` Channel und Klicke auf `Minecraft Verknüpfen`.
|
||||||
DC_TITLE_SCHEMINFO=Schematicinfo
|
DC_TITLE_SCHEMINFO=Schematicinfo
|
||||||
|
|||||||
@@ -27,10 +27,13 @@ import java.util.Arrays;
|
|||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.function.BiConsumer;
|
import java.util.function.BiConsumer;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
public class GameModeConfig {
|
public class GameModeConfig {
|
||||||
|
|
||||||
|
private static final Pattern terminatingNumber = Pattern.compile("\\D+(\\d+)$");
|
||||||
|
|
||||||
public static <T extends GameModeConfig> void loadAll(Class<T> config, BiConsumer<File, T> consumer) {
|
public static <T extends GameModeConfig> void loadAll(Class<T> config, BiConsumer<File, T> consumer) {
|
||||||
File folder = new File(VelocityCore.get().getDataDirectory().getParent().toFile(), "FightSystem");
|
File folder = new File(VelocityCore.get().getDataDirectory().getParent().toFile(), "FightSystem");
|
||||||
if(!folder.exists())
|
if(!folder.exists())
|
||||||
@@ -51,9 +54,9 @@ public class GameModeConfig {
|
|||||||
@Getter
|
@Getter
|
||||||
public static class Server {
|
public static class Server {
|
||||||
private String Folder;
|
private String Folder;
|
||||||
private String ServerJar;
|
|
||||||
private List<String> ChatNames = Collections.emptyList();
|
private List<String> ChatNames = Collections.emptyList();
|
||||||
private List<String> Maps;
|
private List<String> Maps;
|
||||||
|
private boolean Spigot = false;
|
||||||
private boolean Ranked = false;
|
private boolean Ranked = false;
|
||||||
private boolean Historic = false;
|
private boolean Historic = false;
|
||||||
}
|
}
|
||||||
@@ -66,8 +69,8 @@ public class GameModeConfig {
|
|||||||
private boolean ManualCheck = true;
|
private boolean ManualCheck = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getServerJar() {
|
public ServerVersion getVersion() {
|
||||||
return getServer().getServerJar();
|
return ServerVersion.valueOf((getServer().isSpigot() ? "SPIGOT_" : "PAPER_") + terminatingNumber.matcher(getServer().getFolder()).group(1));
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getFolder() {
|
public String getFolder() {
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ public abstract class Node {
|
|||||||
nodes.forEach(consumer);
|
nodes.forEach(consumer);
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract ProcessBuilder startServer(String serverJar, File directory, String worldDir, String levelName, int port, String xmx, String... dParams);
|
public abstract ProcessBuilder startServer(String serverJar, File directory, String worldDir, String levelName, int port, String... dParams);
|
||||||
|
|
||||||
protected abstract ProcessBuilder prepareExecution(String... command);
|
protected abstract ProcessBuilder prepareExecution(String... command);
|
||||||
protected abstract void calcLoadLimit();
|
protected abstract void calcLoadLimit();
|
||||||
@@ -95,7 +95,7 @@ public abstract class Node {
|
|||||||
return hostname;
|
return hostname;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void constructServerstart(File directory, List<String> cmd, String serverJar, String worldDir, String levelName, int port, String xmx, String... dParams) {
|
protected void constructServerstart(File directory, List<String> cmd, String serverJar, String worldDir, String levelName, int port, String... dParams) {
|
||||||
if (JAVA_8.contains(serverJar))
|
if (JAVA_8.contains(serverJar))
|
||||||
cmd.add("/usr/lib/jvm/java-8-openj9-amd64/bin/java");
|
cmd.add("/usr/lib/jvm/java-8-openj9-amd64/bin/java");
|
||||||
else
|
else
|
||||||
@@ -105,7 +105,7 @@ public abstract class Node {
|
|||||||
cmd.add("-D" + param);
|
cmd.add("-D" + param);
|
||||||
}
|
}
|
||||||
cmd.add("-Xshareclasses:nonfatal,name=" + directory.getName());
|
cmd.add("-Xshareclasses:nonfatal,name=" + directory.getName());
|
||||||
cmd.add("-Xmx" + xmx);
|
cmd.add("-Xmx768M");
|
||||||
cmd.addAll(OPENJ9_ARGS);
|
cmd.addAll(OPENJ9_ARGS);
|
||||||
if (!JAVA_8.contains(serverJar)) {
|
if (!JAVA_8.contains(serverJar)) {
|
||||||
cmd.add("--add-opens");
|
cmd.add("--add-opens");
|
||||||
@@ -142,9 +142,9 @@ public abstract class Node {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ProcessBuilder startServer(String serverJar, File directory, String worldDir, String levelName, int port, String xmx, String... dParams) {
|
public ProcessBuilder startServer(String serverJar, File directory, String worldDir, String levelName, int port, String... dParams) {
|
||||||
List<String> cmd = new ArrayList<>();
|
List<String> cmd = new ArrayList<>();
|
||||||
constructServerstart(directory, cmd, serverJar, worldDir, levelName, port, xmx, dParams);
|
constructServerstart(directory, cmd, serverJar, worldDir, levelName, port, dParams);
|
||||||
ProcessBuilder builder = new ProcessBuilder(cmd);
|
ProcessBuilder builder = new ProcessBuilder(cmd);
|
||||||
builder.directory(directory);
|
builder.directory(directory);
|
||||||
return builder;
|
return builder;
|
||||||
@@ -174,7 +174,7 @@ public abstract class Node {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ProcessBuilder startServer(String serverJar, File directory, String worldDir, String levelName, int port, String xmx, String... dParams) {
|
public ProcessBuilder startServer(String serverJar, File directory, String worldDir, String levelName, int port, String... dParams) {
|
||||||
List<String> cmd = new ArrayList<>();
|
List<String> cmd = new ArrayList<>();
|
||||||
cmd.add("ssh");
|
cmd.add("ssh");
|
||||||
cmd.add("-L");
|
cmd.add("-L");
|
||||||
@@ -183,7 +183,7 @@ public abstract class Node {
|
|||||||
cmd.add("cd");
|
cmd.add("cd");
|
||||||
cmd.add(directory.getPath());
|
cmd.add(directory.getPath());
|
||||||
cmd.add(";");
|
cmd.add(";");
|
||||||
constructServerstart(directory, cmd, serverJar, worldDir, levelName, port, xmx, dParams);
|
constructServerstart(directory, cmd, serverJar, worldDir, levelName, port, dParams);
|
||||||
return new ProcessBuilder(cmd);
|
return new ProcessBuilder(cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -20,6 +20,8 @@
|
|||||||
package de.steamwar.velocitycore;
|
package de.steamwar.velocitycore;
|
||||||
|
|
||||||
import com.velocitypowered.api.proxy.Player;
|
import com.velocitypowered.api.proxy.Player;
|
||||||
|
import com.viaversion.viaversion.api.Via;
|
||||||
|
import com.viaversion.viaversion.velocity.platform.VelocityViaConfig;
|
||||||
import de.steamwar.messages.Chatter;
|
import de.steamwar.messages.Chatter;
|
||||||
import de.steamwar.persistent.Arenaserver;
|
import de.steamwar.persistent.Arenaserver;
|
||||||
import de.steamwar.persistent.Bauserver;
|
import de.steamwar.persistent.Bauserver;
|
||||||
@@ -56,8 +58,7 @@ public class ServerStarter {
|
|||||||
private String worldDir = null;
|
private String worldDir = null;
|
||||||
|
|
||||||
private Node node = null;
|
private Node node = null;
|
||||||
private String serverJar = "spigot-1.15.2.jar";
|
private ServerVersion version = ServerVersion.PAPER_20;
|
||||||
private String xmx = "768M";
|
|
||||||
private Portrange portrange = BAU_PORTS;
|
private Portrange portrange = BAU_PORTS;
|
||||||
private Function<Integer, String> serverNameProvider = port -> node.getName() + port;
|
private Function<Integer, String> serverNameProvider = port -> node.getName() + port;
|
||||||
private BooleanSupplier startCondition = () -> true;
|
private BooleanSupplier startCondition = () -> true;
|
||||||
@@ -78,7 +79,7 @@ public class ServerStarter {
|
|||||||
public ServerStarter arena(ArenaMode mode, String map) {
|
public ServerStarter arena(ArenaMode mode, String map) {
|
||||||
portrange = ARENA_PORTS;
|
portrange = ARENA_PORTS;
|
||||||
serverNameProvider = port -> mode.getGameName() + (port - portrange.start);
|
serverNameProvider = port -> mode.getGameName() + (port - portrange.start);
|
||||||
serverJar = mode.getServerJar();
|
version = mode.getVersion();
|
||||||
allowMerge = true;
|
allowMerge = true;
|
||||||
fightMap = map;
|
fightMap = map;
|
||||||
gameMode = mode.getInternalName();
|
gameMode = mode.getInternalName();
|
||||||
@@ -145,8 +146,8 @@ public class ServerStarter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public ServerStarter build(ServerVersion version, UUID owner) {
|
public ServerStarter build(ServerVersion version, UUID owner) {
|
||||||
|
this.version = version;
|
||||||
directory = version.getServerDirectory("Bau");
|
directory = version.getServerDirectory("Bau");
|
||||||
serverJar = version.getServerJar();
|
|
||||||
worldDir = version.getWorldFolder(WORLDS_BASE_PATH);
|
worldDir = version.getWorldFolder(WORLDS_BASE_PATH);
|
||||||
worldName = version != ServerVersion.SPIGOT_12 ? String.valueOf(SteamwarUser.get(owner).getId()) : owner.toString();
|
worldName = version != ServerVersion.SPIGOT_12 ? String.valueOf(SteamwarUser.get(owner).getId()) : owner.toString();
|
||||||
checkpoint = true;
|
checkpoint = true;
|
||||||
@@ -219,7 +220,7 @@ public class ServerStarter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public ServerStarter builder(ServerVersion version, String map, File generator) {
|
public ServerStarter builder(ServerVersion version, String map, File generator) {
|
||||||
serverJar = version.getServerJar();
|
this.version = version;
|
||||||
directory = version.getServerDirectory("Builder");
|
directory = version.getServerDirectory("Builder");
|
||||||
worldDir = version.getWorldFolder(BUILDER_BASE_PATH);
|
worldDir = version.getWorldFolder(BUILDER_BASE_PATH);
|
||||||
worldName = map;
|
worldName = map;
|
||||||
@@ -294,6 +295,7 @@ public class ServerStarter {
|
|||||||
if(checkpoint)
|
if(checkpoint)
|
||||||
arguments.put("checkpoint", checkpointDir.getPath());
|
arguments.put("checkpoint", checkpointDir.getPath());
|
||||||
|
|
||||||
|
((VelocityViaConfig) Via.getConfig()).getVelocityServerProtocols().put(serverName, version.getProtocolVersion().getProtocol());
|
||||||
if(checkpoint && checkpointDir.exists()) {
|
if(checkpoint && checkpointDir.exists()) {
|
||||||
try(DataOutputStream out = new DataOutputStream(Files.newOutputStream(new File(checkpointDir, "port").toPath()))) {
|
try(DataOutputStream out = new DataOutputStream(Files.newOutputStream(new File(checkpointDir, "port").toPath()))) {
|
||||||
out.writeInt(port);
|
out.writeInt(port);
|
||||||
@@ -313,7 +315,7 @@ public class ServerStarter {
|
|||||||
|
|
||||||
private void regularStart(String serverName, int port) {
|
private void regularStart(String serverName, int port) {
|
||||||
postStart(constructor.construct(serverName, port, node.startServer(
|
postStart(constructor.construct(serverName, port, node.startServer(
|
||||||
serverJar, directory, worldDir, worldName, port, xmx, arguments.entrySet().stream().map(entry -> entry.getKey() + "=" + entry.getValue()).toArray(String[]::new)
|
version.getServerJar(), directory, worldDir, worldName, port, arguments.entrySet().stream().map(entry -> entry.getKey() + "=" + entry.getValue()).toArray(String[]::new)
|
||||||
), worldCleanup, null));
|
), worldCleanup, null));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -19,6 +19,8 @@
|
|||||||
|
|
||||||
package de.steamwar.velocitycore;
|
package de.steamwar.velocitycore;
|
||||||
|
|
||||||
|
import com.velocitypowered.api.network.ProtocolVersion;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
@@ -27,12 +29,23 @@ import java.util.Map;
|
|||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
|
@AllArgsConstructor
|
||||||
public enum ServerVersion {
|
public enum ServerVersion {
|
||||||
SPIGOT_12("spigot-1.12.2.jar", 12),
|
SPIGOT_8("spigot-1.8.8.jar", 8, ProtocolVersion.MINECRAFT_1_8),
|
||||||
SPIGOT_15("spigot-1.15.2.jar", 15),
|
SPIGOT_9("spigot-1.9.4.jar", 9, ProtocolVersion.MINECRAFT_1_9),
|
||||||
PAPER_19("paper-1.19.3.jar", 19),
|
SPIGOT_10("spigot-1.10.2.jar", 10, ProtocolVersion.MINECRAFT_1_10),
|
||||||
PAPER_20("paper-1.20.1.jar", 20),
|
SPIGOT_12("spigot-1.12.2.jar", 12, ProtocolVersion.MINECRAFT_1_12_2),
|
||||||
PAPER_21("paper-1.21.jar", 21);
|
SPIGOT_14("spigot-1.14.4.jar", 14, ProtocolVersion.MINECRAFT_1_14_4),
|
||||||
|
SPIGOT_15("spigot-1.15.2.jar", 15, ProtocolVersion.MINECRAFT_1_15_2),
|
||||||
|
|
||||||
|
PAPER_8("paper-1.8.8.jar", 8, ProtocolVersion.MINECRAFT_1_8),
|
||||||
|
PAPER_10("paper-1.10.2.jar", 10, ProtocolVersion.MINECRAFT_1_10),
|
||||||
|
PAPER_12("paper-1.12.2.jar", 12, ProtocolVersion.MINECRAFT_1_12_2),
|
||||||
|
PAPER_15("paper-1.15.2.jar", 15, ProtocolVersion.MINECRAFT_1_15_2),
|
||||||
|
PAPER_18("paper-1.18.2.jar", 15, ProtocolVersion.MINECRAFT_1_18_2),
|
||||||
|
PAPER_19("paper-1.19.3.jar", 19, ProtocolVersion.MINECRAFT_1_19_3),
|
||||||
|
PAPER_20("paper-1.20.1.jar", 20, ProtocolVersion.MINECRAFT_1_20),
|
||||||
|
PAPER_21("paper-1.21.jar", 21, ProtocolVersion.MINECRAFT_1_21_2);
|
||||||
|
|
||||||
private static final Map<String, ServerVersion> chatMap = new HashMap<>();
|
private static final Map<String, ServerVersion> chatMap = new HashMap<>();
|
||||||
|
|
||||||
@@ -76,11 +89,7 @@ public enum ServerVersion {
|
|||||||
|
|
||||||
private final String serverJar;
|
private final String serverJar;
|
||||||
private final int versionSuffix;
|
private final int versionSuffix;
|
||||||
|
private final ProtocolVersion protocolVersion;
|
||||||
ServerVersion(String serverJar, int versionSuffix) {
|
|
||||||
this.serverJar = serverJar;
|
|
||||||
this.versionSuffix = versionSuffix;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getWorldFolder(String base) {
|
public String getWorldFolder(String base) {
|
||||||
return base + versionSuffix + "/";
|
return base + versionSuffix + "/";
|
||||||
|
|||||||
@@ -152,6 +152,7 @@ public class VelocityCore implements ReloadablePlugin {
|
|||||||
new BanListener();
|
new BanListener();
|
||||||
new CheckListener();
|
new CheckListener();
|
||||||
new IPSanitizer();
|
new IPSanitizer();
|
||||||
|
new VersionAnnouncer();
|
||||||
|
|
||||||
local = new Node.LocalNode();
|
local = new Node.LocalNode();
|
||||||
if(MAIN_SERVER) {
|
if(MAIN_SERVER) {
|
||||||
|
|||||||
@@ -0,0 +1,47 @@
|
|||||||
|
/*
|
||||||
|
* 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.velocitycore.listeners;
|
||||||
|
|
||||||
|
import com.velocitypowered.api.event.Subscribe;
|
||||||
|
import com.velocitypowered.api.event.player.ServerConnectedEvent;
|
||||||
|
import com.velocitypowered.api.network.ProtocolVersion;
|
||||||
|
import com.velocitypowered.api.proxy.Player;
|
||||||
|
import com.velocitypowered.api.proxy.server.ServerInfo;
|
||||||
|
import com.viaversion.viaversion.api.Via;
|
||||||
|
import com.viaversion.viaversion.velocity.platform.VelocityViaConfig;
|
||||||
|
import de.steamwar.messages.Chatter;
|
||||||
|
import de.steamwar.persistent.Subserver;
|
||||||
|
|
||||||
|
public class VersionAnnouncer extends BasicListener {
|
||||||
|
|
||||||
|
@Subscribe
|
||||||
|
public void postConnect(ServerConnectedEvent e) {
|
||||||
|
ServerInfo server = e.getServer().getServerInfo();
|
||||||
|
if(!Subserver.isBuild(Subserver.getSubserver(server)))
|
||||||
|
return;
|
||||||
|
|
||||||
|
Player player = e.getPlayer();
|
||||||
|
int serverVersion = ((VelocityViaConfig) Via.getConfig()).getVelocityServerProtocols().get(server.getName());
|
||||||
|
if(Via.getAPI().getPlayerVersion(player) == serverVersion)
|
||||||
|
return;
|
||||||
|
|
||||||
|
player.sendActionBar(Chatter.of(player).parse("SERVER_VERSION", ProtocolVersion.getProtocolVersion(serverVersion).getMostRecentSupportedVersion()));
|
||||||
|
}
|
||||||
|
}
|
||||||
+2
-1
@@ -116,7 +116,6 @@ dependencyResolutionManagement {
|
|||||||
library("authlib", "com.mojang:authlib:1.5.25")
|
library("authlib", "com.mojang:authlib:1.5.25")
|
||||||
library("datafixer", "com.mojang:datafixerupper:4.0.26")
|
library("datafixer", "com.mojang:datafixerupper:4.0.26")
|
||||||
library("brigadier", "com.mojang:brigadier:1.0.18")
|
library("brigadier", "com.mojang:brigadier:1.0.18")
|
||||||
library("viaapi", "com.viaversion:viaversion-api:4.3.1")
|
|
||||||
library("anvilgui", "net.wesjd:anvilgui:1.10.3-SNAPSHOT")
|
library("anvilgui", "net.wesjd:anvilgui:1.10.3-SNAPSHOT")
|
||||||
|
|
||||||
library("nms8", "de.steamwar:spigot:1.8")
|
library("nms8", "de.steamwar:spigot:1.8")
|
||||||
@@ -138,6 +137,8 @@ dependencyResolutionManagement {
|
|||||||
|
|
||||||
library("velocity", "de.steamwar:velocity:RELEASE")
|
library("velocity", "de.steamwar:velocity:RELEASE")
|
||||||
library("velocityapi", "com.velocitypowered:velocity-api:3.3.0-SNAPSHOT")
|
library("velocityapi", "com.velocitypowered:velocity-api:3.3.0-SNAPSHOT")
|
||||||
|
library("viaapi", "com.viaversion:viaversion-api:4.3.1")
|
||||||
|
library("viavelocity", "com.viaversion:viaversion-velocity:4.3.1")
|
||||||
library("jda", "net.dv8tion:JDA:5.2.0")
|
library("jda", "net.dv8tion:JDA:5.2.0")
|
||||||
library("msgpack", "org.msgpack:msgpack-core:0.9.8")
|
library("msgpack", "org.msgpack:msgpack-core:0.9.8")
|
||||||
library("apolloprotos", "com.lunarclient:apollo-protos:1.0-SNAPSHOT")
|
library("apolloprotos", "com.lunarclient:apollo-protos:1.0-SNAPSHOT")
|
||||||
|
|||||||
Reference in New Issue
Block a user