Adds debug output and a new working position
All checks were successful
KnarCraft/BlacksmithVisuals/pipeline/head This commit looks good
All checks were successful
KnarCraft/BlacksmithVisuals/pipeline/head This commit looks good
This commit is contained in:
parent
9b04dd042e
commit
b094d34c62
@ -24,6 +24,7 @@ public final class BlacksmithVisuals extends JavaPlugin {
|
|||||||
private static BlacksmithVisuals instance;
|
private static BlacksmithVisuals instance;
|
||||||
private ConfigurationManager configurationManager;
|
private ConfigurationManager configurationManager;
|
||||||
private NPCDataManager npcDataManager;
|
private NPCDataManager npcDataManager;
|
||||||
|
private boolean debug = false;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
@ -35,6 +36,8 @@ public final class BlacksmithVisuals extends JavaPlugin {
|
|||||||
this.reloadConfig();
|
this.reloadConfig();
|
||||||
this.saveConfig();
|
this.saveConfig();
|
||||||
|
|
||||||
|
this.debug = this.getConfig().getBoolean("debug", false);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
this.configurationManager = new ConfigurationManager(this.getConfig());
|
this.configurationManager = new ConfigurationManager(this.getConfig());
|
||||||
} catch (InvalidConfigurationException exception) {
|
} catch (InvalidConfigurationException exception) {
|
||||||
@ -68,7 +71,12 @@ public final class BlacksmithVisuals extends JavaPlugin {
|
|||||||
* @param message <p>The debug message to log</p>
|
* @param message <p>The debug message to log</p>
|
||||||
*/
|
*/
|
||||||
public static void debug(@NotNull String message) {
|
public static void debug(@NotNull String message) {
|
||||||
getInstance().getLogger().log(Level.FINE, message);
|
BlacksmithVisuals instance = getInstance();
|
||||||
|
if (instance.debug) {
|
||||||
|
instance.getLogger().log(Level.INFO, "[Debug] " + message);
|
||||||
|
} else {
|
||||||
|
instance.getLogger().log(Level.FINE, message);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -77,6 +77,7 @@ public class NPCDataManager {
|
|||||||
npcSection.set("workingPositionNetherite", entry.getValue().positions().get(NPCPosition.WORKING_NETHERITE));
|
npcSection.set("workingPositionNetherite", entry.getValue().positions().get(NPCPosition.WORKING_NETHERITE));
|
||||||
npcSection.set("workingPositionCrafting", entry.getValue().positions().get(NPCPosition.WORKING_CRAFTING));
|
npcSection.set("workingPositionCrafting", entry.getValue().positions().get(NPCPosition.WORKING_CRAFTING));
|
||||||
npcSection.set("workingPositionRepairable", entry.getValue().positions().get(NPCPosition.WORKING_REPAIRABLE));
|
npcSection.set("workingPositionRepairable", entry.getValue().positions().get(NPCPosition.WORKING_REPAIRABLE));
|
||||||
|
npcSection.set("workingPositionEnchantedBook", entry.getValue().positions().get(NPCPosition.WORKING_SPLITTING));
|
||||||
npcSection.set("idlePosition", entry.getValue().positions().get(NPCPosition.IDLE));
|
npcSection.set("idlePosition", entry.getValue().positions().get(NPCPosition.IDLE));
|
||||||
}
|
}
|
||||||
configuration.save(configurationFile);
|
configuration.save(configurationFile);
|
||||||
@ -106,6 +107,7 @@ public class NPCDataManager {
|
|||||||
locationMap.put(NPCPosition.WORKING_NETHERITE, section.getLocation("workingPositionNetherite"));
|
locationMap.put(NPCPosition.WORKING_NETHERITE, section.getLocation("workingPositionNetherite"));
|
||||||
locationMap.put(NPCPosition.WORKING_CRAFTING, section.getLocation("workingPositionCrafting"));
|
locationMap.put(NPCPosition.WORKING_CRAFTING, section.getLocation("workingPositionCrafting"));
|
||||||
locationMap.put(NPCPosition.WORKING_REPAIRABLE, section.getLocation("workingPositionRepairable"));
|
locationMap.put(NPCPosition.WORKING_REPAIRABLE, section.getLocation("workingPositionRepairable"));
|
||||||
|
locationMap.put(NPCPosition.WORKING_SPLITTING, section.getLocation("workingPositionEnchantedBook"));
|
||||||
locationMap.put(NPCPosition.IDLE, section.getLocation("idlePosition"));
|
locationMap.put(NPCPosition.IDLE, section.getLocation("idlePosition"));
|
||||||
npcDataMap.put(UUID.fromString(configurationSectionKey), new NPCData(locationMap));
|
npcDataMap.put(UUID.fromString(configurationSectionKey), new NPCData(locationMap));
|
||||||
}
|
}
|
||||||
|
@ -33,6 +33,11 @@ public enum NPCPosition {
|
|||||||
* The position the NPC should be in while un-crafting items
|
* The position the NPC should be in while un-crafting items
|
||||||
*/
|
*/
|
||||||
WORKING_CRAFTING("crafting-workstation", List.of(ScrapperTrait.class)),
|
WORKING_CRAFTING("crafting-workstation", List.of(ScrapperTrait.class)),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The position the NPC should be in while salvaging an enchanted book
|
||||||
|
*/
|
||||||
|
WORKING_SPLITTING("enchanted-book-workstation", List.of(ScrapperTrait.class)),
|
||||||
;
|
;
|
||||||
|
|
||||||
private final String positionName;
|
private final String positionName;
|
||||||
@ -71,6 +76,7 @@ public enum NPCPosition {
|
|||||||
case CRAFTING_TABLE -> NPCPosition.WORKING_CRAFTING;
|
case CRAFTING_TABLE -> NPCPosition.WORKING_CRAFTING;
|
||||||
case ANVIL -> NPCPosition.WORKING_REPAIRABLE;
|
case ANVIL -> NPCPosition.WORKING_REPAIRABLE;
|
||||||
case SMITHING_TABLE -> NPCPosition.WORKING_NETHERITE;
|
case SMITHING_TABLE -> NPCPosition.WORKING_NETHERITE;
|
||||||
|
case ENCHANTING_TABLE -> NPCPosition.WORKING_SPLITTING;
|
||||||
default -> null;
|
default -> null;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -25,15 +25,18 @@ public final class SoundHelper {
|
|||||||
public static void playSound(@NotNull Entity entity, @NotNull SoundData soundData) {
|
public static void playSound(@NotNull Entity entity, @NotNull SoundData soundData) {
|
||||||
// Don't play disabled sounds
|
// Don't play disabled sounds
|
||||||
if (!soundData.enabled()) {
|
if (!soundData.enabled()) {
|
||||||
|
BlacksmithVisuals.debug("Skipping sound " + soundData.sound() + " as it's disabled");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
World world = entity.getLocation().getWorld();
|
World world = entity.getLocation().getWorld();
|
||||||
if (world == null) {
|
if (world == null) {
|
||||||
|
BlacksmithVisuals.debug("Could not play sound, as world is null");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int delay = Math.max(soundData.offsetTicks(), 0);
|
int delay = Math.max(soundData.offsetTicks(), 0);
|
||||||
|
BlacksmithVisuals.debug("Playing sound " + soundData.sound() + " after " + delay + " ticks");
|
||||||
Bukkit.getScheduler().scheduleSyncDelayedTask(BlacksmithVisuals.getInstance(), () ->
|
Bukkit.getScheduler().scheduleSyncDelayedTask(BlacksmithVisuals.getInstance(), () ->
|
||||||
world.playSound(entity, soundData.sound(), soundData.soundCategory(),
|
world.playSound(entity, soundData.sound(), soundData.soundCategory(),
|
||||||
soundData.volume(), soundData.pitch()), delay);
|
soundData.volume(), soundData.pitch()), delay);
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
# Show debug messages in the console
|
||||||
|
debug: false
|
||||||
blacksmith:
|
blacksmith:
|
||||||
animation:
|
animation:
|
||||||
# Whether to simulate hitting an anvil or similar by animating the blacksmith's off-hand
|
# Whether to simulate hitting an anvil or similar by animating the blacksmith's off-hand
|
||||||
|
Loading…
x
Reference in New Issue
Block a user