Merge branch 'scoreboard' of SteamWar/BauSystem into master
Dieser Commit ist enthalten in:
Commit
2a212e30f5
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,3 +1,4 @@
|
|||||||
.idea
|
.idea
|
||||||
target
|
target
|
||||||
dependency-reduced-pom.xml
|
dependency-reduced-pom.xml
|
||||||
|
*.iml
|
@ -2,9 +2,11 @@ package de.steamwar.bausystem;
|
|||||||
|
|
||||||
import de.steamwar.bausystem.commands.*;
|
import de.steamwar.bausystem.commands.*;
|
||||||
import de.steamwar.bausystem.world.ArenaSection;
|
import de.steamwar.bausystem.world.ArenaSection;
|
||||||
|
import de.steamwar.bausystem.world.BauScoreboard;
|
||||||
import de.steamwar.bausystem.world.RegionListener;
|
import de.steamwar.bausystem.world.RegionListener;
|
||||||
import de.steamwar.bausystem.world.TNTListener;
|
import de.steamwar.bausystem.world.TNTListener;
|
||||||
import de.steamwar.core.CommandRemover;
|
import de.steamwar.core.CommandRemover;
|
||||||
|
import de.steamwar.scoreboard.SWScoreboard;
|
||||||
import de.steamwar.sql.SteamwarUser;
|
import de.steamwar.sql.SteamwarUser;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.configuration.InvalidConfigurationException;
|
import org.bukkit.configuration.InvalidConfigurationException;
|
||||||
@ -84,6 +86,7 @@ public class BauSystem extends JavaPlugin implements Listener {
|
|||||||
Bukkit.getPluginManager().registerEvents(this, this);
|
Bukkit.getPluginManager().registerEvents(this, this);
|
||||||
Bukkit.getPluginManager().registerEvents(new RegionListener(), this);
|
Bukkit.getPluginManager().registerEvents(new RegionListener(), this);
|
||||||
Bukkit.getPluginManager().registerEvents(new TNTListener(), this);
|
Bukkit.getPluginManager().registerEvents(new TNTListener(), this);
|
||||||
|
Bukkit.getPluginManager().registerEvents(new BauScoreboard(), this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static BauSystem getPlugin(){
|
public static BauSystem getPlugin(){
|
||||||
@ -240,7 +243,8 @@ public class BauSystem extends JavaPlugin implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onLeave(PlayerQuitEvent e){
|
public void onLeave(PlayerQuitEvent e) {
|
||||||
|
SWScoreboard.removeScoreboard(e.getPlayer());
|
||||||
if(Bukkit.getOnlinePlayers().isEmpty() || (Bukkit.getOnlinePlayers().size() == 1 && Bukkit.getOnlinePlayers().contains(e.getPlayer())))
|
if(Bukkit.getOnlinePlayers().isEmpty() || (Bukkit.getOnlinePlayers().size() == 1 && Bukkit.getOnlinePlayers().contains(e.getPlayer())))
|
||||||
Bukkit.shutdown();
|
Bukkit.shutdown();
|
||||||
}
|
}
|
||||||
|
@ -31,19 +31,29 @@ public class CommandInfo implements CommandExecutor {
|
|||||||
}
|
}
|
||||||
sender.sendMessage(membermessage.toString());
|
sender.sendMessage(membermessage.toString());
|
||||||
|
|
||||||
|
StringBuilder tpsmessage = new StringBuilder().append(BauSystem.PREFIX).append("TPS:§e");
|
||||||
|
for(float tps : getTps()){
|
||||||
|
tpsmessage.append(" " + tps);
|
||||||
|
}
|
||||||
|
sender.sendMessage(tpsmessage.toString());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static float[] getTps() {
|
||||||
double[] tps;
|
double[] tps;
|
||||||
switch(Core.getVersion()){
|
|
||||||
|
switch (Core.getVersion()) {
|
||||||
case 15:
|
case 15:
|
||||||
tps = CommandInfo_15.getTps();
|
tps = CommandInfo_15.getTps();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
tps = CommandInfo_12.getTps();
|
tps = CommandInfo_12.getTps();
|
||||||
}
|
}
|
||||||
StringBuilder tpsmessage = new StringBuilder().append(BauSystem.PREFIX).append("TPS:§e");
|
|
||||||
for(double t : tps){
|
float[] roundedTps = new float[3];
|
||||||
tpsmessage.append(String.format(" %.1f", t));
|
for(int i = 0; i < tps.length; i++) {
|
||||||
|
roundedTps[i] = Math.round(tps[0]);
|
||||||
}
|
}
|
||||||
sender.sendMessage(tpsmessage.toString());
|
return roundedTps;
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
45
BauSystem_Main/src/de/steamwar/bausystem/world/BauScoreboard.java
Normale Datei
45
BauSystem_Main/src/de/steamwar/bausystem/world/BauScoreboard.java
Normale Datei
@ -0,0 +1,45 @@
|
|||||||
|
package de.steamwar.bausystem.world;
|
||||||
|
|
||||||
|
import de.steamwar.bausystem.commands.CommandFreeze;
|
||||||
|
import de.steamwar.bausystem.commands.CommandInfo;
|
||||||
|
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<String, Integer> getData() {
|
||||||
|
HashMap<String, Integer> data = new HashMap<>();
|
||||||
|
data.put("§1 ", 7);
|
||||||
|
data.put("§eUhrzeit§8: §7" + new SimpleDateFormat("HH:mm:ss").format(Calendar.getInstance().getTime()), 6);
|
||||||
|
data.put("§2 ", 5);
|
||||||
|
data.put("§eTNT§8: " + (!CommandTNT.getInstance().isOn() ? "§aan" : "§caus"), 4);
|
||||||
|
data.put("§eFreeze§8: " + (!CommandFreeze.getInstance().isOn() ? "§aan" : "§caus"), 3);
|
||||||
|
data.put("§3 ", 2);
|
||||||
|
data.put("§eTPS§8: §7" + CommandInfo.getTps()[0], 1);
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getTitle() {
|
||||||
|
return "§eSteam§8War";
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
In neuem Issue referenzieren
Einen Benutzer sperren