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