mirror of
https://github.com/PaperMC/Paper.git
synced 2025-08-01 04:32:11 -07:00
Paper config files
== AT == public org.spigotmc.SpigotWorldConfig getBoolean(Ljava/lang/String;Z)Z public org.spigotmc.SpigotWorldConfig getDouble(Ljava/lang/String;)D public org.spigotmc.SpigotWorldConfig getDouble(Ljava/lang/String;D)D public org.spigotmc.SpigotWorldConfig getInt(Ljava/lang/String;)I public org.spigotmc.SpigotWorldConfig getInt(Ljava/lang/String;I)I public org.spigotmc.SpigotWorldConfig getList(Ljava/lang/String;Ljava/lang/Object;)Ljava/util/List; public org.spigotmc.SpigotWorldConfig getString(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String; public net.minecraft.server.dedicated.DedicatedServerProperties reload(Lnet/minecraft/core/RegistryAccess;Ljava/util/Properties;Ljoptsimple/OptionSet;)Lnet/minecraft/server/dedicated/DedicatedServerProperties; public net.minecraft.world.level.NaturalSpawner SPAWNING_CATEGORIES
This commit is contained in:
@@ -71,7 +71,7 @@
|
||||
JvmProfiler.INSTANCE.start(Environment.SERVER);
|
||||
}
|
||||
|
||||
@@ -112,28 +125,52 @@
|
||||
@@ -112,28 +125,56 @@
|
||||
Bootstrap.validate();
|
||||
Util.startTimerHackThread();
|
||||
Path path1 = Paths.get("server.properties");
|
||||
@@ -82,6 +82,10 @@
|
||||
RegionFileVersion.configure(dedicatedserversettings.getProperties().regionFileComression);
|
||||
Path path2 = Paths.get("eula.txt");
|
||||
Eula eula = new Eula(path2);
|
||||
+ // Paper start - load config files early for access below if needed
|
||||
+ org.bukkit.configuration.file.YamlConfiguration bukkitConfiguration = io.papermc.paper.configuration.PaperConfigurations.loadLegacyConfigFile((File) optionset.valueOf("bukkit-settings"));
|
||||
+ org.bukkit.configuration.file.YamlConfiguration spigotConfiguration = io.papermc.paper.configuration.PaperConfigurations.loadLegacyConfigFile((File) optionset.valueOf("spigot-settings"));
|
||||
+ // Paper end - load config files early for access below if needed
|
||||
|
||||
- if (optionset.has(optionspec1)) {
|
||||
+ if (optionset.has("initSettings")) { // CraftBukkit
|
||||
@@ -118,9 +122,10 @@
|
||||
}
|
||||
|
||||
- File file = new File((String) optionset.valueOf(optionspec9));
|
||||
+ File file = (File) optionset.valueOf("universe"); // CraftBukkit
|
||||
Services services = Services.create(new YggdrasilAuthenticationService(Proxy.NO_PROXY), file);
|
||||
- Services services = Services.create(new YggdrasilAuthenticationService(Proxy.NO_PROXY), file);
|
||||
- String s = (String) Optional.ofNullable((String) optionset.valueOf(optionspec10)).orElse(dedicatedserversettings.getProperties().levelName);
|
||||
+ File file = (File) optionset.valueOf("universe"); // CraftBukkit
|
||||
+ Services services = Services.create(new YggdrasilAuthenticationService(Proxy.NO_PROXY), file, optionset); // Paper - pass OptionSet to load paper config files
|
||||
+ // CraftBukkit start
|
||||
+ String s = (String) Optional.ofNullable((String) optionset.valueOf("world")).orElse(dedicatedserversettings.getProperties().levelName);
|
||||
LevelStorageSource convertable = LevelStorageSource.createDefault(file.toPath());
|
||||
@@ -130,7 +135,7 @@
|
||||
Dynamic dynamic;
|
||||
|
||||
if (convertable_conversionsession.hasWorldData()) {
|
||||
@@ -174,13 +211,31 @@
|
||||
@@ -174,13 +215,31 @@
|
||||
}
|
||||
|
||||
Dynamic<?> dynamic1 = dynamic;
|
||||
@@ -163,7 +168,7 @@
|
||||
|
||||
WorldStem worldstem;
|
||||
|
||||
@@ -189,6 +244,7 @@
|
||||
@@ -189,6 +248,7 @@
|
||||
|
||||
worldstem = (WorldStem) Util.blockUntilDone((executor) -> {
|
||||
return WorldLoader.load(worldloader_c, (worldloader_a) -> {
|
||||
@@ -171,7 +176,7 @@
|
||||
Registry<LevelStem> iregistry = worldloader_a.datapackDimensions().lookupOrThrow(Registries.LEVEL_STEM);
|
||||
|
||||
if (dynamic1 != null) {
|
||||
@@ -201,7 +257,7 @@
|
||||
@@ -201,7 +261,7 @@
|
||||
WorldOptions worldoptions;
|
||||
WorldDimensions worlddimensions;
|
||||
|
||||
@@ -180,7 +185,7 @@
|
||||
worldsettings = MinecraftServer.DEMO_SETTINGS;
|
||||
worldoptions = WorldOptions.DEMO_OPTIONS;
|
||||
worlddimensions = WorldPresets.createNormalWorldDimensions(worldloader_a.datapackWorldgen());
|
||||
@@ -209,7 +265,7 @@
|
||||
@@ -209,7 +269,7 @@
|
||||
DedicatedServerProperties dedicatedserverproperties = dedicatedserversettings.getProperties();
|
||||
|
||||
worldsettings = new LevelSettings(dedicatedserverproperties.levelName, dedicatedserverproperties.gamemode, dedicatedserverproperties.hardcore, dedicatedserverproperties.difficulty, false, new GameRules(worldloader_a.dataConfiguration().enabledFeatures()), worldloader_a.dataConfiguration());
|
||||
@@ -189,7 +194,7 @@
|
||||
worlddimensions = dedicatedserverproperties.createDimensions(worldloader_a.datapackWorldgen());
|
||||
}
|
||||
|
||||
@@ -225,32 +281,44 @@
|
||||
@@ -225,32 +285,44 @@
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -239,7 +244,7 @@
|
||||
Thread thread = new Thread("Server Shutdown Thread") {
|
||||
public void run() {
|
||||
dedicatedserver.halt(true);
|
||||
@@ -259,6 +327,7 @@
|
||||
@@ -259,6 +331,7 @@
|
||||
|
||||
thread.setUncaughtExceptionHandler(new DefaultUncaughtExceptionHandler(Main.LOGGER));
|
||||
Runtime.getRuntime().addShutdownHook(thread);
|
||||
@@ -247,7 +252,7 @@
|
||||
} catch (Exception exception1) {
|
||||
Main.LOGGER.error(LogUtils.FATAL_MARKER, "Failed to start the minecraft server", exception1);
|
||||
}
|
||||
@@ -295,7 +364,7 @@
|
||||
@@ -295,7 +368,7 @@
|
||||
}
|
||||
|
||||
public static void forceUpgrade(LevelStorageSource.LevelStorageAccess session, DataFixer dataFixer, boolean eraseCache, BooleanSupplier continueCheck, RegistryAccess dynamicRegistryManager, boolean recreateRegionFiles) {
|
||||
|
@@ -107,7 +107,7 @@
|
||||
private static final int OVERLOADED_TICKS_THRESHOLD = 20;
|
||||
private static final long OVERLOADED_WARNING_INTERVAL_NANOS = 10L * TimeUtil.NANOSECONDS_PER_SECOND;
|
||||
private static final int OVERLOADED_TICKS_WARNING_INTERVAL = 100;
|
||||
@@ -276,6 +301,25 @@
|
||||
@@ -276,6 +301,26 @@
|
||||
private static final AtomicReference<RuntimeException> fatalException = new AtomicReference();
|
||||
private final SuppressedExceptionCollector suppressedExceptions;
|
||||
private final DiscontinuousFrame tickFrame;
|
||||
@@ -130,10 +130,11 @@
|
||||
+ private static final int SAMPLE_INTERVAL = 100;
|
||||
+ public final double[] recentTps = new double[ 3 ];
|
||||
+ // Spigot end
|
||||
+ public final io.papermc.paper.configuration.PaperConfigurations paperConfigurations; // Paper - add paper configuration files
|
||||
|
||||
public static <S extends MinecraftServer> S spin(Function<Thread, S> serverFactory) {
|
||||
AtomicReference<S> atomicreference = new AtomicReference();
|
||||
@@ -290,14 +334,14 @@
|
||||
@@ -290,14 +335,14 @@
|
||||
thread.setPriority(8);
|
||||
}
|
||||
|
||||
@@ -150,7 +151,7 @@
|
||||
super("Server");
|
||||
this.metricsRecorder = InactiveMetricsRecorder.INSTANCE;
|
||||
this.onMetricsRecordingStopped = (methodprofilerresults) -> {
|
||||
@@ -319,36 +363,63 @@
|
||||
@@ -319,36 +364,64 @@
|
||||
this.scoreboard = new ServerScoreboard(this);
|
||||
this.customBossEvents = new CustomBossEvents();
|
||||
this.suppressedExceptions = new SuppressedExceptionCollector();
|
||||
@@ -226,10 +227,11 @@
|
||||
+ }
|
||||
+ Runtime.getRuntime().addShutdownHook(new org.bukkit.craftbukkit.util.ServerShutdownThread(this));
|
||||
+ // CraftBukkit end
|
||||
+ this.paperConfigurations = services.paperConfigurations(); // Paper - add paper configuration files
|
||||
}
|
||||
|
||||
private void readScoreboard(DimensionDataStorage persistentStateManager) {
|
||||
@@ -357,7 +428,7 @@
|
||||
@@ -357,7 +430,7 @@
|
||||
|
||||
protected abstract boolean initServer() throws IOException;
|
||||
|
||||
@@ -238,7 +240,7 @@
|
||||
if (!JvmProfiler.INSTANCE.isRunning()) {
|
||||
;
|
||||
}
|
||||
@@ -365,12 +436,8 @@
|
||||
@@ -365,12 +438,8 @@
|
||||
boolean flag = false;
|
||||
ProfiledDuration profiledduration = JvmProfiler.INSTANCE.onWorldLoadedStarted();
|
||||
|
||||
@@ -252,7 +254,7 @@
|
||||
if (profiledduration != null) {
|
||||
profiledduration.finish(true);
|
||||
}
|
||||
@@ -387,23 +454,217 @@
|
||||
@@ -387,23 +456,217 @@
|
||||
|
||||
protected void forceDifficulty() {}
|
||||
|
||||
@@ -484,7 +486,7 @@
|
||||
|
||||
if (!iworlddataserver.isInitialized()) {
|
||||
try {
|
||||
@@ -427,30 +688,8 @@
|
||||
@@ -427,30 +690,8 @@
|
||||
iworlddataserver.setInitialized(true);
|
||||
}
|
||||
|
||||
@@ -511,12 +513,13 @@
|
||||
- }
|
||||
-
|
||||
- worldborder.applySettings(iworlddataserver.getWorldBorder());
|
||||
}
|
||||
- }
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
|
||||
private static void setInitialSpawn(ServerLevel world, ServerLevelData worldProperties, boolean bonusChest, boolean debugWorld) {
|
||||
if (debugWorld) {
|
||||
@@ -458,6 +697,21 @@
|
||||
@@ -458,6 +699,21 @@
|
||||
} else {
|
||||
ServerChunkCache chunkproviderserver = world.getChunkSource();
|
||||
ChunkPos chunkcoordintpair = new ChunkPos(chunkproviderserver.randomState().sampler().findSpawnPosition());
|
||||
@@ -538,7 +541,7 @@
|
||||
int i = chunkproviderserver.getGenerator().getSpawnHeight(world);
|
||||
|
||||
if (i < world.getMinY()) {
|
||||
@@ -516,31 +770,36 @@
|
||||
@@ -516,31 +772,36 @@
|
||||
iworlddataserver.setGameType(GameType.SPECTATOR);
|
||||
}
|
||||
|
||||
@@ -586,7 +589,7 @@
|
||||
ForcedChunksSavedData forcedchunk = (ForcedChunksSavedData) worldserver1.getDataStorage().get(ForcedChunksSavedData.factory(), "chunks");
|
||||
|
||||
if (forcedchunk != null) {
|
||||
@@ -555,10 +814,17 @@
|
||||
@@ -555,10 +816,17 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -608,7 +611,7 @@
|
||||
}
|
||||
|
||||
public GameType getDefaultGameType() {
|
||||
@@ -588,12 +854,16 @@
|
||||
@@ -588,12 +856,16 @@
|
||||
worldserver.save((ProgressListener) null, flush, worldserver.noSave && !force);
|
||||
}
|
||||
|
||||
@@ -627,7 +630,7 @@
|
||||
if (flush) {
|
||||
Iterator iterator1 = this.getAllLevels().iterator();
|
||||
|
||||
@@ -628,18 +898,40 @@
|
||||
@@ -628,18 +900,40 @@
|
||||
this.stopServer();
|
||||
}
|
||||
|
||||
@@ -668,7 +671,7 @@
|
||||
}
|
||||
|
||||
MinecraftServer.LOGGER.info("Saving worlds");
|
||||
@@ -693,6 +985,12 @@
|
||||
@@ -693,6 +987,12 @@
|
||||
} catch (IOException ioexception1) {
|
||||
MinecraftServer.LOGGER.error("Failed to unlock level {}", this.storageSource.getLevelId(), ioexception1);
|
||||
}
|
||||
@@ -681,7 +684,7 @@
|
||||
|
||||
}
|
||||
|
||||
@@ -720,6 +1018,13 @@
|
||||
@@ -720,6 +1020,13 @@
|
||||
|
||||
}
|
||||
|
||||
@@ -695,7 +698,7 @@
|
||||
protected void runServer() {
|
||||
try {
|
||||
if (!this.initServer()) {
|
||||
@@ -727,9 +1032,12 @@
|
||||
@@ -727,9 +1034,12 @@
|
||||
}
|
||||
|
||||
this.nextTickTimeNanos = Util.getNanos();
|
||||
@@ -709,7 +712,7 @@
|
||||
while (this.running) {
|
||||
long i;
|
||||
|
||||
@@ -744,11 +1052,23 @@
|
||||
@@ -744,11 +1054,23 @@
|
||||
if (j > MinecraftServer.OVERLOADED_THRESHOLD_NANOS + 20L * i && this.nextTickTimeNanos - this.lastOverloadWarningNanos >= MinecraftServer.OVERLOADED_WARNING_INTERVAL_NANOS + 100L * i) {
|
||||
long k = j / i;
|
||||
|
||||
@@ -718,7 +721,7 @@
|
||||
this.nextTickTimeNanos += k * i;
|
||||
this.lastOverloadWarningNanos = this.nextTickTimeNanos;
|
||||
}
|
||||
}
|
||||
+ }
|
||||
+ // Spigot start
|
||||
+ if ( tickCount++ % MinecraftServer.SAMPLE_INTERVAL == 0 )
|
||||
+ {
|
||||
@@ -728,12 +731,12 @@
|
||||
+ this.recentTps[1] = MinecraftServer.calcTps( this.recentTps[1], 0.9835, currentTps ); // 1/exp(5sec/5min)
|
||||
+ this.recentTps[2] = MinecraftServer.calcTps( this.recentTps[2], 0.9945, currentTps ); // 1/exp(5sec/15min)
|
||||
+ tickSection = curTime;
|
||||
+ }
|
||||
}
|
||||
+ // Spigot end
|
||||
|
||||
boolean flag = i == 0L;
|
||||
|
||||
@@ -757,6 +1077,7 @@
|
||||
@@ -757,6 +1079,7 @@
|
||||
this.debugCommandProfiler = new MinecraftServer.TimeProfiler(Util.getNanos(), this.tickCount);
|
||||
}
|
||||
|
||||
@@ -741,7 +744,7 @@
|
||||
this.nextTickTimeNanos += i;
|
||||
|
||||
try {
|
||||
@@ -830,6 +1151,13 @@
|
||||
@@ -830,6 +1153,13 @@
|
||||
this.services.profileCache().clearExecutor();
|
||||
}
|
||||
|
||||
@@ -755,7 +758,7 @@
|
||||
this.onServerExit();
|
||||
}
|
||||
|
||||
@@ -889,9 +1217,16 @@
|
||||
@@ -889,9 +1219,16 @@
|
||||
}
|
||||
|
||||
private boolean haveTime() {
|
||||
@@ -773,7 +776,7 @@
|
||||
public static boolean throwIfFatalException() {
|
||||
RuntimeException runtimeexception = (RuntimeException) MinecraftServer.fatalException.get();
|
||||
|
||||
@@ -903,7 +1238,7 @@
|
||||
@@ -903,7 +1240,7 @@
|
||||
}
|
||||
|
||||
public static void setFatalException(RuntimeException exception) {
|
||||
@@ -782,7 +785,7 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -977,7 +1312,7 @@
|
||||
@@ -977,7 +1314,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -791,7 +794,7 @@
|
||||
Profiler.get().incrementCounter("runTask");
|
||||
super.doRunTask(ticktask);
|
||||
}
|
||||
@@ -1025,6 +1360,7 @@
|
||||
@@ -1025,6 +1362,7 @@
|
||||
}
|
||||
|
||||
public void tickServer(BooleanSupplier shouldKeepTicking) {
|
||||
@@ -799,7 +802,7 @@
|
||||
long i = Util.getNanos();
|
||||
int j = this.pauseWhileEmptySeconds() * 20;
|
||||
|
||||
@@ -1041,11 +1377,13 @@
|
||||
@@ -1041,11 +1379,13 @@
|
||||
this.autoSave();
|
||||
}
|
||||
|
||||
@@ -813,7 +816,7 @@
|
||||
++this.tickCount;
|
||||
this.tickRateManager.tick();
|
||||
this.tickChildren(shouldKeepTicking);
|
||||
@@ -1055,7 +1393,7 @@
|
||||
@@ -1055,7 +1395,7 @@
|
||||
}
|
||||
|
||||
--this.ticksUntilAutosave;
|
||||
@@ -822,7 +825,7 @@
|
||||
this.autoSave();
|
||||
}
|
||||
|
||||
@@ -1071,10 +1409,13 @@
|
||||
@@ -1071,10 +1411,13 @@
|
||||
this.smoothedTickTimeMillis = this.smoothedTickTimeMillis * 0.8F + (float) k / (float) TimeUtil.NANOSECONDS_PER_MILLISECOND * 0.19999999F;
|
||||
this.logTickMethodTime(i);
|
||||
gameprofilerfiller.pop();
|
||||
@@ -837,7 +840,7 @@
|
||||
MinecraftServer.LOGGER.debug("Autosave started");
|
||||
ProfilerFiller gameprofilerfiller = Profiler.get();
|
||||
|
||||
@@ -1082,6 +1423,7 @@
|
||||
@@ -1082,6 +1425,7 @@
|
||||
this.saveEverything(true, false, false);
|
||||
gameprofilerfiller.pop();
|
||||
MinecraftServer.LOGGER.debug("Autosave finished");
|
||||
@@ -845,7 +848,7 @@
|
||||
}
|
||||
|
||||
private void logTickMethodTime(long tickStartTime) {
|
||||
@@ -1154,11 +1496,34 @@
|
||||
@@ -1154,11 +1498,34 @@
|
||||
this.getPlayerList().getPlayers().forEach((entityplayer) -> {
|
||||
entityplayer.connection.suspendFlushing();
|
||||
});
|
||||
@@ -880,7 +883,7 @@
|
||||
while (iterator.hasNext()) {
|
||||
ServerLevel worldserver = (ServerLevel) iterator.next();
|
||||
|
||||
@@ -1167,16 +1532,20 @@
|
||||
@@ -1167,16 +1534,20 @@
|
||||
|
||||
return s + " " + String.valueOf(worldserver.dimension().location());
|
||||
});
|
||||
@@ -901,7 +904,7 @@
|
||||
} catch (Throwable throwable) {
|
||||
CrashReport crashreport = CrashReport.forThrowable(throwable, "Exception ticking world");
|
||||
|
||||
@@ -1189,18 +1558,24 @@
|
||||
@@ -1189,18 +1560,24 @@
|
||||
}
|
||||
|
||||
gameprofilerfiller.popPush("connection");
|
||||
@@ -926,10 +929,12 @@
|
||||
|
||||
gameprofilerfiller.popPush("send chunks");
|
||||
iterator = this.playerList.getPlayers().iterator();
|
||||
@@ -1267,6 +1642,22 @@
|
||||
@@ -1265,7 +1642,23 @@
|
||||
@Nullable
|
||||
public ServerLevel getLevel(ResourceKey<Level> key) {
|
||||
return (ServerLevel) this.levels.get(key);
|
||||
}
|
||||
|
||||
+ }
|
||||
+
|
||||
+ // CraftBukkit start
|
||||
+ public void addLevel(ServerLevel level) {
|
||||
+ Map<ResourceKey<Level>, ServerLevel> oldLevels = this.levels;
|
||||
@@ -943,13 +948,12 @@
|
||||
+ Map<ResourceKey<Level>, ServerLevel> newLevels = Maps.newLinkedHashMap(oldLevels);
|
||||
+ newLevels.remove(level.dimension());
|
||||
+ this.levels = Collections.unmodifiableMap(newLevels);
|
||||
+ }
|
||||
}
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
|
||||
public Set<ResourceKey<Level>> levelKeys() {
|
||||
return this.levels.keySet();
|
||||
}
|
||||
@@ -1296,7 +1687,7 @@
|
||||
@@ -1296,7 +1689,7 @@
|
||||
|
||||
@DontObfuscate
|
||||
public String getServerModName() {
|
||||
@@ -958,7 +962,7 @@
|
||||
}
|
||||
|
||||
public SystemReport fillSystemReport(SystemReport details) {
|
||||
@@ -1507,7 +1898,7 @@
|
||||
@@ -1507,7 +1900,7 @@
|
||||
}
|
||||
|
||||
public ServerConnectionListener getConnection() {
|
||||
@@ -967,7 +971,7 @@
|
||||
}
|
||||
|
||||
public boolean isReady() {
|
||||
@@ -1634,11 +2025,11 @@
|
||||
@@ -1634,11 +2027,11 @@
|
||||
|
||||
public CompletableFuture<Void> reloadResources(Collection<String> dataPacks) {
|
||||
CompletableFuture<Void> completablefuture = CompletableFuture.supplyAsync(() -> {
|
||||
@@ -981,7 +985,7 @@
|
||||
}, this).thenCompose((immutablelist) -> {
|
||||
MultiPackResourceManager resourcemanager = new MultiPackResourceManager(PackType.SERVER_DATA, immutablelist);
|
||||
List<Registry.PendingTags<?>> list = TagLoader.loadTagsForExistingRegistries(resourcemanager, this.registries.compositeAccess());
|
||||
@@ -1654,6 +2045,7 @@
|
||||
@@ -1654,6 +2047,7 @@
|
||||
}).thenAcceptAsync((minecraftserver_reloadableresources) -> {
|
||||
this.resources.close();
|
||||
this.resources = minecraftserver_reloadableresources;
|
||||
@@ -989,7 +993,7 @@
|
||||
this.packRepository.setSelected(dataPacks);
|
||||
WorldDataConfiguration worlddataconfiguration = new WorldDataConfiguration(MinecraftServer.getSelectedPacks(this.packRepository, true), this.worldData.enabledFeatures());
|
||||
|
||||
@@ -1952,7 +2344,7 @@
|
||||
@@ -1952,7 +2346,7 @@
|
||||
final List<String> list = Lists.newArrayList();
|
||||
final GameRules gamerules = this.getGameRules();
|
||||
|
||||
@@ -998,7 +1002,7 @@
|
||||
@Override
|
||||
public <T extends GameRules.Value<T>> void visit(GameRules.Key<T> key, GameRules.Type<T> type) {
|
||||
list.add(String.format(Locale.ROOT, "%s=%s\n", key.getId(), gamerules.getRule(key)));
|
||||
@@ -2058,7 +2450,7 @@
|
||||
@@ -2058,7 +2452,7 @@
|
||||
try {
|
||||
label51:
|
||||
{
|
||||
@@ -1007,7 +1011,7 @@
|
||||
|
||||
try {
|
||||
arraylist = Lists.newArrayList(NativeModuleLister.listModules());
|
||||
@@ -2105,8 +2497,24 @@
|
||||
@@ -2105,8 +2499,24 @@
|
||||
if (bufferedwriter != null) {
|
||||
bufferedwriter.close();
|
||||
}
|
||||
@@ -1032,7 +1036,7 @@
|
||||
|
||||
private ProfilerFiller createProfiler() {
|
||||
if (this.willStartRecordingMetrics) {
|
||||
@@ -2235,6 +2643,11 @@
|
||||
@@ -2235,6 +2645,11 @@
|
||||
|
||||
}
|
||||
|
||||
|
@@ -0,0 +1,38 @@
|
||||
--- a/net/minecraft/server/Services.java
|
||||
+++ b/net/minecraft/server/Services.java
|
||||
@@ -10,16 +10,32 @@
|
||||
import net.minecraft.server.players.GameProfileCache;
|
||||
import net.minecraft.util.SignatureValidator;
|
||||
|
||||
+
|
||||
public record Services(
|
||||
- MinecraftSessionService sessionService, ServicesKeySet servicesKeySet, GameProfileRepository profileRepository, GameProfileCache profileCache
|
||||
+ MinecraftSessionService sessionService, ServicesKeySet servicesKeySet, GameProfileRepository profileRepository, GameProfileCache profileCache, @javax.annotation.Nullable io.papermc.paper.configuration.PaperConfigurations paperConfigurations // Paper - add paper configuration files
|
||||
) {
|
||||
+ // Paper start - add paper configuration files
|
||||
+ public Services(MinecraftSessionService sessionService, ServicesKeySet servicesKeySet, GameProfileRepository profileRepository, GameProfileCache profileCache) {
|
||||
+ this(sessionService, servicesKeySet, profileRepository, profileCache, null);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public io.papermc.paper.configuration.PaperConfigurations paperConfigurations() {
|
||||
+ return java.util.Objects.requireNonNull(this.paperConfigurations);
|
||||
+ }
|
||||
+ // Paper end - add paper configuration files
|
||||
private static final String USERID_CACHE_FILE = "usercache.json";
|
||||
|
||||
- public static Services create(YggdrasilAuthenticationService authenticationService, File rootDirectory) {
|
||||
+ public static Services create(YggdrasilAuthenticationService authenticationService, File rootDirectory, joptsimple.OptionSet optionSet) throws Exception { // Paper - add optionset to load paper config files
|
||||
MinecraftSessionService minecraftSessionService = authenticationService.createMinecraftSessionService();
|
||||
GameProfileRepository gameProfileRepository = authenticationService.createProfileRepository();
|
||||
GameProfileCache gameProfileCache = new GameProfileCache(gameProfileRepository, new File(rootDirectory, "usercache.json"));
|
||||
- return new Services(minecraftSessionService, authenticationService.getServicesKeySet(), gameProfileRepository, gameProfileCache);
|
||||
+ // Paper start - load paper config files from cli options
|
||||
+ final java.nio.file.Path legacyConfigPath = ((File) optionSet.valueOf("paper-settings")).toPath();
|
||||
+ final java.nio.file.Path configDirPath = ((File) optionSet.valueOf("paper-settings-directory")).toPath();
|
||||
+ io.papermc.paper.configuration.PaperConfigurations paperConfigurations = io.papermc.paper.configuration.PaperConfigurations.setup(legacyConfigPath, configDirPath, rootDirectory.toPath(), (File) optionSet.valueOf("spigot-settings"));
|
||||
+ return new Services(minecraftSessionService, authenticationService.getServicesKeySet(), gameProfileRepository, gameProfileCache, paperConfigurations);
|
||||
+ // Paper end - load paper config files from cli options
|
||||
}
|
||||
|
||||
@Nullable
|
@@ -132,7 +132,7 @@
|
||||
thread.setDaemon(true);
|
||||
thread.setUncaughtExceptionHandler(new DefaultUncaughtExceptionHandler(DedicatedServer.LOGGER));
|
||||
thread.start();
|
||||
@@ -126,13 +194,18 @@
|
||||
@@ -126,13 +194,22 @@
|
||||
this.setPreventProxyConnections(dedicatedserverproperties.preventProxyConnections);
|
||||
this.setLocalIp(dedicatedserverproperties.serverIp);
|
||||
}
|
||||
@@ -141,6 +141,10 @@
|
||||
+ org.spigotmc.SpigotConfig.init((java.io.File) this.options.valueOf("spigot-settings"));
|
||||
+ org.spigotmc.SpigotConfig.registerCommands();
|
||||
+ // Spigot end
|
||||
+ // Paper start - initialize global and world-defaults configuration
|
||||
+ this.paperConfigurations.initializeGlobalConfiguration(this.registryAccess());
|
||||
+ this.paperConfigurations.initializeWorldDefaultsConfiguration(this.registryAccess());
|
||||
+ // Paper end - initialize global and world-defaults configuration
|
||||
|
||||
this.setPvpAllowed(dedicatedserverproperties.pvp);
|
||||
this.setFlightAllowed(dedicatedserverproperties.allowFlight);
|
||||
@@ -152,17 +156,16 @@
|
||||
DedicatedServer.LOGGER.info("Default game type: {}", dedicatedserverproperties.gamemode);
|
||||
InetAddress inetaddress = null;
|
||||
|
||||
@@ -155,11 +228,24 @@
|
||||
DedicatedServer.LOGGER.warn("Perhaps a server is already running on that port?");
|
||||
@@ -156,10 +233,23 @@
|
||||
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.");
|
||||
@@ -178,7 +181,7 @@
|
||||
DedicatedServer.LOGGER.warn("To change this, set \"online-mode\" to \"true\" in the server.properties file.");
|
||||
}
|
||||
|
||||
@@ -170,7 +256,7 @@
|
||||
@@ -170,7 +260,7 @@
|
||||
if (!OldUsersConverter.serverReadyAfterUserconversion(this)) {
|
||||
return false;
|
||||
} else {
|
||||
@@ -187,7 +190,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 +264,13 @@
|
||||
@@ -178,13 +268,13 @@
|
||||
SkullBlockEntity.setup(this.services, this);
|
||||
GameProfileCache.setUsesAuthentication(this.usesAuthentication());
|
||||
DedicatedServer.LOGGER.info("Preparing level \"{}\"", this.getLevelIdName());
|
||||
@@ -203,7 +206,7 @@
|
||||
}
|
||||
|
||||
if (dedicatedserverproperties.enableQuery) {
|
||||
@@ -197,7 +283,7 @@
|
||||
@@ -197,7 +287,7 @@
|
||||
this.rconThread = RconThread.create(this);
|
||||
}
|
||||
|
||||
@@ -212,7 +215,7 @@
|
||||
Thread thread1 = new Thread(new ServerWatchdog(this));
|
||||
|
||||
thread1.setUncaughtExceptionHandler(new DefaultUncaughtExceptionHandlerWithName(DedicatedServer.LOGGER));
|
||||
@@ -293,6 +379,7 @@
|
||||
@@ -293,6 +383,7 @@
|
||||
this.queryThreadGs4.stop();
|
||||
}
|
||||
|
||||
@@ -220,7 +223,7 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -302,8 +389,8 @@
|
||||
@@ -302,8 +393,8 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -231,7 +234,7 @@
|
||||
}
|
||||
|
||||
public void handleConsoleInput(String command, CommandSourceStack commandSource) {
|
||||
@@ -311,12 +398,22 @@
|
||||
@@ -311,12 +402,22 @@
|
||||
}
|
||||
|
||||
public void handleConsoleInputs() {
|
||||
@@ -255,7 +258,7 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -383,7 +480,7 @@
|
||||
@@ -383,7 +484,7 @@
|
||||
|
||||
@Override
|
||||
public boolean isUnderSpawnProtection(ServerLevel world, BlockPos pos, Player player) {
|
||||
@@ -264,7 +267,7 @@
|
||||
return false;
|
||||
} else if (this.getPlayerList().getOps().isEmpty()) {
|
||||
return false;
|
||||
@@ -541,16 +638,52 @@
|
||||
@@ -541,16 +642,52 @@
|
||||
|
||||
@Override
|
||||
public String getPluginNames() {
|
||||
@@ -321,7 +324,7 @@
|
||||
}
|
||||
|
||||
public void storeUsingWhiteList(boolean useWhitelist) {
|
||||
@@ -660,4 +793,15 @@
|
||||
@@ -660,4 +797,15 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -43,19 +43,20 @@
|
||||
Properties properties;
|
||||
Properties properties1;
|
||||
|
||||
@@ -97,6 +117,11 @@
|
||||
@@ -97,6 +117,12 @@
|
||||
|
||||
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()) {
|
||||
+ Settings.LOGGER.warn("Can not write to file {}, skipping.", path); // Paper - log message file is read-only
|
||||
+ return;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
BufferedWriter bufferedwriter = Files.newBufferedWriter(path, StandardCharsets.UTF_8);
|
||||
|
||||
try {
|
||||
@@ -125,7 +150,7 @@
|
||||
@@ -125,7 +151,7 @@
|
||||
private static <V extends Number> Function<String, V> wrapNumberDeserializer(Function<String, V> parser) {
|
||||
return (s) -> {
|
||||
try {
|
||||
@@ -64,7 +65,7 @@
|
||||
} catch (NumberFormatException numberformatexception) {
|
||||
return null;
|
||||
}
|
||||
@@ -144,7 +169,7 @@
|
||||
@@ -144,7 +170,7 @@
|
||||
|
||||
@Nullable
|
||||
public String getStringRaw(String key) {
|
||||
@@ -73,7 +74,7 @@
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@@ -160,10 +185,20 @@
|
||||
@@ -160,10 +186,20 @@
|
||||
}
|
||||
|
||||
protected <V> V get(String key, Function<String, V> parser, Function<V, String> stringifier, V fallback) {
|
||||
@@ -97,7 +98,7 @@
|
||||
return v1;
|
||||
}
|
||||
|
||||
@@ -172,7 +207,7 @@
|
||||
@@ -172,7 +208,7 @@
|
||||
V v1 = MoreObjects.firstNonNull(s1 != null ? parser.apply(s1) : null, fallback);
|
||||
|
||||
this.properties.put(key, stringifier.apply(v1));
|
||||
@@ -106,7 +107,7 @@
|
||||
}
|
||||
|
||||
protected <V> V get(String key, Function<String, V> parser, UnaryOperator<V> parsedTransformer, Function<V, String> stringifier, V fallback) {
|
||||
@@ -236,7 +271,7 @@
|
||||
@@ -236,7 +272,7 @@
|
||||
return properties;
|
||||
}
|
||||
|
||||
@@ -115,7 +116,7 @@
|
||||
|
||||
public class MutableValue<V> implements Supplier<V> {
|
||||
|
||||
@@ -244,7 +279,7 @@
|
||||
@@ -244,7 +280,7 @@
|
||||
private final V value;
|
||||
private final Function<V, String> serializer;
|
||||
|
||||
@@ -124,7 +125,7 @@
|
||||
this.key = s;
|
||||
this.value = object;
|
||||
this.serializer = function;
|
||||
@@ -258,7 +293,7 @@
|
||||
@@ -258,7 +294,7 @@
|
||||
Properties properties = Settings.this.cloneProperties();
|
||||
|
||||
properties.put(this.key, this.serializer.apply(value));
|
||||
|
@@ -91,7 +91,7 @@
|
||||
+
|
||||
+ // Add env and gen to constructor, IWorldDataServer -> WorldDataServer
|
||||
+ public ServerLevel(MinecraftServer minecraftserver, Executor executor, LevelStorageSource.LevelStorageAccess convertable_conversionsession, PrimaryLevelData iworlddataserver, ResourceKey<Level> resourcekey, LevelStem worlddimension, ChunkProgressListener worldloadlistener, boolean flag, long i, List<CustomSpawner> list, boolean flag1, @Nullable RandomSequences randomsequences, org.bukkit.World.Environment env, org.bukkit.generator.ChunkGenerator gen, org.bukkit.generator.BiomeProvider biomeProvider) {
|
||||
+ super(iworlddataserver, resourcekey, minecraftserver.registryAccess(), worlddimension.type(), false, flag, i, minecraftserver.getMaxChainedNeighborUpdates(), gen, biomeProvider, env);
|
||||
+ super(iworlddataserver, resourcekey, minecraftserver.registryAccess(), worlddimension.type(), false, flag, i, minecraftserver.getMaxChainedNeighborUpdates(), gen, biomeProvider, env, spigotConfig -> minecraftserver.paperConfigurations.createWorldConfig(io.papermc.paper.configuration.PaperConfigurations.createWorldContextMap(convertable_conversionsession.levelDirectory.path(), iworlddataserver.getLevelName(), resourcekey.location(), spigotConfig, minecraftserver.registryAccess(), iworlddataserver.getGameRules()))); // Paper - create paper world configs
|
||||
+ this.pvpMode = minecraftserver.isPvpAllowed();
|
||||
+ this.convertable = convertable_conversionsession;
|
||||
+ this.uuid = WorldUUID.getUUID(convertable_conversionsession.levelDirectory.path().toFile());
|
||||
|
@@ -57,7 +57,7 @@
|
||||
public abstract class Level implements LevelAccessor, AutoCloseable {
|
||||
|
||||
public static final Codec<ResourceKey<Level>> RESOURCE_KEY_CODEC = ResourceKey.codec(Registries.DIMENSION);
|
||||
@@ -121,23 +144,66 @@
|
||||
@@ -121,23 +144,73 @@
|
||||
private final DamageSources damageSources;
|
||||
private long subTickCount;
|
||||
|
||||
@@ -81,6 +81,12 @@
|
||||
+ public final it.unimi.dsi.fastutil.objects.Object2LongOpenHashMap<SpawnCategory> ticksPerSpawnCategory = new it.unimi.dsi.fastutil.objects.Object2LongOpenHashMap<>();
|
||||
+ public boolean populating;
|
||||
+ public final org.spigotmc.SpigotWorldConfig spigotConfig; // Spigot
|
||||
+ // Paper start - add paper world config
|
||||
+ private final io.papermc.paper.configuration.WorldConfiguration paperConfig;
|
||||
+ public io.papermc.paper.configuration.WorldConfiguration paperConfig() {
|
||||
+ return this.paperConfig;
|
||||
+ }
|
||||
+ // Paper end - add paper world config
|
||||
+
|
||||
+ public final SpigotTimings.WorldTimingsHandler timings; // Spigot
|
||||
+ public static BlockPos lastPhysicsProblem; // Spigot
|
||||
@@ -98,8 +104,9 @@
|
||||
+
|
||||
+ public abstract ResourceKey<LevelStem> getTypeKey();
|
||||
+
|
||||
+ protected Level(WritableLevelData worlddatamutable, ResourceKey<Level> resourcekey, RegistryAccess iregistrycustom, Holder<DimensionType> holder, boolean flag, boolean flag1, long i, int j, org.bukkit.generator.ChunkGenerator gen, org.bukkit.generator.BiomeProvider biomeProvider, org.bukkit.World.Environment env) {
|
||||
+ protected Level(WritableLevelData worlddatamutable, ResourceKey<Level> resourcekey, RegistryAccess iregistrycustom, Holder<DimensionType> holder, boolean flag, boolean flag1, long i, int j, org.bukkit.generator.ChunkGenerator gen, org.bukkit.generator.BiomeProvider biomeProvider, org.bukkit.World.Environment env, java.util.function.Function<org.spigotmc.SpigotWorldConfig, io.papermc.paper.configuration.WorldConfiguration> paperWorldConfigCreator) { // Paper - create paper world config
|
||||
+ this.spigotConfig = new org.spigotmc.SpigotWorldConfig(((net.minecraft.world.level.storage.PrimaryLevelData) worlddatamutable).getLevelName()); // Spigot
|
||||
+ this.paperConfig = paperWorldConfigCreator.apply(this.spigotConfig); // Paper - create paper world config
|
||||
+ this.generator = gen;
|
||||
+ this.world = new CraftWorld((ServerLevel) this, gen, biomeProvider, env);
|
||||
+
|
||||
@@ -133,7 +140,7 @@
|
||||
}
|
||||
};
|
||||
} else {
|
||||
@@ -145,11 +211,50 @@
|
||||
@@ -145,11 +218,50 @@
|
||||
}
|
||||
|
||||
this.thread = Thread.currentThread();
|
||||
@@ -189,7 +196,7 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -207,6 +312,18 @@
|
||||
@@ -207,6 +319,18 @@
|
||||
|
||||
@Override
|
||||
public boolean setBlock(BlockPos pos, BlockState state, int flags, int maxUpdateDepth) {
|
||||
@@ -208,7 +215,7 @@
|
||||
if (this.isOutsideBuildHeight(pos)) {
|
||||
return false;
|
||||
} else if (!this.isClientSide && this.isDebug()) {
|
||||
@@ -214,45 +331,124 @@
|
||||
@@ -214,45 +338,124 @@
|
||||
} else {
|
||||
LevelChunk chunk = this.getChunkAt(pos);
|
||||
Block block = state.getBlock();
|
||||
@@ -348,7 +355,7 @@
|
||||
public void onBlockStateChange(BlockPos pos, BlockState oldBlock, BlockState newBlock) {}
|
||||
|
||||
@Override
|
||||
@@ -340,6 +536,14 @@
|
||||
@@ -340,6 +543,14 @@
|
||||
|
||||
@Override
|
||||
public BlockState getBlockState(BlockPos pos) {
|
||||
@@ -363,7 +370,7 @@
|
||||
if (this.isOutsideBuildHeight(pos)) {
|
||||
return Blocks.VOID_AIR.defaultBlockState();
|
||||
} else {
|
||||
@@ -440,32 +644,48 @@
|
||||
@@ -440,32 +651,48 @@
|
||||
ProfilerFiller gameprofilerfiller = Profiler.get();
|
||||
|
||||
gameprofilerfiller.push("blockEntities");
|
||||
@@ -416,15 +423,15 @@
|
||||
} catch (Throwable throwable) {
|
||||
CrashReport crashreport = CrashReport.forThrowable(throwable, "Ticking entity");
|
||||
CrashReportCategory crashreportsystemdetails = crashreport.addCategory("Entity being ticked");
|
||||
@@ -510,13 +730,29 @@
|
||||
@@ -510,13 +737,29 @@
|
||||
@Nullable
|
||||
@Override
|
||||
public BlockEntity getBlockEntity(BlockPos pos) {
|
||||
- return this.isOutsideBuildHeight(pos) ? null : (!this.isClientSide && Thread.currentThread() != this.thread ? null : this.getChunkAt(pos).getBlockEntity(pos, LevelChunk.EntityCreationType.IMMEDIATE));
|
||||
+ // CraftBukkit start
|
||||
+ return this.getBlockEntity(pos, true);
|
||||
+ }
|
||||
+
|
||||
}
|
||||
|
||||
+ @Nullable
|
||||
+ public BlockEntity getBlockEntity(BlockPos blockposition, boolean validate) {
|
||||
+ if (this.capturedTileEntities.containsKey(blockposition)) {
|
||||
@@ -432,8 +439,8 @@
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+ return this.isOutsideBuildHeight(blockposition) ? null : (!this.isClientSide && Thread.currentThread() != this.thread ? null : this.getChunkAt(blockposition).getBlockEntity(blockposition, LevelChunk.EntityCreationType.IMMEDIATE));
|
||||
}
|
||||
|
||||
+ }
|
||||
+
|
||||
public void setBlockEntity(BlockEntity blockEntity) {
|
||||
BlockPos blockposition = blockEntity.getBlockPos();
|
||||
|
||||
@@ -447,7 +454,7 @@
|
||||
this.getChunkAt(blockposition).addAndRegisterBlockEntity(blockEntity);
|
||||
}
|
||||
}
|
||||
@@ -643,7 +879,7 @@
|
||||
@@ -643,7 +886,7 @@
|
||||
|
||||
for (int k = 0; k < j; ++k) {
|
||||
EnderDragonPart entitycomplexpart = aentitycomplexpart[k];
|
||||
@@ -456,7 +463,7 @@
|
||||
|
||||
if (t0 != null && predicate.test(t0)) {
|
||||
result.add(t0);
|
||||
@@ -912,7 +1148,7 @@
|
||||
@@ -912,7 +1155,7 @@
|
||||
|
||||
public static enum ExplosionInteraction implements StringRepresentable {
|
||||
|
||||
|
Reference in New Issue
Block a user