mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-01 05:47:45 +01:00
Implement methods to convert between Component and Brigadier's Message
This commit is contained in:
parent
472880fdde
commit
b9cab64e46
@ -148,7 +148,7 @@
|
|||||||
DedicatedServer.LOGGER.info("Starting minecraft server version {}", SharedConstants.getCurrentVersion().getName());
|
DedicatedServer.LOGGER.info("Starting minecraft server version {}", SharedConstants.getCurrentVersion().getName());
|
||||||
if (Runtime.getRuntime().maxMemory() / 1024L / 1024L < 512L) {
|
if (Runtime.getRuntime().maxMemory() / 1024L / 1024L < 512L) {
|
||||||
DedicatedServer.LOGGER.warn("To start the server with more ram, launch it as \"java -Xmx1024M -Xms1024M -jar minecraft_server.jar\"");
|
DedicatedServer.LOGGER.warn("To start the server with more ram, launch it as \"java -Xmx1024M -Xms1024M -jar minecraft_server.jar\"");
|
||||||
@@ -126,13 +203,34 @@
|
@@ -126,13 +203,35 @@
|
||||||
this.setPreventProxyConnections(dedicatedserverproperties.preventProxyConnections);
|
this.setPreventProxyConnections(dedicatedserverproperties.preventProxyConnections);
|
||||||
this.setLocalIp(dedicatedserverproperties.serverIp);
|
this.setLocalIp(dedicatedserverproperties.serverIp);
|
||||||
}
|
}
|
||||||
@ -173,6 +173,7 @@
|
|||||||
+ io.papermc.paper.command.PaperCommands.registerCommands(this); // Paper - setup /paper command
|
+ io.papermc.paper.command.PaperCommands.registerCommands(this); // Paper - setup /paper command
|
||||||
+ com.destroystokyo.paper.Metrics.PaperMetrics.startMetrics(); // Paper - start metrics
|
+ com.destroystokyo.paper.Metrics.PaperMetrics.startMetrics(); // Paper - start metrics
|
||||||
+ com.destroystokyo.paper.VersionHistoryManager.INSTANCE.getClass(); // Paper - load version history now
|
+ com.destroystokyo.paper.VersionHistoryManager.INSTANCE.getClass(); // Paper - load version history now
|
||||||
|
+ io.papermc.paper.brigadier.PaperBrigadierProviderImpl.INSTANCE.getClass(); // Paper - init PaperBrigadierProvider
|
||||||
|
|
||||||
this.setPvpAllowed(dedicatedserverproperties.pvp);
|
this.setPvpAllowed(dedicatedserverproperties.pvp);
|
||||||
this.setFlightAllowed(dedicatedserverproperties.allowFlight);
|
this.setFlightAllowed(dedicatedserverproperties.allowFlight);
|
||||||
@ -184,17 +185,16 @@
|
|||||||
DedicatedServer.LOGGER.info("Default game type: {}", dedicatedserverproperties.gamemode);
|
DedicatedServer.LOGGER.info("Default game type: {}", dedicatedserverproperties.gamemode);
|
||||||
InetAddress inetaddress = null;
|
InetAddress inetaddress = null;
|
||||||
|
|
||||||
@@ -155,22 +253,32 @@
|
@@ -156,21 +255,31 @@
|
||||||
DedicatedServer.LOGGER.warn("Perhaps a server is already running on that port?");
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
+
|
|
||||||
+ // CraftBukkit start
|
+ // CraftBukkit start
|
||||||
+ // this.setPlayerList(new DedicatedPlayerList(this, this.registries(), this.playerDataStorage)); // Spigot - moved up
|
+ // this.setPlayerList(new DedicatedPlayerList(this, this.registries(), this.playerDataStorage)); // Spigot - moved up
|
||||||
+ this.server.loadPlugins();
|
+ this.server.loadPlugins();
|
||||||
+ this.server.enablePlugins(org.bukkit.plugin.PluginLoadOrder.STARTUP);
|
+ this.server.enablePlugins(org.bukkit.plugin.PluginLoadOrder.STARTUP);
|
||||||
+ // CraftBukkit end
|
+ // CraftBukkit end
|
||||||
|
+
|
||||||
if (!this.usesAuthentication()) {
|
if (!this.usesAuthentication()) {
|
||||||
DedicatedServer.LOGGER.warn("**** SERVER IS RUNNING IN OFFLINE/INSECURE MODE!");
|
DedicatedServer.LOGGER.warn("**** SERVER IS RUNNING IN OFFLINE/INSECURE MODE!");
|
||||||
DedicatedServer.LOGGER.warn("The server will make no attempt to authenticate usernames. Beware.");
|
DedicatedServer.LOGGER.warn("The server will make no attempt to authenticate usernames. Beware.");
|
||||||
@ -222,7 +222,7 @@
|
|||||||
this.debugSampleSubscriptionTracker = new DebugSampleSubscriptionTracker(this.getPlayerList());
|
this.debugSampleSubscriptionTracker = new DebugSampleSubscriptionTracker(this.getPlayerList());
|
||||||
this.tickTimeLogger = new RemoteSampleLogger(TpsDebugDimensions.values().length, this.debugSampleSubscriptionTracker, RemoteDebugSampleType.TICK_TIME);
|
this.tickTimeLogger = new RemoteSampleLogger(TpsDebugDimensions.values().length, this.debugSampleSubscriptionTracker, RemoteDebugSampleType.TICK_TIME);
|
||||||
long i = Util.getNanos();
|
long i = Util.getNanos();
|
||||||
@@ -178,13 +286,13 @@
|
@@ -178,13 +287,13 @@
|
||||||
SkullBlockEntity.setup(this.services, this);
|
SkullBlockEntity.setup(this.services, this);
|
||||||
GameProfileCache.setUsesAuthentication(this.usesAuthentication());
|
GameProfileCache.setUsesAuthentication(this.usesAuthentication());
|
||||||
DedicatedServer.LOGGER.info("Preparing level \"{}\"", this.getLevelIdName());
|
DedicatedServer.LOGGER.info("Preparing level \"{}\"", this.getLevelIdName());
|
||||||
@ -238,7 +238,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (dedicatedserverproperties.enableQuery) {
|
if (dedicatedserverproperties.enableQuery) {
|
||||||
@@ -197,7 +305,7 @@
|
@@ -197,7 +306,7 @@
|
||||||
this.rconThread = RconThread.create(this);
|
this.rconThread = RconThread.create(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -247,7 +247,7 @@
|
|||||||
Thread thread1 = new Thread(new ServerWatchdog(this));
|
Thread thread1 = new Thread(new ServerWatchdog(this));
|
||||||
|
|
||||||
thread1.setUncaughtExceptionHandler(new DefaultUncaughtExceptionHandlerWithName(DedicatedServer.LOGGER));
|
thread1.setUncaughtExceptionHandler(new DefaultUncaughtExceptionHandlerWithName(DedicatedServer.LOGGER));
|
||||||
@@ -215,6 +323,12 @@
|
@@ -215,6 +324,12 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -260,7 +260,7 @@
|
|||||||
@Override
|
@Override
|
||||||
public boolean isSpawningMonsters() {
|
public boolean isSpawningMonsters() {
|
||||||
return this.settings.getProperties().spawnMonsters && super.isSpawningMonsters();
|
return this.settings.getProperties().spawnMonsters && super.isSpawningMonsters();
|
||||||
@@ -227,7 +341,7 @@
|
@@ -227,7 +342,7 @@
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void forceDifficulty() {
|
public void forceDifficulty() {
|
||||||
@ -269,7 +269,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -286,13 +400,14 @@
|
@@ -286,13 +401,14 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.rconThread != null) {
|
if (this.rconThread != null) {
|
||||||
@ -286,7 +286,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -302,19 +417,29 @@
|
@@ -302,19 +418,29 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -322,7 +322,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -383,7 +508,7 @@
|
@@ -383,7 +509,7 @@
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isUnderSpawnProtection(ServerLevel world, BlockPos pos, Player player) {
|
public boolean isUnderSpawnProtection(ServerLevel world, BlockPos pos, Player player) {
|
||||||
@ -331,7 +331,7 @@
|
|||||||
return false;
|
return false;
|
||||||
} else if (this.getPlayerList().getOps().isEmpty()) {
|
} else if (this.getPlayerList().getOps().isEmpty()) {
|
||||||
return false;
|
return false;
|
||||||
@@ -453,7 +578,11 @@
|
@@ -453,7 +579,11 @@
|
||||||
public boolean enforceSecureProfile() {
|
public boolean enforceSecureProfile() {
|
||||||
DedicatedServerProperties dedicatedserverproperties = this.getProperties();
|
DedicatedServerProperties dedicatedserverproperties = this.getProperties();
|
||||||
|
|
||||||
@ -344,7 +344,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -541,16 +670,52 @@
|
@@ -541,16 +671,52 @@
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getPluginNames() {
|
public String getPluginNames() {
|
||||||
@ -401,7 +401,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void storeUsingWhiteList(boolean useWhitelist) {
|
public void storeUsingWhiteList(boolean useWhitelist) {
|
||||||
@@ -660,4 +825,15 @@
|
@@ -660,4 +826,15 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,30 @@
|
|||||||
|
package io.papermc.paper.brigadier;
|
||||||
|
|
||||||
|
import com.mojang.brigadier.Message;
|
||||||
|
import io.papermc.paper.adventure.PaperAdventure;
|
||||||
|
import net.kyori.adventure.text.Component;
|
||||||
|
import net.kyori.adventure.text.ComponentLike;
|
||||||
|
import net.minecraft.network.chat.ComponentUtils;
|
||||||
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
|
||||||
|
import static java.util.Objects.requireNonNull;
|
||||||
|
|
||||||
|
public enum PaperBrigadierProviderImpl implements PaperBrigadierProvider {
|
||||||
|
INSTANCE;
|
||||||
|
|
||||||
|
PaperBrigadierProviderImpl() {
|
||||||
|
PaperBrigadierProvider.initialize(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @NonNull Message message(final @NonNull ComponentLike componentLike) {
|
||||||
|
requireNonNull(componentLike, "componentLike");
|
||||||
|
return PaperAdventure.asVanilla(componentLike.asComponent());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @NonNull Component componentFromMessage(final @NonNull Message message) {
|
||||||
|
requireNonNull(message, "message");
|
||||||
|
return PaperAdventure.asAdventure(ComponentUtils.fromMessage(message));
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user