geforkt von SteamWar/BungeeCore
Merge pull request 'Add Whois show Playtime' (#126) from whois-playtime into master
Reviewed-by: Lixfel <lixfel@steamwar.de>
Dieser Commit ist enthalten in:
Commit
a7ce6e50db
@ -214,7 +214,7 @@ public class BungeeCore extends Plugin {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
config = ConfigurationProvider.getProvider(YamlConfiguration.class).load(configFile);
|
config = ConfigurationProvider.getProvider(YamlConfiguration.class).load(configFile);
|
||||||
}catch(IOException e){
|
}catch(Exception e){
|
||||||
log("Could not save/load config.yml", e);
|
log("Could not save/load config.yml", e);
|
||||||
ProxyServer.getInstance().stop();
|
ProxyServer.getInstance().stop();
|
||||||
return;
|
return;
|
||||||
|
@ -26,6 +26,8 @@ import net.md_5.bungee.api.CommandSender;
|
|||||||
import net.md_5.bungee.api.chat.ClickEvent;
|
import net.md_5.bungee.api.chat.ClickEvent;
|
||||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||||
|
|
||||||
|
import java.text.DecimalFormat;
|
||||||
|
|
||||||
public class WhoisCommand extends BasicCommand {
|
public class WhoisCommand extends BasicCommand {
|
||||||
public WhoisCommand(){
|
public WhoisCommand(){
|
||||||
super("whois", "bungeecore.teamchat");
|
super("whois", "bungeecore.teamchat");
|
||||||
@ -38,19 +40,32 @@ public class WhoisCommand extends BasicCommand {
|
|||||||
ProxiedPlayer player = (ProxiedPlayer) sender;
|
ProxiedPlayer player = (ProxiedPlayer) sender;
|
||||||
|
|
||||||
if(args.length == 0){
|
if(args.length == 0){
|
||||||
BungeeCore.send(player, BungeeCore.CHAT_PREFIX + "§c/whois [Spieler]");
|
BungeeCore.send(player, BungeeCore.CHAT_PREFIX + "§c/whois [Spieler/ID]");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
SteamwarUser user = SteamwarUser.get(args[0]);
|
SteamwarUser user = SteamwarUser.get(args[0]);
|
||||||
if(user == null){
|
if(user == null){
|
||||||
BungeeCore.send(player, BungeeCore.CHAT_PREFIX + "§cUnbekannter Spieler.");
|
try {
|
||||||
|
int id = Integer.parseInt(args[0]);
|
||||||
|
user = SteamwarUser.get(id);
|
||||||
|
}catch (NumberFormatException ignored) {}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(user == null) {
|
||||||
|
BungeeCore.send(player, BungeeCore.CHAT_PREFIX + "§cUnbekannter Spieler!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sendUserinfo(player, user);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void sendUserinfo(ProxiedPlayer player, SteamwarUser user) {
|
||||||
BungeeCore.send(player, "§7Username§8: §e" + user.getUserName());
|
BungeeCore.send(player, "§7Username§8: §e" + user.getUserName());
|
||||||
BungeeCore.send(player, "§7UUID§8: §e" + user.getUuid().toString(), "", new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, user.getUuid().toString()));
|
BungeeCore.send(player, "§7UUID§8: §e" + user.getUuid().toString(), "", new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, user.getUuid().toString()));
|
||||||
BungeeCore.send(player, "§7ID§8: §e" + user.getId());
|
BungeeCore.send(player, "§7ID§8: §e" + user.getId());
|
||||||
|
BungeeCore.send(player, "§7Beigetreten am§8: §e" + user.getFirstjoin().toString());
|
||||||
|
BungeeCore.send(player, "§7Online Time§8: §e" + new DecimalFormat("###.##").format(user.getOnlinetime() / (double) 3600) + "h");
|
||||||
|
|
||||||
Team team = Team.get(user.getTeam());
|
Team team = Team.get(user.getTeam());
|
||||||
BungeeCore.send(player, "§7Team§8: §e" + team.getTeamName());
|
BungeeCore.send(player, "§7Team§8: §e" + team.getTeamName());
|
||||||
|
@ -233,4 +233,25 @@ public class SteamwarUser {
|
|||||||
throw new SecurityException(e);
|
throw new SecurityException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public double getOnlinetime() {
|
||||||
|
ResultSet set = SQL.select("SELECT SUM(UNIX_TIMESTAMP(EndTime) - UNIX_TIMESTAMP(StartTime)) as Playtime FROM Session WHERE UserID = ?", id);
|
||||||
|
try {
|
||||||
|
set.next();
|
||||||
|
return set.getBigDecimal("Playtime").doubleValue();
|
||||||
|
} catch (SQLException throwables) {
|
||||||
|
throwables.printStackTrace();
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Timestamp getFirstjoin() {
|
||||||
|
ResultSet set = SQL.select("SELECT MIN(StartTime) AS FirstJoin FROM Session WHERE UserID = ?", id);
|
||||||
|
try {
|
||||||
|
set.next();
|
||||||
|
return set.getTimestamp("FirstJoin");
|
||||||
|
} catch (SQLException throwables) {
|
||||||
|
throw new SecurityException("Could not load First Join");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren