Skip to content

Commit

Permalink
Add support for FancyNpcs
Browse files Browse the repository at this point in the history
  • Loading branch information
tastybento committed Dec 7, 2024
1 parent 0961538 commit b4a802d
Show file tree
Hide file tree
Showing 8 changed files with 336 additions and 261 deletions.
24 changes: 9 additions & 15 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -192,10 +192,11 @@
<id>clojars</id>
<url>https://repo.clojars.org/</url>
</repository>
<!-- Citizens -->
<!-- FancyNPC -->
<repository>
<id>citizens-repo</id>
<url>https://maven.citizensnpcs.co/repo</url>
<id>fancyplugins-releases</id>
<name>FancyPlugins Repository</name>
<url>https://repo.fancyplugins.de/releases</url>
</repository>
</repositories>

Expand Down Expand Up @@ -398,19 +399,12 @@
<version>1.1.13</version>
<scope>compile</scope>
</dependency>
<!-- Citizens -->
<dependency>
<groupId>net.citizensnpcs</groupId>
<artifactId>citizens-main</artifactId>
<version>2.0.35-SNAPSHOT</version>
<type>jar</type>
<!-- FancyNPCs -->
<dependency>
<groupId>de.oliver</groupId>
<artifactId>FancyNpcs</artifactId>
<version>2.4.0</version>
<scope>provided</scope>
<exclusions>
<exclusion>
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>

Expand Down
7 changes: 4 additions & 3 deletions src/main/java/world/bentobox/bentobox/BentoBox.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,13 @@

import world.bentobox.bentobox.api.configuration.Config;
import world.bentobox.bentobox.api.events.BentoBoxReadyEvent;
import world.bentobox.bentobox.api.hooks.Hook;
import world.bentobox.bentobox.api.localization.TextVariables;
import world.bentobox.bentobox.api.user.Notifier;
import world.bentobox.bentobox.api.user.User;
import world.bentobox.bentobox.commands.BentoBoxCommand;
import world.bentobox.bentobox.database.DatabaseSetup;
import world.bentobox.bentobox.hooks.CitizensHook;
import world.bentobox.bentobox.hooks.FancyNpcsHook;
import world.bentobox.bentobox.hooks.ItemsAdderHook;
import world.bentobox.bentobox.hooks.MultipaperHook;
import world.bentobox.bentobox.hooks.MultiverseCoreHook;
Expand Down Expand Up @@ -193,8 +194,8 @@ private void completeSetup(long loadTime) {

hooksManager.registerHook(new VaultHook());

// Citizens
hooksManager.registerHook(new CitizensHook());
// FancyNpcs
hooksManager.registerHook(new FancyNpcsHook());

// MythicMobs
hooksManager.registerHook(new MythicMobsHook());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
import world.bentobox.bentobox.blueprints.dataobjects.BlueprintBlock;
import world.bentobox.bentobox.blueprints.dataobjects.BlueprintCreatureSpawner;
import world.bentobox.bentobox.blueprints.dataobjects.BlueprintEntity;
import world.bentobox.bentobox.hooks.CitizensHook;
import world.bentobox.bentobox.hooks.FancyNpcsHook;
import world.bentobox.bentobox.hooks.MythicMobsHook;

/**
Expand All @@ -70,7 +70,7 @@ public class BlueprintClipboard {
private final Map<Vector, BlueprintBlock> bpBlocks = new LinkedHashMap<>();
private final BentoBox plugin = BentoBox.getInstance();
private Optional<MythicMobsHook> mmh;
private Optional<CitizensHook> ch;
private Optional<FancyNpcsHook> npc;

/**
* Create a clipboard for blueprint
Expand All @@ -83,7 +83,8 @@ public BlueprintClipboard(@NonNull Blueprint blueprint) {

public BlueprintClipboard() {
// Citizens Hook
ch = plugin.getHooks().getHook("Citizens").filter(CitizensHook.class::isInstance).map(CitizensHook.class::cast);
npc = plugin.getHooks().getHook("FancyNpcs").filter(FancyNpcsHook.class::isInstance)
.map(FancyNpcsHook.class::cast);
// MythicMobs Hook
mmh = plugin.getHooks().getHook("MythicMobs").filter(MythicMobsHook.class::isInstance)
.map(MythicMobsHook.class::cast);
Expand Down Expand Up @@ -137,10 +138,10 @@ public boolean copy(User user, boolean copyAir, boolean copyBiome) {

private void copyAsync(World world, User user, List<Vector> vectorsToCopy, int speed, boolean copyAir, boolean copyBiome) {
copying = false;
// Citizens
if (ch.isPresent()) {
// FancyNpcs
if (npc.isPresent()) {
// Add all the citizens for the area in one go. This is pretty fast.
bpEntities.putAll(ch.get().getCitizensInArea(world, vectorsToCopy, origin));
bpEntities.putAll(npc.get().getNpcsInArea(world, vectorsToCopy, origin));
}

// Repeating copy task
Expand Down Expand Up @@ -308,7 +309,6 @@ private BlueprintCreatureSpawner getSpawner(CreatureSpawner spawner) {
private List<BlueprintEntity> setEntities(List<Entity> ents) {
List<BlueprintEntity> bpEnts = new ArrayList<>();
for (Entity entity : ents) {
BentoBox.getInstance().logDebug("Etity = " + entity);
BlueprintEntity bpe = new BlueprintEntity();

bpe.setType(entity.getType());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@
*/
public class BlueprintEntity {

// Citizens storage
// Npc storage
@Expose
private String citizen;
private String npc;

// MythicMobs storage
public record MythicMobRecord(String type, String displayName, double level, float power, String stance) {
Expand Down Expand Up @@ -310,22 +310,22 @@ public void setMythicMobsRecord(MythicMobRecord mmr) {
}

/**
* @return the citizen
* @return the npc
*/
public String getCitizen() {
return citizen;
public String getNpc() {
return npc;
}

/**
* @param citizen the citizen to set
*/
public void setCitizen(String citizen) {
this.citizen = citizen;
public void setNpc(String citizen) {
this.npc = citizen;
}

@Override
public String toString() {
return "BlueprintEntity [" + (citizen != null ? "citizen=" + citizen + ", " : "")
return "BlueprintEntity [" + (npc != null ? "npc=" + npc + ", " : "")
+ (MMtype != null ? "MMtype=" + MMtype + ", " : "")
+ (MMLevel != null ? "MMLevel=" + MMLevel + ", " : "")
+ (MMStance != null ? "MMStance=" + MMStance + ", " : "")
Expand Down
215 changes: 0 additions & 215 deletions src/main/java/world/bentobox/bentobox/hooks/CitizensHook.java

This file was deleted.

Loading

0 comments on commit b4a802d

Please sign in to comment.