From 5fa64c267e9e1e9aae5e0b48368a04aad4c61f92 Mon Sep 17 00:00:00 2001 From: Alfie Cleveland Date: Mon, 9 Jul 2018 13:37:07 -0500 Subject: [PATCH] PotionEffect updates diff --git a/dependency-reduced-pom.xml b/dependency-reduced-pom.xml new file mode 100644 index 00000000..ccd5f2b4 --- /dev/null +++ b/dependency-reduced-pom.xml @@ -0,0 +1,256 @@ + + + + spigot-parent + net.hylist + dev-SNAPSHOT + + 4.0.0 + net.hylist + spigot-server + mSpigot + 1.7.10-R0.1-SNAPSHOT + https://hylist.net + + clean install + + + + org.eclipse.m2e + lifecycle-mapping + 1.0.0 + + + + + + com.lukegb.mojo + gitdescribe-maven-plugin + [1.3,) + + gitdescribe + + + + + + + + + + + + + + + net.md-5 + scriptus + 0.2 + + + ex-mspigot + initialize + + describe + + + git-mSpigot-%s + ../ + mspigot.desc + + + + + + maven-jar-plugin + 2.1 + + + + org.bukkit.craftbukkit.Main + CraftBukkit + ${mspigot.desc} + Bukkit Team + Bukkit + ${api.version} + Bukkit Team + true + ${maven.build.timestamp} + + + + net/bukkit/ + + true + + + + com/bukkit/ + + true + + + + org/bukkit/ + + true + + + + + + + + maven-shade-plugin + 2.1 + + + package + + shade + + + + + org.bouncycastle + net.minecraft.v${minecraft_version}.org.bouncycastle + + + joptsimple + org.bukkit.craftbukkit.libs.joptsimple + + + jline + org.bukkit.craftbukkit.libs.jline + + + org.ibex + org.bukkit.craftbukkit.libs.org.ibex + + + org.gjt + org.bukkit.craftbukkit.libs.org.gjt + + + com.google.gson + org.bukkit.craftbukkit.libs.com.google.gson + + + io.netty + net.minecraft.util.io.netty + + + org.bukkit.craftbukkit + org.bukkit.craftbukkit.v${minecraft_version} + + org.bukkit.craftbukkit.Main* + + + + net.minecraft.server + net.minecraft.server.v${minecraft_version} + + + + + org.bukkit:minecraft-server + + net/minecraft/util/io/netty/** + + + + + + + + + maven-compiler-plugin + 3.1 + + + org.codehaus.plexus + plexus-compiler-eclipse + 2.5.0-spigotmc + + + + 1.8 + 1.8 + eclipse + true + + + + maven-surefire-plugin + 2.11 + + ${basedir}/target/test-server + + org/bukkit/craftbukkit/updater/BukkitDLUpdaterServiceTest.java + org/bukkit/craftbukkit/inventory/ItemStack*Test.java + + + + + net.md-5 + specialsource-maven-plugin + 1.2.1 + + + package + + remap + + + ${project.basedir}/deprecation-mappings.csrg + ${project.basedir}/deprecation-mappings.at + + + + + + + + + spigotmc-public + https://hub.spigotmc.org/nexus/content/groups/public/ + + + + + junit + junit + 4.11 + test + + + hamcrest-core + org.hamcrest + + + + + org.hamcrest + hamcrest-library + 1.3 + test + + + hamcrest-core + org.hamcrest + + + + + + 1.7.10 + 4.11 + ${project.name}-${project.version} + 1_7_R4 + 1.8 + UTF-8 + git-Bukkit- + 1.8 + + + diff --git a/src/main/java/net/minecraft/server/EntityLiving.java b/src/main/java/net/minecraft/server/EntityLiving.java index a52b2c60..a642090a 100644 --- a/src/main/java/net/minecraft/server/EntityLiving.java +++ b/src/main/java/net/minecraft/server/EntityLiving.java @@ -1,14 +1,6 @@ package net.minecraft.server; -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.Random; -import java.util.UUID; - +import com.google.common.collect.Sets; import org.bukkit.Bukkit; import org.bukkit.craftbukkit.SpigotTimings; import org.bukkit.craftbukkit.event.CraftEventFactory; @@ -27,8 +19,10 @@ import org.spigotmc.SpigotConfig; import com.google.common.base.Function; +import java.util.*; + // CraftBukkit start -// CraftBukkit end +// CraftBukkit endß public abstract class EntityLiving extends Entity { @@ -36,7 +30,7 @@ public abstract class EntityLiving extends Entity { public static final AttributeModifier c = (new AttributeModifier(b, "Sprinting speed boost", 0.30000001192092896D, 2)).a(false); // Guardian: private -> public private AttributeMapBase d; public CombatTracker combatTracker = new CombatTracker(this); // CraftBukkit - private -> public, remove final - public final HashMap effects = new HashMap(); // CraftBukkit - protected -> public + private final Map effects = new HashMap<>(); private final ItemStack[] g = new ItemStack[5]; public boolean at; public int au; @@ -462,32 +456,28 @@ public abstract class EntityLiving extends Entity { } protected void aO() { - Iterator iterator = this.effects.keySet().iterator(); - + Iterator> iterator = Sets.newHashSet(this.effects.entrySet()).iterator(); while (iterator.hasNext()) { - Integer integer = (Integer) iterator.next(); - MobEffect mobeffect = (MobEffect) this.effects.get(integer); + Map.Entry next = iterator.next(); + MobEffect mobeffect = next.getValue(); if (!mobeffect.tick(this)) { if (!this.world.isStatic) { PotionEffectExpireEvent event = new PotionEffectExpireEvent((LivingEntity) this.getBukkitEntity(), CraftPotionUtils.toBukkit(mobeffect)); - this.world.getServer().getPluginManager().callEvent(event); - if (event.isCancelled()) { CraftPotionUtils.extendDuration(mobeffect, event.getDuration()); continue; } - - iterator.remove(); + + this.effects.remove(next.getKey()); this.b(mobeffect); } } else if (mobeffect.getDuration() % 600 == 0) { this.a(mobeffect, false); } } - int i; if (this.updateEffects) { @@ -534,13 +524,14 @@ public abstract class EntityLiving extends Entity { } public void removeAllEffects() { - Iterator iterator = new HashSet<>(this.effects.keySet()).iterator(); - + Set> set = this.effects.entrySet(); + Iterator> iterator = new HashSet<>(set).iterator(); while (iterator.hasNext()) { - Integer integer = (Integer) iterator.next(); + Map.Entry next = iterator.next(); + int integer = next.getKey(); if (!this.world.isStatic) { - removeEffect(integer); + this.removeEffect(integer); } } } @@ -566,30 +557,30 @@ public abstract class EntityLiving extends Entity { public void addEffect(MobEffect mobeffect) { this.addEffect(mobeffect, PotionEffectAddEvent.EffectCause.UNKNOWN); } - + public void addEffect(MobEffect mobeffect, PotionEffectAddEvent.EffectCause effectCause) { if (this.d(mobeffect)) { - if (this.effects.containsKey(Integer.valueOf(mobeffect.getEffectId()))) { - MobEffect current = (MobEffect) this.effects.get(mobeffect.getEffectId()); + if (this.effects.containsKey(mobeffect.getEffectId())) { + MobEffect current = this.effects.get(mobeffect.getEffectId()); + PotionEffectExtendEvent event = new PotionEffectExtendEvent((LivingEntity) this.getBukkitEntity(), CraftPotionUtils.toBukkit(mobeffect), CraftPotionUtils.toBukkit(current), effectCause); - this.world.getServer().getPluginManager().callEvent(event); if (event.isCancelled()) return; - + current.a(mobeffect); this.a(current, true); } else { PotionEffectAddEvent event = new PotionEffectAddEvent((LivingEntity) this.getBukkitEntity(), CraftPotionUtils.toBukkit(mobeffect), effectCause); - this.world.getServer().getPluginManager().callEvent(event); if (event.isCancelled()) return; - this.effects.put(Integer.valueOf(mobeffect.getEffectId()), mobeffect); + this.effects.put(mobeffect.getEffectId(), mobeffect); this.a(mobeffect); } } + } public boolean d(MobEffect mobeffect) { @@ -609,7 +600,7 @@ public abstract class EntityLiving extends Entity { } public void removeEffect(int i) { - MobEffect mobeffect = (MobEffect) this.effects.remove(Integer.valueOf(i)); + MobEffect mobeffect = this.effects.remove(i); if (mobeffect != null) { PotionEffectRemoveEvent event = new PotionEffectRemoveEvent((LivingEntity) this.getBukkitEntity(), @@ -619,9 +610,11 @@ public abstract class EntityLiving extends Entity { this.effects.put(i, mobeffect); return; } - + this.b(mobeffect); } + + return; } protected void a(MobEffect mobeffect) { diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java index a09b972c..40ee3088 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java @@ -285,7 +285,7 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity { public Collection getActivePotionEffects() { List effects = new ArrayList(); - for (Object raw : getHandle().effects.values()) { + for (Object raw : getHandle().getEffects()) { if (!(raw instanceof MobEffect)) continue; MobEffect handle = (MobEffect) raw; diff --git a/src/main/java/org/spigotmc/ActivationRange.java b/src/main/java/org/spigotmc/ActivationRange.java index f7ceb4d5..6726a19e 100644 --- a/src/main/java/org/spigotmc/ActivationRange.java +++ b/src/main/java/org/spigotmc/ActivationRange.java @@ -232,7 +232,7 @@ public class ActivationRange { EntityLiving living = (EntityLiving) entity; // Kohi - remove hurtticks check, we will activate entities in their hurt routine - if ( living.attackTicks > 0 || living.effects.size() > 0 ) + if ( living.attackTicks > 0 || living.getEffects().size() > 0 ) { return true; } -- 2.15.2 (Apple Git-101.1)