commit 517f14138b0db71bb374af2ee72cb1b9083c6fc7 Author: Johannes Theiner Date: Wed Nov 27 08:54:27 2019 +0100 first commit diff --git a/impact.iml b/impact.iml new file mode 100644 index 0000000..f6131c6 --- /dev/null +++ b/impact.iml @@ -0,0 +1,96 @@ + + + + + + + PAPER + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..52aeca4 --- /dev/null +++ b/pom.xml @@ -0,0 +1,76 @@ + + + + 4.0.0 + + eu.univento.eu + impact + 1.0-SNAPSHOT + jar + + Impact + + + UTF-8 + + + + + + org.apache.maven.plugins + maven-compiler-plugin + + 1.8 + 1.8 + + + + org.apache.maven.plugins + maven-assembly-plugin + 2.2-beta-5 + + + + eu.univento.maya.Maya + + + + jar-with-dependencies + + + + + make-assembly + package + + single + + + + + + + + + + com.destroystokyo.paper + paper-api + 1.12-R0.1-SNAPSHOT + provided + + + org.bukkit + craftbukkit + 1.12-R0.1-SNAPSHOT + provided + + + eu.univento + Core + 1.0-SNAPSHOT + provided + + + diff --git a/src/main/java/eu/univento/impact/Impact.java b/src/main/java/eu/univento/impact/Impact.java new file mode 100644 index 0000000..b8b9f03 --- /dev/null +++ b/src/main/java/eu/univento/impact/Impact.java @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2017 univento.eu - All rights reserved + * You are not allowed to use, distribute or modify this code + */ + +package eu.univento.impact; + +import eu.univento.commons.server.ServerType; +import eu.univento.core.Core; +import eu.univento.core.api.command.CommandFramework; +import eu.univento.core.api.server.ServerSettings; +import eu.univento.core.commands.PlayerCommands; +import eu.univento.impact.listeners.JoinQuit; +import lombok.Getter; +import org.bukkit.Bukkit; +import org.bukkit.GameMode; +import org.bukkit.plugin.PluginManager; +import org.bukkit.plugin.java.JavaPlugin; + +/** + * @author joethei + * @version 0.1 + */ +public class Impact extends JavaPlugin{ + + @Getter private static Impact instance; + + @Override + public void onEnable() { + instance = this; + PluginManager pm = Bukkit.getPluginManager(); + pm.registerEvents(new JoinQuit(), this); + + CommandFramework commandFramework = Core.getCommandFramework(); + + commandFramework.registerCommands(new PlayerCommands()); + + ServerSettings.setServerType(ServerType.GAME_IMPACT); + ServerSettings.setGameMode(GameMode.ADVENTURE); + } + + @Override + public void onDisable() { + + } +} \ No newline at end of file diff --git a/src/main/java/eu/univento/impact/commands/PlayerCommands.java b/src/main/java/eu/univento/impact/commands/PlayerCommands.java new file mode 100644 index 0000000..2720b1c --- /dev/null +++ b/src/main/java/eu/univento/impact/commands/PlayerCommands.java @@ -0,0 +1,53 @@ +package eu.univento.impact.commands; + +import eu.univento.core.Core; +import eu.univento.core.api.command.Command; +import eu.univento.core.api.command.CommandArgs; +import eu.univento.core.api.command.Completer; +import eu.univento.core.api.player.CustomPlayer; + +import java.util.LinkedList; +import java.util.List; + +/** + * @author joethei + * @version 1.0 + */ +public class PlayerCommands { + + @Command(name = "stats", description = "view statistics", usage = "/stats ", inGameOnly = true) + public void stats(CommandArgs args) { + CustomPlayer p = args.getPlayer(); + if (args.length() == 1) { + CustomPlayer t = CustomPlayer.getPlayer(args.getArg(0)); + if (t == null) { + p.sendMessage("§cDieser Spieler ist nicht online"); + } else { + Core.getCommons().getGameStatistics().getImpact().get(t.getDatabasePlayer()).whenComplete((impactStatistics, throwable) -> { + p.sendMessage("Impact Stats von " + t.getDisplayName()); + p.sendMessage("Gespielte Spiele: " + impactStatistics.getGamesPlayed()); + p.sendMessage("Gewonne Spiele: " + impactStatistics.getGamesWon()); + p.sendMessage("Verlorene Spiele: " + impactStatistics.getGamesLost()); + p.sendMessage("Kills: " + impactStatistics.getKills()); + p.sendMessage("Deaths: " + impactStatistics.getDeaths()); + }); + } + } else { + Core.getCommons().getGameStatistics().getImpact().get(p.getDatabasePlayer()).whenComplete((impactStatistics, throwable) -> { + p.sendMessage("Deine Impact Stats"); + p.sendMessage("Gespielte Spiele: " + impactStatistics.getGamesPlayed()); + p.sendMessage("Gewonne Spiele: " + impactStatistics.getGamesWon()); + p.sendMessage("Verlorene Spiele: " + impactStatistics.getGamesLost()); + p.sendMessage("Kills: " + impactStatistics.getKills()); + p.sendMessage("Deaths: " + impactStatistics.getDeaths()); + }); + } + } + + @Completer(name = "stats") + public List statsCompleter(CommandArgs args) { + List list = new LinkedList<>(); + for (CustomPlayer player : Core.getOnlinePlayers()) list.add(player.getDisplayName()); + return list; + } +} \ No newline at end of file diff --git a/src/main/java/eu/univento/impact/game/GameState.java b/src/main/java/eu/univento/impact/game/GameState.java new file mode 100644 index 0000000..65853e4 --- /dev/null +++ b/src/main/java/eu/univento/impact/game/GameState.java @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2017 univento.eu - All rights reserved + * You are not allowed to use, distribute or modify this code + */ + +package eu.univento.impact.game; + +import lombok.Getter; +import lombok.Setter; + +/** + * @author joethei + * @version 1.0 + */ +public enum GameState { + Lobby, + Warmup, + Ingame; + + @Getter @Setter private static GameState state; + +} \ No newline at end of file diff --git a/src/main/java/eu/univento/impact/listeners/JoinQuit.java b/src/main/java/eu/univento/impact/listeners/JoinQuit.java new file mode 100644 index 0000000..aed1827 --- /dev/null +++ b/src/main/java/eu/univento/impact/listeners/JoinQuit.java @@ -0,0 +1,70 @@ +/* + * Copyright (c) 2017 univento.eu - All rights reserved + * You are not allowed to use, distribute or modify this code + */ + +package eu.univento.impact.listeners; + +import eu.univento.core.Core; +import eu.univento.core.api.game.TeamManager; +import eu.univento.core.api.player.CustomPlayer; +import eu.univento.core.api.player.SpectateManager; +import eu.univento.core.api.player.Spectator; +import eu.univento.core.api.server.ServerSettings; +import eu.univento.impact.game.GameState; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.player.PlayerJoinEvent; +import org.bukkit.event.player.PlayerLoginEvent; +import org.bukkit.event.player.PlayerQuitEvent; + +/** + * @author joethei + * @version 0.1 + */ +public class JoinQuit implements Listener{ + + @EventHandler + public void onJoin(PlayerJoinEvent e) { + CustomPlayer p = CustomPlayer.getPlayer(e.getPlayer()); + if(GameState.getState() == GameState.Lobby) { + + } + if(GameState.getState() == GameState.Warmup) { + e.setJoinMessage(null); + new Spectator(p); + } + if(GameState.getState() == GameState.Ingame) { + e.setJoinMessage(null); + new Spectator(p); + } + } + + @EventHandler + public void onQuit(PlayerQuitEvent e) { + CustomPlayer p = CustomPlayer.getPlayer(e.getPlayer()); + if(GameState.getState() == GameState.Lobby) { + + } + if(GameState.getState() == GameState.Warmup) { + e.setQuitMessage(null); + } + if(GameState.getState() == GameState.Ingame) { + e.setQuitMessage(null); + } + if (SpectateManager.contains(p)) { + SpectateManager.get(p).remove(); + } + if(TeamManager.getTeam(p) != null) { + TeamManager.getTeam(p).removePlayer(p); + } + } + + @EventHandler + public void onLogin(PlayerLoginEvent e) { + CustomPlayer p = CustomPlayer.getPlayer(e.getPlayer()); + if(GameState.getState() != GameState.Lobby && Core.getOnlinePlayers().size() >= ServerSettings.getMaxPlayers()) { + e.disallow(PlayerLoginEvent.Result.KICK_FULL, "§cDas Spiel ist voll"); + } + } +} \ No newline at end of file diff --git a/src/main/main11.iml b/src/main/main11.iml new file mode 100644 index 0000000..07a9b5d --- /dev/null +++ b/src/main/main11.iml @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml new file mode 100644 index 0000000..e16dd2c --- /dev/null +++ b/src/main/resources/plugin.yml @@ -0,0 +1,4 @@ +name: Impact +version: ${project.version} +main: eu.univento.impact.Impact +author: joethei diff --git a/target/classes/plugin.yml b/target/classes/plugin.yml new file mode 100644 index 0000000..e16dd2c --- /dev/null +++ b/target/classes/plugin.yml @@ -0,0 +1,4 @@ +name: Impact +version: ${project.version} +main: eu.univento.impact.Impact +author: joethei