start using Paper API for 1.16+ pathfinder goal removal

This commit is contained in:
Govindas 2020-10-30 09:40:47 +02:00
parent 6e9dd616f8
commit 9080e9b372
28 changed files with 269 additions and 211 deletions

6
.gitignore vendored
View File

@ -1,6 +1,6 @@
/out out
/bin bin
/target target
/META-INF /META-INF
/.settings /.settings
/.idea /.idea

View File

@ -3,7 +3,6 @@
<output-path>$PROJECT_DIR$/out/artifacts/SkStuff_jar</output-path> <output-path>$PROJECT_DIR$/out/artifacts/SkStuff_jar</output-path>
<root id="archive" name="SkStuff.jar"> <root id="archive" name="SkStuff.jar">
<element id="module-output" name="SkStuff" /> <element id="module-output" name="SkStuff" />
<element id="module-source" name="SkStuff" />
<element id="file-copy" path="$PROJECT_DIR$/plugin.yml" /> <element id="file-copy" path="$PROJECT_DIR$/plugin.yml" />
</root> </root>
</artifact> </artifact>

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project version="4"> <project version="4">
<component name="DiscordProjectSettings"> <component name="DiscordProjectSettings">
<option name="show" value="true" /> <option name="show" value="PROJECT_FILES" />
</component> </component>
<component name="ProjectNotificationSettings"> <component name="ProjectNotificationSettings">
<option name="askShowProject" value="false" /> <option name="askShowProject" value="false" />

View File

@ -2,9 +2,33 @@
<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/SkStuff.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/me/TheBukor/SkStuff/SkStuff.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/me/TheBukor/SkStuff/util/NMS_v1_9_R1.java" beforeDir="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" />
@ -23,38 +47,26 @@
</component> </component>
<component name="ProjectId" id="1dDc5mH6vdHCfDtdCWF3TtPitSZ" /> <component name="ProjectId" id="1dDc5mH6vdHCfDtdCWF3TtPitSZ" />
<component name="ProjectViewState"> <component name="ProjectViewState">
<option name="showExcludedFiles" value="true" />
<option name="showLibraryContents" value="true" /> <option name="showLibraryContents" value="true" />
</component> </component>
<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$/plugin.yml" /> <property name="last_opened_file_path" value="$PROJECT_DIR$/../../import/Paper-1.16.3-latest.jar" />
<property name="project.structure.last.edited" value="Artifacts" /> <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" />
</component> </component>
<component name="RecentsManager"> <component name="RecentsManager">
<key name="CopyClassDialog.RECENTS_KEY"> <key name="CopyClassDialog.RECENTS_KEY">
<recent name="me.TheBukor.SkStuff.pathfinders" />
<recent name="me.TheBukor.SkStuff.util" /> <recent name="me.TheBukor.SkStuff.util" />
<recent name="me.TheBukor.SkStuff.pathfinders" />
</key> </key>
</component> </component>
<component name="SQLPlugin.ProjectConfiguration"> <component name="SQLPlugin.ProjectConfiguration">
<queries /> <queries />
</component> </component>
<component name="ServiceViewManager"> <component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="project-level" UseSingleDictionary="true" transferred="true" />
<option name="viewStates">
<list>
<serviceView>
<treeState>
<expand />
<select />
</treeState>
</serviceView>
</list>
</option>
</component>
<component name="SvnConfiguration"> <component name="SvnConfiguration">
<configuration /> <configuration />
</component> </component>
@ -69,18 +81,18 @@
<servers /> <servers />
</component> </component>
<component name="WindowStateProjectService"> <component name="WindowStateProjectService">
<state x="79" y="101" key="FileChooserDialogImpl" timestamp="1595328182010"> <state x="488" y="70" key="#com.intellij.ide.util.MemberChooser" timestamp="1603963583320">
<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="1595328182010" /> <state x="488" y="70" key="#com.intellij.ide.util.MemberChooser/0.0.1366.728@0.0.1366.728" timestamp="1603963583320" />
<state x="348" y="62" key="NewModule_or_Project.wizard" timestamp="1592831160031"> <state x="79" y="101" key="FileChooserDialogImpl" timestamp="1603966567079">
<screen x="0" y="0" width="1366" height="728" /> <screen x="0" y="0" width="1366" height="728" />
</state> </state>
<state x="348" y="62" key="NewModule_or_Project.wizard/0.0.1366.728@0.0.1366.728" timestamp="1592831160031" /> <state x="79" y="101" key="FileChooserDialogImpl/0.0.1366.728@0.0.1366.728" timestamp="1603966567079" />
<state x="163" y="0" key="SettingsEditor" timestamp="1595328184010"> <state x="163" y="0" key="SettingsEditor" timestamp="1603966572549">
<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="1595328184010" /> <state x="163" y="0" key="SettingsEditor/0.0.1366.728@0.0.1366.728" timestamp="1603966572549" />
<state x="0" y="0" key="com.intellij.ide.util.TipDialog" timestamp="1595662947316"> <state x="0" y="0" key="com.intellij.ide.util.TipDialog" timestamp="1595662947316">
<screen x="0" y="0" width="1366" height="728" /> <screen x="0" y="0" width="1366" height="728" />
</state> </state>

View File

@ -28,33 +28,11 @@
<orderEntry type="module-library"> <orderEntry type="module-library">
<library> <library>
<CLASSES> <CLASSES>
<root url="jar://$MODULE_DIR$/../../import/craftbukkit-1.14.4-R0.1-SNAPSHOT.jar!/" /> <root url="jar://$MODULE_DIR$/../../import/Paper-1.16.3-latest.jar!/" />
</CLASSES> </CLASSES>
<JAVADOC /> <JAVADOC />
<SOURCES> <SOURCES>
<root url="jar://$MODULE_DIR$/../../import/craftbukkit-1.14.4-R0.1-SNAPSHOT.jar!/" /> <root url="jar://$MODULE_DIR$/../../import/Paper-1.16.3-latest.jar!/" />
</SOURCES>
</library>
</orderEntry>
<orderEntry type="module-library">
<library>
<CLASSES>
<root url="jar://$MODULE_DIR$/../../import/craftbukkit-1.15.1-R0.1-SNAPSHOT.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES>
<root url="jar://$MODULE_DIR$/../../import/craftbukkit-1.15.1-R0.1-SNAPSHOT.jar!/" />
</SOURCES>
</library>
</orderEntry>
<orderEntry type="module-library">
<library>
<CLASSES>
<root url="jar://$MODULE_DIR$/../../import/craftbukkit-1.13.2.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES>
<root url="jar://$MODULE_DIR$/../../import/craftbukkit-1.13.2.jar!/" />
</SOURCES> </SOURCES>
</library> </library>
</orderEntry> </orderEntry>
@ -70,11 +48,11 @@
<orderEntry type="module-library"> <orderEntry type="module-library">
<library> <library>
<CLASSES> <CLASSES>
<root url="jar://$MODULE_DIR$/../../import/craftbukkit-1.12.2.jar!/" /> <root url="jar://$MODULE_DIR$/../../import/craftbukkit-1.10.2-R0.1-SNAPSHOT-latest.jar!/" />
</CLASSES> </CLASSES>
<JAVADOC /> <JAVADOC />
<SOURCES> <SOURCES>
<root url="jar://$MODULE_DIR$/../../import/craftbukkit-1.12.2.jar!/" /> <root url="jar://$MODULE_DIR$/../../import/craftbukkit-1.10.2-R0.1-SNAPSHOT-latest.jar!/" />
</SOURCES> </SOURCES>
</library> </library>
</orderEntry> </orderEntry>
@ -92,44 +70,33 @@
<orderEntry type="module-library"> <orderEntry type="module-library">
<library> <library>
<CLASSES> <CLASSES>
<root url="jar://$MODULE_DIR$/../../import/craftbukkit-1.10.2-R0.1-SNAPSHOT-latest.jar!/" /> <root url="jar://$MODULE_DIR$/../../import/craftbukkit-1.12.2.jar!/" />
</CLASSES> </CLASSES>
<JAVADOC /> <JAVADOC />
<SOURCES> <SOURCES>
<root url="jar://$MODULE_DIR$/../../import/craftbukkit-1.10.2-R0.1-SNAPSHOT-latest.jar!/" /> <root url="jar://$MODULE_DIR$/../../import/craftbukkit-1.12.2.jar!/" />
</SOURCES> </SOURCES>
</library> </library>
</orderEntry> </orderEntry>
<orderEntry type="module-library"> <orderEntry type="module-library">
<library> <library>
<CLASSES> <CLASSES>
<root url="jar://$MODULE_DIR$/../../import/craftbukkit-1.9.4-R0.1-SNAPSHOT-latest.jar!/" /> <root url="jar://$MODULE_DIR$/../../import/craftbukkit-1.13.2.jar!/" />
</CLASSES> </CLASSES>
<JAVADOC /> <JAVADOC />
<SOURCES> <SOURCES>
<root url="jar://$MODULE_DIR$/../../import/craftbukkit-1.9.4-R0.1-SNAPSHOT-latest.jar!/" /> <root url="jar://$MODULE_DIR$/../../import/craftbukkit-1.13.2.jar!/" />
</SOURCES> </SOURCES>
</library> </library>
</orderEntry> </orderEntry>
<orderEntry type="module-library"> <orderEntry type="module-library">
<library> <library>
<CLASSES> <CLASSES>
<root url="jar://$MODULE_DIR$/../../import/craftbukkit-1.8.8-R0.1-SNAPSHOT-latest.jar!/" /> <root url="jar://$MODULE_DIR$/../../import/craftbukkit-1.14.4-R0.1-SNAPSHOT.jar!/" />
</CLASSES> </CLASSES>
<JAVADOC /> <JAVADOC />
<SOURCES> <SOURCES>
<root url="jar://$MODULE_DIR$/../../import/craftbukkit-1.8.8-R0.1-SNAPSHOT-latest.jar!/" /> <root url="jar://$MODULE_DIR$/../../import/craftbukkit-1.14.4-R0.1-SNAPSHOT.jar!/" />
</SOURCES>
</library>
</orderEntry>
<orderEntry type="module-library">
<library>
<CLASSES>
<root url="jar://$MODULE_DIR$/../../import/craftbukkit-1.9.2-R0.1-SNAPSHOT-latest.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES>
<root url="jar://$MODULE_DIR$/../../import/craftbukkit-1.9.2-R0.1-SNAPSHOT-latest.jar!/" />
</SOURCES> </SOURCES>
</library> </library>
</orderEntry> </orderEntry>
@ -147,11 +114,33 @@
<orderEntry type="module-library"> <orderEntry type="module-library">
<library> <library>
<CLASSES> <CLASSES>
<root url="jar://$MODULE_DIR$/../../import/craftbukkit-1.16.1.jar!/" /> <root url="jar://$MODULE_DIR$/../../import/craftbukkit-1.16.2.jar!/" />
</CLASSES> </CLASSES>
<JAVADOC /> <JAVADOC />
<SOURCES> <SOURCES>
<root url="jar://$MODULE_DIR$/../../import/craftbukkit-1.16.1.jar!/" /> <root url="jar://$MODULE_DIR$/../../import/craftbukkit-1.16.2.jar!/" />
</SOURCES>
</library>
</orderEntry>
<orderEntry type="module-library">
<library>
<CLASSES>
<root url="jar://$MODULE_DIR$/../../import/craftbukkit-1.8.8-R0.1-SNAPSHOT-latest.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES>
<root url="jar://$MODULE_DIR$/../../import/craftbukkit-1.8.8-R0.1-SNAPSHOT-latest.jar!/" />
</SOURCES>
</library>
</orderEntry>
<orderEntry type="module-library">
<library>
<CLASSES>
<root url="jar://$MODULE_DIR$/../../import/craftbukkit-1.9.4-R0.1-SNAPSHOT-latest.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES>
<root url="jar://$MODULE_DIR$/../../import/craftbukkit-1.9.4-R0.1-SNAPSHOT-latest.jar!/" />
</SOURCES> </SOURCES>
</library> </library>
</orderEntry> </orderEntry>

View File

@ -1,6 +1,6 @@
name: SkPathfinderGoals name: SkStuff
authors: [TheBukor, Govindas] authors: [TheBukor, Govindas]
description: A Skript addon which adds extra functionalities such as pathfinder goals. description: A Skript addon which adds extra functionalities such as pathfinder goals.
version: "2.0" version: "2.2"
main: me.TheBukor.SkStuff.SkStuff main: me.TheBukor.SkStuff.SkStuff
softdepend: [Skript] depend: [Skript]

View File

@ -19,11 +19,6 @@ import javax.annotation.Nullable;
import java.io.IOException; import java.io.IOException;
public class SkStuff extends JavaPlugin { public class SkStuff extends JavaPlugin {
private int condAmount = 0;
private int effAmount = 0;
private int evtAmount = 0;
private int exprAmount = 0;
private int typeAmount = 0;
private static NMSInterface nmsMethods; private static NMSInterface nmsMethods;
@ -31,7 +26,7 @@ public class SkStuff extends JavaPlugin {
public void onEnable() { public void onEnable() {
if (Bukkit.getPluginManager().getPlugin("Skript") != null && Skript.isAcceptRegistrations()) { if (Bukkit.getPluginManager().getPlugin("Skript") != null && Skript.isAcceptRegistrations()) {
Skript.registerAddon(this); Skript.registerAddon(this);
getLogger().info("SkPathfinderGoals " + this.getDescription().getVersion() + " has been successfully enabled!"); getLogger().info("SkStuff " + this.getDescription().getVersion() + " has been successfully enabled!");
getLogger().info("Registering general non version specific stuff..."); getLogger().info("Registering general non version specific stuff...");
Skript.registerEffect(EffShowEntityEffect.class, "(display|play|show) entity effect (0¦firework[s] explo(de|sion)|1¦hurt|2¦[[iron] golem] (give|offer) (rose|poppy)|3¦[sheep] eat grass|4¦wolf shake|5¦squid rotate|6¦totem resurrect|7¦rabbit jump) (at|on) %entity%"); Skript.registerEffect(EffShowEntityEffect.class, "(display|play|show) entity effect (0¦firework[s] explo(de|sion)|1¦hurt|2¦[[iron] golem] (give|offer) (rose|poppy)|3¦[sheep] eat grass|4¦wolf shake|5¦squid rotate|6¦totem resurrect|7¦rabbit jump) (at|on) %entity%");
if (setupNMSVersion()) { if (setupNMSVersion()) {
@ -85,11 +80,15 @@ public class SkStuff extends JavaPlugin {
break; break;
case "v1_14_R1.": case "v1_14_R1.":
nmsMethods = new NMS_v1_14_R1(); nmsMethods = new NMS_v1_14_R1();
getLogger().info("It looks like you're running 1.14.2!"); getLogger().info("It looks like you're running 1.14.4!");
break; break;
case "v1_15_R1.": case "v1_15_R1.":
nmsMethods = new NMS_v1_15_R1(); nmsMethods = new NMS_v1_15_R1();
getLogger().info("It looks like you're running 1.15.1!"); getLogger().info("It looks like you're running 1.15.2!");
break;
case "v1_16_R2.":
nmsMethods = new NMS_v1_16_R2();
getLogger().info("It looks like you're running 1.16.3!");
break; 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 :(");
@ -103,6 +102,6 @@ public class SkStuff extends JavaPlugin {
} }
public void onDisable() { public void onDisable() {
getLogger().info("SkPathfinderGoals " + this.getDescription().getVersion() + " has been successfully disabled."); getLogger().info("SkStuff " + this.getDescription().getVersion() + " has been successfully disabled.");
} }
} }

View File

@ -7,6 +7,8 @@ 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.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;
@ -265,7 +267,7 @@ public final class EffSetPathGoal extends Effect {
newGoals.add(goalFollowAdults.getConstructor(entAnimal, double.class).newInstance(nmsEnt, spd)); newGoals.add(goalFollowAdults.getConstructor(entAnimal, double.class).newInstance(nmsEnt, spd));
} else if (mark == 8) { } else if (mark == 8) {
target = true; target = true;
boolean callHelp = (callForHelp == null ? false : callForHelp.getSingle(e)); boolean callHelp = (callForHelp != null && callForHelp.getSingle(e));
EntityData<?>[] types = typesToFightBack.getAll(e); EntityData<?>[] types = typesToFightBack.getAll(e);
List<Class<?>> typesClasses = new ArrayList<Class<?>>(); List<Class<?>> typesClasses = new ArrayList<Class<?>>();
for (EntityData<?> entData : types) { for (EntityData<?> entData : types) {
@ -327,7 +329,7 @@ public final class EffSetPathGoal extends Effect {
} }
} else { } else {
double spd = (meleeSpeed == null ? 1.0D : meleeSpeed.getSingle(e).doubleValue()); double spd = (meleeSpeed == null ? 1.0D : meleeSpeed.getSingle(e).doubleValue());
boolean memorize = (meleeMemorize == null ? false : meleeMemorize.getSingle(e)); boolean memorize = (meleeMemorize != null && meleeMemorize.getSingle(e));
Class<?> goalMeleeAttack = ReflectionUtils.getNMSClass("PathfinderGoalMeleeAttack"); Class<?> goalMeleeAttack = ReflectionUtils.getNMSClass("PathfinderGoalMeleeAttack");
newGoals.add(goalMeleeAttack.getConstructor(entCreature, double.class, boolean.class).newInstance(nmsEnt, spd, memorize)); newGoals.add(goalMeleeAttack.getConstructor(entCreature, double.class, boolean.class).newInstance(nmsEnt, spd, memorize));
} }
@ -354,7 +356,7 @@ public final class EffSetPathGoal extends Effect {
newGoals.add(ReflectionUtils.getConstructor(goalSpiderNearTarget, nmsEnt.getClass(), Class.class).newInstance(nmsEnt, nmsClass)); newGoals.add(ReflectionUtils.getConstructor(goalSpiderNearTarget, nmsEnt.getClass(), Class.class).newInstance(nmsEnt, nmsClass));
} }
} else { } else {
boolean checkView = (checkSight == null ? true : checkSight.getSingle(e)); boolean checkView = (checkSight == null || checkSight.getSingle(e));
Class<?> goalNearTarget = ReflectionUtils.getNMSClass("PathfinderGoalNearestAttackableTarget"); Class<?> goalNearTarget = ReflectionUtils.getNMSClass("PathfinderGoalNearestAttackableTarget");
for (EntityData<?> entData : types) { for (EntityData<?> entData : types) {
if (!LivingEntity.class.isAssignableFrom(entData.getType())) if (!LivingEntity.class.isAssignableFrom(entData.getType()))
@ -539,16 +541,21 @@ public final class EffSetPathGoal extends Effect {
} }
Class<?> nmsClass = ReflectionUtils.getNMSClass("Entity" + className); Class<?> nmsClass = ReflectionUtils.getNMSClass("Entity" + className);
switch (version) { switch (version) {
case "v1.12_R1.": //case "v1.12_R1.":
newGoals.add(new PathfinderGoalFollow_v1_12_R1((net.minecraft.server.v1_12_R1.EntityCreature) nmsEnt, nmsClass, radius, spd, usesName, customName)); // newGoals.add(new PathfinderGoalFollow_v1_12_R1((net.minecraft.server.v1_12_R1.EntityCreature) nmsEnt, nmsClass, radius, spd, usesName, customName));
break; // break;
case "v1.13_R2.": case "v1.13_R2.":
newGoals.add(new PathfinderGoalFollow_v1_13_R2((net.minecraft.server.v1_13_R2.EntityCreature) nmsEnt, nmsClass, radius, spd, usesName, customName)); newGoals.add(new PathfinderGoalFollow_v1_13_R2((net.minecraft.server.v1_13_R2.EntityCreature) nmsEnt, nmsClass, radius, spd, usesName, customName));
break; break;
case "v1.14_R1.": case "v1.14_R1.":
newGoals.add(new PathfinderGoalFollow_v1_14_R1((net.minecraft.server.v1_14_R1.EntityCreature) nmsEnt, nmsClass, radius, spd, usesName, customName)); newGoals.add(new PathfinderGoalFollow_v1_14_R1((net.minecraft.server.v1_14_R1.EntityCreature) nmsEnt, nmsClass, radius, spd, usesName, customName));
break; break;
} case "v1.15_R1.":
newGoals.add(new PathfinderGoalFollow_v1_15_R1((net.minecraft.server.v1_15_R1.EntityCreature) nmsEnt, nmsClass, radius, spd, usesName, customName));
break;
case "v1.16_R2.":
newGoals.add(new PathfinderGoalFollow_v1_16_R2((net.minecraft.server.v1_16_R2.EntityCreature) nmsEnt, nmsClass, radius, spd, usesName, customName));
break;
} }
} }
} else if (mark == 42) { } else if (mark == 42) {

View File

@ -1,10 +1,5 @@
package me.TheBukor.SkStuff.pathfinders; package me.TheBukor.SkStuff.pathfinders;
import me.TheBukor.SkStuff.util.ReflectionUtils;
import net.minecraft.server.v1_13_R2.*; import net.minecraft.server.v1_13_R2.*;
import java.lang.reflect.Field;
import java.util.LinkedHashSet;
import java.util.List; import java.util.List;
public class PathfinderGoalFollow_v1_13_R2 extends PathfinderGoal { public class PathfinderGoalFollow_v1_13_R2 extends PathfinderGoal {

View File

@ -1,13 +1,13 @@
package me.TheBukor.SkStuff.pathfinders; package me.TheBukor.SkStuff.pathfinders;
import net.minecraft.server.v1_16_R1.Entity; import net.minecraft.server.v1_16_R2.Entity;
import net.minecraft.server.v1_16_R1.EntityCreature; import net.minecraft.server.v1_16_R2.EntityCreature;
import net.minecraft.server.v1_16_R1.EntityLiving; import net.minecraft.server.v1_16_R2.EntityLiving;
import net.minecraft.server.v1_16_R1.PathfinderGoal; import net.minecraft.server.v1_16_R2.PathfinderGoal;
import java.util.List; import java.util.List;
public class PathfinderGoalFollow_v1_16_R1 extends PathfinderGoal { public class PathfinderGoalFollow_v1_16_R2 extends PathfinderGoal {
private EntityCreature follower; private EntityCreature follower;
private EntityLiving followed; private EntityLiving followed;
private Class<?> followedClass; private Class<?> followedClass;
@ -16,7 +16,7 @@ public class PathfinderGoalFollow_v1_16_R1 extends PathfinderGoal {
private boolean isByName; private boolean isByName;
private String customName; private String customName;
public PathfinderGoalFollow_v1_16_R1(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;
this.followedClass = followedClass; this.followedClass = followedClass;
this.radius = radius; this.radius = radius;

View File

@ -2,13 +2,14 @@ package me.TheBukor.SkStuff.util;
import net.minecraft.server.v1_14_R1.EntityInsentient; import net.minecraft.server.v1_14_R1.EntityInsentient;
import net.minecraft.server.v1_14_R1.BehaviorController;
import net.minecraft.server.v1_14_R1.PathfinderGoal; import net.minecraft.server.v1_14_R1.PathfinderGoal;
import net.minecraft.server.v1_14_R1.PathfinderGoalSelector; import net.minecraft.server.v1_14_R1.PathfinderGoalSelector;
import org.bukkit.craftbukkit.v1_14_R1.entity.CraftEntity; import org.bukkit.craftbukkit.v1_14_R1.entity.CraftEntity;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import java.util.Iterator; import java.lang.reflect.Field;
import java.util.LinkedHashSet; import java.util.*;
public class NMS_v1_14_R1 implements NMSInterface { public class NMS_v1_14_R1 implements NMSInterface {
@ -16,11 +17,46 @@ public class NMS_v1_14_R1 implements NMSInterface {
@Override @Override
public void clearPathfinderGoals(Entity entity) { public void clearPathfinderGoals(Entity entity) {
EntityInsentient nmsEnt = (EntityInsentient) ((CraftEntity) entity).getHandle(); EntityInsentient nmsEntity = (EntityInsentient) ((CraftEntity) entity).getHandle();
((LinkedHashSet<?>) ReflectionUtils.getField("b", PathfinderGoalSelector.class, nmsEnt.goalSelector)).clear(); PathfinderGoalSelector goalSelector = nmsEntity.goalSelector;
((LinkedHashSet<?>) ReflectionUtils.getField("c", PathfinderGoalSelector.class, nmsEnt.goalSelector)).clear(); PathfinderGoalSelector targetSelector = nmsEntity.targetSelector;
((LinkedHashSet<?>) ReflectionUtils.getField("b", PathfinderGoalSelector.class, nmsEnt.targetSelector)).clear(); try {
((LinkedHashSet<?>) ReflectionUtils.getField("c", PathfinderGoalSelector.class, nmsEnt.targetSelector)).clear(); BehaviorController<?> controller = nmsEntity.getBehaviorController();
Field memoriesField = BehaviorController.class.getDeclaredField("memories");
memoriesField.setAccessible(true);
memoriesField.set(controller, new HashMap<>());
Field sensorsField = BehaviorController.class.getDeclaredField("sensors");
sensorsField.setAccessible(true);
sensorsField.set(controller, new LinkedHashMap<>());
} catch (NoSuchFieldException | SecurityException | IllegalArgumentException | IllegalAccessException e) {
e.printStackTrace();
}
try {
Field dField;
dField = PathfinderGoalSelector.class.getDeclaredField("d");
dField.setAccessible(true);
dField.set(goalSelector, new LinkedHashSet<>());
dField.set(targetSelector, new LinkedHashSet<>());
Field cField;
cField = PathfinderGoalSelector.class.getDeclaredField("c");
cField.setAccessible(true);
dField.set(goalSelector, new LinkedHashSet<>());
cField.set(targetSelector, new EnumMap<>(net.minecraft.server.v1_16_R2.PathfinderGoal.Type.class));
Field fField;
fField = PathfinderGoalSelector.class.getDeclaredField("f");
fField.setAccessible(true);
dField.set(goalSelector, new LinkedHashSet<>());
fField.set(targetSelector, EnumSet.noneOf(PathfinderGoal.Type.class));
} catch (NoSuchFieldException | SecurityException | IllegalArgumentException | IllegalAccessException e) {
e.printStackTrace();
}
} }
@Override @Override

View File

@ -1,14 +1,15 @@
package me.TheBukor.SkStuff.util; package me.TheBukor.SkStuff.util;
import net.minecraft.server.v1_15_R1.BehaviorController;
import net.minecraft.server.v1_15_R1.EntityInsentient; import net.minecraft.server.v1_15_R1.EntityInsentient;
import net.minecraft.server.v1_15_R1.PathfinderGoal; import net.minecraft.server.v1_15_R1.PathfinderGoal;
import net.minecraft.server.v1_15_R1.PathfinderGoalSelector; import net.minecraft.server.v1_15_R1.PathfinderGoalSelector;
import org.bukkit.craftbukkit.v1_15_R1.entity.CraftEntity; import org.bukkit.craftbukkit.v1_15_R1.entity.CraftEntity;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import java.util.Iterator; import java.lang.reflect.Field;
import java.util.LinkedHashSet; import java.util.*;
public class NMS_v1_15_R1 implements NMSInterface { public class NMS_v1_15_R1 implements NMSInterface {
@ -16,11 +17,46 @@ public class NMS_v1_15_R1 implements NMSInterface {
@Override @Override
public void clearPathfinderGoals(Entity entity) { public void clearPathfinderGoals(Entity entity) {
EntityInsentient nmsEnt = (EntityInsentient) ((CraftEntity) entity).getHandle(); EntityInsentient nmsEntity = (EntityInsentient) ((CraftEntity) entity).getHandle();
((LinkedHashSet<?>) ReflectionUtils.getField("b", PathfinderGoalSelector.class, nmsEnt.goalSelector)).clear(); PathfinderGoalSelector goalSelector = nmsEntity.goalSelector;
((LinkedHashSet<?>) ReflectionUtils.getField("c", PathfinderGoalSelector.class, nmsEnt.goalSelector)).clear(); PathfinderGoalSelector targetSelector = nmsEntity.targetSelector;
((LinkedHashSet<?>) ReflectionUtils.getField("b", PathfinderGoalSelector.class, nmsEnt.targetSelector)).clear(); try {
((LinkedHashSet<?>) ReflectionUtils.getField("c", PathfinderGoalSelector.class, nmsEnt.targetSelector)).clear(); BehaviorController<?> controller = nmsEntity.getBehaviorController();
Field memoriesField = BehaviorController.class.getDeclaredField("memories");
memoriesField.setAccessible(true);
memoriesField.set(controller, new HashMap<>());
Field sensorsField = BehaviorController.class.getDeclaredField("sensors");
sensorsField.setAccessible(true);
sensorsField.set(controller, new LinkedHashMap<>());
} catch (NoSuchFieldException | SecurityException | IllegalArgumentException | IllegalAccessException e) {
e.printStackTrace();
}
try {
Field dField;
dField = PathfinderGoalSelector.class.getDeclaredField("d");
dField.setAccessible(true);
dField.set(goalSelector, new LinkedHashSet<>());
dField.set(targetSelector, new LinkedHashSet<>());
Field cField;
cField = PathfinderGoalSelector.class.getDeclaredField("c");
cField.setAccessible(true);
dField.set(goalSelector, new LinkedHashSet<>());
cField.set(targetSelector, new EnumMap<>(PathfinderGoal.Type.class));
Field fField;
fField = PathfinderGoalSelector.class.getDeclaredField("f");
fField.setAccessible(true);
dField.set(goalSelector, new LinkedHashSet<>());
fField.set(targetSelector, EnumSet.noneOf(PathfinderGoal.Type.class));
} catch (NoSuchFieldException | SecurityException | IllegalArgumentException | IllegalAccessException e) {
e.printStackTrace();
}
} }
@Override @Override

View File

@ -1,94 +0,0 @@
package me.TheBukor.SkStuff.util;
import net.minecraft.server.v1_16_R1.EntityInsentient;
import net.minecraft.server.v1_16_R1.PathfinderGoal;
import net.minecraft.server.v1_16_R1.PathfinderGoalSelector;
import org.bukkit.craftbukkit.v1_16_R1.entity.CraftEntity;
import org.bukkit.entity.Entity;
import java.util.Iterator;
import java.util.LinkedHashSet;
public class NMS_v1_16_R1 implements NMSInterface {
@Override
public void clearPathfinderGoals(Entity entity) {
EntityInsentient nmsEnt = (EntityInsentient) ((CraftEntity) entity).getHandle();
((LinkedHashSet<?>) ReflectionUtils.getField("b", PathfinderGoalSelector.class, nmsEnt.goalSelector)).clear();
((LinkedHashSet<?>) ReflectionUtils.getField("c", PathfinderGoalSelector.class, nmsEnt.goalSelector)).clear();
((LinkedHashSet<?>) ReflectionUtils.getField("b", PathfinderGoalSelector.class, nmsEnt.targetSelector)).clear();
((LinkedHashSet<?>) ReflectionUtils.getField("c", PathfinderGoalSelector.class, nmsEnt.targetSelector)).clear();
}
@Override
public void removePathfinderGoal(Object entity, Class<?> goalClass, boolean isTargetSelector) {
if (entity instanceof EntityInsentient) {
((EntityInsentient) entity).setGoalTarget(null);
if (isTargetSelector) {
Iterator<?> goals = ((LinkedHashSet<?>) ReflectionUtils.getField("b", PathfinderGoalSelector.class, ((EntityInsentient) entity).targetSelector)).iterator();
while (goals.hasNext()) {
Object goal = goals.next();
if (ReflectionUtils.getField("a", goal.getClass(), goal).getClass() == goalClass) {
goals.remove();
}
}
} else {
Iterator<?> goals = ((LinkedHashSet<?>) ReflectionUtils.getField("b", PathfinderGoalSelector.class, ((EntityInsentient) entity).goalSelector)).iterator();
while (goals.hasNext()) {
Object goal = goals.next();
if (ReflectionUtils.getField("a", goal.getClass(), goal).getClass() == goalClass) {
goals.remove();
}
}
}
}
}
@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_R1.Entity nmsEntity = ((CraftEntity) entity).getHandle();
return nmsEntity.noclip;
}
@Override
public void setNoClip(Entity entity, boolean noclip) {
net.minecraft.server.v1_16_R1.Entity nmsEntity = ((CraftEntity) entity).getHandle();
nmsEntity.noclip = noclip;
}
@Override
public boolean getFireProof(Entity entity) {
net.minecraft.server.v1_16_R1.Entity nmsEntity = ((CraftEntity) entity).getHandle();
return nmsEntity.isFireProof();
}
@Override
public void setFireProof(Entity entity, boolean fireProof) {
net.minecraft.server.v1_16_R1.Entity nmsEntity = ((CraftEntity) entity).getHandle();
ReflectionUtils.setField("fireProof", nmsEntity.getClass(), nmsEntity, fireProof);
}
public float getEntityStepLength(Entity entity) {
net.minecraft.server.v1_16_R1.Entity nmsEntity = ((CraftEntity) entity).getHandle();
return nmsEntity.G;
}
@Override
public void setEntityStepLength(Entity entity, float length) {
net.minecraft.server.v1_16_R1.Entity nmsEntity = ((CraftEntity) entity).getHandle();
nmsEntity.G = length;
}
}

View File

@ -0,0 +1,79 @@
package me.TheBukor.SkStuff.util;
import net.minecraft.server.v1_16_R2.EntityInsentient;
import net.minecraft.server.v1_16_R2.PathfinderGoal;
import net.minecraft.server.v1_16_R2.PathfinderGoalSelector;
import org.bukkit.Bukkit;
import org.bukkit.craftbukkit.v1_16_R2.entity.CraftEntity;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Mob;
import java.util.LinkedHashSet;
public class NMS_v1_16_R2 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_R2.Entity nmsEntity = ((CraftEntity) entity).getHandle();
return nmsEntity.noclip;
}
@Override
public void setNoClip(Entity entity, boolean noclip) {
net.minecraft.server.v1_16_R2.Entity nmsEntity = ((CraftEntity) entity).getHandle();
nmsEntity.noclip = noclip;
}
@Override
public boolean getFireProof(Entity entity) {
net.minecraft.server.v1_16_R2.Entity nmsEntity = ((CraftEntity) entity).getHandle();
return nmsEntity.isFireProof();
}
@Override
public void setFireProof(Entity entity, boolean fireProof) {
net.minecraft.server.v1_16_R2.Entity nmsEntity = ((CraftEntity) entity).getHandle();
ReflectionUtils.setField("fireProof", nmsEntity.getClass(), nmsEntity, fireProof);
}
public float getEntityStepLength(Entity entity) {
net.minecraft.server.v1_16_R2.Entity nmsEntity = ((CraftEntity) entity).getHandle();
return nmsEntity.G;
}
@Override
public void setEntityStepLength(Entity entity, float length) {
net.minecraft.server.v1_16_R2.Entity nmsEntity = ((CraftEntity) entity).getHandle();
nmsEntity.G = length;
}
}