mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-29 12:27:59 +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());
|
||||
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\"");
|
||||
@@ -126,13 +203,34 @@
|
||||
@@ -126,13 +203,35 @@
|
||||
this.setPreventProxyConnections(dedicatedserverproperties.preventProxyConnections);
|
||||
this.setLocalIp(dedicatedserverproperties.serverIp);
|
||||
}
|
||||
@ -173,6 +173,7 @@
|
||||
+ io.papermc.paper.command.PaperCommands.registerCommands(this); // Paper - setup /paper command
|
||||
+ com.destroystokyo.paper.Metrics.PaperMetrics.startMetrics(); // Paper - start metrics
|
||||
+ 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.setFlightAllowed(dedicatedserverproperties.allowFlight);
|
||||
@ -184,17 +185,16 @@
|
||||
DedicatedServer.LOGGER.info("Default game type: {}", dedicatedserverproperties.gamemode);
|
||||
InetAddress inetaddress = null;
|
||||
|
||||
@@ -155,22 +253,32 @@
|
||||
DedicatedServer.LOGGER.warn("Perhaps a server is already running on that port?");
|
||||
@@ -156,21 +255,31 @@
|
||||
return false;
|
||||
}
|
||||
+
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ // this.setPlayerList(new DedicatedPlayerList(this, this.registries(), this.playerDataStorage)); // Spigot - moved up
|
||||
+ this.server.loadPlugins();
|
||||
+ this.server.enablePlugins(org.bukkit.plugin.PluginLoadOrder.STARTUP);
|
||||
+ // CraftBukkit end
|
||||
|
||||
+
|
||||
if (!this.usesAuthentication()) {
|
||||
DedicatedServer.LOGGER.warn("**** SERVER IS RUNNING IN OFFLINE/INSECURE MODE!");
|
||||
DedicatedServer.LOGGER.warn("The server will make no attempt to authenticate usernames. Beware.");
|
||||
@ -222,7 +222,7 @@
|
||||
this.debugSampleSubscriptionTracker = new DebugSampleSubscriptionTracker(this.getPlayerList());
|
||||
this.tickTimeLogger = new RemoteSampleLogger(TpsDebugDimensions.values().length, this.debugSampleSubscriptionTracker, RemoteDebugSampleType.TICK_TIME);
|
||||
long i = Util.getNanos();
|
||||
@@ -178,13 +286,13 @@
|
||||
@@ -178,13 +287,13 @@
|
||||
SkullBlockEntity.setup(this.services, this);
|
||||
GameProfileCache.setUsesAuthentication(this.usesAuthentication());
|
||||
DedicatedServer.LOGGER.info("Preparing level \"{}\"", this.getLevelIdName());
|
||||
@ -238,7 +238,7 @@
|
||||
}
|
||||
|
||||
if (dedicatedserverproperties.enableQuery) {
|
||||
@@ -197,7 +305,7 @@
|
||||
@@ -197,7 +306,7 @@
|
||||
this.rconThread = RconThread.create(this);
|
||||
}
|
||||
|
||||
@ -247,7 +247,7 @@
|
||||
Thread thread1 = new Thread(new ServerWatchdog(this));
|
||||
|
||||
thread1.setUncaughtExceptionHandler(new DefaultUncaughtExceptionHandlerWithName(DedicatedServer.LOGGER));
|
||||
@@ -215,6 +323,12 @@
|
||||
@@ -215,6 +324,12 @@
|
||||
}
|
||||
}
|
||||
|
||||
@ -260,7 +260,7 @@
|
||||
@Override
|
||||
public boolean isSpawningMonsters() {
|
||||
return this.settings.getProperties().spawnMonsters && super.isSpawningMonsters();
|
||||
@@ -227,7 +341,7 @@
|
||||
@@ -227,7 +342,7 @@
|
||||
|
||||
@Override
|
||||
public void forceDifficulty() {
|
||||
@ -269,7 +269,7 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -286,13 +400,14 @@
|
||||
@@ -286,13 +401,14 @@
|
||||
}
|
||||
|
||||
if (this.rconThread != null) {
|
||||
@ -286,7 +286,7 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -302,19 +417,29 @@
|
||||
@@ -302,19 +418,29 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -322,7 +322,7 @@
|
||||
}
|
||||
|
||||
}
|
||||
@@ -383,7 +508,7 @@
|
||||
@@ -383,7 +509,7 @@
|
||||
|
||||
@Override
|
||||
public boolean isUnderSpawnProtection(ServerLevel world, BlockPos pos, Player player) {
|
||||
@ -331,7 +331,7 @@
|
||||
return false;
|
||||
} else if (this.getPlayerList().getOps().isEmpty()) {
|
||||
return false;
|
||||
@@ -453,7 +578,11 @@
|
||||
@@ -453,7 +579,11 @@
|
||||
public boolean enforceSecureProfile() {
|
||||
DedicatedServerProperties dedicatedserverproperties = this.getProperties();
|
||||
|
||||
@ -344,7 +344,7 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -541,16 +670,52 @@
|
||||
@@ -541,16 +671,52 @@
|
||||
|
||||
@Override
|
||||
public String getPluginNames() {
|
||||
@ -401,7 +401,7 @@
|
||||
}
|
||||
|
||||
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