From 0657ac404b39d049668c782886fd77750e438ea6 Mon Sep 17 00:00:00 2001 From: Yaruma3341 Date: Tue, 7 Jan 2020 23:22:31 +0100 Subject: [PATCH] added scoreboard --- .gitignore | 3 +- .../src/de/steamwar/bausystem/BauSystem.java | 4 +- .../bausystem/world/BauScoreboard.java | 42 +++++++++++++++++++ 3 files changed, 47 insertions(+), 2 deletions(-) create mode 100644 BauSystem_Main/src/de/steamwar/bausystem/world/BauScoreboard.java diff --git a/.gitignore b/.gitignore index 7eae63f..02142ca 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ .idea target -dependency-reduced-pom.xml \ No newline at end of file +dependency-reduced-pom.xml +*.iml \ No newline at end of file diff --git a/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java b/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java index 7054767..d67bbf3 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java @@ -2,6 +2,7 @@ package de.steamwar.bausystem; import de.steamwar.bausystem.commands.*; import de.steamwar.bausystem.world.ArenaSection; +import de.steamwar.bausystem.world.BauScoreboard; import de.steamwar.bausystem.world.RegionListener; import de.steamwar.bausystem.world.TNTListener; import de.steamwar.core.CommandRemover; @@ -83,6 +84,7 @@ public class BauSystem extends JavaPlugin implements Listener { Bukkit.getPluginManager().registerEvents(this, this); Bukkit.getPluginManager().registerEvents(new RegionListener(), this); Bukkit.getPluginManager().registerEvents(new TNTListener(), this); + Bukkit.getPluginManager().registerEvents(new BauScoreboard(), this); } public static BauSystem getPlugin(){ @@ -114,7 +116,7 @@ public class BauSystem extends JavaPlugin implements Listener { } @EventHandler - public void onLeave(PlayerQuitEvent e){ + public void onLeave(PlayerQuitEvent e) { if(Bukkit.getOnlinePlayers().isEmpty() || (Bukkit.getOnlinePlayers().size() == 1 && Bukkit.getOnlinePlayers().contains(e.getPlayer()))) Bukkit.shutdown(); } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/world/BauScoreboard.java b/BauSystem_Main/src/de/steamwar/bausystem/world/BauScoreboard.java new file mode 100644 index 0000000..4adc7f1 --- /dev/null +++ b/BauSystem_Main/src/de/steamwar/bausystem/world/BauScoreboard.java @@ -0,0 +1,42 @@ +package de.steamwar.bausystem.world; + +import de.steamwar.bausystem.commands.CommandFreeze; +import de.steamwar.bausystem.commands.CommandTNT; +import de.steamwar.scoreboard.SWScoreboard; +import de.steamwar.scoreboard.ScoreboardCallback; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.player.PlayerJoinEvent; + +import java.text.SimpleDateFormat; +import java.util.Calendar; +import java.util.HashMap; + +public class BauScoreboard implements Listener { + + @EventHandler + public void handlePlayerJoin(PlayerJoinEvent event) { + Player player = event.getPlayer(); + + SWScoreboard.createScoreboard(player, new ScoreboardCallback() { + @Override + public HashMap getData() { + HashMap data = new HashMap<>(); + data.put("§1 ", 5); + data.put("§eUhrzeit§8: §7" + new SimpleDateFormat("HH:mm:ss").format(Calendar.getInstance().getTime()), 4); + data.put("§2 ", 3); + data.put("§eTNT§8: " + (!CommandTNT.getInstance().isOn() ? "§aan" : "§caus"), 2); + data.put("§eFreeze§8: " + (!CommandFreeze.getInstance().isOn() ? "§aan" : "§caus"), 1); + return data; + } + + @Override + public String getTitle() { + return "§eSteam§8War"; + } + }); + } + + +}