Adds icons for trader NPCs
All checks were successful
KnarCraft/DynmapCitizens/pipeline/head This commit looks good
All checks were successful
KnarCraft/DynmapCitizens/pipeline/head This commit looks good
This commit is contained in:
parent
9312e2156b
commit
88bf1b28c2
@ -14,4 +14,8 @@ basis, and possibly choosing exactly what information to display on each trait's
|
|||||||
- [Blacksmith](https://www.spigotmc.org/resources/blacksmith.105938/)
|
- [Blacksmith](https://www.spigotmc.org/resources/blacksmith.105938/)
|
||||||
- [Quests](https://www.spigotmc.org/resources/quests.3711/)
|
- [Quests](https://www.spigotmc.org/resources/quests.3711/)
|
||||||
- [Sentinel](https://www.spigotmc.org/resources/sentinel.22017/)
|
- [Sentinel](https://www.spigotmc.org/resources/sentinel.22017/)
|
||||||
- [Minstrel](https://git.knarcraft.net/EpicKnarvik97/Minstrel)
|
- [Minstrel](https://git.knarcraft.net/EpicKnarvik97/Minstrel)
|
||||||
|
|
||||||
|
## Somewhat supported NPC traits, because the developers have no API
|
||||||
|
|
||||||
|
- [Trader](https://www.spigotmc.org/resources/dtltraders.35890/)
|
2
pom.xml
2
pom.xml
@ -167,7 +167,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>net.knarcraft</groupId>
|
<groupId>net.knarcraft</groupId>
|
||||||
<artifactId>knarlib</artifactId>
|
<artifactId>knarlib</artifactId>
|
||||||
<version>1.1</version>
|
<version>1.2.3</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
|
@ -5,6 +5,7 @@ import net.knarcraft.dynmapcitizens.formatting.SentinelTranslatableMessage;
|
|||||||
import net.knarcraft.dynmapcitizens.handler.VaultHandler;
|
import net.knarcraft.dynmapcitizens.handler.VaultHandler;
|
||||||
import net.knarcraft.dynmapcitizens.handler.trait.BlacksmithHandler;
|
import net.knarcraft.dynmapcitizens.handler.trait.BlacksmithHandler;
|
||||||
import net.knarcraft.dynmapcitizens.handler.trait.CitizensTraitHandler;
|
import net.knarcraft.dynmapcitizens.handler.trait.CitizensTraitHandler;
|
||||||
|
import net.knarcraft.dynmapcitizens.handler.trait.DTLTradersHandler;
|
||||||
import net.knarcraft.dynmapcitizens.handler.trait.MinstrelHandler;
|
import net.knarcraft.dynmapcitizens.handler.trait.MinstrelHandler;
|
||||||
import net.knarcraft.dynmapcitizens.handler.trait.SentinelHandler;
|
import net.knarcraft.dynmapcitizens.handler.trait.SentinelHandler;
|
||||||
import net.knarcraft.dynmapcitizens.handler.trait.quests.QuestsHandler;
|
import net.knarcraft.dynmapcitizens.handler.trait.quests.QuestsHandler;
|
||||||
@ -23,6 +24,9 @@ import java.util.ArrayList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* DynmapCitizens' main class
|
||||||
|
*/
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
public final class DynmapCitizens extends JavaPlugin {
|
public final class DynmapCitizens extends JavaPlugin {
|
||||||
|
|
||||||
@ -151,6 +155,7 @@ public final class DynmapCitizens extends JavaPlugin {
|
|||||||
this.traitHandlers.add(new QuestsHandler());
|
this.traitHandlers.add(new QuestsHandler());
|
||||||
this.traitHandlers.add(new SentinelHandler());
|
this.traitHandlers.add(new SentinelHandler());
|
||||||
this.traitHandlers.add(new MinstrelHandler());
|
this.traitHandlers.add(new MinstrelHandler());
|
||||||
|
this.traitHandlers.add(new DTLTradersHandler());
|
||||||
|
|
||||||
//Load and initialize all enabled trait handlers
|
//Load and initialize all enabled trait handlers
|
||||||
for (CitizensTraitHandler handler : this.traitHandlers) {
|
for (CitizensTraitHandler handler : this.traitHandlers) {
|
||||||
|
@ -0,0 +1,53 @@
|
|||||||
|
package net.knarcraft.dynmapcitizens.handler.trait;
|
||||||
|
|
||||||
|
import net.citizensnpcs.api.CitizensAPI;
|
||||||
|
import net.citizensnpcs.api.npc.NPC;
|
||||||
|
import net.citizensnpcs.api.trait.Trait;
|
||||||
|
import net.knarcraft.dynmapcitizens.DynmapCitizens;
|
||||||
|
import net.knarcraft.dynmapcitizens.property.Icon;
|
||||||
|
import net.knarcraft.dynmapcitizens.settings.DTLTradersSettings;
|
||||||
|
import net.knarcraft.dynmapcitizens.settings.TraitSettings;
|
||||||
|
import org.dynmap.markers.GenericMarker;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A handler class for the minstrel trait
|
||||||
|
*/
|
||||||
|
public class DTLTradersHandler extends AbstractTraitHandler {
|
||||||
|
|
||||||
|
private final DTLTradersSettings settings = new DTLTradersSettings();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void initialize() {
|
||||||
|
super.isEnabled = false;
|
||||||
|
CitizensAPI.getTraitFactory().getRegisteredTraits().forEach(traitInfo -> {
|
||||||
|
if (traitInfo.getTraitName().equals("trader")) {
|
||||||
|
super.isEnabled = true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if (this.isEnabled) {
|
||||||
|
super.initializeMarkerSet();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TraitSettings getSettings() {
|
||||||
|
return this.settings;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateMarkers() {
|
||||||
|
//Remove existing markers
|
||||||
|
super.markerSet.getMarkers().forEach(GenericMarker::deleteMarker);
|
||||||
|
|
||||||
|
Class<? extends Trait> traderTrait = CitizensAPI.getTraitFactory().getTraitClass("trader");
|
||||||
|
for (NPC npc : CitizensAPI.getNPCRegistry()) {
|
||||||
|
if (npc.hasTrait(traderTrait)) {
|
||||||
|
String description = "<h2>" + npc.getName() + "</h2>";
|
||||||
|
addNPCMarker(npc.getUniqueId(), "Trader NPC: ", description,
|
||||||
|
DynmapCitizens.getInstance().getGlobalSettings().getMarkerIcons().get(Icon.TRADER), super.markerSet);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -93,7 +93,7 @@ public class QuestAreaHandler {
|
|||||||
} else {
|
} else {
|
||||||
formattedAreaName = "";
|
formattedAreaName = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
String description = formatter.replacePlaceholders(QUESTS_REACH_AREA_DESCRIPTION_FORMAT,
|
String description = formatter.replacePlaceholders(QUESTS_REACH_AREA_DESCRIPTION_FORMAT,
|
||||||
new String[]{"{areaName}", "{questName}"}, new String[]{formattedAreaName, quest.getName()});
|
new String[]{"{areaName}", "{questName}"}, new String[]{formattedAreaName, quest.getName()});
|
||||||
DynmapHelper.markLocation(location, radius, description, reachAreaMarkerSet, settings.getReachAreaSettings());
|
DynmapHelper.markLocation(location, radius, description, reachAreaMarkerSet, settings.getReachAreaSettings());
|
||||||
|
@ -43,6 +43,11 @@ public enum Icon {
|
|||||||
/**
|
/**
|
||||||
* An icon representing a minstrel NPC
|
* An icon representing a minstrel NPC
|
||||||
*/
|
*/
|
||||||
MINSTREL
|
MINSTREL,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An icon representing a trader NPC
|
||||||
|
*/
|
||||||
|
TRADER,
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,20 @@
|
|||||||
|
package net.knarcraft.dynmapcitizens.settings;
|
||||||
|
|
||||||
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* All settings for the minstrel trait
|
||||||
|
*/
|
||||||
|
public class DTLTradersSettings extends AbstractTraitSettings {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void load(FileConfiguration configuration) {
|
||||||
|
super.load(configuration);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected String getTraitConfigRoot() {
|
||||||
|
return "traits.trader";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -82,6 +82,7 @@ public class GlobalSettings {
|
|||||||
case BLACKSMITH -> "hammer";
|
case BLACKSMITH -> "hammer";
|
||||||
case SENTINEL -> "shield";
|
case SENTINEL -> "shield";
|
||||||
case MINSTREL -> "theater";
|
case MINSTREL -> "theater";
|
||||||
|
case TRADER -> "coins";
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,6 +16,8 @@ icon:
|
|||||||
SENTINEL: "shield"
|
SENTINEL: "shield"
|
||||||
# The marker used for minstrels
|
# The marker used for minstrels
|
||||||
MINSTREL: "theater"
|
MINSTREL: "theater"
|
||||||
|
# The marker used for traders
|
||||||
|
TRADER: "coins"
|
||||||
|
|
||||||
# Settings for how often markers will be updated
|
# Settings for how often markers will be updated
|
||||||
timer:
|
timer:
|
||||||
@ -129,4 +131,15 @@ traits:
|
|||||||
# Whether to hide the minstrel icon layer by default
|
# Whether to hide the minstrel icon layer by default
|
||||||
markersHiddenByDefault: false
|
markersHiddenByDefault: false
|
||||||
# Whether to display the list of songs a minstrel is playing
|
# Whether to display the list of songs a minstrel is playing
|
||||||
displayMinstrelSongs: true
|
displayMinstrelSongs: true
|
||||||
|
# Settings for the trader trait
|
||||||
|
trader:
|
||||||
|
enabled: true
|
||||||
|
# The priority of trader markers. Higher priority markers will display on top of lower priority ones
|
||||||
|
markerSetPriority: 1
|
||||||
|
# The id of the trader marker set. Change if it overlaps with an existing set id
|
||||||
|
markerSetId: "traders"
|
||||||
|
# The name of the trader marker set. Change it if you want a cooler name
|
||||||
|
markerSetName: "Traders"
|
||||||
|
# Whether to hide the trader icon layer by default
|
||||||
|
markersHiddenByDefault: false
|
Loading…
x
Reference in New Issue
Block a user