Completely update the re-implemented plugin to how it was before.

Completely update the re-implemented plugin to how it was before.

Changelog:
 * Re-add fox naming.
 * Added an auto alternative color code translator in LanguageConfig.
 
Pretty sure this is it, now its time to create a new release!
This commit is contained in:
SeanOMik 2020-03-30 14:57:56 -05:00
parent 2f0dc9c501
commit f754c69e72
No known key found for this signature in database
GPG Key ID: FA4D55AC05268A88
10 changed files with 224 additions and 173 deletions

View File

@ -3,19 +3,21 @@
<component name="ChangeListManager">
<list default="true" id="dcab9632-7b1a-44d7-9283-be9b37640afc" name="Default Changelist" comment="">
<change beforePath="$PROJECT_DIR$/.gitignore" beforeDir="false" afterPath="$PROJECT_DIR$/.gitignore" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/misc.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/misc.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/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/Utils.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/net/seanomik/tamablefoxes/Utils.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/net/seanomik/tamablefoxes/io/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/io/LanguageConfig.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/net/seanomik/tamablefoxes/io/LanguageConfig.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/net/seanomik/tamablefoxes/versions/version_1_15/command/CommandSpawnTamableFox.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/net/seanomik/tamablefoxes/versions/version_1_15/command/CommandSpawnTamableFox.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/net/seanomik/tamablefoxes/versions/version_1_15/pathfinding/FoxPathfinderGoalFollowOwner.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/net/seanomik/tamablefoxes/versions/version_1_15/pathfinding/FoxPathfinderGoalFollowOwner.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/net/seanomik/tamablefoxes/versions/version_1_15/pathfinding/FoxPathfinderGoalMeleeAttack.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/net/seanomik/tamablefoxes/versions/version_1_15/pathfinding/FoxPathfinderGoalMeleeAttack.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/net/seanomik/tamablefoxes/versions/version_1_15/pathfinding/FoxPathfinderGoalOwnerHurtByTarget.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/net/seanomik/tamablefoxes/versions/version_1_15/pathfinding/FoxPathfinderGoalOwnerHurtByTarget.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/net/seanomik/tamablefoxes/versions/version_1_15/pathfinding/FoxPathfinderGoalOwnerHurtTarget.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/net/seanomik/tamablefoxes/versions/version_1_15/pathfinding/FoxPathfinderGoalOwnerHurtTarget.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/resources/config.yml" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/resources/config.yml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/resources/language.yml" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/resources/language.yml" 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" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
@ -186,10 +188,10 @@
<state x="414" y="174" key="#com.intellij.execution.impl.EditConfigurationsDialog/0.0.1920.1040/-1920.0.1920.1040@0.0.1920.1040" timestamp="1585594670133" />
<state x="414" y="174" key="#com.intellij.execution.impl.EditConfigurationsDialog/0.0.1920.1040/1920.0.1920.1040@0.0.1920.1040" timestamp="1580229888801" />
<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="1580580882620">
<screen x="0" y="0" width="1920" height="1040" />
<state x="-1203" y="274" key="#com.intellij.ide.util.MemberChooser" timestamp="1585596287933">
<screen x="-1920" y="0" width="1920" height="1040" />
</state>
<state x="765" y="230" key="#com.intellij.ide.util.MemberChooser/0.0.1920.1040/-1920.0.1920.1040@0.0.1920.1040" timestamp="1580580882620" />
<state x="-1203" y="274" key="#com.intellij.ide.util.MemberChooser/0.0.1920.1040/-1920.0.1920.1040@0.0.1920.1040" timestamp="1585596287933" />
<state x="765" y="230" key="#com.intellij.ide.util.MemberChooser/1920.0.1920.1040/0.0.1920.1040@0.0.1920.1040" timestamp="1579708181770" />
<state x="808" y="409" key="#com.intellij.ide.util.projectWizard.JdkChooserPanel.MyDialog" timestamp="1585594689529">
<screen x="0" y="0" width="1920" height="1040" />
@ -213,56 +215,56 @@
<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="1580081718270" />
<state width="1877" height="197" key="GridCell.Tab.0.bottom" timestamp="1585595254677">
<state width="1877" height="197" key="GridCell.Tab.0.bottom" timestamp="1585597922096">
<screen x="0" y="0" width="1920" height="1040" />
</state>
<state width="1877" height="197" key="GridCell.Tab.0.bottom/0.0.1920.1040/-1920.0.1920.1040@0.0.1920.1040" timestamp="1585595254677" />
<state width="1877" height="197" key="GridCell.Tab.0.bottom/0.0.1920.1040/-1920.0.1920.1040@0.0.1920.1040" timestamp="1585597922096" />
<state width="939" height="355" key="GridCell.Tab.0.bottom/0.0.1920.1040/1920.0.1920.1040@0.0.1920.1040" timestamp="1580234020859" />
<state width="1879" height="282" key="GridCell.Tab.0.bottom/0.0.1920.1040/1920.0.1920.1040@1920.0.1920.1040" timestamp="1582226910732" />
<state width="1877" height="199" key="GridCell.Tab.0.bottom/1920.0.1920.1040/0.0.1920.1040@0.0.1920.1040" timestamp="1580134668965" />
<state width="1877" height="197" key="GridCell.Tab.0.center" timestamp="1585595254677">
<state width="1877" height="197" key="GridCell.Tab.0.center" timestamp="1585597922096">
<screen x="0" y="0" width="1920" height="1040" />
</state>
<state width="1877" height="197" key="GridCell.Tab.0.center/0.0.1920.1040/-1920.0.1920.1040@0.0.1920.1040" timestamp="1585595254677" />
<state width="1877" height="197" key="GridCell.Tab.0.center/0.0.1920.1040/-1920.0.1920.1040@0.0.1920.1040" timestamp="1585597922096" />
<state width="939" height="355" key="GridCell.Tab.0.center/0.0.1920.1040/1920.0.1920.1040@0.0.1920.1040" timestamp="1580234020858" />
<state width="1879" height="282" key="GridCell.Tab.0.center/0.0.1920.1040/1920.0.1920.1040@1920.0.1920.1040" timestamp="1582226910732" />
<state width="1877" height="199" key="GridCell.Tab.0.center/1920.0.1920.1040/0.0.1920.1040@0.0.1920.1040" timestamp="1580134668964" />
<state width="1877" height="197" key="GridCell.Tab.0.left" timestamp="1585595254676">
<state width="1877" height="197" key="GridCell.Tab.0.left" timestamp="1585597922096">
<screen x="0" y="0" width="1920" height="1040" />
</state>
<state width="1877" height="197" key="GridCell.Tab.0.left/0.0.1920.1040/-1920.0.1920.1040@0.0.1920.1040" timestamp="1585595254676" />
<state width="1877" height="197" key="GridCell.Tab.0.left/0.0.1920.1040/-1920.0.1920.1040@0.0.1920.1040" timestamp="1585597922096" />
<state width="939" height="355" key="GridCell.Tab.0.left/0.0.1920.1040/1920.0.1920.1040@0.0.1920.1040" timestamp="1580234020858" />
<state width="1879" height="282" key="GridCell.Tab.0.left/0.0.1920.1040/1920.0.1920.1040@1920.0.1920.1040" timestamp="1582226910732" />
<state width="1877" height="199" key="GridCell.Tab.0.left/1920.0.1920.1040/0.0.1920.1040@0.0.1920.1040" timestamp="1580134668964" />
<state width="1877" height="197" key="GridCell.Tab.0.right" timestamp="1585595254677">
<state width="1877" height="197" key="GridCell.Tab.0.right" timestamp="1585597922096">
<screen x="0" y="0" width="1920" height="1040" />
</state>
<state width="1877" height="197" key="GridCell.Tab.0.right/0.0.1920.1040/-1920.0.1920.1040@0.0.1920.1040" timestamp="1585595254677" />
<state width="1877" height="197" key="GridCell.Tab.0.right/0.0.1920.1040/-1920.0.1920.1040@0.0.1920.1040" timestamp="1585597922096" />
<state width="939" height="355" key="GridCell.Tab.0.right/0.0.1920.1040/1920.0.1920.1040@0.0.1920.1040" timestamp="1580234020858" />
<state width="1879" height="282" key="GridCell.Tab.0.right/0.0.1920.1040/1920.0.1920.1040@1920.0.1920.1040" timestamp="1582226910732" />
<state width="1877" height="199" key="GridCell.Tab.0.right/1920.0.1920.1040/0.0.1920.1040@0.0.1920.1040" timestamp="1580134668964" />
<state width="1879" height="282" key="GridCell.Tab.1.bottom" timestamp="1582226910717">
<screen x="1920" y="0" width="1920" height="1040" />
<state width="1877" height="197" key="GridCell.Tab.1.bottom" timestamp="1585597922015">
<screen x="0" y="0" width="1920" height="1040" />
</state>
<state width="1877" height="237" key="GridCell.Tab.1.bottom/0.0.1920.1040/-1920.0.1920.1040@0.0.1920.1040" timestamp="1580083439451" />
<state width="1877" height="197" key="GridCell.Tab.1.bottom/0.0.1920.1040/-1920.0.1920.1040@0.0.1920.1040" timestamp="1585597922015" />
<state width="939" height="355" key="GridCell.Tab.1.bottom/0.0.1920.1040/1920.0.1920.1040@0.0.1920.1040" timestamp="1580234020859" />
<state width="1879" height="282" key="GridCell.Tab.1.bottom/0.0.1920.1040/1920.0.1920.1040@1920.0.1920.1040" timestamp="1582226910717" />
<state width="1879" height="282" key="GridCell.Tab.1.center" timestamp="1582226910716">
<screen x="1920" y="0" width="1920" height="1040" />
<state width="1877" height="197" key="GridCell.Tab.1.center" timestamp="1585597922015">
<screen x="0" y="0" width="1920" height="1040" />
</state>
<state width="1877" height="237" key="GridCell.Tab.1.center/0.0.1920.1040/-1920.0.1920.1040@0.0.1920.1040" timestamp="1580083439451" />
<state width="1877" height="197" key="GridCell.Tab.1.center/0.0.1920.1040/-1920.0.1920.1040@0.0.1920.1040" timestamp="1585597922015" />
<state width="939" height="355" key="GridCell.Tab.1.center/0.0.1920.1040/1920.0.1920.1040@0.0.1920.1040" timestamp="1580234020859" />
<state width="1879" height="282" key="GridCell.Tab.1.center/0.0.1920.1040/1920.0.1920.1040@1920.0.1920.1040" timestamp="1582226910716" />
<state width="1879" height="282" key="GridCell.Tab.1.left" timestamp="1582226910716">
<screen x="1920" y="0" width="1920" height="1040" />
<state width="1877" height="197" key="GridCell.Tab.1.left" timestamp="1585597922014">
<screen x="0" y="0" width="1920" height="1040" />
</state>
<state width="1877" height="237" key="GridCell.Tab.1.left/0.0.1920.1040/-1920.0.1920.1040@0.0.1920.1040" timestamp="1580083439451" />
<state width="1877" height="197" key="GridCell.Tab.1.left/0.0.1920.1040/-1920.0.1920.1040@0.0.1920.1040" timestamp="1585597922014" />
<state width="939" height="355" key="GridCell.Tab.1.left/0.0.1920.1040/1920.0.1920.1040@0.0.1920.1040" timestamp="1580234020859" />
<state width="1879" height="282" key="GridCell.Tab.1.left/0.0.1920.1040/1920.0.1920.1040@1920.0.1920.1040" timestamp="1582226910716" />
<state width="1879" height="282" key="GridCell.Tab.1.right" timestamp="1582226910716">
<screen x="1920" y="0" width="1920" height="1040" />
<state width="1877" height="197" key="GridCell.Tab.1.right" timestamp="1585597922015">
<screen x="0" y="0" width="1920" height="1040" />
</state>
<state width="1877" height="237" key="GridCell.Tab.1.right/0.0.1920.1040/-1920.0.1920.1040@0.0.1920.1040" timestamp="1580083439451" />
<state width="1877" height="197" key="GridCell.Tab.1.right/0.0.1920.1040/-1920.0.1920.1040@0.0.1920.1040" timestamp="1585597922015" />
<state width="939" height="355" key="GridCell.Tab.1.right/0.0.1920.1040/1920.0.1920.1040@0.0.1920.1040" timestamp="1580234020859" />
<state width="1879" height="282" key="GridCell.Tab.1.right/0.0.1920.1040/1920.0.1920.1040@1920.0.1920.1040" timestamp="1582226910716" />
<state width="1879" height="282" key="GridCell.Tab.2.bottom" timestamp="1582226910717">
@ -312,10 +314,10 @@
<screen x="0" y="0" width="1920" height="1040" />
</state>
<state x="458" y="257" width="1003" height="602" key="com.intellij.xdebugger.impl.breakpoints.ui.BreakpointsDialogFactory$2/0.0.1920.1040/1920.0.1920.1040@0.0.1920.1040" timestamp="1580233159142" />
<state x="-1340" y="47" width="1356" height="802" maximized="true" key="dock-window-1" timestamp="1585595645245">
<screen x="-1920" y="0" width="1920" height="1040" />
<state x="213" y="285" width="1356" height="802" maximized="true" key="dock-window-1" timestamp="1585598224552">
<screen x="0" y="0" width="1920" height="1040" />
</state>
<state x="-1340" y="47" width="1356" height="802" maximized="true" key="dock-window-1/0.0.1920.1040/-1920.0.1920.1040@0.0.1920.1040" timestamp="1585595645245" />
<state x="213" y="285" width="1356" height="802" maximized="true" key="dock-window-1/0.0.1920.1040/-1920.0.1920.1040@0.0.1920.1040" timestamp="1585598224552" />
<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>
@ -346,20 +348,13 @@
<screen x="0" y="0" width="1920" height="1040" />
</state>
<state x="342" y="189" key="new project wizard/0.0.1920.1040/-1920.0.1920.1040@0.0.1920.1040" timestamp="1579657428699" />
<state x="-1304" y="240" key="run.anything.popup" timestamp="1585596304658">
<screen x="-1920" y="0" width="1920" height="1040" />
</state>
<state x="-1304" y="240" key="run.anything.popup/0.0.1920.1040/-1920.0.1920.1040@0.0.1920.1040" timestamp="1585596304658" />
<state x="623" y="225" width="672" height="678" key="search.everywhere.popup" timestamp="1580063483764">
<screen x="0" y="0" width="1920" height="1040" />
</state>
<state x="623" y="225" width="672" height="678" key="search.everywhere.popup/0.0.1920.1040/-1920.0.1920.1040@0.0.1920.1040" timestamp="1580063483764" />
</component>
<component name="XDebuggerManager">
<breakpoint-manager>
<breakpoints>
<line-breakpoint enabled="true" type="java-line">
<url>file://$PROJECT_DIR$/src/main/java/net/seanomik/tamablefoxes/io/LanguageConfig.java</url>
<line>110</line>
<option name="timeStamp" value="13" />
</line-breakpoint>
</breakpoints>
</breakpoint-manager>
</component>
</project>

View File

@ -39,7 +39,7 @@
<goal>shade</goal>
</goals>
<configuration>
<outputFile>D:\Code\java\spigotPlugins\_TEST_SERVER_1.15.2_\plugins\TamableFoxes-MC-v1.15.1-v${project.version}.jar</outputFile>
<outputFile>D:\Code\java\spigotPlugins\_TEST_SERVER_1.15.2_\plugins\TamableFoxes-MC-v1.15.X-v${project.version}.jar</outputFile>
<!--<outputFile>C:\Users\Checkium\Desktop\vps\smp\SMP\plugins\TamableFoxes-MC-v1.15.X-v${project.version}.jar</outputFile>-->
<createDependencyReducedPom>false</createDependencyReducedPom>
</configuration>
@ -77,6 +77,11 @@
<version>1.15.2-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.github.WesJD.AnvilGUI</groupId>
<artifactId>anvilgui</artifactId>
<version>478e0c1</version>
</dependency>
<!--<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId>

View File

@ -2,10 +2,14 @@ package net.seanomik.tamablefoxes;
import net.minecraft.server.v1_15_R1.*;
import net.seanomik.tamablefoxes.io.Config;
import net.seanomik.tamablefoxes.io.LanguageConfig;
import net.seanomik.tamablefoxes.versions.version_1_15.pathfinding.*;
import net.wesjd.anvilgui.AnvilGUI;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.craftbukkit.v1_15_R1.event.CraftEventFactory;
import org.bukkit.craftbukkit.v1_15_R1.inventory.CraftItemStack;
import org.bukkit.entity.Player;
import org.bukkit.event.entity.EntityRegainHealthEvent;
import javax.annotation.Nullable;
@ -304,23 +308,54 @@ public class EntityTamableFox extends EntityFox {
}
}
} else if (item == Items.CHICKEN) {
// Only remove the item from the player if they're in survival mode.
if (!entityhuman.abilities.canInstantlyBuild) {
itemstack.subtract(1);
}
// Check if the player has permissions to tame the fox
if (Config.canPlayerTameFox((Player) entityhuman.getBukkitEntity())) {
// Only remove the item from the player if they're in survival mode.
if (!entityhuman.abilities.canInstantlyBuild) {
itemstack.subtract(1);
}
// 0.33% chance to tame the fox, also check if the called tame entity event is cancelled or not.
if (this.random.nextInt(3) == 0 && !CraftEventFactory.callEntityTameEvent(this, entityhuman).isCancelled()) {
this.tame(entityhuman);
// 0.33% chance to tame the fox, also check if the called tame entity event is cancelled or not.
if (this.random.nextInt(3) == 0 && !CraftEventFactory.callEntityTameEvent(this, entityhuman).isCancelled()) {
this.tame(entityhuman);
// Remove all navigation when tamed.
this.navigation.o();
this.setGoalTarget(null);
this.goalSit.setSitting(true);
// Remove all navigation when tamed.
this.navigation.o();
this.setGoalTarget(null);
this.goalSit.setSitting(true);
getBukkitEntity().getWorld().spawnParticle(org.bukkit.Particle.HEART, getBukkitEntity().getLocation(), 6, 0.5D, 0.5D, 0.5D);
} else {
getBukkitEntity().getWorld().spawnParticle(org.bukkit.Particle.SMOKE_NORMAL, getBukkitEntity().getLocation(), 10, 0.2D, 0.2D, 0.2D, 0.15D);
getBukkitEntity().getWorld().spawnParticle(org.bukkit.Particle.HEART, getBukkitEntity().getLocation(), 6, 0.5D, 0.5D, 0.5D);
// Give player tamed message.
((Player) entityhuman.getBukkitEntity()).sendMessage(Utils.getPrefix() + ChatColor.GREEN + LanguageConfig.getTamedMessage());
// Let the player choose the new fox's name if its enabled in config.
if (Config.askForNameAfterTaming()) {
Player player = (Player) entityhuman.getBukkitEntity();
player.sendMessage(Utils.getPrefix() + ChatColor.RED + LanguageConfig.getTamingAskingName());
new AnvilGUI.Builder()
.onComplete((plr, input) -> { // Called when the inventory output slot is clicked
if (!input.equals("")) {
org.bukkit.entity.Entity tamableFox = this.getBukkitEntity();
// This will auto format the name for config settings.
String foxName = LanguageConfig.getFoxNameFormat(input, player.getDisplayName());
tamableFox.setCustomName(foxName);
tamableFox.setCustomNameVisible(true);
plr.sendMessage(Utils.getPrefix() + ChatColor.GREEN + LanguageConfig.getTamingChosenPerfect(input));
}
return AnvilGUI.Response.close();
})
.text("Fox name") // Sets the text the GUI should start with
.plugin(TamableFoxes.getPlugin()) // Set the plugin instance
.open(player); // Opens the GUI for the player provided
}
} else {
getBukkitEntity().getWorld().spawnParticle(org.bukkit.Particle.SMOKE_NORMAL, getBukkitEntity().getLocation(), 10, 0.2D, 0.2D, 0.2D, 0.15D);
}
}
return true;

View File

@ -1,25 +1,23 @@
package net.seanomik.tamablefoxes.io;
import net.seanomik.tamablefoxes.TamableFoxes;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.Player;
public class Config {
private static TamableFoxes plugin = TamableFoxes.getPlugin();
private static FileConfiguration config = TamableFoxes.getPlugin().getConfig();
public static boolean doesShowOwnerFoxName() {
return plugin.getConfig().getBoolean("show-owner-in-fox-name");
}
// Does the owner's name show if the foxes name?
public static boolean doesShowOwnerInFoxName() { return config.getBoolean("show-owner-in-fox-name"); }
public static boolean doesTamedAttackWildAnimals() {
return plugin.getConfig().getBoolean("tamed-behavior.attack-wild-animals");
}
// Check if a tamed fox attacks wild animals.
public static boolean doesTamedAttackWildAnimals() { return config.getBoolean("tamed-behavior.attack-wild-animals"); }
// Check if the player can tame the fox.
public static boolean canPlayerTameFox(Player player) {
return !plugin.getConfig().getBoolean("enable-taming-permission") || (plugin.getConfig().getBoolean("enable-taming-permission") && (player.hasPermission("tamablefoxes.tame") || player.isOp()));
}
public static boolean askForNameAfterTaming() {
return plugin.getConfig().getBoolean("ask-for-name-after-taming");
return !config.getBoolean("enable-taming-permission") || (config.getBoolean("enable-taming-permission") && (player.hasPermission("tamablefoxes.tame") || player.isOp()));
}
// Check if the plugin asks for a fox name after taming.
public static boolean askForNameAfterTaming() { return config.getBoolean("ask-for-name-after-taming"); }
}

View File

@ -1,6 +1,7 @@
package net.seanomik.tamablefoxes.io;
import net.minecraft.server.v1_15_R1.EntityFox;
import net.minecraft.server.v1_15_R1.IChatBaseComponent;
import net.seanomik.tamablefoxes.TamableFoxes;
import org.bukkit.ChatColor;
import org.bukkit.configuration.file.YamlConfiguration;
@ -75,40 +76,56 @@ public class LanguageConfig extends YamlConfiguration {
}
}
// Auto replace alternate color codes.
@Override
public String getString(String path) {
// Only attempt to translate if the text is not empty.
return (super.getString(path).isEmpty()) ? super.getString(path) : ChatColor.translateAlternateColorCodes('&', super.getString(path));
}
// Get the error that shows during register when they try to run the plugin on an unsupported mc version.
public static String getUnsupportedMCVersionRegister() {
return getConfig().getString("unsupported-mc-version-not-registering");
}
// Get the error that shows during disable when they try to run the plugin on an unsupported mc version.
public static String getUnsupportedMCVersionDisable() {
return getConfig().getString("unsupported-mc-version-disabling");
}
// Get the message that shows when we successfully replaced the entity.
public static String getSuccessReplaced() {
return getConfig().getString("success-replaced-entity");
}
// Get the error when it failed to replace the entity.
public static String getFailureReplace() {
return getConfig().getString("error-to-replaced-entity");
}
// Get the message when saving foxes.
public static String getSavingFoxMessage() {
return getConfig().getString("saving-foxes-message");
}
// Get the message that shows when you tame a fox.
public static String getTamedMessage() {
return getConfig().getString("taming-tamed-message");
}
// Get the message when you ask for the foxes name.
public static String getTamingAskingName() {
return getConfig().getString("taming-asking-for-name-message");
}
// Get the message when you give feed back on the new fox name.
public static String getTamingChosenPerfect(String chosen) {
return getConfig().getString("taming-chosen-name-perfect").replaceAll("%NAME%", chosen);
return getConfig().getString("taming-chosen-name-perfect").replaceAll("%NEW_FOX_NAME%", chosen);
}
public static String getFoxNameFormat() {
return getConfig().getString("fox-name-format");
// Get the fox name format.
public static String getFoxNameFormat(String foxName, String ownerName) {
return getConfig().getString((Config.doesShowOwnerInFoxName()) ? "fox-name-format" : "fox-name-no-owner-name-format").replaceAll("%FOX_NAME%", foxName).replaceAll("%OWNER%", ownerName);
}
public static String getNoPermMessage() {

View File

@ -1,82 +1,82 @@
package net.seanomik.tamablefoxes.versions.version_1_15.command;
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.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabExecutor;
import org.bukkit.entity.Player;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
public class CommandSpawnTamableFox implements TabExecutor {
private final TamableFoxes plugin;
public CommandSpawnTamableFox(TamableFoxes plugin) {
this.plugin = plugin;
}
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (!(sender instanceof Player)) {
sender.sendMessage(Utils.getPrefix() + ChatColor.RED + LanguageConfig.getOnlyRunPlayer());
return true;
}
if (!sender.hasPermission("tamablefoxes.spawntamablefox")) {
sender.sendMessage(Utils.getPrefix() + ChatColor.RED + LanguageConfig.getNoPermMessage());
return true;
}
Player player = (Player) sender;
if (args.length != 0) {
switch (args[0]) {
case "red":
try {
EntityTamableFox fox = plugin.spawnTamableFox(player.getLocation(), EntityFox.Type.RED);
player.sendMessage(Utils.getPrefix() + ChatColor.RESET + LanguageConfig.getSpawnedFoxMessage(EntityFox.Type.RED));
} catch (Exception e) {
e.printStackTrace();
player.sendMessage(Utils.getPrefix() + ChatColor.RED + LanguageConfig.getFailureSpawn());
}
break;
case "snow":
try {
EntityTamableFox spawnedFox = plugin.spawnTamableFox(player.getLocation(), EntityFox.Type.SNOW);
player.sendMessage(Utils.getPrefix() + ChatColor.RESET + LanguageConfig.getSpawnedFoxMessage(EntityFox.Type.SNOW));
} catch (Exception e) {
e.printStackTrace();
player.sendMessage(Utils.getPrefix() + ChatColor.RED + LanguageConfig.getFailureSpawn());
}
break;
case "reload":
plugin.reloadConfig();
LanguageConfig.getConfig().reloadConfig();
player.sendMessage(Utils.getPrefix() + ChatColor.GREEN + LanguageConfig.getReloadMessage());
break;
default:
player.sendMessage(ChatColor.RED + "/spawntamablefox " + ChatColor.GRAY + "[red | snow | reload]");
}
} else {
player.sendMessage(ChatColor.RED + "/spawntamablefox " + ChatColor.GRAY + "[red | snow | reload]");
}
return true;
}
@Override
public List<String> onTabComplete(CommandSender commandSender, Command command, String s, String[] strings) {
return new LinkedList<>(Arrays.asList(
"red",
"snow",
"reload"
));
}
}
package net.seanomik.tamablefoxes.versions.version_1_15.command;
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.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabExecutor;
import org.bukkit.entity.Player;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
public class CommandSpawnTamableFox implements TabExecutor {
private final TamableFoxes plugin;
public CommandSpawnTamableFox(TamableFoxes plugin) {
this.plugin = plugin;
}
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (!(sender instanceof Player)) {
sender.sendMessage(Utils.getPrefix() + ChatColor.RED + LanguageConfig.getOnlyRunPlayer());
return true;
}
if (!sender.hasPermission("tamablefoxes.spawntamablefox")) {
sender.sendMessage(Utils.getPrefix() + ChatColor.RED + LanguageConfig.getNoPermMessage());
return true;
}
Player player = (Player) sender;
if (args.length != 0) {
switch (args[0]) {
case "red":
try {
EntityTamableFox fox = plugin.spawnTamableFox(player.getLocation(), EntityFox.Type.RED);
player.sendMessage(Utils.getPrefix() + ChatColor.RESET + LanguageConfig.getSpawnedFoxMessage(EntityFox.Type.RED));
} catch (Exception e) {
e.printStackTrace();
player.sendMessage(Utils.getPrefix() + ChatColor.RED + LanguageConfig.getFailureSpawn());
}
break;
case "snow":
try {
EntityTamableFox spawnedFox = plugin.spawnTamableFox(player.getLocation(), EntityFox.Type.SNOW);
player.sendMessage(Utils.getPrefix() + ChatColor.RESET + LanguageConfig.getSpawnedFoxMessage(EntityFox.Type.SNOW));
} catch (Exception e) {
e.printStackTrace();
player.sendMessage(Utils.getPrefix() + ChatColor.RED + LanguageConfig.getFailureSpawn());
}
break;
case "reload":
plugin.reloadConfig();
LanguageConfig.getConfig().reloadConfig();
player.sendMessage(Utils.getPrefix() + ChatColor.GREEN + LanguageConfig.getReloadMessage());
break;
default:
player.sendMessage(ChatColor.RED + "/spawntamablefox " + ChatColor.GRAY + "[red | snow | reload]");
}
} else {
player.sendMessage(ChatColor.RED + "/spawntamablefox " + ChatColor.GRAY + "[red | snow | reload]");
}
return true;
}
@Override
public List<String> onTabComplete(CommandSender commandSender, Command command, String s, String[] strings) {
return new LinkedList<>(Arrays.asList(
"red",
"snow",
"reload"
));
}
}

View File

@ -1,7 +1,7 @@
# Config for Tamable Foxes
show-owner-in-fox-name: false
enable-taming-permission: true
ask-for-name-after-taming: true
tamed-behavior:
# Config for Tamable Foxes
show-owner-in-fox-name: true
enable-taming-permission: true
ask-for-name-after-taming: true
tamed-behavior:
attack-wild-animals: true

View File

@ -6,11 +6,12 @@ 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!"
taming-chosen-name-perfect: "%NEW_FOX_NAME% is perfect!"
fox-name-format: "%FOX_NAME% (%OWNER%'s Fox)"
fox-name-no-owner-name-format: "%FOX_NAME%"
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"
reloaded-message: "Reloaded."

View File

@ -1,5 +1,5 @@
# Config for Tamable Foxes
show-owner-in-fox-name: false
show-owner-in-fox-name: true
enable-taming-permission: true
ask-for-name-after-taming: true

View File

@ -1,13 +1,13 @@
C:\Users\Checkium\IdeaProjects\TamableFoxes\src\main\java\net\seanomik\tamablefoxes\io\LanguageConfig.java
C:\Users\Checkium\IdeaProjects\TamableFoxes\src\main\java\net\seanomik\tamablefoxes\versions\version_1_15\pathfinding\FoxPathfinderGoalMeleeAttack.java
C:\Users\Checkium\IdeaProjects\TamableFoxes\src\main\java\net\seanomik\tamablefoxes\versions\version_1_15\pathfinding\FoxPathfinderGoalHurtByTarget.java
C:\Users\Checkium\IdeaProjects\TamableFoxes\src\main\java\net\seanomik\tamablefoxes\versions\version_1_15\pathfinding\FoxPathfinderGoalOwnerHurtTarget.java
C:\Users\Checkium\IdeaProjects\TamableFoxes\src\main\java\net\seanomik\tamablefoxes\versions\version_1_15\pathfinding\FoxPathfinderGoalFollowOwner.java
C:\Users\Checkium\IdeaProjects\TamableFoxes\src\main\java\net\seanomik\tamablefoxes\versions\version_1_15\pathfinding\FoxPathfinderGoalOwnerHurtByTarget.java
C:\Users\Checkium\IdeaProjects\TamableFoxes\src\main\java\net\seanomik\tamablefoxes\versions\version_1_15\pathfinding\FoxPathfinderGoalSit.java
C:\Users\Checkium\IdeaProjects\TamableFoxes\src\main\java\net\seanomik\tamablefoxes\versions\version_1_15\pathfinding\FoxPathfinderGoalPanic.java
C:\Users\Checkium\IdeaProjects\TamableFoxes\src\main\java\net\seanomik\tamablefoxes\EntityTamableFox.java
C:\Users\Checkium\IdeaProjects\TamableFoxes\src\main\java\net\seanomik\tamablefoxes\versions\version_1_15\command\CommandSpawnTamableFox.java
C:\Users\Checkium\IdeaProjects\TamableFoxes\src\main\java\net\seanomik\tamablefoxes\Utils.java
C:\Users\Checkium\IdeaProjects\TamableFoxes\src\main\java\net\seanomik\tamablefoxes\TamableFoxes.java
C:\Users\Checkium\IdeaProjects\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\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\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\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