Quick 1.16.4 support

This commit is contained in:
Govindas 2020-11-03 13:01:31 +02:00
parent 9080e9b372
commit 89b8b418d5
7 changed files with 191 additions and 55 deletions

View File

@ -2,33 +2,7 @@
<project version="4"> <project version="4">
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="72e0643a-ea45-4e93-b5a5-734a94c41ff5" name="Default Changelist" comment=""> <list default="true" id="72e0643a-ea45-4e93-b5a5-734a94c41ff5" name="Default Changelist" comment="">
<change beforePath="$PROJECT_DIR$/.gitignore" beforeDir="false" afterPath="$PROJECT_DIR$/.gitignore" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/artifacts/SkStuff_jar.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/artifacts/SkStuff_jar.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/discord.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/discord.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" /> <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/SkStuff.iml" beforeDir="false" afterPath="$PROJECT_DIR$/SkStuff.iml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/bin/me/TheBukor/SkStuff/SkStuff.class" beforeDir="false" afterPath="$PROJECT_DIR$/bin/me/TheBukor/SkStuff/SkStuff.class" afterDir="false" />
<change beforePath="$PROJECT_DIR$/bin/me/TheBukor/SkStuff/effects/EffClearPathGoals.class" beforeDir="false" afterPath="$PROJECT_DIR$/bin/me/TheBukor/SkStuff/effects/EffClearPathGoals.class" afterDir="false" />
<change beforePath="$PROJECT_DIR$/bin/me/TheBukor/SkStuff/effects/EffMakeJump.class" beforeDir="false" afterPath="$PROJECT_DIR$/bin/me/TheBukor/SkStuff/effects/EffMakeJump.class" afterDir="false" />
<change beforePath="$PROJECT_DIR$/bin/me/TheBukor/SkStuff/effects/EffRemovePathGoal.class" beforeDir="false" afterPath="$PROJECT_DIR$/bin/me/TheBukor/SkStuff/effects/EffRemovePathGoal.class" afterDir="false" />
<change beforePath="$PROJECT_DIR$/bin/me/TheBukor/SkStuff/effects/EffSetPathGoal.class" beforeDir="false" afterPath="$PROJECT_DIR$/bin/me/TheBukor/SkStuff/effects/EffSetPathGoal.class" afterDir="false" />
<change beforePath="$PROJECT_DIR$/bin/me/TheBukor/SkStuff/effects/EffShowEntityEffect.class" beforeDir="false" afterPath="$PROJECT_DIR$/bin/me/TheBukor/SkStuff/effects/EffShowEntityEffect.class" afterDir="false" />
<change beforePath="$PROJECT_DIR$/bin/me/TheBukor/SkStuff/expressions/ExprFireProof.class" beforeDir="false" afterPath="$PROJECT_DIR$/bin/me/TheBukor/SkStuff/expressions/ExprFireProof.class" afterDir="false" />
<change beforePath="$PROJECT_DIR$/bin/me/TheBukor/SkStuff/expressions/ExprNoClip.class" beforeDir="false" afterPath="$PROJECT_DIR$/bin/me/TheBukor/SkStuff/expressions/ExprNoClip.class" afterDir="false" />
<change beforePath="$PROJECT_DIR$/bin/me/TheBukor/SkStuff/pathfinders/PathfinderGoalFollow_v1_13_R2.class" beforeDir="false" afterPath="$PROJECT_DIR$/bin/me/TheBukor/SkStuff/pathfinders/PathfinderGoalFollow_v1_13_R2.class" afterDir="false" />
<change beforePath="$PROJECT_DIR$/bin/me/TheBukor/SkStuff/pathfinders/PathfinderGoalFollow_v1_14_R1.class" beforeDir="false" afterPath="$PROJECT_DIR$/bin/me/TheBukor/SkStuff/pathfinders/PathfinderGoalFollow_v1_14_R1.class" afterDir="false" />
<change beforePath="$PROJECT_DIR$/bin/me/TheBukor/SkStuff/util/NMS_v1_13_R2.class" beforeDir="false" afterPath="$PROJECT_DIR$/bin/me/TheBukor/SkStuff/util/NMS_v1_13_R2.class" afterDir="false" />
<change beforePath="$PROJECT_DIR$/bin/me/TheBukor/SkStuff/util/NMS_v1_14_R1.class" beforeDir="false" afterPath="$PROJECT_DIR$/bin/me/TheBukor/SkStuff/util/NMS_v1_14_R1.class" afterDir="false" />
<change beforePath="$PROJECT_DIR$/bin/me/TheBukor/SkStuff/util/NMS_v1_15_R1.class" beforeDir="false" afterPath="$PROJECT_DIR$/bin/me/TheBukor/SkStuff/util/NMS_v1_15_R1.class" afterDir="false" />
<change beforePath="$PROJECT_DIR$/bin/me/TheBukor/SkStuff/util/ReflectionUtils.class" beforeDir="false" afterPath="$PROJECT_DIR$/bin/me/TheBukor/SkStuff/util/ReflectionUtils.class" afterDir="false" />
<change beforePath="$PROJECT_DIR$/plugin.yml" beforeDir="false" afterPath="$PROJECT_DIR$/plugin.yml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/me/TheBukor/SkStuff/SkStuff.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/me/TheBukor/SkStuff/SkStuff.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/me/TheBukor/SkStuff/effects/EffSetPathGoal.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/me/TheBukor/SkStuff/effects/EffSetPathGoal.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/me/TheBukor/SkStuff/pathfinders/PathfinderGoalFollow_v1_13_R2.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/me/TheBukor/SkStuff/pathfinders/PathfinderGoalFollow_v1_13_R2.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/me/TheBukor/SkStuff/pathfinders/PathfinderGoalFollow_v1_16_R1.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/me/TheBukor/SkStuff/pathfinders/PathfinderGoalFollow_v1_16_R2.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/me/TheBukor/SkStuff/util/NMS_v1_14_R1.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/me/TheBukor/SkStuff/util/NMS_v1_14_R1.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/me/TheBukor/SkStuff/util/NMS_v1_15_R1.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/me/TheBukor/SkStuff/util/NMS_v1_15_R1.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/me/TheBukor/SkStuff/util/NMS_v1_16_R1.java" beforeDir="false" />
</list> </list>
<option name="SHOW_DIALOG" value="false" /> <option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" /> <option name="HIGHLIGHT_CONFLICTS" value="true" />
@ -52,7 +26,7 @@
<component name="PropertiesComponent"> <component name="PropertiesComponent">
<property name="ASKED_ADD_EXTERNAL_FILES" value="true" /> <property name="ASKED_ADD_EXTERNAL_FILES" value="true" />
<property name="RunOnceActivity.ShowReadmeOnStart" value="true" /> <property name="RunOnceActivity.ShowReadmeOnStart" value="true" />
<property name="last_opened_file_path" value="$PROJECT_DIR$/../../import/Paper-1.16.3-latest.jar" /> <property name="last_opened_file_path" value="$PROJECT_DIR$/../../import/craftbukkit-1.16.4.jar" />
<property name="project.structure.last.edited" value="Modules" /> <property name="project.structure.last.edited" value="Modules" />
<property name="project.structure.proportion" value="0.15" /> <property name="project.structure.proportion" value="0.15" />
<property name="project.structure.side.proportion" value="0.2" /> <property name="project.structure.side.proportion" value="0.2" />
@ -85,18 +59,14 @@
<screen x="0" y="0" width="1366" height="728" /> <screen x="0" y="0" width="1366" height="728" />
</state> </state>
<state x="488" y="70" key="#com.intellij.ide.util.MemberChooser/0.0.1366.728@0.0.1366.728" timestamp="1603963583320" /> <state x="488" y="70" key="#com.intellij.ide.util.MemberChooser/0.0.1366.728@0.0.1366.728" timestamp="1603963583320" />
<state x="79" y="101" key="FileChooserDialogImpl" timestamp="1603966567079"> <state x="79" y="101" key="FileChooserDialogImpl" timestamp="1604401015065">
<screen x="0" y="0" width="1366" height="728" /> <screen x="0" y="0" width="1366" height="728" />
</state> </state>
<state x="79" y="101" key="FileChooserDialogImpl/0.0.1366.728@0.0.1366.728" timestamp="1603966567079" /> <state x="79" y="101" key="FileChooserDialogImpl/0.0.1366.728@0.0.1366.728" timestamp="1604401015065" />
<state x="163" y="0" key="SettingsEditor" timestamp="1603966572549"> <state x="163" y="0" key="SettingsEditor" timestamp="1604401021463">
<screen x="0" y="0" width="1366" height="728" /> <screen x="0" y="0" width="1366" height="728" />
</state> </state>
<state x="163" y="0" key="SettingsEditor/0.0.1366.728@0.0.1366.728" timestamp="1603966572549" /> <state x="163" y="0" key="SettingsEditor/0.0.1366.728@0.0.1366.728" timestamp="1604401021463" />
<state x="0" y="0" key="com.intellij.ide.util.TipDialog" timestamp="1595662947316">
<screen x="0" y="0" width="1366" height="728" />
</state>
<state x="0" y="0" key="com.intellij.ide.util.TipDialog/0.0.1366.728@0.0.1366.728" timestamp="1595662947316" />
</component> </component>
<component name="XDebuggerManager"> <component name="XDebuggerManager">
<breakpoint-manager> <breakpoint-manager>

View File

@ -144,5 +144,16 @@
</SOURCES> </SOURCES>
</library> </library>
</orderEntry> </orderEntry>
<orderEntry type="module-library">
<library>
<CLASSES>
<root url="jar://$MODULE_DIR$/../../import/craftbukkit-1.16.4.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES>
<root url="jar://$MODULE_DIR$/../../import/craftbukkit-1.16.4.jar!/" />
</SOURCES>
</library>
</orderEntry>
</component> </component>
</module> </module>

View File

@ -2,22 +2,15 @@ package me.TheBukor.SkStuff;
import ch.njol.skript.Skript; import ch.njol.skript.Skript;
import ch.njol.skript.lang.ExpressionType; import ch.njol.skript.lang.ExpressionType;
import ch.njol.skript.lang.util.SimpleEvent;
import ch.njol.skript.registrations.EventValues;
import ch.njol.skript.util.Getter;
import me.TheBukor.SkStuff.bstats.Metrics; import me.TheBukor.SkStuff.bstats.Metrics;
import me.TheBukor.SkStuff.effects.*; import me.TheBukor.SkStuff.effects.*;
import me.TheBukor.SkStuff.expressions.*; import me.TheBukor.SkStuff.expressions.ExprFireProof;
import me.TheBukor.SkStuff.expressions.ExprNoClip;
import me.TheBukor.SkStuff.expressions.ExprStepLength;
import me.TheBukor.SkStuff.util.*; import me.TheBukor.SkStuff.util.*;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.entity.Entity;
import org.bukkit.event.entity.EntityToggleGlideEvent;
import org.bukkit.inventory.Inventory;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
import javax.annotation.Nullable;
import java.io.IOException;
public class SkStuff extends JavaPlugin { public class SkStuff extends JavaPlugin {
private static NMSInterface nmsMethods; private static NMSInterface nmsMethods;
@ -90,6 +83,10 @@ public class SkStuff extends JavaPlugin {
nmsMethods = new NMS_v1_16_R2(); nmsMethods = new NMS_v1_16_R2();
getLogger().info("It looks like you're running 1.16.3!"); getLogger().info("It looks like you're running 1.16.3!");
break; break;
case "v1_16_R3.":
nmsMethods = new NMS_v1_16_R3();
getLogger().info("It looks like you're running 1.16.4!");
break;
default: default:
getLogger().warning("It looks like you're running an unsupported server version, some features will not be available :("); getLogger().warning("It looks like you're running an unsupported server version, some features will not be available :(");
break; break;

View File

@ -7,8 +7,7 @@ import java.util.List;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import me.TheBukor.SkStuff.pathfinders.PathfinderGoalFollow_v1_15_R1; import me.TheBukor.SkStuff.pathfinders.*;
import me.TheBukor.SkStuff.pathfinders.PathfinderGoalFollow_v1_16_R2;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.entity.Animals; import org.bukkit.entity.Animals;
import org.bukkit.entity.ArmorStand; import org.bukkit.entity.ArmorStand;
@ -42,8 +41,6 @@ import ch.njol.skript.lang.SkriptParser.ParseResult;
import ch.njol.skript.util.Timespan; import ch.njol.skript.util.Timespan;
import ch.njol.util.Kleenean; import ch.njol.util.Kleenean;
import me.TheBukor.SkStuff.SkStuff; import me.TheBukor.SkStuff.SkStuff;
import me.TheBukor.SkStuff.pathfinders.PathfinderGoalFollow_v1_13_R2;
import me.TheBukor.SkStuff.pathfinders.PathfinderGoalFollow_v1_14_R1;
import me.TheBukor.SkStuff.util.ReflectionUtils; import me.TheBukor.SkStuff.util.ReflectionUtils;
public final class EffSetPathGoal extends Effect { public final class EffSetPathGoal extends Effect {
@ -556,6 +553,9 @@ public final class EffSetPathGoal extends Effect {
case "v1.16_R2.": case "v1.16_R2.":
newGoals.add(new PathfinderGoalFollow_v1_16_R2((net.minecraft.server.v1_16_R2.EntityCreature) nmsEnt, nmsClass, radius, spd, usesName, customName)); newGoals.add(new PathfinderGoalFollow_v1_16_R2((net.minecraft.server.v1_16_R2.EntityCreature) nmsEnt, nmsClass, radius, spd, usesName, customName));
break; break;
case "v1.16_R3.":
newGoals.add(new PathfinderGoalFollow_v1_16_R3((net.minecraft.server.v1_16_R3.EntityCreature) nmsEnt, nmsClass, radius, spd, usesName, customName));
break;
} }
} }
} else if (mark == 42) { } else if (mark == 42) {

View File

@ -8,13 +8,13 @@ import net.minecraft.server.v1_16_R2.PathfinderGoal;
import java.util.List; import java.util.List;
public class PathfinderGoalFollow_v1_16_R2 extends PathfinderGoal { public class PathfinderGoalFollow_v1_16_R2 extends PathfinderGoal {
private EntityCreature follower; private final EntityCreature follower;
private EntityLiving followed; private EntityLiving followed;
private Class<?> followedClass; private final Class<?> followedClass;
private float radius; private final float radius;
private double speed; private final double speed;
private boolean isByName; private final boolean isByName;
private String customName; private final String customName;
public PathfinderGoalFollow_v1_16_R2(EntityCreature follower, Class<?> followedClass, float radius, double speed, boolean isByName, String customName) { public PathfinderGoalFollow_v1_16_R2(EntityCreature follower, Class<?> followedClass, float radius, double speed, boolean isByName, String customName) {
this.follower = follower; this.follower = follower;

View File

@ -0,0 +1,79 @@
package me.TheBukor.SkStuff.pathfinders;
import net.minecraft.server.v1_16_R3.Entity;
import net.minecraft.server.v1_16_R3.EntityCreature;
import net.minecraft.server.v1_16_R3.EntityLiving;
import net.minecraft.server.v1_16_R3.PathfinderGoal;
import java.util.List;
public class PathfinderGoalFollow_v1_16_R3 extends PathfinderGoal {
private final EntityCreature follower;
private EntityLiving followed;
private final Class<?> followedClass;
private final float radius;
private final double speed;
private final boolean isByName;
private final String customName;
public PathfinderGoalFollow_v1_16_R3(EntityCreature follower, Class<?> followedClass, float radius, double speed, boolean isByName, String customName) {
this.follower = follower;
this.followedClass = followedClass;
this.radius = radius;
this.speed = speed;
this.isByName = isByName;
this.customName = customName;
}
// a() is shouldExecute()
@SuppressWarnings("unchecked")
@Override
public boolean a() {
if (followed == null) {
List<?> list = follower.world.a((Class<? extends Entity>) followedClass, follower.getBoundingBox().grow(radius, 4.0D, radius));
if (list.isEmpty()) {
return false;
}
if (isByName) {
for (Object entity : list) {
if (((EntityLiving) entity).getCustomName().equals(customName)) {
followed = (EntityLiving) entity;
return true;
}
}
} else {
followed = (EntityLiving) list.get(0);
return true;
}
}
return true;
}
// b() is shouldContinueExecuting()
@Override
public boolean b() {
if (followed.dead) {
followed = null;
return false;
} else if (followed.h(follower) < 9.0D || followed.h(follower) > Math.pow(radius, 2)) { // h() = distanceSquaredFrom()
return false; // if 3 blocks away or not in radius, stop moving.
//Maybe I'll add a teleport feature later.
} else if (isByName) {
if (!followed.getCustomName().equals(customName)) {
followed = null;
return false;
}
}
//return follower.getNavigation().n(); // n() means hasNoPath()
return true;
// n() is now protected void and I'm not sure how to access it, so I'm just returning a boolean, this probably will cause some issues with this pathfinder goal, if you know a better solution, let me know. - Govindas.
}
// c() is execute()
@Override
public void c () {
follower.getNavigation().a(followed, speed); // a() means moveTo()
}
}

View File

@ -0,0 +1,79 @@
package me.TheBukor.SkStuff.util;
import net.minecraft.server.v1_16_R3.EntityInsentient;
import net.minecraft.server.v1_16_R3.PathfinderGoal;
import net.minecraft.server.v1_16_R3.PathfinderGoalSelector;
import org.bukkit.Bukkit;
import org.bukkit.craftbukkit.v1_16_R3.entity.CraftEntity;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Mob;
import java.util.LinkedHashSet;
public class NMS_v1_16_R3 implements NMSInterface {
@Override
public void clearPathfinderGoals(Entity entity) {
Mob e = (Mob) entity;
Bukkit.getMobGoals().removeAllGoals(e);
}
@Override
public void removePathfinderGoal(Object entity, Class<?> goalClass, boolean isTargetSelector) {
if (entity instanceof EntityInsentient) {
((EntityInsentient) entity).setGoalTarget(null);
if (isTargetSelector) {
((LinkedHashSet<?>) ReflectionUtils.getField("b", PathfinderGoalSelector.class, ((EntityInsentient) entity).targetSelector)).removeIf(goal -> ReflectionUtils.getField("a", goal.getClass(), goal).getClass() == goalClass);
} else {
((LinkedHashSet<?>) ReflectionUtils.getField("b", PathfinderGoalSelector.class, ((EntityInsentient) entity).goalSelector)).removeIf(goal -> ReflectionUtils.getField("a", goal.getClass(), goal).getClass() == goalClass);
}
}
}
@Override
public void addPathfinderGoal(Object entity, int priority, Object goal, boolean isTargetSelector) {
if (entity instanceof EntityInsentient && goal instanceof PathfinderGoal) {
if (isTargetSelector)
((EntityInsentient) entity).targetSelector.a(priority, (PathfinderGoal) goal);
else
((EntityInsentient) entity).goalSelector.a(priority, (PathfinderGoal) goal);
}
}
@Override
public boolean getNoClip(Entity entity) {
net.minecraft.server.v1_16_R3.Entity nmsEntity = ((CraftEntity) entity).getHandle();
return nmsEntity.noclip;
}
@Override
public void setNoClip(Entity entity, boolean noclip) {
net.minecraft.server.v1_16_R3.Entity nmsEntity = ((CraftEntity) entity).getHandle();
nmsEntity.noclip = noclip;
}
@Override
public boolean getFireProof(Entity entity) {
net.minecraft.server.v1_16_R3.Entity nmsEntity = ((CraftEntity) entity).getHandle();
return nmsEntity.isFireProof();
}
@Override
public void setFireProof(Entity entity, boolean fireProof) {
net.minecraft.server.v1_16_R3.Entity nmsEntity = ((CraftEntity) entity).getHandle();
ReflectionUtils.setField("fireProof", nmsEntity.getClass(), nmsEntity, fireProof);
}
public float getEntityStepLength(Entity entity) {
net.minecraft.server.v1_16_R3.Entity nmsEntity = ((CraftEntity) entity).getHandle();
return nmsEntity.G;
}
@Override
public void setEntityStepLength(Entity entity, float length) {
net.minecraft.server.v1_16_R3.Entity nmsEntity = ((CraftEntity) entity).getHandle();
nmsEntity.G = length;
}
}