mirror of
https://github.com/FancyInnovations/FancyPlugins.git
synced 2025-12-06 07:43:36 +00:00
packets: Move factories into :packets module
This commit is contained in:
65
libraries/packets/test-plugin/build.gradle.kts
Normal file
65
libraries/packets/test-plugin/build.gradle.kts
Normal file
@@ -0,0 +1,65 @@
|
||||
plugins {
|
||||
id("java-library")
|
||||
id("maven-publish")
|
||||
|
||||
id("xyz.jpenilla.run-paper")
|
||||
id("com.gradleup.shadow")
|
||||
id("net.minecrell.plugin-yml.paper")
|
||||
}
|
||||
|
||||
runPaper.folia.registerTask()
|
||||
|
||||
repositories {
|
||||
mavenLocal()
|
||||
mavenCentral()
|
||||
maven(url = "https://repo.papermc.io/repository/maven-public/")
|
||||
maven(url = "https://repo.fancyinnovations.com/releases")
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compileOnly("io.papermc.paper:paper-api:1.21.5-R0.1-SNAPSHOT")
|
||||
|
||||
implementation(project(":libraries:packets"))
|
||||
implementation(project(":libraries:packets:packets-api"))
|
||||
implementation(project(":libraries:packets:implementations:1_20_6"))
|
||||
implementation(project(":libraries:packets:implementations:1_21_3"))
|
||||
implementation("de.oliver.FancyAnalytics:logger:0.0.6")
|
||||
}
|
||||
|
||||
paper {
|
||||
name = "FancySitulaTestPlugin"
|
||||
main = "de.oliver.fancysitula.FancySitulaPlugin"
|
||||
bootstrapper = "de.oliver.fancysitula.loaders.FancySitulaPluginBootstrapper"
|
||||
loader = "de.oliver.fancysitula.loaders.FancySitulaPluginLoader"
|
||||
foliaSupported = true
|
||||
version = "1.0.0"
|
||||
description = "Test plugin for FancySitula"
|
||||
apiVersion = "1.19"
|
||||
}
|
||||
|
||||
tasks {
|
||||
runServer {
|
||||
minecraftVersion("1.21.5")
|
||||
}
|
||||
|
||||
shadowJar {
|
||||
archiveClassifier.set("")
|
||||
}
|
||||
|
||||
compileJava {
|
||||
options.encoding = Charsets.UTF_8.name()
|
||||
options.release = 21
|
||||
}
|
||||
|
||||
javadoc {
|
||||
options.encoding = Charsets.UTF_8.name()
|
||||
}
|
||||
|
||||
processResources {
|
||||
filteringCharset = Charsets.UTF_8.name()
|
||||
}
|
||||
}
|
||||
|
||||
java {
|
||||
toolchain.languageVersion.set(JavaLanguageVersion.of(21))
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package de.oliver.fancysitula;
|
||||
|
||||
import de.oliver.fancyanalytics.logger.LogLevel;
|
||||
import de.oliver.fancysitula.api.IFancySitula;
|
||||
import de.oliver.fancysitula.commands.FancySitulaCMD;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
public class FancySitulaPlugin extends JavaPlugin {
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
IFancySitula.LOGGER.setCurrentLevel(LogLevel.DEBUG);
|
||||
|
||||
getServer().getCommandMap().register("fancysitula", new FancySitulaCMD());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,118 @@
|
||||
package de.oliver.fancysitula.commands;
|
||||
|
||||
import de.oliver.fancysitula.api.entities.FS_RealPlayer;
|
||||
import de.oliver.fancysitula.api.packets.FS_ClientboundPlayerInfoUpdatePacket;
|
||||
import de.oliver.fancysitula.api.packets.FS_Color;
|
||||
import de.oliver.fancysitula.api.teams.FS_CollisionRule;
|
||||
import de.oliver.fancysitula.api.teams.FS_NameTagVisibility;
|
||||
import de.oliver.fancysitula.api.teams.FS_Team;
|
||||
import de.oliver.fancysitula.api.utils.FS_GameProfile;
|
||||
import de.oliver.fancysitula.api.utils.FS_GameType;
|
||||
import de.oliver.fancysitula.factories.FancySitula;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public class FancySitulaCMD extends Command {
|
||||
|
||||
public FancySitulaCMD() {
|
||||
super("fancysitula");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean execute(@NotNull CommandSender sender, @NotNull String s, @NotNull String[] args) {
|
||||
if (!(sender instanceof Player p)) {
|
||||
sender.sendMessage("You must be a player to execute this command!");
|
||||
return true;
|
||||
}
|
||||
|
||||
// Wrap the real player into an FS_Player instance
|
||||
FS_RealPlayer fsPlayer = new FS_RealPlayer(p);
|
||||
testTeam(p);
|
||||
|
||||
// FS_TextDisplay fakeTextDisplay = new FS_TextDisplay();
|
||||
// fakeTextDisplay.setBillboardRenderConstraints((byte) 3);
|
||||
// fakeTextDisplay.setScale(new Vector3f(5f));
|
||||
// fakeTextDisplay.setLocation(p.getLocation());
|
||||
// fakeTextDisplay.setText(Component.text("Hello, World!"));
|
||||
// fakeTextDisplay.setBackground(0xFF00C8FF);
|
||||
// FancySitula.ENTITY_FACTORY.spawnEntityFor(fsPlayer, fakeTextDisplay);
|
||||
|
||||
// FS_ItemDisplay fakeItemDisplay = new FS_ItemDisplay();
|
||||
// fakeItemDisplay.setBillboardRenderConstraints((byte) 3);
|
||||
// fakeItemDisplay.setScale(new Vector3f(5f));
|
||||
// fakeItemDisplay.setLocation(p.getLocation());
|
||||
// fakeItemDisplay.setItem(p.getInventory().getItemInMainHand());
|
||||
// FancySitula.ENTITY_FACTORY.spawnEntityFor(fsPlayer, fakeItemDisplay);
|
||||
|
||||
// FS_BlockDisplay fakeBlockDisplay = new FS_BlockDisplay();
|
||||
// fakeBlockDisplay.setBillboardRenderConstraints((byte) 3);
|
||||
// fakeBlockDisplay.setScale(new Vector3f(5f));
|
||||
// fakeBlockDisplay.setLocation(p.getLocation());
|
||||
// fakeBlockDisplay.setBlock(Material.DIAMOND_BLOCK.createBlockData().createBlockState());
|
||||
// FancySitula.ENTITY_FACTORY.spawnEntityFor(fsPlayer, fakeBlockDisplay);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private void testTeam(Player to) {
|
||||
FS_RealPlayer fsPlayer = new FS_RealPlayer(to);
|
||||
|
||||
|
||||
FS_Team team = new FS_Team(
|
||||
"myTeam",
|
||||
Component.text("My Team"),
|
||||
true,
|
||||
true,
|
||||
FS_NameTagVisibility.ALWAYS,
|
||||
FS_CollisionRule.ALWAYS,
|
||||
FS_Color.AQUA,
|
||||
Component.text("Prefix"),
|
||||
Component.text("Suffix"),
|
||||
List.of("OliverHD", "OliverHD_2")
|
||||
);
|
||||
|
||||
|
||||
FancySitula.TEAM_FACTORY.createTeamFor(fsPlayer, team);
|
||||
// FancySitula.TEAM_FACTORY.updateTeamFor(fsPlayer, team);
|
||||
// FancySitula.TEAM_FACTORY.addEntitiesToTeamFor(fsPlayer, team, List.of("OliverHD", "OliverHD_2"));
|
||||
}
|
||||
|
||||
private void fakeTablistEntries(Player to) {
|
||||
// Wrap the real player into an FS_Player instance
|
||||
FS_RealPlayer fsPlayer = new FS_RealPlayer(to);
|
||||
|
||||
|
||||
UUID uuid1 = UUID.randomUUID();
|
||||
FS_ClientboundPlayerInfoUpdatePacket.Entry entry1 = new FS_ClientboundPlayerInfoUpdatePacket.Entry(
|
||||
uuid1,
|
||||
new FS_GameProfile(uuid1, ""),
|
||||
true,
|
||||
69,
|
||||
FS_GameType.SURVIVAL,
|
||||
Component.text("player1")
|
||||
);
|
||||
|
||||
UUID uuid2 = UUID.randomUUID();
|
||||
FS_ClientboundPlayerInfoUpdatePacket.Entry entry2 = new FS_ClientboundPlayerInfoUpdatePacket.Entry(
|
||||
uuid2,
|
||||
new FS_GameProfile(uuid2, ""),
|
||||
true,
|
||||
69,
|
||||
FS_GameType.SURVIVAL,
|
||||
Component.text("player2")
|
||||
);
|
||||
|
||||
FS_ClientboundPlayerInfoUpdatePacket playerInfoUpdatePacket = FancySitula.PACKET_FACTORY.createPlayerInfoUpdatePacket(
|
||||
EnumSet.of(FS_ClientboundPlayerInfoUpdatePacket.Action.ADD_PLAYER, FS_ClientboundPlayerInfoUpdatePacket.Action.UPDATE_LISTED, FS_ClientboundPlayerInfoUpdatePacket.Action.UPDATE_DISPLAY_NAME),
|
||||
List.of(entry1, entry2)
|
||||
);
|
||||
playerInfoUpdatePacket.send(fsPlayer);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package de.oliver.fancysitula.loaders;
|
||||
|
||||
import io.papermc.paper.plugin.bootstrap.BootstrapContext;
|
||||
import io.papermc.paper.plugin.bootstrap.PluginBootstrap;
|
||||
import io.papermc.paper.plugin.bootstrap.PluginProviderContext;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class FancySitulaPluginBootstrapper implements PluginBootstrap {
|
||||
@Override
|
||||
public void bootstrap(@NotNull BootstrapContext bootstrapContext) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull JavaPlugin createPlugin(@NotNull PluginProviderContext context) {
|
||||
return PluginBootstrap.super.createPlugin(context);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package de.oliver.fancysitula.loaders;
|
||||
|
||||
import io.papermc.paper.plugin.loader.PluginClasspathBuilder;
|
||||
import io.papermc.paper.plugin.loader.PluginLoader;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class FancySitulaPluginLoader implements PluginLoader {
|
||||
@Override
|
||||
public void classloader(@NotNull PluginClasspathBuilder pluginClasspathBuilder) {
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user