Fixes jenkins build w/ Async catcher

This commit is contained in:
Sotr
2018-06-11 16:25:30 +08:00
parent ab9aaa6195
commit 2282ca02b7
6 changed files with 48 additions and 43 deletions

View File

@@ -24,7 +24,6 @@
package co.aikar.timings; package co.aikar.timings;
import co.aikar.util.LoadingIntMap; import co.aikar.util.LoadingIntMap;
import io.akarin.api.Akari;
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;

View File

@@ -1,16 +0,0 @@
package io.akarin.server.mixin.core;
import org.spigotmc.AsyncCatcher;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite;
import org.spongepowered.asm.mixin.Shadow;
@Mixin(value = AsyncCatcher.class, remap = false)
public class DesyncCatcher {
@Shadow public static boolean enabled;
@Overwrite
public static void catchOp(String reason) {
;
}
}

View File

@@ -0,0 +1,27 @@
package io.akarin.server.mixin.core;
import org.spigotmc.AsyncCatcher;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite;
import org.spongepowered.asm.mixin.Shadow;
import io.akarin.api.Akari;
import io.akarin.server.core.AkarinGlobalConfig;
import net.minecraft.server.MinecraftServer;
@Mixin(value = AsyncCatcher.class, remap = false)
public class MixinAsyncCatcher {
@Shadow public static boolean enabled;
@Overwrite
public static void catchOp(String reason) {
if (AkarinGlobalConfig.enableAsyncCatcher && enabled && Thread.currentThread() != MinecraftServer.getServer().primaryThread) {
if (AkarinGlobalConfig.throwOnAsyncCaught) {
throw new IllegalStateException("Asynchronous " + reason + "!");
} else {
Akari.logger.warn("Asynchronous " + reason + "!");
Thread.dumpStack();
}
}
}
}

View File

@@ -24,7 +24,6 @@
*/ */
package io.akarin.server.mixin.optimization; package io.akarin.server.mixin.optimization;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite; import org.spongepowered.asm.mixin.Overwrite;
import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.Shadow;
@@ -41,55 +40,51 @@ import net.minecraft.server.ItemStack;
*/ */
@Mixin(value = EnchantmentManager.class, remap = false) @Mixin(value = EnchantmentManager.class, remap = false)
public class WeakEnchantmentManager { public class WeakEnchantmentManager {
@Shadow(aliases = "a") @Final private static EnchantmentManager.EnchantmentModifierProtection protection;
@Shadow(aliases = "c") @Final private static EnchantmentManager.EnchantmentModifierThorns throns;
@Shadow(aliases = "d") @Final private static EnchantmentManager.EnchantmentModifierArthropods arthropods;
@Shadow(aliases = "a") private static void applyEnchantmentModifierArray(EnchantmentManager.EnchantmentModifier modifier, Iterable<ItemStack> iterable) {} @Shadow(aliases = "a") private static void applyEnchantmentModifierArray(EnchantmentManager.EnchantmentModifier modifier, Iterable<ItemStack> iterable) {}
@Shadow(aliases = "a") private static void applyEnchantmentModifier(EnchantmentManager.EnchantmentModifier modifier, ItemStack itemstack) {} @Shadow(aliases = "a") private static void applyEnchantmentModifier(EnchantmentManager.EnchantmentModifier modifier, ItemStack itemstack) {}
@Overwrite @Overwrite
public static int a(Iterable<ItemStack> iterable, DamageSource damageSource) { public static int a(Iterable<ItemStack> iterable, DamageSource damageSource) {
protection.a = 0; // PAIL: damageModifier EnchantmentManager.a.a = 0; // PAIL: damageModifier
protection.b = damageSource; EnchantmentManager.a.b = damageSource;
applyEnchantmentModifierArray(protection, iterable); applyEnchantmentModifierArray(EnchantmentManager.a, iterable);
protection.b = null; // Akarin - Remove reference to Damagesource EnchantmentManager.a.b = null; // Akarin - Remove reference to Damagesource
return protection.a; return EnchantmentManager.a.a;
} }
@Overwrite @Overwrite
public static void a(EntityLiving user, Entity attacker) { // PAIL: applyThornEnchantments public static void a(EntityLiving user, Entity attacker) { // PAIL: applyThornEnchantments
throns.b = attacker; EnchantmentManager.c.b = attacker;
throns.a = user; EnchantmentManager.c.a = user;
if (user != null) { if (user != null) {
applyEnchantmentModifierArray(throns, user.aQ()); // PAIL: getEquipmentAndArmor applyEnchantmentModifierArray(EnchantmentManager.c, user.aQ()); // PAIL: getEquipmentAndArmor
} }
if (attacker instanceof EntityHuman) { if (attacker instanceof EntityHuman) {
applyEnchantmentModifier(throns, user.getItemInMainHand()); applyEnchantmentModifier(EnchantmentManager.c, user.getItemInMainHand());
} }
// Akarin Start - remove references to entity objects to avoid memory leaks // Akarin Start - remove references to entity objects to avoid memory leaks
throns.b = null; EnchantmentManager.c.b = null;
throns.a = null; EnchantmentManager.c.a = null;
// Akarin end // Akarin end
} }
@Overwrite @Overwrite
public static void b(EntityLiving user, Entity target) { // PAIL: applyArthropodEnchantments public static void b(EntityLiving user, Entity target) { // PAIL: applyArthropodEnchantments
arthropods.a = user; EnchantmentManager.d.a = user;
arthropods.b = target; EnchantmentManager.d.b = target;
if (user != null) { if (user != null) {
applyEnchantmentModifierArray(arthropods, user.aQ()); // PAIL: getEquipmentAndArmor applyEnchantmentModifierArray(EnchantmentManager.d, user.aQ()); // PAIL: getEquipmentAndArmor
} }
if (user instanceof EntityHuman) { if (user instanceof EntityHuman) {
applyEnchantmentModifier(arthropods, user.getItemInMainHand()); applyEnchantmentModifier(EnchantmentManager.d, user.getItemInMainHand());
} }
// Akarin Start - remove references to entity objects to avoid memory leaks // Akarin Start - remove references to entity objects to avoid memory leaks
arthropods.a = null; EnchantmentManager.d.a = null;
arthropods.b = null; EnchantmentManager.d.b = null;
// Akarin end // Akarin end
} }
} }

View File

@@ -18,10 +18,10 @@ import java.util.Map.Entry;
*/ */
public class EnchantmentManager { public class EnchantmentManager {
private static final EnchantmentManager.EnchantmentModifierProtection a = new EnchantmentManager.EnchantmentModifierProtection(null); public static final EnchantmentManager.EnchantmentModifierProtection a = new EnchantmentManager.EnchantmentModifierProtection(null); // Akarin - private -> public
private static final EnchantmentManager.EnchantmentModifierDamage b = new EnchantmentManager.EnchantmentModifierDamage(null); private static final EnchantmentManager.EnchantmentModifierDamage b = new EnchantmentManager.EnchantmentModifierDamage(null);
private static final EnchantmentManager.EnchantmentModifierThorns c = new EnchantmentManager.EnchantmentModifierThorns(null); public static final EnchantmentManager.EnchantmentModifierThorns c = new EnchantmentManager.EnchantmentModifierThorns(null); // Akarin - private -> public
private static final EnchantmentManager.EnchantmentModifierArthropods d = new EnchantmentManager.EnchantmentModifierArthropods(null); public static final EnchantmentManager.EnchantmentModifierArthropods d = new EnchantmentManager.EnchantmentModifierArthropods(null); // Akarin - private -> public
public static int getEnchantmentLevel(Enchantment enchantment, ItemStack itemstack) { public static int getEnchantmentLevel(Enchantment enchantment, ItemStack itemstack) {
if (itemstack.isEmpty()) { if (itemstack.isEmpty()) {

View File

@@ -13,8 +13,8 @@
"bootstrap.MetricsBootstrap", "bootstrap.MetricsBootstrap",
"core.MixinMCUtil", "core.MixinMCUtil",
"core.DesyncCatcher",
"core.MixinCraftServer", "core.MixinCraftServer",
"core.MixinAsyncCatcher",
"core.MixinTimingHandler", "core.MixinTimingHandler",
"core.MonsterEggGuardian", "core.MonsterEggGuardian",
"core.MixinVersionCommand", "core.MixinVersionCommand",