Continue work on a better saving and loading

This commit is contained in:
SeanOMik 2020-01-20 22:37:42 -06:00
parent 649ad02758
commit 8e731078d0
No known key found for this signature in database
GPG Key ID: FA4D55AC05268A88
26 changed files with 383 additions and 224 deletions

View File

@ -2,15 +2,43 @@
<project version="4">
<component name="ChangeListManager">
<list default="true" id="dcab9632-7b1a-44d7-9283-be9b37640afc" name="Default Changelist" comment="">
<change afterPath="$PROJECT_DIR$/src/main/java/net/seanomik/tamablefoxes/sqlite/SQLiteHandler.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/main/java/net/seanomik/tamablefoxes/sqlite/SQLiteSetterGetter.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pom.xml" beforeDir="false" afterPath="$PROJECT_DIR$/pom.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/net/seanomilk/tamablefoxes/TamableFoxes.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/net/seanomilk/tamablefoxes/TamableFoxes.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/net/seanomilk/tamablefoxes/EntityTamableFox.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/net/seanomik/tamablefoxes/EntityTamableFox.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/net/seanomilk/tamablefoxes/TamableFoxes.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/net/seanomik/tamablefoxes/TamableFoxes.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/net/seanomilk/tamablefoxes/command/CommandSpawnTamableFox.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/net/seanomik/tamablefoxes/command/CommandSpawnTamableFox.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/net/seanomilk/tamablefoxes/io/FileManager.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/net/seanomik/tamablefoxes/io/FileManager.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/net/seanomilk/tamablefoxes/pathfinding/FoxPathfindGoalBeg.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/net/seanomik/tamablefoxes/pathfinding/FoxPathfindGoalBeg.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/net/seanomilk/tamablefoxes/pathfinding/FoxPathfindGoalBreed.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/net/seanomik/tamablefoxes/pathfinding/FoxPathfindGoalBreed.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/net/seanomilk/tamablefoxes/pathfinding/FoxPathfindGoalFleeSun.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/net/seanomik/tamablefoxes/pathfinding/FoxPathfindGoalFleeSun.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/net/seanomilk/tamablefoxes/pathfinding/FoxPathfindGoalFloat.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/net/seanomik/tamablefoxes/pathfinding/FoxPathfindGoalFloat.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/net/seanomilk/tamablefoxes/pathfinding/FoxPathfindGoalFollowOwner.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/net/seanomik/tamablefoxes/pathfinding/FoxPathfindGoalFollowOwner.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/net/seanomilk/tamablefoxes/pathfinding/FoxPathfindGoalHurtByTarget.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/net/seanomik/tamablefoxes/pathfinding/FoxPathfindGoalHurtByTarget.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/net/seanomilk/tamablefoxes/pathfinding/FoxPathfindGoalLunge.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/net/seanomik/tamablefoxes/pathfinding/FoxPathfindGoalLunge.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/net/seanomilk/tamablefoxes/pathfinding/FoxPathfindGoalLungeUNKNOWN_USE.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/net/seanomik/tamablefoxes/pathfinding/FoxPathfindGoalLungeUNKNOWN_USE.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/net/seanomilk/tamablefoxes/pathfinding/FoxPathfindGoalMeleeAttack.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/net/seanomik/tamablefoxes/pathfinding/FoxPathfindGoalMeleeAttack.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/net/seanomilk/tamablefoxes/pathfinding/FoxPathfindGoalOwnerHurtByTarget.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/net/seanomik/tamablefoxes/pathfinding/FoxPathfindGoalOwnerHurtByTarget.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/net/seanomilk/tamablefoxes/pathfinding/FoxPathfindGoalOwnerHurtTarget.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/net/seanomik/tamablefoxes/pathfinding/FoxPathfindGoalOwnerHurtTarget.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/net/seanomilk/tamablefoxes/pathfinding/FoxPathfindGoalPickBushes.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/net/seanomik/tamablefoxes/pathfinding/FoxPathfindGoalPickBushes.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/net/seanomilk/tamablefoxes/pathfinding/FoxPathfindGoalRandomStrollLand.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/net/seanomik/tamablefoxes/pathfinding/FoxPathfindGoalRandomStrollLand.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/net/seanomilk/tamablefoxes/pathfinding/FoxPathfindGoalRandomTargetNonTamed.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/net/seanomik/tamablefoxes/pathfinding/FoxPathfindGoalRandomTargetNonTamed.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/net/seanomilk/tamablefoxes/pathfinding/FoxPathfindGoalSit.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/net/seanomik/tamablefoxes/pathfinding/FoxPathfindGoalSit.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/resources/plugin.yml" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/resources/plugin.yml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/target/classes/plugin.yml" beforeDir="false" afterPath="$PROJECT_DIR$/target/classes/plugin.yml" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
<option name="LAST_RESOLUTION" value="IGNORE" />
</component>
<component name="FileTemplateManagerImpl">
<option name="RECENT_TEMPLATES">
<list>
<option value="Class" />
</list>
</option>
</component>
<component name="Git.Settings">
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
</component>
@ -22,17 +50,22 @@
</option>
</component>
<component name="ProjectId" id="1WXR7SMZcGllgYVjIOg98VPV9wX" />
<component name="ProjectLevelVcsManager">
<ConfirmationsSetting value="2" id="Add" />
</component>
<component name="ProjectViewState">
<option name="hideEmptyMiddlePackages" value="true" />
<option name="showExcludedFiles" value="true" />
<option name="showLibraryContents" value="true" />
</component>
<component name="PropertiesComponent">
<property name="ASKED_ADD_EXTERNAL_FILES" value="true" />
<property name="JavaMethodFindUsagesOptions.isOverridingMethods" value="true" />
<property name="RunOnceActivity.ShowReadmeOnStart" value="true" />
<property name="SHARE_PROJECT_CONFIGURATION_FILES" value="true" />
<property name="WebServerToolWindowFactoryState" value="false" />
<property name="aspect.path.notification.shown" value="true" />
<property name="last_opened_file_path" value="$PROJECT_DIR$/../../TEST_SERVER/spigot-1.15.1.jar" />
<property name="last_opened_file_path" value="$PROJECT_DIR$/../DexunGUI" />
<property name="node.js.detected.package.eslint" value="true" />
<property name="node.js.detected.package.tslint" value="true" />
<property name="node.js.path.for.package.eslint" value="project" />
@ -43,10 +76,10 @@
<property name="nodejs_npm_path_reset_for_default_project" value="true" />
</component>
<component name="RecentsManager">
<key name="MoveFile.RECENT_KEYS">
<key name="CopyFile.RECENT_KEYS">
<recent name="D:\Ellie\ProjectDirectory\tamablefoxes-1\TamableFoxes-1" />
</key>
<key name="CopyFile.RECENT_KEYS">
<key name="MoveFile.RECENT_KEYS">
<recent name="D:\Ellie\ProjectDirectory\tamablefoxes-1\TamableFoxes-1" />
</key>
</component>
@ -110,58 +143,80 @@
</map>
</option>
</component>
<component name="VcsManagerConfiguration">
<option name="ADD_EXTERNAL_FILES_SILENTLY" value="true" />
</component>
<component name="WindowStateProjectService">
<state x="414" y="174" key="#com.intellij.execution.impl.EditConfigurationsDialog" timestamp="1579378826331">
<screen x="0" y="0" width="1920" height="1040" />
</state>
<state x="414" y="174" key="#com.intellij.execution.impl.EditConfigurationsDialog/0.0.1920.1040/-1920.0.1920.1040@0.0.1920.1040" timestamp="1579378826331" />
<state x="740" y="274" key="FileChooserDialogImpl" timestamp="1579378776852">
<state x="765" y="229" key="#com.intellij.ide.util.MemberChooser" timestamp="1579568884135">
<screen x="0" y="0" width="1920" height="1040" />
</state>
<state x="740" y="274" key="FileChooserDialogImpl/0.0.1920.1040/-1920.0.1920.1040@0.0.1920.1040" timestamp="1579378776852" />
<state width="1877" height="276" key="GridCell.Tab.0.bottom" timestamp="1579379569576">
<state x="765" y="229" key="#com.intellij.ide.util.MemberChooser/0.0.1920.1040/-1920.0.1920.1040@0.0.1920.1040" timestamp="1579568884135" />
<state x="740" y="274" key="FileChooserDialogImpl" timestamp="1579570099439">
<screen x="0" y="0" width="1920" height="1040" />
</state>
<state width="1877" height="276" key="GridCell.Tab.0.bottom/0.0.1920.1040/-1920.0.1920.1040@0.0.1920.1040" timestamp="1579379569576" />
<state width="1877" height="276" key="GridCell.Tab.0.center" timestamp="1579379569576">
<state x="740" y="274" key="FileChooserDialogImpl/0.0.1920.1040/-1920.0.1920.1040@0.0.1920.1040" timestamp="1579570099439" />
<state x="794" y="418" width="356" height="203" key="Github.CreateGistDialog" timestamp="1579471488647">
<screen x="0" y="0" width="1920" height="1040" />
</state>
<state width="1877" height="276" key="GridCell.Tab.0.center/0.0.1920.1040/-1920.0.1920.1040@0.0.1920.1040" timestamp="1579379569576" />
<state width="1877" height="276" key="GridCell.Tab.0.left" timestamp="1579379569576">
<state x="794" y="418" width="356" height="203" key="Github.CreateGistDialog/0.0.1920.1040/-1920.0.1920.1040@0.0.1920.1040" timestamp="1579471488647" />
<state width="1877" height="256" key="GridCell.Tab.0.bottom" timestamp="1579581388624">
<screen x="0" y="0" width="1920" height="1040" />
</state>
<state width="1877" height="276" key="GridCell.Tab.0.left/0.0.1920.1040/-1920.0.1920.1040@0.0.1920.1040" timestamp="1579379569576" />
<state width="1877" height="276" key="GridCell.Tab.0.right" timestamp="1579379569576">
<state width="1877" height="256" key="GridCell.Tab.0.bottom/0.0.1920.1040/-1920.0.1920.1040@0.0.1920.1040" timestamp="1579581388624" />
<state width="1877" height="256" key="GridCell.Tab.0.center" timestamp="1579581388624">
<screen x="0" y="0" width="1920" height="1040" />
</state>
<state width="1877" height="276" key="GridCell.Tab.0.right/0.0.1920.1040/-1920.0.1920.1040@0.0.1920.1040" timestamp="1579379569576" />
<state width="1877" height="276" key="GridCell.Tab.1.bottom" timestamp="1579379569576">
<state width="1877" height="256" key="GridCell.Tab.0.center/0.0.1920.1040/-1920.0.1920.1040@0.0.1920.1040" timestamp="1579581388624" />
<state width="1877" height="256" key="GridCell.Tab.0.left" timestamp="1579581388624">
<screen x="0" y="0" width="1920" height="1040" />
</state>
<state width="1877" height="276" key="GridCell.Tab.1.bottom/0.0.1920.1040/-1920.0.1920.1040@0.0.1920.1040" timestamp="1579379569576" />
<state width="1877" height="276" key="GridCell.Tab.1.center" timestamp="1579379569576">
<state width="1877" height="256" key="GridCell.Tab.0.left/0.0.1920.1040/-1920.0.1920.1040@0.0.1920.1040" timestamp="1579581388624" />
<state width="1877" height="256" key="GridCell.Tab.0.right" timestamp="1579581388624">
<screen x="0" y="0" width="1920" height="1040" />
</state>
<state width="1877" height="276" key="GridCell.Tab.1.center/0.0.1920.1040/-1920.0.1920.1040@0.0.1920.1040" timestamp="1579379569576" />
<state width="1877" height="276" key="GridCell.Tab.1.left" timestamp="1579379569576">
<state width="1877" height="256" key="GridCell.Tab.0.right/0.0.1920.1040/-1920.0.1920.1040@0.0.1920.1040" timestamp="1579581388624" />
<state width="1877" height="256" key="GridCell.Tab.1.bottom" timestamp="1579581388624">
<screen x="0" y="0" width="1920" height="1040" />
</state>
<state width="1877" height="276" key="GridCell.Tab.1.left/0.0.1920.1040/-1920.0.1920.1040@0.0.1920.1040" timestamp="1579379569576" />
<state width="1877" height="276" key="GridCell.Tab.1.right" timestamp="1579379569576">
<state width="1877" height="256" key="GridCell.Tab.1.bottom/0.0.1920.1040/-1920.0.1920.1040@0.0.1920.1040" timestamp="1579581388624" />
<state width="1877" height="256" key="GridCell.Tab.1.center" timestamp="1579581388624">
<screen x="0" y="0" width="1920" height="1040" />
</state>
<state width="1877" height="276" key="GridCell.Tab.1.right/0.0.1920.1040/-1920.0.1920.1040@0.0.1920.1040" timestamp="1579379569576" />
<state width="1877" height="256" key="GridCell.Tab.1.center/0.0.1920.1040/-1920.0.1920.1040@0.0.1920.1040" timestamp="1579581388624" />
<state width="1877" height="256" key="GridCell.Tab.1.left" timestamp="1579581388624">
<screen x="0" y="0" width="1920" height="1040" />
</state>
<state width="1877" height="256" key="GridCell.Tab.1.left/0.0.1920.1040/-1920.0.1920.1040@0.0.1920.1040" timestamp="1579581388624" />
<state width="1877" height="256" key="GridCell.Tab.1.right" timestamp="1579581388624">
<screen x="0" y="0" width="1920" height="1040" />
</state>
<state width="1877" height="256" key="GridCell.Tab.1.right/0.0.1920.1040/-1920.0.1920.1040@0.0.1920.1040" timestamp="1579581388624" />
<state x="490" y="174" key="Maven.ArtifactSearchDialog" timestamp="1579373377880">
<screen x="0" y="0" width="1920" height="1040" />
</state>
<state x="490" y="174" key="Maven.ArtifactSearchDialog/0.0.1920.1040/-1920.0.1920.1040@0.0.1920.1040" timestamp="1579373377880" />
<state width="498" height="446" key="SwitcherDM" timestamp="1579367994204">
<state width="498" height="446" key="SwitcherDM" timestamp="1579469022098">
<screen x="0" y="0" width="1920" height="1040" />
</state>
<state width="498" height="446" key="SwitcherDM/0.0.1920.1040/-1920.0.1920.1040@0.0.1920.1040" timestamp="1579367994204" />
<state x="656" y="343" key="com.intellij.ide.util.TipDialog" timestamp="1579377807994">
<state width="498" height="446" key="SwitcherDM/0.0.1920.1040/-1920.0.1920.1040@0.0.1920.1040" timestamp="1579469022098" />
<state x="656" y="343" key="com.intellij.ide.util.TipDialog" timestamp="1579535914963">
<screen x="0" y="0" width="1920" height="1040" />
</state>
<state x="656" y="343" key="com.intellij.ide.util.TipDialog/0.0.1920.1040/-1920.0.1920.1040@0.0.1920.1040" timestamp="1579377807994" />
<state x="656" y="343" key="com.intellij.ide.util.TipDialog/0.0.1920.1040/-1920.0.1920.1040@0.0.1920.1040" timestamp="1579535914963" />
</component>
<component name="XDebuggerManager">
<breakpoint-manager>
<breakpoints>
<line-breakpoint enabled="true" type="java-line">
<url>file://$PROJECT_DIR$/src/main/java/net/seanomik/tamablefoxes/TamableFoxes.java</url>
<line>440</line>
<option name="timeStamp" value="6" />
</line-breakpoint>
</breakpoints>
</breakpoint-manager>
</component>
</project>

View File

@ -1,7 +1,7 @@
package net.seanomilk.tamablefoxes;
package net.seanomik.tamablefoxes;
import net.minecraft.server.v1_15_R1.*;
import net.seanomilk.tamablefoxes.pathfinding.*;
import net.seanomik.tamablefoxes.pathfinding.*;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.craftbukkit.v1_15_R1.CraftWorld;
@ -30,11 +30,17 @@ public class EntityTamableFox extends EntityFox {
private FoxPathfindGoalSit goalSit;
private PathfinderGoalNearestAttackableTarget goalAttack;
public int databaseIndex = -1;
public EntityTamableFox(TamableFoxes plugin, EntityTypes entitytypes, World world) {
super(EntityTypes.FOX, world);
this.plugin = plugin;
thisFox = (Fox) this.getBukkitEntity();
plugin.getFoxUUIDs().put(this.getBukkitEntity().getUniqueId(), null);
if (!plugin.getFoxUUIDs().containsKey(thisFox.getUniqueId())) {
plugin.getFoxUUIDs().put(this.getBukkitEntity().getUniqueId(), null);
}
this.setPersistent();
}
@ -153,7 +159,7 @@ public class EntityTamableFox extends EntityFox {
public void setChosenName(String chosenName) {
this.chosenName = chosenName;
plugin.getConfigFoxes().set("Foxes." + getUniqueID() + ".name", chosenName).save();
//plugin.getConfigFoxes().set("Foxes." + getUniqueID() + ".name", chosenName).save();
updateFoxVisual();
}
@ -163,7 +169,7 @@ public class EntityTamableFox extends EntityFox {
public void setOwner(EntityLiving owner) {
this.owner = owner;
plugin.getConfigFoxes().set("Foxes." + getUniqueID() + ".owner", owner.getUniqueIDString()).save();
//plugin.getConfigFoxes().set("Foxes." + getUniqueID() + ".owner", owner.getUniqueIDString()).save();
updateFoxVisual();
}

View File

@ -1,11 +1,13 @@
package net.seanomilk.tamablefoxes;
package net.seanomik.tamablefoxes;
import com.google.common.collect.Maps;
import com.mojang.datafixers.DataFixUtils;
import com.mojang.datafixers.types.Type;
import net.seanomilk.tamablefoxes.command.CommandSpawnTamableFox;
import net.seanomilk.tamablefoxes.io.FileManager;
import net.seanomik.tamablefoxes.command.CommandSpawnTamableFox;
import net.seanomik.tamablefoxes.io.FileManager;
import net.minecraft.server.v1_15_R1.*;
import net.seanomik.tamablefoxes.sqlite.SQLiteHandler;
import net.seanomik.tamablefoxes.sqlite.SQLiteSetterGetter;
import net.wesjd.anvilgui.AnvilGUI;
import org.bukkit.Chunk;
import org.bukkit.Material;
@ -16,11 +18,9 @@ import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.craftbukkit.v1_15_R1.CraftWorld;
import org.bukkit.craftbukkit.v1_15_R1.entity.CraftEntity;
import org.bukkit.craftbukkit.v1_15_R1.entity.CraftFox;
import org.bukkit.craftbukkit.v1_15_R1.entity.CraftItem;
import org.bukkit.craftbukkit.v1_15_R1.entity.CraftPlayer;
import org.bukkit.craftbukkit.v1_15_R1.inventory.CraftItemStack;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Fox;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
@ -34,31 +34,29 @@ import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.plugin.java.JavaPlugin;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.util.stream.Collectors;
// @TODO: Add language.yml
public class TamableFoxes extends JavaPlugin implements Listener {
public static final String ITEM_INSPECTOR_LORE = ChatColor.BLUE + "Tamable Fox Inspector";
public static final String TAG_TAME_FOX = "tameablefox";
private FileManager fileManager;
private FileManager fileManager = new FileManager(this);
private Map<UUID, UUID> foxUUIDs;
private Map<UUID, UUID> foxUUIDs = Maps.newHashMap(); // FoxUUID, OwnerUUID
private EntityTypes customType;
private boolean isOnLoad = true;
private Map<UUID, Entity> lookupCache;
private FileManager.Config config, configFoxes;
private Map<Player, UUID> waitingName;
private Map<UUID, Entity> lookupCache = Maps.newHashMap();
private List<EntityTamableFox> spawnedFoxes;
private FileManager.Config config;//, configFoxes;
public static SQLiteHandler sqLiteHandler = new SQLiteHandler();
public static SQLiteSetterGetter sqLiteSetterGetter = new SQLiteSetterGetter();
@Override
public void onEnable() {
@ -69,19 +67,17 @@ public class TamableFoxes extends JavaPlugin implements Listener {
return;
}
fileManager = new FileManager(this);
sqLiteHandler.connect();
sqLiteSetterGetter.createTablesIfNotExist();
this.config = fileManager.getConfig("config.yml");
this.config.copyDefaults(true).save();
this.configFoxes = fileManager.getConfig("foxes.yml");
this.configFoxes.copyDefaults(true).save();
/*this.configFoxes = fileManager.getConfig("foxes.yml");
this.configFoxes.copyDefaults(true).save();*/
this.getServer().getPluginManager().registerEvents(this, this);
this.getCommand("spawntamablefox").setExecutor(new CommandSpawnTamableFox(this));
this.foxUUIDs = Maps.newHashMap();
this.lookupCache = Maps.newHashMap();
this.waitingName = Maps.newHashMap();
final Map<String, Type<?>> types = (Map<String, Type<?>>) DataConverterRegistry.a()
.getSchema(DataFixUtils.makeKey(SharedConstants.getGameVersion().getWorldVersion()))
.findChoiceType(DataConverterTypes.ENTITY).types();
@ -96,11 +92,21 @@ public class TamableFoxes extends JavaPlugin implements Listener {
@Override
public void onDisable() {
try {
for (EntityTamableFox fox : spawnedFoxes) {
sqLiteSetterGetter.saveFox(fox);
fox.getBukkitEntity().remove();
}
getServer().getConsoleSender().sendMessage(getPrefix() + ChatColor.GREEN + "Saved all foxes successfully!");
} catch (Exception e) {
getServer().getConsoleSender().sendMessage(getPrefix() + ChatColor.RED + "Failed to save foxes!");
}
}
private void replaceFoxesOnLoad() {
int amountReplaced = 0;
/*int amountReplaced = 0;
for (World world : Bukkit.getWorlds()) {
Chunk[] loadedChunks = world.getLoadedChunks();
@ -113,7 +119,7 @@ public class TamableFoxes extends JavaPlugin implements Listener {
continue;
EntityTamableFox tamableFox = (EntityTamableFox) spawnTamableFox(entity.getLocation(), ((CraftFox) entity).getHandle().getFoxType());
final YamlConfiguration configuration = configFoxes.get();
//final YamlConfiguration configuration = configFoxes.get();
// get living entity data
if (configuration.isConfigurationSection("Foxes." + entity.getUniqueId())) {
String owner = configuration.getString("Foxes." + entity.getUniqueId() + ".owner");
@ -142,8 +148,10 @@ public class TamableFoxes extends JavaPlugin implements Listener {
tamableFox.updateFox();
tamableFox.setAge(((CraftFox) entity).getAge());
ItemStack entityMouthItem = ((CraftFox) entity).getEquipment().getItemInMainHand();
entityMouthItem.setAmount(1);
if (entityMouthItem.getType() != Material.AIR) {
tamableFox.setSlot(EnumItemSlot.MAINHAND, CraftItemStack.asNMSCopy(new ItemStack(entityMouthItem.getType(), 1)));
tamableFox.setSlot(EnumItemSlot.MAINHAND, CraftItemStack.asNMSCopy(entityMouthItem));
} else {
tamableFox.setSlot(EnumItemSlot.MAINHAND, new net.minecraft.server.v1_15_R1.ItemStack(Items.AIR));
}
@ -153,8 +161,10 @@ public class TamableFoxes extends JavaPlugin implements Listener {
tamableFox.setAge(((CraftFox) entity).getAge());
ItemStack entityMouthItem = ((CraftFox) entity).getEquipment().getItemInMainHand();
entityMouthItem.setAmount(1);
if (entityMouthItem.getType() != Material.AIR) {
tamableFox.setSlot(EnumItemSlot.MAINHAND, CraftItemStack.asNMSCopy(new ItemStack(entityMouthItem.getType(), 1)));
tamableFox.setSlot(EnumItemSlot.MAINHAND, CraftItemStack.asNMSCopy(entityMouthItem));
} else {
tamableFox.setSlot(EnumItemSlot.MAINHAND, new net.minecraft.server.v1_15_R1.ItemStack(Items.AIR));
}
@ -166,7 +176,9 @@ public class TamableFoxes extends JavaPlugin implements Listener {
}
}
configFoxes.save();
configFoxes.save();*/
spawnedFoxes = sqLiteSetterGetter.spawnFoxes();
this.isOnLoad = false;
}
@ -179,15 +191,15 @@ public class TamableFoxes extends JavaPlugin implements Listener {
EntityFox fox = (EntityFox) spawnedEntity;
fox.setFoxType(type);
configFoxes.get().set("Foxes." + spawnedEntity.getUniqueID() + ".owner", "none");
fileManager.saveConfig("foxes.yml");
/*configFoxes.get().set("Foxes." + spawnedEntity.getUniqueID() + ".owner", "none");
fileManager.saveConfig("foxes.yml");*/
return fox;
}
@EventHandler
public void onChunkLoad(ChunkLoadEvent event) {
if (isOnLoad)
/*if (isOnLoad)
return;
Chunk chunk = event.getChunk();
Entity[] entities = chunk.getEntities();
@ -241,7 +253,7 @@ public class TamableFoxes extends JavaPlugin implements Listener {
entity.remove();
}
}
}*/
}
@ -363,12 +375,11 @@ public class TamableFoxes extends JavaPlugin implements Listener {
if(!text.equals("")) {
tamableFox.setChosenName(text);
plr.sendMessage(getPrefix() + ChatColor.GREEN + text + " is perfect!");
return AnvilGUI.Response.close();
} else {
return AnvilGUI.Response.text("Insert a name for your fox!");
}
return AnvilGUI.Response.close();
})
.preventClose() // Prevents the inventory from being closed
//.preventClose() // Prevents the inventory from being closed
.text("Fox name") // Sets the text the GUI should start with
.plugin(this) // Set the plugin instance
.open(player); // Opens the GUI for the player provided
@ -420,7 +431,43 @@ public class TamableFoxes extends JavaPlugin implements Listener {
spawnTamableFox(entity.getLocation(), foxType);
event.setCancelled(true);
}
}
@EventHandler
public void onEntityDeathEvent(EntityDeathEvent event) {
Entity entity = event.getEntity();
if (!this.isTamableFox(entity)) {
return;
}
// Remove the fox from storage
lookupCache.remove(entity.getUniqueId());
foxUUIDs.remove(entity.getUniqueId());
spawnedFoxes.remove(entity.getUniqueId());
//sqLiteSetterGetter.removeFox();
EntityTamableFox tamableFox = (EntityTamableFox) ((CraftEntity) entity).getHandle();
if (tamableFox.getOwner() != null) {
Player owner = ((EntityPlayer)tamableFox.getOwner()).getBukkitEntity();
owner.sendMessage(getPrefix() + ChatColor.RED + tamableFox.getChosenName() + " was killed!");
}
sqLiteSetterGetter.removeFox(tamableFox);
/*if (configFoxes.get().getConfigurationSection("Foxes").contains(entity.getUniqueId().toString())) {
*//*EntityTamableFox tamableFox = (EntityTamableFox) ((CraftEntity) entity).getHandle();
if (tamableFox.getOwner() != null && tamableFox.getOwner() instanceof Player) {
Player owner = (Player) tamableFox.getOwner();
owner.sendMessage(getPrefix() + ChatColor.RED + tamableFox.getChosenName() + " was killed!");
}*//*
configFoxes.get().set("Foxes." + entity.getUniqueId(), null);
fileManager.saveConfig("foxes.yml");
}*/
}
public Entity getEntityByUniqueId(UUID uniqueId) {
@ -445,26 +492,6 @@ public class TamableFoxes extends JavaPlugin implements Listener {
return null;
}
@EventHandler
public void onEntityDeathEvent(EntityDeathEvent event) {
Entity entity = event.getEntity();
if (!this.isTamableFox(entity))
return;
this.lookupCache.remove(entity.getUniqueId());
foxUUIDs.remove(entity.getUniqueId());
if (configFoxes.get().getConfigurationSection("Foxes").contains(entity.getUniqueId().toString())) {
/*EntityTamableFox tamableFox = (EntityTamableFox) ((CraftEntity) entity).getHandle();
if (tamableFox.getOwner() != null && tamableFox.getOwner() instanceof Player) {
Player owner = (Player) tamableFox.getOwner();
owner.sendMessage(getPrefix() + ChatColor.RED + tamableFox.getChosenName() + " was killed!");
}*/
configFoxes.get().set("Foxes." + entity.getUniqueId(), null);
fileManager.saveConfig("foxes.yml");
}
}
public boolean isTamableFox(org.bukkit.entity.Entity entity) {
return ((CraftEntity) entity).getHandle().getClass().getName().contains("TamableFox")
|| ((CraftEntity) entity).getHandle() instanceof EntityTamableFox;
@ -483,9 +510,9 @@ public class TamableFoxes extends JavaPlugin implements Listener {
return config;
}
public FileManager.Config getConfigFoxes() {
/*public FileManager.Config getConfigFoxes() {
return configFoxes;
}
}*/
public EntityTypes getCustomType() {
return customType;
@ -495,6 +522,10 @@ public class TamableFoxes extends JavaPlugin implements Listener {
return foxUUIDs;
}
public List<EntityTamableFox> getSpawnedFoxes() {
return spawnedFoxes;
}
public static String getPrefix() {
//return ChatColor.translateAlternateColorCodes('&', (String) config.get("prefix"));
return ChatColor.RED + "[Tamable Foxes] ";

View File

@ -1,11 +1,11 @@
package net.seanomilk.tamablefoxes.command;
package net.seanomik.tamablefoxes.command;
import net.seanomilk.tamablefoxes.TamableFoxes;
import net.seanomik.tamablefoxes.EntityTamableFox;
import net.seanomik.tamablefoxes.TamableFoxes;
import net.minecraft.server.v1_15_R1.EntityFox;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabExecutor;
import org.bukkit.entity.Player;
@ -41,12 +41,18 @@ public class CommandSpawnTamableFox implements TabExecutor {
if (args.length != 0) {
switch (args[0]) {
case "red":
plugin.spawnTamableFox(player.getLocation(), EntityFox.Type.RED);
EntityTamableFox fox = (EntityTamableFox) plugin.spawnTamableFox(player.getLocation(), EntityFox.Type.RED);
plugin.getSpawnedFoxes().add(fox);
plugin.sqLiteSetterGetter.saveFox(fox);
player.sendMessage(plugin.getPrefix() + ChatColor.RESET + "Spawned a " + ChatColor.RED + "Red" + ChatColor.WHITE + " fox.");
break;
case "snow":
plugin.spawnTamableFox(player.getLocation(), EntityFox.Type.SNOW);
player.sendMessage(plugin.getPrefix() + ChatColor.RESET + "Spawned a Snow fox.");
EntityTamableFox spawnedFox = (EntityTamableFox) plugin.spawnTamableFox(player.getLocation(), EntityFox.Type.SNOW);
plugin.getSpawnedFoxes().add(spawnedFox);
plugin.sqLiteSetterGetter.saveFox(spawnedFox);
player.sendMessage(plugin.getPrefix() + ChatColor.RESET + "Spawned a " + ChatColor.AQUA + "Snow" + ChatColor.WHITE + " fox.");
break;
case "verbose":
player.sendMessage(plugin.getFoxUUIDs().toString());
@ -60,7 +66,7 @@ public class CommandSpawnTamableFox implements TabExecutor {
if (player.getInventory().getItemInMainHand().getType() == Material.AIR) {
player.getInventory().setItemInMainHand(itemStack);
player.sendMessage(plugin.getPrefix() + ChatColor.GREEN + "Given Inspector item.");
player.sendMessage(plugin.getPrefix() + ChatColor.GREEN + "Gave Inspector item.");
} else if (player.getInventory().firstEmpty() == -1) {
player.sendMessage(plugin.getPrefix() + ChatColor.RED + "Your inventory is full!");
} else {
@ -70,7 +76,7 @@ public class CommandSpawnTamableFox implements TabExecutor {
break;
case "reload":
plugin.getMainConfig().reload();
plugin.getConfigFoxes().reload();
//plugin.getConfigFoxes().reload();
player.sendMessage(plugin.getPrefix() + ChatColor.GREEN + "Reloaded.");
break;
default:

View File

@ -1,7 +1,7 @@
package net.seanomilk.tamablefoxes.io;
package net.seanomik.tamablefoxes.io;
import com.google.common.collect.Maps;
import net.seanomilk.tamablefoxes.TamableFoxes;
import net.seanomik.tamablefoxes.TamableFoxes;
import org.bukkit.configuration.file.YamlConfiguration;
import java.io.File;

View File

@ -1,6 +1,6 @@
package net.seanomilk.tamablefoxes.pathfinding;
package net.seanomik.tamablefoxes.pathfinding;
import net.seanomilk.tamablefoxes.EntityTamableFox;
import net.seanomik.tamablefoxes.EntityTamableFox;
import net.minecraft.server.v1_15_R1.*;
import java.util.EnumSet;

View File

@ -1,6 +1,6 @@
package net.seanomilk.tamablefoxes.pathfinding;
package net.seanomik.tamablefoxes.pathfinding;
import net.seanomilk.tamablefoxes.EntityTamableFox;
import net.seanomik.tamablefoxes.EntityTamableFox;
import net.minecraft.server.v1_15_R1.*;
import org.bukkit.craftbukkit.v1_15_R1.event.CraftEventFactory;
import org.bukkit.event.entity.CreatureSpawnEvent;

View File

@ -1,6 +1,6 @@
package net.seanomilk.tamablefoxes.pathfinding;
package net.seanomik.tamablefoxes.pathfinding;
import net.seanomilk.tamablefoxes.EntityTamableFox;
import net.seanomik.tamablefoxes.EntityTamableFox;
import net.minecraft.server.v1_15_R1.BlockPosition;
import net.minecraft.server.v1_15_R1.PathfinderGoalFleeSun;
import net.minecraft.server.v1_15_R1.WorldServer;

View File

@ -1,6 +1,6 @@
package net.seanomilk.tamablefoxes.pathfinding;
package net.seanomik.tamablefoxes.pathfinding;
import net.seanomilk.tamablefoxes.EntityTamableFox;
import net.seanomik.tamablefoxes.EntityTamableFox;
import net.minecraft.server.v1_15_R1.PathfinderGoalFloat;
import java.lang.reflect.InvocationTargetException;

View File

@ -1,6 +1,6 @@
package net.seanomilk.tamablefoxes.pathfinding;
package net.seanomik.tamablefoxes.pathfinding;
import net.seanomilk.tamablefoxes.EntityTamableFox;
import net.seanomik.tamablefoxes.EntityTamableFox;
import net.minecraft.server.v1_15_R1.*;
import org.bukkit.Location;
import org.bukkit.craftbukkit.v1_15_R1.entity.CraftEntity;

View File

@ -1,6 +1,6 @@
package net.seanomilk.tamablefoxes.pathfinding;
package net.seanomik.tamablefoxes.pathfinding;
import net.seanomilk.tamablefoxes.EntityTamableFox;
import net.seanomik.tamablefoxes.EntityTamableFox;
import net.minecraft.server.v1_15_R1.*;
import org.bukkit.event.entity.EntityTargetEvent.TargetReason;

View File

@ -1,6 +1,6 @@
package net.seanomilk.tamablefoxes.pathfinding;
package net.seanomik.tamablefoxes.pathfinding;
import net.seanomilk.tamablefoxes.EntityTamableFox;
import net.seanomik.tamablefoxes.EntityTamableFox;
import net.minecraft.server.v1_15_R1.*;
import java.lang.reflect.Field;

View File

@ -1,6 +1,6 @@
package net.seanomilk.tamablefoxes.pathfinding;
package net.seanomik.tamablefoxes.pathfinding;
import net.seanomilk.tamablefoxes.EntityTamableFox;
import net.seanomik.tamablefoxes.EntityTamableFox;
import net.minecraft.server.v1_15_R1.Entity;
import net.minecraft.server.v1_15_R1.EntityFox;
import net.minecraft.server.v1_15_R1.EntityLiving;

View File

@ -1,6 +1,6 @@
package net.seanomilk.tamablefoxes.pathfinding;
package net.seanomik.tamablefoxes.pathfinding;
import net.seanomilk.tamablefoxes.EntityTamableFox;
import net.seanomik.tamablefoxes.EntityTamableFox;
import net.minecraft.server.v1_15_R1.EntityLiving;
import net.minecraft.server.v1_15_R1.PathfinderGoalMeleeAttack;
import net.minecraft.server.v1_15_R1.SoundEffects;

View File

@ -1,6 +1,6 @@
package net.seanomilk.tamablefoxes.pathfinding;
package net.seanomik.tamablefoxes.pathfinding;
import net.seanomilk.tamablefoxes.EntityTamableFox;
import net.seanomik.tamablefoxes.EntityTamableFox;
import net.minecraft.server.v1_15_R1.EntityLiving;
import net.minecraft.server.v1_15_R1.PathfinderGoalTarget;
import net.minecraft.server.v1_15_R1.PathfinderTargetCondition;

View File

@ -1,6 +1,6 @@
package net.seanomilk.tamablefoxes.pathfinding;
package net.seanomik.tamablefoxes.pathfinding;
import net.seanomilk.tamablefoxes.EntityTamableFox;
import net.seanomik.tamablefoxes.EntityTamableFox;
import net.minecraft.server.v1_15_R1.EntityLiving;
import net.minecraft.server.v1_15_R1.PathfinderGoalTarget;
import net.minecraft.server.v1_15_R1.PathfinderTargetCondition;

View File

@ -1,6 +1,6 @@
package net.seanomilk.tamablefoxes.pathfinding;
package net.seanomik.tamablefoxes.pathfinding;
import net.seanomilk.tamablefoxes.EntityTamableFox;
import net.seanomik.tamablefoxes.EntityTamableFox;
import net.minecraft.server.v1_15_R1.*;
import org.bukkit.craftbukkit.v1_15_R1.event.CraftEventFactory;

View File

@ -1,6 +1,6 @@
package net.seanomilk.tamablefoxes.pathfinding;
package net.seanomik.tamablefoxes.pathfinding;
import net.seanomilk.tamablefoxes.EntityTamableFox;
import net.seanomik.tamablefoxes.EntityTamableFox;
import net.minecraft.server.v1_15_R1.PathfinderGoalRandomStroll;
import net.minecraft.server.v1_15_R1.RandomPositionGenerator;
import net.minecraft.server.v1_15_R1.Vec3D;

View File

@ -1,6 +1,6 @@
package net.seanomilk.tamablefoxes.pathfinding;
package net.seanomik.tamablefoxes.pathfinding;
import net.seanomilk.tamablefoxes.EntityTamableFox;
import net.seanomik.tamablefoxes.EntityTamableFox;
import net.minecraft.server.v1_15_R1.EntityLiving;
import net.minecraft.server.v1_15_R1.PathfinderGoalNearestAttackableTarget;

View File

@ -1,6 +1,6 @@
package net.seanomilk.tamablefoxes.pathfinding;
package net.seanomik.tamablefoxes.pathfinding;
import net.seanomilk.tamablefoxes.EntityTamableFox;
import net.seanomik.tamablefoxes.EntityTamableFox;
import net.minecraft.server.v1_15_R1.EntityLiving;
import net.minecraft.server.v1_15_R1.PathfinderGoal;

View File

@ -1,4 +1,4 @@
package net.seanomik.tamablefoxes.sqllite;
package net.seanomik.tamablefoxes.sqlite;
import net.seanomik.tamablefoxes.TamableFoxes;
import org.bukkit.Bukkit;
@ -18,7 +18,7 @@ public class SQLiteHandler {
String url = "jdbc:sqlite:" + baseLoc + "plugins/TamableFoxes/foxes.db";
connection = DriverManager.getConnection(url);
Bukkit.getConsoleSender().sendMessage(TamableFoxes.getPrefix() + "Connection to SQLite has been established.");
//Bukkit.getConsoleSender().sendMessage(TamableFoxes.getPrefix() + "Connection to SQLite has been established.");
} catch (SQLException e) {
e.printStackTrace();
}

View File

@ -1,20 +1,28 @@
package net.seanomik.tamablefoxes.sqllite;
package net.seanomik.tamablefoxes.sqlite;
import net.minecraft.server.v1_15_R1.BlockPosition;
import net.minecraft.server.v1_15_R1.EntityFox;
import net.minecraft.server.v1_15_R1.EnumItemSlot;
import net.seanomik.tamablefoxes.EntityTamableFox;
import net.seanomik.tamablefoxes.TamableFoxes;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.OfflinePlayer;
import org.bukkit.craftbukkit.v1_15_R1.CraftWorld;
import org.bukkit.craftbukkit.v1_15_R1.entity.CraftPlayer;
import org.bukkit.craftbukkit.v1_15_R1.inventory.CraftItemStack;
import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.Plugin;
import java.sql.DatabaseMetaData;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.*;
public class SQLiteSetterGetter {
public static Plugin plugin;
public static TamableFoxes plugin;
public static SQLiteHandler sqLiteHandler;
public void createTablesIfNotExist() {
@ -24,9 +32,11 @@ public class SQLiteSetterGetter {
String foxesTable =
"CREATE TABLE IF NOT EXISTS `foxes` ( " +
"`OWNER_UUID` TEXT PRIMARY KEY , " +
"`NAME` TEXT NOT NULL , " +
"`INDEX` INTEGER PRIMARY KEY AUTOINCREMENT , " +
"`OWNER_UUID` TEXT NOT NULL , " +
"`NAME` TEXT , " +
"`LOCATION` TEXT NOT NULL , " +
"`TYPE` TEXT NOT NULL , " +
"`MOUTH_ITEM` TEXT NOT NULL);";
try {
@ -57,14 +67,96 @@ public class SQLiteSetterGetter {
plugin = TamableFoxes.getPlugin(TamableFoxes.class);
try {
sqLiteHandler.connect();
PreparedStatement statement = sqLiteHandler.getConnection()
.prepareStatement("INSERT INTO foxes (OWNER_UUID,NAME,LOCATION,MOUTH_ITEM) VALUES (?,?,?,?)");
statement.setString(1, (fox.getOwner().getUniqueID() == null) ? "none" : fox.getOwner().getUniqueID().toString());
PreparedStatement statement = sqLiteHandler.getConnection().prepareStatement("INSERT INTO foxes (OWNER_UUID,NAME,LOCATION,TYPE,MOUTH_ITEM) VALUES (?,?,?,?,?)");
if (fox.databaseIndex != -1) {
statement = sqLiteHandler.getConnection().prepareStatement("UPDATE foxes SET OWNER_UUID=?, NAME=?, LOCATION=?, TYPE=?, MOUTH_ITEM=? WHERE INDEX=" + fox.databaseIndex);
}
statement.setString(1, (fox.getOwner() == null) ? "none" : fox.getOwner().getUniqueID().toString());
statement.setString(2, fox.getChosenName());
statement.setString(3, fox.locX() + "," + fox.locY() + "," + fox.locY());
statement.setString(4, fox.getEquipment(EnumItemSlot.MAINHAND).toString());
statement.setString(3, fox.getWorld().worldData.getName() + "," + fox.locX() + "," + fox.locY() + "," + fox.locY());
statement.setString(4, fox.getFoxType().toString());
statement.setString(5, fox.getEquipment(EnumItemSlot.MAINHAND).toString().toUpperCase().substring(fox.getEquipment(EnumItemSlot.MAINHAND).toString().indexOf(' ')+1));
statement.executeUpdate();
ResultSet result = statement.getGeneratedKeys();
if (result.next()) {
fox.databaseIndex = result.getInt("INDEX");
}
} catch (SQLException e) {
e.printStackTrace();
} finally {
if (sqLiteHandler.getConnection() != null) {
try {
sqLiteHandler.getConnection().close();
} catch (SQLException e) {
e.printStackTrace();
}
}
}
}
public void saveFoxes(List<EntityTamableFox> foxes) { // @TODO: Optimize
for (EntityTamableFox fox : foxes) {
saveFox(fox);
}
}
public List<EntityTamableFox> spawnFoxes() {
plugin = TamableFoxes.getPlugin(TamableFoxes.class);
try {
sqLiteHandler.connect();
PreparedStatement statement = sqLiteHandler.getConnection().prepareStatement("SELECT * FROM foxes");
ResultSet results = statement.executeQuery();
List<EntityTamableFox> foxList = new ArrayList<>();
while (results.next()) { // Loop through each row
List<String> locationList = Arrays.asList(results.getString("LOCATION").split("\\s*,\\s*"));
Location loc = new Location(Bukkit.getWorld(locationList.get(0)), Double.parseDouble(locationList.get(1)), Double.parseDouble(locationList.get(2)), Double.parseDouble(locationList.get(3)));
EntityTamableFox spawnedFox = (EntityTamableFox) plugin.spawnTamableFox(loc, EntityFox.Type.valueOf(results.getString("TYPE")));
spawnedFox.databaseIndex = results.getInt("INDEX");
spawnedFox.setSlot(EnumItemSlot.MAINHAND, CraftItemStack.asNMSCopy(new ItemStack(Material.valueOf(results.getString("MOUTH_ITEM")), 1)));
if (!results.getString("OWNER_UUID").equals("none")) {
UUID ownerUUID = UUID.fromString(results.getString("OWNER_UUID"));
OfflinePlayer owner = plugin.getServer().getOfflinePlayer(ownerUUID);
if (owner.isOnline()) {
spawnedFox.setOwner(((CraftPlayer) owner.getPlayer()).getHandle());
}
plugin.getFoxUUIDs().put(spawnedFox.getUniqueID(), ownerUUID);
spawnedFox.setChosenName(results.getString("NAME"));
}
foxList.add(spawnedFox);
}
return foxList;
} catch (SQLException e) {
e.printStackTrace();
} finally {
if (sqLiteHandler.getConnection() != null) {
try {
sqLiteHandler.getConnection().close();
} catch (SQLException e) {
e.printStackTrace();
}
}
}
return null;
}
public void removeFox(int databaseID) {
plugin = TamableFoxes.getPlugin(TamableFoxes.class);
try {
sqLiteHandler.connect();
PreparedStatement statement = sqLiteHandler.getConnection().prepareStatement("DELETE FROM foxes WHERE INDEX=" + databaseID);
statement.setInt(1, databaseID);
statement.executeUpdate();
} catch (SQLException e) {
e.printStackTrace();
@ -79,42 +171,7 @@ public class SQLiteSetterGetter {
}
}
public List<EntityTamableFox> spawnFoxes() {
plugin = Dexun.getPlugin(Dexun.class);
try {
sqLiteHandler.connect();
PreparedStatement statement = sqLiteHandler.getConnection()
.prepareStatement("SELECT * FROM foxes");
ResultSet results = statement.executeQuery();
results.next();
String banReasonsSTR = results.getString("REASONS");
String banDatesSTR = results.getString("ON_DATES");
String banEndDatesSTR = results.getString("END_DATES");
String unbanReasonsSTR = results.getString("UNBAN_REASONS");
List<String> banReasons = new LinkedList<String>(Arrays.asList(banReasonsSTR.substring(1).split(",")));
List<String> banDates = new LinkedList<String>(Arrays.asList(banDatesSTR.substring(1).split(",")));
List<String> banEndDates = new LinkedList<String>(Arrays.asList(banEndDatesSTR.substring(1).split(",")));
List<String> unbanReasons = new LinkedList<String>(Arrays.asList(unbanReasonsSTR.substring(1).split(",")));
List<List<String>> bans = new ArrayList<List<String>>();
bans.add(banReasons);
bans.add(banDates);
bans.add(banEndDates);
bans.add(unbanReasons);
return bans;
} catch (SQLException e) {
e.printStackTrace();
} finally {
if (sqLiteHandler.getConnection() != null) {
try {
sqLiteHandler.getConnection().close();
} catch (SQLException e) {
e.printStackTrace();
}
}
}
public void removeFox(EntityTamableFox fox) {
removeFox(fox.databaseIndex);
}
}

View File

@ -1,6 +1,6 @@
name: TamableFoxes
version: 1.4-RELEASE
main: net.seanomilk.tamablefoxes.TamableFoxes
version: 1.4.1-SNAPSHOT
main: net.seanomik.tamablefoxes.TamableFoxes
api-version: 1.15
load: POSTWORLD
description: Modified version of TamableFoxes for 1.15.1.

View File

@ -1,6 +1,6 @@
name: TamableFoxes
version: 1.4-RELEASE
main: net.seanomilk.tamablefoxes.TamableFoxes
version: 1.4.1-SNAPSHOT
main: net.seanomik.tamablefoxes.TamableFoxes
api-version: 1.15
load: POSTWORLD
description: Modified version of TamableFoxes for 1.15.1.

View File

@ -1,21 +1,23 @@
net\seanomilk\tamablefoxes\EntityTamableFox.class
net\seanomilk\tamablefoxes\pathfinding\FoxPathfindGoalBreed.class
net\seanomilk\tamablefoxes\TamableFoxes.class
net\seanomilk\tamablefoxes\command\CommandSpawnTamableFox.class
net\seanomilk\tamablefoxes\io\FileManager$Config.class
net\seanomilk\tamablefoxes\pathfinding\FoxPathfindGoalFloat.class
net\seanomilk\tamablefoxes\pathfinding\FoxPathfindGoalFollowOwner.class
net\seanomilk\tamablefoxes\pathfinding\FoxPathfindGoalMeleeAttack.class
net\seanomilk\tamablefoxes\io\FileManager.class
net\seanomilk\tamablefoxes\EntityTamableFox$UpdateFoxRunnable.class
net\seanomilk\tamablefoxes\pathfinding\FoxPathfindGoalRandomTargetNonTamed.class
net\seanomilk\tamablefoxes\pathfinding\FoxPathfindGoalBeg.class
net\seanomilk\tamablefoxes\pathfinding\FoxPathfindGoalPickBushes.class
net\seanomilk\tamablefoxes\pathfinding\FoxPathfindGoalOwnerHurtByTarget.class
net\seanomilk\tamablefoxes\pathfinding\FoxPathfindGoalFleeSun.class
net\seanomilk\tamablefoxes\pathfinding\FoxPathfindGoalSit.class
net\seanomilk\tamablefoxes\pathfinding\FoxPathfindGoalLungeUNKNOWN_USE.class
net\seanomilk\tamablefoxes\pathfinding\FoxPathfindGoalLunge.class
net\seanomilk\tamablefoxes\pathfinding\FoxPathfindGoalHurtByTarget.class
net\seanomilk\tamablefoxes\pathfinding\FoxPathfindGoalRandomStrollLand.class
net\seanomilk\tamablefoxes\pathfinding\FoxPathfindGoalOwnerHurtTarget.class
net\seanomik\tamablefoxes\EntityTamableFox.class
net\seanomik\tamablefoxes\pathfinding\FoxPathfindGoalOwnerHurtByTarget.class
net\seanomik\tamablefoxes\io\FileManager$Config.class
net\seanomik\tamablefoxes\command\CommandSpawnTamableFox.class
net\seanomik\tamablefoxes\pathfinding\FoxPathfindGoalSit.class
net\seanomik\tamablefoxes\sqlite\SQLiteSetterGetter.class
net\seanomik\tamablefoxes\pathfinding\FoxPathfindGoalBeg.class
net\seanomik\tamablefoxes\pathfinding\FoxPathfindGoalRandomStrollLand.class
net\seanomik\tamablefoxes\pathfinding\FoxPathfindGoalLunge.class
net\seanomik\tamablefoxes\pathfinding\FoxPathfindGoalFloat.class
net\seanomik\tamablefoxes\pathfinding\FoxPathfindGoalMeleeAttack.class
net\seanomik\tamablefoxes\pathfinding\FoxPathfindGoalRandomTargetNonTamed.class
net\seanomik\tamablefoxes\pathfinding\FoxPathfindGoalFleeSun.class
net\seanomik\tamablefoxes\pathfinding\FoxPathfindGoalOwnerHurtTarget.class
net\seanomik\tamablefoxes\io\FileManager.class
net\seanomik\tamablefoxes\pathfinding\FoxPathfindGoalBreed.class
net\seanomik\tamablefoxes\pathfinding\FoxPathfindGoalFollowOwner.class
net\seanomik\tamablefoxes\sqlite\SQLiteHandler.class
net\seanomik\tamablefoxes\TamableFoxes.class
net\seanomik\tamablefoxes\EntityTamableFox$UpdateFoxRunnable.class
net\seanomik\tamablefoxes\pathfinding\FoxPathfindGoalLungeUNKNOWN_USE.class
net\seanomik\tamablefoxes\pathfinding\FoxPathfindGoalPickBushes.class
net\seanomik\tamablefoxes\pathfinding\FoxPathfindGoalHurtByTarget.class

View File

@ -1,19 +1,21 @@
D:\Code\java\spigotPlugins\myPlugins\GitTamableFoxes\src\main\java\net\seanomilk\tamablefoxes\pathfinding\FoxPathfindGoalRandomTargetNonTamed.java
D:\Code\java\spigotPlugins\myPlugins\GitTamableFoxes\src\main\java\net\seanomilk\tamablefoxes\command\CommandSpawnTamableFox.java
D:\Code\java\spigotPlugins\myPlugins\GitTamableFoxes\src\main\java\net\seanomilk\tamablefoxes\pathfinding\FoxPathfindGoalLunge.java
D:\Code\java\spigotPlugins\myPlugins\GitTamableFoxes\src\main\java\net\seanomilk\tamablefoxes\pathfinding\FoxPathfindGoalOwnerHurtTarget.java
D:\Code\java\spigotPlugins\myPlugins\GitTamableFoxes\src\main\java\net\seanomilk\tamablefoxes\pathfinding\FoxPathfindGoalRandomStrollLand.java
D:\Code\java\spigotPlugins\myPlugins\GitTamableFoxes\src\main\java\net\seanomilk\tamablefoxes\EntityTamableFox.java
D:\Code\java\spigotPlugins\myPlugins\GitTamableFoxes\src\main\java\net\seanomilk\tamablefoxes\pathfinding\FoxPathfindGoalHurtByTarget.java
D:\Code\java\spigotPlugins\myPlugins\GitTamableFoxes\src\main\java\net\seanomilk\tamablefoxes\pathfinding\FoxPathfindGoalOwnerHurtByTarget.java
D:\Code\java\spigotPlugins\myPlugins\GitTamableFoxes\src\main\java\net\seanomilk\tamablefoxes\pathfinding\FoxPathfindGoalPickBushes.java
D:\Code\java\spigotPlugins\myPlugins\GitTamableFoxes\src\main\java\net\seanomilk\tamablefoxes\pathfinding\FoxPathfindGoalFollowOwner.java
D:\Code\java\spigotPlugins\myPlugins\GitTamableFoxes\src\main\java\net\seanomilk\tamablefoxes\pathfinding\FoxPathfindGoalSit.java
D:\Code\java\spigotPlugins\myPlugins\GitTamableFoxes\src\main\java\net\seanomilk\tamablefoxes\pathfinding\FoxPathfindGoalFloat.java
D:\Code\java\spigotPlugins\myPlugins\GitTamableFoxes\src\main\java\net\seanomilk\tamablefoxes\io\FileManager.java
D:\Code\java\spigotPlugins\myPlugins\GitTamableFoxes\src\main\java\net\seanomilk\tamablefoxes\pathfinding\FoxPathfindGoalFleeSun.java
D:\Code\java\spigotPlugins\myPlugins\GitTamableFoxes\src\main\java\net\seanomilk\tamablefoxes\pathfinding\FoxPathfindGoalBeg.java
D:\Code\java\spigotPlugins\myPlugins\GitTamableFoxes\src\main\java\net\seanomilk\tamablefoxes\pathfinding\FoxPathfindGoalBreed.java
D:\Code\java\spigotPlugins\myPlugins\GitTamableFoxes\src\main\java\net\seanomilk\tamablefoxes\pathfinding\FoxPathfindGoalLungeUNKNOWN_USE.java
D:\Code\java\spigotPlugins\myPlugins\GitTamableFoxes\src\main\java\net\seanomilk\tamablefoxes\pathfinding\FoxPathfindGoalMeleeAttack.java
D:\Code\java\spigotPlugins\myPlugins\GitTamableFoxes\src\main\java\net\seanomilk\tamablefoxes\TamableFoxes.java
D:\Code\java\spigotPlugins\myPlugins\GitTamableFoxes\src\main\java\net\seanomik\tamablefoxes\pathfinding\FoxPathfindGoalRandomStrollLand.java
D:\Code\java\spigotPlugins\myPlugins\GitTamableFoxes\src\main\java\net\seanomik\tamablefoxes\pathfinding\FoxPathfindGoalRandomTargetNonTamed.java
D:\Code\java\spigotPlugins\myPlugins\GitTamableFoxes\src\main\java\net\seanomik\tamablefoxes\pathfinding\FoxPathfindGoalLunge.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\pathfinding\FoxPathfindGoalBeg.java
D:\Code\java\spigotPlugins\myPlugins\GitTamableFoxes\src\main\java\net\seanomik\tamablefoxes\pathfinding\FoxPathfindGoalPickBushes.java
D:\Code\java\spigotPlugins\myPlugins\GitTamableFoxes\src\main\java\net\seanomik\tamablefoxes\pathfinding\FoxPathfindGoalBreed.java
D:\Code\java\spigotPlugins\myPlugins\GitTamableFoxes\src\main\java\net\seanomik\tamablefoxes\pathfinding\FoxPathfindGoalMeleeAttack.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\FoxPathfindGoalFleeSun.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\pathfinding\FoxPathfindGoalLungeUNKNOWN_USE.java
D:\Code\java\spigotPlugins\myPlugins\GitTamableFoxes\src\main\java\net\seanomik\tamablefoxes\pathfinding\FoxPathfindGoalOwnerHurtByTarget.java
D:\Code\java\spigotPlugins\myPlugins\GitTamableFoxes\src\main\java\net\seanomik\tamablefoxes\pathfinding\FoxPathfindGoalOwnerHurtTarget.java
D:\Code\java\spigotPlugins\myPlugins\GitTamableFoxes\src\main\java\net\seanomik\tamablefoxes\pathfinding\FoxPathfindGoalSit.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\FoxPathfindGoalFloat.java
D:\Code\java\spigotPlugins\myPlugins\GitTamableFoxes\src\main\java\net\seanomik\tamablefoxes\io\FileManager.java
D:\Code\java\spigotPlugins\myPlugins\GitTamableFoxes\src\main\java\net\seanomik\tamablefoxes\pathfinding\FoxPathfindGoalHurtByTarget.java
D:\Code\java\spigotPlugins\myPlugins\GitTamableFoxes\src\main\java\net\seanomik\tamablefoxes\pathfinding\FoxPathfindGoalFollowOwner.java