Compare commits

...

10 commits

Author SHA1 Message Date
7825d92b2a 21 2025-03-04 20:33:49 +01:00
5c9ac03615 feat: HoloRemoveAllDuplicatesCommand 2025-03-04 20:32:53 +01:00
f07acc0e77 feat: HoloRemoveDuplicateCommand 2025-03-04 20:32:50 +01:00
db2f14369d refactor: do not shade packetevents 2025-03-04 20:32:44 +01:00
92682ea60f chore: expose api methods we need 2025-03-04 20:32:42 +01:00
2248f3530c chore: update packetevents properly 2025-03-04 20:32:39 +01:00
D3v1s0m
c68585868c added camel_sitting property 2025-03-04 20:32:37 +01:00
D3v1s0m
cdda0f0e47 fix action commands, ughh 2025-03-04 20:32:37 +01:00
D3v1s0m
33bd65f766 small action command(s) fix 2025-03-04 20:32:35 +01:00
bridge
c0789c8630 chore: update jdk image 2025-03-04 20:31:35 +01:00
11 changed files with 149 additions and 5 deletions

View file

@ -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

View file

@ -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);
} }

View file

@ -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"
} }

View file

@ -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")
} }

View file

@ -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))

View file

@ -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();
}
}

View file

@ -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();
}
}

View file

@ -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);

View file

@ -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());
}
} }

View file

@ -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)

View file

@ -11,6 +11,9 @@ api-version: 1.13
folia-supported: true folia-supported: true
depend:
- packetevents
softdepend: softdepend:
- PlaceholderAPI - PlaceholderAPI
- ServersNPC - ServersNPC