From 759506f874a61c9e8910ae935438a440f2720404 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Tue, 22 Mar 2022 10:40:48 +0100 Subject: [PATCH 1/2] Add TutorialCommand --- src/de/steamwar/tutorial/TutorialSystem.java | 3 +++ .../tutorial/commands/TutorialCommand.java | 17 +++++++++++++++++ 2 files changed, 20 insertions(+) create mode 100644 src/de/steamwar/tutorial/commands/TutorialCommand.java diff --git a/src/de/steamwar/tutorial/TutorialSystem.java b/src/de/steamwar/tutorial/TutorialSystem.java index 2393f69..bfb64b0 100644 --- a/src/de/steamwar/tutorial/TutorialSystem.java +++ b/src/de/steamwar/tutorial/TutorialSystem.java @@ -19,6 +19,7 @@ package de.steamwar.tutorial; +import de.steamwar.tutorial.commands.TutorialCommand; import de.steamwar.tutorial.listener.Joining; import de.steamwar.tutorial.listener.RateSign; import org.bukkit.plugin.java.JavaPlugin; @@ -36,6 +37,8 @@ public class TutorialSystem extends JavaPlugin { public void onEnable() { new RateSign(); new Joining(); + + new TutorialCommand(); } public static TutorialSystem getPlugin() { diff --git a/src/de/steamwar/tutorial/commands/TutorialCommand.java b/src/de/steamwar/tutorial/commands/TutorialCommand.java new file mode 100644 index 0000000..09aa30e --- /dev/null +++ b/src/de/steamwar/tutorial/commands/TutorialCommand.java @@ -0,0 +1,17 @@ +package de.steamwar.tutorial.commands; + +import de.steamwar.command.SWCommand; +import de.steamwar.comms.packets.ExecuteCommandPacket; +import org.bukkit.entity.Player; + +public class TutorialCommand extends SWCommand { + + public TutorialCommand() { + super("tutorial"); + } + + @Register("rate") + public void rateCommand(Player player) { + new ExecuteCommandPacket(player, "tutorial rate " + System.getProperty("tutorial")).send(player); + } +} From 5371ad1cd5bddfce9f00caee60eb9dbad40aaf66 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Tue, 22 Mar 2022 10:59:53 +0100 Subject: [PATCH 2/2] Remove duplication --- src/de/steamwar/tutorial/commands/TutorialCommand.java | 4 ++++ src/de/steamwar/tutorial/listener/RateSign.java | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/de/steamwar/tutorial/commands/TutorialCommand.java b/src/de/steamwar/tutorial/commands/TutorialCommand.java index 09aa30e..4ef7edd 100644 --- a/src/de/steamwar/tutorial/commands/TutorialCommand.java +++ b/src/de/steamwar/tutorial/commands/TutorialCommand.java @@ -12,6 +12,10 @@ public class TutorialCommand extends SWCommand { @Register("rate") public void rateCommand(Player player) { + rate(player); + } + + public static void rate(Player player) { new ExecuteCommandPacket(player, "tutorial rate " + System.getProperty("tutorial")).send(player); } } diff --git a/src/de/steamwar/tutorial/listener/RateSign.java b/src/de/steamwar/tutorial/listener/RateSign.java index faa526a..01d8750 100644 --- a/src/de/steamwar/tutorial/listener/RateSign.java +++ b/src/de/steamwar/tutorial/listener/RateSign.java @@ -19,7 +19,7 @@ package de.steamwar.tutorial.listener; -import de.steamwar.comms.packets.ExecuteCommandPacket; +import de.steamwar.tutorial.commands.TutorialCommand; import org.bukkit.block.BlockState; import org.bukkit.block.Sign; import org.bukkit.entity.Player; @@ -43,6 +43,6 @@ public class RateSign extends BasicListener { return; Player player = event.getPlayer(); - new ExecuteCommandPacket(player, "tutorial rate " + System.getProperty("tutorial")).send(player); + TutorialCommand.rate(player); } }