@@ -0,0 +1,23 @@
|
||||
--- a/net/minecraft/server/AdvancementDataPlayer.java
|
||||
+++ b/net/minecraft/server/AdvancementDataPlayer.java
|
||||
@@ -163,7 +163,11 @@
|
||||
Advancement advancement = advancementdataworld.a((MinecraftKey) entry.getKey());
|
||||
|
||||
if (advancement == null) {
|
||||
- AdvancementDataPlayer.LOGGER.warn("Ignored advancement '{}' in progress file {} - it doesn't exist anymore?", entry.getKey(), this.f);
|
||||
+ // CraftBukkit start
|
||||
+ if (entry.getKey().getNamespace().equals("minecraft")) {
|
||||
+ AdvancementDataPlayer.LOGGER.warn("Ignored advancement '{}' in progress file {} - it doesn't exist anymore?", entry.getKey(), this.f);
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
} else {
|
||||
this.a(advancement, (AdvancementProgress) entry.getValue());
|
||||
}
|
||||
@@ -278,6 +282,7 @@
|
||||
this.j.add(advancement);
|
||||
flag = true;
|
||||
if (!flag1 && advancementprogress.isDone()) {
|
||||
+ this.player.world.getServer().getPluginManager().callEvent(new org.bukkit.event.player.PlayerAdvancementDoneEvent(this.player.getBukkitEntity(), advancement.bukkit)); // CraftBukkit
|
||||
advancement.d().a(this.player);
|
||||
if (advancement.c() != null && advancement.c().i() && this.player.world.getGameRules().getBoolean(GameRules.ANNOUNCE_ADVANCEMENTS)) {
|
||||
this.e.sendMessage(new ChatMessage("chat.type.advancement." + advancement.c().e().a(), new Object[]{this.player.getScoreboardDisplayName(), advancement.j()}), ChatMessageType.SYSTEM, SystemUtils.b);
|
||||
@@ -0,0 +1,11 @@
|
||||
--- a/net/minecraft/server/CustomFunctionData.java
|
||||
+++ b/net/minecraft/server/CustomFunctionData.java
|
||||
@@ -30,7 +30,7 @@
|
||||
}
|
||||
|
||||
public com.mojang.brigadier.CommandDispatcher<CommandListenerWrapper> getCommandDispatcher() {
|
||||
- return this.server.getCommandDispatcher().a();
|
||||
+ return this.server.vanillaCommandDispatcher.a(); // CraftBukkit
|
||||
}
|
||||
|
||||
public void tick() {
|
||||
@@ -0,0 +1,72 @@
|
||||
--- a/net/minecraft/server/DispenserRegistry.java
|
||||
+++ b/net/minecraft/server/DispenserRegistry.java
|
||||
@@ -31,6 +31,69 @@
|
||||
TagStatic.b();
|
||||
d();
|
||||
}
|
||||
+ // CraftBukkit start - easier than fixing the decompile
|
||||
+ DataConverterFlattenData.map(1008, "{Name:'minecraft:oak_sign',Properties:{rotation:'0'}}", "{Name:'minecraft:standing_sign',Properties:{rotation:'0'}}");
|
||||
+ DataConverterFlattenData.map(1009, "{Name:'minecraft:oak_sign',Properties:{rotation:'1'}}", "{Name:'minecraft:standing_sign',Properties:{rotation:'1'}}");
|
||||
+ DataConverterFlattenData.map(1010, "{Name:'minecraft:oak_sign',Properties:{rotation:'2'}}", "{Name:'minecraft:standing_sign',Properties:{rotation:'2'}}");
|
||||
+ DataConverterFlattenData.map(1011, "{Name:'minecraft:oak_sign',Properties:{rotation:'3'}}", "{Name:'minecraft:standing_sign',Properties:{rotation:'3'}}");
|
||||
+ DataConverterFlattenData.map(1012, "{Name:'minecraft:oak_sign',Properties:{rotation:'4'}}", "{Name:'minecraft:standing_sign',Properties:{rotation:'4'}}");
|
||||
+ DataConverterFlattenData.map(1013, "{Name:'minecraft:oak_sign',Properties:{rotation:'5'}}", "{Name:'minecraft:standing_sign',Properties:{rotation:'5'}}");
|
||||
+ DataConverterFlattenData.map(1014, "{Name:'minecraft:oak_sign',Properties:{rotation:'6'}}", "{Name:'minecraft:standing_sign',Properties:{rotation:'6'}}");
|
||||
+ DataConverterFlattenData.map(1015, "{Name:'minecraft:oak_sign',Properties:{rotation:'7'}}", "{Name:'minecraft:standing_sign',Properties:{rotation:'7'}}");
|
||||
+ DataConverterFlattenData.map(1016, "{Name:'minecraft:oak_sign',Properties:{rotation:'8'}}", "{Name:'minecraft:standing_sign',Properties:{rotation:'8'}}");
|
||||
+ DataConverterFlattenData.map(1017, "{Name:'minecraft:oak_sign',Properties:{rotation:'9'}}", "{Name:'minecraft:standing_sign',Properties:{rotation:'9'}}");
|
||||
+ DataConverterFlattenData.map(1018, "{Name:'minecraft:oak_sign',Properties:{rotation:'10'}}", "{Name:'minecraft:standing_sign',Properties:{rotation:'10'}}");
|
||||
+ DataConverterFlattenData.map(1019, "{Name:'minecraft:oak_sign',Properties:{rotation:'11'}}", "{Name:'minecraft:standing_sign',Properties:{rotation:'11'}}");
|
||||
+ DataConverterFlattenData.map(1020, "{Name:'minecraft:oak_sign',Properties:{rotation:'12'}}", "{Name:'minecraft:standing_sign',Properties:{rotation:'12'}}");
|
||||
+ DataConverterFlattenData.map(1021, "{Name:'minecraft:oak_sign',Properties:{rotation:'13'}}", "{Name:'minecraft:standing_sign',Properties:{rotation:'13'}}");
|
||||
+ DataConverterFlattenData.map(1022, "{Name:'minecraft:oak_sign',Properties:{rotation:'14'}}", "{Name:'minecraft:standing_sign',Properties:{rotation:'14'}}");
|
||||
+ DataConverterFlattenData.map(1023, "{Name:'minecraft:oak_sign',Properties:{rotation:'15'}}", "{Name:'minecraft:standing_sign',Properties:{rotation:'15'}}");
|
||||
+ DataConverterMaterialId.ID_MAPPING.put(323, "minecraft:oak_sign");
|
||||
+
|
||||
+ DataConverterFlattenData.map(1440, "{Name:\'minecraft:portal\',Properties:{axis:\'x\'}}", new String[]{"{Name:\'minecraft:portal\',Properties:{axis:\'x\'}}"});
|
||||
+
|
||||
+ DataConverterMaterialId.ID_MAPPING.put(409, "minecraft:prismarine_shard");
|
||||
+ DataConverterMaterialId.ID_MAPPING.put(410, "minecraft:prismarine_crystals");
|
||||
+ DataConverterMaterialId.ID_MAPPING.put(411, "minecraft:rabbit");
|
||||
+ DataConverterMaterialId.ID_MAPPING.put(412, "minecraft:cooked_rabbit");
|
||||
+ DataConverterMaterialId.ID_MAPPING.put(413, "minecraft:rabbit_stew");
|
||||
+ DataConverterMaterialId.ID_MAPPING.put(414, "minecraft:rabbit_foot");
|
||||
+ DataConverterMaterialId.ID_MAPPING.put(415, "minecraft:rabbit_hide");
|
||||
+ DataConverterMaterialId.ID_MAPPING.put(416, "minecraft:armor_stand");
|
||||
+
|
||||
+ DataConverterMaterialId.ID_MAPPING.put(423, "minecraft:mutton");
|
||||
+ DataConverterMaterialId.ID_MAPPING.put(424, "minecraft:cooked_mutton");
|
||||
+ DataConverterMaterialId.ID_MAPPING.put(425, "minecraft:banner");
|
||||
+ DataConverterMaterialId.ID_MAPPING.put(426, "minecraft:end_crystal");
|
||||
+ DataConverterMaterialId.ID_MAPPING.put(427, "minecraft:spruce_door");
|
||||
+ DataConverterMaterialId.ID_MAPPING.put(428, "minecraft:birch_door");
|
||||
+ DataConverterMaterialId.ID_MAPPING.put(429, "minecraft:jungle_door");
|
||||
+ DataConverterMaterialId.ID_MAPPING.put(430, "minecraft:acacia_door");
|
||||
+ DataConverterMaterialId.ID_MAPPING.put(431, "minecraft:dark_oak_door");
|
||||
+ DataConverterMaterialId.ID_MAPPING.put(432, "minecraft:chorus_fruit");
|
||||
+ DataConverterMaterialId.ID_MAPPING.put(433, "minecraft:chorus_fruit_popped");
|
||||
+ DataConverterMaterialId.ID_MAPPING.put(434, "minecraft:beetroot");
|
||||
+ DataConverterMaterialId.ID_MAPPING.put(435, "minecraft:beetroot_seeds");
|
||||
+ DataConverterMaterialId.ID_MAPPING.put(436, "minecraft:beetroot_soup");
|
||||
+ DataConverterMaterialId.ID_MAPPING.put(437, "minecraft:dragon_breath");
|
||||
+ DataConverterMaterialId.ID_MAPPING.put(438, "minecraft:splash_potion");
|
||||
+ DataConverterMaterialId.ID_MAPPING.put(439, "minecraft:spectral_arrow");
|
||||
+ DataConverterMaterialId.ID_MAPPING.put(440, "minecraft:tipped_arrow");
|
||||
+ DataConverterMaterialId.ID_MAPPING.put(441, "minecraft:lingering_potion");
|
||||
+ DataConverterMaterialId.ID_MAPPING.put(442, "minecraft:shield");
|
||||
+ DataConverterMaterialId.ID_MAPPING.put(443, "minecraft:elytra");
|
||||
+ DataConverterMaterialId.ID_MAPPING.put(444, "minecraft:spruce_boat");
|
||||
+ DataConverterMaterialId.ID_MAPPING.put(445, "minecraft:birch_boat");
|
||||
+ DataConverterMaterialId.ID_MAPPING.put(446, "minecraft:jungle_boat");
|
||||
+ DataConverterMaterialId.ID_MAPPING.put(447, "minecraft:acacia_boat");
|
||||
+ DataConverterMaterialId.ID_MAPPING.put(448, "minecraft:dark_oak_boat");
|
||||
+ DataConverterMaterialId.ID_MAPPING.put(449, "minecraft:totem_of_undying");
|
||||
+ DataConverterMaterialId.ID_MAPPING.put(450, "minecraft:shulker_shell");
|
||||
+ DataConverterMaterialId.ID_MAPPING.put(452, "minecraft:iron_nugget");
|
||||
+ DataConverterMaterialId.ID_MAPPING.put(453, "minecraft:knowledge_book");
|
||||
+
|
||||
+ DataConverterSpawnEgg.ID_MAPPING[23] = "Arrow";
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
}
|
||||
}
|
||||
145
paper-server/nms-patches/net/minecraft/server/Main.patch
Normal file
145
paper-server/nms-patches/net/minecraft/server/Main.patch
Normal file
@@ -0,0 +1,145 @@
|
||||
--- a/net/minecraft/server/Main.java
|
||||
+++ b/net/minecraft/server/Main.java
|
||||
@@ -27,7 +27,8 @@
|
||||
|
||||
public Main() {}
|
||||
|
||||
- public static void main(String[] astring) {
|
||||
+ public static void main(final OptionSet optionset) { // CraftBukkit - replaces main(String[] astring)
|
||||
+ /* CraftBukkit start - Replace everything
|
||||
OptionParser optionparser = new OptionParser();
|
||||
OptionSpec<Void> optionspec = optionparser.accepts("nogui");
|
||||
OptionSpec<Void> optionspec1 = optionparser.accepts("initSettings", "Initializes 'server.properties' and 'eula.txt', then quits");
|
||||
@@ -51,20 +52,22 @@
|
||||
optionparser.printHelpOn(System.err);
|
||||
return;
|
||||
}
|
||||
+ */ // CraftBukkit end
|
||||
|
||||
+ try {
|
||||
CrashReport.h();
|
||||
DispenserRegistry.init();
|
||||
DispenserRegistry.c();
|
||||
SystemUtils.l();
|
||||
IRegistryCustom.Dimension iregistrycustom_dimension = IRegistryCustom.b();
|
||||
java.nio.file.Path java_nio_file_path = Paths.get("server.properties");
|
||||
- DedicatedServerSettings dedicatedserversettings = new DedicatedServerSettings(iregistrycustom_dimension, java_nio_file_path);
|
||||
+ DedicatedServerSettings dedicatedserversettings = new DedicatedServerSettings(iregistrycustom_dimension, optionset); // CraftBukkit - CLI argument support
|
||||
|
||||
dedicatedserversettings.save();
|
||||
java.nio.file.Path java_nio_file_path1 = Paths.get("eula.txt");
|
||||
EULA eula = new EULA(java_nio_file_path1);
|
||||
|
||||
- if (optionset.has(optionspec1)) {
|
||||
+ if (optionset.has("initSettings")) { // CraftBukkit
|
||||
Main.LOGGER.info("Initialized '{}' and '{}'", java_nio_file_path.toAbsolutePath(), java_nio_file_path1.toAbsolutePath());
|
||||
return;
|
||||
}
|
||||
@@ -74,24 +77,42 @@
|
||||
return;
|
||||
}
|
||||
|
||||
- File file = new File((String) optionset.valueOf(optionspec9));
|
||||
+ File file = (File) optionset.valueOf("universe"); // CraftBukkit
|
||||
YggdrasilAuthenticationService yggdrasilauthenticationservice = new YggdrasilAuthenticationService(Proxy.NO_PROXY);
|
||||
MinecraftSessionService minecraftsessionservice = yggdrasilauthenticationservice.createMinecraftSessionService();
|
||||
GameProfileRepository gameprofilerepository = yggdrasilauthenticationservice.createProfileRepository();
|
||||
UserCache usercache = new UserCache(gameprofilerepository, new File(file, MinecraftServer.b.getName()));
|
||||
- String s = (String) Optional.ofNullable(optionset.valueOf(optionspec10)).orElse(dedicatedserversettings.getProperties().levelName);
|
||||
+ // CraftBukkit start
|
||||
+ String s = (String) Optional.ofNullable(optionset.valueOf("world")).orElse(dedicatedserversettings.getProperties().levelName);
|
||||
Convertable convertable = Convertable.a(file.toPath());
|
||||
- Convertable.ConversionSession convertable_conversionsession = convertable.c(s);
|
||||
+ Convertable.ConversionSession convertable_conversionsession = convertable.c(s, WorldDimension.OVERWORLD);
|
||||
|
||||
MinecraftServer.convertWorld(convertable_conversionsession);
|
||||
DataPackConfiguration datapackconfiguration = convertable_conversionsession.e();
|
||||
- boolean flag = optionset.has(optionspec6);
|
||||
+ boolean flag = optionset.has("safeMode");
|
||||
|
||||
if (flag) {
|
||||
Main.LOGGER.warn("Safe mode active, only vanilla datapack will be loaded");
|
||||
}
|
||||
|
||||
ResourcePackRepository resourcepackrepository = new ResourcePackRepository(new ResourcePackSource[]{new ResourcePackSourceVanilla(), new ResourcePackSourceFolder(convertable_conversionsession.getWorldFolder(SavedFile.DATAPACKS).toFile(), PackSource.c)});
|
||||
+ // CraftBukkit start
|
||||
+ File bukkitDataPackFolder = new File(convertable_conversionsession.getWorldFolder(SavedFile.DATAPACKS).toFile(), "bukkit");
|
||||
+ if (!bukkitDataPackFolder.exists()) {
|
||||
+ bukkitDataPackFolder.mkdirs();
|
||||
+ }
|
||||
+ File mcMeta = new File(bukkitDataPackFolder, "pack.mcmeta");
|
||||
+ try {
|
||||
+ com.google.common.io.Files.write("{\n"
|
||||
+ + " \"pack\": {\n"
|
||||
+ + " \"description\": \"Data pack for resources provided by Bukkit plugins\",\n"
|
||||
+ + " \"pack_format\": " + SharedConstants.getGameVersion().getPackVersion() + "\n"
|
||||
+ + " }\n"
|
||||
+ + "}\n", mcMeta, com.google.common.base.Charsets.UTF_8);
|
||||
+ } catch (java.io.IOException ex) {
|
||||
+ throw new RuntimeException("Could not initialize Bukkit datapack", ex);
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
DataPackConfiguration datapackconfiguration1 = MinecraftServer.a(resourcepackrepository, datapackconfiguration == null ? DataPackConfiguration.a : datapackconfiguration, flag);
|
||||
CompletableFuture completablefuture = DataPackResources.a(resourcepackrepository.f(), CommandDispatcher.ServerType.DEDICATED, dedicatedserversettings.getProperties().functionPermissionLevel, SystemUtils.f(), Runnable::run);
|
||||
|
||||
@@ -106,6 +127,7 @@
|
||||
}
|
||||
|
||||
datapackresources.i();
|
||||
+ /*
|
||||
RegistryReadOps<NBTBase> registryreadops = RegistryReadOps.a((DynamicOps) DynamicOpsNBT.a, datapackresources.h(), iregistrycustom_dimension);
|
||||
Object object = convertable_conversionsession.a((DynamicOps) registryreadops, datapackconfiguration1);
|
||||
|
||||
@@ -133,21 +155,32 @@
|
||||
}
|
||||
|
||||
convertable_conversionsession.a((IRegistryCustom) iregistrycustom_dimension, (SaveData) object);
|
||||
+ */
|
||||
final DedicatedServer dedicatedserver = (DedicatedServer) MinecraftServer.a((thread) -> {
|
||||
- DedicatedServer dedicatedserver1 = new DedicatedServer(thread, iregistrycustom_dimension, convertable_conversionsession, resourcepackrepository, datapackresources, object, dedicatedserversettings, DataConverterRegistry.a(), minecraftsessionservice, gameprofilerepository, usercache, WorldLoadListenerLogger::new);
|
||||
+ DedicatedServer dedicatedserver1 = new DedicatedServer(optionset, datapackconfiguration1, thread, iregistrycustom_dimension, convertable_conversionsession, resourcepackrepository, datapackresources, null, dedicatedserversettings, DataConverterRegistry.a(), minecraftsessionservice, gameprofilerepository, usercache, WorldLoadListenerLogger::new);
|
||||
|
||||
+ /*
|
||||
dedicatedserver1.d((String) optionset.valueOf(optionspec8));
|
||||
dedicatedserver1.setPort((Integer) optionset.valueOf(optionspec11));
|
||||
dedicatedserver1.c(optionset.has(optionspec2));
|
||||
dedicatedserver1.b((String) optionset.valueOf(optionspec12));
|
||||
- boolean flag1 = !optionset.has(optionspec) && !optionset.valuesOf(nonoptionargumentspec).contains("nogui");
|
||||
+ */
|
||||
+ boolean flag1 = !optionset.has("nogui") && !optionset.nonOptionArguments().contains("nogui");
|
||||
|
||||
if (flag1 && !GraphicsEnvironment.isHeadless()) {
|
||||
dedicatedserver1.bd();
|
||||
}
|
||||
|
||||
+ if (optionset.has("port")) {
|
||||
+ int port = (Integer) optionset.valueOf("port");
|
||||
+ if (port > 0) {
|
||||
+ dedicatedserver1.setPort(port);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
return dedicatedserver1;
|
||||
});
|
||||
+ /* CraftBukkit start
|
||||
Thread thread = new Thread("Server Shutdown Thread") {
|
||||
public void run() {
|
||||
dedicatedserver.safeShutdown(true);
|
||||
@@ -156,14 +189,15 @@
|
||||
|
||||
thread.setUncaughtExceptionHandler(new DefaultUncaughtExceptionHandler(Main.LOGGER));
|
||||
Runtime.getRuntime().addShutdownHook(thread);
|
||||
+ */ // CraftBukkit end
|
||||
} catch (Exception exception1) {
|
||||
Main.LOGGER.fatal("Failed to start the minecraft server", exception1);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
- public static void convertWorld(Convertable.ConversionSession convertable_conversionsession, DataFixer datafixer, boolean flag, BooleanSupplier booleansupplier, ImmutableSet<ResourceKey<World>> immutableset) {
|
||||
- Main.LOGGER.info("Forcing world upgrade!");
|
||||
+ public static void convertWorld(Convertable.ConversionSession convertable_conversionsession, DataFixer datafixer, boolean flag, BooleanSupplier booleansupplier, ImmutableSet<ResourceKey<DimensionManager>> immutableset) { // CraftBukkit
|
||||
+ Main.LOGGER.info("Forcing world upgrade! {}", convertable_conversionsession.getLevelName()); // CraftBukkit
|
||||
WorldUpgrader worldupgrader = new WorldUpgrader(convertable_conversionsession, datafixer, immutableset, flag);
|
||||
IChatBaseComponent ichatbasecomponent = null;
|
||||
|
||||
@@ -0,0 +1,657 @@
|
||||
--- a/net/minecraft/server/MinecraftServer.java
|
||||
+++ b/net/minecraft/server/MinecraftServer.java
|
||||
@@ -55,6 +55,18 @@
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import com.mojang.serialization.DynamicOps;
|
||||
+import com.mojang.serialization.Lifecycle;
|
||||
+import com.google.common.collect.ImmutableSet;
|
||||
+import jline.console.ConsoleReader;
|
||||
+import joptsimple.OptionSet;
|
||||
+import org.bukkit.Bukkit;
|
||||
+import org.bukkit.craftbukkit.CraftServer;
|
||||
+import org.bukkit.craftbukkit.Main;
|
||||
+import org.bukkit.event.server.ServerLoadEvent;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTask> implements IMojangStatistics, ICommandListener, AutoCloseable {
|
||||
|
||||
public static final Logger LOGGER = LogManager.getLogger();
|
||||
@@ -124,6 +136,20 @@
|
||||
private final DefinedStructureManager ak;
|
||||
protected SaveData saveData;
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ public DataPackConfiguration datapackconfiguration;
|
||||
+ public org.bukkit.craftbukkit.CraftServer server;
|
||||
+ public OptionSet options;
|
||||
+ public org.bukkit.command.ConsoleCommandSender console;
|
||||
+ public org.bukkit.command.RemoteConsoleCommandSender remoteConsole;
|
||||
+ public ConsoleReader reader;
|
||||
+ public static int currentTick = (int) (System.currentTimeMillis() / 50);
|
||||
+ public java.util.Queue<Runnable> processQueue = new java.util.concurrent.ConcurrentLinkedQueue<Runnable>();
|
||||
+ public int autosavePeriod;
|
||||
+ public CommandDispatcher vanillaCommandDispatcher;
|
||||
+ private boolean forceTicks;
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
public static <S extends MinecraftServer> S a(Function<Thread, S> function) {
|
||||
AtomicReference<S> atomicreference = new AtomicReference();
|
||||
Thread thread = new Thread(() -> {
|
||||
@@ -133,21 +159,21 @@
|
||||
thread.setUncaughtExceptionHandler((thread1, throwable) -> {
|
||||
MinecraftServer.LOGGER.error(throwable);
|
||||
});
|
||||
- S s0 = (MinecraftServer) function.apply(thread);
|
||||
+ S s0 = function.apply(thread); // CraftBukkit - decompile error
|
||||
|
||||
atomicreference.set(s0);
|
||||
thread.start();
|
||||
return s0;
|
||||
}
|
||||
|
||||
- public MinecraftServer(Thread thread, IRegistryCustom.Dimension iregistrycustom_dimension, Convertable.ConversionSession convertable_conversionsession, SaveData savedata, ResourcePackRepository resourcepackrepository, Proxy proxy, DataFixer datafixer, DataPackResources datapackresources, MinecraftSessionService minecraftsessionservice, GameProfileRepository gameprofilerepository, UserCache usercache, WorldLoadListenerFactory worldloadlistenerfactory) {
|
||||
+ public MinecraftServer(OptionSet options, DataPackConfiguration datapackconfiguration, Thread thread, IRegistryCustom.Dimension iregistrycustom_dimension, Convertable.ConversionSession convertable_conversionsession, SaveData savedata, ResourcePackRepository resourcepackrepository, Proxy proxy, DataFixer datafixer, DataPackResources datapackresources, MinecraftSessionService minecraftsessionservice, GameProfileRepository gameprofilerepository, UserCache usercache, WorldLoadListenerFactory worldloadlistenerfactory) {
|
||||
super("Server");
|
||||
this.m = new GameProfilerSwitcher(SystemUtils.a, this::ai);
|
||||
this.methodProfiler = GameProfilerDisabled.a;
|
||||
this.serverPing = new ServerPing();
|
||||
this.r = new Random();
|
||||
this.serverPort = -1;
|
||||
- this.worldServer = Maps.newLinkedHashMap();
|
||||
+ this.worldServer = Maps.newLinkedHashMap(); // CraftBukkit - keep order, k+v already use identity methods
|
||||
this.isRunning = true;
|
||||
this.h = new long[100];
|
||||
this.K = "";
|
||||
@@ -173,7 +199,34 @@
|
||||
this.ak = new DefinedStructureManager(datapackresources.h(), convertable_conversionsession, datafixer);
|
||||
this.serverThread = thread;
|
||||
this.executorService = SystemUtils.f();
|
||||
+ // CraftBukkit start
|
||||
+ this.options = options;
|
||||
+ this.datapackconfiguration = datapackconfiguration;
|
||||
+ this.vanillaCommandDispatcher = datapackresources.commandDispatcher; // CraftBukkit
|
||||
+ // Try to see if we're actually running in a terminal, disable jline if not
|
||||
+ if (System.console() == null && System.getProperty("jline.terminal") == null) {
|
||||
+ System.setProperty("jline.terminal", "jline.UnsupportedTerminal");
|
||||
+ Main.useJline = false;
|
||||
+ }
|
||||
+
|
||||
+ try {
|
||||
+ reader = new ConsoleReader(System.in, System.out);
|
||||
+ reader.setExpandEvents(false); // Avoid parsing exceptions for uncommonly used event designators
|
||||
+ } catch (Throwable e) {
|
||||
+ try {
|
||||
+ // Try again with jline disabled for Windows users without C++ 2008 Redistributable
|
||||
+ System.setProperty("jline.terminal", "jline.UnsupportedTerminal");
|
||||
+ System.setProperty("user.language", "en");
|
||||
+ Main.useJline = false;
|
||||
+ reader = new ConsoleReader(System.in, System.out);
|
||||
+ reader.setExpandEvents(false);
|
||||
+ } catch (IOException ex) {
|
||||
+ LOGGER.warn((String) null, ex);
|
||||
+ }
|
||||
+ }
|
||||
+ Runtime.getRuntime().addShutdownHook(new org.bukkit.craftbukkit.util.ServerShutdownThread(this));
|
||||
}
|
||||
+ // CraftBukkit end
|
||||
|
||||
private void initializeScoreboards(WorldPersistentData worldpersistentdata) {
|
||||
PersistentScoreboard persistentscoreboard = (PersistentScoreboard) worldpersistentdata.a(PersistentScoreboard::new, "scoreboard");
|
||||
@@ -186,7 +239,7 @@
|
||||
|
||||
public static void convertWorld(Convertable.ConversionSession convertable_conversionsession) {
|
||||
if (convertable_conversionsession.isConvertable()) {
|
||||
- MinecraftServer.LOGGER.info("Converting map!");
|
||||
+ MinecraftServer.LOGGER.info("Converting map! {}", convertable_conversionsession.getLevelName()); // CraftBukkit
|
||||
convertable_conversionsession.convert(new IProgressUpdate() {
|
||||
private long a = SystemUtils.getMonotonicMillis();
|
||||
|
||||
@@ -209,45 +262,184 @@
|
||||
|
||||
}
|
||||
|
||||
- protected void loadWorld() {
|
||||
- this.loadResourcesZip();
|
||||
- this.saveData.a(this.getServerModName(), this.getModded().isPresent());
|
||||
- WorldLoadListener worldloadlistener = this.worldLoadListenerFactory.create(11);
|
||||
+ protected void loadWorld(String s) {
|
||||
+ int worldCount = 3;
|
||||
+
|
||||
+ for (int worldId = 0; worldId < worldCount; ++worldId) {
|
||||
+ WorldServer world;
|
||||
+ WorldDataServer worlddata;
|
||||
+ byte dimension = 0;
|
||||
+ ResourceKey<WorldDimension> dimensionKey = WorldDimension.OVERWORLD;
|
||||
+
|
||||
+ if (worldId == 1) {
|
||||
+ if (getAllowNether()) {
|
||||
+ dimension = -1;
|
||||
+ dimensionKey = WorldDimension.THE_NETHER;
|
||||
+ } else {
|
||||
+ continue;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ if (worldId == 2) {
|
||||
+ if (server.getAllowEnd()) {
|
||||
+ dimension = 1;
|
||||
+ dimensionKey = WorldDimension.THE_END;
|
||||
+ } else {
|
||||
+ continue;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ String worldType = org.bukkit.World.Environment.getEnvironment(dimension).toString().toLowerCase();
|
||||
+ String name = (dimension == 0) ? s : s + "_" + worldType;
|
||||
+ Convertable.ConversionSession worldSession;
|
||||
+ if (dimension == 0) {
|
||||
+ worldSession = this.convertable;
|
||||
+ } else {
|
||||
+ String dim = "DIM" + dimension;
|
||||
+
|
||||
+ File newWorld = new File(new File(name), dim);
|
||||
+ File oldWorld = new File(new File(s), dim);
|
||||
+ File oldLevelDat = new File(new File(s), "level.dat"); // The data folders exist on first run as they are created in the PersistentCollection constructor above, but the level.dat won't
|
||||
+
|
||||
+ if (!newWorld.isDirectory() && oldWorld.isDirectory() && oldLevelDat.isFile()) {
|
||||
+ MinecraftServer.LOGGER.info("---- Migration of old " + worldType + " folder required ----");
|
||||
+ MinecraftServer.LOGGER.info("Unfortunately due to the way that Minecraft implemented multiworld support in 1.6, Bukkit requires that you move your " + worldType + " folder to a new location in order to operate correctly.");
|
||||
+ MinecraftServer.LOGGER.info("We will move this folder for you, but it will mean that you need to move it back should you wish to stop using Bukkit in the future.");
|
||||
+ MinecraftServer.LOGGER.info("Attempting to move " + oldWorld + " to " + newWorld + "...");
|
||||
+
|
||||
+ if (newWorld.exists()) {
|
||||
+ MinecraftServer.LOGGER.warn("A file or folder already exists at " + newWorld + "!");
|
||||
+ MinecraftServer.LOGGER.info("---- Migration of old " + worldType + " folder failed ----");
|
||||
+ } else if (newWorld.getParentFile().mkdirs()) {
|
||||
+ if (oldWorld.renameTo(newWorld)) {
|
||||
+ MinecraftServer.LOGGER.info("Success! To restore " + worldType + " in the future, simply move " + newWorld + " to " + oldWorld);
|
||||
+ // Migrate world data too.
|
||||
+ try {
|
||||
+ com.google.common.io.Files.copy(oldLevelDat, new File(new File(name), "level.dat"));
|
||||
+ org.apache.commons.io.FileUtils.copyDirectory(new File(new File(s), "data"), new File(new File(name), "data"));
|
||||
+ } catch (IOException exception) {
|
||||
+ MinecraftServer.LOGGER.warn("Unable to migrate world data.");
|
||||
+ }
|
||||
+ MinecraftServer.LOGGER.info("---- Migration of old " + worldType + " folder complete ----");
|
||||
+ } else {
|
||||
+ MinecraftServer.LOGGER.warn("Could not move folder " + oldWorld + " to " + newWorld + "!");
|
||||
+ MinecraftServer.LOGGER.info("---- Migration of old " + worldType + " folder failed ----");
|
||||
+ }
|
||||
+ } else {
|
||||
+ MinecraftServer.LOGGER.warn("Could not create path for " + newWorld + "!");
|
||||
+ MinecraftServer.LOGGER.info("---- Migration of old " + worldType + " folder failed ----");
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ try {
|
||||
+ worldSession = Convertable.a(server.getWorldContainer().toPath()).c(name, dimensionKey);
|
||||
+ } catch (IOException ex) {
|
||||
+ throw new RuntimeException(ex);
|
||||
+ }
|
||||
+ MinecraftServer.convertWorld(worldSession); // Run conversion now
|
||||
+ }
|
||||
|
||||
- this.a(worldloadlistener);
|
||||
+ org.bukkit.generator.ChunkGenerator gen = this.server.getGenerator(name);
|
||||
+
|
||||
+ IRegistryCustom.Dimension iregistrycustom_dimension = this.customRegistry;
|
||||
+
|
||||
+ RegistryReadOps<NBTBase> registryreadops = RegistryReadOps.a((DynamicOps) DynamicOpsNBT.a, this.dataPackResources.h(), iregistrycustom_dimension);
|
||||
+ worlddata = (WorldDataServer) worldSession.a((DynamicOps) registryreadops, datapackconfiguration);
|
||||
+ if (worlddata == null) {
|
||||
+ WorldSettings worldsettings;
|
||||
+ GeneratorSettings generatorsettings;
|
||||
+
|
||||
+ if (this.isDemoMode()) {
|
||||
+ worldsettings = MinecraftServer.c;
|
||||
+ generatorsettings = GeneratorSettings.a((IRegistryCustom) iregistrycustom_dimension);
|
||||
+ } else {
|
||||
+ DedicatedServerProperties dedicatedserverproperties = ((DedicatedServer) this).getDedicatedServerProperties();
|
||||
+
|
||||
+ worldsettings = new WorldSettings(dedicatedserverproperties.levelName, dedicatedserverproperties.gamemode, dedicatedserverproperties.hardcore, dedicatedserverproperties.difficulty, false, new GameRules(), datapackconfiguration);
|
||||
+ generatorsettings = options.has("bonusChest") ? dedicatedserverproperties.generatorSettings.j() : dedicatedserverproperties.generatorSettings;
|
||||
+ }
|
||||
+
|
||||
+ worlddata = new WorldDataServer(worldsettings, generatorsettings, Lifecycle.stable());
|
||||
+ }
|
||||
+ worlddata.checkName(name); // CraftBukkit - Migration did not rewrite the level.dat; This forces 1.8 to take the last loaded world as respawn (in this case the end)
|
||||
+ if (options.has("forceUpgrade")) {
|
||||
+ net.minecraft.server.Main.convertWorld(worldSession, DataConverterRegistry.a(), options.has("eraseCache"), () -> {
|
||||
+ return true;
|
||||
+ }, worlddata.getGeneratorSettings().d().d().stream().map((entry) -> {
|
||||
+ return ResourceKey.a(IRegistry.K, ((ResourceKey) entry.getKey()).a());
|
||||
+ }).collect(ImmutableSet.toImmutableSet()));
|
||||
+ }
|
||||
+
|
||||
+ IWorldDataServer iworlddataserver = worlddata;
|
||||
+ GeneratorSettings generatorsettings = worlddata.getGeneratorSettings();
|
||||
+ boolean flag = generatorsettings.isDebugWorld();
|
||||
+ long i = generatorsettings.getSeed();
|
||||
+ long j = BiomeManager.a(i);
|
||||
+ List<MobSpawner> list = ImmutableList.of(new MobSpawnerPhantom(), new MobSpawnerPatrol(), new MobSpawnerCat(), new VillageSiege(), new MobSpawnerTrader(iworlddataserver));
|
||||
+ RegistryMaterials<WorldDimension> registrymaterials = generatorsettings.d();
|
||||
+ WorldDimension worlddimension = (WorldDimension) registrymaterials.a(dimensionKey);
|
||||
+ DimensionManager dimensionmanager;
|
||||
+ ChunkGenerator chunkgenerator;
|
||||
+
|
||||
+ if (worlddimension == null) {
|
||||
+ dimensionmanager = (DimensionManager) this.customRegistry.a().d(DimensionManager.OVERWORLD);
|
||||
+ chunkgenerator = GeneratorSettings.a(customRegistry.b(IRegistry.ay), customRegistry.b(IRegistry.ar), (new Random()).nextLong());
|
||||
+ } else {
|
||||
+ dimensionmanager = worlddimension.b();
|
||||
+ chunkgenerator = worlddimension.c();
|
||||
+ }
|
||||
+
|
||||
+ ResourceKey<World> worldKey = ResourceKey.a(IRegistry.L, dimensionKey.a());
|
||||
+
|
||||
+ if (worldId == 0) {
|
||||
+ this.saveData = worlddata;
|
||||
+ this.saveData.setGameType(((DedicatedServer) this).getDedicatedServerProperties().gamemode); // From DedicatedServer.init
|
||||
+
|
||||
+ WorldLoadListener worldloadlistener = this.worldLoadListenerFactory.create(11);
|
||||
+
|
||||
+ world = new WorldServer(this, this.executorService, worldSession, iworlddataserver, worldKey, dimensionmanager, worldloadlistener, chunkgenerator, flag, j, list, true, org.bukkit.World.Environment.getEnvironment(dimension), gen);
|
||||
+ WorldPersistentData worldpersistentdata = world.getWorldPersistentData();
|
||||
+ this.initializeScoreboards(worldpersistentdata);
|
||||
+ this.server.scoreboardManager = new org.bukkit.craftbukkit.scoreboard.CraftScoreboardManager(this, world.getScoreboard());
|
||||
+ this.persistentCommandStorage = new PersistentCommandStorage(worldpersistentdata);
|
||||
+ } else {
|
||||
+ WorldLoadListener worldloadlistener = this.worldLoadListenerFactory.create(11);
|
||||
+ world = new WorldServer(this, this.executorService, worldSession, iworlddataserver, worldKey, dimensionmanager, worldloadlistener, chunkgenerator, flag, j, ImmutableList.of(), true, org.bukkit.World.Environment.getEnvironment(dimension), gen);
|
||||
+ }
|
||||
+
|
||||
+ worlddata.a(this.getServerModName(), this.getModded().isPresent());
|
||||
+ this.initWorld(world, worlddata, saveData, worlddata.getGeneratorSettings());
|
||||
+ this.server.getPluginManager().callEvent(new org.bukkit.event.world.WorldInitEvent(world.getWorld()));
|
||||
+
|
||||
+ this.worldServer.put(world.getDimensionKey(), world);
|
||||
+ this.getPlayerList().setPlayerFileData(world);
|
||||
+
|
||||
+ if (worlddata.getCustomBossEvents() != null) {
|
||||
+ this.getBossBattleCustomData().load(worlddata.getCustomBossEvents());
|
||||
+ }
|
||||
+ }
|
||||
this.updateWorldSettings();
|
||||
- this.loadSpawn(worldloadlistener);
|
||||
+ for (WorldServer worldserver : this.getWorlds()) {
|
||||
+ this.loadSpawn(worldserver.getChunkProvider().playerChunkMap.worldLoadListener, worldserver);
|
||||
+ this.server.getPluginManager().callEvent(new org.bukkit.event.world.WorldLoadEvent(worldserver.getWorld()));
|
||||
+ }
|
||||
+
|
||||
+ this.server.enablePlugins(org.bukkit.plugin.PluginLoadOrder.POSTWORLD);
|
||||
+ this.server.getPluginManager().callEvent(new ServerLoadEvent(ServerLoadEvent.LoadType.STARTUP));
|
||||
+ this.serverConnection.acceptConnections();
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
}
|
||||
|
||||
protected void updateWorldSettings() {}
|
||||
|
||||
- protected void a(WorldLoadListener worldloadlistener) {
|
||||
- IWorldDataServer iworlddataserver = this.saveData.H();
|
||||
- GeneratorSettings generatorsettings = this.saveData.getGeneratorSettings();
|
||||
+ // CraftBukkit start
|
||||
+ public void initWorld(WorldServer worldserver, IWorldDataServer iworlddataserver, SaveData saveData, GeneratorSettings generatorsettings) {
|
||||
boolean flag = generatorsettings.isDebugWorld();
|
||||
- long i = generatorsettings.getSeed();
|
||||
- long j = BiomeManager.a(i);
|
||||
- List<MobSpawner> list = ImmutableList.of(new MobSpawnerPhantom(), new MobSpawnerPatrol(), new MobSpawnerCat(), new VillageSiege(), new MobSpawnerTrader(iworlddataserver));
|
||||
- RegistryMaterials<WorldDimension> registrymaterials = generatorsettings.d();
|
||||
- WorldDimension worlddimension = (WorldDimension) registrymaterials.a(WorldDimension.OVERWORLD);
|
||||
- DimensionManager dimensionmanager;
|
||||
- Object object;
|
||||
-
|
||||
- if (worlddimension == null) {
|
||||
- dimensionmanager = (DimensionManager) this.customRegistry.a().d(DimensionManager.OVERWORLD);
|
||||
- object = GeneratorSettings.a(this.customRegistry.b(IRegistry.ay), this.customRegistry.b(IRegistry.ar), (new Random()).nextLong());
|
||||
- } else {
|
||||
- dimensionmanager = worlddimension.b();
|
||||
- object = worlddimension.c();
|
||||
+ // CraftBukkit start
|
||||
+ if (worldserver.generator != null) {
|
||||
+ worldserver.getWorld().getPopulators().addAll(worldserver.generator.getDefaultPopulators(worldserver.getWorld()));
|
||||
}
|
||||
-
|
||||
- WorldServer worldserver = new WorldServer(this, this.executorService, this.convertable, iworlddataserver, World.OVERWORLD, dimensionmanager, worldloadlistener, (ChunkGenerator) object, flag, j, list, true);
|
||||
-
|
||||
- this.worldServer.put(World.OVERWORLD, worldserver);
|
||||
- WorldPersistentData worldpersistentdata = worldserver.getWorldPersistentData();
|
||||
-
|
||||
- this.initializeScoreboards(worldpersistentdata);
|
||||
- this.persistentCommandStorage = new PersistentCommandStorage(worldpersistentdata);
|
||||
WorldBorder worldborder = worldserver.getWorldBorder();
|
||||
|
||||
worldborder.a(iworlddataserver.r());
|
||||
@@ -272,31 +464,8 @@
|
||||
|
||||
iworlddataserver.c(true);
|
||||
}
|
||||
-
|
||||
- this.getPlayerList().setPlayerFileData(worldserver);
|
||||
- if (this.saveData.getCustomBossEvents() != null) {
|
||||
- this.getBossBattleCustomData().load(this.saveData.getCustomBossEvents());
|
||||
- }
|
||||
-
|
||||
- Iterator iterator = registrymaterials.d().iterator();
|
||||
-
|
||||
- while (iterator.hasNext()) {
|
||||
- Entry<ResourceKey<WorldDimension>, WorldDimension> entry = (Entry) iterator.next();
|
||||
- ResourceKey<WorldDimension> resourcekey = (ResourceKey) entry.getKey();
|
||||
-
|
||||
- if (resourcekey != WorldDimension.OVERWORLD) {
|
||||
- ResourceKey<World> resourcekey1 = ResourceKey.a(IRegistry.L, resourcekey.a());
|
||||
- DimensionManager dimensionmanager1 = ((WorldDimension) entry.getValue()).b();
|
||||
- ChunkGenerator chunkgenerator = ((WorldDimension) entry.getValue()).c();
|
||||
- SecondaryWorldData secondaryworlddata = new SecondaryWorldData(this.saveData, iworlddataserver);
|
||||
- WorldServer worldserver1 = new WorldServer(this, this.executorService, this.convertable, secondaryworlddata, resourcekey1, dimensionmanager1, worldloadlistener, chunkgenerator, flag, j, ImmutableList.of(), false);
|
||||
-
|
||||
- worldborder.a((IWorldBorderListener) (new IWorldBorderListener.a(worldserver1.getWorldBorder())));
|
||||
- this.worldServer.put(resourcekey1, worldserver1);
|
||||
- }
|
||||
- }
|
||||
-
|
||||
}
|
||||
+ // CraftBukkit end
|
||||
|
||||
private static void a(WorldServer worldserver, IWorldDataServer iworlddataserver, boolean flag, boolean flag1, boolean flag2) {
|
||||
ChunkGenerator chunkgenerator = worldserver.getChunkProvider().getChunkGenerator();
|
||||
@@ -312,6 +481,21 @@
|
||||
return biomebase.b().b();
|
||||
}, random);
|
||||
ChunkCoordIntPair chunkcoordintpair = blockposition == null ? new ChunkCoordIntPair(0, 0) : new ChunkCoordIntPair(blockposition);
|
||||
+ // CraftBukkit start
|
||||
+ if (worldserver.generator != null) {
|
||||
+ Random rand = new Random(worldserver.getSeed());
|
||||
+ org.bukkit.Location spawn = worldserver.generator.getFixedSpawnLocation(worldserver.getWorld(), rand);
|
||||
+
|
||||
+ if (spawn != null) {
|
||||
+ if (spawn.getWorld() != worldserver.getWorld()) {
|
||||
+ throw new IllegalStateException("Cannot set spawn point for " + iworlddataserver.getName() + " to be in another world (" + spawn.getWorld().getName() + ")");
|
||||
+ } else {
|
||||
+ iworlddataserver.setSpawn(new BlockPosition(spawn.getBlockX(), spawn.getBlockY(), spawn.getBlockZ()), spawn.getYaw());
|
||||
+ return;
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
|
||||
if (blockposition == null) {
|
||||
MinecraftServer.LOGGER.warn("Unable to find spawn biome");
|
||||
@@ -378,8 +562,15 @@
|
||||
iworlddataserver.setGameType(EnumGamemode.SPECTATOR);
|
||||
}
|
||||
|
||||
- public void loadSpawn(WorldLoadListener worldloadlistener) {
|
||||
- WorldServer worldserver = this.E();
|
||||
+ // CraftBukkit start
|
||||
+ public void loadSpawn(WorldLoadListener worldloadlistener, WorldServer worldserver) {
|
||||
+ if (!worldserver.getWorld().getKeepSpawnInMemory()) {
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ // WorldServer worldserver = this.E();
|
||||
+ this.forceTicks = true;
|
||||
+ // CraftBukkit end
|
||||
|
||||
MinecraftServer.LOGGER.info("Preparing start region for dimension {}", worldserver.getDimensionKey().a());
|
||||
BlockPosition blockposition = worldserver.getSpawn();
|
||||
@@ -392,17 +583,21 @@
|
||||
chunkproviderserver.addTicket(TicketType.START, new ChunkCoordIntPair(blockposition), 11, Unit.INSTANCE);
|
||||
|
||||
while (chunkproviderserver.b() != 441) {
|
||||
- this.nextTick = SystemUtils.getMonotonicMillis() + 10L;
|
||||
- this.sleepForTick();
|
||||
+ // CraftBukkit start
|
||||
+ // this.nextTick = SystemUtils.getMonotonicMillis() + 10L;
|
||||
+ this.executeModerately();
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
- this.nextTick = SystemUtils.getMonotonicMillis() + 10L;
|
||||
- this.sleepForTick();
|
||||
- Iterator iterator = this.worldServer.values().iterator();
|
||||
-
|
||||
- while (iterator.hasNext()) {
|
||||
- WorldServer worldserver1 = (WorldServer) iterator.next();
|
||||
- ForcedChunk forcedchunk = (ForcedChunk) worldserver1.getWorldPersistentData().b(ForcedChunk::new, "chunks");
|
||||
+ // CraftBukkit start
|
||||
+ // this.nextTick = SystemUtils.getMonotonicMillis() + 10L;
|
||||
+ this.executeModerately();
|
||||
+ // Iterator iterator = this.worldServer.values().iterator();
|
||||
+
|
||||
+ if (true) {
|
||||
+ WorldServer worldserver1 = worldserver;
|
||||
+ ForcedChunk forcedchunk = (ForcedChunk) worldserver.getWorldPersistentData().b(ForcedChunk::new, "chunks");
|
||||
+ // CraftBukkit end
|
||||
|
||||
if (forcedchunk != null) {
|
||||
LongIterator longiterator = forcedchunk.a().iterator();
|
||||
@@ -416,11 +611,18 @@
|
||||
}
|
||||
}
|
||||
|
||||
- this.nextTick = SystemUtils.getMonotonicMillis() + 10L;
|
||||
- this.sleepForTick();
|
||||
+ // CraftBukkit start
|
||||
+ // this.nextTick = SystemUtils.getMonotonicMillis() + 10L;
|
||||
+ this.executeModerately();
|
||||
+ // CraftBukkit end
|
||||
worldloadlistener.b();
|
||||
chunkproviderserver.getLightEngine().a(5);
|
||||
- this.updateSpawnFlags();
|
||||
+ // CraftBukkit start
|
||||
+ // this.updateSpawnFlags();
|
||||
+ worldserver.setSpawnFlags(this.getSpawnMonsters(), this.getSpawnAnimals());
|
||||
+
|
||||
+ this.forceTicks = false;
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
protected void loadResourcesZip() {
|
||||
@@ -465,12 +667,16 @@
|
||||
worldserver.save((IProgressUpdate) null, flag1, worldserver.savingDisabled && !flag2);
|
||||
}
|
||||
|
||||
+ // CraftBukkit start - moved to WorldServer.save
|
||||
+ /*
|
||||
WorldServer worldserver1 = this.E();
|
||||
IWorldDataServer iworlddataserver = this.saveData.H();
|
||||
|
||||
iworlddataserver.a(worldserver1.getWorldBorder().t());
|
||||
this.saveData.setCustomBossEvents(this.getBossBattleCustomData().save());
|
||||
this.convertable.a(this.customRegistry, this.saveData, this.getPlayerList().save());
|
||||
+ */
|
||||
+ // CraftBukkit end
|
||||
return flag3;
|
||||
}
|
||||
|
||||
@@ -479,8 +685,29 @@
|
||||
this.stop();
|
||||
}
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ private boolean hasStopped = false;
|
||||
+ private final Object stopLock = new Object();
|
||||
+ public final boolean hasStopped() {
|
||||
+ synchronized (stopLock) {
|
||||
+ return hasStopped;
|
||||
+ }
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
protected void stop() {
|
||||
+ // CraftBukkit start - prevent double stopping on multiple threads
|
||||
+ synchronized(stopLock) {
|
||||
+ if (hasStopped) return;
|
||||
+ hasStopped = true;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
MinecraftServer.LOGGER.info("Stopping server");
|
||||
+ // CraftBukkit start
|
||||
+ if (this.server != null) {
|
||||
+ this.server.disablePlugins();
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
if (this.getServerConnection() != null) {
|
||||
this.getServerConnection().b();
|
||||
}
|
||||
@@ -489,6 +716,7 @@
|
||||
MinecraftServer.LOGGER.info("Saving players");
|
||||
this.playerList.savePlayers();
|
||||
this.playerList.shutdown();
|
||||
+ try { Thread.sleep(100); } catch (InterruptedException ex) {} // CraftBukkit - SPIGOT-625 - give server at least a chance to send packets
|
||||
}
|
||||
|
||||
MinecraftServer.LOGGER.info("Saving worlds");
|
||||
@@ -566,14 +794,16 @@
|
||||
while (this.isRunning) {
|
||||
long i = SystemUtils.getMonotonicMillis() - this.nextTick;
|
||||
|
||||
- if (i > 2000L && this.nextTick - this.lastOverloadTime >= 15000L) {
|
||||
+ if (i > 5000L && this.nextTick - this.lastOverloadTime >= 30000L) { // CraftBukkit
|
||||
long j = i / 50L;
|
||||
|
||||
+ if (server.getWarnOnOverload()) // CraftBukkit
|
||||
MinecraftServer.LOGGER.warn("Can't keep up! Is the server overloaded? Running {}ms or {} ticks behind", i, j);
|
||||
this.nextTick += j * 50L;
|
||||
this.lastOverloadTime = this.nextTick;
|
||||
}
|
||||
|
||||
+ MinecraftServer.currentTick = (int) (System.currentTimeMillis() / 50); // CraftBukkit
|
||||
this.nextTick += 50L;
|
||||
GameProfilerTick gameprofilertick = GameProfilerTick.a("Server");
|
||||
|
||||
@@ -619,6 +849,12 @@
|
||||
} catch (Throwable throwable1) {
|
||||
MinecraftServer.LOGGER.error("Exception stopping the server", throwable1);
|
||||
} finally {
|
||||
+ // CraftBukkit start - Restore terminal to original settings
|
||||
+ try {
|
||||
+ reader.getTerminal().restore();
|
||||
+ } catch (Exception ignored) {
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
this.exit();
|
||||
}
|
||||
|
||||
@@ -627,8 +863,15 @@
|
||||
}
|
||||
|
||||
private boolean canSleepForTick() {
|
||||
- return this.isEntered() || SystemUtils.getMonotonicMillis() < (this.X ? this.W : this.nextTick);
|
||||
+ // CraftBukkit start
|
||||
+ return this.forceTicks || this.isEntered() || SystemUtils.getMonotonicMillis() < (this.X ? this.W : this.nextTick);
|
||||
+ }
|
||||
+
|
||||
+ private void executeModerately() {
|
||||
+ this.executeAll();
|
||||
+ java.util.concurrent.locks.LockSupport.parkNanos("executing tasks", 1000L);
|
||||
}
|
||||
+ // CraftBukkit end
|
||||
|
||||
protected void sleepForTick() {
|
||||
this.executeAll();
|
||||
@@ -734,7 +977,7 @@
|
||||
this.serverPing.b().a(agameprofile);
|
||||
}
|
||||
|
||||
- if (this.ticks % 6000 == 0) {
|
||||
+ if (autosavePeriod > 0 && this.ticks % autosavePeriod == 0) { // CraftBukkit
|
||||
MinecraftServer.LOGGER.debug("Autosave started");
|
||||
this.methodProfiler.enter("save");
|
||||
this.playerList.savePlayers();
|
||||
@@ -764,22 +1007,39 @@
|
||||
}
|
||||
|
||||
protected void b(BooleanSupplier booleansupplier) {
|
||||
+ this.server.getScheduler().mainThreadHeartbeat(this.ticks); // CraftBukkit
|
||||
this.methodProfiler.enter("commandFunctions");
|
||||
this.getFunctionData().tick();
|
||||
this.methodProfiler.exitEnter("levels");
|
||||
Iterator iterator = this.getWorlds().iterator();
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ // Run tasks that are waiting on processing
|
||||
+ while (!processQueue.isEmpty()) {
|
||||
+ processQueue.remove().run();
|
||||
+ }
|
||||
+
|
||||
+ // Send time updates to everyone, it will get the right time from the world the player is in.
|
||||
+ if (this.ticks % 20 == 0) {
|
||||
+ for (int i = 0; i < this.getPlayerList().players.size(); ++i) {
|
||||
+ EntityPlayer entityplayer = (EntityPlayer) this.getPlayerList().players.get(i);
|
||||
+ entityplayer.playerConnection.sendPacket(new PacketPlayOutUpdateTime(entityplayer.world.getTime(), entityplayer.getPlayerTime(), entityplayer.world.getGameRules().getBoolean(GameRules.DO_DAYLIGHT_CYCLE))); // Add support for per player time
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
while (iterator.hasNext()) {
|
||||
WorldServer worldserver = (WorldServer) iterator.next();
|
||||
|
||||
this.methodProfiler.a(() -> {
|
||||
return worldserver + " " + worldserver.getDimensionKey().a();
|
||||
});
|
||||
+ /* Drop global time updates
|
||||
if (this.ticks % 20 == 0) {
|
||||
this.methodProfiler.enter("timeSync");
|
||||
this.playerList.a((Packet) (new PacketPlayOutUpdateTime(worldserver.getTime(), worldserver.getDayTime(), worldserver.getGameRules().getBoolean(GameRules.DO_DAYLIGHT_CYCLE))), worldserver.getDimensionKey());
|
||||
this.methodProfiler.exit();
|
||||
}
|
||||
+ // CraftBukkit end */
|
||||
|
||||
this.methodProfiler.enter("tick");
|
||||
|
||||
@@ -863,7 +1123,7 @@
|
||||
}
|
||||
|
||||
public String getServerModName() {
|
||||
- return "vanilla";
|
||||
+ return server.getName(); // CraftBukkit - cb > vanilla!
|
||||
}
|
||||
|
||||
public CrashReport b(CrashReport crashreport) {
|
||||
@@ -1220,16 +1480,17 @@
|
||||
|
||||
public CompletableFuture<Void> a(Collection<String> collection) {
|
||||
CompletableFuture<Void> completablefuture = CompletableFuture.supplyAsync(() -> {
|
||||
- Stream stream = collection.stream();
|
||||
+ Stream<String> stream = collection.stream(); // CraftBukkit - decompile error
|
||||
ResourcePackRepository resourcepackrepository = this.resourcePackRepository;
|
||||
|
||||
this.resourcePackRepository.getClass();
|
||||
- return (ImmutableList) stream.map(resourcepackrepository::a).filter(Objects::nonNull).map(ResourcePackLoader::d).collect(ImmutableList.toImmutableList());
|
||||
+ return stream.map(resourcepackrepository::a).filter(Objects::nonNull).map(ResourcePackLoader::d).collect(ImmutableList.toImmutableList()); // CraftBukkit - decompile error
|
||||
}, this).thenCompose((immutablelist) -> {
|
||||
return DataPackResources.a(immutablelist, this.j() ? CommandDispatcher.ServerType.DEDICATED : CommandDispatcher.ServerType.INTEGRATED, this.h(), this.executorService, this);
|
||||
}).thenAcceptAsync((datapackresources) -> {
|
||||
this.dataPackResources.close();
|
||||
this.dataPackResources = datapackresources;
|
||||
+ this.server.syncCommands(); // SPIGOT-5884: Lost on reload
|
||||
this.resourcePackRepository.a(collection);
|
||||
this.saveData.a(a(this.resourcePackRepository));
|
||||
datapackresources.i();
|
||||
@@ -1595,6 +1856,22 @@
|
||||
|
||||
}
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ @Override
|
||||
+ public boolean isMainThread() {
|
||||
+ return super.isMainThread() || this.isStopped(); // CraftBukkit - MC-142590
|
||||
+ }
|
||||
+
|
||||
+ public boolean isDebugging() {
|
||||
+ return false;
|
||||
+ }
|
||||
+
|
||||
+ @Deprecated
|
||||
+ public static MinecraftServer getServer() {
|
||||
+ return (Bukkit.getServer() instanceof CraftServer) ? ((CraftServer) Bukkit.getServer()).getServer() : null;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
private void a(@Nullable GameProfilerTick gameprofilertick) {
|
||||
if (this.O) {
|
||||
this.O = false;
|
||||
@@ -0,0 +1,132 @@
|
||||
--- a/net/minecraft/server/ScoreboardServer.java
|
||||
+++ b/net/minecraft/server/ScoreboardServer.java
|
||||
@@ -22,7 +22,7 @@
|
||||
public void handleScoreChanged(ScoreboardScore scoreboardscore) {
|
||||
super.handleScoreChanged(scoreboardscore);
|
||||
if (this.b.contains(scoreboardscore.getObjective())) {
|
||||
- this.a.getPlayerList().sendAll(new PacketPlayOutScoreboardScore(ScoreboardServer.Action.CHANGE, scoreboardscore.getObjective().getName(), scoreboardscore.getPlayerName(), scoreboardscore.getScore()));
|
||||
+ this.sendAll(new PacketPlayOutScoreboardScore(ScoreboardServer.Action.CHANGE, scoreboardscore.getObjective().getName(), scoreboardscore.getPlayerName(), scoreboardscore.getScore()));
|
||||
}
|
||||
|
||||
this.b();
|
||||
@@ -31,7 +31,7 @@
|
||||
@Override
|
||||
public void handlePlayerRemoved(String s) {
|
||||
super.handlePlayerRemoved(s);
|
||||
- this.a.getPlayerList().sendAll(new PacketPlayOutScoreboardScore(ScoreboardServer.Action.REMOVE, (String) null, s, 0));
|
||||
+ this.sendAll(new PacketPlayOutScoreboardScore(ScoreboardServer.Action.REMOVE, (String) null, s, 0));
|
||||
this.b();
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
public void a(String s, ScoreboardObjective scoreboardobjective) {
|
||||
super.a(s, scoreboardobjective);
|
||||
if (this.b.contains(scoreboardobjective)) {
|
||||
- this.a.getPlayerList().sendAll(new PacketPlayOutScoreboardScore(ScoreboardServer.Action.REMOVE, scoreboardobjective.getName(), s, 0));
|
||||
+ this.sendAll(new PacketPlayOutScoreboardScore(ScoreboardServer.Action.REMOVE, scoreboardobjective.getName(), s, 0));
|
||||
}
|
||||
|
||||
this.b();
|
||||
@@ -52,7 +52,7 @@
|
||||
super.setDisplaySlot(i, scoreboardobjective);
|
||||
if (scoreboardobjective1 != scoreboardobjective && scoreboardobjective1 != null) {
|
||||
if (this.h(scoreboardobjective1) > 0) {
|
||||
- this.a.getPlayerList().sendAll(new PacketPlayOutScoreboardDisplayObjective(i, scoreboardobjective));
|
||||
+ this.sendAll(new PacketPlayOutScoreboardDisplayObjective(i, scoreboardobjective));
|
||||
} else {
|
||||
this.g(scoreboardobjective1);
|
||||
}
|
||||
@@ -60,7 +60,7 @@
|
||||
|
||||
if (scoreboardobjective != null) {
|
||||
if (this.b.contains(scoreboardobjective)) {
|
||||
- this.a.getPlayerList().sendAll(new PacketPlayOutScoreboardDisplayObjective(i, scoreboardobjective));
|
||||
+ this.sendAll(new PacketPlayOutScoreboardDisplayObjective(i, scoreboardobjective));
|
||||
} else {
|
||||
this.e(scoreboardobjective);
|
||||
}
|
||||
@@ -72,7 +72,7 @@
|
||||
@Override
|
||||
public boolean addPlayerToTeam(String s, ScoreboardTeam scoreboardteam) {
|
||||
if (super.addPlayerToTeam(s, scoreboardteam)) {
|
||||
- this.a.getPlayerList().sendAll(new PacketPlayOutScoreboardTeam(scoreboardteam, Arrays.asList(s), 3));
|
||||
+ this.sendAll(new PacketPlayOutScoreboardTeam(scoreboardteam, Arrays.asList(s), 3));
|
||||
this.b();
|
||||
return true;
|
||||
} else {
|
||||
@@ -83,7 +83,7 @@
|
||||
@Override
|
||||
public void removePlayerFromTeam(String s, ScoreboardTeam scoreboardteam) {
|
||||
super.removePlayerFromTeam(s, scoreboardteam);
|
||||
- this.a.getPlayerList().sendAll(new PacketPlayOutScoreboardTeam(scoreboardteam, Arrays.asList(s), 4));
|
||||
+ this.sendAll(new PacketPlayOutScoreboardTeam(scoreboardteam, Arrays.asList(s), 4));
|
||||
this.b();
|
||||
}
|
||||
|
||||
@@ -97,7 +97,7 @@
|
||||
public void handleObjectiveChanged(ScoreboardObjective scoreboardobjective) {
|
||||
super.handleObjectiveChanged(scoreboardobjective);
|
||||
if (this.b.contains(scoreboardobjective)) {
|
||||
- this.a.getPlayerList().sendAll(new PacketPlayOutScoreboardObjective(scoreboardobjective, 2));
|
||||
+ this.sendAll(new PacketPlayOutScoreboardObjective(scoreboardobjective, 2));
|
||||
}
|
||||
|
||||
this.b();
|
||||
@@ -116,21 +116,21 @@
|
||||
@Override
|
||||
public void handleTeamAdded(ScoreboardTeam scoreboardteam) {
|
||||
super.handleTeamAdded(scoreboardteam);
|
||||
- this.a.getPlayerList().sendAll(new PacketPlayOutScoreboardTeam(scoreboardteam, 0));
|
||||
+ this.sendAll(new PacketPlayOutScoreboardTeam(scoreboardteam, 0));
|
||||
this.b();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleTeamChanged(ScoreboardTeam scoreboardteam) {
|
||||
super.handleTeamChanged(scoreboardteam);
|
||||
- this.a.getPlayerList().sendAll(new PacketPlayOutScoreboardTeam(scoreboardteam, 2));
|
||||
+ this.sendAll(new PacketPlayOutScoreboardTeam(scoreboardteam, 2));
|
||||
this.b();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleTeamRemoved(ScoreboardTeam scoreboardteam) {
|
||||
super.handleTeamRemoved(scoreboardteam);
|
||||
- this.a.getPlayerList().sendAll(new PacketPlayOutScoreboardTeam(scoreboardteam, 1));
|
||||
+ this.sendAll(new PacketPlayOutScoreboardTeam(scoreboardteam, 1));
|
||||
this.b();
|
||||
}
|
||||
|
||||
@@ -179,6 +179,7 @@
|
||||
|
||||
while (iterator.hasNext()) {
|
||||
EntityPlayer entityplayer = (EntityPlayer) iterator.next();
|
||||
+ if (entityplayer.getBukkitEntity().getScoreboard().getHandle() != this) continue; // CraftBukkit - Only players on this board
|
||||
Iterator iterator1 = list.iterator();
|
||||
|
||||
while (iterator1.hasNext()) {
|
||||
@@ -211,6 +212,7 @@
|
||||
|
||||
while (iterator.hasNext()) {
|
||||
EntityPlayer entityplayer = (EntityPlayer) iterator.next();
|
||||
+ if (entityplayer.getBukkitEntity().getScoreboard().getHandle() != this) continue; // CraftBukkit - Only players on this board
|
||||
Iterator iterator1 = list.iterator();
|
||||
|
||||
while (iterator1.hasNext()) {
|
||||
@@ -235,6 +237,16 @@
|
||||
return i;
|
||||
}
|
||||
|
||||
+ // CraftBukkit start - Send to players
|
||||
+ private void sendAll(Packet packet) {
|
||||
+ for (EntityPlayer entityplayer : (List<EntityPlayer>) this.a.getPlayerList().players) {
|
||||
+ if (entityplayer.getBukkitEntity().getScoreboard().getHandle() == this) {
|
||||
+ entityplayer.playerConnection.sendPacket(packet);
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
public static enum Action {
|
||||
|
||||
CHANGE, REMOVE;
|
||||
@@ -0,0 +1,30 @@
|
||||
--- a/net/minecraft/server/BossBattleCustom.java
|
||||
+++ b/net/minecraft/server/BossBattleCustom.java
|
||||
@@ -6,12 +6,27 @@
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.boss.KeyedBossBar;
|
||||
+import org.bukkit.craftbukkit.boss.CraftKeyedBossbar;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public class BossBattleCustom extends BossBattleServer {
|
||||
|
||||
private final MinecraftKey h;
|
||||
private final Set<UUID> i = Sets.newHashSet();
|
||||
private int j;
|
||||
private int k = 100;
|
||||
+ // CraftBukkit start
|
||||
+ private KeyedBossBar bossBar;
|
||||
+
|
||||
+ public KeyedBossBar getBukkitEntity() {
|
||||
+ if (bossBar == null) {
|
||||
+ bossBar = new CraftKeyedBossbar(this);
|
||||
+ }
|
||||
+ return bossBar;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
|
||||
public BossBattleCustom(MinecraftKey minecraftkey, IChatBaseComponent ichatbasecomponent) {
|
||||
super(ichatbasecomponent, BossBattle.BarColor.WHITE, BossBattle.BarStyle.PROGRESS);
|
||||
@@ -0,0 +1,29 @@
|
||||
--- a/net/minecraft/server/CommandEffect.java
|
||||
+++ b/net/minecraft/server/CommandEffect.java
|
||||
@@ -62,7 +62,7 @@
|
||||
if (entity instanceof EntityLiving) {
|
||||
MobEffect mobeffect = new MobEffect(mobeffectlist, k, i, false, flag);
|
||||
|
||||
- if (((EntityLiving) entity).addEffect(mobeffect)) {
|
||||
+ if (((EntityLiving) entity).addEffect(mobeffect, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.COMMAND)) { // CraftBukkit
|
||||
++j;
|
||||
}
|
||||
}
|
||||
@@ -88,7 +88,7 @@
|
||||
while (iterator.hasNext()) {
|
||||
Entity entity = (Entity) iterator.next();
|
||||
|
||||
- if (entity instanceof EntityLiving && ((EntityLiving) entity).removeAllEffects()) {
|
||||
+ if (entity instanceof EntityLiving && ((EntityLiving) entity).removeAllEffects(org.bukkit.event.entity.EntityPotionEffectEvent.Cause.COMMAND)) { // CraftBukkit
|
||||
++i;
|
||||
}
|
||||
}
|
||||
@@ -113,7 +113,7 @@
|
||||
while (iterator.hasNext()) {
|
||||
Entity entity = (Entity) iterator.next();
|
||||
|
||||
- if (entity instanceof EntityLiving && ((EntityLiving) entity).removeEffect(mobeffectlist)) {
|
||||
+ if (entity instanceof EntityLiving && ((EntityLiving) entity).removeEffect(mobeffectlist, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.COMMAND)) { // CraftBukkit
|
||||
++i;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
--- a/net/minecraft/server/CommandGamemode.java
|
||||
+++ b/net/minecraft/server/CommandGamemode.java
|
||||
@@ -55,6 +55,12 @@
|
||||
|
||||
if (entityplayer.playerInteractManager.getGameMode() != enumgamemode) {
|
||||
entityplayer.a(enumgamemode);
|
||||
+ // CraftBukkit start - handle event cancelling the change
|
||||
+ if (entityplayer.playerInteractManager.getGameMode() != enumgamemode) {
|
||||
+ commandcontext.getSource().sendFailureMessage(new ChatComponentText("Failed to set the gamemode of '" + entityplayer.getName() + "'"));
|
||||
+ continue;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
a((CommandListenerWrapper) commandcontext.getSource(), entityplayer, enumgamemode);
|
||||
++i;
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
--- a/net/minecraft/server/CommandGamerule.java
|
||||
+++ b/net/minecraft/server/CommandGamerule.java
|
||||
@@ -25,7 +25,7 @@
|
||||
|
||||
private static <T extends GameRules.GameRuleValue<T>> int b(CommandContext<CommandListenerWrapper> commandcontext, GameRules.GameRuleKey<T> gamerules_gamerulekey) {
|
||||
CommandListenerWrapper commandlistenerwrapper = (CommandListenerWrapper) commandcontext.getSource();
|
||||
- T t0 = commandlistenerwrapper.getServer().getGameRules().get(gamerules_gamerulekey);
|
||||
+ T t0 = commandlistenerwrapper.getWorld().getGameRules().get(gamerules_gamerulekey); // CraftBukkit
|
||||
|
||||
t0.b(commandcontext, "value");
|
||||
commandlistenerwrapper.sendMessage(new ChatMessage("commands.gamerule.set", new Object[]{gamerules_gamerulekey.a(), t0.toString()}), true);
|
||||
@@ -33,7 +33,7 @@
|
||||
}
|
||||
|
||||
private static <T extends GameRules.GameRuleValue<T>> int b(CommandListenerWrapper commandlistenerwrapper, GameRules.GameRuleKey<T> gamerules_gamerulekey) {
|
||||
- T t0 = commandlistenerwrapper.getServer().getGameRules().get(gamerules_gamerulekey);
|
||||
+ T t0 = commandlistenerwrapper.getWorld().getGameRules().get(gamerules_gamerulekey); // CraftBukkit
|
||||
|
||||
commandlistenerwrapper.sendMessage(new ChatMessage("commands.gamerule.query", new Object[]{gamerules_gamerulekey.a(), t0.toString()}), false);
|
||||
return t0.getIntValue();
|
||||
@@ -0,0 +1,19 @@
|
||||
--- a/net/minecraft/server/CommandReload.java
|
||||
+++ b/net/minecraft/server/CommandReload.java
|
||||
@@ -36,6 +36,16 @@
|
||||
return collection1;
|
||||
}
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ public static void reload(MinecraftServer minecraftserver) {
|
||||
+ ResourcePackRepository resourcepackrepository = minecraftserver.getResourcePackRepository();
|
||||
+ SaveData savedata = minecraftserver.getSaveData();
|
||||
+ Collection<String> collection = resourcepackrepository.d();
|
||||
+ Collection<String> collection1 = a(resourcepackrepository, savedata, collection);
|
||||
+ minecraftserver.a(collection1);
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
public static void a(com.mojang.brigadier.CommandDispatcher<CommandListenerWrapper> com_mojang_brigadier_commanddispatcher) {
|
||||
com_mojang_brigadier_commanddispatcher.register((LiteralArgumentBuilder) ((LiteralArgumentBuilder) CommandDispatcher.a("reload").requires((commandlistenerwrapper) -> {
|
||||
return commandlistenerwrapper.hasPermission(2);
|
||||
@@ -0,0 +1,42 @@
|
||||
--- a/net/minecraft/server/CommandSpreadPlayers.java
|
||||
+++ b/net/minecraft/server/CommandSpreadPlayers.java
|
||||
@@ -61,7 +61,7 @@
|
||||
if (entity instanceof EntityHuman) {
|
||||
set.add(entity.getScoreboardTeam());
|
||||
} else {
|
||||
- set.add((Object) null);
|
||||
+ set.add((ScoreboardTeamBase) null); // CraftBukkit - decompile error
|
||||
}
|
||||
}
|
||||
|
||||
@@ -270,7 +270,7 @@
|
||||
|
||||
for (boolean flag2 = iblockaccess.getType(blockposition_mutableblockposition).isAir(); blockposition_mutableblockposition.getY() > 0; flag2 = flag1) {
|
||||
blockposition_mutableblockposition.c(EnumDirection.DOWN);
|
||||
- flag1 = iblockaccess.getType(blockposition_mutableblockposition).isAir();
|
||||
+ flag1 = getType(iblockaccess, blockposition_mutableblockposition).isAir(); // CraftBukkit
|
||||
if (!flag1 && flag2 && flag) {
|
||||
return blockposition_mutableblockposition.getY() + 1;
|
||||
}
|
||||
@@ -283,7 +283,7 @@
|
||||
|
||||
public boolean b(IBlockAccess iblockaccess, int i) {
|
||||
BlockPosition blockposition = new BlockPosition(this.a, (double) (this.a(iblockaccess, i) - 1), this.b);
|
||||
- IBlockData iblockdata = iblockaccess.getType(blockposition);
|
||||
+ IBlockData iblockdata = getType(iblockaccess, blockposition); // CraftBukkit
|
||||
Material material = iblockdata.getMaterial();
|
||||
|
||||
return blockposition.getY() < i && !material.isLiquid() && material != Material.FIRE;
|
||||
@@ -293,5 +293,12 @@
|
||||
this.a = MathHelper.a(random, d0, d2);
|
||||
this.b = MathHelper.a(random, d1, d3);
|
||||
}
|
||||
+
|
||||
+ // CraftBukkit start - add a version of getType which force loads chunks
|
||||
+ private static IBlockData getType(IBlockAccess iblockaccess, BlockPosition position) {
|
||||
+ ((WorldServer) iblockaccess).getChunkProvider().getChunkAt(position.getX() >> 4, position.getZ() >> 4, true);
|
||||
+ return iblockaccess.getType(position);
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
--- a/net/minecraft/server/CommandTeleport.java
|
||||
+++ b/net/minecraft/server/CommandTeleport.java
|
||||
@@ -13,6 +13,12 @@
|
||||
import java.util.Set;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.Location;
|
||||
+import org.bukkit.craftbukkit.CraftWorld;
|
||||
+import org.bukkit.event.entity.EntityTeleportEvent;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public class CommandTeleport {
|
||||
|
||||
private static final SimpleCommandExceptionType a = new SimpleCommandExceptionType(new ChatMessage("commands.teleport.invalidPosition"));
|
||||
@@ -128,9 +134,9 @@
|
||||
}
|
||||
|
||||
if (worldserver == entity.world) {
|
||||
- ((EntityPlayer) entity).playerConnection.a(d0, d1, d2, f, f1, set);
|
||||
+ ((EntityPlayer) entity).playerConnection.a(d0, d1, d2, f, f1, set, org.bukkit.event.player.PlayerTeleportEvent.TeleportCause.COMMAND); // CraftBukkit
|
||||
} else {
|
||||
- ((EntityPlayer) entity).a(worldserver, d0, d1, d2, f, f1);
|
||||
+ ((EntityPlayer) entity).a(worldserver, d0, d1, d2, f, f1, org.bukkit.event.player.PlayerTeleportEvent.TeleportCause.COMMAND); // CraftBukkit
|
||||
}
|
||||
|
||||
entity.setHeadRotation(f);
|
||||
@@ -139,6 +145,21 @@
|
||||
float f3 = MathHelper.g(f1);
|
||||
|
||||
f3 = MathHelper.a(f3, -90.0F, 90.0F);
|
||||
+ // CraftBukkit start - Teleport event
|
||||
+ Location to = new Location(worldserver.getWorld(), d0, d1, d2, f2, f3);
|
||||
+ EntityTeleportEvent event = new EntityTeleportEvent(entity.getBukkitEntity(), entity.getBukkitEntity().getLocation(), to);
|
||||
+ worldserver.getServer().getPluginManager().callEvent(event);
|
||||
+ if (event.isCancelled()) {
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ d0 = to.getX();
|
||||
+ d1 = to.getY();
|
||||
+ d2 = to.getZ();
|
||||
+ f2 = to.getYaw();
|
||||
+ f3 = to.getPitch();
|
||||
+ worldserver = ((CraftWorld) to.getWorld()).getHandle();
|
||||
+ // CraftBukkit end
|
||||
if (worldserver == entity.world) {
|
||||
entity.setPositionRotation(d0, d1, d2, f2, f3);
|
||||
entity.setHeadRotation(f2);
|
||||
@@ -0,0 +1,44 @@
|
||||
--- a/net/minecraft/server/CommandTime.java
|
||||
+++ b/net/minecraft/server/CommandTime.java
|
||||
@@ -5,6 +5,11 @@
|
||||
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
||||
import java.util.Iterator;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.Bukkit;
|
||||
+import org.bukkit.event.world.TimeSkipEvent;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public class CommandTime {
|
||||
|
||||
public static void a(com.mojang.brigadier.CommandDispatcher<CommandListenerWrapper> com_mojang_brigadier_commanddispatcher) {
|
||||
@@ -46,7 +51,13 @@
|
||||
while (iterator.hasNext()) {
|
||||
WorldServer worldserver = (WorldServer) iterator.next();
|
||||
|
||||
- worldserver.setDayTime((long) i);
|
||||
+ // CraftBukkit start
|
||||
+ TimeSkipEvent event = new TimeSkipEvent(worldserver.getWorld(), TimeSkipEvent.SkipReason.COMMAND, i - worldserver.getDayTime());
|
||||
+ Bukkit.getPluginManager().callEvent(event);
|
||||
+ if (!event.isCancelled()) {
|
||||
+ worldserver.setDayTime((long) worldserver.getDayTime() + event.getSkipAmount());
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
commandlistenerwrapper.sendMessage(new ChatMessage("commands.time.set", new Object[]{i}), true);
|
||||
@@ -59,7 +70,13 @@
|
||||
while (iterator.hasNext()) {
|
||||
WorldServer worldserver = (WorldServer) iterator.next();
|
||||
|
||||
- worldserver.setDayTime(worldserver.getDayTime() + (long) i);
|
||||
+ // CraftBukkit start
|
||||
+ TimeSkipEvent event = new TimeSkipEvent(worldserver.getWorld(), TimeSkipEvent.SkipReason.COMMAND, i);
|
||||
+ Bukkit.getPluginManager().callEvent(event);
|
||||
+ if (!event.isCancelled()) {
|
||||
+ worldserver.setDayTime(worldserver.getDayTime() + event.getSkipAmount());
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
int j = a(commandlistenerwrapper.getWorld());
|
||||
@@ -0,0 +1,243 @@
|
||||
--- a/net/minecraft/server/DedicatedServer.java
|
||||
+++ b/net/minecraft/server/DedicatedServer.java
|
||||
@@ -22,6 +22,14 @@
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import org.apache.logging.log4j.Level;
|
||||
+import org.apache.logging.log4j.io.IoBuilder;
|
||||
+import org.bukkit.command.CommandSender;
|
||||
+import org.bukkit.event.server.ServerCommandEvent;
|
||||
+import org.bukkit.event.server.RemoteServerCommandEvent;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public class DedicatedServer extends MinecraftServer implements IMinecraftServer {
|
||||
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
@@ -36,8 +44,10 @@
|
||||
@Nullable
|
||||
private final TextFilter r;
|
||||
|
||||
- public DedicatedServer(Thread thread, IRegistryCustom.Dimension iregistrycustom_dimension, Convertable.ConversionSession convertable_conversionsession, ResourcePackRepository resourcepackrepository, DataPackResources datapackresources, SaveData savedata, DedicatedServerSettings dedicatedserversettings, DataFixer datafixer, MinecraftSessionService minecraftsessionservice, GameProfileRepository gameprofilerepository, UserCache usercache, WorldLoadListenerFactory worldloadlistenerfactory) {
|
||||
- super(thread, iregistrycustom_dimension, convertable_conversionsession, savedata, resourcepackrepository, Proxy.NO_PROXY, datafixer, datapackresources, minecraftsessionservice, gameprofilerepository, usercache, worldloadlistenerfactory);
|
||||
+ // CraftBukkit start - Signature changed
|
||||
+ public DedicatedServer(joptsimple.OptionSet options, DataPackConfiguration datapackconfiguration, Thread thread, IRegistryCustom.Dimension iregistrycustom_dimension, Convertable.ConversionSession convertable_conversionsession, ResourcePackRepository resourcepackrepository, DataPackResources datapackresources, SaveData savedata, DedicatedServerSettings dedicatedserversettings, DataFixer datafixer, MinecraftSessionService minecraftsessionservice, GameProfileRepository gameprofilerepository, UserCache usercache, WorldLoadListenerFactory worldloadlistenerfactory) {
|
||||
+ super(options, datapackconfiguration, thread, iregistrycustom_dimension, convertable_conversionsession, savedata, resourcepackrepository, Proxy.NO_PROXY, datafixer, datapackresources, minecraftsessionservice, gameprofilerepository, usercache, worldloadlistenerfactory);
|
||||
+ // CraftBukkit end
|
||||
this.propertyManager = dedicatedserversettings;
|
||||
this.remoteControlCommandListener = new RemoteControlCommandListener(this);
|
||||
this.r = null;
|
||||
@@ -47,13 +57,44 @@
|
||||
public boolean init() throws IOException {
|
||||
Thread thread = new Thread("Server console handler") {
|
||||
public void run() {
|
||||
- BufferedReader bufferedreader = new BufferedReader(new InputStreamReader(System.in, StandardCharsets.UTF_8));
|
||||
+ // CraftBukkit start
|
||||
+ if (!org.bukkit.craftbukkit.Main.useConsole) {
|
||||
+ return;
|
||||
+ }
|
||||
+ jline.console.ConsoleReader bufferedreader = reader;
|
||||
+
|
||||
+ // MC-33041, SPIGOT-5538: if System.in is not valid due to javaw, then return
|
||||
+ try {
|
||||
+ System.in.available();
|
||||
+ } catch (IOException ex) {
|
||||
+ return;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
|
||||
String s;
|
||||
|
||||
try {
|
||||
- while (!DedicatedServer.this.isStopped() && DedicatedServer.this.isRunning() && (s = bufferedreader.readLine()) != null) {
|
||||
- DedicatedServer.this.issueCommand(s, DedicatedServer.this.getServerCommandListener());
|
||||
+ // CraftBukkit start - JLine disabling compatibility
|
||||
+ while (!DedicatedServer.this.isStopped() && DedicatedServer.this.isRunning()) {
|
||||
+ if (org.bukkit.craftbukkit.Main.useJline) {
|
||||
+ s = bufferedreader.readLine(">", null);
|
||||
+ } else {
|
||||
+ s = bufferedreader.readLine();
|
||||
+ }
|
||||
+
|
||||
+ // SPIGOT-5220: Throttle if EOF (ctrl^d) or stdin is /dev/null
|
||||
+ if (s == null) {
|
||||
+ try {
|
||||
+ Thread.sleep(50L);
|
||||
+ } catch (InterruptedException ex) {
|
||||
+ Thread.currentThread().interrupt();
|
||||
+ }
|
||||
+ continue;
|
||||
+ }
|
||||
+ if (s.trim().length() > 0) { // Trim to filter lines which are just spaces
|
||||
+ DedicatedServer.this.issueCommand(s, DedicatedServer.this.getServerCommandListener());
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
} catch (IOException ioexception) {
|
||||
DedicatedServer.LOGGER.error("Exception handling console input", ioexception);
|
||||
@@ -62,6 +103,27 @@
|
||||
}
|
||||
};
|
||||
|
||||
+ // CraftBukkit start - TODO: handle command-line logging arguments
|
||||
+ java.util.logging.Logger global = java.util.logging.Logger.getLogger("");
|
||||
+ global.setUseParentHandlers(false);
|
||||
+ for (java.util.logging.Handler handler : global.getHandlers()) {
|
||||
+ global.removeHandler(handler);
|
||||
+ }
|
||||
+ global.addHandler(new org.bukkit.craftbukkit.util.ForwardLogHandler());
|
||||
+
|
||||
+ final org.apache.logging.log4j.core.Logger logger = ((org.apache.logging.log4j.core.Logger) LogManager.getRootLogger());
|
||||
+ for (org.apache.logging.log4j.core.Appender appender : logger.getAppenders().values()) {
|
||||
+ if (appender instanceof org.apache.logging.log4j.core.appender.ConsoleAppender) {
|
||||
+ logger.removeAppender(appender);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ new org.bukkit.craftbukkit.util.TerminalConsoleWriterThread(System.out, this.reader).start();
|
||||
+
|
||||
+ System.setOut(IoBuilder.forLogger(logger).setLevel(Level.INFO).buildPrintStream());
|
||||
+ System.setErr(IoBuilder.forLogger(logger).setLevel(Level.WARN).buildPrintStream());
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
thread.setDaemon(true);
|
||||
thread.setUncaughtExceptionHandler(new DefaultUncaughtExceptionHandler(DedicatedServer.LOGGER));
|
||||
thread.start();
|
||||
@@ -88,7 +150,7 @@
|
||||
this.setForceGamemode(dedicatedserverproperties.forceGamemode);
|
||||
super.setIdleTimeout((Integer) dedicatedserverproperties.playerIdleTimeout.get());
|
||||
this.i(dedicatedserverproperties.enforceWhitelist);
|
||||
- this.saveData.setGameType(dedicatedserverproperties.gamemode);
|
||||
+ // this.saveData.setGameType(dedicatedserverproperties.gamemode); // CraftBukkit - moved to world loading
|
||||
DedicatedServer.LOGGER.info("Default game type: {}", dedicatedserverproperties.gamemode);
|
||||
InetAddress inetaddress = null;
|
||||
|
||||
@@ -112,6 +174,12 @@
|
||||
return false;
|
||||
}
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ this.a((PlayerList) (new DedicatedPlayerList(this, this.customRegistry, this.worldNBTStorage)));
|
||||
+ server.loadPlugins();
|
||||
+ server.enablePlugins(org.bukkit.plugin.PluginLoadOrder.STARTUP);
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
if (!this.getOnlineMode()) {
|
||||
DedicatedServer.LOGGER.warn("**** SERVER IS RUNNING IN OFFLINE/INSECURE MODE!");
|
||||
DedicatedServer.LOGGER.warn("The server will make no attempt to authenticate usernames. Beware.");
|
||||
@@ -126,7 +194,7 @@
|
||||
if (!NameReferencingFileConverter.e(this)) {
|
||||
return false;
|
||||
} else {
|
||||
- this.a((PlayerList) (new DedicatedPlayerList(this, this.customRegistry, this.worldNBTStorage)));
|
||||
+ // this.a((PlayerList) (new DedicatedPlayerList(this, this.customRegistry, this.worldNBTStorage))); // CraftBukkit - moved up
|
||||
long i = SystemUtils.getMonotonicNanos();
|
||||
|
||||
this.c(dedicatedserverproperties.maxBuildHeight);
|
||||
@@ -134,7 +202,7 @@
|
||||
TileEntitySkull.a(this.getMinecraftSessionService());
|
||||
UserCache.a(this.getOnlineMode());
|
||||
DedicatedServer.LOGGER.info("Preparing level \"{}\"", this.getWorld());
|
||||
- this.loadWorld();
|
||||
+ this.loadWorld(convertable.getLevelName()); // CraftBukkit
|
||||
long j = SystemUtils.getMonotonicNanos() - i;
|
||||
String s = String.format(Locale.ROOT, "%.3fs", (double) j / 1.0E9D);
|
||||
|
||||
@@ -151,6 +219,7 @@
|
||||
if (dedicatedserverproperties.enableRcon) {
|
||||
DedicatedServer.LOGGER.info("Starting remote control listener");
|
||||
this.remoteControlListener = RemoteControlListener.a((IMinecraftServer) this);
|
||||
+ this.remoteConsole = new org.bukkit.craftbukkit.command.CraftRemoteConsoleCommandSender(this.remoteControlCommandListener); // CraftBukkit
|
||||
}
|
||||
|
||||
if (this.getMaxTickTime() > 0L) {
|
||||
@@ -265,6 +334,7 @@
|
||||
this.remoteStatusListener.b();
|
||||
}
|
||||
|
||||
+ System.exit(0); // CraftBukkit
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -293,7 +363,15 @@
|
||||
while (!this.serverCommandQueue.isEmpty()) {
|
||||
ServerCommand servercommand = (ServerCommand) this.serverCommandQueue.remove(0);
|
||||
|
||||
- this.getCommandDispatcher().a(servercommand.source, servercommand.command);
|
||||
+ // CraftBukkit start - ServerCommand for preprocessing
|
||||
+ ServerCommandEvent event = new ServerCommandEvent(console, servercommand.command);
|
||||
+ server.getPluginManager().callEvent(event);
|
||||
+ if (event.isCancelled()) continue;
|
||||
+ servercommand = new ServerCommand(event.getCommand(), servercommand.source);
|
||||
+
|
||||
+ // this.getCommandDispatcher().a(servercommand.source, servercommand.command); // Called in dispatchServerCommand
|
||||
+ server.dispatchServerCommand(console, servercommand);
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
}
|
||||
@@ -503,14 +581,45 @@
|
||||
|
||||
@Override
|
||||
public String getPlugins() {
|
||||
- return "";
|
||||
+ // CraftBukkit start - Whole method
|
||||
+ StringBuilder result = new StringBuilder();
|
||||
+ org.bukkit.plugin.Plugin[] plugins = server.getPluginManager().getPlugins();
|
||||
+
|
||||
+ result.append(server.getName());
|
||||
+ result.append(" on Bukkit ");
|
||||
+ result.append(server.getBukkitVersion());
|
||||
+
|
||||
+ if (plugins.length > 0 && server.getQueryPlugins()) {
|
||||
+ result.append(": ");
|
||||
+
|
||||
+ for (int i = 0; i < plugins.length; i++) {
|
||||
+ if (i > 0) {
|
||||
+ result.append("; ");
|
||||
+ }
|
||||
+
|
||||
+ result.append(plugins[i].getDescription().getName());
|
||||
+ result.append(" ");
|
||||
+ result.append(plugins[i].getDescription().getVersion().replaceAll(";", ","));
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ return result.toString();
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
@Override
|
||||
public String executeRemoteCommand(String s) {
|
||||
this.remoteControlCommandListener.clearMessages();
|
||||
this.executeSync(() -> {
|
||||
- this.getCommandDispatcher().a(this.remoteControlCommandListener.getWrapper(), s);
|
||||
+ // CraftBukkit start - fire RemoteServerCommandEvent
|
||||
+ RemoteServerCommandEvent event = new RemoteServerCommandEvent(remoteConsole, s);
|
||||
+ server.getPluginManager().callEvent(event);
|
||||
+ if (event.isCancelled()) {
|
||||
+ return;
|
||||
+ }
|
||||
+ ServerCommand serverCommand = new ServerCommand(event.getCommand(), remoteControlCommandListener.getWrapper());
|
||||
+ server.dispatchServerCommand(remoteConsole, serverCommand);
|
||||
+ // CraftBukkit end
|
||||
});
|
||||
return this.remoteControlCommandListener.getMessages();
|
||||
}
|
||||
@@ -552,4 +661,15 @@
|
||||
public ITextFilter a(EntityPlayer entityplayer) {
|
||||
return this.r != null ? this.r.a(entityplayer.getProfile()) : null;
|
||||
}
|
||||
+
|
||||
+ // CraftBukkit start
|
||||
+ public boolean isDebugging() {
|
||||
+ return this.getDedicatedServerProperties().debug;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public CommandSender getBukkitSender(CommandListenerWrapper wrapper) {
|
||||
+ return console;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
--- a/net/minecraft/server/DedicatedServerProperties.java
|
||||
+++ b/net/minecraft/server/DedicatedServerProperties.java
|
||||
@@ -3,8 +3,14 @@
|
||||
import java.util.Properties;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import joptsimple.OptionSet;
|
||||
+import net.minecraft.server.PropertyManager.EditableProperty;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public class DedicatedServerProperties extends PropertyManager<DedicatedServerProperties> {
|
||||
|
||||
+ public final boolean debug = this.getBoolean("debug", false); // CraftBukkit
|
||||
public final boolean onlineMode = this.getBoolean("online-mode", true);
|
||||
public final boolean preventProxyConnections = this.getBoolean("prevent-proxy-connections", false);
|
||||
public final String serverIp = this.getString("server-ip", "");
|
||||
@@ -55,8 +61,10 @@
|
||||
public final PropertyManager<DedicatedServerProperties>.EditableProperty<Boolean> whiteList;
|
||||
public final GeneratorSettings generatorSettings;
|
||||
|
||||
- public DedicatedServerProperties(Properties properties, IRegistryCustom iregistrycustom) {
|
||||
- super(properties);
|
||||
+ // CraftBukkit start
|
||||
+ public DedicatedServerProperties(Properties properties, IRegistryCustom iregistrycustom, OptionSet optionset) {
|
||||
+ super(properties, optionset);
|
||||
+ // CraftBukkit end
|
||||
this.difficulty = (EnumDifficulty) this.a("difficulty", a(EnumDifficulty::getById, EnumDifficulty::a), EnumDifficulty::c, EnumDifficulty.EASY);
|
||||
this.gamemode = (EnumGamemode) this.a("gamemode", a(EnumGamemode::getById, EnumGamemode::a), EnumGamemode::b, EnumGamemode.SURVIVAL);
|
||||
this.levelName = this.getString("level-name", "world");
|
||||
@@ -107,12 +115,14 @@
|
||||
this.generatorSettings = GeneratorSettings.a(iregistrycustom, properties);
|
||||
}
|
||||
|
||||
- public static DedicatedServerProperties load(IRegistryCustom iregistrycustom, java.nio.file.Path java_nio_file_path) {
|
||||
- return new DedicatedServerProperties(loadPropertiesFile(java_nio_file_path), iregistrycustom);
|
||||
+ // CraftBukkit start
|
||||
+ public static DedicatedServerProperties load(IRegistryCustom iregistrycustom, java.nio.file.Path java_nio_file_path, OptionSet optionset) {
|
||||
+ return new DedicatedServerProperties(loadPropertiesFile(java_nio_file_path), iregistrycustom, optionset);
|
||||
}
|
||||
|
||||
@Override
|
||||
- protected DedicatedServerProperties reload(IRegistryCustom iregistrycustom, Properties properties) {
|
||||
- return new DedicatedServerProperties(properties, iregistrycustom);
|
||||
+ protected DedicatedServerProperties reload(IRegistryCustom iregistrycustom, Properties properties, OptionSet optionset) {
|
||||
+ return new DedicatedServerProperties(properties, iregistrycustom, optionset);
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
--- a/net/minecraft/server/DedicatedServerSettings.java
|
||||
+++ b/net/minecraft/server/DedicatedServerSettings.java
|
||||
@@ -2,14 +2,21 @@
|
||||
|
||||
import java.util.function.UnaryOperator;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import java.io.File;
|
||||
+import joptsimple.OptionSet;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public class DedicatedServerSettings {
|
||||
|
||||
private final java.nio.file.Path path;
|
||||
private DedicatedServerProperties properties;
|
||||
|
||||
- public DedicatedServerSettings(IRegistryCustom iregistrycustom, java.nio.file.Path java_nio_file_path) {
|
||||
- this.path = java_nio_file_path;
|
||||
- this.properties = DedicatedServerProperties.load(iregistrycustom, java_nio_file_path);
|
||||
+ // CraftBukkit start
|
||||
+ public DedicatedServerSettings(IRegistryCustom iregistrycustom, OptionSet optionset) {
|
||||
+ this.path = ((File) optionset.valueOf("config")).toPath();
|
||||
+ this.properties = DedicatedServerProperties.load(iregistrycustom, path, optionset);
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
public DedicatedServerProperties getProperties() {
|
||||
@@ -0,0 +1,118 @@
|
||||
--- a/net/minecraft/server/PropertyManager.java
|
||||
+++ b/net/minecraft/server/PropertyManager.java
|
||||
@@ -15,15 +15,30 @@
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
+import joptsimple.OptionSet; // CraftBukkit
|
||||
+
|
||||
public abstract class PropertyManager<T extends PropertyManager<T>> {
|
||||
|
||||
private static final Logger LOGGER = LogManager.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 loadPropertiesFile(java.nio.file.Path java_nio_file_path) {
|
||||
Properties properties = new Properties();
|
||||
|
||||
@@ -59,6 +74,11 @@
|
||||
|
||||
public void savePropertiesFile(java.nio.file.Path java_nio_file_path) {
|
||||
try {
|
||||
+ // CraftBukkit start - Don't attempt writing to file if it's read only
|
||||
+ if (java_nio_file_path.toFile().exists() && !java_nio_file_path.toFile().canWrite()) {
|
||||
+ return;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
OutputStream outputstream = Files.newOutputStream(java_nio_file_path);
|
||||
Throwable throwable = null;
|
||||
|
||||
@@ -90,7 +110,7 @@
|
||||
private static <V extends Number> Function<String, V> a(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;
|
||||
}
|
||||
@@ -109,7 +129,7 @@
|
||||
|
||||
@Nullable
|
||||
private String c(String s) {
|
||||
- return (String) this.properties.get(s);
|
||||
+ return (String) getOverride(s, this.properties.getProperty(s)); // CraftBukkit
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@@ -137,7 +157,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 a(String s, Function<String, V> function, UnaryOperator<V> unaryoperator, Function<V, String> function1, V v0) {
|
||||
@@ -166,7 +186,7 @@
|
||||
}
|
||||
|
||||
protected int getInt(String s, int i) {
|
||||
- return (Integer) this.a(s, a(Integer::parseInt), (Object) i);
|
||||
+ return (Integer) this.a(s, a(Integer::parseInt), i); // CraftBukkit - decompile error
|
||||
}
|
||||
|
||||
protected PropertyManager<T>.EditableProperty<Integer> b(String s, int i) {
|
||||
@@ -178,7 +198,7 @@
|
||||
}
|
||||
|
||||
protected long getLong(String s, long i) {
|
||||
- return (Long) this.a(s, a(Long::parseLong), (Object) i);
|
||||
+ return (Long) this.a(s, a(Long::parseLong), i); // CraftBukkit - decompile error
|
||||
}
|
||||
|
||||
protected boolean getBoolean(String s, boolean flag) {
|
||||
@@ -201,7 +221,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> {
|
||||
|
||||
@@ -209,7 +229,7 @@
|
||||
private final V c;
|
||||
private final Function<V, String> d;
|
||||
|
||||
- private EditableProperty(String s, Object object, Function function) {
|
||||
+ private EditableProperty(String s, V object, Function function) { // CraftBukkit - decompile error
|
||||
this.b = s;
|
||||
this.c = object;
|
||||
this.d = function;
|
||||
@@ -223,7 +243,7 @@
|
||||
Properties properties = PropertyManager.this.a();
|
||||
|
||||
properties.put(this.b, this.d.apply(v0));
|
||||
- return PropertyManager.this.reload(iregistrycustom, properties);
|
||||
+ return PropertyManager.this.reload(iregistrycustom, properties, PropertyManager.this.options); // CraftBukkit
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
--- a/net/minecraft/server/ServerGUI.java
|
||||
+++ b/net/minecraft/server/ServerGUI.java
|
||||
@@ -158,6 +158,7 @@
|
||||
this.e.forEach(Runnable::run);
|
||||
}
|
||||
|
||||
+ private static final java.util.regex.Pattern ANSI = java.util.regex.Pattern.compile("\\x1B\\[([0-9]{1,2}(;[0-9]{1,2})*)?[m|K]"); // CraftBukkit
|
||||
public void a(JTextArea jtextarea, JScrollPane jscrollpane, String s) {
|
||||
if (!SwingUtilities.isEventDispatchThread()) {
|
||||
SwingUtilities.invokeLater(() -> {
|
||||
@@ -173,7 +174,7 @@
|
||||
}
|
||||
|
||||
try {
|
||||
- document.insertString(document.getLength(), s, (AttributeSet) null);
|
||||
+ document.insertString(document.getLength(), ANSI.matcher(s).replaceAll(""), (AttributeSet) null); // CraftBukkit
|
||||
} catch (BadLocationException badlocationexception) {
|
||||
;
|
||||
}
|
||||
@@ -0,0 +1,138 @@
|
||||
--- a/net/minecraft/server/ChunkMapDistance.java
|
||||
+++ b/net/minecraft/server/ChunkMapDistance.java
|
||||
@@ -59,7 +59,7 @@
|
||||
while (objectiterator.hasNext()) {
|
||||
Entry<ArraySetSorted<Ticket<?>>> entry = (Entry) objectiterator.next();
|
||||
|
||||
- if (((ArraySetSorted) entry.getValue()).removeIf((ticket) -> {
|
||||
+ if ((entry.getValue()).removeIf((ticket) -> { // CraftBukkit - decompile error
|
||||
return ticket.b(this.currentTick);
|
||||
})) {
|
||||
this.ticketLevelTracker.update(entry.getLongKey(), getLowestTicketLevel((ArraySetSorted) entry.getValue()), false);
|
||||
@@ -95,10 +95,25 @@
|
||||
}
|
||||
|
||||
if (!this.pendingChunkUpdates.isEmpty()) {
|
||||
- this.pendingChunkUpdates.forEach((playerchunk) -> {
|
||||
+ // CraftBukkit start
|
||||
+ // Iterate pending chunk updates with protection against concurrent modification exceptions
|
||||
+ java.util.Iterator<PlayerChunk> iter = this.pendingChunkUpdates.iterator();
|
||||
+ int expectedSize = this.pendingChunkUpdates.size();
|
||||
+ do {
|
||||
+ PlayerChunk playerchunk = iter.next();
|
||||
+ iter.remove();
|
||||
+ expectedSize--;
|
||||
+
|
||||
playerchunk.a(playerchunkmap);
|
||||
- });
|
||||
- this.pendingChunkUpdates.clear();
|
||||
+
|
||||
+ // Reset iterator if set was modified using add()
|
||||
+ if (this.pendingChunkUpdates.size() != expectedSize) {
|
||||
+ expectedSize = this.pendingChunkUpdates.size();
|
||||
+ iter = this.pendingChunkUpdates.iterator();
|
||||
+ }
|
||||
+ } while (iter.hasNext());
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
return true;
|
||||
} else {
|
||||
if (!this.l.isEmpty()) {
|
||||
@@ -134,23 +149,25 @@
|
||||
}
|
||||
}
|
||||
|
||||
- private void addTicket(long i, Ticket<?> ticket) {
|
||||
+ private boolean addTicket(long i, Ticket<?> ticket) { // CraftBukkit - void -> boolean
|
||||
ArraySetSorted<Ticket<?>> arraysetsorted = this.e(i);
|
||||
int j = getLowestTicketLevel(arraysetsorted);
|
||||
- Ticket<?> ticket1 = (Ticket) arraysetsorted.a((Object) ticket);
|
||||
+ Ticket<?> ticket1 = (Ticket) arraysetsorted.a(ticket); // CraftBukkit - decompile error
|
||||
|
||||
ticket1.a(this.currentTick);
|
||||
if (ticket.b() < j) {
|
||||
this.ticketLevelTracker.update(i, ticket.b(), true);
|
||||
}
|
||||
|
||||
+ return ticket == ticket1; // CraftBukkit
|
||||
}
|
||||
|
||||
- private void removeTicket(long i, Ticket<?> ticket) {
|
||||
+ private boolean removeTicket(long i, Ticket<?> ticket) { // CraftBukkit - void -> boolean
|
||||
ArraySetSorted<Ticket<?>> arraysetsorted = this.e(i);
|
||||
|
||||
+ boolean removed = false; // CraftBukkit
|
||||
if (arraysetsorted.remove(ticket)) {
|
||||
- ;
|
||||
+ removed = true; // CraftBukkit
|
||||
}
|
||||
|
||||
if (arraysetsorted.isEmpty()) {
|
||||
@@ -158,16 +175,29 @@
|
||||
}
|
||||
|
||||
this.ticketLevelTracker.update(i, getLowestTicketLevel(arraysetsorted), false);
|
||||
+ return removed; // CraftBukkit
|
||||
}
|
||||
|
||||
public <T> void a(TicketType<T> tickettype, ChunkCoordIntPair chunkcoordintpair, int i, T t0) {
|
||||
- this.addTicket(chunkcoordintpair.pair(), new Ticket<>(tickettype, i, t0));
|
||||
+ // CraftBukkit start
|
||||
+ this.addTicketAtLevel(tickettype, chunkcoordintpair, i, t0);
|
||||
+ }
|
||||
+
|
||||
+ public <T> boolean addTicketAtLevel(TicketType<T> ticketType, ChunkCoordIntPair chunkcoordintpair, int level, T identifier) {
|
||||
+ return this.addTicket(chunkcoordintpair.pair(), new Ticket<>(ticketType, level, identifier));
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
public <T> void b(TicketType<T> tickettype, ChunkCoordIntPair chunkcoordintpair, int i, T t0) {
|
||||
- Ticket<T> ticket = new Ticket<>(tickettype, i, t0);
|
||||
+ // CraftBukkit start
|
||||
+ this.removeTicketAtLevel(tickettype, chunkcoordintpair, i, t0);
|
||||
+ }
|
||||
|
||||
- this.removeTicket(chunkcoordintpair.pair(), ticket);
|
||||
+ public <T> boolean removeTicketAtLevel(TicketType<T> ticketType, ChunkCoordIntPair chunkcoordintpair, int level, T identifier) {
|
||||
+ Ticket<T> ticket = new Ticket<>(ticketType, level, identifier);
|
||||
+
|
||||
+ return this.removeTicket(chunkcoordintpair.pair(), ticket);
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
public <T> void addTicket(TicketType<T> tickettype, ChunkCoordIntPair chunkcoordintpair, int i, T t0) {
|
||||
@@ -210,6 +240,7 @@
|
||||
public void b(SectionPosition sectionposition, EntityPlayer entityplayer) {
|
||||
long i = sectionposition.r().pair();
|
||||
ObjectSet<EntityPlayer> objectset = (ObjectSet) this.c.get(i);
|
||||
+ if (objectset == null) return; // CraftBukkit - SPIGOT-6208
|
||||
|
||||
objectset.remove(entityplayer);
|
||||
if (objectset.isEmpty()) {
|
||||
@@ -251,6 +282,26 @@
|
||||
return this.i.a();
|
||||
}
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ public <T> void removeAllTicketsFor(TicketType<T> ticketType, int ticketLevel, T ticketIdentifier) {
|
||||
+ Ticket<T> target = new Ticket<>(ticketType, ticketLevel, ticketIdentifier);
|
||||
+
|
||||
+ for (java.util.Iterator<Entry<ArraySetSorted<Ticket<?>>>> iterator = this.tickets.long2ObjectEntrySet().fastIterator(); iterator.hasNext();) {
|
||||
+ Entry<ArraySetSorted<Ticket<?>>> entry = iterator.next();
|
||||
+ ArraySetSorted<Ticket<?>> tickets = entry.getValue();
|
||||
+ if (tickets.remove(target)) {
|
||||
+ // copied from removeTicket
|
||||
+ this.ticketLevelTracker.update(entry.getLongKey(), getLowestTicketLevel(tickets), false);
|
||||
+
|
||||
+ // can't use entry after it's removed
|
||||
+ if (tickets.isEmpty()) {
|
||||
+ iterator.remove();
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
class a extends ChunkMap {
|
||||
|
||||
public a() {
|
||||
@@ -0,0 +1,167 @@
|
||||
--- a/net/minecraft/server/ChunkProviderServer.java
|
||||
+++ b/net/minecraft/server/ChunkProviderServer.java
|
||||
@@ -54,6 +54,24 @@
|
||||
this.clearCache();
|
||||
}
|
||||
|
||||
+ // CraftBukkit start - properly implement isChunkLoaded
|
||||
+ public boolean isChunkLoaded(int chunkX, int chunkZ) {
|
||||
+ PlayerChunk chunk = this.playerChunkMap.getUpdatingChunk(ChunkCoordIntPair.pair(chunkX, chunkZ));
|
||||
+ if (chunk == null) {
|
||||
+ return false;
|
||||
+ }
|
||||
+ return chunk.getFullChunk() != null;
|
||||
+ }
|
||||
+
|
||||
+ public Chunk getChunkUnchecked(int chunkX, int chunkZ) {
|
||||
+ PlayerChunk chunk = this.playerChunkMap.getUpdatingChunk(ChunkCoordIntPair.pair(chunkX, chunkZ));
|
||||
+ if (chunk == null) {
|
||||
+ return null;
|
||||
+ }
|
||||
+ return chunk.getFullChunkUnchecked();
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
@Override
|
||||
public LightEngineThreaded getLightEngine() {
|
||||
return this.lightEngine;
|
||||
@@ -98,7 +116,7 @@
|
||||
for (int l = 0; l < 4; ++l) {
|
||||
if (k == this.cachePos[l] && chunkstatus == this.cacheStatus[l]) {
|
||||
ichunkaccess = this.cacheChunk[l];
|
||||
- if (ichunkaccess != null || !flag) {
|
||||
+ if (ichunkaccess != null) { // CraftBukkit - the chunk can become accessible in the meantime TODO for non-null chunks it might also make sense to check that the chunk's state hasn't changed in the meantime
|
||||
return ichunkaccess;
|
||||
}
|
||||
}
|
||||
@@ -144,12 +162,12 @@
|
||||
if (playerchunk == null) {
|
||||
return null;
|
||||
} else {
|
||||
- Either<IChunkAccess, PlayerChunk.Failure> either = (Either) playerchunk.b(ChunkStatus.FULL).getNow((Object) null);
|
||||
+ Either<IChunkAccess, PlayerChunk.Failure> either = (Either) playerchunk.b(ChunkStatus.FULL).getNow(null); // CraftBukkit - decompile error
|
||||
|
||||
if (either == null) {
|
||||
return null;
|
||||
} else {
|
||||
- IChunkAccess ichunkaccess1 = (IChunkAccess) either.left().orElse((Object) null);
|
||||
+ IChunkAccess ichunkaccess1 = (IChunkAccess) either.left().orElse(null); // CraftBukkit - decompile error
|
||||
|
||||
if (ichunkaccess1 != null) {
|
||||
this.a(k, ichunkaccess1, ChunkStatus.FULL);
|
||||
@@ -176,7 +194,15 @@
|
||||
int l = 33 + ChunkStatus.a(chunkstatus);
|
||||
PlayerChunk playerchunk = this.getChunk(k);
|
||||
|
||||
- if (flag) {
|
||||
+ // CraftBukkit start - don't add new ticket for currently unloading chunk
|
||||
+ boolean currentlyUnloading = false;
|
||||
+ if (playerchunk != null) {
|
||||
+ PlayerChunk.State oldChunkState = PlayerChunk.getChunkState(playerchunk.oldTicketLevel);
|
||||
+ PlayerChunk.State currentChunkState = PlayerChunk.getChunkState(playerchunk.getTicketLevel());
|
||||
+ currentlyUnloading = (oldChunkState.isAtLeast(PlayerChunk.State.BORDER) && !currentChunkState.isAtLeast(PlayerChunk.State.BORDER));
|
||||
+ }
|
||||
+ if (flag && !currentlyUnloading) {
|
||||
+ // CraftBukkit end
|
||||
this.chunkMapDistance.a(TicketType.UNKNOWN, chunkcoordintpair, l, chunkcoordintpair);
|
||||
if (this.a(playerchunk, l)) {
|
||||
GameProfilerFiller gameprofilerfiller = this.world.getMethodProfiler();
|
||||
@@ -195,7 +221,7 @@
|
||||
}
|
||||
|
||||
private boolean a(@Nullable PlayerChunk playerchunk, int i) {
|
||||
- return playerchunk == null || playerchunk.getTicketLevel() > i;
|
||||
+ return playerchunk == null || playerchunk.oldTicketLevel > i; // CraftBukkit using oldTicketLevel for isLoaded checks
|
||||
}
|
||||
|
||||
public boolean isLoaded(int i, int j) {
|
||||
@@ -257,19 +283,19 @@
|
||||
public boolean a(Entity entity) {
|
||||
long i = ChunkCoordIntPair.pair(MathHelper.floor(entity.locX()) >> 4, MathHelper.floor(entity.locZ()) >> 4);
|
||||
|
||||
- return this.a(i, PlayerChunk::b);
|
||||
+ return this.a(i, (Function<PlayerChunk, CompletableFuture<Either<Chunk, PlayerChunk.Failure>>>) PlayerChunk::b); // CraftBukkit - decompile error
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean a(ChunkCoordIntPair chunkcoordintpair) {
|
||||
- return this.a(chunkcoordintpair.pair(), PlayerChunk::b);
|
||||
+ return this.a(chunkcoordintpair.pair(), (Function<PlayerChunk, CompletableFuture<Either<Chunk, PlayerChunk.Failure>>>) PlayerChunk::b); // CraftBukkit - decompile error
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean a(BlockPosition blockposition) {
|
||||
long i = ChunkCoordIntPair.pair(blockposition.getX() >> 4, blockposition.getZ() >> 4);
|
||||
|
||||
- return this.a(i, PlayerChunk::a);
|
||||
+ return this.a(i, (Function<PlayerChunk, CompletableFuture<Either<Chunk, PlayerChunk.Failure>>>) PlayerChunk::a); // CraftBukkit - decompile error
|
||||
}
|
||||
|
||||
private boolean a(long i, Function<PlayerChunk, CompletableFuture<Either<Chunk, PlayerChunk.Failure>>> function) {
|
||||
@@ -291,11 +317,31 @@
|
||||
|
||||
@Override
|
||||
public void close() throws IOException {
|
||||
- this.save(true);
|
||||
+ // CraftBukkit start
|
||||
+ close(true);
|
||||
+ }
|
||||
+
|
||||
+ public void close(boolean save) throws IOException {
|
||||
+ if (save) {
|
||||
+ this.save(true);
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
this.lightEngine.close();
|
||||
this.playerChunkMap.close();
|
||||
}
|
||||
|
||||
+ // CraftBukkit start - modelled on below
|
||||
+ public void purgeUnload() {
|
||||
+ this.world.getMethodProfiler().enter("purge");
|
||||
+ this.chunkMapDistance.purgeTickets();
|
||||
+ this.tickDistanceManager();
|
||||
+ this.world.getMethodProfiler().exitEnter("unload");
|
||||
+ this.playerChunkMap.unloadChunks(() -> true);
|
||||
+ this.world.getMethodProfiler().exit();
|
||||
+ this.clearCache();
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
public void tick(BooleanSupplier booleansupplier) {
|
||||
this.world.getMethodProfiler().enter("purge");
|
||||
this.chunkMapDistance.purgeTickets();
|
||||
@@ -315,12 +361,12 @@
|
||||
this.lastTickTime = i;
|
||||
WorldData worlddata = this.world.getWorldData();
|
||||
boolean flag = this.world.isDebugWorld();
|
||||
- boolean flag1 = this.world.getGameRules().getBoolean(GameRules.DO_MOB_SPAWNING);
|
||||
+ boolean flag1 = this.world.getGameRules().getBoolean(GameRules.DO_MOB_SPAWNING) && !world.getPlayers().isEmpty(); // CraftBukkit
|
||||
|
||||
if (!flag) {
|
||||
this.world.getMethodProfiler().enter("pollingChunks");
|
||||
int k = this.world.getGameRules().getInt(GameRules.RANDOM_TICK_SPEED);
|
||||
- boolean flag2 = worlddata.getTime() % 400L == 0L;
|
||||
+ boolean flag2 = world.ticksPerAnimalSpawns != 0L && worlddata.getTime() % world.ticksPerAnimalSpawns == 0L; // CraftBukkit
|
||||
|
||||
this.world.getMethodProfiler().enter("naturalSpawnCount");
|
||||
int l = this.chunkMapDistance.b();
|
||||
@@ -507,12 +553,18 @@
|
||||
|
||||
@Override
|
||||
protected boolean executeNext() {
|
||||
+ // CraftBukkit start - process pending Chunk loadCallback() and unloadCallback() after each run task
|
||||
+ try {
|
||||
if (ChunkProviderServer.this.tickDistanceManager()) {
|
||||
return true;
|
||||
} else {
|
||||
ChunkProviderServer.this.lightEngine.queueUpdate();
|
||||
return super.executeNext();
|
||||
}
|
||||
+ } finally {
|
||||
+ playerChunkMap.callbackExecutor.run();
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,174 @@
|
||||
--- a/net/minecraft/server/EntityTrackerEntry.java
|
||||
+++ b/net/minecraft/server/EntityTrackerEntry.java
|
||||
@@ -11,6 +11,11 @@
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.entity.Player;
|
||||
+import org.bukkit.event.player.PlayerVelocityEvent;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public class EntityTrackerEntry {
|
||||
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
@@ -31,8 +36,12 @@
|
||||
private List<Entity> p;
|
||||
private boolean q;
|
||||
private boolean r;
|
||||
+ // CraftBukkit start
|
||||
+ private final Set<EntityPlayer> trackedPlayers;
|
||||
|
||||
- public EntityTrackerEntry(WorldServer worldserver, Entity entity, int i, boolean flag, Consumer<Packet<?>> consumer) {
|
||||
+ public EntityTrackerEntry(WorldServer worldserver, Entity entity, int i, boolean flag, Consumer<Packet<?>> consumer, Set<EntityPlayer> trackedPlayers) {
|
||||
+ this.trackedPlayers = trackedPlayers;
|
||||
+ // CraftBukkit end
|
||||
this.m = Vec3D.ORIGIN;
|
||||
this.p = Collections.emptyList();
|
||||
this.b = worldserver;
|
||||
@@ -52,16 +61,17 @@
|
||||
|
||||
if (!list.equals(this.p)) {
|
||||
this.p = list;
|
||||
- this.f.accept(new PacketPlayOutMount(this.tracker));
|
||||
+ this.broadcastIncludingSelf(new PacketPlayOutMount(this.tracker)); // CraftBukkit
|
||||
}
|
||||
|
||||
- if (this.tracker instanceof EntityItemFrame && this.tickCounter % 10 == 0) {
|
||||
+ // PAIL : rename
|
||||
+ if (this.tracker instanceof EntityItemFrame /*&& this.tickCounter % 10 == 0*/) { // CraftBukkit - Moved below, should always enter this block
|
||||
EntityItemFrame entityitemframe = (EntityItemFrame) this.tracker;
|
||||
ItemStack itemstack = entityitemframe.getItem();
|
||||
|
||||
- if (itemstack.getItem() instanceof ItemWorldMap) {
|
||||
+ if (this.tickCounter % 10 == 0 && itemstack.getItem() instanceof ItemWorldMap) { // CraftBukkit - Moved this.tickCounter % 10 logic here so item frames do not enter the other blocks
|
||||
WorldMap worldmap = ItemWorldMap.getSavedMap(itemstack, this.b);
|
||||
- Iterator iterator = this.b.getPlayers().iterator();
|
||||
+ Iterator iterator = this.trackedPlayers.iterator(); // CraftBukkit
|
||||
|
||||
while (iterator.hasNext()) {
|
||||
EntityPlayer entityplayer = (EntityPlayer) iterator.next();
|
||||
@@ -106,6 +116,17 @@
|
||||
boolean flag2 = flag1 || this.tickCounter % 60 == 0;
|
||||
boolean flag3 = Math.abs(i - this.yRot) >= 1 || Math.abs(j - this.xRot) >= 1;
|
||||
|
||||
+ // CraftBukkit start - Code moved from below
|
||||
+ if (flag2) {
|
||||
+ this.d();
|
||||
+ }
|
||||
+
|
||||
+ if (flag3) {
|
||||
+ this.yRot = i;
|
||||
+ this.xRot = j;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
if (this.tickCounter > 0 || this.tracker instanceof EntityArrow) {
|
||||
long k = PacketPlayOutEntity.a(vec3d.x);
|
||||
long l = PacketPlayOutEntity.a(vec3d.y);
|
||||
@@ -144,6 +165,7 @@
|
||||
}
|
||||
|
||||
this.c();
|
||||
+ /* CraftBukkit start - Code moved up
|
||||
if (flag2) {
|
||||
this.d();
|
||||
}
|
||||
@@ -152,6 +174,7 @@
|
||||
this.yRot = i;
|
||||
this.xRot = j;
|
||||
}
|
||||
+ // CraftBukkit end */
|
||||
|
||||
this.q = false;
|
||||
}
|
||||
@@ -167,7 +190,27 @@
|
||||
|
||||
++this.tickCounter;
|
||||
if (this.tracker.velocityChanged) {
|
||||
- this.broadcastIncludingSelf(new PacketPlayOutEntityVelocity(this.tracker));
|
||||
+ // CraftBukkit start - Create PlayerVelocity event
|
||||
+ boolean cancelled = false;
|
||||
+
|
||||
+ if (this.tracker instanceof EntityPlayer) {
|
||||
+ Player player = (Player) this.tracker.getBukkitEntity();
|
||||
+ org.bukkit.util.Vector velocity = player.getVelocity();
|
||||
+
|
||||
+ PlayerVelocityEvent event = new PlayerVelocityEvent(player, velocity.clone());
|
||||
+ this.tracker.world.getServer().getPluginManager().callEvent(event);
|
||||
+
|
||||
+ if (event.isCancelled()) {
|
||||
+ cancelled = true;
|
||||
+ } else if (!velocity.equals(event.getVelocity())) {
|
||||
+ player.setVelocity(event.getVelocity());
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ if (!cancelled) {
|
||||
+ this.broadcastIncludingSelf(new PacketPlayOutEntityVelocity(this.tracker));
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
this.tracker.velocityChanged = false;
|
||||
}
|
||||
|
||||
@@ -182,14 +225,17 @@
|
||||
PlayerConnection playerconnection = entityplayer.playerConnection;
|
||||
|
||||
entityplayer.playerConnection.getClass();
|
||||
- this.a(playerconnection::sendPacket);
|
||||
+ this.a(playerconnection::sendPacket, entityplayer); // CraftBukkit - add player
|
||||
this.tracker.b(entityplayer);
|
||||
entityplayer.d(this.tracker);
|
||||
}
|
||||
|
||||
- public void a(Consumer<Packet<?>> consumer) {
|
||||
+ public void a(Consumer<Packet<?>> consumer, EntityPlayer entityplayer) { // CraftBukkit - add player
|
||||
if (this.tracker.dead) {
|
||||
- EntityTrackerEntry.LOGGER.warn("Fetching packet for removed entity " + this.tracker);
|
||||
+ // CraftBukkit start - Remove useless error spam, just return
|
||||
+ // EntityTrackerEntry.LOGGER.warn("Fetching packet for removed entity " + this.tracker);
|
||||
+ return;
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
Packet<?> packet = this.tracker.P();
|
||||
@@ -205,6 +251,12 @@
|
||||
if (this.tracker instanceof EntityLiving) {
|
||||
Collection<AttributeModifiable> collection = ((EntityLiving) this.tracker).getAttributeMap().b();
|
||||
|
||||
+ // CraftBukkit start - If sending own attributes send scaled health instead of current maximum health
|
||||
+ if (this.tracker.getId() == entityplayer.getId()) {
|
||||
+ ((EntityPlayer) this.tracker).getBukkitEntity().injectScaledMaxHealth(collection, false);
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
if (!collection.isEmpty()) {
|
||||
consumer.accept(new PacketPlayOutUpdateAttributes(this.tracker.getId(), collection));
|
||||
}
|
||||
@@ -236,8 +288,14 @@
|
||||
if (!list.isEmpty()) {
|
||||
consumer.accept(new PacketPlayOutEntityEquipment(this.tracker.getId(), list));
|
||||
}
|
||||
+ ((EntityLiving) this.tracker).updateEquipment(); // CraftBukkit - SPIGOT-3789: sync again immediately after sending
|
||||
}
|
||||
|
||||
+ // CraftBukkit start - Fix for nonsensical head yaw
|
||||
+ this.headYaw = MathHelper.d(this.tracker.getHeadRotation() * 256.0F / 360.0F);
|
||||
+ consumer.accept(new PacketPlayOutEntityHeadRotation(this.tracker, (byte) headYaw));
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
if (this.tracker instanceof EntityLiving) {
|
||||
EntityLiving entityliving = (EntityLiving) this.tracker;
|
||||
Iterator iterator = entityliving.getEffects().iterator();
|
||||
@@ -278,6 +336,11 @@
|
||||
Set<AttributeModifiable> set = ((EntityLiving) this.tracker).getAttributeMap().getAttributes();
|
||||
|
||||
if (!set.isEmpty()) {
|
||||
+ // CraftBukkit start - Send scaled max health
|
||||
+ if (this.tracker instanceof EntityPlayer) {
|
||||
+ ((EntityPlayer) this.tracker).getBukkitEntity().injectScaledMaxHealth(set, false);
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
this.broadcastIncludingSelf(new PacketPlayOutUpdateAttributes(this.tracker.getId(), set));
|
||||
}
|
||||
|
||||
@@ -0,0 +1,127 @@
|
||||
--- a/net/minecraft/server/PlayerChunk.java
|
||||
+++ b/net/minecraft/server/PlayerChunk.java
|
||||
@@ -44,7 +44,7 @@
|
||||
this.fullChunkFuture = PlayerChunk.UNLOADED_CHUNK_FUTURE;
|
||||
this.tickingFuture = PlayerChunk.UNLOADED_CHUNK_FUTURE;
|
||||
this.entityTickingFuture = PlayerChunk.UNLOADED_CHUNK_FUTURE;
|
||||
- this.chunkSave = CompletableFuture.completedFuture((Object) null);
|
||||
+ this.chunkSave = CompletableFuture.completedFuture(null); // CraftBukkit - decompile error
|
||||
this.dirtyBlocks = new ShortSet[16];
|
||||
this.location = chunkcoordintpair;
|
||||
this.lightEngine = lightengine;
|
||||
@@ -56,6 +56,19 @@
|
||||
this.a(i);
|
||||
}
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ public Chunk getFullChunk() {
|
||||
+ if (!getChunkState(this.oldTicketLevel).isAtLeast(PlayerChunk.State.BORDER)) return null; // note: using oldTicketLevel for isLoaded checks
|
||||
+ return this.getFullChunkUnchecked();
|
||||
+ }
|
||||
+
|
||||
+ public Chunk getFullChunkUnchecked() {
|
||||
+ CompletableFuture<Either<IChunkAccess, PlayerChunk.Failure>> statusFuture = this.getStatusFutureUnchecked(ChunkStatus.FULL);
|
||||
+ Either<IChunkAccess, PlayerChunk.Failure> either = (Either<IChunkAccess, PlayerChunk.Failure>) statusFuture.getNow(null);
|
||||
+ return (either == null) ? null : (Chunk) either.left().orElse(null);
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
public CompletableFuture<Either<IChunkAccess, PlayerChunk.Failure>> getStatusFutureUnchecked(ChunkStatus chunkstatus) {
|
||||
CompletableFuture<Either<IChunkAccess, PlayerChunk.Failure>> completablefuture = (CompletableFuture) this.statusFutures.get(chunkstatus.c());
|
||||
|
||||
@@ -81,9 +94,9 @@
|
||||
@Nullable
|
||||
public Chunk getChunk() {
|
||||
CompletableFuture<Either<Chunk, PlayerChunk.Failure>> completablefuture = this.a();
|
||||
- Either<Chunk, PlayerChunk.Failure> either = (Either) completablefuture.getNow((Object) null);
|
||||
+ Either<Chunk, PlayerChunk.Failure> either = (Either) completablefuture.getNow(null); // CraftBukkit - decompile error
|
||||
|
||||
- return either == null ? null : (Chunk) either.left().orElse((Object) null);
|
||||
+ return either == null ? null : (Chunk) either.left().orElse(null); // CraftBukkit - decompile error
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@@ -114,6 +127,7 @@
|
||||
if (chunk != null) {
|
||||
byte b0 = (byte) SectionPosition.a(blockposition.getY());
|
||||
|
||||
+ if (b0 < 0 || b0 >= this.dirtyBlocks.length) return; // CraftBukkit - SPIGOT-6086, SPIGOT-6296
|
||||
if (this.dirtyBlocks[b0] == null) {
|
||||
this.p = true;
|
||||
this.dirtyBlocks[b0] = new ShortArraySet();
|
||||
@@ -216,7 +230,7 @@
|
||||
CompletableFuture<Either<IChunkAccess, PlayerChunk.Failure>> completablefuture = (CompletableFuture) this.statusFutures.get(i);
|
||||
|
||||
if (completablefuture != null) {
|
||||
- Either<IChunkAccess, PlayerChunk.Failure> either = (Either) completablefuture.getNow((Object) null);
|
||||
+ Either<IChunkAccess, PlayerChunk.Failure> either = (Either) completablefuture.getNow(null); // CraftBukkit - decompile error
|
||||
|
||||
if (either == null || either.left().isPresent()) {
|
||||
return completablefuture;
|
||||
@@ -271,6 +285,30 @@
|
||||
boolean flag1 = this.ticketLevel <= PlayerChunkMap.GOLDEN_TICKET;
|
||||
PlayerChunk.State playerchunk_state = getChunkState(this.oldTicketLevel);
|
||||
PlayerChunk.State playerchunk_state1 = getChunkState(this.ticketLevel);
|
||||
+ // CraftBukkit start
|
||||
+ // ChunkUnloadEvent: Called before the chunk is unloaded: isChunkLoaded is still true and chunk can still be modified by plugins.
|
||||
+ if (playerchunk_state.isAtLeast(PlayerChunk.State.BORDER) && !playerchunk_state1.isAtLeast(PlayerChunk.State.BORDER)) {
|
||||
+ this.getStatusFutureUnchecked(ChunkStatus.FULL).thenAccept((either) -> {
|
||||
+ Chunk chunk = (Chunk)either.left().orElse(null);
|
||||
+ if (chunk != null) {
|
||||
+ playerchunkmap.callbackExecutor.execute(() -> {
|
||||
+ // Minecraft will apply the chunks tick lists to the world once the chunk got loaded, and then store the tick
|
||||
+ // lists again inside the chunk once the chunk becomes inaccessible and set the chunk's needsSaving flag.
|
||||
+ // These actions may however happen deferred, so we manually set the needsSaving flag already here.
|
||||
+ chunk.setNeedsSaving(true);
|
||||
+ chunk.unloadCallback();
|
||||
+ });
|
||||
+ }
|
||||
+ }).exceptionally((throwable) -> {
|
||||
+ // ensure exceptions are printed, by default this is not the case
|
||||
+ MinecraftServer.LOGGER.fatal("Failed to schedule unload callback for chunk " + PlayerChunk.this.location, throwable);
|
||||
+ return null;
|
||||
+ });
|
||||
+
|
||||
+ // Run callback right away if the future was already done
|
||||
+ playerchunkmap.callbackExecutor.run();
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
CompletableFuture completablefuture;
|
||||
|
||||
if (flag) {
|
||||
@@ -302,7 +340,7 @@
|
||||
if (flag2 && !flag3) {
|
||||
completablefuture = this.fullChunkFuture;
|
||||
this.fullChunkFuture = PlayerChunk.UNLOADED_CHUNK_FUTURE;
|
||||
- this.a(completablefuture.thenApply((either1) -> {
|
||||
+ this.a(((CompletableFuture<Either<Chunk, PlayerChunk.Failure>>) completablefuture).thenApply((either1) -> { // CraftBukkit - decompile error
|
||||
playerchunkmap.getClass();
|
||||
return either1.ifLeft(playerchunkmap::a);
|
||||
}));
|
||||
@@ -340,6 +378,26 @@
|
||||
|
||||
this.u.a(this.location, this::k, this.ticketLevel, this::d);
|
||||
this.oldTicketLevel = this.ticketLevel;
|
||||
+ // CraftBukkit start
|
||||
+ // ChunkLoadEvent: Called after the chunk is loaded: isChunkLoaded returns true and chunk is ready to be modified by plugins.
|
||||
+ if (!playerchunk_state.isAtLeast(PlayerChunk.State.BORDER) && playerchunk_state1.isAtLeast(PlayerChunk.State.BORDER)) {
|
||||
+ this.getStatusFutureUnchecked(ChunkStatus.FULL).thenAccept((either) -> {
|
||||
+ Chunk chunk = (Chunk)either.left().orElse(null);
|
||||
+ if (chunk != null) {
|
||||
+ playerchunkmap.callbackExecutor.execute(() -> {
|
||||
+ chunk.loadCallback();
|
||||
+ });
|
||||
+ }
|
||||
+ }).exceptionally((throwable) -> {
|
||||
+ // ensure exceptions are printed, by default this is not the case
|
||||
+ MinecraftServer.LOGGER.fatal("Failed to schedule load callback for chunk " + PlayerChunk.this.location, throwable);
|
||||
+ return null;
|
||||
+ });
|
||||
+
|
||||
+ // Run callback right away if the future was already done
|
||||
+ playerchunkmap.callbackExecutor.run();
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
public static ChunkStatus getChunkStatus(int i) {
|
||||
@@ -0,0 +1,165 @@
|
||||
--- a/net/minecraft/server/PlayerChunkMap.java
|
||||
+++ b/net/minecraft/server/PlayerChunkMap.java
|
||||
@@ -45,6 +45,8 @@
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
+import org.bukkit.entity.Player; // CraftBukkit
|
||||
+
|
||||
public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
|
||||
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
@@ -75,6 +77,31 @@
|
||||
private final Queue<Runnable> A;
|
||||
private int viewDistance;
|
||||
|
||||
+ // CraftBukkit start - recursion-safe executor for Chunk loadCallback() and unloadCallback()
|
||||
+ public final CallbackExecutor callbackExecutor = new CallbackExecutor();
|
||||
+ public static final class CallbackExecutor implements java.util.concurrent.Executor, Runnable {
|
||||
+
|
||||
+ private Runnable queued;
|
||||
+
|
||||
+ @Override
|
||||
+ public void execute(Runnable runnable) {
|
||||
+ if (queued != null) {
|
||||
+ throw new IllegalStateException("Already queued");
|
||||
+ }
|
||||
+ queued = runnable;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void run() {
|
||||
+ Runnable task = queued;
|
||||
+ queued = null;
|
||||
+ if (task != null) {
|
||||
+ task.run();
|
||||
+ }
|
||||
+ }
|
||||
+ };
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
public PlayerChunkMap(WorldServer worldserver, Convertable.ConversionSession convertable_conversionsession, DataFixer datafixer, DefinedStructureManager definedstructuremanager, Executor executor, IAsyncTaskHandler<Runnable> iasynctaskhandler, ILightAccess ilightaccess, ChunkGenerator chunkgenerator, WorldLoadListener worldloadlistener, Supplier<WorldPersistentData> supplier, int i, boolean flag) {
|
||||
super(new File(convertable_conversionsession.a(worldserver.getDimensionKey()), "region"), datafixer, flag);
|
||||
this.visibleChunks = this.updatingChunks.clone();
|
||||
@@ -195,9 +222,12 @@
|
||||
|
||||
return completablefuture1.thenApply((list1) -> {
|
||||
List<IChunkAccess> list2 = Lists.newArrayList();
|
||||
- final int l1 = 0;
|
||||
+ // CraftBukkit start - decompile error
|
||||
+ int cnt = 0;
|
||||
|
||||
- for (Iterator iterator = list1.iterator(); iterator.hasNext(); ++l1) {
|
||||
+ for (Iterator iterator = list1.iterator(); iterator.hasNext(); ++cnt) {
|
||||
+ final int l1 = cnt;
|
||||
+ // CraftBukkit end
|
||||
final Either<IChunkAccess, PlayerChunk.Failure> either = (Either) iterator.next();
|
||||
Optional<IChunkAccess> optional = either.left();
|
||||
|
||||
@@ -300,7 +330,7 @@
|
||||
PlayerChunkMap.LOGGER.info("ThreadedAnvilChunkStorage ({}): All chunks are saved", this.w.getName());
|
||||
} else {
|
||||
this.visibleChunks.values().stream().filter(PlayerChunk::hasBeenLoaded).forEach((playerchunk) -> {
|
||||
- IChunkAccess ichunkaccess = (IChunkAccess) playerchunk.getChunkSave().getNow((Object) null);
|
||||
+ IChunkAccess ichunkaccess = (IChunkAccess) playerchunk.getChunkSave().getNow(null); // CraftBukkit - decompile error
|
||||
|
||||
if (ichunkaccess instanceof ProtoChunkExtension || ichunkaccess instanceof Chunk) {
|
||||
this.saveChunk(ichunkaccess);
|
||||
@@ -311,7 +341,6 @@
|
||||
}
|
||||
|
||||
}
|
||||
-
|
||||
protected void unloadChunks(BooleanSupplier booleansupplier) {
|
||||
GameProfilerFiller gameprofilerfiller = this.world.getMethodProfiler();
|
||||
|
||||
@@ -350,7 +379,7 @@
|
||||
|
||||
private void a(long i, PlayerChunk playerchunk) {
|
||||
CompletableFuture<IChunkAccess> completablefuture = playerchunk.getChunkSave();
|
||||
- Consumer consumer = (ichunkaccess) -> {
|
||||
+ Consumer<IChunkAccess> consumer = (ichunkaccess) -> { // CraftBukkit - decompile error
|
||||
CompletableFuture<IChunkAccess> completablefuture1 = playerchunk.getChunkSave();
|
||||
|
||||
if (completablefuture1 != completablefuture) {
|
||||
@@ -572,8 +601,15 @@
|
||||
|
||||
while (iterator.hasNext()) {
|
||||
Entity entity = (Entity) iterator.next();
|
||||
+ // CraftBukkit start - these are spawned serialized (DefinedStructure) and we don't call an add event below at the moment due to ordering complexities
|
||||
+ boolean needsRemoval = false;
|
||||
+ if (chunk.needsDecoration && !this.world.getServer().getServer().getSpawnNPCs() && entity instanceof NPC) {
|
||||
+ entity.die();
|
||||
+ needsRemoval = true;
|
||||
+ }
|
||||
|
||||
- if (!(entity instanceof EntityHuman) && !this.world.addEntityChunk(entity)) {
|
||||
+ if (!(entity instanceof EntityHuman) && (needsRemoval || !this.world.addEntityChunk(entity))) {
|
||||
+ // CraftBukkit end
|
||||
if (list == null) {
|
||||
list = Lists.newArrayList(new Entity[]{entity});
|
||||
} else {
|
||||
@@ -784,7 +820,8 @@
|
||||
return ichunkaccess instanceof Chunk ? Optional.of((Chunk) ichunkaccess) : Optional.empty();
|
||||
});
|
||||
|
||||
- csvwriter.a(chunkcoordintpair.x, chunkcoordintpair.z, playerchunk.getTicketLevel(), optional.isPresent(), optional.map(IChunkAccess::getChunkStatus).orElse((Object) null), optional1.map(Chunk::getState).orElse((Object) null), a(playerchunk.c()), a(playerchunk.a()), a(playerchunk.b()), this.chunkDistanceManager.c(entry.getLongKey()), !this.isOutsideOfRange(chunkcoordintpair), optional1.map((chunk) -> {
|
||||
+ // CraftBukkit - decompile error
|
||||
+ csvwriter.a(chunkcoordintpair.x, chunkcoordintpair.z, playerchunk.getTicketLevel(), optional.isPresent(), optional.map(IChunkAccess::getChunkStatus).orElse(null), optional1.map(Chunk::getState).orElse(null), a(playerchunk.c()), a(playerchunk.a()), a(playerchunk.b()), this.chunkDistanceManager.c(entry.getLongKey()), !this.isOutsideOfRange(chunkcoordintpair), optional1.map((chunk) -> {
|
||||
return Stream.of(chunk.getEntitySlices()).mapToInt(EntitySlice::size).sum();
|
||||
}).orElse(0), optional1.map((chunk) -> {
|
||||
return chunk.getTileEntities().size();
|
||||
@@ -795,7 +832,7 @@
|
||||
|
||||
private static String a(CompletableFuture<Either<Chunk, PlayerChunk.Failure>> completablefuture) {
|
||||
try {
|
||||
- Either<Chunk, PlayerChunk.Failure> either = (Either) completablefuture.getNow((Object) null);
|
||||
+ Either<Chunk, PlayerChunk.Failure> either = (Either) completablefuture.getNow(null); // CraftBukkit - decompile error
|
||||
|
||||
return either != null ? (String) either.map((chunk) -> {
|
||||
return "done";
|
||||
@@ -813,7 +850,7 @@
|
||||
private NBTTagCompound readChunkData(ChunkCoordIntPair chunkcoordintpair) throws IOException {
|
||||
NBTTagCompound nbttagcompound = this.read(chunkcoordintpair);
|
||||
|
||||
- return nbttagcompound == null ? null : this.getChunkData(this.world.getDimensionKey(), this.l, nbttagcompound);
|
||||
+ return nbttagcompound == null ? null : this.getChunkData(this.world.getTypeKey(), this.l, nbttagcompound, chunkcoordintpair, world); // CraftBukkit
|
||||
}
|
||||
|
||||
boolean isOutsideOfRange(ChunkCoordIntPair chunkcoordintpair) {
|
||||
@@ -1145,7 +1182,7 @@
|
||||
public final Set<EntityPlayer> trackedPlayers = Sets.newHashSet();
|
||||
|
||||
public EntityTracker(Entity entity, int i, int j, boolean flag) {
|
||||
- this.trackerEntry = new EntityTrackerEntry(PlayerChunkMap.this.world, entity, j, flag, this::broadcast);
|
||||
+ this.trackerEntry = new EntityTrackerEntry(PlayerChunkMap.this.world, entity, j, flag, this::broadcast, trackedPlayers); // CraftBukkit
|
||||
this.tracker = entity;
|
||||
this.trackingDistance = i;
|
||||
this.e = SectionPosition.a(entity);
|
||||
@@ -1198,7 +1235,7 @@
|
||||
|
||||
public void updatePlayer(EntityPlayer entityplayer) {
|
||||
if (entityplayer != this.tracker) {
|
||||
- Vec3D vec3d = entityplayer.getPositionVector().d(this.trackerEntry.b());
|
||||
+ Vec3D vec3d = entityplayer.getPositionVector().d(this.tracker.getPositionVector()); // MC-155077, SPIGOT-5113
|
||||
int i = Math.min(this.b(), (PlayerChunkMap.this.viewDistance - 1) * 16);
|
||||
boolean flag = vec3d.x >= (double) (-i) && vec3d.x <= (double) i && vec3d.z >= (double) (-i) && vec3d.z <= (double) i && this.tracker.a(entityplayer);
|
||||
|
||||
@@ -1214,6 +1251,17 @@
|
||||
}
|
||||
}
|
||||
|
||||
+ // CraftBukkit start - respect vanish API
|
||||
+ if (this.tracker instanceof EntityPlayer) {
|
||||
+ Player player = ((EntityPlayer) this.tracker).getBukkitEntity();
|
||||
+ if (!entityplayer.getBukkitEntity().canSee(player)) {
|
||||
+ flag1 = false;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ entityplayer.removeQueue.remove(Integer.valueOf(this.tracker.getId()));
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
if (flag1 && this.trackedPlayers.add(entityplayer)) {
|
||||
this.trackerEntry.b(entityplayer);
|
||||
}
|
||||
@@ -0,0 +1,336 @@
|
||||
--- a/net/minecraft/server/PlayerInteractManager.java
|
||||
+++ b/net/minecraft/server/PlayerInteractManager.java
|
||||
@@ -4,6 +4,16 @@
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import java.util.ArrayList;
|
||||
+import org.bukkit.craftbukkit.block.CraftBlock;
|
||||
+import org.bukkit.event.block.BlockBreakEvent;
|
||||
+import org.bukkit.craftbukkit.event.CraftEventFactory;
|
||||
+import org.bukkit.event.Event;
|
||||
+import org.bukkit.event.block.Action;
|
||||
+import org.bukkit.event.player.PlayerInteractEvent;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public class PlayerInteractManager {
|
||||
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
@@ -38,7 +48,7 @@
|
||||
this.gamemode = enumgamemode;
|
||||
enumgamemode.a(this.player.abilities);
|
||||
this.player.updateAbilities();
|
||||
- this.player.server.getPlayerList().sendAll(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.UPDATE_GAME_MODE, new EntityPlayer[]{this.player}));
|
||||
+ this.player.server.getPlayerList().sendAll(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.UPDATE_GAME_MODE, new EntityPlayer[]{this.player}), this.player); // CraftBukkit
|
||||
this.world.everyoneSleeping();
|
||||
}
|
||||
|
||||
@@ -67,7 +77,7 @@
|
||||
}
|
||||
|
||||
public void a() {
|
||||
- ++this.currentTick;
|
||||
+ this.currentTick = MinecraftServer.currentTick; // CraftBukkit;
|
||||
IBlockData iblockdata;
|
||||
|
||||
if (this.j) {
|
||||
@@ -123,9 +133,31 @@
|
||||
|
||||
if (packetplayinblockdig_enumplayerdigtype == PacketPlayInBlockDig.EnumPlayerDigType.START_DESTROY_BLOCK) {
|
||||
if (!this.world.a((EntityHuman) this.player, blockposition)) {
|
||||
+ // CraftBukkit start - fire PlayerInteractEvent
|
||||
+ CraftEventFactory.callPlayerInteractEvent(this.player, Action.LEFT_CLICK_BLOCK, blockposition, enumdirection, this.player.inventory.getItemInHand(), EnumHand.MAIN_HAND);
|
||||
this.player.playerConnection.sendPacket(new PacketPlayOutBlockBreak(blockposition, this.world.getType(blockposition), packetplayinblockdig_enumplayerdigtype, false, "may not interact"));
|
||||
+ // Update any tile entity data for this block
|
||||
+ TileEntity tileentity = world.getTileEntity(blockposition);
|
||||
+ if (tileentity != null) {
|
||||
+ this.player.playerConnection.sendPacket(tileentity.getUpdatePacket());
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ // CraftBukkit start
|
||||
+ PlayerInteractEvent event = CraftEventFactory.callPlayerInteractEvent(this.player, Action.LEFT_CLICK_BLOCK, blockposition, enumdirection, this.player.inventory.getItemInHand(), EnumHand.MAIN_HAND);
|
||||
+ if (event.isCancelled()) {
|
||||
+ // Let the client know the block still exists
|
||||
+ this.player.playerConnection.sendPacket(new PacketPlayOutBlockChange(this.world, blockposition));
|
||||
+ // Update any tile entity data for this block
|
||||
+ TileEntity tileentity = this.world.getTileEntity(blockposition);
|
||||
+ if (tileentity != null) {
|
||||
+ this.player.playerConnection.sendPacket(tileentity.getUpdatePacket());
|
||||
+ }
|
||||
return;
|
||||
}
|
||||
+ // CraftBukkit end
|
||||
|
||||
if (this.isCreative()) {
|
||||
this.a(blockposition, packetplayinblockdig_enumplayerdigtype, "creative destroy");
|
||||
@@ -141,11 +173,43 @@
|
||||
float f = 1.0F;
|
||||
|
||||
iblockdata = this.world.getType(blockposition);
|
||||
- if (!iblockdata.isAir()) {
|
||||
+ // CraftBukkit start - Swings at air do *NOT* exist.
|
||||
+ if (event.useInteractedBlock() == Event.Result.DENY) {
|
||||
+ // If we denied a door from opening, we need to send a correcting update to the client, as it already opened the door.
|
||||
+ IBlockData data = this.world.getType(blockposition);
|
||||
+ if (data.getBlock() instanceof BlockDoor) {
|
||||
+ // For some reason *BOTH* the bottom/top part have to be marked updated.
|
||||
+ boolean bottom = data.get(BlockDoor.HALF) == BlockPropertyDoubleBlockHalf.LOWER;
|
||||
+ this.player.playerConnection.sendPacket(new PacketPlayOutBlockChange(this.world, blockposition));
|
||||
+ this.player.playerConnection.sendPacket(new PacketPlayOutBlockChange(this.world, bottom ? blockposition.up() : blockposition.down()));
|
||||
+ } else if (data.getBlock() instanceof BlockTrapdoor) {
|
||||
+ this.player.playerConnection.sendPacket(new PacketPlayOutBlockChange(this.world, blockposition));
|
||||
+ }
|
||||
+ } else if (!iblockdata.isAir()) {
|
||||
iblockdata.attack(this.world, blockposition, this.player);
|
||||
f = iblockdata.getDamage(this.player, this.player.world, blockposition);
|
||||
}
|
||||
|
||||
+ if (event.useItemInHand() == Event.Result.DENY) {
|
||||
+ // If we 'insta destroyed' then the client needs to be informed.
|
||||
+ if (f > 1.0f) {
|
||||
+ this.player.playerConnection.sendPacket(new PacketPlayOutBlockChange(this.world, blockposition));
|
||||
+ }
|
||||
+ return;
|
||||
+ }
|
||||
+ org.bukkit.event.block.BlockDamageEvent blockEvent = CraftEventFactory.callBlockDamageEvent(this.player, blockposition.getX(), blockposition.getY(), blockposition.getZ(), this.player.inventory.getItemInHand(), f >= 1.0f);
|
||||
+
|
||||
+ if (blockEvent.isCancelled()) {
|
||||
+ // Let the client know the block still exists
|
||||
+ this.player.playerConnection.sendPacket(new PacketPlayOutBlockChange(this.world, blockposition));
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ if (blockEvent.getInstaBreak()) {
|
||||
+ f = 2.0f;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
if (!iblockdata.isAir() && f >= 1.0F) {
|
||||
this.a(blockposition, packetplayinblockdig_enumplayerdigtype, "insta mine");
|
||||
} else {
|
||||
@@ -189,7 +253,7 @@
|
||||
} else if (packetplayinblockdig_enumplayerdigtype == PacketPlayInBlockDig.EnumPlayerDigType.ABORT_DESTROY_BLOCK) {
|
||||
this.f = false;
|
||||
if (!Objects.equals(this.h, blockposition)) {
|
||||
- PlayerInteractManager.LOGGER.warn("Mismatch in destroy block pos: " + this.h + " " + blockposition);
|
||||
+ PlayerInteractManager.LOGGER.debug("Mismatch in destroy block pos: " + this.h + " " + blockposition); // CraftBukkit - SPIGOT-5457 sent by client when interact event cancelled
|
||||
this.world.a(this.player.getId(), this.h, -1);
|
||||
this.player.playerConnection.sendPacket(new PacketPlayOutBlockBreak(this.h, this.world.getType(this.h), packetplayinblockdig_enumplayerdigtype, true, "aborted mismatched destroying"));
|
||||
}
|
||||
@@ -205,17 +269,73 @@
|
||||
if (this.breakBlock(blockposition)) {
|
||||
this.player.playerConnection.sendPacket(new PacketPlayOutBlockBreak(blockposition, this.world.getType(blockposition), packetplayinblockdig_enumplayerdigtype, true, s));
|
||||
} else {
|
||||
- this.player.playerConnection.sendPacket(new PacketPlayOutBlockBreak(blockposition, this.world.getType(blockposition), packetplayinblockdig_enumplayerdigtype, false, s));
|
||||
+ this.player.playerConnection.sendPacket(new PacketPlayOutBlockChange(this.world, blockposition)); // CraftBukkit - SPIGOT-5196
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public boolean breakBlock(BlockPosition blockposition) {
|
||||
IBlockData iblockdata = this.world.getType(blockposition);
|
||||
+ // CraftBukkit start - fire BlockBreakEvent
|
||||
+ org.bukkit.block.Block bblock = CraftBlock.at(world, blockposition);
|
||||
+ BlockBreakEvent event = null;
|
||||
+
|
||||
+ if (this.player instanceof EntityPlayer) {
|
||||
+ // Sword + Creative mode pre-cancel
|
||||
+ boolean isSwordNoBreak = !this.player.getItemInMainHand().getItem().a(iblockdata, this.world, blockposition, (EntityHuman) this.player);
|
||||
+
|
||||
+ // Tell client the block is gone immediately then process events
|
||||
+ // Don't tell the client if its a creative sword break because its not broken!
|
||||
+ if (world.getTileEntity(blockposition) == null && !isSwordNoBreak) {
|
||||
+ PacketPlayOutBlockChange packet = new PacketPlayOutBlockChange(this.world, blockposition);
|
||||
+ packet.block = Blocks.AIR.getBlockData();
|
||||
+ this.player.playerConnection.sendPacket(packet);
|
||||
+ }
|
||||
+
|
||||
+ event = new BlockBreakEvent(bblock, this.player.getBukkitEntity());
|
||||
+
|
||||
+ // Sword + Creative mode pre-cancel
|
||||
+ event.setCancelled(isSwordNoBreak);
|
||||
+
|
||||
+ // Calculate default block experience
|
||||
+ IBlockData nmsData = this.world.getType(blockposition);
|
||||
+ Block nmsBlock = nmsData.getBlock();
|
||||
+
|
||||
+ ItemStack itemstack = this.player.getEquipment(EnumItemSlot.MAINHAND);
|
||||
+
|
||||
+ if (nmsBlock != null && !event.isCancelled() && !this.isCreative() && this.player.hasBlock(nmsBlock.getBlockData())) {
|
||||
+ event.setExpToDrop(nmsBlock.getExpDrop(nmsData, this.world, blockposition, itemstack));
|
||||
+ }
|
||||
|
||||
- if (!this.player.getItemInMainHand().getItem().a(iblockdata, (World) this.world, blockposition, (EntityHuman) this.player)) {
|
||||
+ this.world.getServer().getPluginManager().callEvent(event);
|
||||
+
|
||||
+ if (event.isCancelled()) {
|
||||
+ if (isSwordNoBreak) {
|
||||
+ return false;
|
||||
+ }
|
||||
+ // Let the client know the block still exists
|
||||
+ this.player.playerConnection.sendPacket(new PacketPlayOutBlockChange(this.world, blockposition));
|
||||
+
|
||||
+ // Brute force all possible updates
|
||||
+ for (EnumDirection dir : EnumDirection.values()) {
|
||||
+ this.player.playerConnection.sendPacket(new PacketPlayOutBlockChange(world, blockposition.shift(dir)));
|
||||
+ }
|
||||
+
|
||||
+ // Update any tile entity data for this block
|
||||
+ TileEntity tileentity = this.world.getTileEntity(blockposition);
|
||||
+ if (tileentity != null) {
|
||||
+ this.player.playerConnection.sendPacket(tileentity.getUpdatePacket());
|
||||
+ }
|
||||
+ return false;
|
||||
+ }
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
+ if (false && !this.player.getItemInMainHand().getItem().a(iblockdata, (World) this.world, blockposition, (EntityHuman) this.player)) { // CraftBukkit - false
|
||||
return false;
|
||||
} else {
|
||||
+ iblockdata = this.world.getType(blockposition); // CraftBukkit - update state from plugins
|
||||
+ if (iblockdata.isAir()) return false; // CraftBukkit - A plugin set block to air without cancelling
|
||||
TileEntity tileentity = this.world.getTileEntity(blockposition);
|
||||
Block block = iblockdata.getBlock();
|
||||
|
||||
@@ -225,6 +345,10 @@
|
||||
} else if (this.player.a((World) this.world, blockposition, this.gamemode)) {
|
||||
return false;
|
||||
} else {
|
||||
+ // CraftBukkit start
|
||||
+ org.bukkit.block.BlockState state = bblock.getState();
|
||||
+ world.captureDrops = new ArrayList<>();
|
||||
+ // CraftBukkit end
|
||||
block.a((World) this.world, blockposition, iblockdata, (EntityHuman) this.player);
|
||||
boolean flag = this.world.a(blockposition, false);
|
||||
|
||||
@@ -233,19 +357,32 @@
|
||||
}
|
||||
|
||||
if (this.isCreative()) {
|
||||
- return true;
|
||||
+ // return true; // CraftBukkit
|
||||
} else {
|
||||
ItemStack itemstack = this.player.getItemInMainHand();
|
||||
ItemStack itemstack1 = itemstack.cloneItemStack();
|
||||
boolean flag1 = this.player.hasBlock(iblockdata);
|
||||
|
||||
itemstack.a(this.world, iblockdata, blockposition, this.player);
|
||||
- if (flag && flag1) {
|
||||
+ if (flag && flag1 && event.isDropItems()) { // CraftBukkit - Check if block should drop items
|
||||
block.a(this.world, this.player, blockposition, iblockdata, tileentity, itemstack1);
|
||||
}
|
||||
|
||||
- return true;
|
||||
+ // return true; // CraftBukkit
|
||||
+ }
|
||||
+ // CraftBukkit start
|
||||
+ if (event.isDropItems()) {
|
||||
+ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockDropItemEvent(bblock, state, this.player, world.captureDrops);
|
||||
+ }
|
||||
+ world.captureDrops = null;
|
||||
+
|
||||
+ // Drop event experience
|
||||
+ if (flag && event != null) {
|
||||
+ iblockdata.getBlock().dropExperience(this.world, blockposition, event.getExpToDrop());
|
||||
}
|
||||
+
|
||||
+ return true;
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -287,12 +424,46 @@
|
||||
}
|
||||
}
|
||||
|
||||
+ // CraftBukkit start - whole method
|
||||
+ public boolean interactResult = false;
|
||||
+ public boolean firedInteract = false;
|
||||
+ public BlockPosition interactPosition;
|
||||
+ public EnumHand interactHand;
|
||||
+ public ItemStack interactItemStack;
|
||||
public EnumInteractionResult a(EntityPlayer entityplayer, World world, ItemStack itemstack, EnumHand enumhand, MovingObjectPositionBlock movingobjectpositionblock) {
|
||||
BlockPosition blockposition = movingobjectpositionblock.getBlockPosition();
|
||||
IBlockData iblockdata = world.getType(blockposition);
|
||||
+ EnumInteractionResult enuminteractionresult = EnumInteractionResult.PASS;
|
||||
+ boolean cancelledBlock = false;
|
||||
|
||||
if (this.gamemode == EnumGamemode.SPECTATOR) {
|
||||
ITileInventory itileinventory = iblockdata.b(world, blockposition);
|
||||
+ cancelledBlock = !(itileinventory instanceof ITileInventory);
|
||||
+ }
|
||||
+
|
||||
+ if (entityplayer.getCooldownTracker().hasCooldown(itemstack.getItem())) {
|
||||
+ cancelledBlock = true;
|
||||
+ }
|
||||
+
|
||||
+ PlayerInteractEvent event = CraftEventFactory.callPlayerInteractEvent(entityplayer, Action.RIGHT_CLICK_BLOCK, blockposition, movingobjectpositionblock.getDirection(), itemstack, cancelledBlock, enumhand);
|
||||
+ firedInteract = true;
|
||||
+ interactResult = event.useItemInHand() == Event.Result.DENY;
|
||||
+ interactPosition = blockposition.immutableCopy();
|
||||
+ interactHand = enumhand;
|
||||
+ interactItemStack = itemstack.cloneItemStack();
|
||||
+
|
||||
+ if (event.useInteractedBlock() == Event.Result.DENY) {
|
||||
+ // If we denied a door from opening, we need to send a correcting update to the client, as it already opened the door.
|
||||
+ if (iblockdata.getBlock() instanceof BlockDoor) {
|
||||
+ boolean bottom = iblockdata.get(BlockDoor.HALF) == BlockPropertyDoubleBlockHalf.LOWER;
|
||||
+ entityplayer.playerConnection.sendPacket(new PacketPlayOutBlockChange(world, bottom ? blockposition.up() : blockposition.down()));
|
||||
+ } else if (iblockdata.getBlock() instanceof BlockCake) {
|
||||
+ entityplayer.getBukkitEntity().sendHealthUpdate(); // SPIGOT-1341 - reset health for cake
|
||||
+ }
|
||||
+ entityplayer.getBukkitEntity().updateInventory(); // SPIGOT-2867
|
||||
+ enuminteractionresult = (event.useItemInHand() != Event.Result.ALLOW) ? EnumInteractionResult.SUCCESS : EnumInteractionResult.PASS;
|
||||
+ } else if (this.gamemode == EnumGamemode.SPECTATOR) {
|
||||
+ ITileInventory itileinventory = iblockdata.b(world, blockposition);
|
||||
|
||||
if (itileinventory != null) {
|
||||
entityplayer.openContainer(itileinventory);
|
||||
@@ -306,7 +477,7 @@
|
||||
ItemStack itemstack1 = itemstack.cloneItemStack();
|
||||
|
||||
if (!flag1) {
|
||||
- EnumInteractionResult enuminteractionresult = iblockdata.interact(world, entityplayer, enumhand, movingobjectpositionblock);
|
||||
+ enuminteractionresult = iblockdata.interact(world, entityplayer, enumhand, movingobjectpositionblock);
|
||||
|
||||
if (enuminteractionresult.a()) {
|
||||
CriterionTriggers.M.a(entityplayer, blockposition, itemstack1);
|
||||
@@ -314,17 +485,17 @@
|
||||
}
|
||||
}
|
||||
|
||||
- if (!itemstack.isEmpty() && !entityplayer.getCooldownTracker().hasCooldown(itemstack.getItem())) {
|
||||
+ if (!itemstack.isEmpty() && enuminteractionresult != EnumInteractionResult.SUCCESS && !interactResult) { // add !interactResult SPIGOT-764
|
||||
ItemActionContext itemactioncontext = new ItemActionContext(entityplayer, enumhand, movingobjectpositionblock);
|
||||
EnumInteractionResult enuminteractionresult1;
|
||||
|
||||
if (this.isCreative()) {
|
||||
int i = itemstack.getCount();
|
||||
|
||||
- enuminteractionresult1 = itemstack.placeItem(itemactioncontext);
|
||||
+ enuminteractionresult1 = itemstack.placeItem(itemactioncontext, enumhand);
|
||||
itemstack.setCount(i);
|
||||
} else {
|
||||
- enuminteractionresult1 = itemstack.placeItem(itemactioncontext);
|
||||
+ enuminteractionresult1 = itemstack.placeItem(itemactioncontext, enumhand);
|
||||
}
|
||||
|
||||
if (enuminteractionresult1.a()) {
|
||||
@@ -332,10 +503,10 @@
|
||||
}
|
||||
|
||||
return enuminteractionresult1;
|
||||
- } else {
|
||||
- return EnumInteractionResult.PASS;
|
||||
}
|
||||
}
|
||||
+ return enuminteractionresult;
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
public void a(WorldServer worldserver) {
|
||||
@@ -0,0 +1,16 @@
|
||||
--- a/net/minecraft/server/RegionLimitedWorldAccess.java
|
||||
+++ b/net/minecraft/server/RegionLimitedWorldAccess.java
|
||||
@@ -236,6 +236,13 @@
|
||||
|
||||
@Override
|
||||
public boolean addEntity(Entity entity) {
|
||||
+ // CraftBukkit start
|
||||
+ return addEntity(entity, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.DEFAULT);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean addEntity(Entity entity, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason reason) {
|
||||
+ // CraftBukkit end
|
||||
int i = MathHelper.floor(entity.locX() / 16.0D);
|
||||
int j = MathHelper.floor(entity.locZ() / 16.0D);
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
--- a/net/minecraft/server/TicketType.java
|
||||
+++ b/net/minecraft/server/TicketType.java
|
||||
@@ -19,6 +19,8 @@
|
||||
public static final TicketType<BlockPosition> PORTAL = a("portal", BaseBlockPosition::compareTo, 300);
|
||||
public static final TicketType<Integer> POST_TELEPORT = a("post_teleport", Integer::compareTo, 5);
|
||||
public static final TicketType<ChunkCoordIntPair> UNKNOWN = a("unknown", Comparator.comparingLong(ChunkCoordIntPair::pair), 1);
|
||||
+ public static final TicketType<Unit> PLUGIN = a("plugin", (a, b) -> 0); // CraftBukkit
|
||||
+ public static final TicketType<org.bukkit.plugin.Plugin> PLUGIN_TICKET = a("plugin_ticket", (plugin1, plugin2) -> plugin1.getClass().getName().compareTo(plugin2.getClass().getName())); // CraftBukkit
|
||||
|
||||
public static <T> TicketType<T> a(String s, Comparator<T> comparator) {
|
||||
return new TicketType<>(s, comparator, 0L);
|
||||
@@ -0,0 +1,687 @@
|
||||
--- a/net/minecraft/server/WorldServer.java
|
||||
+++ b/net/minecraft/server/WorldServer.java
|
||||
@@ -39,6 +39,18 @@
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import java.util.logging.Level;
|
||||
+import org.bukkit.Bukkit;
|
||||
+import org.bukkit.WeatherType;
|
||||
+import org.bukkit.craftbukkit.event.CraftEventFactory;
|
||||
+import org.bukkit.craftbukkit.util.WorldUUID;
|
||||
+import org.bukkit.event.entity.CreatureSpawnEvent;
|
||||
+import org.bukkit.event.server.MapInitializeEvent;
|
||||
+import org.bukkit.event.weather.LightningStrikeEvent;
|
||||
+import org.bukkit.event.world.TimeSkipEvent;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public class WorldServer extends World implements GeneratorAccessSeed {
|
||||
|
||||
public static final BlockPosition a = new BlockPosition(100, 50, 0);
|
||||
@@ -50,7 +62,7 @@
|
||||
private final ChunkProviderServer chunkProvider;
|
||||
boolean tickingEntities;
|
||||
private final MinecraftServer server;
|
||||
- public final IWorldDataServer worldDataServer;
|
||||
+ public final WorldDataServer worldDataServer; // CraftBukkit - type
|
||||
public boolean savingDisabled;
|
||||
private boolean everyoneSleeping;
|
||||
private int emptyTime;
|
||||
@@ -67,8 +79,23 @@
|
||||
private final StructureManager structureManager;
|
||||
private final boolean Q;
|
||||
|
||||
- public WorldServer(MinecraftServer minecraftserver, Executor executor, Convertable.ConversionSession convertable_conversionsession, IWorldDataServer iworlddataserver, ResourceKey<World> resourcekey, DimensionManager dimensionmanager, WorldLoadListener worldloadlistener, ChunkGenerator chunkgenerator, boolean flag, long i, List<MobSpawner> list, boolean flag1) {
|
||||
- super(iworlddataserver, resourcekey, dimensionmanager, minecraftserver::getMethodProfiler, false, flag, i);
|
||||
+
|
||||
+ // CraftBukkit start
|
||||
+ private int tickPosition;
|
||||
+ public final Convertable.ConversionSession convertable;
|
||||
+ public final UUID uuid;
|
||||
+
|
||||
+ public Chunk getChunkIfLoaded(int x, int z) {
|
||||
+ return this.chunkProvider.getChunkAt(x, z, false);
|
||||
+ }
|
||||
+
|
||||
+ // Add env and gen to constructor, WorldData -> WorldDataServer
|
||||
+ public WorldServer(MinecraftServer minecraftserver, Executor executor, Convertable.ConversionSession convertable_conversionsession, IWorldDataServer iworlddataserver, ResourceKey<World> resourcekey, DimensionManager dimensionmanager, WorldLoadListener worldloadlistener, ChunkGenerator chunkgenerator, boolean flag, long i, List<MobSpawner> list, boolean flag1, org.bukkit.World.Environment env, org.bukkit.generator.ChunkGenerator gen) {
|
||||
+ super(iworlddataserver, resourcekey, dimensionmanager, minecraftserver::getMethodProfiler, false, flag, i, gen, env);
|
||||
+ this.pvpMode = minecraftserver.getPVP();
|
||||
+ convertable = convertable_conversionsession;
|
||||
+ uuid = WorldUUID.getUUID(convertable_conversionsession.folder.toFile());
|
||||
+ // CraftBukkit end
|
||||
this.nextTickListBlock = new TickListServer<>(this, (block) -> {
|
||||
return block == null || block.getBlockData().isAir();
|
||||
}, IRegistry.BLOCK::getKey, this::b);
|
||||
@@ -80,10 +107,17 @@
|
||||
this.Q = flag1;
|
||||
this.server = minecraftserver;
|
||||
this.mobSpawners = list;
|
||||
- this.worldDataServer = iworlddataserver;
|
||||
+ // CraftBukkit start
|
||||
+ this.worldDataServer = (WorldDataServer) iworlddataserver;
|
||||
+ worldDataServer.world = this;
|
||||
+ if (gen != null) {
|
||||
+ chunkgenerator = new org.bukkit.craftbukkit.generator.CustomChunkGenerator(this, chunkgenerator, gen);
|
||||
+ }
|
||||
+
|
||||
this.chunkProvider = new ChunkProviderServer(this, convertable_conversionsession, minecraftserver.getDataFixer(), minecraftserver.getDefinedStructureManager(), executor, chunkgenerator, minecraftserver.getPlayerList().getViewDistance(), minecraftserver.isSyncChunkWrites(), worldloadlistener, () -> {
|
||||
return minecraftserver.E().getWorldPersistentData();
|
||||
});
|
||||
+ // CraftBukkit end
|
||||
this.portalTravelAgent = new PortalTravelAgent(this);
|
||||
this.Q();
|
||||
this.R();
|
||||
@@ -95,14 +129,48 @@
|
||||
iworlddataserver.setGameType(minecraftserver.getGamemode());
|
||||
}
|
||||
|
||||
- this.structureManager = new StructureManager(this, minecraftserver.getSaveData().getGeneratorSettings());
|
||||
+ this.structureManager = new StructureManager(this, this.worldDataServer.getGeneratorSettings()); // CraftBukkit
|
||||
if (this.getDimensionManager().isCreateDragonBattle()) {
|
||||
- this.dragonBattle = new EnderDragonBattle(this, minecraftserver.getSaveData().getGeneratorSettings().getSeed(), minecraftserver.getSaveData().C());
|
||||
+ this.dragonBattle = new EnderDragonBattle(this, this.worldDataServer.getGeneratorSettings().getSeed(), this.worldDataServer.C()); // CraftBukkit
|
||||
} else {
|
||||
this.dragonBattle = null;
|
||||
}
|
||||
+ this.getServer().addWorld(this.getWorld()); // CraftBukkit
|
||||
+ }
|
||||
+
|
||||
+ // CraftBukkit start
|
||||
+ @Override
|
||||
+ protected TileEntity getTileEntity(BlockPosition pos, boolean validate) {
|
||||
+ TileEntity result = super.getTileEntity(pos, validate);
|
||||
+ if (!validate || Thread.currentThread() != this.serverThread) {
|
||||
+ // SPIGOT-5378: avoid deadlock, this can be called in loading logic (i.e lighting) but getType() will block on chunk load
|
||||
+ return result;
|
||||
+ }
|
||||
+ Block type = getType(pos).getBlock();
|
||||
|
||||
+ if (result != null && type != Blocks.AIR) {
|
||||
+ if (!result.getTileType().isValidBlock(type)) {
|
||||
+ result = fixTileEntity(pos, type, result);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ return result;
|
||||
+ }
|
||||
+
|
||||
+ private TileEntity fixTileEntity(BlockPosition pos, Block type, TileEntity found) {
|
||||
+ this.getServer().getLogger().log(Level.SEVERE, "Block at {0}, {1}, {2} is {3} but has {4}" + ". "
|
||||
+ + "Bukkit will attempt to fix this, but there may be additional damage that we cannot recover.", new Object[]{pos.getX(), pos.getY(), pos.getZ(), type, found});
|
||||
+
|
||||
+ if (type instanceof ITileEntity) {
|
||||
+ TileEntity replacement = ((ITileEntity) type).createTile(this);
|
||||
+ replacement.world = this;
|
||||
+ this.setTileEntity(pos, replacement);
|
||||
+ return replacement;
|
||||
+ } else {
|
||||
+ return found;
|
||||
+ }
|
||||
}
|
||||
+ // CraftBukkit end
|
||||
|
||||
public void a(int i, int j, boolean flag, boolean flag1) {
|
||||
this.worldDataServer.setClearWeatherTime(i);
|
||||
@@ -193,6 +261,7 @@
|
||||
this.rainLevel = MathHelper.a(this.rainLevel, 0.0F, 1.0F);
|
||||
}
|
||||
|
||||
+ /* CraftBukkit start
|
||||
if (this.lastRainLevel != this.rainLevel) {
|
||||
this.server.getPlayerList().a((Packet) (new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.h, this.rainLevel)), this.getDimensionKey());
|
||||
}
|
||||
@@ -211,18 +280,47 @@
|
||||
this.server.getPlayerList().sendAll(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.h, this.rainLevel));
|
||||
this.server.getPlayerList().sendAll(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.i, this.thunderLevel));
|
||||
}
|
||||
+ // */
|
||||
+ for (int idx = 0; idx < this.players.size(); ++idx) {
|
||||
+ if (((EntityPlayer) this.players.get(idx)).world == this) {
|
||||
+ ((EntityPlayer) this.players.get(idx)).tickWeather();
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ if (flag != this.isRaining()) {
|
||||
+ // Only send weather packets to those affected
|
||||
+ for (int idx = 0; idx < this.players.size(); ++idx) {
|
||||
+ if (((EntityPlayer) this.players.get(idx)).world == this) {
|
||||
+ ((EntityPlayer) this.players.get(idx)).setPlayerWeather((!flag ? WeatherType.DOWNFALL : WeatherType.CLEAR), false);
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ for (int idx = 0; idx < this.players.size(); ++idx) {
|
||||
+ if (((EntityPlayer) this.players.get(idx)).world == this) {
|
||||
+ ((EntityPlayer) this.players.get(idx)).updateWeather(this.lastRainLevel, this.rainLevel, this.lastThunderLevel, this.thunderLevel);
|
||||
+ }
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
|
||||
if (this.everyoneSleeping && this.players.stream().noneMatch((entityplayer) -> {
|
||||
- return !entityplayer.isSpectator() && !entityplayer.isDeeplySleeping();
|
||||
+ return !entityplayer.isSpectator() && !entityplayer.isDeeplySleeping() && !entityplayer.fauxSleeping; // CraftBukkit
|
||||
})) {
|
||||
- this.everyoneSleeping = false;
|
||||
+ // CraftBukkit start
|
||||
+ long l = this.worldData.getDayTime() + 24000L;
|
||||
+ TimeSkipEvent event = new TimeSkipEvent(this.getWorld(), TimeSkipEvent.SkipReason.NIGHT_SKIP, (l - l % 24000L) - this.getDayTime());
|
||||
if (this.getGameRules().getBoolean(GameRules.DO_DAYLIGHT_CYCLE)) {
|
||||
- long l = this.worldData.getDayTime() + 24000L;
|
||||
+ getServer().getPluginManager().callEvent(event);
|
||||
+ if (!event.isCancelled()) {
|
||||
+ this.setDayTime(this.getDayTime() + event.getSkipAmount());
|
||||
+ }
|
||||
|
||||
- this.setDayTime(l - l % 24000L);
|
||||
}
|
||||
|
||||
- this.wakeupPlayers();
|
||||
+ if (!event.isCancelled()) {
|
||||
+ this.everyoneSleeping = false;
|
||||
+ this.wakeupPlayers();
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
if (this.getGameRules().getBoolean(GameRules.DO_WEATHER_CYCLE)) {
|
||||
this.clearWeather();
|
||||
}
|
||||
@@ -244,7 +342,7 @@
|
||||
this.ak();
|
||||
this.ticking = false;
|
||||
gameprofilerfiller.exitEnter("entities");
|
||||
- boolean flag3 = !this.players.isEmpty() || !this.getForceLoadedChunks().isEmpty();
|
||||
+ boolean flag3 = true || !this.players.isEmpty() || !this.getForceLoadedChunks().isEmpty(); // CraftBukkit - this prevents entity cleanup, other issues on servers with no players
|
||||
|
||||
if (flag3) {
|
||||
this.resetEmptyTime();
|
||||
@@ -263,6 +361,7 @@
|
||||
Entity entity = (Entity) entry.getValue();
|
||||
Entity entity1 = entity.getVehicle();
|
||||
|
||||
+ /* CraftBukkit start - We prevent spawning in general, so this butchering is not needed
|
||||
if (!this.server.getSpawnAnimals() && (entity instanceof EntityAnimal || entity instanceof EntityWaterAnimal)) {
|
||||
entity.die();
|
||||
}
|
||||
@@ -270,6 +369,7 @@
|
||||
if (!this.server.getSpawnNPCs() && entity instanceof NPC) {
|
||||
entity.die();
|
||||
}
|
||||
+ // CraftBukkit end */
|
||||
|
||||
gameprofilerfiller.enter("checkDespawn");
|
||||
if (!entity.dead) {
|
||||
@@ -344,7 +444,7 @@
|
||||
}
|
||||
|
||||
private void wakeupPlayers() {
|
||||
- ((List) this.players.stream().filter(EntityLiving::isSleeping).collect(Collectors.toList())).forEach((entityplayer) -> {
|
||||
+ (this.players.stream().filter(EntityLiving::isSleeping).collect(Collectors.toList())).forEach((entityplayer) -> { // CraftBukkit - decompile error
|
||||
entityplayer.wakeup(false, false);
|
||||
});
|
||||
}
|
||||
@@ -371,14 +471,14 @@
|
||||
entityhorseskeleton.t(true);
|
||||
entityhorseskeleton.setAgeRaw(0);
|
||||
entityhorseskeleton.setPosition((double) blockposition.getX(), (double) blockposition.getY(), (double) blockposition.getZ());
|
||||
- this.addEntity(entityhorseskeleton);
|
||||
+ this.addEntity(entityhorseskeleton, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.LIGHTNING); // CraftBukkit
|
||||
}
|
||||
|
||||
EntityLightning entitylightning = (EntityLightning) EntityTypes.LIGHTNING_BOLT.a((World) this);
|
||||
|
||||
entitylightning.d(Vec3D.c((BaseBlockPosition) blockposition));
|
||||
entitylightning.setEffect(flag1);
|
||||
- this.addEntity(entitylightning);
|
||||
+ this.strikeLightning(entitylightning, org.bukkit.event.weather.LightningStrikeEvent.Cause.WEATHER); // CraftBukkit
|
||||
}
|
||||
}
|
||||
|
||||
@@ -389,11 +489,11 @@
|
||||
BiomeBase biomebase = this.getBiome(blockposition);
|
||||
|
||||
if (biomebase.a(this, blockposition1)) {
|
||||
- this.setTypeUpdate(blockposition1, Blocks.ICE.getBlockData());
|
||||
+ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(this, blockposition1, Blocks.ICE.getBlockData(), null); // CraftBukkit
|
||||
}
|
||||
|
||||
if (flag && biomebase.b(this, blockposition)) {
|
||||
- this.setTypeUpdate(blockposition, Blocks.SNOW.getBlockData());
|
||||
+ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(this, blockposition, Blocks.SNOW.getBlockData(), null); // CraftBukkit
|
||||
}
|
||||
|
||||
if (flag && this.getBiome(blockposition1).c() == BiomeBase.Precipitation.RAIN) {
|
||||
@@ -440,7 +540,7 @@
|
||||
protected BlockPosition a(BlockPosition blockposition) {
|
||||
BlockPosition blockposition1 = this.getHighestBlockYAt(HeightMap.Type.MOTION_BLOCKING, blockposition);
|
||||
AxisAlignedBB axisalignedbb = (new AxisAlignedBB(blockposition1, new BlockPosition(blockposition1.getX(), this.getBuildHeight(), blockposition1.getZ()))).g(3.0D);
|
||||
- List<EntityLiving> list = this.a(EntityLiving.class, axisalignedbb, (entityliving) -> {
|
||||
+ List<EntityLiving> list = this.a(EntityLiving.class, axisalignedbb, (java.util.function.Predicate<EntityLiving>) (entityliving) -> { // CraftBukkit - decompile error
|
||||
return entityliving != null && entityliving.isAlive() && this.e(entityliving.getChunkCoordinates());
|
||||
});
|
||||
|
||||
@@ -469,7 +569,7 @@
|
||||
while (iterator.hasNext()) {
|
||||
EntityPlayer entityplayer = (EntityPlayer) iterator.next();
|
||||
|
||||
- if (entityplayer.isSpectator()) {
|
||||
+ if (entityplayer.isSpectator() || (entityplayer.fauxSleeping && !entityplayer.isSleeping())) { // CraftBukkit
|
||||
++i;
|
||||
} else if (entityplayer.isSleeping()) {
|
||||
++j;
|
||||
@@ -487,10 +587,22 @@
|
||||
}
|
||||
|
||||
private void clearWeather() {
|
||||
- this.worldDataServer.setWeatherDuration(0);
|
||||
+ // CraftBukkit start
|
||||
this.worldDataServer.setStorm(false);
|
||||
- this.worldDataServer.setThunderDuration(0);
|
||||
+ // If we stop due to everyone sleeping we should reset the weather duration to some other random value.
|
||||
+ // Not that everyone ever manages to get the whole server to sleep at the same time....
|
||||
+ if (!this.worldDataServer.hasStorm()) {
|
||||
+ this.worldDataServer.setWeatherDuration(0);
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
this.worldDataServer.setThundering(false);
|
||||
+ // CraftBukkit start
|
||||
+ // If we stop due to everyone sleeping we should reset the weather duration to some other random value.
|
||||
+ // Not that everyone ever manages to get the whole server to sleep at the same time....
|
||||
+ if (!this.worldDataServer.isThundering()) {
|
||||
+ this.worldDataServer.setThunderDuration(0);
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
public void resetEmptyTime() {
|
||||
@@ -531,6 +643,7 @@
|
||||
});
|
||||
gameprofilerfiller.c("tickNonPassenger");
|
||||
entity.tick();
|
||||
+ entity.postTick(); // CraftBukkit
|
||||
gameprofilerfiller.exit();
|
||||
}
|
||||
|
||||
@@ -563,6 +676,7 @@
|
||||
});
|
||||
gameprofilerfiller.c("tickPassenger");
|
||||
entity1.passengerTick();
|
||||
+ entity1.postTick(); // CraftBukkit
|
||||
gameprofilerfiller.exit();
|
||||
}
|
||||
|
||||
@@ -619,6 +733,7 @@
|
||||
ChunkProviderServer chunkproviderserver = this.getChunkProvider();
|
||||
|
||||
if (!flag1) {
|
||||
+ org.bukkit.Bukkit.getPluginManager().callEvent(new org.bukkit.event.world.WorldSaveEvent(getWorld())); // CraftBukkit
|
||||
if (iprogressupdate != null) {
|
||||
iprogressupdate.a(new ChatMessage("menu.savingLevel"));
|
||||
}
|
||||
@@ -630,11 +745,19 @@
|
||||
|
||||
chunkproviderserver.save(flag);
|
||||
}
|
||||
+
|
||||
+ // CraftBukkit start - moved from MinecraftServer.saveChunks
|
||||
+ WorldServer worldserver1 = this;
|
||||
+
|
||||
+ worldDataServer.a(worldserver1.getWorldBorder().t());
|
||||
+ worldDataServer.setCustomBossEvents(this.server.getBossBattleCustomData().save());
|
||||
+ convertable.a(this.server.customRegistry, this.worldDataServer, this.server.getPlayerList().save());
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
private void aj() {
|
||||
if (this.dragonBattle != null) {
|
||||
- this.server.getSaveData().a(this.dragonBattle.a());
|
||||
+ this.worldDataServer.a(this.dragonBattle.a()); // CraftBukkit
|
||||
}
|
||||
|
||||
this.getChunkProvider().getWorldPersistentData().a();
|
||||
@@ -695,11 +818,24 @@
|
||||
|
||||
@Override
|
||||
public boolean addEntity(Entity entity) {
|
||||
- return this.addEntity0(entity);
|
||||
+ // CraftBukkit start
|
||||
+ return this.addEntity0(entity, CreatureSpawnEvent.SpawnReason.DEFAULT);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean addEntity(Entity entity, CreatureSpawnEvent.SpawnReason reason) {
|
||||
+ return this.addEntity0(entity, reason);
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
public boolean addEntitySerialized(Entity entity) {
|
||||
- return this.addEntity0(entity);
|
||||
+ // CraftBukkit start
|
||||
+ return this.addEntitySerialized(entity, CreatureSpawnEvent.SpawnReason.DEFAULT);
|
||||
+ }
|
||||
+
|
||||
+ public boolean addEntitySerialized(Entity entity, CreatureSpawnEvent.SpawnReason reason) {
|
||||
+ return this.addEntity0(entity, reason);
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
public void addEntityTeleport(Entity entity) {
|
||||
@@ -749,13 +885,18 @@
|
||||
this.registerEntity(entityplayer);
|
||||
}
|
||||
|
||||
- private boolean addEntity0(Entity entity) {
|
||||
+ // CraftBukkit start
|
||||
+ private boolean addEntity0(Entity entity, CreatureSpawnEvent.SpawnReason spawnReason) {
|
||||
if (entity.dead) {
|
||||
- WorldServer.LOGGER.warn("Tried to add entity {} but it was marked as removed already", EntityTypes.getName(entity.getEntityType()));
|
||||
+ // WorldServer.LOGGER.warn("Tried to add entity {} but it was marked as removed already", EntityTypes.getName(entity.getEntityType())); // CraftBukkit
|
||||
return false;
|
||||
} else if (this.isUUIDTaken(entity)) {
|
||||
return false;
|
||||
} else {
|
||||
+ if (!CraftEventFactory.doEntityAddEventCalling(this, entity, spawnReason)) {
|
||||
+ return false;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
IChunkAccess ichunkaccess = this.getChunkAt(MathHelper.floor(entity.locX() / 16.0D), MathHelper.floor(entity.locZ() / 16.0D), ChunkStatus.FULL, entity.attachedToPlayer);
|
||||
|
||||
if (!(ichunkaccess instanceof Chunk)) {
|
||||
@@ -784,7 +925,7 @@
|
||||
if (entity1 == null) {
|
||||
return false;
|
||||
} else {
|
||||
- WorldServer.LOGGER.warn("Trying to add entity with duplicated UUID {}. Existing {}#{}, new: {}#{}", uuid, EntityTypes.getName(entity1.getEntityType()), entity1.getId(), EntityTypes.getName(entity.getEntityType()), entity.getId());
|
||||
+ // WorldServer.LOGGER.warn("Trying to add entity with duplicated UUID {}. Existing {}#{}, new: {}#{}", uuid, EntityTypes.getName(entity1.getEntityType()), entity1.getId(), EntityTypes.getName(entity.getEntityType()), entity.getId()); // CraftBukkit
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -813,10 +954,16 @@
|
||||
}
|
||||
|
||||
public boolean addAllEntitiesSafely(Entity entity) {
|
||||
+ // CraftBukkit start
|
||||
+ return this.addAllEntitiesSafely(entity, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.DEFAULT);
|
||||
+ }
|
||||
+
|
||||
+ public boolean addAllEntitiesSafely(Entity entity, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason reason) {
|
||||
+ // CraftBukkit end
|
||||
if (entity.recursiveStream().anyMatch(this::isUUIDTaken)) {
|
||||
return false;
|
||||
} else {
|
||||
- this.addAllEntities(entity);
|
||||
+ this.addAllEntities(entity, reason); // CraftBukkit
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -867,10 +1014,17 @@
|
||||
}
|
||||
|
||||
this.getScoreboard().a(entity);
|
||||
+ // CraftBukkit start - SPIGOT-5278
|
||||
+ if (entity instanceof EntityDrowned) {
|
||||
+ this.navigators.remove(((EntityDrowned) entity).navigationWater);
|
||||
+ this.navigators.remove(((EntityDrowned) entity).navigationLand);
|
||||
+ } else
|
||||
+ // CraftBukkit end
|
||||
if (entity instanceof EntityInsentient) {
|
||||
this.navigators.remove(((EntityInsentient) entity).getNavigation());
|
||||
}
|
||||
|
||||
+ entity.valid = false; // CraftBukkit
|
||||
}
|
||||
|
||||
private void registerEntity(Entity entity) {
|
||||
@@ -891,9 +1045,16 @@
|
||||
|
||||
this.entitiesByUUID.put(entity.getUniqueID(), entity);
|
||||
this.getChunkProvider().addEntity(entity);
|
||||
+ // CraftBukkit start - SPIGOT-5278
|
||||
+ if (entity instanceof EntityDrowned) {
|
||||
+ this.navigators.add(((EntityDrowned) entity).navigationWater);
|
||||
+ this.navigators.add(((EntityDrowned) entity).navigationLand);
|
||||
+ } else
|
||||
+ // CraftBukkit end
|
||||
if (entity instanceof EntityInsentient) {
|
||||
this.navigators.add(((EntityInsentient) entity).getNavigation());
|
||||
}
|
||||
+ entity.valid = true; // CraftBukkit
|
||||
}
|
||||
|
||||
}
|
||||
@@ -909,7 +1070,7 @@
|
||||
}
|
||||
|
||||
private void removeEntityFromChunk(Entity entity) {
|
||||
- IChunkAccess ichunkaccess = this.getChunkAt(entity.chunkX, entity.chunkZ, ChunkStatus.FULL, false);
|
||||
+ IChunkAccess ichunkaccess = chunkProvider.getChunkUnchecked(entity.chunkX, entity.chunkZ); // CraftBukkit - SPIGOT-5228: getChunkAt won't find the entity's chunk if it has already been unloaded (i.e. if it switched to state INACCESSIBLE).
|
||||
|
||||
if (ichunkaccess instanceof Chunk) {
|
||||
((Chunk) ichunkaccess).b(entity);
|
||||
@@ -923,10 +1084,33 @@
|
||||
this.everyoneSleeping();
|
||||
}
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ public boolean strikeLightning(Entity entitylightning) {
|
||||
+ return this.strikeLightning(entitylightning, LightningStrikeEvent.Cause.UNKNOWN);
|
||||
+ }
|
||||
+
|
||||
+ public boolean strikeLightning(Entity entitylightning, LightningStrikeEvent.Cause cause) {
|
||||
+ LightningStrikeEvent lightning = new LightningStrikeEvent(this.getWorld(), (org.bukkit.entity.LightningStrike) entitylightning.getBukkitEntity(), cause);
|
||||
+ this.getServer().getPluginManager().callEvent(lightning);
|
||||
+
|
||||
+ if (lightning.isCancelled()) {
|
||||
+ return false;
|
||||
+ }
|
||||
+
|
||||
+ return this.addEntity(entitylightning);
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
@Override
|
||||
public void a(int i, BlockPosition blockposition, int j) {
|
||||
Iterator iterator = this.server.getPlayerList().getPlayers().iterator();
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ EntityHuman entityhuman = null;
|
||||
+ Entity entity = this.getEntity(i);
|
||||
+ if (entity instanceof EntityHuman) entityhuman = (EntityHuman) entity;
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
while (iterator.hasNext()) {
|
||||
EntityPlayer entityplayer = (EntityPlayer) iterator.next();
|
||||
|
||||
@@ -935,6 +1119,12 @@
|
||||
double d1 = (double) blockposition.getY() - entityplayer.locY();
|
||||
double d2 = (double) blockposition.getZ() - entityplayer.locZ();
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ if (entityhuman != null && entityhuman instanceof EntityPlayer && !entityplayer.getBukkitEntity().canSee(((EntityPlayer) entityhuman).getBukkitEntity())) {
|
||||
+ continue;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
if (d0 * d0 + d1 * d1 + d2 * d2 < 1024.0D) {
|
||||
entityplayer.playerConnection.sendPacket(new PacketPlayOutBlockBreakAnimation(i, blockposition, j));
|
||||
}
|
||||
@@ -973,7 +1163,18 @@
|
||||
Iterator iterator = this.navigators.iterator();
|
||||
|
||||
while (iterator.hasNext()) {
|
||||
- NavigationAbstract navigationabstract = (NavigationAbstract) iterator.next();
|
||||
+ // CraftBukkit start - fix SPIGOT-6362
|
||||
+ NavigationAbstract navigationabstract;
|
||||
+ try {
|
||||
+ navigationabstract = (NavigationAbstract) iterator.next();
|
||||
+ } catch (java.util.ConcurrentModificationException ex) {
|
||||
+ // This can happen because the pathfinder update below may trigger a chunk load, which in turn may cause more navigators to register
|
||||
+ // In this case we just run the update again across all the iterators as the chunk will then be loaded
|
||||
+ // As this is a relative edge case it is much faster than copying navigators (on either read or write)
|
||||
+ notify(blockposition, iblockdata, iblockdata1, i);
|
||||
+ return;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
|
||||
if (!navigationabstract.i()) {
|
||||
navigationabstract.b(blockposition);
|
||||
@@ -995,10 +1196,20 @@
|
||||
|
||||
@Override
|
||||
public Explosion createExplosion(@Nullable Entity entity, @Nullable DamageSource damagesource, @Nullable ExplosionDamageCalculator explosiondamagecalculator, double d0, double d1, double d2, float f, boolean flag, Explosion.Effect explosion_effect) {
|
||||
+ // CraftBukkit start
|
||||
+ Explosion explosion = super.createExplosion(entity, damagesource, explosiondamagecalculator, d0, d1, d2, f, flag, explosion_effect);
|
||||
+
|
||||
+ if (explosion.wasCanceled) {
|
||||
+ return explosion;
|
||||
+ }
|
||||
+
|
||||
+ /* Remove
|
||||
Explosion explosion = new Explosion(this, entity, damagesource, explosiondamagecalculator, d0, d1, d2, f, flag, explosion_effect);
|
||||
|
||||
explosion.a();
|
||||
explosion.a(false);
|
||||
+ */
|
||||
+ // CraftBukkit end - TODO: Check if explosions are still properly implemented
|
||||
if (explosion_effect == Explosion.Effect.NONE) {
|
||||
explosion.clearBlocks();
|
||||
}
|
||||
@@ -1063,13 +1274,20 @@
|
||||
}
|
||||
|
||||
public <T extends ParticleParam> int a(T t0, double d0, double d1, double d2, int i, double d3, double d4, double d5, double d6) {
|
||||
- PacketPlayOutWorldParticles packetplayoutworldparticles = new PacketPlayOutWorldParticles(t0, false, d0, d1, d2, (float) d3, (float) d4, (float) d5, (float) d6, i);
|
||||
+ // CraftBukkit - visibility api support
|
||||
+ return sendParticles(null, t0, d0, d1, d2, i, d3, d4, d5, d6, false);
|
||||
+ }
|
||||
+
|
||||
+ public <T extends ParticleParam> int sendParticles(EntityPlayer sender, T t0, double d0, double d1, double d2, int i, double d3, double d4, double d5, double d6, boolean force) {
|
||||
+ PacketPlayOutWorldParticles packetplayoutworldparticles = new PacketPlayOutWorldParticles(t0, force, d0, d1, d2, (float) d3, (float) d4, (float) d5, (float) d6, i);
|
||||
+ // CraftBukkit end
|
||||
int j = 0;
|
||||
|
||||
for (int k = 0; k < this.players.size(); ++k) {
|
||||
EntityPlayer entityplayer = (EntityPlayer) this.players.get(k);
|
||||
+ if (sender != null && !entityplayer.getBukkitEntity().canSee(sender.getBukkitEntity())) continue; // CraftBukkit
|
||||
|
||||
- if (this.a(entityplayer, false, d0, d1, d2, packetplayoutworldparticles)) {
|
||||
+ if (this.a(entityplayer, force, d0, d1, d2, packetplayoutworldparticles)) { // CraftBukkit
|
||||
++j;
|
||||
}
|
||||
}
|
||||
@@ -1111,7 +1329,7 @@
|
||||
|
||||
@Nullable
|
||||
public BlockPosition a(StructureGenerator<?> structuregenerator, BlockPosition blockposition, int i, boolean flag) {
|
||||
- return !this.server.getSaveData().getGeneratorSettings().shouldGenerateMapFeatures() ? null : this.getChunkProvider().getChunkGenerator().findNearestMapFeature(this, structuregenerator, blockposition, i, flag);
|
||||
+ return !this.worldDataServer.getGeneratorSettings().shouldGenerateMapFeatures() ? null : this.getChunkProvider().getChunkGenerator().findNearestMapFeature(this, structuregenerator, blockposition, i, flag); // CraftBukkit
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@@ -1149,7 +1367,13 @@
|
||||
@Override
|
||||
public WorldMap a(String s) {
|
||||
return (WorldMap) this.getMinecraftServer().E().getWorldPersistentData().b(() -> {
|
||||
- return new WorldMap(s);
|
||||
+ // CraftBukkit start
|
||||
+ // We only get here when the data file exists, but is not a valid map
|
||||
+ WorldMap newMap = new WorldMap(s);
|
||||
+ MapInitializeEvent event = new MapInitializeEvent(newMap.mapView);
|
||||
+ Bukkit.getServer().getPluginManager().callEvent(event);
|
||||
+ return newMap;
|
||||
+ // CraftBukkit end
|
||||
}, s);
|
||||
}
|
||||
|
||||
@@ -1460,6 +1684,11 @@
|
||||
@Override
|
||||
public void update(BlockPosition blockposition, Block block) {
|
||||
if (!this.isDebugWorld()) {
|
||||
+ // CraftBukkit start
|
||||
+ if (populating) {
|
||||
+ return;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
this.applyPhysics(blockposition, block);
|
||||
}
|
||||
|
||||
@@ -1474,12 +1703,12 @@
|
||||
}
|
||||
|
||||
public boolean isFlatWorld() {
|
||||
- return this.server.getSaveData().getGeneratorSettings().isFlatWorld();
|
||||
+ return this.worldDataServer.getGeneratorSettings().isFlatWorld(); // CraftBukkit
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getSeed() {
|
||||
- return this.server.getSaveData().getGeneratorSettings().getSeed();
|
||||
+ return this.worldDataServer.getGeneratorSettings().getSeed(); // CraftBukkit
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@@ -1499,9 +1728,9 @@
|
||||
|
||||
@VisibleForTesting
|
||||
public String F() {
|
||||
- return String.format("players: %s, entities: %d [%s], block_entities: %d [%s], block_ticks: %d, fluid_ticks: %d, chunk_source: %s", this.players.size(), this.entitiesById.size(), a((Collection) this.entitiesById.values(), (entity) -> {
|
||||
+ return String.format("players: %s, entities: %d [%s], block_entities: %d [%s], block_ticks: %d, fluid_ticks: %d, chunk_source: %s", this.players.size(), this.entitiesById.size(), a(this.entitiesById.values(), (entity) -> { // CraftBukkit - decompile error
|
||||
return IRegistry.ENTITY_TYPE.getKey(entity.getEntityType());
|
||||
- }), this.tileEntityListTick.size(), a((Collection) this.tileEntityListTick, (tileentity) -> {
|
||||
+ }), this.tileEntityListTick.size(), a(this.tileEntityListTick, (tileentity) -> { // CraftBukkit - decompile error
|
||||
return IRegistry.BLOCK_ENTITY_TYPE.getKey(tileentity.getTileType());
|
||||
}), this.getBlockTickList().a(), this.getFluidTickList().a(), this.P());
|
||||
}
|
||||
@@ -1509,7 +1738,7 @@
|
||||
private static <T> String a(Collection<T> collection, Function<T, MinecraftKey> function) {
|
||||
try {
|
||||
Object2IntOpenHashMap<MinecraftKey> object2intopenhashmap = new Object2IntOpenHashMap();
|
||||
- Iterator iterator = collection.iterator();
|
||||
+ Iterator<T> iterator = collection.iterator(); // CraftBukkit - decompile error
|
||||
|
||||
while (iterator.hasNext()) {
|
||||
T t0 = iterator.next();
|
||||
@@ -1518,7 +1747,8 @@
|
||||
object2intopenhashmap.addTo(minecraftkey, 1);
|
||||
}
|
||||
|
||||
- return (String) object2intopenhashmap.object2IntEntrySet().stream().sorted(Comparator.comparing(it.unimi.dsi.fastutil.objects.Object2IntMap.Entry::getIntValue).reversed()).limit(5L).map((it_unimi_dsi_fastutil_objects_object2intmap_entry) -> {
|
||||
+ // CraftBukkit - decompile error
|
||||
+ return (String) object2intopenhashmap.object2IntEntrySet().stream().sorted(Comparator.comparing(it.unimi.dsi.fastutil.objects.Object2IntMap.Entry<MinecraftKey>::getIntValue).reversed()).limit(5L).map((it_unimi_dsi_fastutil_objects_object2intmap_entry) -> {
|
||||
return it_unimi_dsi_fastutil_objects_object2intmap_entry.getKey() + ":" + it_unimi_dsi_fastutil_objects_object2intmap_entry.getIntValue();
|
||||
}).collect(Collectors.joining(","));
|
||||
} catch (Exception exception) {
|
||||
@@ -1527,16 +1757,32 @@
|
||||
}
|
||||
|
||||
public static void a(WorldServer worldserver) {
|
||||
+ // CraftBukkit start
|
||||
+ WorldServer.a(worldserver, null);
|
||||
+ }
|
||||
+
|
||||
+ public static void a(WorldServer worldserver, Entity entity) {
|
||||
+ // CraftBukkit end
|
||||
BlockPosition blockposition = WorldServer.a;
|
||||
int i = blockposition.getX();
|
||||
int j = blockposition.getY() - 2;
|
||||
int k = blockposition.getZ();
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ org.bukkit.craftbukkit.util.BlockStateListPopulator blockList = new org.bukkit.craftbukkit.util.BlockStateListPopulator(worldserver);
|
||||
BlockPosition.b(i - 2, j + 1, k - 2, i + 2, j + 3, k + 2).forEach((blockposition1) -> {
|
||||
- worldserver.setTypeUpdate(blockposition1, Blocks.AIR.getBlockData());
|
||||
+ blockList.setTypeAndData(blockposition1, Blocks.AIR.getBlockData(), 3);
|
||||
});
|
||||
BlockPosition.b(i - 2, j, k - 2, i + 2, j, k + 2).forEach((blockposition1) -> {
|
||||
- worldserver.setTypeUpdate(blockposition1, Blocks.OBSIDIAN.getBlockData());
|
||||
+ blockList.setTypeAndData(blockposition1, Blocks.OBSIDIAN.getBlockData(), 3);
|
||||
});
|
||||
+ org.bukkit.World bworld = worldserver.getWorld();
|
||||
+ org.bukkit.event.world.PortalCreateEvent portalEvent = new org.bukkit.event.world.PortalCreateEvent((List<org.bukkit.block.BlockState>) (List) blockList.getList(), bworld, (entity == null) ? null : entity.getBukkitEntity(), org.bukkit.event.world.PortalCreateEvent.CreateReason.END_PLATFORM);
|
||||
+
|
||||
+ worldserver.getServer().getPluginManager().callEvent(portalEvent);
|
||||
+ if (!portalEvent.isCancelled()) {
|
||||
+ blockList.updateList();
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
--- a/net/minecraft/server/HandshakeListener.java
|
||||
+++ b/net/minecraft/server/HandshakeListener.java
|
||||
@@ -1,7 +1,16 @@
|
||||
package net.minecraft.server;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import java.net.InetAddress;
|
||||
+import java.util.HashMap;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public class HandshakeListener implements PacketHandshakingInListener {
|
||||
|
||||
+ // CraftBukkit start - add fields
|
||||
+ private static final HashMap<InetAddress, Long> throttleTracker = new HashMap<InetAddress, Long>();
|
||||
+ private static int throttleCounter = 0;
|
||||
+ // CraftBukkit end
|
||||
private static final IChatBaseComponent a = new ChatComponentText("Ignoring status request");
|
||||
private final MinecraftServer b;
|
||||
private final NetworkManager c;
|
||||
@@ -16,6 +25,40 @@
|
||||
switch (packethandshakinginsetprotocol.b()) {
|
||||
case LOGIN:
|
||||
this.c.setProtocol(EnumProtocol.LOGIN);
|
||||
+ // CraftBukkit start - Connection throttle
|
||||
+ try {
|
||||
+ long currentTime = System.currentTimeMillis();
|
||||
+ long connectionThrottle = this.b.server.getConnectionThrottle();
|
||||
+ InetAddress address = ((java.net.InetSocketAddress) this.c.getSocketAddress()).getAddress();
|
||||
+
|
||||
+ synchronized (throttleTracker) {
|
||||
+ if (throttleTracker.containsKey(address) && !"127.0.0.1".equals(address.getHostAddress()) && currentTime - throttleTracker.get(address) < connectionThrottle) {
|
||||
+ throttleTracker.put(address, currentTime);
|
||||
+ ChatMessage chatmessage = new ChatMessage("Connection throttled! Please wait before reconnecting.");
|
||||
+ this.c.sendPacket(new PacketLoginOutDisconnect(chatmessage));
|
||||
+ this.c.close(chatmessage);
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ throttleTracker.put(address, currentTime);
|
||||
+ throttleCounter++;
|
||||
+ if (throttleCounter > 200) {
|
||||
+ throttleCounter = 0;
|
||||
+
|
||||
+ // Cleanup stale entries
|
||||
+ java.util.Iterator iter = throttleTracker.entrySet().iterator();
|
||||
+ while (iter.hasNext()) {
|
||||
+ java.util.Map.Entry<InetAddress, Long> entry = (java.util.Map.Entry) iter.next();
|
||||
+ if (entry.getValue() > connectionThrottle) {
|
||||
+ iter.remove();
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ } catch (Throwable t) {
|
||||
+ org.apache.logging.log4j.LogManager.getLogger().debug("Failed to check connection throttle", t);
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
if (packethandshakinginsetprotocol.c() != SharedConstants.getGameVersion().getProtocolVersion()) {
|
||||
ChatMessage chatmessage;
|
||||
|
||||
@@ -29,6 +72,7 @@
|
||||
this.c.close(chatmessage);
|
||||
} else {
|
||||
this.c.setPacketListener(new LoginListener(this.b, this.c));
|
||||
+ ((LoginListener) this.c.j()).hostname = packethandshakinginsetprotocol.hostname + ":" + packethandshakinginsetprotocol.port; // CraftBukkit - set hostname
|
||||
}
|
||||
break;
|
||||
case STATUS:
|
||||
@@ -0,0 +1,34 @@
|
||||
--- a/net/minecraft/server/LegacyPingHandler.java
|
||||
+++ b/net/minecraft/server/LegacyPingHandler.java
|
||||
@@ -34,11 +34,12 @@
|
||||
MinecraftServer minecraftserver = this.b.d();
|
||||
int i = bytebuf.readableBytes();
|
||||
String s;
|
||||
+ org.bukkit.event.server.ServerListPingEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callServerListPingEvent(minecraftserver.server, inetsocketaddress.getAddress(), minecraftserver.getMotd(), minecraftserver.getPlayerCount(), minecraftserver.getMaxPlayers()); // CraftBukkit
|
||||
|
||||
switch (i) {
|
||||
case 0:
|
||||
LegacyPingHandler.LOGGER.debug("Ping: (<1.3.x) from {}:{}", inetsocketaddress.getAddress(), inetsocketaddress.getPort());
|
||||
- s = String.format("%s\u00a7%d\u00a7%d", minecraftserver.getMotd(), minecraftserver.getPlayerCount(), minecraftserver.getMaxPlayers());
|
||||
+ s = String.format("%s\u00a7%d\u00a7%d", event.getMotd(), event.getNumPlayers(), event.getMaxPlayers()); // CraftBukkit
|
||||
this.a(channelhandlercontext, this.a(s));
|
||||
break;
|
||||
case 1:
|
||||
@@ -47,7 +48,7 @@
|
||||
}
|
||||
|
||||
LegacyPingHandler.LOGGER.debug("Ping: (1.4-1.5.x) from {}:{}", inetsocketaddress.getAddress(), inetsocketaddress.getPort());
|
||||
- s = String.format("\u00a71\u0000%d\u0000%s\u0000%s\u0000%d\u0000%d", 127, minecraftserver.getVersion(), minecraftserver.getMotd(), minecraftserver.getPlayerCount(), minecraftserver.getMaxPlayers());
|
||||
+ s = String.format("\u00a71\u0000%d\u0000%s\u0000%s\u0000%d\u0000%d", 127, minecraftserver.getVersion(), event.getMotd(), event.getNumPlayers(), event.getMaxPlayers()); // CraftBukkit
|
||||
this.a(channelhandlercontext, this.a(s));
|
||||
break;
|
||||
default:
|
||||
@@ -66,7 +67,7 @@
|
||||
}
|
||||
|
||||
LegacyPingHandler.LOGGER.debug("Ping: (1.6) from {}:{}", inetsocketaddress.getAddress(), inetsocketaddress.getPort());
|
||||
- String s1 = String.format("\u00a71\u0000%d\u0000%s\u0000%s\u0000%d\u0000%d", 127, minecraftserver.getVersion(), minecraftserver.getMotd(), minecraftserver.getPlayerCount(), minecraftserver.getMaxPlayers());
|
||||
+ String s1 = String.format("\u00a71\u0000%d\u0000%s\u0000%s\u0000%d\u0000%d", 127, minecraftserver.getVersion(), event.getMotd(), event.getNumPlayers(), event.getMaxPlayers()); // CraftBukkit
|
||||
ByteBuf bytebuf1 = this.a(s1);
|
||||
|
||||
try {
|
||||
@@ -0,0 +1,128 @@
|
||||
--- a/net/minecraft/server/LoginListener.java
|
||||
+++ b/net/minecraft/server/LoginListener.java
|
||||
@@ -18,6 +18,12 @@
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.craftbukkit.util.Waitable;
|
||||
+import org.bukkit.event.player.AsyncPlayerPreLoginEvent;
|
||||
+import org.bukkit.event.player.PlayerPreLoginEvent;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public class LoginListener implements PacketLoginInListener {
|
||||
|
||||
private static final AtomicInteger b = new AtomicInteger(0);
|
||||
@@ -32,6 +38,7 @@
|
||||
private final String j;
|
||||
private SecretKey loginKey;
|
||||
private EntityPlayer l;
|
||||
+ public String hostname = ""; // CraftBukkit - add field
|
||||
|
||||
public LoginListener(MinecraftServer minecraftserver, NetworkManager networkmanager) {
|
||||
this.g = LoginListener.EnumProtocolState.HELLO;
|
||||
@@ -60,6 +67,20 @@
|
||||
|
||||
}
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ @Deprecated
|
||||
+ public void disconnect(String s) {
|
||||
+ try {
|
||||
+ IChatBaseComponent ichatbasecomponent = new ChatComponentText(s);
|
||||
+ LoginListener.LOGGER.info("Disconnecting {}: {}", this.d(), s);
|
||||
+ this.networkManager.sendPacket(new PacketLoginOutDisconnect(ichatbasecomponent));
|
||||
+ this.networkManager.close(ichatbasecomponent);
|
||||
+ } catch (Exception exception) {
|
||||
+ LoginListener.LOGGER.error("Error whilst disconnecting player", exception);
|
||||
+ }
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
@Override
|
||||
public NetworkManager a() {
|
||||
return this.networkManager;
|
||||
@@ -81,10 +102,12 @@
|
||||
this.i = this.a(this.i);
|
||||
}
|
||||
|
||||
- IChatBaseComponent ichatbasecomponent = this.server.getPlayerList().attemptLogin(this.networkManager.getSocketAddress(), this.i);
|
||||
+ // CraftBukkit start - fire PlayerLoginEvent
|
||||
+ EntityPlayer s = this.server.getPlayerList().attemptLogin(this, this.i, hostname);
|
||||
|
||||
- if (ichatbasecomponent != null) {
|
||||
- this.disconnect(ichatbasecomponent);
|
||||
+ if (s == null) {
|
||||
+ // this.disconnect(ichatbasecomponent);
|
||||
+ // CraftBukkit end
|
||||
} else {
|
||||
this.g = LoginListener.EnumProtocolState.ACCEPTED;
|
||||
if (this.server.ax() >= 0 && !this.networkManager.isLocal()) {
|
||||
@@ -98,9 +121,9 @@
|
||||
|
||||
if (entityplayer != null) {
|
||||
this.g = LoginListener.EnumProtocolState.DELAY_ACCEPT;
|
||||
- this.l = this.server.getPlayerList().processLogin(this.i);
|
||||
+ this.l = this.server.getPlayerList().processLogin(this.i, s); // CraftBukkit - add player reference
|
||||
} else {
|
||||
- this.server.getPlayerList().a(this.networkManager, this.server.getPlayerList().processLogin(this.i));
|
||||
+ this.server.getPlayerList().a(this.networkManager, this.server.getPlayerList().processLogin(this.i, s)); // CraftBukkit - add player reference
|
||||
}
|
||||
}
|
||||
|
||||
@@ -158,6 +181,43 @@
|
||||
try {
|
||||
LoginListener.this.i = LoginListener.this.server.getMinecraftSessionService().hasJoinedServer(new GameProfile((UUID) null, gameprofile.getName()), s, this.a());
|
||||
if (LoginListener.this.i != null) {
|
||||
+ // CraftBukkit start - fire PlayerPreLoginEvent
|
||||
+ if (!networkManager.isConnected()) {
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ String playerName = i.getName();
|
||||
+ java.net.InetAddress address = ((java.net.InetSocketAddress) networkManager.getSocketAddress()).getAddress();
|
||||
+ java.util.UUID uniqueId = i.getId();
|
||||
+ final org.bukkit.craftbukkit.CraftServer server = LoginListener.this.server.server;
|
||||
+
|
||||
+ AsyncPlayerPreLoginEvent asyncEvent = new AsyncPlayerPreLoginEvent(playerName, address, uniqueId);
|
||||
+ server.getPluginManager().callEvent(asyncEvent);
|
||||
+
|
||||
+ if (PlayerPreLoginEvent.getHandlerList().getRegisteredListeners().length != 0) {
|
||||
+ final PlayerPreLoginEvent event = new PlayerPreLoginEvent(playerName, address, uniqueId);
|
||||
+ if (asyncEvent.getResult() != PlayerPreLoginEvent.Result.ALLOWED) {
|
||||
+ event.disallow(asyncEvent.getResult(), asyncEvent.getKickMessage());
|
||||
+ }
|
||||
+ Waitable<PlayerPreLoginEvent.Result> waitable = new Waitable<PlayerPreLoginEvent.Result>() {
|
||||
+ @Override
|
||||
+ protected PlayerPreLoginEvent.Result evaluate() {
|
||||
+ server.getPluginManager().callEvent(event);
|
||||
+ return event.getResult();
|
||||
+ }};
|
||||
+
|
||||
+ LoginListener.this.server.processQueue.add(waitable);
|
||||
+ if (waitable.get() != PlayerPreLoginEvent.Result.ALLOWED) {
|
||||
+ disconnect(event.getKickMessage());
|
||||
+ return;
|
||||
+ }
|
||||
+ } else {
|
||||
+ if (asyncEvent.getLoginResult() != AsyncPlayerPreLoginEvent.Result.ALLOWED) {
|
||||
+ disconnect(asyncEvent.getKickMessage());
|
||||
+ return;
|
||||
+ }
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
LoginListener.LOGGER.info("UUID of player {} is {}", LoginListener.this.i.getName(), LoginListener.this.i.getId());
|
||||
LoginListener.this.g = LoginListener.EnumProtocolState.READY_TO_ACCEPT;
|
||||
} else if (LoginListener.this.server.isEmbeddedServer()) {
|
||||
@@ -177,6 +237,11 @@
|
||||
LoginListener.this.disconnect(new ChatMessage("multiplayer.disconnect.authservers_down"));
|
||||
LoginListener.LOGGER.error("Couldn't verify username because servers are unavailable");
|
||||
}
|
||||
+ // CraftBukkit start - catch all exceptions
|
||||
+ } catch (Exception exception) {
|
||||
+ disconnect("Failed to verify username!");
|
||||
+ server.server.getLogger().log(java.util.logging.Level.WARNING, "Exception verifying " + gameprofile.getName(), exception);
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,115 @@
|
||||
--- a/net/minecraft/server/PacketStatusListener.java
|
||||
+++ b/net/minecraft/server/PacketStatusListener.java
|
||||
@@ -1,5 +1,14 @@
|
||||
package net.minecraft.server;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import com.mojang.authlib.GameProfile;
|
||||
+import java.net.InetSocketAddress;
|
||||
+import java.util.Iterator;
|
||||
+import org.bukkit.craftbukkit.util.CraftChatMessage;
|
||||
+import org.bukkit.craftbukkit.util.CraftIconCache;
|
||||
+import org.bukkit.entity.Player;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public class PacketStatusListener implements PacketStatusInListener {
|
||||
|
||||
private static final IChatBaseComponent a = new ChatMessage("multiplayer.status.request_handled");
|
||||
@@ -26,8 +35,96 @@
|
||||
this.networkManager.close(PacketStatusListener.a);
|
||||
} else {
|
||||
this.d = true;
|
||||
- this.networkManager.sendPacket(new PacketStatusOutServerInfo(this.minecraftServer.getServerPing()));
|
||||
+ // CraftBukkit start
|
||||
+ // this.networkManager.sendPacket(new PacketStatusOutServerInfo(this.minecraftServer.getServerPing()));
|
||||
+ final Object[] players = minecraftServer.getPlayerList().players.toArray();
|
||||
+ class ServerListPingEvent extends org.bukkit.event.server.ServerListPingEvent {
|
||||
+
|
||||
+ CraftIconCache icon = minecraftServer.server.getServerIcon();
|
||||
+
|
||||
+ ServerListPingEvent() {
|
||||
+ super(((InetSocketAddress) networkManager.getSocketAddress()).getAddress(), minecraftServer.getMotd(), minecraftServer.getPlayerList().getMaxPlayers());
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void setServerIcon(org.bukkit.util.CachedServerIcon icon) {
|
||||
+ if (!(icon instanceof CraftIconCache)) {
|
||||
+ throw new IllegalArgumentException(icon + " was not created by " + org.bukkit.craftbukkit.CraftServer.class);
|
||||
+ }
|
||||
+ this.icon = (CraftIconCache) icon;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public Iterator<Player> iterator() throws UnsupportedOperationException {
|
||||
+ return new Iterator<Player>() {
|
||||
+ int i;
|
||||
+ int ret = Integer.MIN_VALUE;
|
||||
+ EntityPlayer player;
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean hasNext() {
|
||||
+ if (player != null) {
|
||||
+ return true;
|
||||
+ }
|
||||
+ final Object[] currentPlayers = players;
|
||||
+ for (int length = currentPlayers.length, i = this.i; i < length; i++) {
|
||||
+ final EntityPlayer player = (EntityPlayer) currentPlayers[i];
|
||||
+ if (player != null) {
|
||||
+ this.i = i + 1;
|
||||
+ this.player = player;
|
||||
+ return true;
|
||||
+ }
|
||||
+ }
|
||||
+ return false;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public Player next() {
|
||||
+ if (!hasNext()) {
|
||||
+ throw new java.util.NoSuchElementException();
|
||||
+ }
|
||||
+ final EntityPlayer player = this.player;
|
||||
+ this.player = null;
|
||||
+ this.ret = this.i - 1;
|
||||
+ return player.getBukkitEntity();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void remove() {
|
||||
+ final Object[] currentPlayers = players;
|
||||
+ final int i = this.ret;
|
||||
+ if (i < 0 || currentPlayers[i] == null) {
|
||||
+ throw new IllegalStateException();
|
||||
+ }
|
||||
+ currentPlayers[i] = null;
|
||||
+ }
|
||||
+ };
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ ServerListPingEvent event = new ServerListPingEvent();
|
||||
+ this.minecraftServer.server.getPluginManager().callEvent(event);
|
||||
+
|
||||
+ java.util.List<GameProfile> profiles = new java.util.ArrayList<GameProfile>(players.length);
|
||||
+ for (Object player : players) {
|
||||
+ if (player != null) {
|
||||
+ profiles.add(((EntityPlayer) player).getProfile());
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ ServerPing.ServerPingPlayerSample playerSample = new ServerPing.ServerPingPlayerSample(event.getMaxPlayers(), profiles.size());
|
||||
+ playerSample.a(profiles.toArray(new GameProfile[profiles.size()]));
|
||||
+
|
||||
+ ServerPing ping = new ServerPing();
|
||||
+ ping.setFavicon(event.icon.value);
|
||||
+ ping.setMOTD(CraftChatMessage.fromString(event.getMotd(), true)[0]);
|
||||
+ ping.setPlayerSample(playerSample);
|
||||
+ int version = SharedConstants.getGameVersion().getProtocolVersion();
|
||||
+ ping.setServerInfo(new ServerPing.ServerData(minecraftServer.getServerModName() + " " + minecraftServer.getVersion(), version));
|
||||
+
|
||||
+ this.networkManager.sendPacket(new PacketStatusOutServerInfo(ping));
|
||||
}
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
@Override
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,29 @@
|
||||
--- a/net/minecraft/server/ServerConnection.java
|
||||
+++ b/net/minecraft/server/ServerConnection.java
|
||||
@@ -74,14 +74,24 @@
|
||||
int j = ServerConnection.this.e.k();
|
||||
Object object = j > 0 ? new NetworkManagerServer(j) : new NetworkManager(EnumProtocolDirection.SERVERBOUND);
|
||||
|
||||
- ServerConnection.this.connectedChannels.add(object);
|
||||
+ ServerConnection.this.connectedChannels.add((NetworkManager) object); // CraftBukkit - decompile error
|
||||
channel.pipeline().addLast("packet_handler", (ChannelHandler) object);
|
||||
((NetworkManager) object).setPacketListener(new HandshakeListener(ServerConnection.this.e, (NetworkManager) object));
|
||||
}
|
||||
- }).group((EventLoopGroup) lazyinitvar.a()).localAddress(inetaddress, i)).bind().syncUninterruptibly());
|
||||
+ }).group((EventLoopGroup) lazyinitvar.a()).localAddress(inetaddress, i)).option(ChannelOption.AUTO_READ, false).bind().syncUninterruptibly()); // CraftBukkit
|
||||
}
|
||||
}
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ public void acceptConnections() {
|
||||
+ synchronized (this.listeningChannels) {
|
||||
+ for (ChannelFuture future : this.listeningChannels) {
|
||||
+ future.channel().config().setAutoRead(true);
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
public void b() {
|
||||
this.c = false;
|
||||
Iterator iterator = this.listeningChannels.iterator();
|
||||
@@ -0,0 +1,38 @@
|
||||
--- a/net/minecraft/server/ExpirableListEntry.java
|
||||
+++ b/net/minecraft/server/ExpirableListEntry.java
|
||||
@@ -23,7 +23,7 @@
|
||||
}
|
||||
|
||||
protected ExpirableListEntry(T t0, JsonObject jsonobject) {
|
||||
- super(t0);
|
||||
+ super(checkExpiry(t0, jsonobject));
|
||||
|
||||
Date date;
|
||||
|
||||
@@ -74,4 +74,26 @@
|
||||
jsonobject.addProperty("expires", this.d == null ? "forever" : ExpirableListEntry.a.format(this.d));
|
||||
jsonobject.addProperty("reason", this.e);
|
||||
}
|
||||
+
|
||||
+ // CraftBukkit start
|
||||
+ public Date getCreated() {
|
||||
+ return this.b;
|
||||
+ }
|
||||
+
|
||||
+ private static <T> T checkExpiry(T object, JsonObject jsonobject) {
|
||||
+ Date expires = null;
|
||||
+
|
||||
+ try {
|
||||
+ expires = jsonobject.has("expires") ? a.parse(jsonobject.get("expires").getAsString()) : null;
|
||||
+ } catch (ParseException ex) {
|
||||
+ // Guess we don't have a date
|
||||
+ }
|
||||
+
|
||||
+ if (expires == null || expires.after(new Date())) {
|
||||
+ return object;
|
||||
+ } else {
|
||||
+ return null;
|
||||
+ }
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
--- a/net/minecraft/server/JsonList.java
|
||||
+++ b/net/minecraft/server/JsonList.java
|
||||
@@ -50,7 +50,7 @@
|
||||
@Nullable
|
||||
public V get(K k0) {
|
||||
this.g();
|
||||
- return (JsonListEntry) this.d.get(this.a(k0));
|
||||
+ return (V) this.d.get(this.a(k0)); // CraftBukkit - fix decompile error
|
||||
}
|
||||
|
||||
public void remove(K k0) {
|
||||
@@ -72,6 +72,12 @@
|
||||
return (String[]) this.d.keySet().toArray(new String[this.d.size()]);
|
||||
}
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ public Collection<V> getValues() {
|
||||
+ return this.d.values();
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
public boolean isEmpty() {
|
||||
return this.d.size() < 1;
|
||||
}
|
||||
@@ -89,7 +95,7 @@
|
||||
Iterator iterator = this.d.values().iterator();
|
||||
|
||||
while (iterator.hasNext()) {
|
||||
- V v0 = (JsonListEntry) iterator.next();
|
||||
+ V v0 = (V) iterator.next(); // CraftBukkit - decompile error
|
||||
|
||||
if (v0.hasExpired()) {
|
||||
list.add(v0.getKey());
|
||||
@@ -99,7 +105,7 @@
|
||||
iterator = list.iterator();
|
||||
|
||||
while (iterator.hasNext()) {
|
||||
- K k0 = iterator.next();
|
||||
+ K k0 = (K) iterator.next(); // CraftBukkit - decompile error
|
||||
|
||||
this.d.remove(this.a(k0));
|
||||
}
|
||||
@@ -119,7 +125,7 @@
|
||||
JsonObject jsonobject = new JsonObject();
|
||||
|
||||
jsonlistentry.getClass();
|
||||
- return (JsonObject) SystemUtils.a((Object) jsonobject, jsonlistentry::a);
|
||||
+ return (JsonObject) SystemUtils.a(jsonobject, jsonlistentry::a); // CraftBukkit - decompile error
|
||||
}).forEach(jsonarray::add);
|
||||
BufferedWriter bufferedwriter = Files.newWriter(this.c, StandardCharsets.UTF_8);
|
||||
Throwable throwable = null;
|
||||
@@ -163,7 +169,7 @@
|
||||
JsonListEntry<K> jsonlistentry = this.a(jsonobject);
|
||||
|
||||
if (jsonlistentry.getKey() != null) {
|
||||
- this.d.put(this.a(jsonlistentry.getKey()), jsonlistentry);
|
||||
+ this.d.put(this.a(jsonlistentry.getKey()), (V) jsonlistentry); // CraftBukkit - fix decompile error
|
||||
}
|
||||
}
|
||||
} catch (Throwable throwable1) {
|
||||
@@ -0,0 +1,69 @@
|
||||
--- a/net/minecraft/server/NameReferencingFileConverter.java
|
||||
+++ b/net/minecraft/server/NameReferencingFileConverter.java
|
||||
@@ -80,7 +80,7 @@
|
||||
try {
|
||||
gameprofilebanlist.load();
|
||||
} catch (IOException ioexception) {
|
||||
- NameReferencingFileConverter.LOGGER.warn("Could not load existing file {}", gameprofilebanlist.b().getName(), ioexception);
|
||||
+ NameReferencingFileConverter.LOGGER.warn("Could not load existing file {}", gameprofilebanlist.b().getName()); // CraftBukkit - don't print stacktrace
|
||||
}
|
||||
}
|
||||
|
||||
@@ -138,7 +138,7 @@
|
||||
try {
|
||||
ipbanlist.load();
|
||||
} catch (IOException ioexception) {
|
||||
- NameReferencingFileConverter.LOGGER.warn("Could not load existing file {}", ipbanlist.b().getName(), ioexception);
|
||||
+ NameReferencingFileConverter.LOGGER.warn("Could not load existing file {}", ipbanlist.b().getName()); // CraftBukkit - don't print stacktrace
|
||||
}
|
||||
}
|
||||
|
||||
@@ -179,7 +179,7 @@
|
||||
try {
|
||||
oplist.load();
|
||||
} catch (IOException ioexception) {
|
||||
- NameReferencingFileConverter.LOGGER.warn("Could not load existing file {}", oplist.b().getName(), ioexception);
|
||||
+ NameReferencingFileConverter.LOGGER.warn("Could not load existing file {}", oplist.b().getName()); // CraftBukkit - don't print stacktrace
|
||||
}
|
||||
}
|
||||
|
||||
@@ -223,7 +223,7 @@
|
||||
try {
|
||||
whitelist.load();
|
||||
} catch (IOException ioexception) {
|
||||
- NameReferencingFileConverter.LOGGER.warn("Could not load existing file {}", whitelist.b().getName(), ioexception);
|
||||
+ NameReferencingFileConverter.LOGGER.warn("Could not load existing file {}", whitelist.b().getName()); // CraftBukkit - don't print stacktrace
|
||||
}
|
||||
}
|
||||
|
||||
@@ -346,6 +346,30 @@
|
||||
File file5 = new File(file, s2 + ".dat");
|
||||
File file6 = new File(file4, s3 + ".dat");
|
||||
|
||||
+ // CraftBukkit start - Use old file name to seed lastKnownName
|
||||
+ NBTTagCompound root = null;
|
||||
+
|
||||
+ try {
|
||||
+ root = NBTCompressedStreamTools.a(new java.io.FileInputStream(file5));
|
||||
+ } catch (Exception exception) {
|
||||
+ exception.printStackTrace();
|
||||
+ }
|
||||
+
|
||||
+ if (root != null) {
|
||||
+ if (!root.hasKey("bukkit")) {
|
||||
+ root.set("bukkit", new NBTTagCompound());
|
||||
+ }
|
||||
+ NBTTagCompound data = root.getCompound("bukkit");
|
||||
+ data.setString("lastKnownName", s2);
|
||||
+
|
||||
+ try {
|
||||
+ NBTCompressedStreamTools.a(root, new java.io.FileOutputStream(file2));
|
||||
+ } catch (Exception exception) {
|
||||
+ exception.printStackTrace();
|
||||
+ }
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
NameReferencingFileConverter.b(file4);
|
||||
if (!file5.renameTo(file6)) {
|
||||
throw new NameReferencingFileConverter.FileConversionException("Could not convert file for " + s2);
|
||||
@@ -0,0 +1,786 @@
|
||||
--- a/net/minecraft/server/PlayerList.java
|
||||
+++ b/net/minecraft/server/PlayerList.java
|
||||
@@ -21,6 +21,23 @@
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import com.google.common.base.Predicate;
|
||||
+import com.google.common.collect.Iterables;
|
||||
+
|
||||
+import org.bukkit.craftbukkit.CraftServer;
|
||||
+import org.bukkit.craftbukkit.CraftWorld;
|
||||
+
|
||||
+import org.bukkit.Location;
|
||||
+import org.bukkit.craftbukkit.util.CraftChatMessage;
|
||||
+import org.bukkit.entity.Player;
|
||||
+import org.bukkit.event.player.PlayerChangedWorldEvent;
|
||||
+import org.bukkit.event.player.PlayerJoinEvent;
|
||||
+import org.bukkit.event.player.PlayerLoginEvent;
|
||||
+import org.bukkit.event.player.PlayerQuitEvent;
|
||||
+import org.bukkit.event.player.PlayerRespawnEvent;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public abstract class PlayerList {
|
||||
|
||||
public static final File b = new File("banned-players.json");
|
||||
@@ -30,14 +47,16 @@
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
private static final SimpleDateFormat g = new SimpleDateFormat("yyyy-MM-dd 'at' HH:mm:ss z");
|
||||
private final MinecraftServer server;
|
||||
- public final List<EntityPlayer> players = Lists.newArrayList();
|
||||
+ public final List<EntityPlayer> players = new java.util.concurrent.CopyOnWriteArrayList(); // CraftBukkit - ArrayList -> CopyOnWriteArrayList: Iterator safety
|
||||
private final Map<UUID, EntityPlayer> j = Maps.newHashMap();
|
||||
private final GameProfileBanList k;
|
||||
private final IpBanList l;
|
||||
private final OpList operators;
|
||||
private final WhiteList whitelist;
|
||||
- private final Map<UUID, ServerStatisticManager> o;
|
||||
- private final Map<UUID, AdvancementDataPlayer> p;
|
||||
+ // CraftBukkit start
|
||||
+ // private final Map<UUID, ServerStatisticManager> o;
|
||||
+ // private final Map<UUID, AdvancementDataPlayer> p;
|
||||
+ // CraftBukkit end
|
||||
public final WorldNBTStorage playerFileData;
|
||||
private boolean hasWhitelist;
|
||||
private final IRegistryCustom.Dimension s;
|
||||
@@ -47,13 +66,23 @@
|
||||
private boolean v;
|
||||
private int w;
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ private CraftServer cserver;
|
||||
+
|
||||
public PlayerList(MinecraftServer minecraftserver, IRegistryCustom.Dimension iregistrycustom_dimension, WorldNBTStorage worldnbtstorage, int i) {
|
||||
+ this.cserver = minecraftserver.server = new CraftServer((DedicatedServer) minecraftserver, this);
|
||||
+ minecraftserver.console = org.bukkit.craftbukkit.command.ColouredConsoleSender.getInstance();
|
||||
+ minecraftserver.reader.addCompleter(new org.bukkit.craftbukkit.command.ConsoleCommandCompleter(minecraftserver.server));
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
this.k = new GameProfileBanList(PlayerList.b);
|
||||
this.l = new IpBanList(PlayerList.c);
|
||||
this.operators = new OpList(PlayerList.d);
|
||||
this.whitelist = new WhiteList(PlayerList.e);
|
||||
- this.o = Maps.newHashMap();
|
||||
- this.p = Maps.newHashMap();
|
||||
+ // CraftBukkit start
|
||||
+ // this.o = Maps.newHashMap();
|
||||
+ // this.p = Maps.newHashMap();
|
||||
+ // CraftBukkit end
|
||||
this.server = minecraftserver;
|
||||
this.s = iregistrycustom_dimension;
|
||||
this.maxPlayers = i;
|
||||
@@ -69,6 +98,12 @@
|
||||
usercache.a(gameprofile);
|
||||
NBTTagCompound nbttagcompound = this.a(entityplayer);
|
||||
ResourceKey resourcekey;
|
||||
+ // CraftBukkit start - Better rename detection
|
||||
+ if (nbttagcompound != null && nbttagcompound.hasKey("bukkit")) {
|
||||
+ NBTTagCompound bukkit = nbttagcompound.getCompound("bukkit");
|
||||
+ s = bukkit.hasKeyOfType("lastKnownName", 8) ? bukkit.getString("lastKnownName") : s;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
|
||||
if (nbttagcompound != null) {
|
||||
DataResult dataresult = DimensionManager.a(new Dynamic(DynamicOpsNBT.a, nbttagcompound.get("Dimension")));
|
||||
@@ -99,7 +134,8 @@
|
||||
s1 = networkmanager.getSocketAddress().toString();
|
||||
}
|
||||
|
||||
- PlayerList.LOGGER.info("{}[{}] logged in with entity id {} at ({}, {}, {})", entityplayer.getDisplayName().getString(), s1, entityplayer.getId(), entityplayer.locX(), entityplayer.locY(), entityplayer.locZ());
|
||||
+ // CraftBukkit - Moved message to after join
|
||||
+ // PlayerList.LOGGER.info("{}[{}] logged in with entity id {} at ({}, {}, {})", entityplayer.getDisplayName().getString(), s1, entityplayer.getId(), entityplayer.locX(), entityplayer.locY(), entityplayer.locZ());
|
||||
WorldData worlddata = worldserver1.getWorldData();
|
||||
|
||||
this.a(entityplayer, (EntityPlayer) null, worldserver1);
|
||||
@@ -109,6 +145,7 @@
|
||||
boolean flag1 = gamerules.getBoolean(GameRules.REDUCED_DEBUG_INFO);
|
||||
|
||||
playerconnection.sendPacket(new PacketPlayOutLogin(entityplayer.getId(), entityplayer.playerInteractManager.getGameMode(), entityplayer.playerInteractManager.c(), BiomeManager.a(worldserver1.getSeed()), worlddata.isHardcore(), this.server.F(), this.s, worldserver1.getDimensionManager(), worldserver1.getDimensionKey(), this.getMaxPlayers(), this.viewDistance, flag1, !flag, worldserver1.isDebugWorld(), worldserver1.isFlatWorld()));
|
||||
+ entityplayer.getBukkitEntity().sendSupportedChannels(); // CraftBukkit
|
||||
playerconnection.sendPacket(new PacketPlayOutCustomPayload(PacketPlayOutCustomPayload.a, (new PacketDataSerializer(Unpooled.buffer())).a(this.getServer().getServerModName())));
|
||||
playerconnection.sendPacket(new PacketPlayOutServerDifficulty(worlddata.getDifficulty(), worlddata.isDifficultyLocked()));
|
||||
playerconnection.sendPacket(new PacketPlayOutAbilities(entityplayer.abilities));
|
||||
@@ -127,19 +164,61 @@
|
||||
} else {
|
||||
chatmessage = new ChatMessage("multiplayer.player.joined.renamed", new Object[]{entityplayer.getScoreboardDisplayName(), s});
|
||||
}
|
||||
+ // CraftBukkit start
|
||||
+ chatmessage.a(EnumChatFormat.YELLOW);
|
||||
+ String joinMessage = CraftChatMessage.fromComponent(chatmessage);
|
||||
|
||||
- this.sendMessage(chatmessage.a(EnumChatFormat.YELLOW), ChatMessageType.SYSTEM, SystemUtils.b);
|
||||
playerconnection.a(entityplayer.locX(), entityplayer.locY(), entityplayer.locZ(), entityplayer.yaw, entityplayer.pitch);
|
||||
this.players.add(entityplayer);
|
||||
this.j.put(entityplayer.getUniqueID(), entityplayer);
|
||||
- this.sendAll(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER, new EntityPlayer[]{entityplayer}));
|
||||
+ // this.sendAll(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER, new EntityPlayer[]{entityplayer})); // CraftBukkit - replaced with loop below
|
||||
+
|
||||
+ // CraftBukkit start
|
||||
+ PlayerJoinEvent playerJoinEvent = new PlayerJoinEvent(cserver.getPlayer(entityplayer), joinMessage);
|
||||
+ cserver.getPluginManager().callEvent(playerJoinEvent);
|
||||
+
|
||||
+ if (!entityplayer.playerConnection.networkManager.isConnected()) {
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ joinMessage = playerJoinEvent.getJoinMessage();
|
||||
+
|
||||
+ if (joinMessage != null && joinMessage.length() > 0) {
|
||||
+ for (IChatBaseComponent line : org.bukkit.craftbukkit.util.CraftChatMessage.fromString(joinMessage)) {
|
||||
+ server.getPlayerList().sendAll(new PacketPlayOutChat(line, ChatMessageType.SYSTEM, SystemUtils.b));
|
||||
+ }
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
+ // CraftBukkit start - sendAll above replaced with this loop
|
||||
+ PacketPlayOutPlayerInfo packet = new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER, entityplayer);
|
||||
|
||||
for (int i = 0; i < this.players.size(); ++i) {
|
||||
- entityplayer.playerConnection.sendPacket(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER, new EntityPlayer[]{(EntityPlayer) this.players.get(i)}));
|
||||
+ EntityPlayer entityplayer1 = (EntityPlayer) this.players.get(i);
|
||||
+
|
||||
+ if (entityplayer1.getBukkitEntity().canSee(entityplayer.getBukkitEntity())) {
|
||||
+ entityplayer1.playerConnection.sendPacket(packet);
|
||||
+ }
|
||||
+
|
||||
+ if (!entityplayer.getBukkitEntity().canSee(entityplayer1.getBukkitEntity())) {
|
||||
+ continue;
|
||||
+ }
|
||||
+
|
||||
+ entityplayer.playerConnection.sendPacket(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER, new EntityPlayer[] { entityplayer1}));
|
||||
+ }
|
||||
+ entityplayer.sentListPacket = true;
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
+ entityplayer.playerConnection.sendPacket(new PacketPlayOutEntityMetadata(entityplayer.getId(), entityplayer.datawatcher, true)); // CraftBukkit - BungeeCord#2321, send complete data to self on spawn
|
||||
+
|
||||
+ // CraftBukkit start - Only add if the player wasn't moved in the event
|
||||
+ if (entityplayer.world == worldserver1 && !worldserver1.getPlayers().contains(entityplayer)) {
|
||||
+ worldserver1.addPlayerJoin(entityplayer);
|
||||
+ this.server.getBossBattleCustomData().a(entityplayer);
|
||||
}
|
||||
|
||||
- worldserver1.addPlayerJoin(entityplayer);
|
||||
- this.server.getBossBattleCustomData().a(entityplayer);
|
||||
+ worldserver1 = entityplayer.getWorldServer(); // CraftBukkit - Update in case join event changed it
|
||||
+ // CraftBukkit end
|
||||
this.a(entityplayer, worldserver1);
|
||||
if (!this.server.getResourcePack().isEmpty()) {
|
||||
entityplayer.setResourcePack(this.server.getResourcePack(), this.server.getResourcePackHash());
|
||||
@@ -155,8 +234,11 @@
|
||||
|
||||
if (nbttagcompound != null && nbttagcompound.hasKeyOfType("RootVehicle", 10)) {
|
||||
NBTTagCompound nbttagcompound1 = nbttagcompound.getCompound("RootVehicle");
|
||||
- Entity entity = EntityTypes.a(nbttagcompound1.getCompound("Entity"), worldserver1, (entity1) -> {
|
||||
- return !worldserver1.addEntitySerialized(entity1) ? null : entity1;
|
||||
+ // CraftBukkit start
|
||||
+ WorldServer finalWorldServer = worldserver1;
|
||||
+ Entity entity = EntityTypes.a(nbttagcompound1.getCompound("Entity"), finalWorldServer, (entity1) -> {
|
||||
+ return !finalWorldServer.addEntitySerialized(entity1) ? null : entity1;
|
||||
+ // CraftBukkit end
|
||||
});
|
||||
|
||||
if (entity != null) {
|
||||
@@ -199,6 +281,8 @@
|
||||
}
|
||||
|
||||
entityplayer.syncInventory();
|
||||
+ // CraftBukkit - Moved from above, added world
|
||||
+ PlayerList.LOGGER.info("{}[{}] logged in with entity id {} at ([{}]{}, {}, {})", entityplayer.getDisplayName().getString(), s1, entityplayer.getId(), worldserver1.worldDataServer.getName(), entityplayer.locX(), entityplayer.locY(), entityplayer.locZ());
|
||||
}
|
||||
|
||||
public void sendScoreboard(ScoreboardServer scoreboardserver, EntityPlayer entityplayer) {
|
||||
@@ -231,30 +315,31 @@
|
||||
}
|
||||
|
||||
public void setPlayerFileData(WorldServer worldserver) {
|
||||
+ if (playerFileData != null) return; // CraftBukkit
|
||||
worldserver.getWorldBorder().a(new IWorldBorderListener() {
|
||||
@Override
|
||||
public void a(WorldBorder worldborder, double d0) {
|
||||
- PlayerList.this.sendAll(new PacketPlayOutWorldBorder(worldborder, PacketPlayOutWorldBorder.EnumWorldBorderAction.SET_SIZE));
|
||||
+ PlayerList.this.sendAll(new PacketPlayOutWorldBorder(worldborder, PacketPlayOutWorldBorder.EnumWorldBorderAction.SET_SIZE), worldborder.world);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void a(WorldBorder worldborder, double d0, double d1, long i) {
|
||||
- PlayerList.this.sendAll(new PacketPlayOutWorldBorder(worldborder, PacketPlayOutWorldBorder.EnumWorldBorderAction.LERP_SIZE));
|
||||
+ PlayerList.this.sendAll(new PacketPlayOutWorldBorder(worldborder, PacketPlayOutWorldBorder.EnumWorldBorderAction.LERP_SIZE), worldborder.world);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void a(WorldBorder worldborder, double d0, double d1) {
|
||||
- PlayerList.this.sendAll(new PacketPlayOutWorldBorder(worldborder, PacketPlayOutWorldBorder.EnumWorldBorderAction.SET_CENTER));
|
||||
+ PlayerList.this.sendAll(new PacketPlayOutWorldBorder(worldborder, PacketPlayOutWorldBorder.EnumWorldBorderAction.SET_CENTER), worldborder.world);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void a(WorldBorder worldborder, int i) {
|
||||
- PlayerList.this.sendAll(new PacketPlayOutWorldBorder(worldborder, PacketPlayOutWorldBorder.EnumWorldBorderAction.SET_WARNING_TIME));
|
||||
+ PlayerList.this.sendAll(new PacketPlayOutWorldBorder(worldborder, PacketPlayOutWorldBorder.EnumWorldBorderAction.SET_WARNING_TIME), worldborder.world);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void b(WorldBorder worldborder, int i) {
|
||||
- PlayerList.this.sendAll(new PacketPlayOutWorldBorder(worldborder, PacketPlayOutWorldBorder.EnumWorldBorderAction.SET_WARNING_BLOCKS));
|
||||
+ PlayerList.this.sendAll(new PacketPlayOutWorldBorder(worldborder, PacketPlayOutWorldBorder.EnumWorldBorderAction.SET_WARNING_BLOCKS), worldborder.world);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -282,14 +367,15 @@
|
||||
}
|
||||
|
||||
protected void savePlayerFile(EntityPlayer entityplayer) {
|
||||
+ if (!entityplayer.getBukkitEntity().isPersistent()) return; // CraftBukkit
|
||||
this.playerFileData.save(entityplayer);
|
||||
- ServerStatisticManager serverstatisticmanager = (ServerStatisticManager) this.o.get(entityplayer.getUniqueID());
|
||||
+ ServerStatisticManager serverstatisticmanager = (ServerStatisticManager) entityplayer.getStatisticManager(); // CraftBukkit
|
||||
|
||||
if (serverstatisticmanager != null) {
|
||||
serverstatisticmanager.save();
|
||||
}
|
||||
|
||||
- AdvancementDataPlayer advancementdataplayer = (AdvancementDataPlayer) this.p.get(entityplayer.getUniqueID());
|
||||
+ AdvancementDataPlayer advancementdataplayer = (AdvancementDataPlayer) entityplayer.getAdvancementData(); // CraftBukkit
|
||||
|
||||
if (advancementdataplayer != null) {
|
||||
advancementdataplayer.b();
|
||||
@@ -297,10 +383,24 @@
|
||||
|
||||
}
|
||||
|
||||
- public void disconnect(EntityPlayer entityplayer) {
|
||||
+ public String disconnect(EntityPlayer entityplayer) { // CraftBukkit - return string
|
||||
WorldServer worldserver = entityplayer.getWorldServer();
|
||||
|
||||
entityplayer.a(StatisticList.LEAVE_GAME);
|
||||
+
|
||||
+ // CraftBukkit start - Quitting must be before we do final save of data, in case plugins need to modify it
|
||||
+ // See SPIGOT-5799, SPIGOT-6145
|
||||
+ if (entityplayer.activeContainer != entityplayer.defaultContainer) {
|
||||
+ entityplayer.closeInventory();
|
||||
+ }
|
||||
+
|
||||
+ PlayerQuitEvent playerQuitEvent = new PlayerQuitEvent(cserver.getPlayer(entityplayer), "\u00A7e" + entityplayer.getName() + " left the game");
|
||||
+ cserver.getPluginManager().callEvent(playerQuitEvent);
|
||||
+ entityplayer.getBukkitEntity().disconnect(playerQuitEvent.getQuitMessage());
|
||||
+
|
||||
+ entityplayer.playerTick(); // SPIGOT-924
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
this.savePlayerFile(entityplayer);
|
||||
if (entityplayer.isPassenger()) {
|
||||
Entity entity = entityplayer.getRootVehicle();
|
||||
@@ -332,18 +432,66 @@
|
||||
|
||||
if (entityplayer1 == entityplayer) {
|
||||
this.j.remove(uuid);
|
||||
- this.o.remove(uuid);
|
||||
- this.p.remove(uuid);
|
||||
+ // CraftBukkit start
|
||||
+ // this.o.remove(uuid);
|
||||
+ // this.p.remove(uuid);
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
- this.sendAll(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.REMOVE_PLAYER, new EntityPlayer[]{entityplayer}));
|
||||
+ // CraftBukkit start
|
||||
+ // this.sendAll(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.REMOVE_PLAYER, new EntityPlayer[]{entityplayer}));
|
||||
+ PacketPlayOutPlayerInfo packet = new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.REMOVE_PLAYER, entityplayer);
|
||||
+ for (int i = 0; i < players.size(); i++) {
|
||||
+ EntityPlayer entityplayer2 = (EntityPlayer) this.players.get(i);
|
||||
+
|
||||
+ if (entityplayer2.getBukkitEntity().canSee(entityplayer.getBukkitEntity())) {
|
||||
+ entityplayer2.playerConnection.sendPacket(packet);
|
||||
+ } else {
|
||||
+ entityplayer2.getBukkitEntity().removeDisconnectingPlayer(entityplayer.getBukkitEntity());
|
||||
+ }
|
||||
+ }
|
||||
+ // This removes the scoreboard (and player reference) for the specific player in the manager
|
||||
+ cserver.getScoreboardManager().removePlayer(entityplayer.getBukkitEntity());
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
+ return playerQuitEvent.getQuitMessage(); // CraftBukkit
|
||||
}
|
||||
|
||||
- @Nullable
|
||||
- public IChatBaseComponent attemptLogin(SocketAddress socketaddress, GameProfile gameprofile) {
|
||||
+ // CraftBukkit start - Whole method, SocketAddress to LoginListener, added hostname to signature, return EntityPlayer
|
||||
+ public EntityPlayer attemptLogin(LoginListener loginlistener, GameProfile gameprofile, String hostname) {
|
||||
ChatMessage chatmessage;
|
||||
|
||||
- if (this.k.isBanned(gameprofile)) {
|
||||
+ // Moved from processLogin
|
||||
+ UUID uuid = EntityHuman.a(gameprofile);
|
||||
+ List<EntityPlayer> list = Lists.newArrayList();
|
||||
+
|
||||
+ EntityPlayer entityplayer;
|
||||
+
|
||||
+ for (int i = 0; i < this.players.size(); ++i) {
|
||||
+ entityplayer = (EntityPlayer) this.players.get(i);
|
||||
+ if (entityplayer.getUniqueID().equals(uuid)) {
|
||||
+ list.add(entityplayer);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ Iterator iterator = list.iterator();
|
||||
+
|
||||
+ while (iterator.hasNext()) {
|
||||
+ entityplayer = (EntityPlayer) iterator.next();
|
||||
+ savePlayerFile(entityplayer); // CraftBukkit - Force the player's inventory to be saved
|
||||
+ entityplayer.playerConnection.disconnect(new ChatMessage("multiplayer.disconnect.duplicate_login", new Object[0]));
|
||||
+ }
|
||||
+
|
||||
+ // Instead of kicking then returning, we need to store the kick reason
|
||||
+ // in the event, check with plugins to see if it's ok, and THEN kick
|
||||
+ // depending on the outcome.
|
||||
+ SocketAddress socketaddress = loginlistener.networkManager.getSocketAddress();
|
||||
+
|
||||
+ EntityPlayer entity = new EntityPlayer(this.server, this.server.getWorldServer(World.OVERWORLD), gameprofile, new PlayerInteractManager(this.server.getWorldServer(World.OVERWORLD)));
|
||||
+ Player player = entity.getBukkitEntity();
|
||||
+ PlayerLoginEvent event = new PlayerLoginEvent(player, hostname, ((java.net.InetSocketAddress) socketaddress).getAddress());
|
||||
+
|
||||
+ if (getProfileBans().isBanned(gameprofile) && !getProfileBans().get(gameprofile).hasExpired()) {
|
||||
GameProfileBanEntry gameprofilebanentry = (GameProfileBanEntry) this.k.get(gameprofile);
|
||||
|
||||
chatmessage = new ChatMessage("multiplayer.disconnect.banned.reason", new Object[]{gameprofilebanentry.getReason()});
|
||||
@@ -351,10 +499,12 @@
|
||||
chatmessage.addSibling(new ChatMessage("multiplayer.disconnect.banned.expiration", new Object[]{PlayerList.g.format(gameprofilebanentry.getExpires())}));
|
||||
}
|
||||
|
||||
- return chatmessage;
|
||||
+ // return chatmessage;
|
||||
+ event.disallow(PlayerLoginEvent.Result.KICK_BANNED, CraftChatMessage.fromComponent(chatmessage));
|
||||
} else if (!this.isWhitelisted(gameprofile)) {
|
||||
- return new ChatMessage("multiplayer.disconnect.not_whitelisted");
|
||||
- } else if (this.l.isBanned(socketaddress)) {
|
||||
+ chatmessage = new ChatMessage("multiplayer.disconnect.not_whitelisted");
|
||||
+ event.disallow(PlayerLoginEvent.Result.KICK_WHITELIST, CraftChatMessage.fromComponent(chatmessage));
|
||||
+ } else if (getIPBans().isBanned(socketaddress) && !getIPBans().get(socketaddress).hasExpired()) {
|
||||
IpBanEntry ipbanentry = this.l.get(socketaddress);
|
||||
|
||||
chatmessage = new ChatMessage("multiplayer.disconnect.banned_ip.reason", new Object[]{ipbanentry.getReason()});
|
||||
@@ -362,13 +512,25 @@
|
||||
chatmessage.addSibling(new ChatMessage("multiplayer.disconnect.banned_ip.expiration", new Object[]{PlayerList.g.format(ipbanentry.getExpires())}));
|
||||
}
|
||||
|
||||
- return chatmessage;
|
||||
+ // return chatmessage;
|
||||
+ event.disallow(PlayerLoginEvent.Result.KICK_BANNED, CraftChatMessage.fromComponent(chatmessage));
|
||||
} else {
|
||||
- return this.players.size() >= this.maxPlayers && !this.f(gameprofile) ? new ChatMessage("multiplayer.disconnect.server_full") : null;
|
||||
+ // return this.players.size() >= this.maxPlayers && !this.f(gameprofile) ? new ChatMessage("multiplayer.disconnect.server_full") : null;
|
||||
+ if (this.players.size() >= this.maxPlayers && !this.f(gameprofile)) {
|
||||
+ event.disallow(PlayerLoginEvent.Result.KICK_FULL, "The server is full");
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ cserver.getPluginManager().callEvent(event);
|
||||
+ if (event.getResult() != PlayerLoginEvent.Result.ALLOWED) {
|
||||
+ loginlistener.disconnect(event.getKickMessage());
|
||||
+ return null;
|
||||
}
|
||||
+ return entity;
|
||||
}
|
||||
|
||||
- public EntityPlayer processLogin(GameProfile gameprofile) {
|
||||
+ public EntityPlayer processLogin(GameProfile gameprofile, EntityPlayer player) { // CraftBukkit - added EntityPlayer
|
||||
+ /* CraftBukkit startMoved up
|
||||
UUID uuid = EntityHuman.a(gameprofile);
|
||||
List<EntityPlayer> list = Lists.newArrayList();
|
||||
|
||||
@@ -404,14 +566,24 @@
|
||||
}
|
||||
|
||||
return new EntityPlayer(this.server, worldserver, gameprofile, (PlayerInteractManager) object);
|
||||
+ */
|
||||
+ return player;
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
+ // CraftBukkit start
|
||||
public EntityPlayer moveToWorld(EntityPlayer entityplayer, boolean flag) {
|
||||
+ return this.moveToWorld(entityplayer, this.server.getWorldServer(entityplayer.getSpawnDimension()), flag, null, true);
|
||||
+ }
|
||||
+
|
||||
+ public EntityPlayer moveToWorld(EntityPlayer entityplayer, WorldServer worldserver, boolean flag, Location location, boolean avoidSuffocation) {
|
||||
+ entityplayer.stopRiding(); // CraftBukkit
|
||||
this.players.remove(entityplayer);
|
||||
entityplayer.getWorldServer().removePlayer(entityplayer);
|
||||
BlockPosition blockposition = entityplayer.getSpawn();
|
||||
float f = entityplayer.getSpawnAngle();
|
||||
boolean flag1 = entityplayer.isSpawnForced();
|
||||
+ /* CraftBukkit start
|
||||
WorldServer worldserver = this.server.getWorldServer(entityplayer.getSpawnDimension());
|
||||
Optional optional;
|
||||
|
||||
@@ -431,6 +603,11 @@
|
||||
}
|
||||
|
||||
EntityPlayer entityplayer1 = new EntityPlayer(this.server, worldserver1, entityplayer.getProfile(), (PlayerInteractManager) object);
|
||||
+ // */
|
||||
+ EntityPlayer entityplayer1 = entityplayer;
|
||||
+ org.bukkit.World fromWorld = entityplayer.getBukkitEntity().getWorld();
|
||||
+ entityplayer.viewingCredits = false;
|
||||
+ // CraftBukkit end
|
||||
|
||||
entityplayer1.playerConnection = entityplayer.playerConnection;
|
||||
entityplayer1.copyFrom(entityplayer, flag);
|
||||
@@ -444,52 +621,113 @@
|
||||
entityplayer1.addScoreboardTag(s);
|
||||
}
|
||||
|
||||
- this.a(entityplayer1, entityplayer, worldserver1);
|
||||
+ // this.a(entityplayer1, entityplayer, worldserver1); // CraftBukkit - removed
|
||||
boolean flag2 = false;
|
||||
|
||||
- if (optional.isPresent()) {
|
||||
- IBlockData iblockdata = worldserver1.getType(blockposition);
|
||||
- boolean flag3 = iblockdata.a(Blocks.RESPAWN_ANCHOR);
|
||||
- Vec3D vec3d = (Vec3D) optional.get();
|
||||
- float f1;
|
||||
+ // CraftBukkit start - fire PlayerRespawnEvent
|
||||
+ if (location == null) {
|
||||
+ boolean isBedSpawn = false;
|
||||
+ WorldServer worldserver1 = this.server.getWorldServer(entityplayer.getSpawnDimension());
|
||||
+ if (worldserver1 != null) {
|
||||
+ Optional optional;
|
||||
|
||||
- if (!iblockdata.a((Tag) TagsBlock.BEDS) && !flag3) {
|
||||
- f1 = f;
|
||||
- } else {
|
||||
- Vec3D vec3d1 = Vec3D.c((BaseBlockPosition) blockposition).d(vec3d).d();
|
||||
+ if (blockposition != null) {
|
||||
+ optional = EntityHuman.getBed(worldserver1, blockposition, f, flag1, flag);
|
||||
+ } else {
|
||||
+ optional = Optional.empty();
|
||||
+ }
|
||||
+
|
||||
+ if (optional.isPresent()) {
|
||||
+ IBlockData iblockdata = worldserver1.getType(blockposition);
|
||||
+ boolean flag3 = iblockdata.a(Blocks.RESPAWN_ANCHOR);
|
||||
+ Vec3D vec3d = (Vec3D) optional.get();
|
||||
+ float f1;
|
||||
+
|
||||
+ if (!iblockdata.a((Tag) TagsBlock.BEDS) && !flag3) {
|
||||
+ f1 = f;
|
||||
+ } else {
|
||||
+ Vec3D vec3d1 = Vec3D.c((BaseBlockPosition) blockposition).d(vec3d).d();
|
||||
+
|
||||
+ f1 = (float) MathHelper.g(MathHelper.d(vec3d1.z, vec3d1.x) * 57.2957763671875D - 90.0D);
|
||||
+ }
|
||||
|
||||
- f1 = (float) MathHelper.g(MathHelper.d(vec3d1.z, vec3d1.x) * 57.2957763671875D - 90.0D);
|
||||
+ entityplayer1.setRespawnPosition(worldserver1.getDimensionKey(), blockposition, f, flag1, false);
|
||||
+ flag2 = !flag && flag3;
|
||||
+ isBedSpawn = true;
|
||||
+ location = new Location(worldserver1.getWorld(), vec3d.x, vec3d.y, vec3d.z, f1, 0.0F);
|
||||
+ } else if (blockposition != null) {
|
||||
+ entityplayer1.playerConnection.sendPacket(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.a, 0.0F));
|
||||
+ }
|
||||
}
|
||||
|
||||
- entityplayer1.setPositionRotation(vec3d.x, vec3d.y, vec3d.z, f1, 0.0F);
|
||||
- entityplayer1.setRespawnPosition(worldserver1.getDimensionKey(), blockposition, f, flag1, false);
|
||||
- flag2 = !flag && flag3;
|
||||
- } else if (blockposition != null) {
|
||||
- entityplayer1.playerConnection.sendPacket(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.a, 0.0F));
|
||||
+ if (location == null) {
|
||||
+ worldserver1 = this.server.getWorldServer(World.OVERWORLD);
|
||||
+ blockposition = entityplayer1.getSpawnPoint(worldserver1);
|
||||
+ location = new Location(worldserver1.getWorld(), (double) ((float) blockposition.getX() + 0.5F), (double) ((float) blockposition.getY() + 0.1F), (double) ((float) blockposition.getZ() + 0.5F));
|
||||
+ }
|
||||
+
|
||||
+ Player respawnPlayer = cserver.getPlayer(entityplayer1);
|
||||
+ PlayerRespawnEvent respawnEvent = new PlayerRespawnEvent(respawnPlayer, location, isBedSpawn && !flag2, flag2);
|
||||
+ cserver.getPluginManager().callEvent(respawnEvent);
|
||||
+
|
||||
+ location = respawnEvent.getRespawnLocation();
|
||||
+ if (!flag) entityplayer.reset(); // SPIGOT-4785
|
||||
+ } else {
|
||||
+ location.setWorld(worldserver.getWorld());
|
||||
}
|
||||
+ WorldServer worldserver1 = ((CraftWorld) location.getWorld()).getHandle();
|
||||
+ entityplayer1.forceSetPositionRotation(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch());
|
||||
+ // CraftBukkit end
|
||||
|
||||
- while (!worldserver1.getCubes(entityplayer1) && entityplayer1.locY() < 256.0D) {
|
||||
+ while (avoidSuffocation && !worldserver1.getCubes(entityplayer1) && entityplayer1.locY() < 256.0D) {
|
||||
entityplayer1.setPosition(entityplayer1.locX(), entityplayer1.locY() + 1.0D, entityplayer1.locZ());
|
||||
}
|
||||
+ // CraftBukkit start
|
||||
+ WorldData worlddata = worldserver1.getWorldData();
|
||||
+ entityplayer1.playerConnection.sendPacket(new PacketPlayOutRespawn(worldserver1.getDimensionManager(), worldserver1.getDimensionKey(), BiomeManager.a(worldserver1.getSeed()), entityplayer1.playerInteractManager.getGameMode(), entityplayer1.playerInteractManager.c(), worldserver1.isDebugWorld(), worldserver1.isFlatWorld(), flag));
|
||||
+ entityplayer1.spawnIn(worldserver1);
|
||||
+ entityplayer1.dead = false;
|
||||
+ entityplayer1.playerConnection.teleport(new Location(worldserver1.getWorld(), entityplayer1.locX(), entityplayer1.locY(), entityplayer1.locZ(), entityplayer1.yaw, entityplayer1.pitch));
|
||||
+ entityplayer1.setSneaking(false);
|
||||
|
||||
- WorldData worlddata = entityplayer1.world.getWorldData();
|
||||
-
|
||||
- entityplayer1.playerConnection.sendPacket(new PacketPlayOutRespawn(entityplayer1.world.getDimensionManager(), entityplayer1.world.getDimensionKey(), BiomeManager.a(entityplayer1.getWorldServer().getSeed()), entityplayer1.playerInteractManager.getGameMode(), entityplayer1.playerInteractManager.c(), entityplayer1.getWorldServer().isDebugWorld(), entityplayer1.getWorldServer().isFlatWorld(), flag));
|
||||
- entityplayer1.playerConnection.a(entityplayer1.locX(), entityplayer1.locY(), entityplayer1.locZ(), entityplayer1.yaw, entityplayer1.pitch);
|
||||
+ // entityplayer1.playerConnection.a(entityplayer1.locX(), entityplayer1.locY(), entityplayer1.locZ(), entityplayer1.yaw, entityplayer1.pitch);
|
||||
entityplayer1.playerConnection.sendPacket(new PacketPlayOutSpawnPosition(worldserver1.getSpawn(), worldserver1.v()));
|
||||
entityplayer1.playerConnection.sendPacket(new PacketPlayOutServerDifficulty(worlddata.getDifficulty(), worlddata.isDifficultyLocked()));
|
||||
entityplayer1.playerConnection.sendPacket(new PacketPlayOutExperience(entityplayer1.exp, entityplayer1.expTotal, entityplayer1.expLevel));
|
||||
this.a(entityplayer1, worldserver1);
|
||||
this.d(entityplayer1);
|
||||
- worldserver1.addPlayerRespawn(entityplayer1);
|
||||
- this.players.add(entityplayer1);
|
||||
- this.j.put(entityplayer1.getUniqueID(), entityplayer1);
|
||||
- entityplayer1.syncInventory();
|
||||
+ if (!entityplayer.playerConnection.isDisconnected()) {
|
||||
+ worldserver1.addPlayerRespawn(entityplayer1);
|
||||
+ this.players.add(entityplayer1);
|
||||
+ this.j.put(entityplayer1.getUniqueID(), entityplayer1);
|
||||
+ }
|
||||
+ // entityplayer1.syncInventory();
|
||||
entityplayer1.setHealth(entityplayer1.getHealth());
|
||||
if (flag2) {
|
||||
entityplayer1.playerConnection.sendPacket(new PacketPlayOutNamedSoundEffect(SoundEffects.BLOCK_RESPAWN_ANCHOR_DEPLETE, SoundCategory.BLOCKS, (double) blockposition.getX(), (double) blockposition.getY(), (double) blockposition.getZ(), 1.0F, 1.0F));
|
||||
}
|
||||
+ // Added from changeDimension
|
||||
+ updateClient(entityplayer); // Update health, etc...
|
||||
+ entityplayer.updateAbilities();
|
||||
+ for (Object o1 : entityplayer.getEffects()) {
|
||||
+ MobEffect mobEffect = (MobEffect) o1;
|
||||
+ entityplayer.playerConnection.sendPacket(new PacketPlayOutEntityEffect(entityplayer.getId(), mobEffect));
|
||||
+ }
|
||||
+
|
||||
+ // Fire advancement trigger
|
||||
+ entityplayer.triggerDimensionAdvancements(((CraftWorld) fromWorld).getHandle());
|
||||
+
|
||||
+ // Don't fire on respawn
|
||||
+ if (fromWorld != location.getWorld()) {
|
||||
+ PlayerChangedWorldEvent event = new PlayerChangedWorldEvent(entityplayer.getBukkitEntity(), fromWorld);
|
||||
+ server.server.getPluginManager().callEvent(event);
|
||||
+ }
|
||||
|
||||
+ // Save player file again if they were disconnected
|
||||
+ if (entityplayer.playerConnection.isDisconnected()) {
|
||||
+ this.savePlayerFile(entityplayer);
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
return entityplayer1;
|
||||
}
|
||||
|
||||
@@ -502,7 +740,18 @@
|
||||
|
||||
public void tick() {
|
||||
if (++this.w > 600) {
|
||||
- this.sendAll(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.UPDATE_LATENCY, this.players));
|
||||
+ // CraftBukkit start
|
||||
+ for (int i = 0; i < this.players.size(); ++i) {
|
||||
+ final EntityPlayer target = (EntityPlayer) this.players.get(i);
|
||||
+
|
||||
+ target.playerConnection.sendPacket(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.UPDATE_LATENCY, Iterables.filter(this.players, new Predicate<EntityPlayer>() {
|
||||
+ @Override
|
||||
+ public boolean apply(EntityPlayer input) {
|
||||
+ return target.getBukkitEntity().canSee(input.getBukkitEntity());
|
||||
+ }
|
||||
+ })));
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
this.w = 0;
|
||||
}
|
||||
|
||||
@@ -515,6 +764,25 @@
|
||||
|
||||
}
|
||||
|
||||
+ // CraftBukkit start - add a world/entity limited version
|
||||
+ public void sendAll(Packet packet, EntityHuman entityhuman) {
|
||||
+ for (int i = 0; i < this.players.size(); ++i) {
|
||||
+ EntityPlayer entityplayer = this.players.get(i);
|
||||
+ if (entityhuman != null && entityhuman instanceof EntityPlayer && !entityplayer.getBukkitEntity().canSee(((EntityPlayer) entityhuman).getBukkitEntity())) {
|
||||
+ continue;
|
||||
+ }
|
||||
+ ((EntityPlayer) this.players.get(i)).playerConnection.sendPacket(packet);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ public void sendAll(Packet packet, World world) {
|
||||
+ for (int i = 0; i < world.getPlayers().size(); ++i) {
|
||||
+ ((EntityPlayer) world.getPlayers().get(i)).playerConnection.sendPacket(packet);
|
||||
+ }
|
||||
+
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
public void a(Packet<?> packet, ResourceKey<World> resourcekey) {
|
||||
for (int i = 0; i < this.players.size(); ++i) {
|
||||
EntityPlayer entityplayer = (EntityPlayer) this.players.get(i);
|
||||
@@ -615,6 +883,7 @@
|
||||
entityplayer.playerConnection.sendPacket(new PacketPlayOutEntityStatus(entityplayer, b0));
|
||||
}
|
||||
|
||||
+ entityplayer.getBukkitEntity().recalculatePermissions(); // CraftBukkit
|
||||
this.server.getCommandDispatcher().a(entityplayer);
|
||||
}
|
||||
|
||||
@@ -647,6 +916,12 @@
|
||||
for (int i = 0; i < this.players.size(); ++i) {
|
||||
EntityPlayer entityplayer = (EntityPlayer) this.players.get(i);
|
||||
|
||||
+ // CraftBukkit start - Test if player receiving packet can see the source of the packet
|
||||
+ if (entityhuman != null && entityhuman instanceof EntityPlayer && !entityplayer.getBukkitEntity().canSee(((EntityPlayer) entityhuman).getBukkitEntity())) {
|
||||
+ continue;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
if (entityplayer != entityhuman && entityplayer.world.getDimensionKey() == resourcekey) {
|
||||
double d4 = d0 - entityplayer.locX();
|
||||
double d5 = d1 - entityplayer.locY();
|
||||
@@ -686,23 +961,34 @@
|
||||
public void reloadWhitelist() {}
|
||||
|
||||
public void a(EntityPlayer entityplayer, WorldServer worldserver) {
|
||||
- WorldBorder worldborder = this.server.E().getWorldBorder();
|
||||
+ WorldBorder worldborder = entityplayer.world.getWorldBorder(); // CraftBukkit
|
||||
|
||||
entityplayer.playerConnection.sendPacket(new PacketPlayOutWorldBorder(worldborder, PacketPlayOutWorldBorder.EnumWorldBorderAction.INITIALIZE));
|
||||
entityplayer.playerConnection.sendPacket(new PacketPlayOutUpdateTime(worldserver.getTime(), worldserver.getDayTime(), worldserver.getGameRules().getBoolean(GameRules.DO_DAYLIGHT_CYCLE)));
|
||||
entityplayer.playerConnection.sendPacket(new PacketPlayOutSpawnPosition(worldserver.getSpawn(), worldserver.v()));
|
||||
if (worldserver.isRaining()) {
|
||||
- entityplayer.playerConnection.sendPacket(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.b, 0.0F));
|
||||
- entityplayer.playerConnection.sendPacket(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.h, worldserver.d(1.0F)));
|
||||
- entityplayer.playerConnection.sendPacket(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.i, worldserver.b(1.0F)));
|
||||
+ // CraftBukkit start - handle player weather
|
||||
+ // entityplayer.playerConnection.sendPacket(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.b, 0.0F));
|
||||
+ // entityplayer.playerConnection.sendPacket(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.h, worldserver.d(1.0F)));
|
||||
+ // entityplayer.playerConnection.sendPacket(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.i, worldserver.b(1.0F)));
|
||||
+ entityplayer.setPlayerWeather(org.bukkit.WeatherType.DOWNFALL, false);
|
||||
+ entityplayer.updateWeather(-worldserver.rainLevel, worldserver.rainLevel, -worldserver.thunderLevel, worldserver.thunderLevel);
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void updateClient(EntityPlayer entityplayer) {
|
||||
entityplayer.updateInventory(entityplayer.defaultContainer);
|
||||
- entityplayer.triggerHealthUpdate();
|
||||
+ // entityplayer.triggerHealthUpdate();
|
||||
+ entityplayer.getBukkitEntity().updateScaledHealth(); // CraftBukkit - Update scaled health on respawn and worldchange
|
||||
entityplayer.playerConnection.sendPacket(new PacketPlayOutHeldItemSlot(entityplayer.inventory.itemInHandIndex));
|
||||
+ // CraftBukkit start - from GameRules
|
||||
+ int i = entityplayer.world.getGameRules().getBoolean(GameRules.REDUCED_DEBUG_INFO) ? 22 : 23;
|
||||
+ entityplayer.playerConnection.sendPacket(new PacketPlayOutEntityStatus(entityplayer, (byte) i));
|
||||
+ float immediateRespawn = entityplayer.world.getGameRules().getBoolean(GameRules.DO_IMMEDIATE_RESPAWN) ? 1.0F: 0.0F;
|
||||
+ entityplayer.playerConnection.sendPacket(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.l, immediateRespawn));
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
public int getPlayerCount() {
|
||||
@@ -755,31 +1041,54 @@
|
||||
entityplayer.playerInteractManager.a(this.u, EnumGamemode.NOT_SET);
|
||||
}
|
||||
|
||||
- entityplayer.playerInteractManager.b(worldserver.getMinecraftServer().getSaveData().getGameType());
|
||||
+ entityplayer.playerInteractManager.b(worldserver.worldDataServer.getGameType()); // CraftBukkit
|
||||
}
|
||||
|
||||
public void shutdown() {
|
||||
- for (int i = 0; i < this.players.size(); ++i) {
|
||||
- ((EntityPlayer) this.players.get(i)).playerConnection.disconnect(new ChatMessage("multiplayer.disconnect.server_shutdown"));
|
||||
+ // CraftBukkit start - disconnect safely
|
||||
+ for (EntityPlayer player : this.players) {
|
||||
+ player.playerConnection.disconnect(this.server.server.getShutdownMessage()); // CraftBukkit - add custom shutdown message
|
||||
}
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
+ }
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ public void sendMessage(IChatBaseComponent[] iChatBaseComponents) {
|
||||
+ for (IChatBaseComponent component : iChatBaseComponents) {
|
||||
+ sendMessage(component, ChatMessageType.SYSTEM, SystemUtils.b);
|
||||
+ }
|
||||
}
|
||||
+ // CraftBukkit end
|
||||
|
||||
public void sendMessage(IChatBaseComponent ichatbasecomponent, ChatMessageType chatmessagetype, UUID uuid) {
|
||||
this.server.sendMessage(ichatbasecomponent, uuid);
|
||||
- this.sendAll(new PacketPlayOutChat(ichatbasecomponent, chatmessagetype, uuid));
|
||||
+ // CraftBukkit start - we run this through our processor first so we can get web links etc
|
||||
+ this.sendAll(new PacketPlayOutChat(CraftChatMessage.fixComponent(ichatbasecomponent), chatmessagetype, uuid));
|
||||
+ // CraftBukkit end
|
||||
+ }
|
||||
+
|
||||
+ public void sendMessage(IChatBaseComponent ichatbasecomponent) {
|
||||
+ this.sendMessage(ichatbasecomponent, ChatMessageType.SYSTEM, SystemUtils.b);
|
||||
}
|
||||
|
||||
- public ServerStatisticManager getStatisticManager(EntityHuman entityhuman) {
|
||||
- UUID uuid = entityhuman.getUniqueID();
|
||||
- ServerStatisticManager serverstatisticmanager = uuid == null ? null : (ServerStatisticManager) this.o.get(uuid);
|
||||
+ // CraftBukkit start
|
||||
+ public ServerStatisticManager getStatisticManager(EntityPlayer entityhuman) {
|
||||
+ ServerStatisticManager serverstatisticmanager = entityhuman.getStatisticManager();
|
||||
+ return serverstatisticmanager == null ? getStatisticManager(entityhuman.getUniqueID(), entityhuman.getDisplayName().getString()) : serverstatisticmanager;
|
||||
+ }
|
||||
+
|
||||
+ public ServerStatisticManager getStatisticManager(UUID uuid, String displayName) {
|
||||
+ EntityPlayer entityhuman = this.getPlayer(uuid);
|
||||
+ ServerStatisticManager serverstatisticmanager = entityhuman == null ? null : (ServerStatisticManager) entityhuman.getStatisticManager();
|
||||
+ // CraftBukkit end
|
||||
|
||||
if (serverstatisticmanager == null) {
|
||||
File file = this.server.a(SavedFile.STATS).toFile();
|
||||
File file1 = new File(file, uuid + ".json");
|
||||
|
||||
if (!file1.exists()) {
|
||||
- File file2 = new File(file, entityhuman.getDisplayName().getString() + ".json");
|
||||
+ File file2 = new File(file, displayName + ".json"); // CraftBukkit
|
||||
|
||||
if (file2.exists() && file2.isFile()) {
|
||||
file2.renameTo(file1);
|
||||
@@ -787,7 +1096,7 @@
|
||||
}
|
||||
|
||||
serverstatisticmanager = new ServerStatisticManager(this.server, file1);
|
||||
- this.o.put(uuid, serverstatisticmanager);
|
||||
+ // this.o.put(uuid, serverstatisticmanager); // CraftBukkit
|
||||
}
|
||||
|
||||
return serverstatisticmanager;
|
||||
@@ -795,14 +1104,14 @@
|
||||
|
||||
public AdvancementDataPlayer f(EntityPlayer entityplayer) {
|
||||
UUID uuid = entityplayer.getUniqueID();
|
||||
- AdvancementDataPlayer advancementdataplayer = (AdvancementDataPlayer) this.p.get(uuid);
|
||||
+ AdvancementDataPlayer advancementdataplayer = (AdvancementDataPlayer) entityplayer.getAdvancementData(); // CraftBukkit
|
||||
|
||||
if (advancementdataplayer == null) {
|
||||
File file = this.server.a(SavedFile.ADVANCEMENTS).toFile();
|
||||
File file1 = new File(file, uuid + ".json");
|
||||
|
||||
advancementdataplayer = new AdvancementDataPlayer(this.server.getDataFixer(), this, this.server.getAdvancementData(), file1, entityplayer);
|
||||
- this.p.put(uuid, advancementdataplayer);
|
||||
+ // this.p.put(uuid, advancementdataplayer); // CraftBukkit
|
||||
}
|
||||
|
||||
advancementdataplayer.a(entityplayer);
|
||||
@@ -838,13 +1147,20 @@
|
||||
}
|
||||
|
||||
public void reload() {
|
||||
- Iterator iterator = this.p.values().iterator();
|
||||
+ // CraftBukkit start
|
||||
+ /*Iterator iterator = this.p.values().iterator();
|
||||
|
||||
while (iterator.hasNext()) {
|
||||
AdvancementDataPlayer advancementdataplayer = (AdvancementDataPlayer) iterator.next();
|
||||
|
||||
advancementdataplayer.a(this.server.getAdvancementData());
|
||||
+ }*/
|
||||
+
|
||||
+ for (EntityPlayer player : players) {
|
||||
+ player.getAdvancementData().a(this.server.getAdvancementData());
|
||||
+ player.getAdvancementData().b(player); // CraftBukkit - trigger immediate flush of advancements
|
||||
}
|
||||
+ // CraftBukkit end
|
||||
|
||||
this.sendAll(new PacketPlayOutTags(this.server.getTagRegistry()));
|
||||
PacketPlayOutRecipeUpdate packetplayoutrecipeupdate = new PacketPlayOutRecipeUpdate(this.server.getCraftingManager().b());
|
||||
@@ -0,0 +1,20 @@
|
||||
--- a/net/minecraft/server/RemoteControlCommandListener.java
|
||||
+++ b/net/minecraft/server/RemoteControlCommandListener.java
|
||||
@@ -26,6 +26,17 @@
|
||||
return new CommandListenerWrapper(this, Vec3D.b((BaseBlockPosition) worldserver.getSpawn()), Vec2F.a, worldserver, 4, "Rcon", RemoteControlCommandListener.b, this.server, (Entity) null);
|
||||
}
|
||||
|
||||
+ // CraftBukkit start - Send a String
|
||||
+ public void sendMessage(String message) {
|
||||
+ this.buffer.append(message);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public org.bukkit.command.CommandSender getBukkitSender(CommandListenerWrapper wrapper) {
|
||||
+ return server.remoteConsole;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
@Override
|
||||
public void sendMessage(IChatBaseComponent ichatbasecomponent, UUID uuid) {
|
||||
this.buffer.append(ichatbasecomponent.getString());
|
||||
Reference in New Issue
Block a user