Remap CraftBukkit to Mojang+Yarn Mappings
By: Initial Source <noreply+automated@papermc.io>
This commit is contained in:
@@ -1,7 +1,12 @@
|
||||
--- a/net/minecraft/server/dedicated/DedicatedServer.java
|
||||
+++ b/net/minecraft/server/dedicated/DedicatedServer.java
|
||||
@@ -59,6 +59,18 @@
|
||||
import net.minecraft.world.level.storage.Convertable;
|
||||
@@ -54,11 +54,22 @@
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.level.GameRules;
|
||||
import net.minecraft.world.level.GameType;
|
||||
-import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.entity.SkullBlockEntity;
|
||||
import net.minecraft.world.level.storage.LevelStorageSource;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
+// CraftBukkit start
|
||||
@@ -16,35 +21,39 @@
|
||||
+import org.bukkit.event.server.RemoteServerCommandEvent;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public class DedicatedServer extends MinecraftServer implements IMinecraftServer {
|
||||
public class DedicatedServer extends MinecraftServer implements ServerInterface {
|
||||
|
||||
static final Logger LOGGER = LogUtils.getLogger();
|
||||
@@ -67,7 +79,7 @@
|
||||
private final List<ServerCommand> consoleInput = Collections.synchronizedList(Lists.newArrayList());
|
||||
@@ -67,7 +78,7 @@
|
||||
private final List<ConsoleInput> consoleInput = Collections.synchronizedList(Lists.newArrayList());
|
||||
@Nullable
|
||||
private RemoteStatusListener queryThreadGs4;
|
||||
- private final RemoteControlCommandListener rconConsoleSource;
|
||||
private QueryThreadGs4 queryThreadGs4;
|
||||
- private final RconConsoleSource rconConsoleSource;
|
||||
+ // private final RemoteControlCommandListener rconConsoleSource; // CraftBukkit - remove field
|
||||
@Nullable
|
||||
private RemoteControlListener rconThread;
|
||||
private RconThread rconThread;
|
||||
public DedicatedServerSettings settings;
|
||||
@@ -81,10 +93,12 @@
|
||||
@@ -81,25 +92,58 @@
|
||||
private DebugSampleSubscriptionTracker debugSampleSubscriptionTracker;
|
||||
public ServerLinks serverLinks;
|
||||
|
||||
- public DedicatedServer(Thread thread, Convertable.ConversionSession convertable_conversionsession, ResourcePackRepository resourcepackrepository, WorldStem worldstem, DedicatedServerSettings dedicatedserversettings, DataFixer datafixer, Services services, WorldLoadListenerFactory worldloadlistenerfactory) {
|
||||
- super(thread, convertable_conversionsession, resourcepackrepository, worldstem, Proxy.NO_PROXY, datafixer, services, worldloadlistenerfactory);
|
||||
- public DedicatedServer(Thread serverThread, LevelStorageSource.LevelStorageAccess session, PackRepository dataPackManager, WorldStem saveLoader, DedicatedServerSettings propertiesLoader, DataFixer dataFixer, Services apiServices, ChunkProgressListenerFactory worldGenerationProgressListenerFactory) {
|
||||
- super(serverThread, session, dataPackManager, saveLoader, Proxy.NO_PROXY, dataFixer, apiServices, worldGenerationProgressListenerFactory);
|
||||
- this.settings = propertiesLoader;
|
||||
- this.rconConsoleSource = new RconConsoleSource(this);
|
||||
- this.serverTextFilter = ServerTextFilter.createFromConfig(propertiesLoader.getProperties());
|
||||
- this.serverLinks = DedicatedServer.createServerLinks(propertiesLoader);
|
||||
+ // CraftBukkit start - Signature changed
|
||||
+ public DedicatedServer(joptsimple.OptionSet options, WorldLoader.a worldLoader, Thread thread, Convertable.ConversionSession convertable_conversionsession, ResourcePackRepository resourcepackrepository, WorldStem worldstem, DedicatedServerSettings dedicatedserversettings, DataFixer datafixer, Services services, WorldLoadListenerFactory worldloadlistenerfactory) {
|
||||
+ public DedicatedServer(joptsimple.OptionSet options, WorldLoader.DataLoadContext worldLoader, Thread thread, LevelStorageSource.LevelStorageAccess convertable_conversionsession, PackRepository resourcepackrepository, WorldStem worldstem, DedicatedServerSettings dedicatedserversettings, DataFixer datafixer, Services services, ChunkProgressListenerFactory worldloadlistenerfactory) {
|
||||
+ super(options, worldLoader, thread, convertable_conversionsession, resourcepackrepository, worldstem, Proxy.NO_PROXY, datafixer, services, worldloadlistenerfactory);
|
||||
+ // CraftBukkit end
|
||||
this.settings = dedicatedserversettings;
|
||||
- this.rconConsoleSource = new RemoteControlCommandListener(this);
|
||||
+ this.settings = dedicatedserversettings;
|
||||
+ // this.rconConsoleSource = new RemoteControlCommandListener(this); // CraftBukkit - remove field
|
||||
this.serverTextFilter = ServerTextFilter.createFromConfig(dedicatedserversettings.getProperties());
|
||||
this.serverLinks = createServerLinks(dedicatedserversettings);
|
||||
+ this.serverTextFilter = ServerTextFilter.createFromConfig(dedicatedserversettings.getProperties());
|
||||
+ this.serverLinks = DedicatedServer.createServerLinks(dedicatedserversettings);
|
||||
}
|
||||
@@ -93,13 +107,44 @@
|
||||
|
||||
@Override
|
||||
public boolean initServer() throws IOException {
|
||||
Thread thread = new Thread("Server console handler") {
|
||||
public void run() {
|
||||
@@ -53,8 +62,8 @@
|
||||
+ if (!org.bukkit.craftbukkit.Main.useConsole) {
|
||||
+ return;
|
||||
+ }
|
||||
+ jline.console.ConsoleReader bufferedreader = reader;
|
||||
+
|
||||
+ jline.console.ConsoleReader bufferedreader = DedicatedServer.this.reader;
|
||||
|
||||
+ // MC-33041, SPIGOT-5538: if System.in is not valid due to javaw, then return
|
||||
+ try {
|
||||
+ System.in.available();
|
||||
@@ -62,7 +71,7 @@
|
||||
+ return;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
|
||||
+
|
||||
String s;
|
||||
|
||||
try {
|
||||
@@ -92,7 +101,7 @@
|
||||
}
|
||||
} catch (IOException ioexception) {
|
||||
DedicatedServer.LOGGER.error("Exception handling console input", ioexception);
|
||||
@@ -108,6 +153,29 @@
|
||||
@@ -108,6 +152,29 @@
|
||||
}
|
||||
};
|
||||
|
||||
@@ -122,7 +131,7 @@
|
||||
thread.setDaemon(true);
|
||||
thread.setUncaughtExceptionHandler(new DefaultUncaughtExceptionHandler(DedicatedServer.LOGGER));
|
||||
thread.start();
|
||||
@@ -132,7 +200,7 @@
|
||||
@@ -132,7 +199,7 @@
|
||||
this.setMotd(dedicatedserverproperties.motd);
|
||||
super.setPlayerIdleTimeout((Integer) dedicatedserverproperties.playerIdleTimeout.get());
|
||||
this.setEnforceWhitelist(dedicatedserverproperties.enforceWhitelist);
|
||||
@@ -131,45 +140,45 @@
|
||||
DedicatedServer.LOGGER.info("Default game type: {}", dedicatedserverproperties.gamemode);
|
||||
InetAddress inetaddress = null;
|
||||
|
||||
@@ -156,6 +224,12 @@
|
||||
@@ -156,6 +223,12 @@
|
||||
return false;
|
||||
}
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ this.setPlayerList(new DedicatedPlayerList(this, this.registries(), this.playerDataStorage));
|
||||
+ server.loadPlugins();
|
||||
+ server.enablePlugins(org.bukkit.plugin.PluginLoadOrder.STARTUP);
|
||||
+ 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.");
|
||||
@@ -170,7 +244,7 @@
|
||||
if (!NameReferencingFileConverter.serverReadyAfterUserconversion(this)) {
|
||||
@@ -170,7 +243,7 @@
|
||||
if (!OldUsersConverter.serverReadyAfterUserconversion(this)) {
|
||||
return false;
|
||||
} else {
|
||||
- this.setPlayerList(new DedicatedPlayerList(this, this.registries(), this.playerDataStorage));
|
||||
+ // this.setPlayerList(new DedicatedPlayerList(this, this.registries(), this.playerDataStorage)); // CraftBukkit - moved up
|
||||
this.debugSampleSubscriptionTracker = new DebugSampleSubscriptionTracker(this.getPlayerList());
|
||||
this.tickTimeLogger = new RemoteSampleLogger(TpsDebugDimensions.values().length, this.debugSampleSubscriptionTracker, RemoteDebugSampleType.TICK_TIME);
|
||||
long i = SystemUtils.getNanos();
|
||||
@@ -178,13 +252,13 @@
|
||||
TileEntitySkull.setup(this.services, this);
|
||||
UserCache.setUsesAuthentication(this.usesAuthentication());
|
||||
long i = Util.getNanos();
|
||||
@@ -178,13 +251,13 @@
|
||||
SkullBlockEntity.setup(this.services, this);
|
||||
GameProfileCache.setUsesAuthentication(this.usesAuthentication());
|
||||
DedicatedServer.LOGGER.info("Preparing level \"{}\"", this.getLevelIdName());
|
||||
- this.loadLevel();
|
||||
+ this.loadLevel(storageSource.getLevelId()); // CraftBukkit
|
||||
long j = SystemUtils.getNanos() - i;
|
||||
+ this.loadLevel(this.storageSource.getLevelId()); // CraftBukkit
|
||||
long j = Util.getNanos() - i;
|
||||
String s = String.format(Locale.ROOT, "%.3fs", (double) j / 1.0E9D);
|
||||
|
||||
DedicatedServer.LOGGER.info("Done ({})! For help, type \"help\"", s);
|
||||
if (dedicatedserverproperties.announcePlayerAchievements != null) {
|
||||
- ((GameRules.GameRuleBoolean) this.getGameRules().getRule(GameRules.RULE_ANNOUNCE_ADVANCEMENTS)).set(dedicatedserverproperties.announcePlayerAchievements, this);
|
||||
+ ((GameRules.GameRuleBoolean) this.getGameRules().getRule(GameRules.RULE_ANNOUNCE_ADVANCEMENTS)).set(dedicatedserverproperties.announcePlayerAchievements, this.overworld()); // CraftBukkit - per-world
|
||||
- ((GameRules.BooleanValue) this.getGameRules().getRule(GameRules.RULE_ANNOUNCE_ADVANCEMENTS)).set(dedicatedserverproperties.announcePlayerAchievements, this);
|
||||
+ ((GameRules.BooleanValue) this.getGameRules().getRule(GameRules.RULE_ANNOUNCE_ADVANCEMENTS)).set(dedicatedserverproperties.announcePlayerAchievements, this.overworld()); // CraftBukkit - per-world
|
||||
}
|
||||
|
||||
if (dedicatedserverproperties.enableQuery) {
|
||||
@@ -293,6 +367,7 @@
|
||||
@@ -293,6 +366,7 @@
|
||||
this.queryThreadGs4.stop();
|
||||
}
|
||||
|
||||
@@ -177,37 +186,57 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -314,7 +389,15 @@
|
||||
@@ -302,8 +376,8 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
- public boolean isLevelEnabled(Level world) {
|
||||
- return world.dimension() == Level.NETHER ? this.getProperties().allowNether : true;
|
||||
+ public boolean isLevelEnabled(net.minecraft.world.level.Level world) {
|
||||
+ return world.dimension() == net.minecraft.world.level.Level.NETHER ? this.getProperties().allowNether : true;
|
||||
}
|
||||
|
||||
public void handleConsoleInput(String command, CommandSourceStack commandSource) {
|
||||
@@ -314,7 +388,15 @@
|
||||
while (!this.consoleInput.isEmpty()) {
|
||||
ServerCommand servercommand = (ServerCommand) this.consoleInput.remove(0);
|
||||
ConsoleInput servercommand = (ConsoleInput) this.consoleInput.remove(0);
|
||||
|
||||
- this.getCommands().performPrefixedCommand(servercommand.source, servercommand.msg);
|
||||
+ // CraftBukkit start - ServerCommand for preprocessing
|
||||
+ ServerCommandEvent event = new ServerCommandEvent(console, servercommand.msg);
|
||||
+ server.getPluginManager().callEvent(event);
|
||||
+ ServerCommandEvent event = new ServerCommandEvent(this.console, servercommand.msg);
|
||||
+ this.server.getPluginManager().callEvent(event);
|
||||
+ if (event.isCancelled()) continue;
|
||||
+ servercommand = new ServerCommand(event.getCommand(), servercommand.source);
|
||||
+ servercommand = new ConsoleInput(event.getCommand(), servercommand.source);
|
||||
+
|
||||
+ // this.getCommands().performPrefixedCommand(servercommand.source, servercommand.msg); // Called in dispatchServerCommand
|
||||
+ server.dispatchServerCommand(console, servercommand);
|
||||
+ this.server.dispatchServerCommand(this.console, servercommand);
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
}
|
||||
@@ -541,16 +624,52 @@
|
||||
@@ -383,7 +465,7 @@
|
||||
|
||||
@Override
|
||||
public boolean isUnderSpawnProtection(ServerLevel world, BlockPos pos, Player player) {
|
||||
- if (world.dimension() != Level.OVERWORLD) {
|
||||
+ if (world.dimension() != net.minecraft.world.level.Level.OVERWORLD) {
|
||||
return false;
|
||||
} else if (this.getPlayerList().getOps().isEmpty()) {
|
||||
return false;
|
||||
@@ -541,16 +623,52 @@
|
||||
|
||||
@Override
|
||||
public String getPluginNames() {
|
||||
- return "";
|
||||
+ // CraftBukkit start - Whole method
|
||||
+ StringBuilder result = new StringBuilder();
|
||||
+ org.bukkit.plugin.Plugin[] plugins = server.getPluginManager().getPlugins();
|
||||
+ org.bukkit.plugin.Plugin[] plugins = this.server.getPluginManager().getPlugins();
|
||||
+
|
||||
+ result.append(server.getName());
|
||||
+ result.append(this.server.getName());
|
||||
+ result.append(" on Bukkit ");
|
||||
+ result.append(server.getBukkitVersion());
|
||||
+ result.append(this.server.getBukkitVersion());
|
||||
+
|
||||
+ if (plugins.length > 0 && server.getQueryPlugins()) {
|
||||
+ if (plugins.length > 0 && this.server.getQueryPlugins()) {
|
||||
+ result.append(": ");
|
||||
+
|
||||
+ for (int i = 0; i < plugins.length; i++) {
|
||||
@@ -226,32 +255,32 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
public String runCommand(String s) {
|
||||
public String runCommand(String command) {
|
||||
- this.rconConsoleSource.prepareForCommand();
|
||||
+ // CraftBukkit start - fire RemoteServerCommandEvent
|
||||
+ throw new UnsupportedOperationException("Not supported - remote source required.");
|
||||
+ }
|
||||
+
|
||||
+ public String runCommand(RemoteControlCommandListener rconConsoleSource, String s) {
|
||||
+ public String runCommand(RconConsoleSource rconConsoleSource, String s) {
|
||||
+ rconConsoleSource.prepareForCommand();
|
||||
this.executeBlocking(() -> {
|
||||
- this.getCommands().performPrefixedCommand(this.rconConsoleSource.createCommandSourceStack(), s);
|
||||
+ CommandListenerWrapper wrapper = rconConsoleSource.createCommandSourceStack();
|
||||
- this.getCommands().performPrefixedCommand(this.rconConsoleSource.createCommandSourceStack(), command);
|
||||
+ CommandSourceStack wrapper = rconConsoleSource.createCommandSourceStack();
|
||||
+ RemoteServerCommandEvent event = new RemoteServerCommandEvent(rconConsoleSource.getBukkitSender(wrapper), s);
|
||||
+ server.getPluginManager().callEvent(event);
|
||||
+ this.server.getPluginManager().callEvent(event);
|
||||
+ if (event.isCancelled()) {
|
||||
+ return;
|
||||
+ }
|
||||
+ ServerCommand serverCommand = new ServerCommand(event.getCommand(), wrapper);
|
||||
+ server.dispatchServerCommand(event.getSender(), serverCommand);
|
||||
+ ConsoleInput serverCommand = new ConsoleInput(event.getCommand(), wrapper);
|
||||
+ this.server.dispatchServerCommand(event.getSender(), serverCommand);
|
||||
});
|
||||
- return this.rconConsoleSource.getCommandResponse();
|
||||
+ return rconConsoleSource.getCommandResponse();
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
public void storeUsingWhiteList(boolean flag) {
|
||||
@@ -660,4 +779,15 @@
|
||||
public void storeUsingWhiteList(boolean useWhitelist) {
|
||||
@@ -660,4 +778,15 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -262,8 +291,8 @@
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public CommandSender getBukkitSender(CommandListenerWrapper wrapper) {
|
||||
+ return console;
|
||||
+ public CommandSender getBukkitSender(CommandSourceStack wrapper) {
|
||||
+ return this.console;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
@@ -8,7 +8,7 @@
|
||||
+import joptsimple.OptionSet;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public class DedicatedServerProperties extends PropertyManager<DedicatedServerProperties> {
|
||||
public class DedicatedServerProperties extends Settings<DedicatedServerProperties> {
|
||||
|
||||
static final Logger LOGGER = LogUtils.getLogger();
|
||||
private static final Pattern SHA1 = Pattern.compile("^[a-fA-F0-9]{40}$");
|
||||
@@ -18,7 +18,7 @@
|
||||
public final boolean preventProxyConnections = this.get("prevent-proxy-connections", false);
|
||||
public final String serverIp = this.get("server-ip", "");
|
||||
@@ -100,13 +105,15 @@
|
||||
public final PropertyManager<DedicatedServerProperties>.EditableProperty<Boolean> whiteList;
|
||||
public final Settings<DedicatedServerProperties>.MutableValue<Boolean> whiteList;
|
||||
public final boolean enforceSecureProfile;
|
||||
public final boolean logIPs;
|
||||
- public final int pauseWhenEmptySeconds;
|
||||
@@ -33,11 +33,11 @@
|
||||
+ public DedicatedServerProperties(Properties properties, OptionSet optionset) {
|
||||
+ super(properties, optionset);
|
||||
+ // CraftBukkit end
|
||||
this.difficulty = (EnumDifficulty) this.get("difficulty", dispatchNumberOrString(EnumDifficulty::byId, EnumDifficulty::byName), EnumDifficulty::getKey, EnumDifficulty.EASY);
|
||||
this.gamemode = (EnumGamemode) this.get("gamemode", dispatchNumberOrString(EnumGamemode::byId, EnumGamemode::byName), EnumGamemode::getName, EnumGamemode.SURVIVAL);
|
||||
this.difficulty = (Difficulty) this.get("difficulty", dispatchNumberOrString(Difficulty::byId, Difficulty::byName), Difficulty::getKey, Difficulty.EASY);
|
||||
this.gamemode = (GameType) this.get("gamemode", dispatchNumberOrString(GameType::byId, GameType::byName), GameType::getName, GameType.SURVIVAL);
|
||||
this.levelName = this.get("level-name", "world");
|
||||
@@ -167,13 +174,15 @@
|
||||
this.initialDataPackConfiguration = getDatapackConfig(this.get("initial-enabled-packs", String.join(",", WorldDataConfiguration.DEFAULT.dataPacks().getEnabled())), this.get("initial-disabled-packs", String.join(",", WorldDataConfiguration.DEFAULT.dataPacks().getDisabled())));
|
||||
this.initialDataPackConfiguration = DedicatedServerProperties.getDatapackConfig(this.get("initial-enabled-packs", String.join(",", WorldDataConfiguration.DEFAULT.dataPacks().getEnabled())), this.get("initial-disabled-packs", String.join(",", WorldDataConfiguration.DEFAULT.dataPacks().getDisabled())));
|
||||
}
|
||||
|
||||
- public static DedicatedServerProperties fromFile(Path path) {
|
||||
@@ -48,9 +48,9 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
- protected DedicatedServerProperties reload(IRegistryCustom iregistrycustom, Properties properties) {
|
||||
- protected DedicatedServerProperties reload(RegistryAccess registryManager, Properties properties) {
|
||||
- return new DedicatedServerProperties(properties);
|
||||
+ protected DedicatedServerProperties reload(IRegistryCustom iregistrycustom, Properties properties, OptionSet optionset) {
|
||||
+ public DedicatedServerProperties reload(RegistryAccess iregistrycustom, Properties properties, OptionSet optionset) {
|
||||
+ return new DedicatedServerProperties(properties, optionset);
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
@@ -60,8 +60,8 @@
|
||||
}).orElseThrow(() -> {
|
||||
return new IllegalStateException("Invalid datapack contents: can't find default preset");
|
||||
});
|
||||
- Optional optional = Optional.ofNullable(MinecraftKey.tryParse(this.levelType)).map((minecraftkey) -> {
|
||||
+ Optional<ResourceKey<WorldPreset>> optional = Optional.ofNullable(MinecraftKey.tryParse(this.levelType)).map((minecraftkey) -> { // CraftBukkit - decompile error
|
||||
- Optional optional = Optional.ofNullable(ResourceLocation.tryParse(this.levelType)).map((minecraftkey) -> {
|
||||
+ Optional<ResourceKey<WorldPreset>> optional = Optional.ofNullable(ResourceLocation.tryParse(this.levelType)).map((minecraftkey) -> { // CraftBukkit - decompile error
|
||||
return ResourceKey.create(Registries.WORLD_PRESET, minecraftkey);
|
||||
}).or(() -> {
|
||||
- return Optional.ofNullable((ResourceKey) DedicatedServerProperties.WorldDimensionData.LEGACY_PRESET_NAMES.get(this.levelType));
|
||||
@@ -72,9 +72,9 @@
|
||||
@@ -269,7 +278,7 @@
|
||||
|
||||
if (holder.is(WorldPresets.FLAT)) {
|
||||
RegistryOps<JsonElement> registryops = holderlookup_a.createSerializationContext(JsonOps.INSTANCE);
|
||||
- DataResult dataresult = GeneratorSettingsFlat.CODEC.parse(new Dynamic(registryops, this.generatorSettings()));
|
||||
+ DataResult<GeneratorSettingsFlat> dataresult = GeneratorSettingsFlat.CODEC.parse(new Dynamic(registryops, this.generatorSettings())); // CraftBukkit - decompile error
|
||||
RegistryOps<JsonElement> registryops = registries.createSerializationContext(JsonOps.INSTANCE);
|
||||
- DataResult dataresult = FlatLevelGeneratorSettings.CODEC.parse(new Dynamic(registryops, this.generatorSettings()));
|
||||
+ DataResult<FlatLevelGeneratorSettings> dataresult = FlatLevelGeneratorSettings.CODEC.parse(new Dynamic(registryops, this.generatorSettings())); // CraftBukkit - decompile error
|
||||
Logger logger = DedicatedServerProperties.LOGGER;
|
||||
|
||||
Objects.requireNonNull(logger);
|
||||
@@ -20,7 +20,7 @@
|
||||
+ // CraftBukkit start
|
||||
+ public DedicatedServerSettings(OptionSet optionset) {
|
||||
+ this.source = ((File) optionset.valueOf("config")).toPath();
|
||||
+ this.properties = DedicatedServerProperties.fromFile(source, optionset);
|
||||
+ this.properties = DedicatedServerProperties.fromFile(this.source, optionset);
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
@@ -1,124 +0,0 @@
|
||||
--- a/net/minecraft/server/dedicated/PropertyManager.java
|
||||
+++ b/net/minecraft/server/dedicated/PropertyManager.java
|
||||
@@ -23,17 +23,37 @@
|
||||
import net.minecraft.core.IRegistryCustom;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
+import joptsimple.OptionSet; // CraftBukkit
|
||||
+
|
||||
public abstract class PropertyManager<T extends PropertyManager<T>> {
|
||||
|
||||
private static final Logger LOGGER = LogUtils.getLogger();
|
||||
public final Properties properties;
|
||||
+ // CraftBukkit start
|
||||
+ private OptionSet options = null;
|
||||
|
||||
- public PropertyManager(Properties properties) {
|
||||
+ public PropertyManager(Properties properties, final OptionSet options) {
|
||||
this.properties = properties;
|
||||
+
|
||||
+ this.options = options;
|
||||
+ }
|
||||
+
|
||||
+ private String getOverride(String name, String value) {
|
||||
+ if ((this.options != null) && (this.options.has(name))) {
|
||||
+ return String.valueOf(this.options.valueOf(name));
|
||||
+ }
|
||||
+
|
||||
+ return value;
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
public static Properties loadFromFile(Path path) {
|
||||
try {
|
||||
+ // CraftBukkit start - SPIGOT-7465, MC-264979: Don't load if file doesn't exist
|
||||
+ if (!path.toFile().exists()) {
|
||||
+ return new Properties();
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
Properties properties;
|
||||
Properties properties1;
|
||||
|
||||
@@ -97,6 +117,11 @@
|
||||
|
||||
public void store(Path path) {
|
||||
try {
|
||||
+ // CraftBukkit start - Don't attempt writing to file if it's read only
|
||||
+ if (path.toFile().exists() && !path.toFile().canWrite()) {
|
||||
+ return;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
BufferedWriter bufferedwriter = Files.newBufferedWriter(path, StandardCharsets.UTF_8);
|
||||
|
||||
try {
|
||||
@@ -125,7 +150,7 @@
|
||||
private static <V extends Number> Function<String, V> wrapNumberDeserializer(Function<String, V> function) {
|
||||
return (s) -> {
|
||||
try {
|
||||
- return (Number) function.apply(s);
|
||||
+ return (V) function.apply(s); // CraftBukkit - decompile error
|
||||
} catch (NumberFormatException numberformatexception) {
|
||||
return null;
|
||||
}
|
||||
@@ -144,7 +169,7 @@
|
||||
|
||||
@Nullable
|
||||
private String getStringRaw(String s) {
|
||||
- return (String) this.properties.get(s);
|
||||
+ return (String) getOverride(s, this.properties.getProperty(s)); // CraftBukkit
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@@ -160,6 +185,16 @@
|
||||
}
|
||||
|
||||
protected <V> V get(String s, Function<String, V> function, Function<V, String> function1, V v0) {
|
||||
+ // CraftBukkit start
|
||||
+ try {
|
||||
+ return get0(s, function, function1, v0);
|
||||
+ } catch (Exception ex) {
|
||||
+ throw new RuntimeException("Could not load invalidly configured property '" + s + "'", ex);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ private <V> V get0(String s, Function<String, V> function, Function<V, String> function1, V v0) {
|
||||
+ // CraftBukkit end
|
||||
String s1 = this.getStringRaw(s);
|
||||
V v1 = MoreObjects.firstNonNull(s1 != null ? function.apply(s1) : null, v0);
|
||||
|
||||
@@ -172,7 +207,7 @@
|
||||
V v1 = MoreObjects.firstNonNull(s1 != null ? function.apply(s1) : null, v0);
|
||||
|
||||
this.properties.put(s, function1.apply(v1));
|
||||
- return new PropertyManager.EditableProperty<>(s, v1, function1);
|
||||
+ return new PropertyManager.EditableProperty(s, v1, function1); // CraftBukkit - decompile error
|
||||
}
|
||||
|
||||
protected <V> V get(String s, Function<String, V> function, UnaryOperator<V> unaryoperator, Function<V, String> function1, V v0) {
|
||||
@@ -236,7 +271,7 @@
|
||||
return properties;
|
||||
}
|
||||
|
||||
- protected abstract T reload(IRegistryCustom iregistrycustom, Properties properties);
|
||||
+ protected abstract T reload(IRegistryCustom iregistrycustom, Properties properties, OptionSet optionset); // CraftBukkit
|
||||
|
||||
public class EditableProperty<V> implements Supplier<V> {
|
||||
|
||||
@@ -244,7 +279,7 @@
|
||||
private final V value;
|
||||
private final Function<V, String> serializer;
|
||||
|
||||
- EditableProperty(final String s, final Object object, final Function function) {
|
||||
+ EditableProperty(final String s, final V object, final Function function) { // CraftBukkit - decompile error
|
||||
this.key = s;
|
||||
this.value = object;
|
||||
this.serializer = function;
|
||||
@@ -258,7 +293,7 @@
|
||||
Properties properties = PropertyManager.this.cloneProperties();
|
||||
|
||||
properties.put(this.key, this.serializer.apply(v0));
|
||||
- return PropertyManager.this.reload(iregistrycustom, properties);
|
||||
+ return PropertyManager.this.reload(iregistrycustom, properties, PropertyManager.this.options); // CraftBukkit
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,135 @@
|
||||
--- a/net/minecraft/server/dedicated/Settings.java
|
||||
+++ b/net/minecraft/server/dedicated/Settings.java
|
||||
@@ -20,20 +20,40 @@
|
||||
import java.util.function.Supplier;
|
||||
import java.util.function.UnaryOperator;
|
||||
import javax.annotation.Nullable;
|
||||
-import net.minecraft.core.RegistryAccess;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
+import joptsimple.OptionSet; // CraftBukkit
|
||||
+import net.minecraft.core.RegistryAccess;
|
||||
+
|
||||
public abstract class Settings<T extends Settings<T>> {
|
||||
|
||||
private static final Logger LOGGER = LogUtils.getLogger();
|
||||
public final Properties properties;
|
||||
+ // CraftBukkit start
|
||||
+ private OptionSet options = null;
|
||||
|
||||
- public Settings(Properties properties) {
|
||||
+ public Settings(Properties properties, final OptionSet options) {
|
||||
this.properties = properties;
|
||||
+
|
||||
+ this.options = options;
|
||||
}
|
||||
|
||||
+ private String getOverride(String name, String value) {
|
||||
+ if ((this.options != null) && (this.options.has(name))) {
|
||||
+ return String.valueOf(this.options.valueOf(name));
|
||||
+ }
|
||||
+
|
||||
+ return value;
|
||||
+ // CraftBukkit end
|
||||
+ }
|
||||
+
|
||||
public static Properties loadFromFile(Path path) {
|
||||
try {
|
||||
+ // CraftBukkit start - SPIGOT-7465, MC-264979: Don't load if file doesn't exist
|
||||
+ if (!path.toFile().exists()) {
|
||||
+ return new Properties();
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
Properties properties;
|
||||
Properties properties1;
|
||||
|
||||
@@ -97,6 +117,11 @@
|
||||
|
||||
public void store(Path path) {
|
||||
try {
|
||||
+ // CraftBukkit start - Don't attempt writing to file if it's read only
|
||||
+ if (path.toFile().exists() && !path.toFile().canWrite()) {
|
||||
+ return;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
BufferedWriter bufferedwriter = Files.newBufferedWriter(path, StandardCharsets.UTF_8);
|
||||
|
||||
try {
|
||||
@@ -125,7 +150,7 @@
|
||||
private static <V extends Number> Function<String, V> wrapNumberDeserializer(Function<String, V> parser) {
|
||||
return (s) -> {
|
||||
try {
|
||||
- return (Number) parser.apply(s);
|
||||
+ return (V) parser.apply(s); // CraftBukkit - decompile error
|
||||
} catch (NumberFormatException numberformatexception) {
|
||||
return null;
|
||||
}
|
||||
@@ -144,7 +169,7 @@
|
||||
|
||||
@Nullable
|
||||
public String getStringRaw(String key) {
|
||||
- return (String) this.properties.get(key);
|
||||
+ return (String) this.getOverride(key, this.properties.getProperty(key)); // CraftBukkit
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@@ -160,10 +185,20 @@
|
||||
}
|
||||
|
||||
protected <V> V get(String key, Function<String, V> parser, Function<V, String> stringifier, V fallback) {
|
||||
- String s1 = this.getStringRaw(key);
|
||||
- V v1 = MoreObjects.firstNonNull(s1 != null ? parser.apply(s1) : null, fallback);
|
||||
+ // CraftBukkit start
|
||||
+ try {
|
||||
+ return this.get0(key, parser, stringifier, fallback);
|
||||
+ } catch (Exception ex) {
|
||||
+ throw new RuntimeException("Could not load invalidly configured property '" + key + "'", ex);
|
||||
+ }
|
||||
+ }
|
||||
|
||||
- this.properties.put(key, stringifier.apply(v1));
|
||||
+ private <V> V get0(String s, Function<String, V> function, Function<V, String> function1, V v0) {
|
||||
+ // CraftBukkit end
|
||||
+ String s1 = this.getStringRaw(s);
|
||||
+ V v1 = MoreObjects.firstNonNull(s1 != null ? function.apply(s1) : null, v0);
|
||||
+
|
||||
+ this.properties.put(s, function1.apply(v1));
|
||||
return v1;
|
||||
}
|
||||
|
||||
@@ -172,7 +207,7 @@
|
||||
V v1 = MoreObjects.firstNonNull(s1 != null ? parser.apply(s1) : null, fallback);
|
||||
|
||||
this.properties.put(key, stringifier.apply(v1));
|
||||
- return new Settings.MutableValue<>(key, v1, stringifier);
|
||||
+ return new Settings.MutableValue(key, v1, stringifier); // CraftBukkit - decompile error
|
||||
}
|
||||
|
||||
protected <V> V get(String key, Function<String, V> parser, UnaryOperator<V> parsedTransformer, Function<V, String> stringifier, V fallback) {
|
||||
@@ -236,7 +271,7 @@
|
||||
return properties;
|
||||
}
|
||||
|
||||
- protected abstract T reload(RegistryAccess registryManager, Properties properties);
|
||||
+ protected abstract T reload(RegistryAccess iregistrycustom, Properties properties, OptionSet optionset); // CraftBukkit
|
||||
|
||||
public class MutableValue<V> implements Supplier<V> {
|
||||
|
||||
@@ -244,7 +279,7 @@
|
||||
private final V value;
|
||||
private final Function<V, String> serializer;
|
||||
|
||||
- MutableValue(final String s, final Object object, final Function function) {
|
||||
+ MutableValue(final String s, final V object, final Function function) { // CraftBukkit - decompile error
|
||||
this.key = s;
|
||||
this.value = object;
|
||||
this.serializer = function;
|
||||
@@ -258,7 +293,7 @@
|
||||
Properties properties = Settings.this.cloneProperties();
|
||||
|
||||
properties.put(this.key, this.serializer.apply(value));
|
||||
- return Settings.this.reload(registryManager, properties);
|
||||
+ return Settings.this.reload(registryManager, properties, Settings.this.options); // CraftBukkit
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user