Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added Citizens-2.0.41-b4138.jar
Binary file not shown.
7 changes: 7 additions & 0 deletions Freesia-Backend/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
repositories {
maven("https://maven.citizensnpcs.co/repo")
}

dependencies {
compileOnly("io.papermc.paper:paper-api:1.21.1-R0.1-SNAPSHOT")
compileOnly("io.netty:netty-all:4.1.118.Final")
compileOnly("net.citizensnpcs:citizens-main:2.0.41-SNAPSHOT") {
exclude(group = "*", module = "*")
}
}

tasks.build {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,3 @@ public void onDisable() {
"&5[&dFreesia&5] &cFreesia Backend plugin disabled!"));
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,3 @@ public void setCancelled(boolean b) {
return HANDLERS;
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,3 @@ public Set<UUID> getResultsUnmodifiable() {
return HANDLERS;
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -114,4 +114,3 @@ public CompletableFuture<Boolean> addVirtualPlayer(UUID playerUUID, int entityId
return future;
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -131,4 +131,4 @@ public void onPluginMessageReceived(@NotNull String channel, @NotNull Player sen
}
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -886,4 +886,4 @@ public byte[] getBytes() {
this.source.readBytes(bytes);
return bytes;
}
}
}
1 change: 1 addition & 0 deletions Freesia-Backend/src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ version: '1.0.3-YSM-2.6.4'
main: com.nguyendevs.freesia.backend.FreesiaBackend
api-version: '1.16'
folia-supported: true
softdepend: [Citizens]
29 changes: 29 additions & 0 deletions Freesia-NPC/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
plugins {
id("java")
id("com.github.johnrengelman.shadow") version "8.1.1"
}

group = "com.nguyendevs.freesia"
version = "1.0.0"

repositories {
mavenCentral()
maven("https://repo.papermc.io/repository/maven-public/")
maven("https://repo.citizensnpcs.co/")
}

dependencies {
compileOnly("io.papermc.paper:paper-api:1.21.1-R0.1-SNAPSHOT")
compileOnly("net.citizensnpcs:citizens-main:2.0.33-SNAPSHOT") {
exclude(group = "*", module = "*")
}
}

java {
toolchain.languageVersion.set(JavaLanguageVersion.of(21))
}

tasks.shadowJar {
archiveClassifier.set("")
archiveFileName.set("Freesia-NPC-${project.version}.jar")
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package com.nguyendevs.freesia.npc;

import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;

public class FreesiaNPCPlugin extends JavaPlugin {

public static final String CHANNEL_NAME = "freesia:npc";
public static FreesiaNPCPlugin INSTANCE;

@Override
public void onEnable() {
INSTANCE = this;

Bukkit.getMessenger().registerOutgoingPluginChannel(this, CHANNEL_NAME);
Bukkit.getMessenger().registerIncomingPluginChannel(this, CHANNEL_NAME, new TrackerListener());

getServer().getPluginManager().registerEvents(new TrackerListener(), this);
Bukkit.getConsoleSender().sendMessage(ChatColor.translateAlternateColorCodes('&',
"&5[&dFreesia-NPC&5] &a Enabled successfully. Hooked Citizens for proxy model injection!"));
}

@Override
public void onDisable() {
Bukkit.getMessenger().unregisterIncomingPluginChannel(this, CHANNEL_NAME);
Bukkit.getMessenger().unregisterOutgoingPluginChannel(this, CHANNEL_NAME);
getLogger().info(ChatColor.RED + "[Freesia-NPC] Disabled!");
}

public void sendProxyPayload(Player player, byte[] payload) {
player.sendPluginMessage(this, CHANNEL_NAME, payload);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
package com.nguyendevs.freesia.npc;

import io.papermc.paper.event.player.PlayerTrackEntityEvent;
import net.citizensnpcs.api.CitizensAPI;
import net.citizensnpcs.api.npc.NPC;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.plugin.messaging.PluginMessageListener;
import org.jetbrains.annotations.NotNull;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.util.Collection;

public class TrackerListener implements Listener, PluginMessageListener {

private static final byte OP_TRACK_SYNC = 0;
private static final byte OP_REQ_LIST = 1;
private static final byte OP_RES_LIST = 2;

@EventHandler
public void onTrackEntity(PlayerTrackEntityEvent event) {
final Entity beingWatched = event.getEntity();
final Player watcher = event.getPlayer();

if (beingWatched.hasMetadata("NPC")) {
NPC npc = CitizensAPI.getNPCRegistry().getNPC(beingWatched);
if (npc != null) {
try {
ByteArrayOutputStream bos = new ByteArrayOutputStream();
DataOutputStream dos = new DataOutputStream(bos);
dos.writeByte(OP_TRACK_SYNC);
dos.writeLong(watcher.getUniqueId().getMostSignificantBits());
dos.writeLong(watcher.getUniqueId().getLeastSignificantBits());
dos.writeInt(npc.getId());
dos.writeInt(beingWatched.getEntityId());
dos.flush();

FreesiaNPCPlugin.INSTANCE.sendProxyPayload(watcher, bos.toByteArray());
} catch (Exception e) {
FreesiaNPCPlugin.INSTANCE.getLogger().warning("Failed to send track sync: " + e.getMessage());
}
}
}
}

@Override
public void onPluginMessageReceived(@NotNull String channel, @NotNull Player player, byte[] message) {
if (!channel.equals(FreesiaNPCPlugin.CHANNEL_NAME)) return;

try (DataInputStream in = new DataInputStream(new ByteArrayInputStream(message))) {
byte opcode = in.readByte();
if (opcode == OP_REQ_LIST) {
Collection<NPC> npcs = (Collection<NPC>) CitizensAPI.getNPCRegistry().sorted();
ByteArrayOutputStream bos = new ByteArrayOutputStream();
DataOutputStream dos = new DataOutputStream(bos);
dos.writeByte(OP_RES_LIST);
dos.writeInt(npcs.size());
for (NPC npc : npcs) {
dos.writeInt(npc.getId());
dos.writeUTF(npc.getName());
}
dos.flush();
FreesiaNPCPlugin.INSTANCE.sendProxyPayload(player, bos.toByteArray());
}
} catch (Exception e) {
FreesiaNPCPlugin.INSTANCE.getLogger().warning("Failed to parse plugin messaging: " + e.getMessage());
}
}
}
7 changes: 7 additions & 0 deletions Freesia-NPC/src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
name: Freesia-NPC
version: 1.0.0
main: com.nguyendevs.freesia.npc.FreesiaNPCPlugin
api-version: '1.20'
depend: [Citizens]
description: Freesia expansion for mapping Citizens NPCs to YesSteveModel environments via Velocity/Waterfall arrays.
author: NguyenDevs
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@
import com.velocitypowered.api.proxy.messages.MinecraftChannelIdentifier;
import com.nguyendevs.freesia.common.EntryPoint;
import com.nguyendevs.freesia.common.communicating.NettySocketServer;
import com.nguyendevs.freesia.velocity.command.ListYsmPlayersCommand;
import com.nguyendevs.freesia.velocity.command.DispatchWorkerCommandCommand;
import com.nguyendevs.freesia.velocity.command.FreesiaCommand;
import com.nguyendevs.freesia.velocity.i18n.I18NManager;
import com.nguyendevs.freesia.velocity.network.backend.MasterServerMessageHandler;
import com.nguyendevs.freesia.velocity.network.mc.FreesiaPlayerTracker;
Expand Down Expand Up @@ -59,6 +58,7 @@ public class Freesia implements PacketListener {
public static YsmClientKickingDetector kickChecker;
public static YsmMapperPayloadManager mapperManager;
public static NettySocketServer masterServer;
public static com.nguyendevs.freesia.velocity.network.misc.NpcMessageReceiver npcMessageReceiver;

@Inject
private Logger logger;
Expand Down Expand Up @@ -114,6 +114,9 @@ public void onProxyStart(ProxyInitializeEvent event) {
tracker.addVirtualPlayerTrackerEventListener(mapperManager::onVirtualPlayerTrackerUpdate);

virtualPlayerManager.init();

npcMessageReceiver = new com.nguyendevs.freesia.velocity.network.misc.NpcMessageReceiver();
this.proxyServer.getEventManager().register(this, npcMessageReceiver);

io.netty.handler.ssl.SslContext sslContext = null;
try {
Expand All @@ -140,8 +143,8 @@ public void onProxyStart(ProxyInitializeEvent event) {
kickChecker.bootstrap();

LOGGER.info("Registering commands");
DispatchWorkerCommandCommand.register();
ListYsmPlayersCommand.register();
FreesiaCommand.register();

}

@Subscribe
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ public static final class FileConstants {

public static final class PermissionConstants {
public static final String LIST_PLAYER_COMMAND = "freesia.commands.listysmplayers",
DISPATCH_WORKER_COMMAND = "freesia.commands.dworkerc";
DISPATCH_WORKER_COMMAND = "freesia.commands.dworkerc",
SET_SKIN_COMMAND = "freesia.commands.setskin";
}

public static final class LanguageConstants {
Expand All @@ -33,6 +34,10 @@ public static final class LanguageConstants {
PLAYER_LIST_HEADER = "freesia.list_player_command_header",
PLAYER_LIST_ENTRY = "freesia.list_player_command_body",

SETSKIN_SUCCESS = "freesia.setskin.success",
SETSKIN_NO_PLAYERS = "freesia.setskin.no_players",
SETSKIN_CITIZENS_DISABLED = "freesia.setskin.citizens_disabled",

HANDSHAKE_TIMED_OUT = "freesia.mod_handshake_time_outed",
WORKER_TERMINATED_CONNECTION = "freesia.backend.disconnected",
WORKER_NOT_CONNECTED = "freesia.backend.not_connected";
Expand Down

This file was deleted.

Loading
Loading