More more work

This commit is contained in:
Nassim Jahnke 2021-06-12 13:18:01 +02:00
parent d937034264
commit 3f41a42781
34 changed files with 301 additions and 245 deletions

View file

@ -1,117 +1,117 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Minecrell <minecrell@minecrell.net>
Date: Thu, 21 Sep 2017 19:41:20 +0200
Subject: [PATCH] Add workaround for plugins modifying the parent of the plugin
logger
Essentials uses a custom logger name ("Essentials") instead of the
plugin logger. Log messages are redirected to the plugin logger by
setting the parent of the "Essentials" logger to the plugin logger.
With our changes, the plugin logger is now also called "Essentials",
resulting in an infinite loop. Make sure plugins can't change the
parent of the plugin logger to avoid this.
diff --git a/src/main/java/com/destroystokyo/paper/utils/PaperPluginLogger.java b/src/main/java/com/destroystokyo/paper/utils/PaperPluginLogger.java
new file mode 100644
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000
--- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/utils/PaperPluginLogger.java
@@ -0,0 +0,0 @@
+package com.destroystokyo.paper.utils;
+
+import org.bukkit.plugin.PluginDescriptionFile;
+
+import java.util.logging.Level;
+import java.util.logging.LogManager;
+import java.util.logging.Logger;
+import org.jetbrains.annotations.NotNull;
+
+/**
+ * Prevents plugins (e.g. Essentials) from changing the parent of the plugin logger.
+ */
+public class PaperPluginLogger extends Logger {
+
+ @NotNull
+ public static Logger getLogger(@NotNull PluginDescriptionFile description) {
+ Logger logger = new PaperPluginLogger(description);
+ if (!LogManager.getLogManager().addLogger(logger)) {
+ // Disable this if it's going to happen across reloads anyways...
+ //logger.log(Level.WARNING, "Could not insert plugin logger - one was already found: {}", LogManager.getLogManager().getLogger(this.getName()));
+ logger = LogManager.getLogManager().getLogger(description.getPrefix() != null ? description.getPrefix() : description.getName());
+ }
+
+ return logger;
+ }
+
+ private PaperPluginLogger(@NotNull PluginDescriptionFile description) {
+ super(description.getPrefix() != null ? description.getPrefix() : description.getName(), null);
+ }
+
+ @Override
+ public void setParent(@NotNull Logger parent) {
+ if (getParent() != null) {
+ warning("Ignoring attempt to change parent of plugin logger");
+ } else {
+ this.log(Level.FINE, "Setting plugin logger parent to {0}", parent);
+ super.setParent(parent);
+ }
+ }
+
+}
diff --git a/src/main/java/org/bukkit/plugin/java/JavaPlugin.java b/src/main/java/org/bukkit/plugin/java/JavaPlugin.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/org/bukkit/plugin/java/JavaPlugin.java
+++ b/src/main/java/org/bukkit/plugin/java/JavaPlugin.java
@@ -0,0 +0,0 @@ public abstract class JavaPlugin extends PluginBase {
private boolean naggable = true;
private FileConfiguration newConfig = null;
private File configFile = null;
- private Logger logger = null; // Paper - PluginLogger -> Logger
+ Logger logger = null; // Paper - PluginLogger -> Logger, package-private
public JavaPlugin() {
final ClassLoader classLoader = this.getClass().getClassLoader();
@@ -0,0 +0,0 @@ public abstract class JavaPlugin extends PluginBase {
this.dataFolder = dataFolder;
this.classLoader = classLoader;
this.configFile = new File(dataFolder, "config.yml");
- // Paper - Handle plugin prefix in implementation
- this.logger = Logger.getLogger(description.getPrefix() != null ? description.getPrefix() : description.getName());
+ // Paper start
+ if (this.logger == null) {
+ this.logger = com.destroystokyo.paper.utils.PaperPluginLogger.getLogger(this.description);
+ }
+ // Paper end
}
/**
diff --git a/src/main/java/org/bukkit/plugin/java/PluginClassLoader.java b/src/main/java/org/bukkit/plugin/java/PluginClassLoader.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/org/bukkit/plugin/java/PluginClassLoader.java
+++ b/src/main/java/org/bukkit/plugin/java/PluginClassLoader.java
@@ -0,0 +0,0 @@ public final class PluginClassLoader extends URLClassLoader { // Spigot
private JavaPlugin pluginInit;
private IllegalStateException pluginState;
private final Set<String> seenIllegalAccess = Collections.newSetFromMap(new ConcurrentHashMap<>());
+ private java.util.logging.Logger logger; // Paper - add field
static {
ClassLoader.registerAsParallelCapable();
@@ -0,0 +0,0 @@ public final class PluginClassLoader extends URLClassLoader { // Spigot
this.url = file.toURI().toURL();
this.libraryLoader = libraryLoader;
+ this.logger = com.destroystokyo.paper.utils.PaperPluginLogger.getLogger(description); // Paper - Register logger early
+
try {
Class<?> jarClass;
try {
@@ -0,0 +0,0 @@ public final class PluginClassLoader extends URLClassLoader { // Spigot
pluginState = new IllegalStateException("Initial initialization");
this.pluginInit = javaPlugin;
+ javaPlugin.logger = this.logger; // Paper - set logger
javaPlugin.init(loader, loader.server, description, dataFolder, file, this);
}
}
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Minecrell <minecrell@minecrell.net>
Date: Thu, 21 Sep 2017 19:41:20 +0200
Subject: [PATCH] Add workaround for plugins modifying the parent of the plugin
logger
Essentials uses a custom logger name ("Essentials") instead of the
plugin logger. Log messages are redirected to the plugin logger by
setting the parent of the "Essentials" logger to the plugin logger.
With our changes, the plugin logger is now also called "Essentials",
resulting in an infinite loop. Make sure plugins can't change the
parent of the plugin logger to avoid this.
diff --git a/src/main/java/com/destroystokyo/paper/utils/PaperPluginLogger.java b/src/main/java/com/destroystokyo/paper/utils/PaperPluginLogger.java
new file mode 100644
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000
--- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/utils/PaperPluginLogger.java
@@ -0,0 +0,0 @@
+package com.destroystokyo.paper.utils;
+
+import org.bukkit.plugin.PluginDescriptionFile;
+
+import java.util.logging.Level;
+import java.util.logging.LogManager;
+import java.util.logging.Logger;
+import org.jetbrains.annotations.NotNull;
+
+/**
+ * Prevents plugins (e.g. Essentials) from changing the parent of the plugin logger.
+ */
+public class PaperPluginLogger extends Logger {
+
+ @NotNull
+ public static Logger getLogger(@NotNull PluginDescriptionFile description) {
+ Logger logger = new PaperPluginLogger(description);
+ if (!LogManager.getLogManager().addLogger(logger)) {
+ // Disable this if it's going to happen across reloads anyways...
+ //logger.log(Level.WARNING, "Could not insert plugin logger - one was already found: {}", LogManager.getLogManager().getLogger(this.getName()));
+ logger = LogManager.getLogManager().getLogger(description.getPrefix() != null ? description.getPrefix() : description.getName());
+ }
+
+ return logger;
+ }
+
+ private PaperPluginLogger(@NotNull PluginDescriptionFile description) {
+ super(description.getPrefix() != null ? description.getPrefix() : description.getName(), null);
+ }
+
+ @Override
+ public void setParent(@NotNull Logger parent) {
+ if (getParent() != null) {
+ warning("Ignoring attempt to change parent of plugin logger");
+ } else {
+ this.log(Level.FINE, "Setting plugin logger parent to {0}", parent);
+ super.setParent(parent);
+ }
+ }
+
+}
diff --git a/src/main/java/org/bukkit/plugin/java/JavaPlugin.java b/src/main/java/org/bukkit/plugin/java/JavaPlugin.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/org/bukkit/plugin/java/JavaPlugin.java
+++ b/src/main/java/org/bukkit/plugin/java/JavaPlugin.java
@@ -0,0 +0,0 @@ public abstract class JavaPlugin extends PluginBase {
private boolean naggable = true;
private FileConfiguration newConfig = null;
private File configFile = null;
- private Logger logger = null; // Paper - PluginLogger -> Logger
+ Logger logger = null; // Paper - PluginLogger -> Logger, package-private
public JavaPlugin() {
final ClassLoader classLoader = this.getClass().getClassLoader();
@@ -0,0 +0,0 @@ public abstract class JavaPlugin extends PluginBase {
this.dataFolder = dataFolder;
this.classLoader = classLoader;
this.configFile = new File(dataFolder, "config.yml");
- // Paper - Handle plugin prefix in implementation
- this.logger = Logger.getLogger(description.getPrefix() != null ? description.getPrefix() : description.getName());
+ // Paper start
+ if (this.logger == null) {
+ this.logger = com.destroystokyo.paper.utils.PaperPluginLogger.getLogger(this.description);
+ }
+ // Paper end
}
/**
diff --git a/src/main/java/org/bukkit/plugin/java/PluginClassLoader.java b/src/main/java/org/bukkit/plugin/java/PluginClassLoader.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/org/bukkit/plugin/java/PluginClassLoader.java
+++ b/src/main/java/org/bukkit/plugin/java/PluginClassLoader.java
@@ -0,0 +0,0 @@ public final class PluginClassLoader extends URLClassLoader { // Spigot
private JavaPlugin pluginInit;
private IllegalStateException pluginState;
private final Set<String> seenIllegalAccess = Collections.newSetFromMap(new ConcurrentHashMap<>());
+ private java.util.logging.Logger logger; // Paper - add field
static {
ClassLoader.registerAsParallelCapable();
@@ -0,0 +0,0 @@ public final class PluginClassLoader extends URLClassLoader { // Spigot
this.url = file.toURI().toURL();
this.libraryLoader = libraryLoader;
+ this.logger = com.destroystokyo.paper.utils.PaperPluginLogger.getLogger(description); // Paper - Register logger early
+
try {
Class<?> jarClass;
try {
@@ -0,0 +0,0 @@ public final class PluginClassLoader extends URLClassLoader { // Spigot
pluginState = new IllegalStateException("Initial initialization");
this.pluginInit = javaPlugin;
+ javaPlugin.logger = this.logger; // Paper - set logger
javaPlugin.init(loader, loader.server, description, dataFolder, file, this);
}
}

View file

@ -14,7 +14,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
@@ -0,0 +0,0 @@ public interface ItemFactory {
*/
@NotNull
ItemStack ensureServerConversions(@NotNull ItemStack item);
net.kyori.adventure.text.Component displayName(@NotNull ItemStack itemStack);
+
+ /**
+ * Gets the Display name as seen in the Client.
@ -33,8 +33,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
--- a/src/main/java/org/bukkit/inventory/ItemStack.java
+++ b/src/main/java/org/bukkit/inventory/ItemStack.java
@@ -0,0 +0,0 @@ public class ItemStack implements Cloneable, ConfigurationSerializable, net.kyor
public ItemStack ensureServerConversions() {
return Bukkit.getServer().getItemFactory().ensureServerConversions(this);
public @NotNull net.kyori.adventure.text.Component displayName() {
return Bukkit.getServer().getItemFactory().displayName(this);
}
+
+ /**

View file

@ -0,0 +1,117 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Minecrell <minecrell@minecrell.net>
Date: Thu, 21 Sep 2017 19:41:20 +0200
Subject: [PATCH] Add workaround for plugins modifying the parent of the plugin
logger
Essentials uses a custom logger name ("Essentials") instead of the
plugin logger. Log messages are redirected to the plugin logger by
setting the parent of the "Essentials" logger to the plugin logger.
With our changes, the plugin logger is now also called "Essentials",
resulting in an infinite loop. Make sure plugins can't change the
parent of the plugin logger to avoid this.
diff --git a/src/main/java/com/destroystokyo/paper/utils/PaperPluginLogger.java b/src/main/java/com/destroystokyo/paper/utils/PaperPluginLogger.java
new file mode 100644
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000
--- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/utils/PaperPluginLogger.java
@@ -0,0 +0,0 @@
+package com.destroystokyo.paper.utils;
+
+import org.bukkit.plugin.PluginDescriptionFile;
+
+import java.util.logging.Level;
+import java.util.logging.LogManager;
+import java.util.logging.Logger;
+import org.jetbrains.annotations.NotNull;
+
+/**
+ * Prevents plugins (e.g. Essentials) from changing the parent of the plugin logger.
+ */
+public class PaperPluginLogger extends Logger {
+
+ @NotNull
+ public static Logger getLogger(@NotNull PluginDescriptionFile description) {
+ Logger logger = new PaperPluginLogger(description);
+ if (!LogManager.getLogManager().addLogger(logger)) {
+ // Disable this if it's going to happen across reloads anyways...
+ //logger.log(Level.WARNING, "Could not insert plugin logger - one was already found: {}", LogManager.getLogManager().getLogger(this.getName()));
+ logger = LogManager.getLogManager().getLogger(description.getPrefix() != null ? description.getPrefix() : description.getName());
+ }
+
+ return logger;
+ }
+
+ private PaperPluginLogger(@NotNull PluginDescriptionFile description) {
+ super(description.getPrefix() != null ? description.getPrefix() : description.getName(), null);
+ }
+
+ @Override
+ public void setParent(@NotNull Logger parent) {
+ if (getParent() != null) {
+ warning("Ignoring attempt to change parent of plugin logger");
+ } else {
+ this.log(Level.FINE, "Setting plugin logger parent to {0}", parent);
+ super.setParent(parent);
+ }
+ }
+
+}
diff --git a/src/main/java/org/bukkit/plugin/java/JavaPlugin.java b/src/main/java/org/bukkit/plugin/java/JavaPlugin.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/org/bukkit/plugin/java/JavaPlugin.java
+++ b/src/main/java/org/bukkit/plugin/java/JavaPlugin.java
@@ -0,0 +0,0 @@ public abstract class JavaPlugin extends PluginBase {
private boolean naggable = true;
private FileConfiguration newConfig = null;
private File configFile = null;
- private Logger logger = null; // Paper - PluginLogger -> Logger
+ Logger logger = null; // Paper - PluginLogger -> Logger, package-private
public JavaPlugin() {
final ClassLoader classLoader = this.getClass().getClassLoader();
@@ -0,0 +0,0 @@ public abstract class JavaPlugin extends PluginBase {
this.dataFolder = dataFolder;
this.classLoader = classLoader;
this.configFile = new File(dataFolder, "config.yml");
- // Paper - Handle plugin prefix in implementation
- this.logger = Logger.getLogger(description.getPrefix() != null ? description.getPrefix() : description.getName());
+ // Paper start
+ if (this.logger == null) {
+ this.logger = com.destroystokyo.paper.utils.PaperPluginLogger.getLogger(this.description);
+ }
+ // Paper end
}
/**
diff --git a/src/main/java/org/bukkit/plugin/java/PluginClassLoader.java b/src/main/java/org/bukkit/plugin/java/PluginClassLoader.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/org/bukkit/plugin/java/PluginClassLoader.java
+++ b/src/main/java/org/bukkit/plugin/java/PluginClassLoader.java
@@ -0,0 +0,0 @@ public final class PluginClassLoader extends URLClassLoader { // Spigot
private JavaPlugin pluginInit;
private IllegalStateException pluginState;
private final Set<String> seenIllegalAccess = Collections.newSetFromMap(new ConcurrentHashMap<>());
+ private java.util.logging.Logger logger; // Paper - add field
static {
ClassLoader.registerAsParallelCapable();
@@ -0,0 +0,0 @@ public final class PluginClassLoader extends URLClassLoader { // Spigot
this.url = file.toURI().toURL();
this.libraryLoader = libraryLoader;
+ this.logger = com.destroystokyo.paper.utils.PaperPluginLogger.getLogger(description); // Paper - Register logger early
+
try {
Class<?> jarClass;
try {
@@ -0,0 +0,0 @@ public final class PluginClassLoader extends URLClassLoader { // Spigot
pluginState = new IllegalStateException("Initial initialization");
this.pluginInit = javaPlugin;
+ javaPlugin.logger = this.logger; // Paper - set logger
javaPlugin.init(loader, loader.server, description, dataFolder, file, this);
}
}

View file

@ -13,24 +13,18 @@ Expose SLF4J as optional logging API for plugins, so they can use
it without having to shade it in the plugin and going through
several layers of logging abstraction.
diff --git a/pom.xml b/pom.xml
diff --git a/build.gradle.kts b/build.gradle.kts
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/pom.xml
+++ b/pom.xml
@@ -0,0 +0,0 @@
<version>21.0.1</version>
<scope>provided</scope>
</dependency>
+ <!-- Paper - Add SLF4J -->
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ <version>1.7.25</version>
+ <scope>compile</scope>
+ </dependency>
<!-- testing -->
<dependency>
<groupId>junit</groupId>
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -0,0 +0,0 @@ dependencies {
api("net.kyori:adventure-text-serializer-plain")
api("org.ow2.asm:asm:9.0")
api("org.ow2.asm:asm-commons:9.0")
+ api("org.apache.logging.log4j:log4j-api:2.14.1") // Paper
compileOnly("org.apache.maven:maven-resolver-provider:3.8.1")
compileOnly("org.apache.maven.resolver:maven-resolver-connector-basic:1.7.0")
diff --git a/src/main/java/org/bukkit/plugin/Plugin.java b/src/main/java/org/bukkit/plugin/Plugin.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/org/bukkit/plugin/Plugin.java

View file

@ -15,11 +15,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ private boolean flyAtPlayer = true; // Paper
private boolean cancel = false;
private final int remaining;
@@ -0,0 +0,0 @@ public class PlayerPickupItemEvent extends PlayerEvent implements Cancellable {
return remaining;
}
+ // Paper Start
+ /**
+ * Set if the item will fly at the player
@ -50,5 +50,5 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
this.cancel = cancel;
+ this.flyAtPlayer = !cancel; // Paper
}
@NotNull

View file

@ -12,8 +12,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+++ b/src/main/java/org/bukkit/inventory/ItemFactory.java
@@ -0,0 +0,0 @@ public interface ItemFactory {
*/
@NotNull
net.kyori.adventure.text.Component displayName(@NotNull ItemStack itemStack);
@Nullable
String getI18NDisplayName(@Nullable ItemStack item);
+
+ /**
+ * Minecraft updates are converting simple item stacks into more complex NBT oriented Item Stacks.
@ -42,10 +42,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
/**
@@ -0,0 +0,0 @@ public class ItemStack implements Cloneable, ConfigurationSerializable, net.kyor
public @NotNull net.kyori.adventure.text.Component displayName() {
return Bukkit.getServer().getItemFactory().displayName(this);
}
+
+ /**
+ * Minecraft updates are converting simple item stacks into more complex NBT oriented Item Stacks.
+ *
@ -58,5 +57,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ public ItemStack ensureServerConversions() {
+ return Bukkit.getServer().getItemFactory().ensureServerConversions(this);
+ }
// Paper end
}
+
/**
* Gets the Display name as seen in the Client.
* Currently the server only supports the English language. To override this,

View file

@ -1,23 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: mezz <tehgeek@gmail.com>
Date: Wed, 9 Aug 2017 17:51:22 -0500
Subject: [PATCH] Fix MC-117075: TE Unload Lag Spike
diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/world/level/Level.java
+++ b/src/main/java/net/minecraft/world/level/Level.java
@@ -0,0 +0,0 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
gameprofilerfiller.push("blockEntities");
timings.tileEntityTick.startTiming(); // Spigot
if (!this.tileEntityListUnload.isEmpty()) {
- this.tickableBlockEntities.removeAll(this.tileEntityListUnload);
+ // Paper start - Use alternate implementation with faster contains
+ java.util.Set<BlockEntity> toRemove = java.util.Collections.newSetFromMap(new java.util.IdentityHashMap<>());
+ toRemove.addAll(tileEntityListUnload);
+ this.tickableBlockEntities.removeAll(toRemove);
+ // Paper end
//this.tileEntityList.removeAll(this.tileEntityListUnload); // Paper - remove unused list
this.tileEntityListUnload.clear();
}

View file

@ -13,8 +13,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
@@ -0,0 +0,0 @@
+package com.destroystokyo.paper.profile;
+
+import PlayerProfile;
+import ProfileProperty;
+import com.destroystokyo.paper.profile.PlayerProfile;
+import com.destroystokyo.paper.profile.ProfileProperty;
+import com.destroystokyo.paper.PaperConfig;
+import com.google.common.base.Charsets;
+import com.mojang.authlib.GameProfile;
@ -207,7 +207,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ copyProfileProperties(result, this.profile, true);
+ }
+ if (this.profile.isComplete()) {
+ server.getProfileCache().saveProfile(this.profile);
+ server.getProfileCache().add(this.profile);
+ }
+ }
+ return profile.isComplete() && (!onlineMode || !textures || hasTextures());
@ -436,7 +436,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
@@ -0,0 +0,0 @@
package net.minecraft.server;
import com.destroystokyo.paper.block.TargetBlockInfo;
+import com.destroystokyo.paper.profile.CraftPlayerProfile;
+import com.destroystokyo.paper.profile.PlayerProfile;
import com.google.common.util.concurrent.ThreadFactoryBuilder;
@ -478,30 +477,21 @@ diff --git a/src/main/java/net/minecraft/server/players/GameProfileCache.java b/
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/server/players/GameProfileCache.java
+++ b/src/main/java/net/minecraft/server/players/GameProfileCache.java
@@ -0,0 +0,0 @@ public class GameProfileCache {
private static final Logger LOGGER = LogManager.getLogger();
private static boolean usesAuthentication;
- private final Map<String, GameProfileCache.GameProfileInfo> profilesByName = Maps.newConcurrentMap();
+ private final Map<String, GameProfileCache.GameProfileInfo> profilesByName = Maps.newConcurrentMap();private final Map<String, GameProfileCache.GameProfileInfo> nameCache = profilesByName; // Paper - OBFHELPER // Paper
private final Map<UUID, GameProfileCache.GameProfileInfo> profilesByUUID = Maps.newConcurrentMap();
private final GameProfileRepository profileRepository;
private final Gson gson = (new GsonBuilder()).create();
@@ -0,0 +0,0 @@ public class GameProfileCache {
return com.destroystokyo.paper.PaperConfig.isProxyOnlineMode(); // Paper
}
+ public void saveProfile(GameProfile gameprofile) { add(gameprofile); } // Paper - OBFHELPER
public synchronized void add(GameProfile gameprofile) { // Paper - synchronize
+ @Deprecated public void saveProfile(GameProfile gameprofile) { add(gameprofile); } // Paper - OBFHELPER
public synchronized void add(GameProfile profile) { // Paper - synchronize
Calendar calendar = Calendar.getInstance();
@@ -0,0 +0,0 @@ public class GameProfileCache {
return gameprofile;
}
}
+ // Paper start
+ @Nullable public GameProfile getProfileIfCached(String name) {
+ GameProfileCache.GameProfileInfo entry = this.nameCache.get(name.toLowerCase(Locale.ROOT));
+ GameProfileCache.GameProfileInfo entry = this.profilesByName.get(name.toLowerCase(Locale.ROOT));
+ return entry == null ? null : entry.getProfile();
+ }
+ // Paper end
@ -509,15 +499,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
@Nullable
public GameProfile get(UUID uuid) {
GameProfileCache.GameProfileInfo usercache_usercacheentry = (GameProfileCache.GameProfileInfo) this.profilesByUUID.get(uuid);
@@ -0,0 +0,0 @@ public class GameProfileCache {
static class GameProfileInfo {
- private final GameProfile profile;
+ private final GameProfile profile;public GameProfile getProfile() { return profile; } // Paper - OBFHELPER
private final Date expirationDate;
private volatile long lastAccess;
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java

View file

@ -8,7 +8,7 @@ diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/jav
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
@@ -0,0 +0,0 @@ public abstract class Entity implements Nameable, CommandSource, net.minecraft.s
@@ -0,0 +0,0 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, n
public final org.spigotmc.ActivationRange.ActivationType activationType = org.spigotmc.ActivationRange.initializeEntityActivationType(this);
public final boolean defaultActivationState;
public long activatedTick = Integer.MIN_VALUE;
@ -16,23 +16,23 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
protected int numCollisions = 0; // Paper
public void inactiveTick() { }
// Spigot end
@@ -0,0 +0,0 @@ public abstract class Entity implements Nameable, CommandSource, net.minecraft.s
tag.setUUID("Paper.OriginWorld", origin.getWorld().getUID());
tag.put("Paper.Origin", this.createList(origin.getX(), origin.getY(), origin.getZ()));
@@ -0,0 +0,0 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, n
nbt.setUUID("Paper.OriginWorld", origin.getWorld().getUID());
nbt.put("Paper.Origin", this.newDoubleList(origin.getX(), origin.getY(), origin.getZ()));
}
+ // Save entity's from mob spawner status
+ if (spawnedViaMobSpawner) {
+ tag.putBoolean("Paper.FromMobSpawner", true);
+ nbt.putBoolean("Paper.FromMobSpawner", true);
+ }
// Paper end
return tag;
return nbt;
} catch (Throwable throwable) {
@@ -0,0 +0,0 @@ public abstract class Entity implements Nameable, CommandSource, net.minecraft.s
@@ -0,0 +0,0 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, n
}
origin = new org.bukkit.Location(originWorld, originTag.getDoubleAt(0), originTag.getDoubleAt(1), originTag.getDoubleAt(2));
}
+
+ spawnedViaMobSpawner = tag.getBoolean("Paper.FromMobSpawner"); // Restore entity's from mob spawner status
+ spawnedViaMobSpawner = nbt.getBoolean("Paper.FromMobSpawner"); // Restore entity's from mob spawner status
// Paper end
} catch (Throwable throwable) {
@ -41,13 +41,13 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
--- a/src/main/java/net/minecraft/world/level/BaseSpawner.java
+++ b/src/main/java/net/minecraft/world/level/BaseSpawner.java
@@ -0,0 +0,0 @@ public abstract class BaseSpawner {
}
// Spigot End
if (this.nextSpawnData.getTag().size() == 1 && this.nextSpawnData.getTag().contains("id", 8)) {
((Mob) entity).finalizeSpawn(world, world.getCurrentDifficultyAt(entity.blockPosition()), MobSpawnType.SPAWNER, (SpawnGroupData) null, (CompoundTag) null);
}
+ entity.spawnedViaMobSpawner = true; // Paper
+ entity.spawnedViaMobSpawner = true; // Paper
// Spigot Start
if (org.bukkit.craftbukkit.event.CraftEventFactory.callSpawnerSpawnEvent(entity, blockposition).isCancelled()) {
Entity vehicle = entity.getVehicle();
if (entityinsentient.level.spigotConfig.nerfSpawnerMobs) {
entityinsentient.aware = false;
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java

View file

@ -14,7 +14,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+++ b/src/main/java/org/bukkit/craftbukkit/Main.java
@@ -0,0 +0,0 @@ public class Main {
Calendar deadline = Calendar.getInstance();
deadline.add(Calendar.DAY_OF_YEAR, -28);
deadline.add(Calendar.DAY_OF_YEAR, -3);
if (buildDate.before(deadline.getTime())) {
- System.err.println("*** Error, this build is outdated ***");
+ // Paper start - This is some stupid bullshit

View file

@ -12,24 +12,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
--- a/src/main/java/net/minecraft/locale/Language.java
+++ b/src/main/java/net/minecraft/locale/Language.java
@@ -0,0 +0,0 @@ public abstract class Language {
private static Language loadDefault() {
Builder<String, String> builder = ImmutableMap.builder();
- BiConsumer biconsumer = builder::put;
+ BiConsumer<String, String> biconsumer = builder::put; // Paper - decompile fix
try {
InputStream inputstream = Language.class.getResourceAsStream("/assets/minecraft/lang/en_us.json");
@@ -0,0 +0,0 @@ public abstract class Language {
instance = language;
}
+ public static Language getInstance() { return getInstance(); } // Paper - OBFHELPER
public static Language getInstance() {
return Language.instance;
}
+ public String translateKey(String key) { return getOrDefault(key); } // Paper - OBFHELPER
+ @Deprecated public String translateKey(String key) { return getOrDefault(key); } // Paper - OBFHELPER
public abstract String getOrDefault(String key);
public abstract boolean has(String key);
@ -52,7 +38,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ nms = CraftItemStack.asNMSCopy(item);
+ }
+
+ return nms != null ? net.minecraft.locale.Language.getInstance().translateKey(nms.getItem().getDescriptionId()) : null;
+ return nms != null ? net.minecraft.locale.Language.getInstance().getOrDefault(nms.getItem().getDescriptionId()) : null;
+ }
// Paper end
}

View file

@ -22,7 +22,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
@Override
public AbstractHorseInventory getInventory() {
- return new CraftInventoryAbstractHorse(getHandle().inventory);
- return new CraftInventoryAbstractHorse(this.getHandle().inventory);
+ return new CraftSaddledInventory(getHandle().inventory);
}
}

View file

@ -30,7 +30,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
import net.minecraft.world.damagesource.DamageSource;
import net.minecraft.world.effect.MobEffect;
@@ -0,0 +0,0 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
return getHandle().lastHurtByPlayer == null ? null : (Player) getHandle().lastHurtByPlayer.getBukkitEntity();
return this.getHandle().lastHurtByPlayer == null ? null : (Player) this.getHandle().lastHurtByPlayer.getBukkitEntity();
}
+ // Paper start
@ -45,4 +45,4 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+
@Override
public boolean addPotionEffect(PotionEffect effect) {
return addPotionEffect(effect, false);
return this.addPotionEffect(effect, false);

View file

@ -18,7 +18,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ } else if (!this.isWhitelisted(gameprofile, event)) { // Paper
+ //chatmessage = new ChatMessage("multiplayer.disconnect.not_whitelisted"); // Paper
+ //event.disallow(PlayerLoginEvent.Result.KICK_WHITELIST, org.spigotmc.SpigotConfig.whitelistMessage); // Spigot // Paper - moved to isWhitelisted
} else if (getIpBans().isBanned(socketaddress) && !getIpBans().get(socketaddress).hasExpired()) {
} else if (this.getIpBans().isBanned(socketaddress) && !this.getIpBans().get(socketaddress).hasExpired()) {
IpBanListEntry ipbanentry = this.ipBans.get(socketaddress);
@@ -0,0 +0,0 @@ public abstract class PlayerList {
@ -34,7 +34,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ boolean isOp = this.ops.contains(gameprofile);
+ boolean isWhitelisted = !this.doWhiteList || isOp || this.whitelist.contains(gameprofile);
+ final com.destroystokyo.paper.event.profile.ProfileWhitelistVerifyEvent event;
+ event = new com.destroystokyo.paper.event.profile.ProfileWhitelistVerifyEvent(MCUtil.toBukkit(gameprofile), this.doWhiteList, isWhitelisted, isOp, org.spigotmc.SpigotConfig.whitelistMessage);
+ event = new com.destroystokyo.paper.event.profile.ProfileWhitelistVerifyEvent(net.minecraft.server.MCUtil.toBukkit(gameprofile), this.doWhiteList, isWhitelisted, isOp, org.spigotmc.SpigotConfig.whitelistMessage);
+ event.callEvent();
+ if (!event.isWhitelisted()) {
+ if (loginEvent != null) {

View file

@ -9,19 +9,19 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
--- a/src/main/java/net/minecraft/world/level/BaseSpawner.java
+++ b/src/main/java/net/minecraft/world/level/BaseSpawner.java
@@ -0,0 +0,0 @@ public abstract class BaseSpawner {
// Spigot End
}
entity.spawnedViaMobSpawner = true; // Paper
+ flag = true; // Paper
// Spigot Start
if (org.bukkit.craftbukkit.event.CraftEventFactory.callSpawnerSpawnEvent(entity, blockposition).isCancelled()) {
Entity vehicle = entity.getVehicle();
@@ -0,0 +0,0 @@ public abstract class BaseSpawner {
((Mob) entity).spawnAnim();
}
- flag = true;
+ /*flag = true;*/ // Paper - moved up above cancellable event
// Spigot End
}
+ flag = true; // Paper
// Spigot Start
if (org.bukkit.craftbukkit.event.CraftEventFactory.callSpawnerSpawnEvent(entity, pos).isCancelled()) {
Entity vehicle = entity.getVehicle();
@@ -0,0 +0,0 @@ public abstract class BaseSpawner {
((Mob) entity).spawnAnim();
}
- flag = true;
+ //flag = true; // Paper - moved up above cancellable event
}
}

View file

@ -62,7 +62,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java
@@ -0,0 +0,0 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity {
getHandle().getCooldowns().addCooldown(CraftMagicNumbers.getItem(material), ticks);
this.getHandle().getCooldowns().addCooldown(CraftMagicNumbers.getItem(material), ticks);
}
+ // Paper start
@ -93,4 +93,4 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+
@Override
public boolean discoverRecipe(NamespacedKey recipe) {
return discoverRecipes(Arrays.asList(recipe)) != 0;
return this.discoverRecipes(Arrays.asList(recipe)) != 0;