diff --git a/.idea/compiler.xml b/.idea/compiler.xml
index 3068ac5..1ebe581 100644
--- a/.idea/compiler.xml
+++ b/.idea/compiler.xml
@@ -8,9 +8,11 @@
+
+
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index aa0aed9..eaec241 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -2,18 +2,25 @@
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -49,7 +56,7 @@
-
+
@@ -64,12 +71,32 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
+
+
+
+
+
+
+
@@ -104,6 +131,9 @@
+
+
+
@@ -133,61 +163,65 @@
-
+
-
+
-
+
-
+
-
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
+
+
+
+
+
-
+
-
+
@@ -204,5 +238,9 @@
+
+
+
+
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
index 126f2e1..fa0cfda 100644
--- a/pom.xml
+++ b/pom.xml
@@ -6,7 +6,7 @@
net.seanomik
tamablefoxes
- 1.5-SNAPSHOT
+ 1.5.1-SNAPSHOT
jar
Tamablefoxes
@@ -40,7 +40,7 @@
D:\Code\java\spigotPlugins\_TEST_SERVER_1.15.1_\plugins\TamableFoxes-MC-v1.15.1-v${project.version}.jar
-
+
false
@@ -74,7 +74,7 @@
org.spigotmc
spigot
- 1.15.1-R0.1-SNAPSHOT
+ 1.15.2-R0.1-SNAPSHOT
provided
diff --git a/src/main/java/net/seanomik/tamablefoxes/EntityTamableFox.java b/src/main/java/net/seanomik/tamablefoxes/EntityTamableFox.java
index 212b57b..439290b 100644
--- a/src/main/java/net/seanomik/tamablefoxes/EntityTamableFox.java
+++ b/src/main/java/net/seanomik/tamablefoxes/EntityTamableFox.java
@@ -3,7 +3,7 @@ package net.seanomik.tamablefoxes;
import com.mojang.datafixers.Dynamic;
import net.minecraft.server.v1_15_R1.*;
import net.seanomik.tamablefoxes.io.Config;
-import net.seanomik.tamablefoxes.pathfinding.*;
+import net.seanomik.tamablefoxes.versions.version_1_15.pathfinding.*;
import org.bukkit.ChatColor;
import org.bukkit.craftbukkit.v1_15_R1.inventory.CraftItemStack;
import org.bukkit.entity.Item;
diff --git a/src/main/java/net/seanomik/tamablefoxes/TamableFoxes.java b/src/main/java/net/seanomik/tamablefoxes/TamableFoxes.java
index 4431972..b109251 100644
--- a/src/main/java/net/seanomik/tamablefoxes/TamableFoxes.java
+++ b/src/main/java/net/seanomik/tamablefoxes/TamableFoxes.java
@@ -1,11 +1,11 @@
package net.seanomik.tamablefoxes;
import net.minecraft.server.v1_15_R1.*;
-import net.seanomik.tamablefoxes.command.CommandSpawnTamableFox;
+import net.seanomik.tamablefoxes.versions.version_1_15.command.CommandSpawnTamableFox;
import net.seanomik.tamablefoxes.io.Config;
import net.seanomik.tamablefoxes.io.LanguageConfig;
import net.seanomik.tamablefoxes.sqlite.SQLiteHandler;
-import net.seanomik.tamablefoxes.sqlite.SQLiteSetterGetter;
+import net.seanomik.tamablefoxes.versions.version_1_15.sqlite.SQLiteSetterGetter;
import net.wesjd.anvilgui.AnvilGUI;
import org.bukkit.*;
import org.bukkit.Material;
@@ -23,38 +23,44 @@ import org.bukkit.event.player.PlayerBedEnterEvent;
import org.bukkit.event.player.PlayerBedLeaveEvent;
import org.bukkit.event.player.PlayerInteractEntityEvent;
import org.bukkit.event.player.PlayerJoinEvent;
+import org.bukkit.event.world.ChunkLoadEvent;
import org.bukkit.event.world.WorldSaveEvent;
import org.bukkit.inventory.EquipmentSlot;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.plugin.java.JavaPlugin;
+import org.bukkit.scheduler.BukkitRunnable;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.util.ArrayList;
import java.util.List;
+import java.util.UUID;
import java.util.stream.Collectors;
-// @TODO: Add language.yml
-// Foxes will be loaded in as sitting, even if they weren't when the server was shutdown (sometimes)
+// @TODO:
+
+/* @CHANGELOG (1.5.1):
+ * Now loads on Linux
+ * Fixed a bug that would cause foxes to not be tamed after a server reboot
+ * Updated to 1.15.2
+ */
public final class TamableFoxes extends JavaPlugin implements Listener {
private static TamableFoxes plugin;
public List spawnedFoxes = new ArrayList<>();
public SQLiteSetterGetter sqLiteSetterGetter = new SQLiteSetterGetter();
- public SQLiteHandler sqLiteHandler;
+ public SQLiteHandler sqLiteHandler = new SQLiteHandler();
private boolean versionSupported = true;
@Override
public void onLoad() {
- sqLiteHandler = new SQLiteHandler(getDataFolder());
plugin = this;
LanguageConfig.getConfig().saveDefault();
String version = Bukkit.getServer().getClass().getPackage().getName();
-
if (!version.equals("org.bukkit.craftbukkit.v1_15_R1")) {
Bukkit.getServer().getConsoleSender().sendMessage(Utils.getPrefix() + ChatColor.RED + LanguageConfig.getUnsupportedMCVersionRegister());
versionSupported = false;
@@ -98,8 +104,6 @@ public final class TamableFoxes extends JavaPlugin implements Listener {
this.saveDefaultConfig();
getConfig().options().copyDefaults(true);
saveConfig();
-
- spawnedFoxes = sqLiteSetterGetter.loadFoxes();
}
@Override
@@ -113,6 +117,13 @@ public final class TamableFoxes extends JavaPlugin implements Listener {
sqLiteSetterGetter.saveFoxes(spawnedFoxes);
}
+ @EventHandler
+ public void onChunkLoad(ChunkLoadEvent event) {
+ Bukkit.getScheduler().runTaskLaterAsynchronously(this, ()-> {
+ spawnedFoxes.addAll(sqLiteSetterGetter.loadFoxes(event.getChunk()));
+ }, 5L);
+ }
+
@EventHandler
public void onPlayerJoin(PlayerJoinEvent event) {
Player player = event.getPlayer();
@@ -140,6 +151,8 @@ public final class TamableFoxes extends JavaPlugin implements Listener {
if (event.getHand() != EquipmentSlot.HAND) return;
+ player.sendMessage(entity.getUniqueId().toString());
+
ItemStack itemHand = player.getInventory().getItemInMainHand();
ItemMeta handMeta = itemHand.getItemMeta();
@@ -258,7 +271,7 @@ public final class TamableFoxes extends JavaPlugin implements Listener {
}
// Remove the fox from database
- sqLiteSetterGetter.removeFox(tamableFox);
+ //sqLiteSetterGetter.removeFox(tamableFox);
}
public EntityTamableFox spawnTamableFox(Location loc, EntityFox.Type type) {
diff --git a/src/main/java/net/seanomik/tamablefoxes/Utils.java b/src/main/java/net/seanomik/tamablefoxes/Utils.java
index ab95e56..b794a71 100644
--- a/src/main/java/net/seanomik/tamablefoxes/Utils.java
+++ b/src/main/java/net/seanomik/tamablefoxes/Utils.java
@@ -1,11 +1,16 @@
package net.seanomik.tamablefoxes;
+import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
+import org.bukkit.Chunk;
+import org.bukkit.World;
import org.bukkit.craftbukkit.v1_15_R1.entity.CraftEntity;
+import org.bukkit.entity.Entity;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.util.List;
+import java.util.UUID;
public class Utils {
@@ -83,4 +88,26 @@ public class Utils {
return null;
}
}
+
+ public static Entity getEntity(UUID uuid) {
+ for (World world : Bukkit.getServer().getWorlds()) {
+ for (Entity entity : world.getEntities()) {
+ if (entity.getUniqueId().equals(uuid)) {
+ return entity;
+ }
+ }
+ }
+
+ return null;
+ }
+
+ public static Entity getEntity(Chunk chunk, UUID uuid) {
+ for (Entity entity : chunk.getEntities()) {
+ if (entity.getUniqueId().equals(uuid)) {
+ return entity;
+ }
+ }
+
+ return null;
+ }
}
diff --git a/src/main/java/net/seanomik/tamablefoxes/sqlite/SQLiteHandler.java b/src/main/java/net/seanomik/tamablefoxes/sqlite/SQLiteHandler.java
index 5f8b35f..6caa8f4 100644
--- a/src/main/java/net/seanomik/tamablefoxes/sqlite/SQLiteHandler.java
+++ b/src/main/java/net/seanomik/tamablefoxes/sqlite/SQLiteHandler.java
@@ -1,24 +1,20 @@
package net.seanomik.tamablefoxes.sqlite;
+import net.seanomik.tamablefoxes.TamableFoxes;
+
import java.io.File;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
+import java.util.Properties;
public class SQLiteHandler {
private Connection connection;
- private File dataFolder;
-
- public SQLiteHandler(File dataFolder) {
- this.dataFolder = dataFolder;
- }
public void connect() {
try {
- String url = "jdbc:sqlite:/" + dataFolder.getAbsolutePath() + "/foxes.db";
+ String url = "jdbc:sqlite:" + TamableFoxes.getPlugin().getDataFolder() + "/foxes.db";
connection = DriverManager.getConnection(url);
-
- //Bukkit.getConsoleSender().sendMessage(TamableFoxes.getPrefix() + "Connection to SQLite has been established.");
} catch (SQLException e) {
e.printStackTrace();
}
diff --git a/src/main/java/net/seanomik/tamablefoxes/command/CommandSpawnTamableFox.java b/src/main/java/net/seanomik/tamablefoxes/versions/version_1_15/command/CommandSpawnTamableFox.java
similarity index 98%
rename from src/main/java/net/seanomik/tamablefoxes/command/CommandSpawnTamableFox.java
rename to src/main/java/net/seanomik/tamablefoxes/versions/version_1_15/command/CommandSpawnTamableFox.java
index 42a2bd9..0d4f7f5 100644
--- a/src/main/java/net/seanomik/tamablefoxes/command/CommandSpawnTamableFox.java
+++ b/src/main/java/net/seanomik/tamablefoxes/versions/version_1_15/command/CommandSpawnTamableFox.java
@@ -1,4 +1,4 @@
-package net.seanomik.tamablefoxes.command;
+package net.seanomik.tamablefoxes.versions.version_1_15.command;
import net.seanomik.tamablefoxes.EntityTamableFox;
import net.seanomik.tamablefoxes.TamableFoxes;
diff --git a/src/main/java/net/seanomik/tamablefoxes/pathfinding/FoxPathfinderGoalFollowOwner.java b/src/main/java/net/seanomik/tamablefoxes/versions/version_1_15/pathfinding/FoxPathfinderGoalFollowOwner.java
similarity index 98%
rename from src/main/java/net/seanomik/tamablefoxes/pathfinding/FoxPathfinderGoalFollowOwner.java
rename to src/main/java/net/seanomik/tamablefoxes/versions/version_1_15/pathfinding/FoxPathfinderGoalFollowOwner.java
index e4fd60c..de11343 100644
--- a/src/main/java/net/seanomik/tamablefoxes/pathfinding/FoxPathfinderGoalFollowOwner.java
+++ b/src/main/java/net/seanomik/tamablefoxes/versions/version_1_15/pathfinding/FoxPathfinderGoalFollowOwner.java
@@ -1,4 +1,4 @@
-package net.seanomik.tamablefoxes.pathfinding;
+package net.seanomik.tamablefoxes.versions.version_1_15.pathfinding;
import net.seanomik.tamablefoxes.EntityTamableFox;
import net.minecraft.server.v1_15_R1.*;
diff --git a/src/main/java/net/seanomik/tamablefoxes/pathfinding/FoxPathfinderGoalHurtByTarget.java b/src/main/java/net/seanomik/tamablefoxes/versions/version_1_15/pathfinding/FoxPathfinderGoalHurtByTarget.java
similarity index 98%
rename from src/main/java/net/seanomik/tamablefoxes/pathfinding/FoxPathfinderGoalHurtByTarget.java
rename to src/main/java/net/seanomik/tamablefoxes/versions/version_1_15/pathfinding/FoxPathfinderGoalHurtByTarget.java
index 2247077..1c8a65a 100644
--- a/src/main/java/net/seanomik/tamablefoxes/pathfinding/FoxPathfinderGoalHurtByTarget.java
+++ b/src/main/java/net/seanomik/tamablefoxes/versions/version_1_15/pathfinding/FoxPathfinderGoalHurtByTarget.java
@@ -1,4 +1,4 @@
-package net.seanomik.tamablefoxes.pathfinding;
+package net.seanomik.tamablefoxes.versions.version_1_15.pathfinding;
import net.seanomik.tamablefoxes.EntityTamableFox;
import net.minecraft.server.v1_15_R1.*;
diff --git a/src/main/java/net/seanomik/tamablefoxes/pathfinding/FoxPathfinderGoalMeleeAttack.java b/src/main/java/net/seanomik/tamablefoxes/versions/version_1_15/pathfinding/FoxPathfinderGoalMeleeAttack.java
similarity index 94%
rename from src/main/java/net/seanomik/tamablefoxes/pathfinding/FoxPathfinderGoalMeleeAttack.java
rename to src/main/java/net/seanomik/tamablefoxes/versions/version_1_15/pathfinding/FoxPathfinderGoalMeleeAttack.java
index 490a7f4..2845443 100644
--- a/src/main/java/net/seanomik/tamablefoxes/pathfinding/FoxPathfinderGoalMeleeAttack.java
+++ b/src/main/java/net/seanomik/tamablefoxes/versions/version_1_15/pathfinding/FoxPathfinderGoalMeleeAttack.java
@@ -1,4 +1,4 @@
-package net.seanomik.tamablefoxes.pathfinding;
+package net.seanomik.tamablefoxes.versions.version_1_15.pathfinding;
import net.minecraft.server.v1_15_R1.EntityLiving;
import net.minecraft.server.v1_15_R1.PathfinderGoalMeleeAttack;
diff --git a/src/main/java/net/seanomik/tamablefoxes/pathfinding/FoxPathfinderGoalOwnerHurtByTarget.java b/src/main/java/net/seanomik/tamablefoxes/versions/version_1_15/pathfinding/FoxPathfinderGoalOwnerHurtByTarget.java
similarity index 95%
rename from src/main/java/net/seanomik/tamablefoxes/pathfinding/FoxPathfinderGoalOwnerHurtByTarget.java
rename to src/main/java/net/seanomik/tamablefoxes/versions/version_1_15/pathfinding/FoxPathfinderGoalOwnerHurtByTarget.java
index 640e8ce..3555885 100644
--- a/src/main/java/net/seanomik/tamablefoxes/pathfinding/FoxPathfinderGoalOwnerHurtByTarget.java
+++ b/src/main/java/net/seanomik/tamablefoxes/versions/version_1_15/pathfinding/FoxPathfinderGoalOwnerHurtByTarget.java
@@ -1,4 +1,4 @@
-package net.seanomik.tamablefoxes.pathfinding;
+package net.seanomik.tamablefoxes.versions.version_1_15.pathfinding;
import net.seanomik.tamablefoxes.EntityTamableFox;
import net.minecraft.server.v1_15_R1.EntityLiving;
diff --git a/src/main/java/net/seanomik/tamablefoxes/pathfinding/FoxPathfinderGoalOwnerHurtTarget.java b/src/main/java/net/seanomik/tamablefoxes/versions/version_1_15/pathfinding/FoxPathfinderGoalOwnerHurtTarget.java
similarity index 96%
rename from src/main/java/net/seanomik/tamablefoxes/pathfinding/FoxPathfinderGoalOwnerHurtTarget.java
rename to src/main/java/net/seanomik/tamablefoxes/versions/version_1_15/pathfinding/FoxPathfinderGoalOwnerHurtTarget.java
index 0ebbf61..40168d9 100644
--- a/src/main/java/net/seanomik/tamablefoxes/pathfinding/FoxPathfinderGoalOwnerHurtTarget.java
+++ b/src/main/java/net/seanomik/tamablefoxes/versions/version_1_15/pathfinding/FoxPathfinderGoalOwnerHurtTarget.java
@@ -1,4 +1,4 @@
-package net.seanomik.tamablefoxes.pathfinding;
+package net.seanomik.tamablefoxes.versions.version_1_15.pathfinding;
import net.seanomik.tamablefoxes.EntityTamableFox;
import net.minecraft.server.v1_15_R1.EntityLiving;
diff --git a/src/main/java/net/seanomik/tamablefoxes/pathfinding/FoxPathfinderGoalPanic.java b/src/main/java/net/seanomik/tamablefoxes/versions/version_1_15/pathfinding/FoxPathfinderGoalPanic.java
similarity index 92%
rename from src/main/java/net/seanomik/tamablefoxes/pathfinding/FoxPathfinderGoalPanic.java
rename to src/main/java/net/seanomik/tamablefoxes/versions/version_1_15/pathfinding/FoxPathfinderGoalPanic.java
index 031895e..c42b2ac 100644
--- a/src/main/java/net/seanomik/tamablefoxes/pathfinding/FoxPathfinderGoalPanic.java
+++ b/src/main/java/net/seanomik/tamablefoxes/versions/version_1_15/pathfinding/FoxPathfinderGoalPanic.java
@@ -1,4 +1,4 @@
-package net.seanomik.tamablefoxes.pathfinding;
+package net.seanomik.tamablefoxes.versions.version_1_15.pathfinding;
import net.minecraft.server.v1_15_R1.EntityFox;
import net.minecraft.server.v1_15_R1.PathfinderGoalPanic;
diff --git a/src/main/java/net/seanomik/tamablefoxes/pathfinding/FoxPathfinderGoalSit.java b/src/main/java/net/seanomik/tamablefoxes/versions/version_1_15/pathfinding/FoxPathfinderGoalSit.java
similarity index 94%
rename from src/main/java/net/seanomik/tamablefoxes/pathfinding/FoxPathfinderGoalSit.java
rename to src/main/java/net/seanomik/tamablefoxes/versions/version_1_15/pathfinding/FoxPathfinderGoalSit.java
index 26b2a60..e682333 100644
--- a/src/main/java/net/seanomik/tamablefoxes/pathfinding/FoxPathfinderGoalSit.java
+++ b/src/main/java/net/seanomik/tamablefoxes/versions/version_1_15/pathfinding/FoxPathfinderGoalSit.java
@@ -1,4 +1,4 @@
-package net.seanomik.tamablefoxes.pathfinding;
+package net.seanomik.tamablefoxes.versions.version_1_15.pathfinding;
import net.seanomik.tamablefoxes.EntityTamableFox;
import net.minecraft.server.v1_15_R1.EntityLiving;
diff --git a/src/main/java/net/seanomik/tamablefoxes/sqlite/SQLiteSetterGetter.java b/src/main/java/net/seanomik/tamablefoxes/versions/version_1_15/sqlite/SQLiteSetterGetter.java
similarity index 64%
rename from src/main/java/net/seanomik/tamablefoxes/sqlite/SQLiteSetterGetter.java
rename to src/main/java/net/seanomik/tamablefoxes/versions/version_1_15/sqlite/SQLiteSetterGetter.java
index 5ff2b21..fb7ac87 100644
--- a/src/main/java/net/seanomik/tamablefoxes/sqlite/SQLiteSetterGetter.java
+++ b/src/main/java/net/seanomik/tamablefoxes/versions/version_1_15/sqlite/SQLiteSetterGetter.java
@@ -1,12 +1,17 @@
-package net.seanomik.tamablefoxes.sqlite;
+package net.seanomik.tamablefoxes.versions.version_1_15.sqlite;
import net.minecraft.server.v1_15_R1.EntityLiving;
import net.seanomik.tamablefoxes.EntityTamableFox;
import net.seanomik.tamablefoxes.TamableFoxes;
import net.seanomik.tamablefoxes.Utils;
import net.seanomik.tamablefoxes.io.LanguageConfig;
+import net.seanomik.tamablefoxes.sqlite.SQLiteHandler;
+import org.bukkit.Bukkit;
+import org.bukkit.ChatColor;
+import org.bukkit.Chunk;
import org.bukkit.OfflinePlayer;
import org.bukkit.craftbukkit.v1_15_R1.entity.CraftEntity;
+import org.bukkit.entity.Entity;
import java.sql.DatabaseMetaData;
import java.sql.PreparedStatement;
@@ -14,6 +19,8 @@ import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.*;
+// @TODO: Use try-with-resource instead of try-catch-finally
+
public class SQLiteSetterGetter {
public static TamableFoxes plugin;
public static SQLiteHandler sqLiteHandler;
@@ -39,17 +46,13 @@ public class SQLiteSetterGetter {
PreparedStatement statement = sqLiteHandler.getConnection().prepareStatement(foxesTable);
statement.executeUpdate();
- plugin.getServer().getConsoleSender().sendMessage(Utils.getPrefix() + LanguageConfig.getCreatedSQLDatabase());
+ plugin.getServer().getConsoleSender().sendMessage(Utils.getPrefix() + ChatColor.GREEN + LanguageConfig.getCreatedSQLDatabase());
}
} catch (SQLException e) {
e.printStackTrace();
} finally {
if (sqLiteHandler.getConnection() != null) {
- try {
- sqLiteHandler.getConnection().close();
- } catch (SQLException e) {
- e.printStackTrace();
- }
+ sqLiteHandler.closeConnection();
}
}
}
@@ -91,11 +94,7 @@ public class SQLiteSetterGetter {
e.printStackTrace();
} finally {
if (sqLiteHandler.getConnection() != null) {
- try {
- sqLiteHandler.getConnection().close();
- } catch (SQLException e) {
- e.printStackTrace();
- }
+ sqLiteHandler.closeConnection();
}
}
}
@@ -108,54 +107,64 @@ public class SQLiteSetterGetter {
}
}
- public List loadFoxes() {
+ public List loadFoxes(Chunk chunk) {
plugin = TamableFoxes.getPlugin(TamableFoxes.class);
- List toRemoveLater = new ArrayList<>();
+
+ // If there are no foxes then don't even start
+ List foxesInChunk = new ArrayList<>();
+ for (Entity entity : chunk.getEntities()) {
+ if (Utils.isTamableFox(entity)) {
+ foxesInChunk.add((EntityTamableFox) ((CraftEntity) entity).getHandle());
+ }
+ }
+
+ if (foxesInChunk.size() == 0) {
+ return new ArrayList<>();
+ }
+
try {
sqLiteHandler.connect();
- PreparedStatement statement = sqLiteHandler.getConnection().prepareStatement("SELECT * FROM foxes");
- ResultSet results = statement.executeQuery();
List spawnedFoxes = new ArrayList<>();
- while (results.next()) { // Loop through each row
- UUID entityUUID = UUID.fromString(results.getString("ENTITY_UUID"));
- String ownerUUIDString = results.getString("OWNER_UUID");
- String name = results.getString("NAME");
- boolean sitting = results.getInt("SITTING") == 1;
- boolean sleeping = results.getInt("SLEEPING") == 1;
- // If the entity is null, it doesn't exist anymore so remove it from database
- if (plugin.getServer().getEntity(entityUUID) == null) {
- toRemoveLater.add(entityUUID);
- continue;
- }
+ for (EntityTamableFox tamableFox : foxesInChunk) {
+ PreparedStatement statement = sqLiteHandler.getConnection().prepareStatement("SELECT * FROM foxes WHERE ENTITY_UUID=?");
+ statement.setString(1, tamableFox.getUniqueID().toString());
+ ResultSet results = statement.executeQuery();
- boolean tamed = false;
- EntityTamableFox tamableFox = (EntityTamableFox) ((CraftEntity) plugin.getServer().getEntity(entityUUID)).getHandle();
- if (!ownerUUIDString.equals("none")) {
- tamed = true;
+ if (results.next()) {
+ String ownerUUIDString = results.getString("OWNER_UUID");
+ String name = results.getString("NAME");
+ boolean sitting = results.getInt("SITTING") == 1;
+ boolean sleeping = results.getInt("SLEEPING") == 1;
- OfflinePlayer owner = plugin.getServer().getOfflinePlayer(UUID.fromString(ownerUUIDString));
- if (owner.isOnline()) {
- EntityLiving livingOwner = (EntityLiving) ((CraftEntity) owner).getHandle();
- tamableFox.setOwner(livingOwner);
+ boolean tamed = false;
+ if (!ownerUUIDString.equals("none")) {
+ tamed = true;
+
+ OfflinePlayer owner = plugin.getServer().getOfflinePlayer(UUID.fromString(ownerUUIDString));
+ if (owner.isOnline()) {
+ EntityLiving livingOwner = (EntityLiving) ((CraftEntity) owner).getHandle();
+ tamableFox.setOwner(livingOwner);
+ }
+
+ tamableFox.setOwnerUUID(owner.getUniqueId());
+ tamableFox.setTamed(true);
+ tamableFox.setChosenName(name);
}
- tamableFox.setOwnerUUID(owner.getUniqueId());
- tamableFox.setTamed(true);
- tamableFox.setChosenName(name);
- }
-
- // Fox may spawn standing if the server was closed while it was sitting.
- if (sitting) {
- if (tamed) {
+ if (sitting && tamed) {
tamableFox.setHardSitting(true);
+ } else if (sleeping) {
+ tamableFox.setSleeping(true);
+ } else { // Avoid the foxes getting stuck sitting down.
+ tamableFox.setSitting(false);
+ tamableFox.setSleeping(false);
}
- } else if (sleeping) {
- tamableFox.setSleeping(true);
- }
- spawnedFoxes.add(tamableFox);
+
+ spawnedFoxes.add(tamableFox);
+ }
}
return spawnedFoxes;
@@ -163,16 +172,7 @@ public class SQLiteSetterGetter {
e.printStackTrace();
} finally {
if (sqLiteHandler.getConnection() != null) {
- try {
- sqLiteHandler.getConnection().close();
- } catch (SQLException e) {
- e.printStackTrace();
- }
- }
-
- // Remove those to remove later UUIDs
- for (UUID uuid : toRemoveLater) {
- removeFox(uuid);
+ sqLiteHandler.closeConnection();
}
}
return null;
@@ -189,11 +189,7 @@ public class SQLiteSetterGetter {
e.printStackTrace();
} finally {
if (sqLiteHandler.getConnection() != null) {
- try {
- sqLiteHandler.getConnection().close();
- } catch (SQLException e) {
- e.printStackTrace();
- }
+ sqLiteHandler.closeConnection();
}
}
}
diff --git a/src/main/resources/language.yml b/src/main/resources/language.yml
index ea870ea..5c30c9a 100644
--- a/src/main/resources/language.yml
+++ b/src/main/resources/language.yml
@@ -1,5 +1,5 @@
-unsupported-mc-version-not-registering: "ERROR: This plugin version only supports 1.15.1! Not registering entity!"
-unsupported-mc-version-disabling: "This plugin version only supports 1.15.1! Disabling plugin!"
+unsupported-mc-version-not-registering: "ERROR: This plugin version only supports Spigot 1.15.1, currently not Paper! Not registering entity!"
+unsupported-mc-version-disabling: "This plugin version only supports Spigot 1.15.1, currently not Paper! Disabling plugin!"
success-replaced-entity: "Replaced tamable fox entity!"
error-to-replaced-entity: "Failed to replace tamable fox entity!"
diff --git a/target/classes/plugin.yml b/target/classes/plugin.yml
index 131cbf2..a3c149c 100644
--- a/target/classes/plugin.yml
+++ b/target/classes/plugin.yml
@@ -1,10 +1,8 @@
name: Tamablefoxes
-version: 1.5-SNAPSHOT
+version: 1.5.1-SNAPSHOT
main: net.seanomik.tamablefoxes.TamableFoxes
api-version: 1.15
-#load: STARTUP
load: POSTWORLD
-#load: STARTUP
description: Adds tamable foxes to Minecraft!
commands:
diff --git a/target/maven-archiver/pom.properties b/target/maven-archiver/pom.properties
index 39e6256..8f162d7 100644
--- a/target/maven-archiver/pom.properties
+++ b/target/maven-archiver/pom.properties
@@ -1,5 +1,5 @@
#Generated by Maven
-#Wed Jan 22 08:36:01 CST 2020
-version=1.5-SNAPSHOT
+#Sun Jan 26 14:51:19 CST 2020
+version=1.5.1-SNAPSHOT
groupId=net.seanomik
artifactId=tamablefoxes
diff --git a/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst b/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst
index 7a0f253..4e44b00 100644
--- a/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst
+++ b/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst
@@ -1,16 +1,16 @@
net\seanomik\tamablefoxes\EntityTamableFox.class
-net\seanomik\tamablefoxes\command\CommandSpawnTamableFox.class
-net\seanomik\tamablefoxes\pathfinding\FoxPathfinderGoalSit.class
-net\seanomik\tamablefoxes\sqlite\SQLiteSetterGetter.class
-net\seanomik\tamablefoxes\io\LanguageConfig.class
-net\seanomik\tamablefoxes\pathfinding\FoxPathfinderGoalPanic.class
-net\seanomik\tamablefoxes\pathfinding\FoxPathfinderGoalOwnerHurtTarget.class
-net\seanomik\tamablefoxes\pathfinding\FoxPathfinderGoalMeleeAttack.class
-net\seanomik\tamablefoxes\pathfinding\FoxPathfinderGoalOwnerHurtByTarget.class
-net\seanomik\tamablefoxes\pathfinding\FoxPathfinderGoalFollowOwner.class
+net\seanomik\tamablefoxes\versions\version_1_15\pathfinding\FoxPathfinderGoalMeleeAttack.class
+net\seanomik\tamablefoxes\versions\version_1_15\pathfinding\FoxPathfinderGoalPanic.class
+net\seanomik\tamablefoxes\versions\version_1_15\pathfinding\FoxPathfinderGoalHurtByTarget.class
net\seanomik\tamablefoxes\sqlite\SQLiteHandler.class
+net\seanomik\tamablefoxes\versions\version_1_15\pathfinding\FoxPathfinderGoalFollowOwner.class
net\seanomik\tamablefoxes\TamableFoxes.class
net\seanomik\tamablefoxes\EntityTamableFox$UpdateFoxRunnable.class
-net\seanomik\tamablefoxes\pathfinding\FoxPathfinderGoalHurtByTarget.class
+net\seanomik\tamablefoxes\versions\version_1_15\pathfinding\FoxPathfinderGoalSit.class
+net\seanomik\tamablefoxes\versions\version_1_15\command\CommandSpawnTamableFox.class
+net\seanomik\tamablefoxes\versions\version_1_15\pathfinding\FoxPathfinderGoalOwnerHurtByTarget.class
+net\seanomik\tamablefoxes\versions\version_1_15\pathfinding\FoxPathfinderGoalOwnerHurtTarget.class
+net\seanomik\tamablefoxes\io\LanguageConfig.class
+net\seanomik\tamablefoxes\versions\version_1_15\sqlite\SQLiteSetterGetter.class
net\seanomik\tamablefoxes\Utils.class
net\seanomik\tamablefoxes\io\Config.class
diff --git a/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst b/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst
index e99918a..6532bea 100644
--- a/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst
+++ b/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst
@@ -1,15 +1,15 @@
-D:\Code\java\spigotPlugins\myPlugins\GitTamableFoxes\src\main\java\net\seanomik\tamablefoxes\pathfinding\FoxPathfinderGoalHurtByTarget.java
-D:\Code\java\spigotPlugins\myPlugins\GitTamableFoxes\src\main\java\net\seanomik\tamablefoxes\pathfinding\FoxPathfinderGoalOwnerHurtByTarget.java
-D:\Code\java\spigotPlugins\myPlugins\GitTamableFoxes\src\main\java\net\seanomik\tamablefoxes\command\CommandSpawnTamableFox.java
-D:\Code\java\spigotPlugins\myPlugins\GitTamableFoxes\src\main\java\net\seanomik\tamablefoxes\TamableFoxes.java
-D:\Code\java\spigotPlugins\myPlugins\GitTamableFoxes\src\main\java\net\seanomik\tamablefoxes\io\Config.java
-D:\Code\java\spigotPlugins\myPlugins\GitTamableFoxes\src\main\java\net\seanomik\tamablefoxes\Utils.java
-D:\Code\java\spigotPlugins\myPlugins\GitTamableFoxes\src\main\java\net\seanomik\tamablefoxes\pathfinding\FoxPathfinderGoalSit.java
-D:\Code\java\spigotPlugins\myPlugins\GitTamableFoxes\src\main\java\net\seanomik\tamablefoxes\EntityTamableFox.java
-D:\Code\java\spigotPlugins\myPlugins\GitTamableFoxes\src\main\java\net\seanomik\tamablefoxes\pathfinding\FoxPathfinderGoalOwnerHurtTarget.java
-D:\Code\java\spigotPlugins\myPlugins\GitTamableFoxes\src\main\java\net\seanomik\tamablefoxes\sqlite\SQLiteHandler.java
-D:\Code\java\spigotPlugins\myPlugins\GitTamableFoxes\src\main\java\net\seanomik\tamablefoxes\sqlite\SQLiteSetterGetter.java
-D:\Code\java\spigotPlugins\myPlugins\GitTamableFoxes\src\main\java\net\seanomik\tamablefoxes\pathfinding\FoxPathfinderGoalFollowOwner.java
-D:\Code\java\spigotPlugins\myPlugins\GitTamableFoxes\src\main\java\net\seanomik\tamablefoxes\pathfinding\FoxPathfinderGoalMeleeAttack.java
-D:\Code\java\spigotPlugins\myPlugins\GitTamableFoxes\src\main\java\net\seanomik\tamablefoxes\pathfinding\FoxPathfinderGoalPanic.java
-D:\Code\java\spigotPlugins\myPlugins\GitTamableFoxes\src\main\java\net\seanomik\tamablefoxes\io\LanguageConfig.java
+D:\Code\java\spigotPlugins\myPlugins\TamableFoxes\src\main\java\net\seanomik\tamablefoxes\versions\version_1_15\pathfinding\FoxPathfinderGoalHurtByTarget.java
+D:\Code\java\spigotPlugins\myPlugins\TamableFoxes\src\main\java\net\seanomik\tamablefoxes\versions\version_1_15\pathfinding\FoxPathfinderGoalPanic.java
+D:\Code\java\spigotPlugins\myPlugins\TamableFoxes\src\main\java\net\seanomik\tamablefoxes\versions\version_1_15\pathfinding\FoxPathfinderGoalOwnerHurtByTarget.java
+D:\Code\java\spigotPlugins\myPlugins\TamableFoxes\src\main\java\net\seanomik\tamablefoxes\sqlite\SQLiteHandler.java
+D:\Code\java\spigotPlugins\myPlugins\TamableFoxes\src\main\java\net\seanomik\tamablefoxes\versions\version_1_15\command\CommandSpawnTamableFox.java
+D:\Code\java\spigotPlugins\myPlugins\TamableFoxes\src\main\java\net\seanomik\tamablefoxes\versions\version_1_15\pathfinding\FoxPathfinderGoalSit.java
+D:\Code\java\spigotPlugins\myPlugins\TamableFoxes\src\main\java\net\seanomik\tamablefoxes\Utils.java
+D:\Code\java\spigotPlugins\myPlugins\TamableFoxes\src\main\java\net\seanomik\tamablefoxes\versions\version_1_15\pathfinding\FoxPathfinderGoalFollowOwner.java
+D:\Code\java\spigotPlugins\myPlugins\TamableFoxes\src\main\java\net\seanomik\tamablefoxes\TamableFoxes.java
+D:\Code\java\spigotPlugins\myPlugins\TamableFoxes\src\main\java\net\seanomik\tamablefoxes\io\Config.java
+D:\Code\java\spigotPlugins\myPlugins\TamableFoxes\src\main\java\net\seanomik\tamablefoxes\versions\version_1_15\pathfinding\FoxPathfinderGoalOwnerHurtTarget.java
+D:\Code\java\spigotPlugins\myPlugins\TamableFoxes\src\main\java\net\seanomik\tamablefoxes\versions\version_1_15\sqlite\SQLiteSetterGetter.java
+D:\Code\java\spigotPlugins\myPlugins\TamableFoxes\src\main\java\net\seanomik\tamablefoxes\versions\version_1_15\pathfinding\FoxPathfinderGoalMeleeAttack.java
+D:\Code\java\spigotPlugins\myPlugins\TamableFoxes\src\main\java\net\seanomik\tamablefoxes\EntityTamableFox.java
+D:\Code\java\spigotPlugins\myPlugins\TamableFoxes\src\main\java\net\seanomik\tamablefoxes\io\LanguageConfig.java