Updated Upstream (Paper & Pufferfish & Purpur)
This commit is contained in:
@@ -542,7 +542,7 @@ index 0000000000000000000000000000000000000000..a7f297ebb569f7c1f205e967ca485be7
|
||||
+}
|
||||
diff --git a/src/main/java/gg/pufferfish/pufferfish/PufferfishCommand.java b/src/main/java/gg/pufferfish/pufferfish/PufferfishCommand.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..e164237e749bcc43466d4ed7aeada5ab9fddf8a6
|
||||
index 0000000000000000000000000000000000000000..020368da69b9a492155f6de6297f74732f4ab6ea
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/gg/pufferfish/pufferfish/PufferfishCommand.java
|
||||
@@ -0,0 +1,68 @@
|
||||
@@ -570,7 +570,7 @@ index 0000000000000000000000000000000000000000..e164237e749bcc43466d4ed7aeada5ab
|
||||
+ this.usageMessage = "/pufferfish [reload | version]";
|
||||
+ this.setPermission("bukkit.command.pufferfish");
|
||||
+ }
|
||||
+
|
||||
+
|
||||
+ public static void init() {
|
||||
+ MinecraftServer.getServer().server.getCommandMap().register("pufferfish", "Pufferfish", new PufferfishCommand());
|
||||
+ }
|
||||
@@ -616,7 +616,7 @@ index 0000000000000000000000000000000000000000..e164237e749bcc43466d4ed7aeada5ab
|
||||
+}
|
||||
diff --git a/src/main/java/gg/pufferfish/pufferfish/PufferfishConfig.java b/src/main/java/gg/pufferfish/pufferfish/PufferfishConfig.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..a8cead500186142115d4dc029c942fdfc68f7fe5
|
||||
index 0000000000000000000000000000000000000000..6e441a1a28ba72a8b1cc09fe5fca71b3c70627d4
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/gg/pufferfish/pufferfish/PufferfishConfig.java
|
||||
@@ -0,0 +1,285 @@
|
||||
@@ -647,10 +647,10 @@ index 0000000000000000000000000000000000000000..a8cead500186142115d4dc029c942fdf
|
||||
+import org.simpleyaml.exceptions.InvalidConfigurationException;
|
||||
+
|
||||
+public class PufferfishConfig {
|
||||
+
|
||||
+
|
||||
+ private static final YamlFile config = new YamlFile();
|
||||
+ private static int updates = 0;
|
||||
+
|
||||
+
|
||||
+ private static ConfigurationSection convertToBukkit(org.simpleyaml.configuration.ConfigurationSection section) {
|
||||
+ ConfigurationSection newSection = new MemoryConfiguration();
|
||||
+ for (String key : section.getKeys(false)) {
|
||||
@@ -662,18 +662,18 @@ index 0000000000000000000000000000000000000000..a8cead500186142115d4dc029c942fdf
|
||||
+ }
|
||||
+ return newSection;
|
||||
+ }
|
||||
+
|
||||
+
|
||||
+ public static ConfigurationSection getConfigCopy() {
|
||||
+ return convertToBukkit(config);
|
||||
+ }
|
||||
+
|
||||
+
|
||||
+ public static int getUpdates() {
|
||||
+ return updates;
|
||||
+ }
|
||||
+
|
||||
+
|
||||
+ public static void load() throws IOException {
|
||||
+ File configFile = new File("pufferfish.yml");
|
||||
+
|
||||
+
|
||||
+ if (configFile.exists()) {
|
||||
+ try {
|
||||
+ config.load(configFile);
|
||||
@@ -681,14 +681,14 @@ index 0000000000000000000000000000000000000000..a8cead500186142115d4dc029c942fdf
|
||||
+ throw new IOException(e);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+
|
||||
+ getString("info.version", "1.0");
|
||||
+ setComment("info",
|
||||
+ "Pufferfish Configuration",
|
||||
+ "Check out Pufferfish Host for maximum performance server hosting: https://pufferfish.host",
|
||||
+ "Join our Discord for support: https://discord.gg/reZw4vQV9H",
|
||||
+ "Download new builds at https://ci.pufferfish.host/job/Pufferfish");
|
||||
+
|
||||
+
|
||||
+ for (Method method : PufferfishConfig.class.getDeclaredMethods()) {
|
||||
+ if (Modifier.isStatic(method.getModifiers()) && Modifier.isPrivate(method.getModifiers()) && method.getParameterCount() == 0 &&
|
||||
+ method.getReturnType() == Void.TYPE && !method.getName().startsWith("lambda")) {
|
||||
@@ -700,11 +700,11 @@ index 0000000000000000000000000000000000000000..a8cead500186142115d4dc029c942fdf
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+
|
||||
+ updates++;
|
||||
+
|
||||
+
|
||||
+ config.save(configFile);
|
||||
+
|
||||
+
|
||||
+ // Attempt to detect vectorization
|
||||
+ try {
|
||||
+ SIMDDetection.isEnabled = SIMDDetection.canEnable(PufferfishLogger.LOGGER);
|
||||
@@ -712,7 +712,7 @@ index 0000000000000000000000000000000000000000..a8cead500186142115d4dc029c942fdf
|
||||
+ } catch (NoClassDefFoundError | Exception ignored) {
|
||||
+ ignored.printStackTrace();
|
||||
+ }
|
||||
+
|
||||
+
|
||||
+ if (SIMDDetection.isEnabled) {
|
||||
+ PufferfishLogger.LOGGER.info("SIMD operations detected as functional. Will replace some operations with faster versions.");
|
||||
+ } else if (SIMDDetection.versionLimited) {
|
||||
@@ -724,76 +724,76 @@ index 0000000000000000000000000000000000000000..a8cead500186142115d4dc029c942fdf
|
||||
+ PufferfishLogger.LOGGER.warning("Debug: Java: " + System.getProperty("java.version") + ", test run: " + SIMDDetection.testRun);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+
|
||||
+ private static void setComment(String key, String... comment) {
|
||||
+ if (config.contains(key)) {
|
||||
+ config.setComment(key, String.join("\n", comment), CommentType.BLOCK);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+
|
||||
+ private static void ensureDefault(String key, Object defaultValue, String... comment) {
|
||||
+ if (!config.contains(key)) {
|
||||
+ config.set(key, defaultValue);
|
||||
+ config.setComment(key, String.join("\n", comment), CommentType.BLOCK);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+
|
||||
+ private static boolean getBoolean(String key, boolean defaultValue, String... comment) {
|
||||
+ return getBoolean(key, null, defaultValue, comment);
|
||||
+ }
|
||||
+
|
||||
+
|
||||
+ private static boolean getBoolean(String key, @Nullable String oldKey, boolean defaultValue, String... comment) {
|
||||
+ ensureDefault(key, defaultValue, comment);
|
||||
+ return config.getBoolean(key, defaultValue);
|
||||
+ }
|
||||
+
|
||||
+
|
||||
+ private static int getInt(String key, int defaultValue, String... comment) {
|
||||
+ return getInt(key, null, defaultValue, comment);
|
||||
+ }
|
||||
+
|
||||
+
|
||||
+ private static int getInt(String key, @Nullable String oldKey, int defaultValue, String... comment) {
|
||||
+ ensureDefault(key, defaultValue, comment);
|
||||
+ return config.getInt(key, defaultValue);
|
||||
+ }
|
||||
+
|
||||
+
|
||||
+ private static double getDouble(String key, double defaultValue, String... comment) {
|
||||
+ return getDouble(key, null, defaultValue, comment);
|
||||
+ }
|
||||
+
|
||||
+
|
||||
+ private static double getDouble(String key, @Nullable String oldKey, double defaultValue, String... comment) {
|
||||
+ ensureDefault(key, defaultValue, comment);
|
||||
+ return config.getDouble(key, defaultValue);
|
||||
+ }
|
||||
+
|
||||
+
|
||||
+ private static String getString(String key, String defaultValue, String... comment) {
|
||||
+ return getOldString(key, null, defaultValue, comment);
|
||||
+ }
|
||||
+
|
||||
+
|
||||
+ private static String getOldString(String key, @Nullable String oldKey, String defaultValue, String... comment) {
|
||||
+ ensureDefault(key, defaultValue, comment);
|
||||
+ return config.getString(key, defaultValue);
|
||||
+ }
|
||||
+
|
||||
+
|
||||
+ private static List<String> getStringList(String key, List<String> defaultValue, String... comment) {
|
||||
+ return getStringList(key, null, defaultValue, comment);
|
||||
+ }
|
||||
+
|
||||
+
|
||||
+ private static List<String> getStringList(String key, @Nullable String oldKey, List<String> defaultValue, String... comment) {
|
||||
+ ensureDefault(key, defaultValue, comment);
|
||||
+ return config.getStringList(key);
|
||||
+ }
|
||||
+
|
||||
+
|
||||
+ public static String sentryDsn;
|
||||
+ private static void sentry() {
|
||||
+ String sentryEnvironment = System.getenv("SENTRY_DSN");
|
||||
+ String sentryConfig = getString("sentry-dsn", "", "Sentry DSN for improved error logging, leave blank to disable", "Obtain from https://sentry.io/");
|
||||
+
|
||||
+
|
||||
+ sentryDsn = sentryEnvironment == null ? sentryConfig : sentryEnvironment;
|
||||
+ if (sentryDsn != null && !sentryDsn.isBlank()) {
|
||||
+ gg.pufferfish.pufferfish.sentry.SentryManager.init();
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+
|
||||
+ public static boolean enableBooks;
|
||||
+ private static void books() {
|
||||
+ enableBooks = getBoolean("enable-books", true,
|
||||
@@ -802,7 +802,7 @@ index 0000000000000000000000000000000000000000..a8cead500186142115d4dc029c942fdf
|
||||
+ "disabling this option.",
|
||||
+ "This can be overridden per-player with the permission pufferfish.usebooks");
|
||||
+ }
|
||||
+
|
||||
+
|
||||
+ public static boolean enableSuffocationOptimization;
|
||||
+ private static void suffocationOptimization() {
|
||||
+ enableSuffocationOptimization = getBoolean("enable-suffocation-optimization", true,
|
||||
@@ -811,7 +811,7 @@ index 0000000000000000000000000000000000000000..a8cead500186142115d4dc029c942fdf
|
||||
+ "be left enabled on most servers, but is provided as a",
|
||||
+ "configuration option if the vanilla deviation is undesirable.");
|
||||
+ }
|
||||
+
|
||||
+
|
||||
+ public static boolean enableAsyncMobSpawning;
|
||||
+ public static boolean asyncMobSpawningInitialized;
|
||||
+ private static void asyncMobSpawning() {
|
||||
@@ -821,14 +821,14 @@ index 0000000000000000000000000000000000000000..a8cead500186142115d4dc029c942fdf
|
||||
+ "paper's per-player-mob-spawns setting set to true for this to work.",
|
||||
+ "One quick note - this does not actually spawn mobs async (that would be very unsafe).",
|
||||
+ "This just offloads some expensive calculations that are required for mob spawning.");
|
||||
+
|
||||
+
|
||||
+ // This prevents us from changing the value during a reload.
|
||||
+ if (!asyncMobSpawningInitialized) {
|
||||
+ asyncMobSpawningInitialized = true;
|
||||
+ enableAsyncMobSpawning = temp;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+
|
||||
+ public static int maxProjectileLoadsPerTick;
|
||||
+ public static int maxProjectileLoadsPerProjectile;
|
||||
+ private static void projectileLoading() {
|
||||
@@ -870,7 +870,7 @@ index 0000000000000000000000000000000000000000..a8cead500186142115d4dc029c942fdf
|
||||
+
|
||||
+ setComment("dab", "Optimizes entity brains when", "they're far away from the player");
|
||||
+ }
|
||||
+
|
||||
+
|
||||
+ public static Map<String, Integer> projectileTimeouts;
|
||||
+ private static void projectileTimeouts() {
|
||||
+ // Set some defaults
|
||||
@@ -881,13 +881,13 @@ index 0000000000000000000000000000000000000000..a8cead500186142115d4dc029c942fdf
|
||||
+ "entity is in this list and it has survived for longer than",
|
||||
+ "that number of ticks, then it will be removed. Setting a value to",
|
||||
+ "-1 disables this feature.");
|
||||
+
|
||||
+
|
||||
+ for (EntityType<?> entityType : BuiltInRegistries.ENTITY_TYPE) {
|
||||
+ String type = EntityType.getKey(entityType).getPath().toUpperCase(Locale.ROOT);
|
||||
+ entityType.ttl = config.getInt("entity_timeouts." + type, -1);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+
|
||||
+ public static boolean throttleInactiveGoalSelectorTick;
|
||||
+ private static void inactiveGoalSelectorThrottle() {
|
||||
+ getBoolean("inactive-goal-selector-throttle", "inactive-goal-selector-disable", true,
|
||||
@@ -929,7 +929,7 @@ index 0000000000000000000000000000000000000000..53f2df00c6809618a9ee3d2ea72e85e8
|
||||
+}
|
||||
diff --git a/src/main/java/gg/pufferfish/pufferfish/PufferfishVersionFetcher.java b/src/main/java/gg/pufferfish/pufferfish/PufferfishVersionFetcher.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..1adc3de7cdb5b5f309df45f463e4697d6ec2c245
|
||||
index 0000000000000000000000000000000000000000..e877921370f6009a4bd204d9b17d2d58834b8822
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/gg/pufferfish/pufferfish/PufferfishVersionFetcher.java
|
||||
@@ -0,0 +1,136 @@
|
||||
@@ -961,46 +961,46 @@ index 0000000000000000000000000000000000000000..1adc3de7cdb5b5f309df45f463e4697d
|
||||
+import org.jetbrains.annotations.Nullable;
|
||||
+
|
||||
+public class PufferfishVersionFetcher implements VersionFetcher {
|
||||
+
|
||||
+
|
||||
+ private static final Logger LOGGER = Logger.getLogger("PufferfishVersionFetcher");
|
||||
+ private static final HttpClient client = HttpClient.newHttpClient();
|
||||
+
|
||||
+
|
||||
+ private static final URI JENKINS_URI = URI.create("https://ci.pufferfish.host/job/Pufferfish-1.19/lastSuccessfulBuild/buildNumber");
|
||||
+ private static final String GITHUB_FORMAT = "https://api.github.com/repos/pufferfish-gg/Pufferfish/compare/ver/1.19...%s";
|
||||
+
|
||||
+
|
||||
+ private static final HttpResponse.BodyHandler<JsonObject> JSON_OBJECT_BODY_HANDLER = responseInfo -> HttpResponse.BodySubscribers
|
||||
+ .mapping(
|
||||
+ HttpResponse.BodySubscribers.ofString(StandardCharsets.UTF_8),
|
||||
+ string -> new Gson().fromJson(string, JsonObject.class)
|
||||
+ );
|
||||
+
|
||||
+
|
||||
+ @Override
|
||||
+ public long getCacheTime() {
|
||||
+ return TimeUnit.MINUTES.toMillis(30);
|
||||
+ }
|
||||
+
|
||||
+
|
||||
+ @Override
|
||||
+ public @NotNull Component getVersionMessage(final @NotNull String serverVersion) {
|
||||
+ final String[] parts = CraftServer.class.getPackage().getImplementationVersion().split("-");
|
||||
+ @NotNull Component component;
|
||||
+
|
||||
+
|
||||
+ if (parts.length != 3) {
|
||||
+ component = text("Unknown server version.", RED);
|
||||
+ } else {
|
||||
+ final String versionString = parts[2];
|
||||
+
|
||||
+
|
||||
+ try {
|
||||
+ component = this.fetchJenkinsVersion(Integer.parseInt(versionString));
|
||||
+ } catch (NumberFormatException e) {
|
||||
+ component = this.fetchGithubVersion(versionString.substring(1, versionString.length() - 1));
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+
|
||||
+ final @Nullable Component history = this.getHistory();
|
||||
+ return history != null ? Component
|
||||
+ .join(JoinConfiguration.noSeparators(), component, Component.newline(), this.getHistory()) : component;
|
||||
+ }
|
||||
+
|
||||
+
|
||||
+ private @NotNull Component fetchJenkinsVersion(final int versionNumber) {
|
||||
+ final HttpRequest request = HttpRequest.newBuilder(JENKINS_URI).build();
|
||||
+ try {
|
||||
@@ -1008,7 +1008,7 @@ index 0000000000000000000000000000000000000000..1adc3de7cdb5b5f309df45f463e4697d
|
||||
+ if (response.statusCode() != 200) {
|
||||
+ return text("Received invalid status code (" + response.statusCode() + ") from server.", RED);
|
||||
+ }
|
||||
+
|
||||
+
|
||||
+ int latestVersionNumber;
|
||||
+ try {
|
||||
+ latestVersionNumber = Integer.parseInt(response.body());
|
||||
@@ -1016,7 +1016,7 @@ index 0000000000000000000000000000000000000000..1adc3de7cdb5b5f309df45f463e4697d
|
||||
+ LOGGER.log(Level.WARNING, "Received invalid response from Jenkins \"" + response.body() + "\".");
|
||||
+ return text("Received invalid response from server.", RED);
|
||||
+ }
|
||||
+
|
||||
+
|
||||
+ final int versionDiff = latestVersionNumber - versionNumber;
|
||||
+ return this.getResponseMessage(versionDiff);
|
||||
+ } catch (IOException | InterruptedException e) {
|
||||
@@ -1024,7 +1024,7 @@ index 0000000000000000000000000000000000000000..1adc3de7cdb5b5f309df45f463e4697d
|
||||
+ return text("Failed to retrieve version from server.", RED);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+
|
||||
+ // Based off code contributed by Techcable <Techcable@outlook.com> in Paper/GH-65
|
||||
+ private @NotNull Component fetchGithubVersion(final @NotNull String hash) {
|
||||
+ final URI uri = URI.create(String.format(GITHUB_FORMAT, hash));
|
||||
@@ -1034,17 +1034,17 @@ index 0000000000000000000000000000000000000000..1adc3de7cdb5b5f309df45f463e4697d
|
||||
+ if (response.statusCode() != 200) {
|
||||
+ return text("Received invalid status code (" + response.statusCode() + ") from server.", RED);
|
||||
+ }
|
||||
+
|
||||
+
|
||||
+ final JsonObject obj = response.body();
|
||||
+ final int versionDiff = obj.get("behind_by").getAsInt();
|
||||
+
|
||||
+
|
||||
+ return this.getResponseMessage(versionDiff);
|
||||
+ } catch (IOException | InterruptedException e) {
|
||||
+ LOGGER.log(Level.WARNING, "Failed to look up version from GitHub", e);
|
||||
+ return text("Failed to retrieve version from server.", RED);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+
|
||||
+ private @NotNull Component getResponseMessage(final int versionDiff) {
|
||||
+ return switch (Math.max(-1, Math.min(1, versionDiff))) {
|
||||
+ case -1 -> text("You are running an unsupported version of Pufferfish.", RED);
|
||||
@@ -1054,25 +1054,25 @@ index 0000000000000000000000000000000000000000..1adc3de7cdb5b5f309df45f463e4697d
|
||||
+ RED);
|
||||
+ };
|
||||
+ }
|
||||
+
|
||||
+
|
||||
+ private @Nullable Component getHistory() {
|
||||
+ final VersionHistoryManager.VersionData data = VersionHistoryManager.INSTANCE.getVersionData();
|
||||
+ if (data == null) {
|
||||
+ return null;
|
||||
+ }
|
||||
+
|
||||
+
|
||||
+ final String oldVersion = data.getOldVersion();
|
||||
+ if (oldVersion == null) {
|
||||
+ return null;
|
||||
+ }
|
||||
+
|
||||
+
|
||||
+ return Component.text("Previous version: " + oldVersion, NamedTextColor.GRAY, TextDecoration.ITALIC);
|
||||
+ }
|
||||
+}
|
||||
\ No newline at end of file
|
||||
diff --git a/src/main/java/gg/pufferfish/pufferfish/sentry/PufferfishSentryAppender.java b/src/main/java/gg/pufferfish/pufferfish/sentry/PufferfishSentryAppender.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..d04a8a4336566dbe6e1b9ec0d574cff43e003fa8
|
||||
index 0000000000000000000000000000000000000000..731ef11c7a025ae95ed8a757b530d834733d0621
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/gg/pufferfish/pufferfish/sentry/PufferfishSentryAppender.java
|
||||
@@ -0,0 +1,135 @@
|
||||
@@ -1096,14 +1096,14 @@ index 0000000000000000000000000000000000000000..d04a8a4336566dbe6e1b9ec0d574cff4
|
||||
+import org.apache.logging.log4j.core.filter.AbstractFilter;
|
||||
+
|
||||
+public class PufferfishSentryAppender extends AbstractAppender {
|
||||
+
|
||||
+
|
||||
+ private static final org.apache.logging.log4j.Logger logger = LogManager.getLogger(PufferfishSentryAppender.class);
|
||||
+ private static final Gson GSON = new Gson();
|
||||
+
|
||||
+
|
||||
+ public PufferfishSentryAppender() {
|
||||
+ super("PufferfishSentryAdapter", new SentryFilter(), null);
|
||||
+ }
|
||||
+
|
||||
+
|
||||
+ @Override
|
||||
+ public void append(LogEvent logEvent) {
|
||||
+ if (logEvent.getThrown() != null && logEvent.getLevel().isMoreSpecificThan(Level.WARN)) {
|
||||
@@ -1120,55 +1120,55 @@ index 0000000000000000000000000000000000000000..d04a8a4336566dbe6e1b9ec0d574cff4
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+
|
||||
+ private void logException(LogEvent e) {
|
||||
+ SentryEvent event = new SentryEvent(e.getThrown());
|
||||
+
|
||||
+
|
||||
+ Message sentryMessage = new Message();
|
||||
+ sentryMessage.setMessage(e.getMessage().getFormattedMessage());
|
||||
+
|
||||
+
|
||||
+ event.setThrowable(e.getThrown());
|
||||
+ event.setLevel(getLevel(e.getLevel()));
|
||||
+ event.setLogger(e.getLoggerName());
|
||||
+ event.setTransaction(e.getLoggerName());
|
||||
+ event.setExtra("thread_name", e.getThreadName());
|
||||
+
|
||||
+
|
||||
+ boolean hasContext = e.getContextData() != null;
|
||||
+
|
||||
+
|
||||
+ if (hasContext && e.getContextData().containsKey("pufferfishsentry_playerid")) {
|
||||
+ User user = new User();
|
||||
+ user.setId(e.getContextData().getValue("pufferfishsentry_playerid"));
|
||||
+ user.setUsername(e.getContextData().getValue("pufferfishsentry_playername"));
|
||||
+ event.setUser(user);
|
||||
+ }
|
||||
+
|
||||
+
|
||||
+ if (hasContext && e.getContextData().containsKey("pufferfishsentry_pluginname")) {
|
||||
+ event.setExtra("plugin.name", e.getContextData().getValue("pufferfishsentry_pluginname"));
|
||||
+ event.setExtra("plugin.version", e.getContextData().getValue("pufferfishsentry_pluginversion"));
|
||||
+ event.setTransaction(e.getContextData().getValue("pufferfishsentry_pluginname"));
|
||||
+ }
|
||||
+
|
||||
+
|
||||
+ if (hasContext && e.getContextData().containsKey("pufferfishsentry_eventdata")) {
|
||||
+ Map<String, String> eventFields = GSON.fromJson((String) e.getContextData().getValue("pufferfishsentry_eventdata"), new TypeToken<Map<String, String>>() {}.getType());
|
||||
+ if (eventFields != null) {
|
||||
+ event.setExtra("event", eventFields);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+
|
||||
+ Sentry.captureEvent(event);
|
||||
+ }
|
||||
+
|
||||
+
|
||||
+ private void logBreadcrumb(LogEvent e) {
|
||||
+ Breadcrumb breadcrumb = new Breadcrumb();
|
||||
+
|
||||
+
|
||||
+ breadcrumb.setLevel(getLevel(e.getLevel()));
|
||||
+ breadcrumb.setCategory(e.getLoggerName());
|
||||
+ breadcrumb.setType(e.getLoggerName());
|
||||
+ breadcrumb.setMessage(e.getMessage().getFormattedMessage());
|
||||
+
|
||||
+
|
||||
+ Sentry.addBreadcrumb(breadcrumb);
|
||||
+ }
|
||||
+
|
||||
+
|
||||
+ private SentryLevel getLevel(Level level) {
|
||||
+ switch (level.getStandardLevel()) {
|
||||
+ case TRACE:
|
||||
@@ -1185,35 +1185,35 @@ index 0000000000000000000000000000000000000000..d04a8a4336566dbe6e1b9ec0d574cff4
|
||||
+ return SentryLevel.INFO;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+
|
||||
+ private static class SentryFilter extends AbstractFilter {
|
||||
+
|
||||
+
|
||||
+ @Override
|
||||
+ public Result filter(Logger logger, org.apache.logging.log4j.Level level, Marker marker, String msg,
|
||||
+ Object... params) {
|
||||
+ return this.filter(logger.getName());
|
||||
+ }
|
||||
+
|
||||
+
|
||||
+ @Override
|
||||
+ public Result filter(Logger logger, org.apache.logging.log4j.Level level, Marker marker, Object msg, Throwable t) {
|
||||
+ return this.filter(logger.getName());
|
||||
+ }
|
||||
+
|
||||
+
|
||||
+ @Override
|
||||
+ public Result filter(LogEvent event) {
|
||||
+ return this.filter(event == null ? null : event.getLoggerName());
|
||||
+ }
|
||||
+
|
||||
+
|
||||
+ private Result filter(String loggerName) {
|
||||
+ return loggerName != null && loggerName.startsWith("gg.castaway.pufferfish.sentry") ? Result.DENY
|
||||
+ : Result.NEUTRAL;
|
||||
+ }
|
||||
+
|
||||
+
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/gg/pufferfish/pufferfish/sentry/SentryManager.java b/src/main/java/gg/pufferfish/pufferfish/sentry/SentryManager.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..b011abbeb80b42de6be3785e47c7ba3c0f6dc161
|
||||
index 0000000000000000000000000000000000000000..1b29210ad0bbb4ada150f23357f0c80d331c996d
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/gg/pufferfish/pufferfish/sentry/SentryManager.java
|
||||
@@ -0,0 +1,40 @@
|
||||
@@ -1225,27 +1225,27 @@ index 0000000000000000000000000000000000000000..b011abbeb80b42de6be3785e47c7ba3c
|
||||
+import org.apache.logging.log4j.Logger;
|
||||
+
|
||||
+public class SentryManager {
|
||||
+
|
||||
+
|
||||
+ private static final Logger logger = LogManager.getLogger(SentryManager.class);
|
||||
+
|
||||
+
|
||||
+ private SentryManager() {
|
||||
+
|
||||
+
|
||||
+ }
|
||||
+
|
||||
+
|
||||
+ private static boolean initialized = false;
|
||||
+
|
||||
+
|
||||
+ public static synchronized void init() {
|
||||
+ if (initialized) {
|
||||
+ return;
|
||||
+ }
|
||||
+ try {
|
||||
+ initialized = true;
|
||||
+
|
||||
+
|
||||
+ Sentry.init(options -> {
|
||||
+ options.setDsn(PufferfishConfig.sentryDsn);
|
||||
+ options.setMaxBreadcrumbs(100);
|
||||
+ });
|
||||
+
|
||||
+
|
||||
+ PufferfishSentryAppender appender = new PufferfishSentryAppender();
|
||||
+ appender.start();
|
||||
+ ((org.apache.logging.log4j.core.Logger) LogManager.getRootLogger()).addAppender(appender);
|
||||
@@ -1255,11 +1255,11 @@ index 0000000000000000000000000000000000000000..b011abbeb80b42de6be3785e47c7ba3c
|
||||
+ initialized = false;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+
|
||||
+}
|
||||
diff --git a/src/main/java/gg/pufferfish/pufferfish/util/AsyncExecutor.java b/src/main/java/gg/pufferfish/pufferfish/util/AsyncExecutor.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..0fe6243ea01f39fc43c4ca8897a70feddb7fb11d
|
||||
index 0000000000000000000000000000000000000000..8e5323d5d9af25c8a85c4b34a6be76cfc54384cf
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/gg/pufferfish/pufferfish/util/AsyncExecutor.java
|
||||
@@ -0,0 +1,73 @@
|
||||
@@ -1274,26 +1274,26 @@ index 0000000000000000000000000000000000000000..0fe6243ea01f39fc43c4ca8897a70fed
|
||||
+import java.util.logging.Level;
|
||||
+
|
||||
+public class AsyncExecutor implements Runnable {
|
||||
+
|
||||
+
|
||||
+ private final Queue<Runnable> jobs = Queues.newArrayDeque();
|
||||
+ private final Lock mutex = new ReentrantLock();
|
||||
+ private final Condition cond = mutex.newCondition();
|
||||
+ private final Thread thread;
|
||||
+ private volatile boolean killswitch = false;
|
||||
+
|
||||
+
|
||||
+ public AsyncExecutor(String threadName) {
|
||||
+ this.thread = new Thread(this, threadName);
|
||||
+ }
|
||||
+
|
||||
+
|
||||
+ public void start() {
|
||||
+ thread.start();
|
||||
+ }
|
||||
+
|
||||
+
|
||||
+ public void kill() {
|
||||
+ killswitch = true;
|
||||
+ cond.signalAll();
|
||||
+ }
|
||||
+
|
||||
+
|
||||
+ public void submit(Runnable runnable) {
|
||||
+ mutex.lock();
|
||||
+ try {
|
||||
@@ -1303,7 +1303,7 @@ index 0000000000000000000000000000000000000000..0fe6243ea01f39fc43c4ca8897a70fed
|
||||
+ mutex.unlock();
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+
|
||||
+ @Override
|
||||
+ public void run() {
|
||||
+ while (!killswitch) {
|
||||
@@ -1319,26 +1319,26 @@ index 0000000000000000000000000000000000000000..0fe6243ea01f39fc43c4ca8897a70fed
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+
|
||||
+ private Runnable takeRunnable() throws InterruptedException {
|
||||
+ mutex.lock();
|
||||
+ try {
|
||||
+ while (jobs.isEmpty() && !killswitch) {
|
||||
+ cond.await();
|
||||
+ }
|
||||
+
|
||||
+
|
||||
+ if (jobs.isEmpty()) return null; // We've set killswitch
|
||||
+
|
||||
+
|
||||
+ return jobs.remove();
|
||||
+ } finally {
|
||||
+ mutex.unlock();
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+
|
||||
+}
|
||||
diff --git a/src/main/java/gg/pufferfish/pufferfish/util/AsyncPlayerAreaMap.java b/src/main/java/gg/pufferfish/pufferfish/util/AsyncPlayerAreaMap.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..a93ee99c2399def1e221260547a3e6bce2d621fa
|
||||
index 0000000000000000000000000000000000000000..fdcb62d12164024a5f354d60cc863821a18d1b2a
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/gg/pufferfish/pufferfish/util/AsyncPlayerAreaMap.java
|
||||
@@ -0,0 +1,31 @@
|
||||
@@ -1350,22 +1350,22 @@ index 0000000000000000000000000000000000000000..a93ee99c2399def1e221260547a3e6bc
|
||||
+import net.minecraft.server.level.ServerPlayer;
|
||||
+
|
||||
+public final class AsyncPlayerAreaMap extends PlayerAreaMap {
|
||||
+
|
||||
+
|
||||
+ public AsyncPlayerAreaMap() {
|
||||
+ super();
|
||||
+ this.areaMap = new Long2ObjectOpenHashMapWrapper<>(new ConcurrentHashMap<>(1024, 0.7f));
|
||||
+ }
|
||||
+
|
||||
+
|
||||
+ public AsyncPlayerAreaMap(final PooledLinkedHashSets<ServerPlayer> pooledHashSets) {
|
||||
+ super(pooledHashSets);
|
||||
+ this.areaMap = new Long2ObjectOpenHashMapWrapper<>(new ConcurrentHashMap<>(1024, 0.7f));
|
||||
+ }
|
||||
+
|
||||
+
|
||||
+ public AsyncPlayerAreaMap(final PooledLinkedHashSets<ServerPlayer> pooledHashSets, final ChangeCallback<ServerPlayer> addCallback,
|
||||
+ final ChangeCallback<ServerPlayer> removeCallback) {
|
||||
+ this(pooledHashSets, addCallback, removeCallback, null);
|
||||
+ }
|
||||
+
|
||||
+
|
||||
+ public AsyncPlayerAreaMap(final PooledLinkedHashSets<ServerPlayer> pooledHashSets, final ChangeCallback<ServerPlayer> addCallback,
|
||||
+ final ChangeCallback<ServerPlayer> removeCallback, final ChangeSourceCallback<ServerPlayer> changeSourceCallback) {
|
||||
+ super(pooledHashSets, addCallback, removeCallback, changeSourceCallback);
|
||||
@@ -1401,7 +1401,7 @@ index 0000000000000000000000000000000000000000..c1929840254a3e6d721816f4a20415be
|
||||
+}
|
||||
diff --git a/src/main/java/gg/pufferfish/pufferfish/util/Long2ObjectOpenHashMapWrapper.java b/src/main/java/gg/pufferfish/pufferfish/util/Long2ObjectOpenHashMapWrapper.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..42cdc43d6b739973a0944f502089757247ee6c61
|
||||
index 0000000000000000000000000000000000000000..facd55463d44cb7e3d2ca6892982f5497b8dded1
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/gg/pufferfish/pufferfish/util/Long2ObjectOpenHashMapWrapper.java
|
||||
@@ -0,0 +1,40 @@
|
||||
@@ -1412,82 +1412,39 @@ index 0000000000000000000000000000000000000000..42cdc43d6b739973a0944f5020897572
|
||||
+import org.jetbrains.annotations.Nullable;
|
||||
+
|
||||
+public class Long2ObjectOpenHashMapWrapper<V> extends Long2ObjectOpenHashMap<V> {
|
||||
+
|
||||
+
|
||||
+ private final Map<Long, V> backingMap;
|
||||
+
|
||||
+
|
||||
+ public Long2ObjectOpenHashMapWrapper(Map<Long, V> map) {
|
||||
+ backingMap = map;
|
||||
+ }
|
||||
+
|
||||
+
|
||||
+ @Override
|
||||
+ public V put(Long key, V value) {
|
||||
+ return backingMap.put(key, value);
|
||||
+ }
|
||||
+
|
||||
+
|
||||
+ @Override
|
||||
+ public V get(Object key) {
|
||||
+ return backingMap.get(key);
|
||||
+ }
|
||||
+
|
||||
+
|
||||
+ @Override
|
||||
+ public V remove(Object key) {
|
||||
+ return backingMap.remove(key);
|
||||
+ }
|
||||
+
|
||||
+
|
||||
+ @Nullable
|
||||
+ @Override
|
||||
+ public V putIfAbsent(Long key, V value) {
|
||||
+ return backingMap.putIfAbsent(key, value);
|
||||
+ }
|
||||
+
|
||||
+
|
||||
+ @Override
|
||||
+ public int size() {
|
||||
+ return backingMap.size();
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/io/papermc/paper/configuration/GlobalConfiguration.java b/src/main/java/io/papermc/paper/configuration/GlobalConfiguration.java
|
||||
index 8d442c5a498ecf288a0cc0c54889c6e2fda849ce..01bdf134fc21220ab7ecca51f2dcd51c0b466bba 100644
|
||||
--- a/src/main/java/io/papermc/paper/configuration/GlobalConfiguration.java
|
||||
+++ b/src/main/java/io/papermc/paper/configuration/GlobalConfiguration.java
|
||||
@@ -7,6 +7,7 @@ import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
import net.minecraft.network.protocol.Packet;
|
||||
import net.minecraft.network.protocol.game.ServerboundPlaceRecipePacket;
|
||||
+import org.bukkit.Bukkit; // Pufferfish
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
import org.spongepowered.configurate.objectmapping.ConfigSerializable;
|
||||
import org.spongepowered.configurate.objectmapping.meta.Comment;
|
||||
@@ -16,6 +17,7 @@ import org.spongepowered.configurate.objectmapping.meta.Setting;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
+import java.util.logging.Level; // Pufferfish
|
||||
|
||||
@SuppressWarnings({"CanBeFinal", "FieldCanBeLocal", "FieldMayBeFinal", "NotNullFieldNotInitialized", "InnerClassMayBeStatic"})
|
||||
public class GlobalConfiguration extends ConfigurationPart {
|
||||
@@ -51,6 +53,7 @@ public class GlobalConfiguration extends ConfigurationPart {
|
||||
|
||||
public class Timings extends ConfigurationPart.Post {
|
||||
public boolean enabled = true;
|
||||
+ public boolean reallyEnabled = false;
|
||||
public boolean verbose = true;
|
||||
public String url = "https://timings.aikar.co/";
|
||||
public boolean serverNamePrivacy = false;
|
||||
@@ -64,6 +67,14 @@ public class GlobalConfiguration extends ConfigurationPart {
|
||||
|
||||
@Override
|
||||
public void postProcess() {
|
||||
+ // Pufferfish start
|
||||
+ if (enabled && !reallyEnabled) {
|
||||
+ Bukkit.getLogger().log(Level.WARNING, "[Pufferfish] To improve performance, timings have been disabled by default");
|
||||
+ Bukkit.getLogger().log(Level.WARNING, "[Pufferfish] You can still use timings by using /timings on, but they will not start on server startup unless you set timings.really-enabled to true in paper.yml");
|
||||
+ Bukkit.getLogger().log(Level.WARNING, "[Pufferfish] If you would like to disable this message, either set timings.really-enabled to true or timings.enabled to false.");
|
||||
+ }
|
||||
+ enabled = reallyEnabled;
|
||||
+ // Pufferfish end
|
||||
MinecraftTimings.processConfig(this);
|
||||
}
|
||||
}
|
||||
diff --git a/src/main/java/io/papermc/paper/util/MCUtil.java b/src/main/java/io/papermc/paper/util/MCUtil.java
|
||||
index 6efb8b10f17c70b05128039376d254e6beda3841..57e8c6673c7cfe447a75f15506e8000062d813fe 100644
|
||||
--- a/src/main/java/io/papermc/paper/util/MCUtil.java
|
||||
@@ -1502,18 +1459,18 @@ index 6efb8b10f17c70b05128039376d254e6beda3841..57e8c6673c7cfe447a75f15506e80000
|
||||
|
||||
public static long getCoordinateKey(final ChunkPos pair) {
|
||||
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
index 9f15d9dbdfa74a0640b1a2b4ff695609d4758a4c..644a7f020afd26017543056fd9378868b1874fe8 100644
|
||||
index 9f15d9dbdfa74a0640b1a2b4ff695609d4758a4c..a29d92b3f2658b63545b25092bb3a1fea46ca36b 100644
|
||||
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
@@ -314,6 +314,8 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
@@ -313,6 +313,8 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
public volatile Thread shutdownThread; // Paper
|
||||
public volatile boolean abnormalExit = false; // Paper
|
||||
public boolean isIteratingOverLevels = false; // Paper
|
||||
|
||||
+
|
||||
+ public gg.pufferfish.pufferfish.util.AsyncExecutor mobSpawnExecutor = new gg.pufferfish.pufferfish.util.AsyncExecutor("MobSpawning"); // Pufferfish - optimize mob spawning
|
||||
+
|
||||
|
||||
public static <S extends MinecraftServer> S spin(Function<Thread, S> serverFactory) {
|
||||
AtomicReference<S> atomicreference = new AtomicReference();
|
||||
Thread thread = new io.papermc.paper.util.TickThread(() -> { // Paper - rewrite chunk system
|
||||
@@ -1682,7 +1684,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
|
||||
@DontObfuscate
|
||||
@@ -1605,19 +1562,19 @@ index fbe209a66c77c47935ad026dd3e45e682af91fd8..3ce4dbf4eed442d89d6bbc8e4c6a0001
|
||||
return this.scaledRange(i);
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/server/level/ServerChunkCache.java b/src/main/java/net/minecraft/server/level/ServerChunkCache.java
|
||||
index ca84eddbdb1e198b899750e5f6b3eafd25ce970f..8438354e482b6f892c3344eceff1abd23cfa128a 100644
|
||||
index ca84eddbdb1e198b899750e5f6b3eafd25ce970f..c6f5d6756fa0e068a462d9c0ded12e0771abba37 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ServerChunkCache.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ServerChunkCache.java
|
||||
@@ -77,6 +77,9 @@ public class ServerChunkCache extends ChunkSource {
|
||||
@@ -76,6 +76,9 @@ public class ServerChunkCache extends ChunkSource {
|
||||
final it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap<LevelChunk> loadedChunkMap = new it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap<>(8192, 0.5f);
|
||||
|
||||
private final LevelChunk[] lastLoadedChunks = new LevelChunk[4 * 4];
|
||||
|
||||
+
|
||||
+ public boolean firstRunSpawnCounts = true; // Pufferfish
|
||||
+ public final java.util.concurrent.atomic.AtomicBoolean _pufferfish_spawnCountsReady = new java.util.concurrent.atomic.AtomicBoolean(false); // Pufferfish - optimize countmobs
|
||||
+
|
||||
|
||||
private static int getChunkCacheKey(int x, int z) {
|
||||
return x & 3 | ((z & 3) << 2);
|
||||
}
|
||||
@@ -703,6 +706,7 @@ public class ServerChunkCache extends ChunkSource {
|
||||
ProfilerFiller gameprofilerfiller = this.level.getProfiler();
|
||||
|
||||
@@ -1673,7 +1630,7 @@ index ca84eddbdb1e198b899750e5f6b3eafd25ce970f..8438354e482b6f892c3344eceff1abd2
|
||||
}
|
||||
// Paper end - controlled flush for entity tracker packets
|
||||
}
|
||||
+
|
||||
+
|
||||
+ // Pufferfish start - optimize mob spawning
|
||||
+ if (gg.pufferfish.pufferfish.PufferfishConfig.enableAsyncMobSpawning) {
|
||||
+ for (ServerPlayer player : this.level.players) {
|
||||
@@ -1721,7 +1678,7 @@ index b7fd8e70413c38923d0719aff803449e392383ac..d5cb594f0b17ec9dc1a19cdb99bba553
|
||||
this.wasOnGround = this.entity.isOnGround();
|
||||
this.teleportDelay = 0;
|
||||
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
index 309ef1b2181eae609737212a50d037a1565daf86..17b1a891073521be51e7c6bf8f53cb4ed79983ce 100644
|
||||
index 3bb63a652aca3c23f5f1bbf9cb70fce6540f2e33..dda5e77f7d9fb2340d50997c0a17bc7f5e2bb961 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
@@ -709,6 +709,7 @@ public class ServerLevel extends Level implements WorldGenLevel {
|
||||
@@ -1786,10 +1743,10 @@ index 309ef1b2181eae609737212a50d037a1565daf86..17b1a891073521be51e7c6bf8f53cb4e
|
||||
this.getRandomBlockPosition(j, 0, k, 15, blockposition);
|
||||
int normalY = chunk.getHeight(Heightmap.Types.MOTION_BLOCKING, blockposition.getX() & 15, blockposition.getZ() & 15) + 1;
|
||||
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
index 177aac1ab10189bb5a52217e86ba5c8a535b4197..b357953dedc2af39673ad4ef78fed14d5e7235bb 100644
|
||||
index 9c5754ac3b00d3f0cb80ec83a2beefadee6d0a14..cc7187c597337665d3cf3c3de4b53e3105b9e4c3 100644
|
||||
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
@@ -1214,6 +1214,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
|
||||
@@ -1215,6 +1215,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
|
||||
|
||||
@Override
|
||||
public void handleEditBook(ServerboundEditBookPacket packet) {
|
||||
@@ -1797,7 +1754,7 @@ index 177aac1ab10189bb5a52217e86ba5c8a535b4197..b357953dedc2af39673ad4ef78fed14d
|
||||
// Paper start
|
||||
if (!this.cserver.isPrimaryThread()) {
|
||||
List<String> pageList = packet.getPages();
|
||||
@@ -2355,6 +2356,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
|
||||
@@ -2356,6 +2357,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
|
||||
}
|
||||
|
||||
private boolean updateChatOrder(Instant timestamp) {
|
||||
@@ -1918,7 +1875,7 @@ index 04b1531572e8fff1e46fe1c94e7fc863841e0f66..47ddc42f2b63d9d3fae5ae6ea93d4183
|
||||
int LARGE_MAX_STACK_SIZE = 64;
|
||||
int DEFAULT_DISTANCE_LIMIT = 8;
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
index 4705d7066207250c03a5f98eef61554c901f2e35..548133e399b5abc4aa83045af87c135a3455b722 100644
|
||||
index 4705d7066207250c03a5f98eef61554c901f2e35..e25be74ef0a88541884ad62a4b84219400d5a142 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
@@ -291,7 +291,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
|
||||
@@ -1939,7 +1896,7 @@ index 4705d7066207250c03a5f98eef61554c901f2e35..548133e399b5abc4aa83045af87c135a
|
||||
+ public int activatedPriority = gg.pufferfish.pufferfish.PufferfishConfig.maximumActivationPrio; // golf score
|
||||
+ public final BlockPos.MutableBlockPos cachedBlockPos = new BlockPos.MutableBlockPos(); // used where needed
|
||||
+ // Pufferfish end
|
||||
+
|
||||
+
|
||||
public float getBukkitYaw() {
|
||||
return this.yRot;
|
||||
}
|
||||
@@ -2125,7 +2082,7 @@ index ceacc0d383e2ee674783d3c0a7df0a951595faca..8af0918d3a62de58a4b2af55022c812b
|
||||
private String descriptionId;
|
||||
@Nullable
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
index dcfb71b5a53df789e366fea2080921d677549a2e..791f672b30f2a4d3b329e2ce0f4fb9c2ca627b01 100644
|
||||
index 95a27d28f73039693ca64601954af62028413634..f3d96caa83ef4a8083b78e3265282d4723e37d28 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
@@ -141,7 +141,6 @@ import org.bukkit.event.entity.EntityTeleportEvent;
|
||||
@@ -2776,66 +2733,6 @@ index 2ee9e8e3c1a28c1823de8e1fe421cc1f3e72f384..cf4a8084158b10bf047d418dda375f8c
|
||||
// CraftBukkit start - moved block handling into separate method for use by Block#rayTrace
|
||||
default BlockHitResult clip(ClipContext raytrace1, BlockPos blockposition) {
|
||||
// Paper start - Prevent raytrace from loading chunks
|
||||
diff --git a/src/main/java/net/minecraft/world/level/GameRules.java b/src/main/java/net/minecraft/world/level/GameRules.java
|
||||
index edd2c9d0cf5a81c779011cb4215d496a8987b784..29d1f78dbc8410f9292f409b17705acde55979df 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/GameRules.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/GameRules.java
|
||||
@@ -100,6 +100,7 @@ public class GameRules {
|
||||
public static final GameRules.Key<GameRules.BooleanValue> RULE_GLOBAL_SOUND_EVENTS = GameRules.register("globalSoundEvents", GameRules.Category.MISC, GameRules.BooleanValue.create(true));
|
||||
public static final GameRules.Key<GameRules.BooleanValue> RULE_DO_VINES_SPREAD = GameRules.register("doVinesSpread", GameRules.Category.UPDATES, GameRules.BooleanValue.create(true));
|
||||
private final Map<GameRules.Key<?>, GameRules.Value<?>> rules;
|
||||
+ private final GameRules.Value<?>[] gameruleArray;
|
||||
|
||||
private static <T extends GameRules.Value<T>> GameRules.Key<T> register(String name, GameRules.Category category, GameRules.Type<T> type) {
|
||||
GameRules.Key<T> gamerules_gamerulekey = new GameRules.Key<>(name, category);
|
||||
@@ -118,17 +119,33 @@ public class GameRules {
|
||||
}
|
||||
|
||||
public GameRules() {
|
||||
- this.rules = (Map) GameRules.GAME_RULE_TYPES.entrySet().stream().collect(ImmutableMap.toImmutableMap(Entry::getKey, (entry) -> {
|
||||
+ // Pufferfish start - use this to ensure gameruleArray is initialized
|
||||
+ this((Map) GameRules.GAME_RULE_TYPES.entrySet().stream().collect(ImmutableMap.toImmutableMap(Entry::getKey, (entry) -> {
|
||||
return ((GameRules.Type) entry.getValue()).createRule();
|
||||
- }));
|
||||
+ })));
|
||||
+ // Pufferfish end
|
||||
}
|
||||
|
||||
private GameRules(Map<GameRules.Key<?>, GameRules.Value<?>> rules) {
|
||||
this.rules = rules;
|
||||
+
|
||||
+ // Pufferfish start
|
||||
+ int arraySize = rules.keySet().stream().mapToInt(key -> key.gameRuleIndex).max().orElse(-1) + 1;
|
||||
+ GameRules.Value<?>[] values = new GameRules.Value[arraySize];
|
||||
+
|
||||
+ for (Entry<GameRules.Key<?>, GameRules.Value<?>> entry : rules.entrySet()) {
|
||||
+ values[entry.getKey().gameRuleIndex] = entry.getValue();
|
||||
+ }
|
||||
+
|
||||
+ this.gameruleArray = values;
|
||||
+ // Pufferfish end
|
||||
}
|
||||
|
||||
public <T extends GameRules.Value<T>> T getRule(GameRules.Key<T> key) {
|
||||
- return (T) this.rules.get(key); // CraftBukkit - decompile error
|
||||
+ // Pufferfish start
|
||||
+ return key == null ? null : (T) this.gameruleArray[key.gameRuleIndex];
|
||||
+ //return (T) this.rules.get(key); // CraftBukkit - decompile error
|
||||
+ // Pufferfish end
|
||||
}
|
||||
|
||||
public CompoundTag createTag() {
|
||||
@@ -187,6 +204,10 @@ public class GameRules {
|
||||
}
|
||||
|
||||
public static final class Key<T extends GameRules.Value<T>> {
|
||||
+ // Pufferfish start
|
||||
+ private static int lastGameRuleIndex = 0;
|
||||
+ public final int gameRuleIndex = lastGameRuleIndex++;
|
||||
+ // Pufferfish end
|
||||
|
||||
final String id;
|
||||
private final GameRules.Category category;
|
||||
diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
|
||||
index 973ecd50f9cb6b86c353586e84d15dcb118ccb60..6aec1983a0236d6aa0507a2b3ad1c08b3330f0fc 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/Level.java
|
||||
@@ -3137,7 +3034,7 @@ index a71414397bd45ee7bcacfeef0041d80dfa25f114..d66806565770cb03a21794f99e5c4b0f
|
||||
|
||||
@Override
|
||||
diff --git a/src/main/java/net/minecraft/world/level/block/entity/HopperBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/HopperBlockEntity.java
|
||||
index cba114f554644a37339c93026630c66c43f524b9..746b71ea96ecc441afd45cc779a1777c15d58ff2 100644
|
||||
index aac5572c1d40a10cd1d17f89c9eb836718837577..9b506bd2ec6e7fd1893dc7801592f011680028d7 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/block/entity/HopperBlockEntity.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/block/entity/HopperBlockEntity.java
|
||||
@@ -47,7 +47,10 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen
|
||||
@@ -3261,7 +3158,7 @@ index 79b01e32f89defb6b78f4764600d33d4945af592..6d62cc8fb347ccafd51df05896e61699
|
||||
}
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java b/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java
|
||||
index 206dc04086a218b510930739a6c573f2653ab0fa..e7e2b0fc88c9320449bcd0e0929269c2508886e4 100644
|
||||
index d190bad5d287766ed4165ed827d9901a9d878687..13594b96cc8f451723c3598ef302ccee8e01bcac 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java
|
||||
@@ -88,6 +88,18 @@ public class LevelChunk extends ChunkAccess {
|
||||
@@ -3283,14 +3180,15 @@ index 206dc04086a218b510930739a6c573f2653ab0fa..e7e2b0fc88c9320449bcd0e0929269c2
|
||||
public LevelChunk(Level world, ChunkPos pos) {
|
||||
this(world, pos, UpgradeData.EMPTY, new LevelChunkTicks<>(), new LevelChunkTicks<>(), 0L, (LevelChunkSection[]) null, (LevelChunk.PostLoadProcessor) null, (BlendingData) null);
|
||||
}
|
||||
@@ -118,6 +130,7 @@ public class LevelChunk extends ChunkAccess {
|
||||
@@ -116,6 +128,8 @@ public class LevelChunk extends ChunkAccess {
|
||||
this.postLoad = entityLoader;
|
||||
this.blockTicks = blockTickScheduler;
|
||||
this.fluidTicks = fluidTickScheduler;
|
||||
// CraftBukkit start
|
||||
this.bukkitChunk = new org.bukkit.craftbukkit.CraftChunk(this);
|
||||
+
|
||||
+ this.lightningTick = this.level.getThreadUnsafeRandom().nextInt(100000) << 1; // Pufferfish - initialize lightning tick
|
||||
}
|
||||
|
||||
public org.bukkit.Chunk bukkitChunk;
|
||||
// CraftBukkit start
|
||||
diff --git a/src/main/java/net/minecraft/world/level/chunk/LevelChunkSection.java b/src/main/java/net/minecraft/world/level/chunk/LevelChunkSection.java
|
||||
index 1b80a91fa36c59a31b57ef7ef4a68eacbb0f17f5..b5e118456af6421ae3f85cb8232dc97a8b2d46b7 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/chunk/LevelChunkSection.java
|
||||
@@ -3533,7 +3431,7 @@ index ebe65474a4a05ff1637d7f37ebcfe690af59def5..42142c512b12e5b269c19f1e821c50e7
|
||||
|
||||
@Nullable
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
index 4cd95134811fd65465681d159b2f30cf77455830..7672fe8e6d08370327bb7ad5fa5ac3292c49e3c4 100644
|
||||
index 0ba8446065def1b120fd73241de5bc14d60d3b82..58eaa1142bb0568bef439bba76903309914d3ae1 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
@@ -256,7 +256,7 @@ import javax.annotation.Nullable; // Paper
|
||||
|
||||
Reference in New Issue
Block a user