Compare commits
10 commits
7709310997
...
7825d92b2a
Author | SHA1 | Date | |
---|---|---|---|
7825d92b2a | |||
5c9ac03615 | |||
f07acc0e77 | |||
db2f14369d | |||
92682ea60f | |||
2248f3530c | |||
|
c68585868c | ||
|
cdda0f0e47 | ||
|
33bd65f766 | ||
|
c0789c8630 |
11 changed files with 149 additions and 5 deletions
|
@ -10,7 +10,7 @@ trigger:
|
||||||
steps:
|
steps:
|
||||||
- name: publish
|
- name: publish
|
||||||
pull: if-not-exists
|
pull: if-not-exists
|
||||||
image: openjdk:8-jdk
|
image: openjdk:21-jdk
|
||||||
environment:
|
environment:
|
||||||
PACKAGESKEY:
|
PACKAGESKEY:
|
||||||
from_secret: GITEA_PACKAGE_PUBLIC_RW
|
from_secret: GITEA_PACKAGE_PUBLIC_RW
|
||||||
|
|
|
@ -2,6 +2,7 @@ package lol.pyr.znpcsplus.api.interaction;
|
||||||
|
|
||||||
public interface ActionRegistry {
|
public interface ActionRegistry {
|
||||||
void register(InteractionActionType<?> type);
|
void register(InteractionActionType<?> type);
|
||||||
|
|
||||||
void unregister(Class<? extends InteractionAction> clazz);
|
void unregister(Class<? extends InteractionAction> clazz);
|
||||||
|
<T extends InteractionAction> T deserialize(String str);
|
||||||
|
<T extends InteractionAction> String serialize(T action);
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@ subprojects {
|
||||||
version "2.1.0-netherite-SNAPSHOT"
|
version "2.1.0-netherite-SNAPSHOT"
|
||||||
|
|
||||||
java {
|
java {
|
||||||
toolchain.languageVersion.set(JavaLanguageVersion.of(17))
|
toolchain.languageVersion.set(JavaLanguageVersion.of(21))
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
|
@ -21,6 +21,9 @@ subprojects {
|
||||||
maven {
|
maven {
|
||||||
url "https://repo.codemc.io/repository/maven-releases/"
|
url "https://repo.codemc.io/repository/maven-releases/"
|
||||||
}
|
}
|
||||||
|
maven {
|
||||||
|
url "https://repo.codemc.io/repository/maven-snapshots/"
|
||||||
|
}
|
||||||
maven {
|
maven {
|
||||||
url "https://libraries.minecraft.net"
|
url "https://libraries.minecraft.net"
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,7 +40,7 @@ dependencies {
|
||||||
|
|
||||||
// Fancy text library
|
// Fancy text library
|
||||||
implementation "net.kyori:adventure-platform-bukkit:4.3.4"
|
implementation "net.kyori:adventure-platform-bukkit:4.3.4"
|
||||||
implementation "net.kyori:adventure-text-minimessage:4.17.0"
|
implementation "net.kyori:adventure-text-minimessage:4.18.0"
|
||||||
|
|
||||||
implementation project(":api")
|
implementation project(":api")
|
||||||
}
|
}
|
||||||
|
|
|
@ -335,7 +335,9 @@ public class ZNpcsPlus {
|
||||||
.addSubcommand("set", new HoloSetCommand(npcRegistry))
|
.addSubcommand("set", new HoloSetCommand(npcRegistry))
|
||||||
.addSubcommand("setitem", new HoloSetItemCommand(npcRegistry))
|
.addSubcommand("setitem", new HoloSetItemCommand(npcRegistry))
|
||||||
.addSubcommand("offset", new HoloOffsetCommand(npcRegistry))
|
.addSubcommand("offset", new HoloOffsetCommand(npcRegistry))
|
||||||
.addSubcommand("refreshdelay", new HoloRefreshDelayCommand(npcRegistry)))
|
.addSubcommand("refreshdelay", new HoloRefreshDelayCommand(npcRegistry))
|
||||||
|
.addSubcommand("removeduplicate", new HoloRemoveDuplicateCommand(npcRegistry))
|
||||||
|
.addSubcommand("removeallduplicates", new holoRemoveAllDuplicatesCommand(npcRegistry)))
|
||||||
.addSubcommand("action", new MultiCommand(bootstrap.loadHelpMessage("action"))
|
.addSubcommand("action", new MultiCommand(bootstrap.loadHelpMessage("action"))
|
||||||
.addSubcommand("add", new ActionAddCommand(npcRegistry, actionRegistry))
|
.addSubcommand("add", new ActionAddCommand(npcRegistry, actionRegistry))
|
||||||
.addSubcommand("clear", new ActionClearCommand(npcRegistry))
|
.addSubcommand("clear", new ActionClearCommand(npcRegistry))
|
||||||
|
|
|
@ -0,0 +1,58 @@
|
||||||
|
package lol.pyr.znpcsplus.commands.hologram;
|
||||||
|
|
||||||
|
import lol.pyr.director.adventure.command.CommandContext;
|
||||||
|
import lol.pyr.director.adventure.command.CommandHandler;
|
||||||
|
import lol.pyr.director.common.command.CommandExecutionException;
|
||||||
|
import lol.pyr.znpcsplus.hologram.HologramImpl;
|
||||||
|
import lol.pyr.znpcsplus.hologram.HologramLine;
|
||||||
|
import lol.pyr.znpcsplus.hologram.HologramText;
|
||||||
|
import lol.pyr.znpcsplus.npc.NpcEntryImpl;
|
||||||
|
import lol.pyr.znpcsplus.npc.NpcRegistryImpl;
|
||||||
|
import net.kyori.adventure.text.Component;
|
||||||
|
import net.kyori.adventure.text.format.NamedTextColor;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class HoloRemoveDuplicateCommand implements CommandHandler {
|
||||||
|
private final NpcRegistryImpl registry;
|
||||||
|
|
||||||
|
public HoloRemoveDuplicateCommand(NpcRegistryImpl registry) {
|
||||||
|
this.registry = registry;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run(CommandContext context) throws CommandExecutionException {
|
||||||
|
context.setUsage(context.getLabel() + " holo removeduplicates <id>");
|
||||||
|
HologramImpl hologram = context.parse(NpcEntryImpl.class).getNpc().getHologram();
|
||||||
|
List<HologramLine<?>> lines = new ArrayList<>(hologram.getLines());
|
||||||
|
List<HologramText> textLines = new ArrayList<>();
|
||||||
|
|
||||||
|
Iterator<HologramLine<?>> iterator = lines.iterator();
|
||||||
|
while (iterator.hasNext()) {
|
||||||
|
HologramLine<?> line = iterator.next();
|
||||||
|
if (line instanceof HologramText textLine
|
||||||
|
&& !textLine.getValue().equals(Component.empty())
|
||||||
|
&& textLines.contains(textLine)) {
|
||||||
|
iterator.remove();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (line instanceof HologramText textLine) {
|
||||||
|
textLines.add(textLine);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
hologram.clearLines();
|
||||||
|
hologram.addLines(lines);
|
||||||
|
context.send(Component.text("NPC lines fixed!", NamedTextColor.GREEN));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<String> suggest(CommandContext context) throws CommandExecutionException {
|
||||||
|
if (context.argSize() == 1) return context.suggestCollection(registry.getModifiableIds());
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,62 @@
|
||||||
|
package lol.pyr.znpcsplus.commands.hologram;
|
||||||
|
|
||||||
|
import lol.pyr.director.adventure.command.CommandContext;
|
||||||
|
import lol.pyr.director.adventure.command.CommandHandler;
|
||||||
|
import lol.pyr.director.common.command.CommandExecutionException;
|
||||||
|
import lol.pyr.znpcsplus.hologram.HologramImpl;
|
||||||
|
import lol.pyr.znpcsplus.hologram.HologramLine;
|
||||||
|
import lol.pyr.znpcsplus.hologram.HologramText;
|
||||||
|
import lol.pyr.znpcsplus.npc.NpcEntryImpl;
|
||||||
|
import lol.pyr.znpcsplus.npc.NpcRegistryImpl;
|
||||||
|
import net.kyori.adventure.text.Component;
|
||||||
|
import net.kyori.adventure.text.format.NamedTextColor;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class holoRemoveAllDuplicatesCommand implements CommandHandler {
|
||||||
|
private final NpcRegistryImpl registry;
|
||||||
|
|
||||||
|
public holoRemoveAllDuplicatesCommand(NpcRegistryImpl registry) {
|
||||||
|
this.registry = registry;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run(CommandContext context) throws CommandExecutionException {
|
||||||
|
context.setUsage(context.getLabel() + " holo removeallduplicates <id>");
|
||||||
|
|
||||||
|
for (NpcEntryImpl npcEntry : registry.getAll()) {
|
||||||
|
HologramImpl hologram = npcEntry.getNpc().getHologram();
|
||||||
|
List<HologramLine<?>> lines = new ArrayList<>(hologram.getLines());
|
||||||
|
List<HologramText> textLines = new ArrayList<>();
|
||||||
|
|
||||||
|
Iterator<HologramLine<?>> iterator = lines.iterator();
|
||||||
|
while (iterator.hasNext()) {
|
||||||
|
HologramLine<?> line = iterator.next();
|
||||||
|
if (line instanceof HologramText textLine
|
||||||
|
&& !textLine.getValue().equals(Component.empty())
|
||||||
|
&& textLines.contains(textLine)) {
|
||||||
|
iterator.remove();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (line instanceof HologramText textLine) {
|
||||||
|
textLines.add(textLine);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
hologram.clearLines();
|
||||||
|
hologram.addLines(lines);
|
||||||
|
}
|
||||||
|
|
||||||
|
context.send(Component.text("NPCs fixed!", NamedTextColor.GREEN));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<String> suggest(CommandContext context) throws CommandExecutionException {
|
||||||
|
if (context.argSize() == 1) return context.suggestCollection(registry.getModifiableIds());
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
}
|
|
@ -101,6 +101,12 @@ public class HologramImpl extends Viewable implements Hologram {
|
||||||
lines.clear();
|
lines.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void addLines(List<HologramLine<?>> lines) {
|
||||||
|
this.lines.addAll(lines);
|
||||||
|
relocateLines();
|
||||||
|
for (Player viewer : getViewers()) for (HologramLine<?> line : lines) line.show(viewer);
|
||||||
|
}
|
||||||
|
|
||||||
public void insertTextLineComponent(int index, Component line) {
|
public void insertTextLineComponent(int index, Component line) {
|
||||||
HologramText newLine = new HologramText(this, propertyRegistry, packetFactory, null, line);
|
HologramText newLine = new HologramText(this, propertyRegistry, packetFactory, null, line);
|
||||||
lines.add(index, newLine);
|
lines.add(index, newLine);
|
||||||
|
|
|
@ -39,4 +39,12 @@ public class HologramText extends HologramLine<Component> {
|
||||||
public boolean hasProperty(EntityProperty<?> key) {
|
public boolean hasProperty(EntityProperty<?> key) {
|
||||||
return key.getName().equalsIgnoreCase("name") || key.getName().equalsIgnoreCase("invisible");
|
return key.getName().equalsIgnoreCase("name") || key.getName().equalsIgnoreCase("invisible");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object obj) {
|
||||||
|
if (this == obj) return true;
|
||||||
|
if (obj == null || getClass() != obj.getClass()) return false;
|
||||||
|
HologramText that = (HologramText) obj;
|
||||||
|
return getValue().equals(that.getValue());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -381,6 +381,7 @@ public class NpcTypeRegistryImpl implements NpcTypeRegistry {
|
||||||
.setHologramOffset(0.4)
|
.setHologramOffset(0.4)
|
||||||
.addProperties("bashing", "camel_sitting"));
|
.addProperties("bashing", "camel_sitting"));
|
||||||
|
|
||||||
|
|
||||||
if (!version.isNewerThanOrEquals(ServerVersion.V_1_20_5)) return;
|
if (!version.isNewerThanOrEquals(ServerVersion.V_1_20_5)) return;
|
||||||
|
|
||||||
register(builder(p, "armadillo", EntityTypes.ARMADILLO)
|
register(builder(p, "armadillo", EntityTypes.ARMADILLO)
|
||||||
|
|
|
@ -11,6 +11,9 @@ api-version: 1.13
|
||||||
|
|
||||||
folia-supported: true
|
folia-supported: true
|
||||||
|
|
||||||
|
depend:
|
||||||
|
- packetevents
|
||||||
|
|
||||||
softdepend:
|
softdepend:
|
||||||
- PlaceholderAPI
|
- PlaceholderAPI
|
||||||
- ServersNPC
|
- ServersNPC
|
||||||
|
|
Loading…
Reference in a new issue