Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Redirect left/right clicks for hologram NPCs
- Loading branch information
Showing
6 changed files
with
86 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
main/src/main/java/net/citizensnpcs/trait/ClickRedirectTrait.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package net.citizensnpcs.trait; | ||
|
||
import java.util.UUID; | ||
|
||
import net.citizensnpcs.api.CitizensAPI; | ||
import net.citizensnpcs.api.npc.NPC; | ||
import net.citizensnpcs.api.trait.Trait; | ||
import net.citizensnpcs.api.trait.TraitName; | ||
import net.citizensnpcs.api.util.DataKey; | ||
|
||
/** | ||
* Redirects left and right clicks to another {@link NPC}. | ||
*/ | ||
@TraitName("clickredirecttrait") | ||
public class ClickRedirectTrait extends Trait { | ||
private NPC redirectNPC; | ||
|
||
public ClickRedirectTrait() { | ||
super("clickredirecttrait"); | ||
} | ||
|
||
public ClickRedirectTrait(NPC npc) { | ||
this(); | ||
this.redirectNPC = npc; | ||
} | ||
|
||
public NPC getRedirectNPC() { | ||
return redirectNPC; | ||
} | ||
|
||
@Override | ||
public void load(DataKey key) { | ||
redirectNPC = CitizensAPI.getNPCRegistry().getByUniqueIdGlobal(UUID.fromString(key.getString("uuid"))); | ||
} | ||
|
||
@Override | ||
public void save(DataKey key) { | ||
key.setString("uuid", redirectNPC.getUniqueId().toString()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters