From ed3fcaee0fff278c237d0f113cae73ebcd0dad15 Mon Sep 17 00:00:00 2001 From: Lixfel Date: Sun, 20 Mar 2022 11:50:03 +0100 Subject: [PATCH] Initial commit --- .gitignore | 9 +++ pom.xml | 77 +++++++++++++++++++ src/de/steamwar/tutorial/TutorialSystem.java | 43 +++++++++++ .../tutorial/listener/BasicListener.java | 30 ++++++++ .../steamwar/tutorial/listener/RateSign.java | 48 ++++++++++++ src/plugin.yml | 7 ++ steamwarci.yml | 6 ++ 7 files changed, 220 insertions(+) create mode 100644 .gitignore create mode 100644 pom.xml create mode 100644 src/de/steamwar/tutorial/TutorialSystem.java create mode 100644 src/de/steamwar/tutorial/listener/BasicListener.java create mode 100644 src/de/steamwar/tutorial/listener/RateSign.java create mode 100644 src/plugin.yml create mode 100644 steamwarci.yml diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..f2e94a6 --- /dev/null +++ b/.gitignore @@ -0,0 +1,9 @@ +# Maven +/target + +# IntelliJ IDEA +/.idea +*.iml + +# Other +/lib \ No newline at end of file diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..6390774 --- /dev/null +++ b/pom.xml @@ -0,0 +1,77 @@ + + + + + 4.0.0 + + de.steamwar + TutorialSystem + 1.0 + jar + https://maven.apache.org + + + UTF-8 + ${project.basedir} + + + + src + + + src + + **/*.java + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.6.1 + + 8 + 8 + -Xlint + + + + + + + + steamwar + Spigot + 1.15 + system + ${main.basedir}/lib/Spigot-1.15.jar + + + steamwar + SpigotCore + 1.0 + system + ${main.basedir}/lib/SpigotCore.jar + + + \ No newline at end of file diff --git a/src/de/steamwar/tutorial/TutorialSystem.java b/src/de/steamwar/tutorial/TutorialSystem.java new file mode 100644 index 0000000..b25df01 --- /dev/null +++ b/src/de/steamwar/tutorial/TutorialSystem.java @@ -0,0 +1,43 @@ +/* + * This file is a part of the SteamWar software. + * + * Copyright (C) 2021 SteamWar.de-Serverteam + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package de.steamwar.tutorial; + +import de.steamwar.tutorial.listener.RateSign; +import org.bukkit.plugin.java.JavaPlugin; + +public class TutorialSystem extends JavaPlugin { + + private static TutorialSystem plugin; + + @Override + public void onLoad() { + plugin = this; + } + + @Override + public void onEnable() { + new RateSign(); + } + + + public static TutorialSystem getPlugin() { + return plugin; + } +} diff --git a/src/de/steamwar/tutorial/listener/BasicListener.java b/src/de/steamwar/tutorial/listener/BasicListener.java new file mode 100644 index 0000000..0945ae4 --- /dev/null +++ b/src/de/steamwar/tutorial/listener/BasicListener.java @@ -0,0 +1,30 @@ +/* + * This file is a part of the SteamWar software. + * + * Copyright (C) 2022 SteamWar.de-Serverteam + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package de.steamwar.tutorial.listener; + +import de.steamwar.tutorial.TutorialSystem; +import org.bukkit.Bukkit; +import org.bukkit.event.Listener; + +public abstract class BasicListener implements Listener { + public BasicListener() { + Bukkit.getPluginManager().registerEvents(this, TutorialSystem.getPlugin()); + } +} diff --git a/src/de/steamwar/tutorial/listener/RateSign.java b/src/de/steamwar/tutorial/listener/RateSign.java new file mode 100644 index 0000000..faa526a --- /dev/null +++ b/src/de/steamwar/tutorial/listener/RateSign.java @@ -0,0 +1,48 @@ +/* + * This file is a part of the SteamWar software. + * + * Copyright (C) 2021 SteamWar.de-Serverteam + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package de.steamwar.tutorial.listener; + +import de.steamwar.comms.packets.ExecuteCommandPacket; +import org.bukkit.block.BlockState; +import org.bukkit.block.Sign; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.block.Action; +import org.bukkit.event.player.PlayerInteractEvent; + +public class RateSign extends BasicListener { + + @EventHandler + public void onInteract(PlayerInteractEvent event) { + if(!event.hasBlock() || event.getAction() != Action.RIGHT_CLICK_BLOCK) + return; + + BlockState state = event.getClickedBlock().getState(); + if (!(state instanceof Sign)) + return; + + Sign sign = (Sign) state; + if(!"[rate]".equals(sign.getLine(0))) + return; + + Player player = event.getPlayer(); + new ExecuteCommandPacket(player, "tutorial rate " + System.getProperty("tutorial")).send(player); + } +} diff --git a/src/plugin.yml b/src/plugin.yml new file mode 100644 index 0000000..8534f04 --- /dev/null +++ b/src/plugin.yml @@ -0,0 +1,7 @@ +name: TutorialSystem +version: "1.0" +authors: + - Lixfel +main: de.steamwar.tutorial.TutorialSystem +depend: [SpigotCore] +api-version: "1.13" diff --git a/steamwarci.yml b/steamwarci.yml new file mode 100644 index 0000000..206f643 --- /dev/null +++ b/steamwarci.yml @@ -0,0 +1,6 @@ +build: + - "ln -s /home/gitea/lib" + - "mvn package -B" + +artifacts: + "/binarys/tutorialsystem.jar": "target/TutorialSystem-1.0.jar"