From 6d3c2ceff0148d4b53bf65adce8501fa0c98ef46 Mon Sep 17 00:00:00 2001 From: ef3d0c3e Date: Sat, 10 Aug 2024 12:42:30 +0200 Subject: [PATCH] NPC --- core/dependency-reduced-pom.xml | 100 ++++++++ core/pom.xml | 16 +- .../org/ef3d0c3e/sheepwars/SheepWars.java | 22 +- .../java/org/ef3d0c3e/sheepwars/Util.java | 4 + .../sheepwars/commands/CmdSheepWars.java | 60 +++++ .../sheepwars/commands/CommandFactory.java | 107 +++++++++ .../org/ef3d0c3e/sheepwars/game/Game.java | 6 +- .../ef3d0c3e/sheepwars/hologram/Hologram.java | 47 ++++ .../sheepwars/hologram/HologramComponent.java | 39 ++++ .../sheepwars/hologram/HologramFactory.java | 105 +++++++++ .../hologram/HologramTextComponent.java | 64 ++++++ .../org/ef3d0c3e/sheepwars/items/IItem.java | 211 +++++++++++++++++ .../ef3d0c3e/sheepwars/items/ItemFactory.java | 38 ++++ .../sheepwars/items/UUIDItemTagType.java | 42 ++++ .../org/ef3d0c3e/sheepwars/level/Level.java | 11 + .../sheepwars/level/lobby/LobbyEvents.java | 9 + .../sheepwars/level/lobby/LobbyLevel.java | 7 +- .../ef3d0c3e/sheepwars/npc/NPCFactory.java | 135 +++++++++++ .../org/ef3d0c3e/sheepwars/npc/PlayerNPC.java | 214 ++++++++++++++++++ .../sheepwars/packets/ArmorStandMetadata.java | 45 ++++ .../sheepwars/packets/EntityMetadata.java | 134 +++++++++++ .../sheepwars/packets/IntoEntityData.java | 9 + .../packets/PacketListenerFactory.java | 86 +++++++ .../sheepwars/packets/PlayerMetadata.java | 65 ++++++ .../sheepwars/versions/WrapperFactory.java | 1 - core/src/main/resources/plugin.yml | 2 +- dist/dependency-reduced-pom.xml | 26 ++- dist/pom.xml | 32 ++- ... worldedit-bukkit-7.3.6-SNAPSHOT-dist.jar} | Bin 5811999 -> 5811841 bytes pom.xml | 10 +- {spigot-1.21.1 => spigot-1.21.0}/pom.xml | 2 +- .../ef3d0c3e/sheepwars/v1_21_R0}/Skin.java | 2 +- 32 files changed, 1603 insertions(+), 48 deletions(-) create mode 100644 core/dependency-reduced-pom.xml create mode 100644 core/src/main/java/org/ef3d0c3e/sheepwars/Util.java create mode 100644 core/src/main/java/org/ef3d0c3e/sheepwars/commands/CmdSheepWars.java create mode 100644 core/src/main/java/org/ef3d0c3e/sheepwars/commands/CommandFactory.java create mode 100644 core/src/main/java/org/ef3d0c3e/sheepwars/hologram/Hologram.java create mode 100644 core/src/main/java/org/ef3d0c3e/sheepwars/hologram/HologramComponent.java create mode 100644 core/src/main/java/org/ef3d0c3e/sheepwars/hologram/HologramFactory.java create mode 100644 core/src/main/java/org/ef3d0c3e/sheepwars/hologram/HologramTextComponent.java create mode 100644 core/src/main/java/org/ef3d0c3e/sheepwars/items/IItem.java create mode 100644 core/src/main/java/org/ef3d0c3e/sheepwars/items/ItemFactory.java create mode 100644 core/src/main/java/org/ef3d0c3e/sheepwars/items/UUIDItemTagType.java create mode 100644 core/src/main/java/org/ef3d0c3e/sheepwars/npc/NPCFactory.java create mode 100644 core/src/main/java/org/ef3d0c3e/sheepwars/npc/PlayerNPC.java create mode 100644 core/src/main/java/org/ef3d0c3e/sheepwars/packets/ArmorStandMetadata.java create mode 100644 core/src/main/java/org/ef3d0c3e/sheepwars/packets/EntityMetadata.java create mode 100644 core/src/main/java/org/ef3d0c3e/sheepwars/packets/IntoEntityData.java create mode 100644 core/src/main/java/org/ef3d0c3e/sheepwars/packets/PacketListenerFactory.java create mode 100644 core/src/main/java/org/ef3d0c3e/sheepwars/packets/PlayerMetadata.java rename libs/{worldedit-bukkit-7.3.5.jar => worldedit-bukkit-7.3.6-SNAPSHOT-dist.jar} (94%) rename {spigot-1.21.1 => spigot-1.21.0}/pom.xml (98%) rename {spigot-1.21.1/src/main/java/org/ef3d0c3e/sheepwars/v1_21_R1 => spigot-1.21.0/src/main/java/org/ef3d0c3e/sheepwars/v1_21_R0}/Skin.java (99%) diff --git a/core/dependency-reduced-pom.xml b/core/dependency-reduced-pom.xml new file mode 100644 index 0000000..748d0d6 --- /dev/null +++ b/core/dependency-reduced-pom.xml @@ -0,0 +1,100 @@ + + + + SheepWars + org.ef3d0c3e.sheepwars + 1.0-SNAPSHOT + + 4.0.0 + SheepWars-core + + + + src/main/resources + + + + + maven-shade-plugin + 3.6.0 + + + package + + shade + + + + + + + com.github.retrooper.packetevents + org.ef3d0c3e.lib.packetevents.api + + + io.github.retrooper.packetevents + org.ef3d0c3e.lib.packetevents.impl + + + de.cubbossa.cliententities.lib.packetevents.api + org.ef3d0c3e.lib.packetevents.api + + + de.cubbossa.cliententities.lib.packetevents.impl + org.ef3d0c3e.lib.packetevents.impl + + + fr.mrmicky.fastboard + org.ef3d0c3e.lib.fastboard + + + + + + + + + org.spigotmc + spigot + 1.21.1-R0.1-SNAPSHOT + remapped-mojang + provided + + + commons-lang + commons-lang + + + json-simple + com.googlecode.json-simple + + + + + org.spigotmc + spigot-api + 1.21.1-R0.1-SNAPSHOT + provided + + + com.github.retrooper + packetevents-spigot + 2.4.0 + provided + + + com.comphenix.protocol + ProtocolLib + 5.2.0-SNAPSHOT-726 + system + ${pom.basedir}/../libs/ProtocolLib.jar + + + com.sk89q.worldedit + worldedit-bukkit + 7.3.6 + system + ${pom.basedir}/../libs/worldedit-bukkit-7.3.6-SNAPSHOT-dist.jar + + + diff --git a/core/pom.xml b/core/pom.xml index 7c7d199..5c1bdbd 100644 --- a/core/pom.xml +++ b/core/pom.xml @@ -48,12 +48,18 @@ system ${pom.basedir}/../libs/ProtocolLib.jar + + com.github.retrooper + packetevents-spigot + 2.4.0 + compile + com.sk89q.worldedit worldedit-bukkit - 7.3.5 + 7.3.6 system - ${pom.basedir}/../libs/worldedit-bukkit-7.3.5.jar + ${pom.basedir}/../libs/worldedit-bukkit-7.3.6-SNAPSHOT-dist.jar fr.mrmicky @@ -61,9 +67,9 @@ 2.1.3 - org.bukkit - bukkit - 1.21.1-R0.1-SNAPSHOT + com.google.guava + guava + 33.1.0-jre compile diff --git a/core/src/main/java/org/ef3d0c3e/sheepwars/SheepWars.java b/core/src/main/java/org/ef3d0c3e/sheepwars/SheepWars.java index 716ddec..985ad02 100644 --- a/core/src/main/java/org/ef3d0c3e/sheepwars/SheepWars.java +++ b/core/src/main/java/org/ef3d0c3e/sheepwars/SheepWars.java @@ -1,7 +1,8 @@ package org.ef3d0c3e.sheepwars; -import com.comphenix.protocol.ProtocolLibrary; -import com.comphenix.protocol.ProtocolManager; +import com.github.retrooper.packetevents.PacketEvents; +import io.github.retrooper.packetevents.factory.spigot.SpigotPacketEventsBuilder; +import org.ef3d0c3e.sheepwars.commands.CommandFactory; import lombok.Getter; import org.bukkit.Bukkit; import org.bukkit.configuration.InvalidConfigurationException; @@ -15,6 +16,7 @@ import org.ef3d0c3e.sheepwars.events.EventListenerFactory; import org.ef3d0c3e.sheepwars.game.Game; import org.ef3d0c3e.sheepwars.level.VoidChunkGenerator; import org.ef3d0c3e.sheepwars.locale.LocaleManager; +import org.ef3d0c3e.sheepwars.packets.PacketListenerFactory; import org.ef3d0c3e.sheepwars.player.CPlayer; import org.ef3d0c3e.sheepwars.versions.WrapperFactory; import org.jetbrains.annotations.NotNull; @@ -22,7 +24,6 @@ import org.jetbrains.annotations.NotNull; import java.io.*; import java.text.MessageFormat; import java.util.Enumeration; -import java.util.EventListener; import java.util.jar.JarEntry; import java.util.jar.JarFile; @@ -31,8 +32,6 @@ public final class SheepWars extends JavaPlugin @Getter private static Plugin plugin; @Getter - private static ProtocolManager protocolManager; - @Getter private static Config sheepWarsConfig; @Getter private static LocaleManager localeManager; @@ -87,7 +86,6 @@ public final class SheepWars extends JavaPlugin { throw new RuntimeException(e); } - } { @@ -136,22 +134,32 @@ public final class SheepWars extends JavaPlugin e.printStackTrace(); } + PacketEvents.setAPI(SpigotPacketEventsBuilder.build(this)); + PacketEvents.getAPI().load(); + consoleMessage("--[ Setup done ]--"); } @Override public void onDisable() { + PacketEvents.getAPI().terminate(); consoleMessage("Plugin Disabled!"); } @Override public void onEnable() { plugin = this; - protocolManager = ProtocolLibrary.getProtocolManager(); + + PacketEvents.getAPI().getSettings() + .debug(true) + .reEncodeByDefault(true); + PacketEvents.getAPI().init(); // Factories try { + CommandFactory.registerCommands(); EventListenerFactory.create(); + PacketListenerFactory.create(); } catch (Exception e) { diff --git a/core/src/main/java/org/ef3d0c3e/sheepwars/Util.java b/core/src/main/java/org/ef3d0c3e/sheepwars/Util.java new file mode 100644 index 0000000..3619b9d --- /dev/null +++ b/core/src/main/java/org/ef3d0c3e/sheepwars/Util.java @@ -0,0 +1,4 @@ +package org.ef3d0c3e.sheepwars; + +public class Util { +} diff --git a/core/src/main/java/org/ef3d0c3e/sheepwars/commands/CmdSheepWars.java b/core/src/main/java/org/ef3d0c3e/sheepwars/commands/CmdSheepWars.java new file mode 100644 index 0000000..5c53755 --- /dev/null +++ b/core/src/main/java/org/ef3d0c3e/sheepwars/commands/CmdSheepWars.java @@ -0,0 +1,60 @@ +package org.ef3d0c3e.sheepwars.commands; + +import com.google.common.collect.Lists; +import org.bukkit.command.Command; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; +import org.jetbrains.annotations.NotNull; + +import javax.annotation.Nullable; +import java.util.Arrays; +import java.util.List; + +public class CmdSheepWars extends Command { + public CmdSheepWars() + { + super("sheepwars", "Plugin command", "/sheepwars", Arrays.asList("sw")); + setPermission("sw.admin"); + } + + @Override + public boolean execute(@NotNull CommandSender sender, @NotNull String s, @NotNull String[] args) { + if (!(sender instanceof Player)) + { + sender.sendMessage("§cYou must be a player to execute this command."); + return false; + } + + final Player p = (Player)sender; + final String category = args.length == 0 ? "help" : args[0]; + if (category.equals("help")) + { + sender.sendMessage(" - §ahelp §fDisplays this page"); + sender.sendMessage(" - §astart §fStarts the game"); + sender.sendMessage(" - §adebug §7