fancynpcs: Add swing_arm_on_update option (#135)

This commit is contained in:
envizar
2025-11-04 22:02:00 +03:00
committed by GitHub
parent ac2a4f6e93
commit 414da48403
3 changed files with 17 additions and 4 deletions

View File

@@ -35,6 +35,8 @@ public interface FancyNpcsConfig {
int getRemoveNpcsFromPlayerlistDelay(); int getRemoveNpcsFromPlayerlistDelay();
boolean isSwingArmOnUpdate();
String getMineSkinApiKey(); String getMineSkinApiKey();
List<String> getBlockedCommands(); List<String> getBlockedCommands();

View File

@@ -121,7 +121,7 @@ public abstract class Npc {
public abstract void update(Player player, boolean swingArm); public abstract void update(Player player, boolean swingArm);
public void update(Player player) { public void update(Player player) {
update(player, true); update(player, FancyNpcsPlugin.get().getFancyNpcConfig().isSwingArmOnUpdate());
} }
public void updateForAll(boolean swingArm) { public void updateForAll(boolean swingArm) {
@@ -131,13 +131,13 @@ public abstract class Npc {
} }
public void updateForAll() { public void updateForAll() {
updateForAll(true); updateForAll(FancyNpcsPlugin.get().getFancyNpcConfig().isSwingArmOnUpdate());
} }
public abstract void move(Player player, boolean swingArm); public abstract void move(Player player, boolean swingArm);
public void move(Player player) { public void move(Player player) {
move(player, true); move(player, FancyNpcsPlugin.get().getFancyNpcConfig().isSwingArmOnUpdate());
} }
public void moveForAll(boolean swingArm) { public void moveForAll(boolean swingArm) {
@@ -147,7 +147,7 @@ public abstract class Npc {
} }
public void moveForAll() { public void moveForAll() {
moveForAll(true); moveForAll(FancyNpcsPlugin.get().getFancyNpcConfig().isSwingArmOnUpdate());
} }
public void interact(Player player) { public void interact(Player player) {

View File

@@ -78,6 +78,12 @@ public class FancyNpcsConfigImpl implements FancyNpcsConfig {
*/ */
private int removeNpcsFromPlayerlistDelay; private int removeNpcsFromPlayerlistDelay;
/**
* Whether MPCs should swing arm on update.
*/
private boolean swingArmOnUpdate;
/** /**
* The API key for the MineSkin API. * The API key for the MineSkin API.
*/ */
@@ -139,6 +145,9 @@ public class FancyNpcsConfigImpl implements FancyNpcsConfig {
removeNpcsFromPlayerlistDelay = (int) ConfigHelper.getOrDefault(config, "remove_npcs_from_playerlist_delay", 2000); removeNpcsFromPlayerlistDelay = (int) ConfigHelper.getOrDefault(config, "remove_npcs_from_playerlist_delay", 2000);
config.setInlineComments("remove_npcs_from_playerlist_delay", List.of("The delay in milliseconds to remove NPCs from the player list. Increase this value if you have problems with skins not loading correctly when joining or switching worlds. You can set it to -1, if you don't have any npcs using the show_in_tab feature.")); config.setInlineComments("remove_npcs_from_playerlist_delay", List.of("The delay in milliseconds to remove NPCs from the player list. Increase this value if you have problems with skins not loading correctly when joining or switching worlds. You can set it to -1, if you don't have any npcs using the show_in_tab feature."));
swingArmOnUpdate = (boolean) ConfigHelper.getOrDefault(config, "swing_arm_on_update", true);
config.setInlineComments("swing_arm_on_update", List.of("Whether NPCs should swing arm on update."));
blockedCommands = (List<String>) ConfigHelper.getOrDefault(config, "blocked_commands", Arrays.asList("op", "ban")); blockedCommands = (List<String>) ConfigHelper.getOrDefault(config, "blocked_commands", Arrays.asList("op", "ban"));
config.setInlineComments("blocked_commands", List.of("The commands that are blocked for NPCs in the message.")); config.setInlineComments("blocked_commands", List.of("The commands that are blocked for NPCs in the message."));
@@ -231,6 +240,8 @@ public class FancyNpcsConfigImpl implements FancyNpcsConfig {
return removeNpcsFromPlayerlistDelay; return removeNpcsFromPlayerlistDelay;
} }
public boolean isSwingArmOnUpdate() { return swingArmOnUpdate; }
public String getMineSkinApiKey() { public String getMineSkinApiKey() {
if (mineskinApiKey.isEmpty()) { if (mineskinApiKey.isEmpty()) {
return null; return null;