Fixes #32. Kinda hacky but will work for now

This commit is contained in:
SeanOMik 2021-02-24 19:53:11 -06:00
parent 71bfc365c5
commit 8ba7d983cf
No known key found for this signature in database
GPG Key ID: CA09E5BE1F32728A
8 changed files with 58 additions and 16 deletions

View File

@ -6,7 +6,7 @@
<groupId>net.seanomik</groupId> <groupId>net.seanomik</groupId>
<artifactId>tamablefoxes</artifactId> <artifactId>tamablefoxes</artifactId>
<version>1.8-SNAPSHOT</version> <version>1.8.1-SNAPSHOT</version>
<packaging>jar</packaging> <packaging>jar</packaging>
<name>Tamablefoxes</name> <name>Tamablefoxes</name>
@ -46,7 +46,8 @@
<!--<outputFile>D:\Code\java\spigotPlugins\_TEST_SERVER_1.16.2_\plugins\TamableFoxes_v${project.version}.jar</outputFile>--> <!--<outputFile>D:\Code\java\spigotPlugins\_TEST_SERVER_1.16.2_\plugins\TamableFoxes_v${project.version}.jar</outputFile>-->
<!--<outputFile>D:\Code\java\spigotPlugins\_TEST_SERVER_PAPER_1.16.2_\plugins\TamableFoxes_v${project.version}.jar</outputFile>--> <!--<outputFile>D:\Code\java\spigotPlugins\_TEST_SERVER_PAPER_1.16.2_\plugins\TamableFoxes_v${project.version}.jar</outputFile>-->
<!--<outputFile>D:\Code\java\spigotPlugins\_TEST_SERVER_1.16.3_\plugins\TamableFoxes_v${project.version}.jar</outputFile>--> <!--<outputFile>D:\Code\java\spigotPlugins\_TEST_SERVER_1.16.3_\plugins\TamableFoxes_v${project.version}.jar</outputFile>-->
<outputFile>D:\Code\java\spigotPlugins\_TEST_SERVER_1.16.4_\plugins\TamableFoxes_v${project.version}.jar</outputFile> <!--<outputFile>D:\Code\java\spigotPlugins\_TEST_SERVER_1.16.4_\plugins\TamableFoxes_v${project.version}.jar</outputFile>-->
<outputFile>D:\Code\java\spigotPlugins\_TEST_SERVER_PAPER_1.16.4_\plugins\TamableFoxes_v${project.version}.jar</outputFile>
<createDependencyReducedPom>false</createDependencyReducedPom> <createDependencyReducedPom>false</createDependencyReducedPom>
</configuration> </configuration>
</execution> </execution>

View File

@ -16,8 +16,8 @@ import org.bukkit.plugin.java.JavaPlugin;
// @TODO: // @TODO:
/* @CHANGELOG (1.7.9-SNAPSHOT): /* @CHANGELOG (1.8.1-SNAPSHOT):
* Fix some crashes and errors with the sqlite database failing to be found. * Fixes #32. Kinda hacky but will work for now
*/ */
public final class TamableFoxes extends JavaPlugin implements Listener { public final class TamableFoxes extends JavaPlugin implements Listener {
private static TamableFoxes plugin; private static TamableFoxes plugin;
@ -52,6 +52,7 @@ public final class TamableFoxes extends JavaPlugin implements Listener {
break; break;
default: default:
Bukkit.getServer().getConsoleSender().sendMessage(Utils.getPrefix() + ChatColor.RED + LanguageConfig.getUnsupportedMCVersionRegister()); Bukkit.getServer().getConsoleSender().sendMessage(Utils.getPrefix() + ChatColor.RED + LanguageConfig.getUnsupportedMCVersionRegister());
Bukkit.getServer().getConsoleSender().sendMessage(Utils.getPrefix() + ChatColor.RED + "You're trying to run MC version " + version + " which is not supported!");
versionSupported = false; versionSupported = false;
return; return;
} }

View File

@ -1,8 +1,10 @@
package net.seanomik.tamablefoxes.versions.version_1_14_R1.pathfinding; package net.seanomik.tamablefoxes.versions.version_1_14_R1.pathfinding;
import net.seanomik.tamablefoxes.TamableFoxes;
import net.seanomik.tamablefoxes.versions.version_1_14_R1.EntityTamableFox; import net.seanomik.tamablefoxes.versions.version_1_14_R1.EntityTamableFox;
import net.minecraft.server.v1_14_R1.EntityLiving; import net.minecraft.server.v1_14_R1.EntityLiving;
import net.minecraft.server.v1_14_R1.PathfinderGoal; import net.minecraft.server.v1_14_R1.PathfinderGoal;
import org.bukkit.Bukkit;
import java.util.EnumSet; import java.util.EnumSet;
@ -34,7 +36,12 @@ public class FoxPathfinderGoalSit extends PathfinderGoal {
public void c() { public void c() {
this.entity.getNavigation().o(); this.entity.getNavigation().o();
this.entity.setGoalTarget(null);
// For some reason it needs to be ran later.
Bukkit.getScheduler().runTaskLater(TamableFoxes.getPlugin(), () -> {
this.entity.setSitting(true); this.entity.setSitting(true);
}, 1L);
} }
public void d() { public void d() {

View File

@ -1,8 +1,10 @@
package net.seanomik.tamablefoxes.versions.version_1_15_R1.pathfinding; package net.seanomik.tamablefoxes.versions.version_1_15_R1.pathfinding;
import net.seanomik.tamablefoxes.TamableFoxes;
import net.seanomik.tamablefoxes.versions.version_1_15_R1.EntityTamableFox; import net.seanomik.tamablefoxes.versions.version_1_15_R1.EntityTamableFox;
import net.minecraft.server.v1_15_R1.EntityLiving; import net.minecraft.server.v1_15_R1.EntityLiving;
import net.minecraft.server.v1_15_R1.PathfinderGoal; import net.minecraft.server.v1_15_R1.PathfinderGoal;
import org.bukkit.Bukkit;
import java.util.EnumSet; import java.util.EnumSet;
@ -35,7 +37,12 @@ public class FoxPathfinderGoalSit extends PathfinderGoal {
public void c() { public void c() {
this.entity.getNavigation().o(); this.entity.getNavigation().o();
this.entity.setGoalTarget(null);
// For some reason it needs to be ran later.
Bukkit.getScheduler().runTaskLater(TamableFoxes.getPlugin(), () -> {
this.entity.setSitting(true); this.entity.setSitting(true);
}, 1L);
} }
public void d() { public void d() {

View File

@ -2,7 +2,9 @@ package net.seanomik.tamablefoxes.versions.version_1_16_R1.pathfinding;
import net.minecraft.server.v1_16_R1.PathfinderGoal; import net.minecraft.server.v1_16_R1.PathfinderGoal;
import net.minecraft.server.v1_16_R1.EntityLiving; import net.minecraft.server.v1_16_R1.EntityLiving;
import net.seanomik.tamablefoxes.TamableFoxes;
import net.seanomik.tamablefoxes.versions.version_1_16_R1.EntityTamableFox; import net.seanomik.tamablefoxes.versions.version_1_16_R1.EntityTamableFox;
import org.bukkit.Bukkit;
import java.util.EnumSet; import java.util.EnumSet;
@ -28,13 +30,18 @@ public class FoxPathfinderGoalSit extends PathfinderGoal {
return false; return false;
} else { } else {
EntityLiving entityliving = this.entity.getOwner(); EntityLiving entityliving = this.entity.getOwner();
return entityliving == null ? true : (this.entity.h(entityliving) < 144.0D && entityliving.getLastDamager() != null ? false : this.willSit); // this.entity.isWillSit() return entityliving == null || ((!(this.entity.h(entityliving) < 144.0D) || entityliving.getLastDamager() == null) && this.willSit); // this.entity.isWillSit()
} }
} }
public void c() { public void c() {
this.entity.getNavigation().o(); this.entity.getNavigation().o();
this.entity.setGoalTarget(null);
// For some reason it needs to be ran later.
Bukkit.getScheduler().runTaskLater(TamableFoxes.getPlugin(), () -> {
this.entity.setSitting(true); this.entity.setSitting(true);
}, 1L);
} }
public void d() { public void d() {

View File

@ -2,7 +2,9 @@ package net.seanomik.tamablefoxes.versions.version_1_16_R2.pathfinding;
import net.minecraft.server.v1_16_R2.EntityLiving; import net.minecraft.server.v1_16_R2.EntityLiving;
import net.minecraft.server.v1_16_R2.PathfinderGoal; import net.minecraft.server.v1_16_R2.PathfinderGoal;
import net.seanomik.tamablefoxes.TamableFoxes;
import net.seanomik.tamablefoxes.versions.version_1_16_R2.EntityTamableFox; import net.seanomik.tamablefoxes.versions.version_1_16_R2.EntityTamableFox;
import org.bukkit.Bukkit;
import java.util.EnumSet; import java.util.EnumSet;
@ -28,13 +30,18 @@ public class FoxPathfinderGoalSit extends PathfinderGoal {
return false; return false;
} else { } else {
EntityLiving entityliving = this.entity.getOwner(); EntityLiving entityliving = this.entity.getOwner();
return entityliving == null ? true : (this.entity.h(entityliving) < 144.0D && entityliving.getLastDamager() != null ? false : this.willSit); // this.entity.isWillSit() return entityliving == null || ((!(this.entity.h(entityliving) < 144.0D) || entityliving.getLastDamager() == null) && this.willSit); // this.entity.isWillSit()
} }
} }
public void c() { public void c() {
this.entity.getNavigation().o(); this.entity.getNavigation().o();
this.entity.setGoalTarget(null);
// For some reason it needs to be ran later.
Bukkit.getScheduler().runTaskLater(TamableFoxes.getPlugin(), () -> {
this.entity.setSitting(true); this.entity.setSitting(true);
}, 1L);
} }
public void d() { public void d() {

View File

@ -2,9 +2,16 @@ package net.seanomik.tamablefoxes.versions.version_1_16_R3.pathfinding;
import net.minecraft.server.v1_16_R3.EntityLiving; import net.minecraft.server.v1_16_R3.EntityLiving;
import net.minecraft.server.v1_16_R3.PathfinderGoal; import net.minecraft.server.v1_16_R3.PathfinderGoal;
import net.minecraft.server.v1_16_R3.Vec3D;
import net.seanomik.tamablefoxes.TamableFoxes;
import net.seanomik.tamablefoxes.versions.version_1_16_R3.EntityTamableFox; import net.seanomik.tamablefoxes.versions.version_1_16_R3.EntityTamableFox;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.util.Vector;
import java.util.EnumSet; import java.util.EnumSet;
import java.util.LinkedList;
import java.util.List;
public class FoxPathfinderGoalSit extends PathfinderGoal { public class FoxPathfinderGoalSit extends PathfinderGoal {
private final EntityTamableFox entity; private final EntityTamableFox entity;
@ -17,24 +24,29 @@ public class FoxPathfinderGoalSit extends PathfinderGoal {
public boolean b() { public boolean b() {
return this.willSit; return this.willSit;
} // return this.entity.isWillSit(); }
public boolean a() { public boolean a() {
if (!this.entity.isTamed()) { if (!this.entity.isTamed()) {
return this.willSit && this.entity.getGoalTarget() == null; // this.entity.isWillSit() return this.willSit && this.entity.getGoalTarget() == null;
} else if (this.entity.aG()) { } else if (this.entity.aG()) {
return false; return false;
} else if (!this.entity.isOnGround()) { } else if (!this.entity.isOnGround()) {
return false; return false;
} else { } else {
EntityLiving entityliving = this.entity.getOwner(); EntityLiving entityliving = this.entity.getOwner();
return entityliving == null ? true : (this.entity.h(entityliving) < 144.0D && entityliving.getLastDamager() != null ? false : this.willSit); // this.entity.isWillSit() return entityliving == null || ((!(this.entity.h(entityliving) < 144.0D) || entityliving.getLastDamager() == null) && this.willSit);
} }
} }
public void c() { public void c() {
this.entity.getNavigation().o(); this.entity.getNavigation().o();
this.entity.setGoalTarget(null);
// For some reason it needs to be ran later.
Bukkit.getScheduler().runTaskLater(TamableFoxes.getPlugin(), () -> {
this.entity.setSitting(true); this.entity.setSitting(true);
}, 1L);
} }
public void d() { public void d() {

View File

@ -1,6 +1,6 @@
mc-version-loading: "Registering entity for MC Version %MC_VERSION%..." mc-version-loading: "Registering entity for MC Version %MC_VERSION%..."
unsupported-mc-version-not-registering: "ERROR: This plugin version only supports Spigot 1.15.X! Not registering entity! Make sure your Java version is no newer than Java 11!" unsupported-mc-version-not-registering: "ERROR: This plugin version only supports Spigot 1.14-1.16.4! Not registering entity! Make sure your Java version is no newer than Java 11!"
unsupported-mc-version-disabling: "This plugin version only supports Spigot 1.14-1.16.2! Disabling plugin! Make sure your Java version is no newer than Java 11!" unsupported-mc-version-disabling: "This plugin version only supports Spigot 1.14-1.16.4! Disabling plugin! Make sure your Java version is no newer than Java 11!"
success-replaced-entity: "Replaced tamable fox entity!" success-replaced-entity: "Replaced tamable fox entity!"
error-to-replaced-entity: "Failed to replace tamable fox entity!" error-to-replaced-entity: "Failed to replace tamable fox entity!"
saving-foxes-message: "Saving foxes." saving-foxes-message: "Saving foxes."