upstream #1
13 changed files with 200 additions and 17 deletions
18
.drone.yml
Normal file
18
.drone.yml
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
kind: pipeline
|
||||||
|
type: docker
|
||||||
|
name: default
|
||||||
|
|
||||||
|
trigger:
|
||||||
|
event:
|
||||||
|
- push
|
||||||
|
- custom
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: publish
|
||||||
|
pull: if-not-exists
|
||||||
|
image: openjdk:21-jdk
|
||||||
|
environment:
|
||||||
|
PACKAGESKEY:
|
||||||
|
from_secret: GITEA_PACKAGE_PUBLIC_RW
|
||||||
|
commands:
|
||||||
|
- ./gradlew --no-daemon --parallel -Pnetherite.git.packages.token=$PACKAGESKEY build publish
|
|
@ -1,6 +1,5 @@
|
||||||
plugins {
|
plugins {
|
||||||
id "java"
|
id "java"
|
||||||
id "maven-publish"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
java {
|
java {
|
||||||
|
@ -21,15 +20,4 @@ publishing {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
repositories {
|
|
||||||
maven {
|
|
||||||
Map<String, String> systemProperties = System.getenv()
|
|
||||||
credentials {
|
|
||||||
if (systemProperties.containsKey("DIST_USERNAME")) username systemProperties.get("DIST_USERNAME")
|
|
||||||
if (systemProperties.containsKey("DIST_PASSWORD")) password systemProperties.get("DIST_PASSWORD")
|
|
||||||
}
|
|
||||||
// If the BUILD_ID enviroment variable is present that means its a Jenkins build & that it should go into the snapshots repo
|
|
||||||
url = systemProperties.containsKey("BUILD_ID") ? uri("https://repo.pyr.lol/snapshots/") : uri("https://repo.pyr.lol/releases/")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
|
@ -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);
|
||||||
}
|
}
|
||||||
|
|
25
build.gradle
25
build.gradle
|
@ -2,10 +2,10 @@ subprojects {
|
||||||
apply plugin: "java"
|
apply plugin: "java"
|
||||||
|
|
||||||
group "lol.pyr"
|
group "lol.pyr"
|
||||||
version "2.1.0" + (System.getenv().containsKey("BUILD_ID") ? "-SNAPSHOT" : "")
|
version "2.0.0-netherite-SNAPSHOT"
|
||||||
|
|
||||||
java {
|
java {
|
||||||
toolchain.languageVersion.set(JavaLanguageVersion.of(8))
|
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"
|
||||||
}
|
}
|
||||||
|
@ -33,5 +36,23 @@ subprojects {
|
||||||
maven {
|
maven {
|
||||||
url "https://repo.pyr.lol/releases"
|
url "https://repo.pyr.lol/releases"
|
||||||
}
|
}
|
||||||
|
maven {
|
||||||
|
url "https://jitpack.io/"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
publishing {
|
||||||
|
repositories {
|
||||||
|
maven {
|
||||||
|
url = uri("https://git.netherite.gg/api/packages/Netherite-Public/maven")
|
||||||
|
credentials(HttpHeaderCredentials) {
|
||||||
|
name "Authorization"
|
||||||
|
value "token ${project.properties["netherite.git.packages.token"]}"
|
||||||
|
}
|
||||||
|
authentication {
|
||||||
|
header(HttpHeaderAuthentication)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
0
gradlew
vendored
Normal file → Executable file
0
gradlew
vendored
Normal file → Executable file
|
@ -15,6 +15,21 @@ processResources {
|
||||||
expand("version": version)
|
expand("version": version)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
publishing {
|
||||||
|
publications {
|
||||||
|
mavenJava(MavenPublication) {
|
||||||
|
from components.java
|
||||||
|
artifactId = "znpcsplus-plugin"
|
||||||
|
|
||||||
|
pom {
|
||||||
|
name.set("znpcsplus-plugin")
|
||||||
|
description.set("The ZNPCsPlus plugin")
|
||||||
|
url.set("https://github.com/Pyrbu/ZNPCsPlus")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compileOnly "me.clip:placeholderapi:2.11.6" // Placeholder support
|
compileOnly "me.clip:placeholderapi:2.11.6" // Placeholder support
|
||||||
implementation "com.google.code.gson:gson:2.10.1" // JSON parsing
|
implementation "com.google.code.gson:gson:2.10.1" // JSON parsing
|
||||||
|
@ -25,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