Give fox command - bring up name screen for receiving player (#72)

This commit is contained in:
SeanOMik 2022-01-31 23:58:42 -05:00
parent ddfc667d65
commit 2b37feec07
14 changed files with 67 additions and 9 deletions

View File

@ -46,4 +46,10 @@ public class NMSInterface_1_14_R1 implements NMSInterface {
EntityTamableFox tamableFox = (EntityTamableFox) ((CraftEntity) fox).getHandle(); EntityTamableFox tamableFox = (EntityTamableFox) ((CraftEntity) fox).getHandle();
return tamableFox.getOwnerUUID(); return tamableFox.getOwnerUUID();
} }
@Override
public void renameFox(org.bukkit.entity.Fox fox, Player player) {
EntityTamableFox tamableFox = (EntityTamableFox) ((CraftEntity) fox).getHandle();
tamableFox.rename(player);
}
} }

View File

@ -46,4 +46,10 @@ public class NMSInterface_1_15_R1 implements NMSInterface {
EntityTamableFox tamableFox = (EntityTamableFox) ((CraftEntity) fox).getHandle(); EntityTamableFox tamableFox = (EntityTamableFox) ((CraftEntity) fox).getHandle();
return tamableFox.getOwnerUUID(); return tamableFox.getOwnerUUID();
} }
@Override
public void renameFox(org.bukkit.entity.Fox fox, Player player) {
EntityTamableFox tamableFox = (EntityTamableFox) ((CraftEntity) fox).getHandle();
tamableFox.rename(player);
}
} }

View File

@ -46,4 +46,10 @@ public class NMSInterface_1_16_R1 implements NMSInterface {
EntityTamableFox tamableFox = (EntityTamableFox) ((CraftEntity) fox).getHandle(); EntityTamableFox tamableFox = (EntityTamableFox) ((CraftEntity) fox).getHandle();
return tamableFox.getOwnerUUID(); return tamableFox.getOwnerUUID();
} }
@Override
public void renameFox(org.bukkit.entity.Fox fox, Player player) {
EntityTamableFox tamableFox = (EntityTamableFox) ((CraftEntity) fox).getHandle();
tamableFox.rename(player);
}
} }

View File

@ -46,4 +46,10 @@ public class NMSInterface_1_16_R2 implements NMSInterface {
EntityTamableFox tamableFox = (EntityTamableFox) ((CraftEntity) fox).getHandle(); EntityTamableFox tamableFox = (EntityTamableFox) ((CraftEntity) fox).getHandle();
return tamableFox.getOwnerUUID(); return tamableFox.getOwnerUUID();
} }
@Override
public void renameFox(org.bukkit.entity.Fox fox, Player player) {
EntityTamableFox tamableFox = (EntityTamableFox) ((CraftEntity) fox).getHandle();
tamableFox.rename(player);
}
} }

View File

@ -46,4 +46,10 @@ public class NMSInterface_1_16_R3 implements NMSInterface {
EntityTamableFox tamableFox = (EntityTamableFox) ((CraftEntity) fox).getHandle(); EntityTamableFox tamableFox = (EntityTamableFox) ((CraftEntity) fox).getHandle();
return tamableFox.getOwnerUUID(); return tamableFox.getOwnerUUID();
} }
@Override
public void renameFox(org.bukkit.entity.Fox fox, Player player) {
EntityTamableFox tamableFox = (EntityTamableFox) ((CraftEntity) fox).getHandle();
tamableFox.rename(player);
}
} }

View File

@ -45,4 +45,10 @@ public class NMSInterface_1_17_1_R1 implements NMSInterface {
EntityTamableFox tamableFox = (EntityTamableFox) ((CraftEntity) fox).getHandle(); EntityTamableFox tamableFox = (EntityTamableFox) ((CraftEntity) fox).getHandle();
return tamableFox.getOwnerUUID(); return tamableFox.getOwnerUUID();
} }
@Override
public void renameFox(org.bukkit.entity.Fox fox, Player player) {
EntityTamableFox tamableFox = (EntityTamableFox) ((CraftEntity) fox).getHandle();
tamableFox.rename(player);
}
} }

View File

@ -45,4 +45,10 @@ public class NMSInterface_1_17_R1 implements NMSInterface {
EntityTamableFox tamableFox = (EntityTamableFox) ((CraftEntity) fox).getHandle(); EntityTamableFox tamableFox = (EntityTamableFox) ((CraftEntity) fox).getHandle();
return tamableFox.getOwnerUUID(); return tamableFox.getOwnerUUID();
} }
@Override
public void renameFox(org.bukkit.entity.Fox fox, Player player) {
EntityTamableFox tamableFox = (EntityTamableFox) ((CraftEntity) fox).getHandle();
tamableFox.rename(player);
}
} }

View File

@ -45,4 +45,10 @@ public class NMSInterface_1_18_1_R1 implements NMSInterface {
EntityTamableFox tamableFox = (EntityTamableFox) ((CraftEntity) fox).getHandle(); EntityTamableFox tamableFox = (EntityTamableFox) ((CraftEntity) fox).getHandle();
return tamableFox.getOwnerUUID(); return tamableFox.getOwnerUUID();
} }
@Override
public void renameFox(org.bukkit.entity.Fox fox, Player player) {
EntityTamableFox tamableFox = (EntityTamableFox) ((CraftEntity) fox).getHandle();
tamableFox.rename(player);
}
} }

View File

@ -45,4 +45,10 @@ public class NMSInterface_1_18_R1 implements NMSInterface {
EntityTamableFox tamableFox = (EntityTamableFox) ((CraftEntity) fox).getHandle(); EntityTamableFox tamableFox = (EntityTamableFox) ((CraftEntity) fox).getHandle();
return tamableFox.getOwnerUUID(); return tamableFox.getOwnerUUID();
} }
@Override
public void renameFox(org.bukkit.entity.Fox fox, Player player) {
EntityTamableFox tamableFox = (EntityTamableFox) ((CraftEntity) fox).getHandle();
tamableFox.rename(player);
}
} }

View File

@ -58,7 +58,8 @@
<goal>shade</goal> <goal>shade</goal>
</goals> </goals>
<configuration> <configuration>
<outputFile>C:\Development\Java\Spigot Servers\${server.version}\plugins\TamableFoxes_v${project.parent.version}.jar</outputFile> <outputFile>/home/seanomik/Development/java/spigot-dev/test-servers/${server.version}/plugins/TamableFoxes_v${project.parent.version}.jar</outputFile>
<!--<outputFile>C:\Development\Java\Spigot Servers\${server.version}\plugins\TamableFoxes_v${project.parent.version}.jar</outputFile>-->
<createDependencyReducedPom>false</createDependencyReducedPom> <createDependencyReducedPom>false</createDependencyReducedPom>
</configuration> </configuration>
</execution> </execution>

View File

@ -71,6 +71,14 @@ public class CommandGiveFox implements TabExecutor {
if (plugin.nmsInterface.getFoxOwner(fox).equals(player.getUniqueId()) || if (plugin.nmsInterface.getFoxOwner(fox).equals(player.getUniqueId()) ||
player.hasPermission("tamablefoxes.givefox.give.others")) { player.hasPermission("tamablefoxes.givefox.give.others")) {
plugin.nmsInterface.changeFoxOwner(fox, givingToPlayer); plugin.nmsInterface.changeFoxOwner(fox, givingToPlayer);
Bukkit.getScheduler().runTask(plugin, r2 -> {
// If the player that is receiving the fox is online, prompt them to rename their new fox!
if (givingToPlayer.isOnline()) {
plugin.nmsInterface.renameFox(fox, givingToPlayer);
}
});
sender.sendMessage(Config.getPrefix() + ChatColor.GREEN + LanguageConfig.getGaveFox(givingToPlayer)); sender.sendMessage(Config.getPrefix() + ChatColor.GREEN + LanguageConfig.getGaveFox(givingToPlayer));
} else { } else {
sender.sendMessage(Config.getPrefix() + ChatColor.RED + LanguageConfig.getNotYourFox()); sender.sendMessage(Config.getPrefix() + ChatColor.RED + LanguageConfig.getNotYourFox());

View File

@ -1,11 +1,5 @@
package net.seanomik.tamablefoxes.util; package net.seanomik.tamablefoxes.util;
import net.seanomik.tamablefoxes.util.io.Config;
import net.seanomik.tamablefoxes.util.io.LanguageConfig;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import sun.misc.Unsafe;
import sun.misc.Unsafe; import sun.misc.Unsafe;
import java.lang.reflect.Field; import java.lang.reflect.Field;

View File

@ -16,4 +16,5 @@ public interface NMSInterface {
void spawnTamableFox(Location loc, FoxType type); void spawnTamableFox(Location loc, FoxType type);
void changeFoxOwner(Fox fox, Player newOwner); void changeFoxOwner(Fox fox, Player newOwner);
UUID getFoxOwner(Fox fox); UUID getFoxOwner(Fox fox);
void renameFox(org.bukkit.entity.Fox fox, Player player);
} }

View File

@ -158,7 +158,7 @@ public class LanguageConfig extends YamlConfiguration {
if (str == null || str.isEmpty()) { if (str == null || str.isEmpty()) {
str = "Right click the fox that you want to give to " + transferringTo.getDisplayName() + "."; str = "Right click the fox that you want to give to " + transferringTo.getDisplayName() + ".";
} else { } else {
str.replace("%TRANSFER_TO_PLAYER%", transferringTo.getDisplayName()); str = str.replace("%TRANSFER_TO_PLAYER%", transferringTo.getDisplayName());
} }
return str; return str;
@ -169,7 +169,7 @@ public class LanguageConfig extends YamlConfiguration {
if (str == null || str.isEmpty()) { if (str == null || str.isEmpty()) {
str = "Fox has been given to " + givingTo.getDisplayName() + "!"; str = "Fox has been given to " + givingTo.getDisplayName() + "!";
} else { } else {
str.replace("%GAVE_TO_PLAYER%", givingTo.getDisplayName()); str = str.replace("%GAVE_TO_PLAYER%", givingTo.getDisplayName());
} }
return str; return str;