Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial 1.19.4 update. Of note: sniffers are known to not be working
- Loading branch information
Showing
162 changed files
with
2,549 additions
and
1,686 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
78 changes: 78 additions & 0 deletions
78
main/src/main/java/net/citizensnpcs/trait/versioned/SnifferTrait.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,78 @@ | ||
package net.citizensnpcs.trait.versioned; | ||
|
||
import org.bukkit.command.CommandSender; | ||
import org.bukkit.entity.EntityType; | ||
import org.bukkit.entity.Sniffer; | ||
|
||
import net.citizensnpcs.api.command.Command; | ||
import net.citizensnpcs.api.command.CommandContext; | ||
import net.citizensnpcs.api.command.Flag; | ||
import net.citizensnpcs.api.command.Requirements; | ||
import net.citizensnpcs.api.command.exception.CommandException; | ||
import net.citizensnpcs.api.command.exception.CommandUsageException; | ||
import net.citizensnpcs.api.npc.NPC; | ||
import net.citizensnpcs.api.persistence.Persist; | ||
import net.citizensnpcs.api.trait.Trait; | ||
import net.citizensnpcs.api.trait.TraitName; | ||
import net.citizensnpcs.api.util.Messaging; | ||
import net.citizensnpcs.util.Messages; | ||
import net.citizensnpcs.util.NMS; | ||
|
||
@TraitName("sniffertrait") | ||
public class SnifferTrait extends Trait { | ||
@Persist | ||
private SnifferState state = null; | ||
|
||
public SnifferTrait() { | ||
super("sniffertrait"); | ||
} | ||
|
||
public SnifferState getState() { | ||
return state; | ||
} | ||
|
||
@Override | ||
public void run() { | ||
if (!npc.isSpawned() || !(npc.getEntity() instanceof Sniffer)) | ||
return; | ||
NMS.setSnifferState(npc.getEntity(), state); | ||
} | ||
|
||
public void setState(SnifferState state) { | ||
this.state = state; | ||
} | ||
|
||
public enum SnifferState { | ||
DIGGING, | ||
FEELING_HAPPY, | ||
IDLING, | ||
RISING, | ||
SCENTING, | ||
SEARCHING, | ||
SNIFFING | ||
} | ||
|
||
@Command( | ||
aliases = { "npc" }, | ||
usage = "sniffer (--state [state])", | ||
desc = "Sets sniffer modifiers", | ||
modifiers = { "sniffer" }, | ||
min = 1, | ||
max = 1, | ||
permission = "citizens.npc.sniffer") | ||
@Requirements(selected = true, ownership = true, types = EntityType.SNIFFER) | ||
public static void sniffer(CommandContext args, CommandSender sender, NPC npc, @Flag("state") SnifferState state) | ||
throws CommandException { | ||
SnifferTrait trait = npc.getOrAddTrait(SnifferTrait.class); | ||
String output = ""; | ||
if (state != null) { | ||
trait.setState(state); | ||
output += ' ' + Messaging.tr(Messages.SNIFFER_STATE_SET, npc.getName(), state); | ||
} | ||
if (!output.isEmpty()) { | ||
Messaging.send(sender, output.trim()); | ||
} else { | ||
throw new CommandUsageException(); | ||
} | ||
} | ||
} |
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
Oops, something went wrong.