Finish rewrite, and release it

This commit is contained in:
SeanOMik 2020-01-26 01:05:18 -06:00
parent eb8080796c
commit 071efa181c
No known key found for this signature in database
GPG Key ID: FA4D55AC05268A88
14 changed files with 319 additions and 116 deletions

View File

@ -7,9 +7,11 @@
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
<outputRelativeToContentRoot value="true" />
<module name="TamableFoxesCustomEntity" />
<module name="tamableFoxes" />
</profile>
</annotationProcessing>
<bytecodeTargetLevel>
<module name="tamableFoxes" target="1.8" />
<module name="TamableFoxesCustomEntity" target="1.8" />
</bytecodeTargetLevel>
</component>

View File

@ -2,16 +2,19 @@
<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/io/LanguageConfig.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/main/resources/language.yml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/compiler.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/compiler.xml" 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/seanomik/tamablefoxes/Config.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/net/seanomik/tamablefoxes/io/Config.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/net/seanomik/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/seanomik/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/seanomik/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/seanomik/tamablefoxes/sqlite/SQLiteSetterGetter.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/net/seanomik/tamablefoxes/sqlite/SQLiteSetterGetter.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/config.yml" beforeDir="false" afterPath="$PROJECT_DIR$/target/classes/config.yml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/target/classes/foxes.yml" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/target/classes/plugin.yml" beforeDir="false" afterPath="$PROJECT_DIR$/target/classes/plugin.yml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst" beforeDir="false" afterPath="$PROJECT_DIR$/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst" afterDir="false" />
<change beforePath="$PROJECT_DIR$/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst" beforeDir="false" afterPath="$PROJECT_DIR$/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
@ -46,7 +49,7 @@
</component>
<component name="PropertiesComponent">
<property name="RunOnceActivity.ShowReadmeOnStart" value="true" />
<property name="last_opened_file_path" value="$PROJECT_DIR$" />
<property name="last_opened_file_path" value="$PROJECT_DIR$/src/main/java/net/seanomik/tamablefoxes/io" />
<property name="project.structure.last.edited" value="Modules" />
<property name="project.structure.proportion" value="0.0" />
<property name="project.structure.side.proportion" value="0.0" />
@ -55,19 +58,14 @@
</component>
<component name="RecentsManager">
<key name="CopyFile.RECENT_KEYS">
<recent name="D:\Code\java\spigotPlugins\myPlugins\GitTamableFoxes\src\main\java\net\seanomik\tamablefoxes\io" />
<recent name="E:\TamableFoxesCustomEntity\src\main\resources" />
</key>
</component>
<component name="RunManager">
<component name="RunManager" selected="JAR Application.Spigot-1.15.1">
<configuration name="Spigot-1.15.1" type="JarApplication">
<option name="JAR_PATH" value="$PROJECT_DIR$/../../_TEST_SERVER_/spigot-1.15.1.jar" />
<option name="WORKING_DIRECTORY" value="D:\Code\java\spigotPlugins\_TEST_SERVER_" />
<option name="ALTERNATIVE_JRE_PATH" />
<method v="2" />
</configuration>
<configuration name="Spigot1.15.1" type="JarApplication">
<option name="JAR_PATH" value="$PROJECT_DIR$/../_TEST_SERVER_1.15.1_/spigot-1.15.1.jar" />
<option name="WORKING_DIRECTORY" value="E:\_TEST_SERVER_1.15.1_" />
<option name="JAR_PATH" value="$PROJECT_DIR$/../../_TEST_SERVER_1.15.1_/spigot-1.15.1.jar" />
<option name="WORKING_DIRECTORY" value="D:\Code\java\spigotPlugins\_TEST_SERVER_1.15.1_" />
<option name="ALTERNATIVE_JRE_PATH" />
<method v="2" />
</configuration>
@ -104,7 +102,7 @@
<method v="2" />
</configuration>
<list>
<item itemvalue="JAR Application.Spigot1.15.1" />
<item itemvalue="JAR Application.Spigot-1.15.1" />
<item itemvalue="Maven.TamableFoxesCustomEntity build" />
</list>
</component>
@ -125,7 +123,7 @@
</component>
<component name="TaskManager">
<task active="true" id="Default" summary="Default task">
<changelist id="1e646e82-3081-41be-8f2b-5b16afa0760d" name="Default Changelist" comment="" />
<changelist id="dcab9632-7b1a-44d7-9283-be9b37640afc" name="Default Changelist" comment="" />
<created>1579657428994</created>
<option name="number" value="Default" />
<option name="presentableId" value="Default" />
@ -134,14 +132,10 @@
<servers />
</component>
<component name="WindowStateProjectService">
<state x="414" y="174" key="#com.intellij.execution.impl.EditConfigurationsDialog" timestamp="1579664182600">
<state x="414" y="174" key="#com.intellij.execution.impl.EditConfigurationsDialog" timestamp="1580016134312">
<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="1579664182600" />
<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="414" y="174" key="#com.intellij.execution.impl.EditConfigurationsDialog/0.0.1920.1040/-1920.0.1920.1040@0.0.1920.1040" timestamp="1579738103949" />
<state x="414" y="174" key="#com.intellij.execution.impl.EditConfigurationsDialog/0.0.1920.1040/-1920.0.1920.1040@0.0.1920.1040" timestamp="1580016134312" />
<state x="414" y="174" key="#com.intellij.execution.impl.EditConfigurationsDialog/1920.0.1920.1040/0.0.1920.1040@0.0.1920.1040" timestamp="1579710781130" />
<state x="765" y="230" key="#com.intellij.ide.util.MemberChooser" timestamp="1579737522244">
<screen x="0" y="0" width="1920" height="1040" />
@ -152,50 +146,59 @@
<screen x="0" y="0" width="1920" height="1040" />
</state>
<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="218" key="GridCell.Tab.0.bottom" timestamp="1579666091685">
<state width="1877" height="234" key="GridCell.Tab.0.bottom" timestamp="1580022271776">
<screen x="0" y="0" width="1920" height="1040" />
</state>
<state width="1877" height="218" key="GridCell.Tab.0.bottom/0.0.1920.1040/-1920.0.1920.1040@0.0.1920.1040" timestamp="1579666091685" />
<state width="1877" height="218" key="GridCell.Tab.0.center" timestamp="1579666091685">
<state width="1877" height="234" key="GridCell.Tab.0.bottom/0.0.1920.1040/-1920.0.1920.1040@0.0.1920.1040" timestamp="1580022271776" />
<state width="1877" height="234" key="GridCell.Tab.0.center" timestamp="1580022271776">
<screen x="0" y="0" width="1920" height="1040" />
</state>
<state width="1877" height="218" key="GridCell.Tab.0.center/0.0.1920.1040/-1920.0.1920.1040@0.0.1920.1040" timestamp="1579666091685" />
<state width="1877" height="218" key="GridCell.Tab.0.left" timestamp="1579666091685">
<state width="1877" height="234" key="GridCell.Tab.0.center/0.0.1920.1040/-1920.0.1920.1040@0.0.1920.1040" timestamp="1580022271776" />
<state width="1877" height="234" key="GridCell.Tab.0.left" timestamp="1580022271776">
<screen x="0" y="0" width="1920" height="1040" />
</state>
<state width="1877" height="218" key="GridCell.Tab.0.left/0.0.1920.1040/-1920.0.1920.1040@0.0.1920.1040" timestamp="1579666091685" />
<state width="1877" height="218" key="GridCell.Tab.0.right" timestamp="1579666091685">
<state width="1877" height="234" key="GridCell.Tab.0.left/0.0.1920.1040/-1920.0.1920.1040@0.0.1920.1040" timestamp="1580022271776" />
<state width="1877" height="234" key="GridCell.Tab.0.right" timestamp="1580022271776">
<screen x="0" y="0" width="1920" height="1040" />
</state>
<state width="1877" height="218" key="GridCell.Tab.0.right/0.0.1920.1040/-1920.0.1920.1040@0.0.1920.1040" timestamp="1579666091685" />
<state width="1877" height="216" key="GridCell.Tab.1.bottom" timestamp="1579666076544">
<state width="1877" height="234" key="GridCell.Tab.0.right/0.0.1920.1040/-1920.0.1920.1040@0.0.1920.1040" timestamp="1580022271776" />
<state width="1877" height="234" key="GridCell.Tab.1.bottom" timestamp="1580022271776">
<screen x="0" y="0" width="1920" height="1040" />
</state>
<state width="1877" height="216" key="GridCell.Tab.1.bottom/0.0.1920.1040/-1920.0.1920.1040@0.0.1920.1040" timestamp="1579666076544" />
<state width="1877" height="216" key="GridCell.Tab.1.center" timestamp="1579666076544">
<state width="1877" height="234" key="GridCell.Tab.1.bottom/0.0.1920.1040/-1920.0.1920.1040@0.0.1920.1040" timestamp="1580022271776" />
<state width="1877" height="234" key="GridCell.Tab.1.center" timestamp="1580022271776">
<screen x="0" y="0" width="1920" height="1040" />
</state>
<state width="1877" height="216" key="GridCell.Tab.1.center/0.0.1920.1040/-1920.0.1920.1040@0.0.1920.1040" timestamp="1579666076544" />
<state width="1877" height="216" key="GridCell.Tab.1.left" timestamp="1579666076544">
<state width="1877" height="234" key="GridCell.Tab.1.center/0.0.1920.1040/-1920.0.1920.1040@0.0.1920.1040" timestamp="1580022271776" />
<state width="1877" height="234" key="GridCell.Tab.1.left" timestamp="1580022271776">
<screen x="0" y="0" width="1920" height="1040" />
</state>
<state width="1877" height="216" key="GridCell.Tab.1.left/0.0.1920.1040/-1920.0.1920.1040@0.0.1920.1040" timestamp="1579666076544" />
<state width="1877" height="216" key="GridCell.Tab.1.right" timestamp="1579666076544">
<state width="1877" height="234" key="GridCell.Tab.1.left/0.0.1920.1040/-1920.0.1920.1040@0.0.1920.1040" timestamp="1580022271776" />
<state width="1877" height="234" key="GridCell.Tab.1.right" timestamp="1580022271776">
<screen x="0" y="0" width="1920" height="1040" />
</state>
<state width="1877" height="216" key="GridCell.Tab.1.right/0.0.1920.1040/-1920.0.1920.1040@0.0.1920.1040" timestamp="1579666076544" />
<state width="1877" height="234" key="GridCell.Tab.1.right/0.0.1920.1040/-1920.0.1920.1040@0.0.1920.1040" timestamp="1580022271776" />
<state x="490" y="174" key="Maven.ArtifactSearchDialog" timestamp="1579373377880">
<screen x="0" y="0" width="1920" height="1040" />
</state>
<state width="498" height="446" key="SwitcherDM/1920.0.1920.1040/0.0.1920.1040@0.0.1920.1040" timestamp="1579705820492" />
<state x="2283" y="214" key="com.intellij.ide.util.TipDialog" timestamp="1579874695988">
<screen x="1920" 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="1579469022098" />
<state width="498" height="446" key="SwitcherDM/1920.0.1920.1040/0.0.1920.1040@0.0.1920.1040" timestamp="1579705820492" />
<state x="656" y="343" key="com.intellij.ide.util.TipDialog" timestamp="1579647313147">
<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="1579647313147" />
<state x="-781" y="188" width="1359" height="1028" key="dock-window-1" timestamp="1580017524734">
<screen x="-1920" y="0" width="1920" height="1040" />
</state>
<state x="-781" y="188" width="1359" height="1028" key="dock-window-1/0.0.1920.1040/-1920.0.1920.1040@0.0.1920.1040" timestamp="1580017524734" />
<state x="-809" y="141" width="1359" height="1028" key="dock-window-2" timestamp="1580018302720">
<screen x="-1920" y="0" width="1920" height="1040" />
</state>
<state x="-809" y="141" width="1359" height="1028" key="dock-window-2/0.0.1920.1040/-1920.0.1920.1040@0.0.1920.1040" timestamp="1580018302720" />
<state x="656" y="125" width="607" height="789" key="find.popup" timestamp="1580018609474">
<screen x="0" y="0" width="1920" height="1040" />
</state>
<state x="656" y="125" width="607" height="789" key="find.popup/0.0.1920.1040/-1920.0.1920.1040@0.0.1920.1040" timestamp="1580018609474" />
<state x="342" y="189" key="new project wizard" timestamp="1579657428699">
<screen x="0" y="0" width="1920" height="1040" />
</state>

13
pom.xml
View File

@ -39,8 +39,8 @@
<goal>shade</goal>
</goals>
<configuration>
<!--<outputFile>D:\Code\java\spigotPlugins\_TEST_SERVER_2_\plugins\${project.artifactId}-MC-1.15.1-${project.version}.jar</outputFile>-->
<outputFile>E:\_TEST_SERVER_1.15.1_\plugins\${project.artifactId}-MC-1.15.1-${project.version}.jar</outputFile>
<outputFile>D:\Code\java\spigotPlugins\_TEST_SERVER_1.15.1_\plugins\TamableFoxes-MC-v1.15.1-v${project.version}.jar</outputFile>
<!--<outputFile>E:\_TEST_SERVER_1.15.1_\plugins\${project.artifactId}-MC-1.15.1-${project.version}.jar</outputFile>-->
<createDependencyReducedPom>false</createDependencyReducedPom>
</configuration>
</execution>
@ -71,18 +71,11 @@
</repositories>
<dependencies>
<!--<dependency>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId>
<version>1.15.1-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>-->
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId>
<version>1.15.1</version>
<scope>system</scope>
<systemPath>E:/spigot-1.15.1.jar</systemPath>
</dependency>
<dependency>
<groupId>com.github.WesJD.AnvilGUI</groupId>

View File

@ -2,6 +2,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 org.bukkit.ChatColor;
import org.bukkit.craftbukkit.v1_15_R1.inventory.CraftItemStack;
@ -241,7 +242,7 @@ public class EntityTamableFox extends EntityFox {
return this.jumping;
}
private void updateFoxVisual() {
public void updateFoxVisual() {
new UpdateFoxRunnable().runTask(TamableFoxes.getPlugin());
}

View File

@ -1,16 +1,15 @@
package net.seanomik.tamablefoxes;
import com.google.common.collect.Iterables;
import com.google.common.collect.Lists;
import net.minecraft.server.v1_15_R1.EntityFox;
import net.minecraft.server.v1_15_R1.EntityLiving;
import net.minecraft.server.v1_15_R1.EntityTypes;
import net.minecraft.server.v1_15_R1.EnumItemSlot;
import net.minecraft.server.v1_15_R1.*;
import net.seanomik.tamablefoxes.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.wesjd.anvilgui.AnvilGUI;
import org.bukkit.*;
import org.bukkit.Material;
import org.bukkit.Particle;
import org.bukkit.craftbukkit.v1_15_R1.entity.CraftEntity;
import org.bukkit.craftbukkit.v1_15_R1.entity.CraftPlayer;
import org.bukkit.entity.Entity;
@ -18,7 +17,10 @@ import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityDeathEvent;
import org.bukkit.event.entity.EntitySpawnEvent;
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.WorldSaveEvent;
@ -31,13 +33,10 @@ import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
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
// Add fox sleeping when the player sleeps
// Foxes will be loaded in as sitting, even if they weren't when the server was shutdown (sometimes)
public final class TamableFoxes extends JavaPlugin implements Listener {
private static TamableFoxes plugin;
public List<EntityTamableFox> spawnedFoxes = new ArrayList<>();
@ -45,12 +44,19 @@ public final class TamableFoxes extends JavaPlugin implements Listener {
public SQLiteSetterGetter sqLiteSetterGetter = new SQLiteSetterGetter();
public SQLiteHandler sqLiteHandler = new SQLiteHandler();
private boolean versionSupported = true;
@Override
public void onLoad() {
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 + "This plugin version only supports 1.15.1! Not registering entity!");
Bukkit.getServer().getConsoleSender().sendMessage(Utils.getPrefix() + ChatColor.RED + LanguageConfig.getUnsupportedMCVersionRegister());
versionSupported = false;
return;
}
@ -68,25 +74,22 @@ public final class TamableFoxes extends JavaPlugin implements Listener {
field.setAccessible(false);
getServer().getConsoleSender().sendMessage(Utils.getPrefix() + ChatColor.GREEN + "Replaced tamable fox entity!");
getServer().getConsoleSender().sendMessage(Utils.getPrefix() + ChatColor.GREEN + LanguageConfig.getSuccessReplaced());
} catch (Exception e) {
e.printStackTrace();
getServer().getConsoleSender().sendMessage(Utils.getPrefix() + ChatColor.RED + "Failed to replace tamable fox entity!");
getServer().getConsoleSender().sendMessage(Utils.getPrefix() + ChatColor.RED + LanguageConfig.getFailureReplace());
}
}
@Override
public void onEnable() {
String version = Bukkit.getServer().getClass().getPackage().getName();
if (!version.equals("org.bukkit.craftbukkit.v1_15_R1")) {
Bukkit.getServer().getConsoleSender().sendMessage(Utils.getPrefix() + ChatColor.RED + "This plugin version only supports 1.15.1! Disabling plugin!");
if (!versionSupported) {
Bukkit.getServer().getConsoleSender().sendMessage(Utils.getPrefix() + ChatColor.RED + LanguageConfig.getUnsupportedMCVersionDisable());
getServer().getPluginManager().disablePlugin(this);
return;
}
plugin = this;
getServer().getPluginManager().registerEvents(this, this);
this.getCommand("spawntamablefox").setExecutor(new CommandSpawnTamableFox(this));
@ -100,7 +103,7 @@ public final class TamableFoxes extends JavaPlugin implements Listener {
@Override
public void onDisable() {
getServer().getConsoleSender().sendMessage(Utils.getPrefix() + ChatColor.YELLOW + "Saving foxes.");
getServer().getConsoleSender().sendMessage(Utils.getPrefix() + ChatColor.YELLOW + LanguageConfig.getSavingFoxMessage());
sqLiteSetterGetter.saveFoxes(spawnedFoxes);
}
@ -178,8 +181,8 @@ public final class TamableFoxes extends JavaPlugin implements Listener {
player.getWorld().spawnParticle(Particle.HEART, entity.getLocation(), 6, 0.5D, 0.5D, 0.5D);
// Name fox
player.sendMessage(ChatColor.RED + ChatColor.BOLD.toString() + "You just tamed a wild fox!");
player.sendMessage(ChatColor.RED + "What do you want to call it?");
player.sendMessage(ChatColor.RED + ChatColor.BOLD.toString() + LanguageConfig.getTamedMessage());
player.sendMessage(ChatColor.RED + LanguageConfig.getTamingAskingName());
tamableFox.setChosenName("???");
//TamableFoxes.getPlugin().sqLiteSetterGetter.saveFox(tamableFox);
@ -189,7 +192,7 @@ public final class TamableFoxes extends JavaPlugin implements Listener {
.onComplete((plr, text) -> { // Called when the inventory output slot is clicked
if(!text.equals("")) {
tamableFox.setChosenName(text);
plr.sendMessage(Utils.getPrefix() + ChatColor.GREEN + text + " is perfect!");
plr.sendMessage(Utils.getPrefix() + ChatColor.GREEN + LanguageConfig.getTamingChosenPerfect(text));
TamableFoxes.getPlugin().sqLiteSetterGetter.saveFox(tamableFox);
}
@ -213,6 +216,50 @@ public final class TamableFoxes extends JavaPlugin implements Listener {
}
}
@EventHandler
public void onPlayerBedEnterEvent(PlayerBedEnterEvent event) {
Player player = event.getPlayer();
List<EntityTamableFox> foxesOf = getFoxesOf(player);
for (EntityTamableFox tamableFox : foxesOf) {
if (player.getWorld().getTime() > 12541L && player.getWorld().getTime() < 23460L) {
tamableFox.setSleeping(true);
}
}
}
@EventHandler
public void onPlayerBedLeaveEvent(PlayerBedLeaveEvent event) {
Player player = event.getPlayer();
List<EntityTamableFox> foxesOf = getFoxesOf(player);
for (EntityTamableFox tamableFox : foxesOf) {
tamableFox.setSleeping(false);
if (tamableFox.isSitting()) {
tamableFox.setSitting(true);
}
}
}
@EventHandler
public void onEntityDeathEvent(EntityDeathEvent event) {
Entity entity = event.getEntity();
if (!Utils.isTamableFox(entity)) return; // Is the entity a tamable fox?
// Remove the fox from storage
spawnedFoxes.remove(entity);
// Notify the owner
EntityTamableFox tamableFox = (EntityTamableFox) ((CraftEntity) entity).getHandle();
if (tamableFox.getOwner() != null) {
Player owner = ((EntityPlayer) tamableFox.getOwner()).getBukkitEntity();
owner.sendMessage(Utils.getPrefix() + ChatColor.RED + tamableFox.getChosenName() + " was killed!");
}
// Remove the fox from database
sqLiteSetterGetter.removeFox(tamableFox);
}
public EntityTamableFox spawnTamableFox(Location loc, EntityFox.Type type) {
EntityTamableFox tamableFox = (EntityTamableFox) ((CraftEntity) loc.getWorld().spawnEntity(loc, EntityType.FOX)).getHandle();
tamableFox.setFoxType(type);
@ -221,7 +268,7 @@ public final class TamableFoxes extends JavaPlugin implements Listener {
}
public List<EntityTamableFox> getFoxesOf(Player player) {
return spawnedFoxes.stream().filter(fox -> fox.getOwnerUUID() != null && fox.getOwnerUUID().equals(player.getUniqueId())).collect(Collectors.toList());
return spawnedFoxes.stream().filter(fox -> fox.getOwner() != null && fox.getOwner().getUniqueID().equals(player.getUniqueId())).collect(Collectors.toList());
}
public static TamableFoxes getPlugin() {

View File

@ -1,22 +1,17 @@
package net.seanomik.tamablefoxes.command;
import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Util;
import net.seanomik.tamablefoxes.Config;
import net.seanomik.tamablefoxes.EntityTamableFox;
import net.seanomik.tamablefoxes.TamableFoxes;
import net.minecraft.server.v1_15_R1.EntityFox;
import net.seanomik.tamablefoxes.Utils;
import net.seanomik.tamablefoxes.io.LanguageConfig;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabExecutor;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import java.util.Arrays;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
@ -31,12 +26,12 @@ public class CommandSpawnTamableFox implements TabExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (!(sender instanceof Player)) {
sender.sendMessage("Command can only be run from player state.");
sender.sendMessage(Utils.getPrefix() + ChatColor.RED + LanguageConfig.getOnlyRunPlayer());
return true;
}
if (!sender.hasPermission("tamablefoxes.spawntamablefox")) {
sender.sendMessage(ChatColor.RED + "You do not have the permission for this command.");
sender.sendMessage(Utils.getPrefix() + ChatColor.RED + LanguageConfig.getNoPermMessage());
return true;
}
@ -46,30 +41,29 @@ public class CommandSpawnTamableFox implements TabExecutor {
case "red":
try {
EntityTamableFox fox = plugin.spawnTamableFox(player.getLocation(), EntityFox.Type.RED);
//plugin.getSpawnedFoxes().add(fox);
plugin.sqLiteSetterGetter.saveFox(fox);
player.sendMessage(Utils.getPrefix() + ChatColor.RESET + "Spawned a " + ChatColor.RED + "Red" + ChatColor.WHITE + " fox.");
player.sendMessage(Utils.getPrefix() + ChatColor.RESET + LanguageConfig.getSpawnedFoxMessage(EntityFox.Type.RED));
} catch (Exception e) {
e.printStackTrace();
player.sendMessage(Utils.getPrefix() + ChatColor.RED + "Failed to spawn fox, check console!");
player.sendMessage(Utils.getPrefix() + ChatColor.RED + LanguageConfig.getFailureSpawn());
}
break;
case "snow":
try {
EntityTamableFox spawnedFox = plugin.spawnTamableFox(player.getLocation(), EntityFox.Type.SNOW);
//plugin.getSpawnedFoxes().add(spawnedFox);
plugin.sqLiteSetterGetter.saveFox(spawnedFox);
player.sendMessage(Utils.getPrefix() + ChatColor.RESET + "Spawned a " + ChatColor.AQUA + "Snow" + ChatColor.WHITE + " fox.");
player.sendMessage(Utils.getPrefix() + ChatColor.RESET + LanguageConfig.getSpawnedFoxMessage(EntityFox.Type.SNOW));
} catch (Exception e) {
e.printStackTrace();
player.sendMessage(Utils.getPrefix() + ChatColor.RED + "Failed to spawn fox, check console!");
player.sendMessage(Utils.getPrefix() + ChatColor.RED + LanguageConfig.getFailureSpawn());
}
break;
case "reload":
plugin.reloadConfig();
player.sendMessage(Utils.getPrefix() + ChatColor.GREEN + "Reloaded.");
LanguageConfig.getConfig().reloadConfig();
player.sendMessage(Utils.getPrefix() + ChatColor.GREEN + LanguageConfig.getReloadMessage());
break;
default:
player.sendMessage(ChatColor.RED + "/spawntamablefox " + ChatColor.GRAY + "[red | snow | reload]");

View File

@ -1,5 +1,6 @@
package net.seanomik.tamablefoxes;
package net.seanomik.tamablefoxes.io;
import net.seanomik.tamablefoxes.TamableFoxes;
import org.bukkit.entity.Player;
public class Config {

View File

@ -0,0 +1,136 @@
package net.seanomik.tamablefoxes.io;
import net.minecraft.server.v1_15_R1.EntityFox;
import net.seanomik.tamablefoxes.TamableFoxes;
import org.bukkit.ChatColor;
import org.bukkit.configuration.file.YamlConfiguration;
import java.io.File;
public class LanguageConfig extends YamlConfiguration {
private static LanguageConfig config;
private TamableFoxes plugin;
private File configFile;
public static LanguageConfig getConfig() {
if (LanguageConfig.config == null) {
LanguageConfig.config = new LanguageConfig();
}
return LanguageConfig.config;
}
public LanguageConfig() {
this.plugin = TamableFoxes.getPlugin();
this.configFile = new File(this.plugin.getDataFolder(), "language.yml");
this.saveDefault();
this.reload();
}
public void reload() {
try {
super.load(this.configFile);
}
catch (Exception e) {
e.printStackTrace();
}
}
public void save() {
try {
super.save(this.configFile);
}
catch (Exception e) {
e.printStackTrace();
}
}
public void saveDefault() {
this.plugin.saveResource("language.yml", false);
}
public void saveConfig() {
try {
super.save(this.configFile);
}
catch (Exception e) {
e.printStackTrace();
}
}
public void reloadConfig() {
try {
super.load(this.configFile);
}
catch (Exception e) {
e.printStackTrace();
}
}
public void saveDefaultConfig() {
try {
this.plugin.saveDefaultConfig();
}
catch (Exception e) {
e.printStackTrace();
}
}
public static String getUnsupportedMCVersionRegister() {
return getConfig().getString("unsupported-mc-version-not-registering");
}
public static String getUnsupportedMCVersionDisable() {
return getConfig().getString("unsupported-mc-version-disabling");
}
public static String getSuccessReplaced() {
return getConfig().getString("success-replaced-entity");
}
public static String getFailureReplace() {
return getConfig().getString("error-to-replaced-entity");
}
public static String getSavingFoxMessage() {
return getConfig().getString("saving-foxes-message");
}
public static String getTamedMessage() {
return getConfig().getString("taming-tamed-message");
}
public static String getTamingAskingName() {
return getConfig().getString("taming-asking-for-name-message");
}
public static String getTamingChosenPerfect(String chosen) {
return getConfig().getString("taming-chosen-name-perfect").replaceAll("%NAME%", chosen);
}
public static String getNoPermMessage() {
return getConfig().getString("no-permission");
}
public static String getOnlyRunPlayer() {
return getConfig().getString("only-run-by-player");
}
public static String getSpawnedFoxMessage(EntityFox.Type type) {
String typeStr = ((type == type.SNOW) ? ChatColor.AQUA + "Snow" : ChatColor.RED + "Red") + ChatColor.RESET;
return getConfig().getString("spawned-fox-message").replaceAll("%TYPE%", typeStr);
}
public static String getFailureSpawn() {
return getConfig().getString("failed-to-spawn-message");
}
public static String getReloadMessage() {
return getConfig().getString("reloaded-message");
}
public static String getCreatedSQLDatabase() {
return getConfig().getString("created-sql-foxes-database");
}
}

View File

@ -6,6 +6,7 @@ import net.minecraft.server.v1_15_R1.EnumItemSlot;
import net.seanomik.tamablefoxes.EntityTamableFox;
import net.seanomik.tamablefoxes.TamableFoxes;
import net.seanomik.tamablefoxes.Utils;
import net.seanomik.tamablefoxes.io.LanguageConfig;
import org.apache.commons.lang.ObjectUtils;
import org.bukkit.Bukkit;
import org.bukkit.Location;
@ -49,7 +50,7 @@ public class SQLiteSetterGetter {
PreparedStatement statement = sqLiteHandler.getConnection().prepareStatement(foxesTable);
statement.executeUpdate();
plugin.getServer().getConsoleSender().sendMessage(Utils.getPrefix() + "Created foxes table!");
plugin.getServer().getConsoleSender().sendMessage(Utils.getPrefix() + LanguageConfig.getCreatedSQLDatabase());
}
} catch (SQLException e) {
e.printStackTrace();
@ -139,8 +140,12 @@ public class SQLiteSetterGetter {
toRemoveLater.add(entityUUID);
continue;
}
boolean tamed = false;
EntityTamableFox tamableFox = (EntityTamableFox) ((CraftEntity) plugin.getServer().getEntity(entityUUID)).getHandle();
if (!ownerUUIDString.equals("none")) {
tamed = true;
OfflinePlayer owner = plugin.getServer().getOfflinePlayer(UUID.fromString(ownerUUIDString));
if (owner.isOnline()) {
EntityLiving livingOwner = (EntityLiving) ((CraftEntity) owner).getHandle();
@ -154,7 +159,9 @@ public class SQLiteSetterGetter {
// Fox may spawn standing if the server was closed while it was sitting.
if (sitting) {
if (tamed) {
tamableFox.setHardSitting(true);
}
} else if (sleeping) {
tamableFox.setSleeping(true);
}

View File

@ -0,0 +1,18 @@
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!"
success-replaced-entity: "Replaced tamable fox entity!"
error-to-replaced-entity: "Failed to replace tamable fox entity!"
saving-foxes-message: "Saving foxes."
taming-tamed-message: "You just tamed a wild fox!"
taming-asking-for-name-message: "What do you want to call it?"
taming-chosen-name-perfect: "%NAME% is perfect!"
no-permission: "You do not have the permission for this command."
only-run-by-player: "Command can only be run from player state!"
spawned-fox-message: "Spawned a %TYPE% fox."
failed-to-spawn-message: "Failed to spawn fox!"
reloaded-message: "Reloaded"
created-sql-foxes-database: "Created foxes SQLite database!"

View File

@ -2,10 +2,8 @@ name: Tamablefoxes
version: ${project.version}
main: net.seanomik.tamablefoxes.TamableFoxes
api-version: 1.15
#load: STARTUP
load: POSTWORLD
#load: STARTUP
description: Modified version of TamableFoxes for 1.15.1.
description: Adds tamable foxes to Minecraft!
commands:
spawntamablefox:

View File

@ -5,7 +5,7 @@ api-version: 1.15
#load: STARTUP
load: POSTWORLD
#load: STARTUP
description: Modified version of TamableFoxes for 1.15.1.
description: Adds tamable foxes to Minecraft!
commands:
spawntamablefox:

View File

@ -1,15 +1,16 @@
net\seanomik\tamablefoxes\EntityTamableFox.class
net\seanomik\tamablefoxes\pathfinding\FoxPathfinderGoalOwnerHurtByTarget.class
net\seanomik\tamablefoxes\command\CommandSpawnTamableFox.class
net\seanomik\tamablefoxes\pathfinding\FoxPathfinderGoalFollowOwner.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\sqlite\SQLiteHandler.class
net\seanomik\tamablefoxes\TamableFoxes.class
net\seanomik\tamablefoxes\EntityTamableFox$UpdateFoxRunnable.class
net\seanomik\tamablefoxes\Config.class
net\seanomik\tamablefoxes\pathfinding\FoxPathfinderGoalHurtByTarget.class
net\seanomik\tamablefoxes\sqlite\SQLiteSetterGetter.class
net\seanomik\tamablefoxes\pathfinding\FoxPathfinderGoalPanic.class
net\seanomik\tamablefoxes\Utils.class
net\seanomik\tamablefoxes\pathfinding\FoxPathfinderGoalOwnerHurtTarget.class
net\seanomik\tamablefoxes\pathfinding\FoxPathfinderGoalMeleeAttack.class
net\seanomik\tamablefoxes\io\Config.class

View File

@ -1,13 +1,15 @@
E:\TamableFoxesCustomEntity\src\main\java\net\seanomik\tamablefoxes\sqlite\SQLiteHandler.java
E:\TamableFoxesCustomEntity\src\main\java\net\seanomik\tamablefoxes\pathfinding\FoxPathfindGoalOwnerHurtByTarget.java
E:\TamableFoxesCustomEntity\src\main\java\net\seanomik\tamablefoxes\pathfinding\FoxPathfindGoalSit.java
E:\TamableFoxesCustomEntity\src\main\java\net\seanomik\tamablefoxes\pathfinding\FoxPathfindGoalHurtByTarget.java
E:\TamableFoxesCustomEntity\src\main\java\net\seanomik\tamablefoxes\Config.java
E:\TamableFoxesCustomEntity\src\main\java\net\seanomik\tamablefoxes\pathfinding\FoxPathfinderGoalMeleeAttack.java
E:\TamableFoxesCustomEntity\src\main\java\net\seanomik\tamablefoxes\EntityTamableFox.java
E:\TamableFoxesCustomEntity\src\main\java\net\seanomik\tamablefoxes\pathfinding\FoxPathfindGoalOwnerHurtTarget.java
E:\TamableFoxesCustomEntity\src\main\java\net\seanomik\tamablefoxes\sqlite\SQLiteSetterGetter.java
E:\TamableFoxesCustomEntity\src\main\java\net\seanomik\tamablefoxes\Utils.java
E:\TamableFoxesCustomEntity\src\main\java\net\seanomik\tamablefoxes\command\CommandSpawnTamableFox.java
E:\TamableFoxesCustomEntity\src\main\java\net\seanomik\tamablefoxes\TamableFoxes.java
E:\TamableFoxesCustomEntity\src\main\java\net\seanomik\tamablefoxes\pathfinding\FoxPathfindGoalFollowOwner.java
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