456 lines
18 KiB
Diff
456 lines
18 KiB
Diff
|
From 5fa64c267e9e1e9aae5e0b48368a04aad4c61f92 Mon Sep 17 00:00:00 2001
|
||
|
From: Alfie Cleveland <alfeh@me.com>
|
||
|
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 @@
|
||
|
+<?xml version="1.0" encoding="UTF-8"?>
|
||
|
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||
|
+ <parent>
|
||
|
+ <artifactId>spigot-parent</artifactId>
|
||
|
+ <groupId>net.hylist</groupId>
|
||
|
+ <version>dev-SNAPSHOT</version>
|
||
|
+ </parent>
|
||
|
+ <modelVersion>4.0.0</modelVersion>
|
||
|
+ <groupId>net.hylist</groupId>
|
||
|
+ <artifactId>spigot-server</artifactId>
|
||
|
+ <name>mSpigot</name>
|
||
|
+ <version>1.7.10-R0.1-SNAPSHOT</version>
|
||
|
+ <url>https://hylist.net</url>
|
||
|
+ <build>
|
||
|
+ <defaultGoal>clean install</defaultGoal>
|
||
|
+ <pluginManagement>
|
||
|
+ <plugins>
|
||
|
+ <plugin>
|
||
|
+ <groupId>org.eclipse.m2e</groupId>
|
||
|
+ <artifactId>lifecycle-mapping</artifactId>
|
||
|
+ <version>1.0.0</version>
|
||
|
+ <configuration>
|
||
|
+ <lifecycleMappingMetadata>
|
||
|
+ <pluginExecutions>
|
||
|
+ <pluginExecution>
|
||
|
+ <pluginExecutionFilter>
|
||
|
+ <groupId>com.lukegb.mojo</groupId>
|
||
|
+ <artifactId>gitdescribe-maven-plugin</artifactId>
|
||
|
+ <versionRange>[1.3,)</versionRange>
|
||
|
+ <goals>
|
||
|
+ <goal>gitdescribe</goal>
|
||
|
+ </goals>
|
||
|
+ </pluginExecutionFilter>
|
||
|
+ <action>
|
||
|
+ <ignore />
|
||
|
+ </action>
|
||
|
+ </pluginExecution>
|
||
|
+ </pluginExecutions>
|
||
|
+ </lifecycleMappingMetadata>
|
||
|
+ </configuration>
|
||
|
+ </plugin>
|
||
|
+ </plugins>
|
||
|
+ </pluginManagement>
|
||
|
+ <plugins>
|
||
|
+ <plugin>
|
||
|
+ <groupId>net.md-5</groupId>
|
||
|
+ <artifactId>scriptus</artifactId>
|
||
|
+ <version>0.2</version>
|
||
|
+ <executions>
|
||
|
+ <execution>
|
||
|
+ <id>ex-mspigot</id>
|
||
|
+ <phase>initialize</phase>
|
||
|
+ <goals>
|
||
|
+ <goal>describe</goal>
|
||
|
+ </goals>
|
||
|
+ <configuration>
|
||
|
+ <format>git-mSpigot-%s</format>
|
||
|
+ <scmDirectory>../</scmDirectory>
|
||
|
+ <descriptionProperty>mspigot.desc</descriptionProperty>
|
||
|
+ </configuration>
|
||
|
+ </execution>
|
||
|
+ </executions>
|
||
|
+ </plugin>
|
||
|
+ <plugin>
|
||
|
+ <artifactId>maven-jar-plugin</artifactId>
|
||
|
+ <version>2.1</version>
|
||
|
+ <configuration>
|
||
|
+ <archive>
|
||
|
+ <manifestEntries>
|
||
|
+ <Main-Class>org.bukkit.craftbukkit.Main</Main-Class>
|
||
|
+ <Implementation-Title>CraftBukkit</Implementation-Title>
|
||
|
+ <Implementation-Version>${mspigot.desc}</Implementation-Version>
|
||
|
+ <Implementation-Vendor>Bukkit Team</Implementation-Vendor>
|
||
|
+ <Specification-Title>Bukkit</Specification-Title>
|
||
|
+ <Specification-Version>${api.version}</Specification-Version>
|
||
|
+ <Specification-Vendor>Bukkit Team</Specification-Vendor>
|
||
|
+ <Sealed>true</Sealed>
|
||
|
+ <Timestamp>${maven.build.timestamp}</Timestamp>
|
||
|
+ </manifestEntries>
|
||
|
+ <manifestSections>
|
||
|
+ <manifestSection>
|
||
|
+ <name>net/bukkit/</name>
|
||
|
+ <manifestEntries>
|
||
|
+ <Sealed>true</Sealed>
|
||
|
+ </manifestEntries>
|
||
|
+ </manifestSection>
|
||
|
+ <manifestSection>
|
||
|
+ <name>com/bukkit/</name>
|
||
|
+ <manifestEntries>
|
||
|
+ <Sealed>true</Sealed>
|
||
|
+ </manifestEntries>
|
||
|
+ </manifestSection>
|
||
|
+ <manifestSection>
|
||
|
+ <name>org/bukkit/</name>
|
||
|
+ <manifestEntries>
|
||
|
+ <Sealed>true</Sealed>
|
||
|
+ </manifestEntries>
|
||
|
+ </manifestSection>
|
||
|
+ </manifestSections>
|
||
|
+ </archive>
|
||
|
+ </configuration>
|
||
|
+ </plugin>
|
||
|
+ <plugin>
|
||
|
+ <artifactId>maven-shade-plugin</artifactId>
|
||
|
+ <version>2.1</version>
|
||
|
+ <executions>
|
||
|
+ <execution>
|
||
|
+ <phase>package</phase>
|
||
|
+ <goals>
|
||
|
+ <goal>shade</goal>
|
||
|
+ </goals>
|
||
|
+ <configuration>
|
||
|
+ <relocations>
|
||
|
+ <relocation>
|
||
|
+ <pattern>org.bouncycastle</pattern>
|
||
|
+ <shadedPattern>net.minecraft.v${minecraft_version}.org.bouncycastle</shadedPattern>
|
||
|
+ </relocation>
|
||
|
+ <relocation>
|
||
|
+ <pattern>joptsimple</pattern>
|
||
|
+ <shadedPattern>org.bukkit.craftbukkit.libs.joptsimple</shadedPattern>
|
||
|
+ </relocation>
|
||
|
+ <relocation>
|
||
|
+ <pattern>jline</pattern>
|
||
|
+ <shadedPattern>org.bukkit.craftbukkit.libs.jline</shadedPattern>
|
||
|
+ </relocation>
|
||
|
+ <relocation>
|
||
|
+ <pattern>org.ibex</pattern>
|
||
|
+ <shadedPattern>org.bukkit.craftbukkit.libs.org.ibex</shadedPattern>
|
||
|
+ </relocation>
|
||
|
+ <relocation>
|
||
|
+ <pattern>org.gjt</pattern>
|
||
|
+ <shadedPattern>org.bukkit.craftbukkit.libs.org.gjt</shadedPattern>
|
||
|
+ </relocation>
|
||
|
+ <relocation>
|
||
|
+ <pattern>com.google.gson</pattern>
|
||
|
+ <shadedPattern>org.bukkit.craftbukkit.libs.com.google.gson</shadedPattern>
|
||
|
+ </relocation>
|
||
|
+ <relocation>
|
||
|
+ <pattern>io.netty</pattern>
|
||
|
+ <shadedPattern>net.minecraft.util.io.netty</shadedPattern>
|
||
|
+ </relocation>
|
||
|
+ <relocation>
|
||
|
+ <pattern>org.bukkit.craftbukkit</pattern>
|
||
|
+ <shadedPattern>org.bukkit.craftbukkit.v${minecraft_version}</shadedPattern>
|
||
|
+ <excludes>
|
||
|
+ <exclude>org.bukkit.craftbukkit.Main*</exclude>
|
||
|
+ </excludes>
|
||
|
+ </relocation>
|
||
|
+ <relocation>
|
||
|
+ <pattern>net.minecraft.server</pattern>
|
||
|
+ <shadedPattern>net.minecraft.server.v${minecraft_version}</shadedPattern>
|
||
|
+ </relocation>
|
||
|
+ </relocations>
|
||
|
+ <filters>
|
||
|
+ <filter>
|
||
|
+ <artifact>org.bukkit:minecraft-server</artifact>
|
||
|
+ <excludes>
|
||
|
+ <exclude>net/minecraft/util/io/netty/**</exclude>
|
||
|
+ </excludes>
|
||
|
+ </filter>
|
||
|
+ </filters>
|
||
|
+ </configuration>
|
||
|
+ </execution>
|
||
|
+ </executions>
|
||
|
+ </plugin>
|
||
|
+ <plugin>
|
||
|
+ <artifactId>maven-compiler-plugin</artifactId>
|
||
|
+ <version>3.1</version>
|
||
|
+ <dependencies>
|
||
|
+ <dependency>
|
||
|
+ <groupId>org.codehaus.plexus</groupId>
|
||
|
+ <artifactId>plexus-compiler-eclipse</artifactId>
|
||
|
+ <version>2.5.0-spigotmc</version>
|
||
|
+ </dependency>
|
||
|
+ </dependencies>
|
||
|
+ <configuration>
|
||
|
+ <source>1.8</source>
|
||
|
+ <target>1.8</target>
|
||
|
+ <compilerId>eclipse</compilerId>
|
||
|
+ <optimize>true</optimize>
|
||
|
+ </configuration>
|
||
|
+ </plugin>
|
||
|
+ <plugin>
|
||
|
+ <artifactId>maven-surefire-plugin</artifactId>
|
||
|
+ <version>2.11</version>
|
||
|
+ <configuration>
|
||
|
+ <workingDirectory>${basedir}/target/test-server</workingDirectory>
|
||
|
+ <excludes>
|
||
|
+ <exclude>org/bukkit/craftbukkit/updater/BukkitDLUpdaterServiceTest.java</exclude>
|
||
|
+ <exclude>org/bukkit/craftbukkit/inventory/ItemStack*Test.java</exclude>
|
||
|
+ </excludes>
|
||
|
+ </configuration>
|
||
|
+ </plugin>
|
||
|
+ <plugin>
|
||
|
+ <groupId>net.md-5</groupId>
|
||
|
+ <artifactId>specialsource-maven-plugin</artifactId>
|
||
|
+ <version>1.2.1</version>
|
||
|
+ <executions>
|
||
|
+ <execution>
|
||
|
+ <phase>package</phase>
|
||
|
+ <goals>
|
||
|
+ <goal>remap</goal>
|
||
|
+ </goals>
|
||
|
+ <configuration>
|
||
|
+ <srgIn>${project.basedir}/deprecation-mappings.csrg</srgIn>
|
||
|
+ <accessIn>${project.basedir}/deprecation-mappings.at</accessIn>
|
||
|
+ </configuration>
|
||
|
+ </execution>
|
||
|
+ </executions>
|
||
|
+ </plugin>
|
||
|
+ </plugins>
|
||
|
+ </build>
|
||
|
+ <pluginRepositories>
|
||
|
+ <pluginRepository>
|
||
|
+ <id>spigotmc-public</id>
|
||
|
+ <url>https://hub.spigotmc.org/nexus/content/groups/public/</url>
|
||
|
+ </pluginRepository>
|
||
|
+ </pluginRepositories>
|
||
|
+ <dependencies>
|
||
|
+ <dependency>
|
||
|
+ <groupId>junit</groupId>
|
||
|
+ <artifactId>junit</artifactId>
|
||
|
+ <version>4.11</version>
|
||
|
+ <scope>test</scope>
|
||
|
+ <exclusions>
|
||
|
+ <exclusion>
|
||
|
+ <artifactId>hamcrest-core</artifactId>
|
||
|
+ <groupId>org.hamcrest</groupId>
|
||
|
+ </exclusion>
|
||
|
+ </exclusions>
|
||
|
+ </dependency>
|
||
|
+ <dependency>
|
||
|
+ <groupId>org.hamcrest</groupId>
|
||
|
+ <artifactId>hamcrest-library</artifactId>
|
||
|
+ <version>1.3</version>
|
||
|
+ <scope>test</scope>
|
||
|
+ <exclusions>
|
||
|
+ <exclusion>
|
||
|
+ <artifactId>hamcrest-core</artifactId>
|
||
|
+ <groupId>org.hamcrest</groupId>
|
||
|
+ </exclusion>
|
||
|
+ </exclusions>
|
||
|
+ </dependency>
|
||
|
+ </dependencies>
|
||
|
+ <properties>
|
||
|
+ <minecraft.version>1.7.10</minecraft.version>
|
||
|
+ <junit.version>4.11</junit.version>
|
||
|
+ <api.version>${project.name}-${project.version}</api.version>
|
||
|
+ <minecraft_version>1_7_R4</minecraft_version>
|
||
|
+ <maven.compiler.target>1.8</maven.compiler.target>
|
||
|
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||
|
+ <buildtag.prefix>git-Bukkit-</buildtag.prefix>
|
||
|
+ <maven.compiler.source>1.8</maven.compiler.source>
|
||
|
+ </properties>
|
||
|
+</project>
|
||
|
+
|
||
|
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<Integer, MobEffect> 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<Map.Entry<Integer, MobEffect>> iterator = Sets.newHashSet(this.effects.entrySet()).iterator();
|
||
|
while (iterator.hasNext()) {
|
||
|
- Integer integer = (Integer) iterator.next();
|
||
|
- MobEffect mobeffect = (MobEffect) this.effects.get(integer);
|
||
|
+ Map.Entry<Integer, MobEffect> 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<Map.Entry<Integer, MobEffect>> set = this.effects.entrySet();
|
||
|
+ Iterator<Map.Entry<Integer, MobEffect>> iterator = new HashSet<>(set).iterator();
|
||
|
while (iterator.hasNext()) {
|
||
|
- Integer integer = (Integer) iterator.next();
|
||
|
+ Map.Entry<Integer, MobEffect> 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<PotionEffect> getActivePotionEffects() {
|
||
|
List<PotionEffect> effects = new ArrayList<PotionEffect>();
|
||
|
- 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)
|
||
|
|