geforkt von SteamWar/BungeeCore
Merge branch 'master' into moreML
# Conflicts: # src/de/steamwar/bungeecore/BungeeCore.java # src/de/steamwar/bungeecore/commands/UnbanCommand.java # src/de/steamwar/messages/BungeeCore.properties
Dieser Commit ist enthalten in:
Commit
611074fa0b
@ -71,7 +71,7 @@ public class ErrorLogger extends Handler implements Filter {
|
||||
|
||||
@Override
|
||||
public void publish(LogRecord record) {
|
||||
if(record.getLevel() != Level.SEVERE)
|
||||
if(record.getLevel() != Level.SEVERE && record.getLevel() != Level.WARNING)
|
||||
return;
|
||||
|
||||
StringBuilder stacktrace = new StringBuilder(record.getSourceClassName() + "\n" + record.getSourceMethodName());
|
||||
|
@ -33,7 +33,6 @@ import java.util.Locale;
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
public class Message {
|
||||
private Message(){}
|
||||
|
||||
public static TextComponent parseToComponent(String message, boolean prefixed, CommandSender sender, Object... params){
|
||||
return new TextComponent(TextComponent.fromLegacyText(parse(message, prefixed, sender, params)));
|
||||
@ -60,7 +59,14 @@ public class Message {
|
||||
pattern = resourceBundle.getObject("PREFIX") + " ";
|
||||
pattern += (String)resourceBundle.getObject(message);
|
||||
|
||||
return new MessageFormat(pattern, locale).format(params);
|
||||
MessageFormat format = new MessageFormat(pattern, locale);
|
||||
for (int i = 0; i < params.length; i++) {
|
||||
if(params[i] instanceof Message) {
|
||||
Message msg = (Message) params[i];
|
||||
params[i] = parse(msg.getMessage(), sender, msg.getParams());
|
||||
}
|
||||
}
|
||||
return format.format(params);
|
||||
}
|
||||
|
||||
public static void send(String message, CommandSender sender, Object... params){
|
||||
@ -125,8 +131,25 @@ public class Message {
|
||||
|
||||
public static void team(String message, ChatMessageType type, Object... params){
|
||||
for(ProxiedPlayer player : ProxyServer.getInstance().getPlayers()){
|
||||
if(player.getGroups().contains(ConnectionListener.TEAM_GROUP))
|
||||
if(player.getGroups().contains(ConnectionListener.TEAM_GROUP)) {
|
||||
sendPrefixless(message, player, type, params);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private final String message;
|
||||
private final Object[] params;
|
||||
|
||||
public Message(String message, Object... params) {
|
||||
this.message = message;
|
||||
this.params = params;
|
||||
}
|
||||
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
public Object[] getParams() {
|
||||
return params;
|
||||
}
|
||||
}
|
@ -54,9 +54,10 @@ public class BanCommand extends BasicCommand {
|
||||
for (int i = 2; i < args.length; i++){
|
||||
banReason.append(args[i]).append(" ");
|
||||
}
|
||||
boolean isPerma = args[1].equalsIgnoreCase("perma");
|
||||
String msg = banReason.toString();
|
||||
Message.send("BAN_MESSAGE_YOU", sender, target.getUserName(), msg);
|
||||
target.ban(banTime, msg);
|
||||
target.ban(banTime, msg, SteamwarUser.get(sender.getName()).getId(), isPerma);
|
||||
Message.team("BAN_TEAM_BANNED", new Message("PREFIX"), target.getUserName(), sender.getName(), new Message((isPerma?"BAN_PERMA":"BAN_UNTIL"), banTime), msg);
|
||||
}
|
||||
|
||||
public static Timestamp parseTime(CommandSender sender, String arg){
|
||||
|
@ -49,7 +49,7 @@ public class MsgCommand extends BasicCommand {
|
||||
|
||||
SteamwarUser user = SteamwarUser.get(player);
|
||||
if(user.isMuted()){
|
||||
sender.sendMessage(user.muteMessage());
|
||||
sender.sendMessage(user.muteMessage(player));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -51,7 +51,7 @@ public class MuteCommand extends BasicCommand {
|
||||
muteReason.append(args[i]).append(" ");
|
||||
}
|
||||
String msg = muteReason.toString();
|
||||
Message.send("MUTE_MESSAGE_YOU", sender, target.getUserName(), msg);
|
||||
target.mute(muteTime, msg);
|
||||
target.mute(muteTime, msg, SteamwarUser.get(sender.getName()).getId(), args[1].equalsIgnoreCase("perma"));
|
||||
Message.team("MUTE_TEAM_MUTED", new Message("PREFIX"), target.getUserName(), sender.getName(), new Message((args[1].equalsIgnoreCase("perma")?"BAN_PERMA":"BAN_UNTIL"), muteTime), msg);
|
||||
}
|
||||
}
|
||||
|
@ -45,7 +45,7 @@ public class RCommand extends BasicCommand {
|
||||
|
||||
SteamwarUser user = SteamwarUser.get(player);
|
||||
if(user.isMuted()){
|
||||
sender.sendMessage(user.muteMessage());
|
||||
sender.sendMessage(user.muteMessage(player));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -19,6 +19,7 @@
|
||||
|
||||
package de.steamwar.bungeecore.commands;
|
||||
|
||||
import de.steamwar.bungeecore.BungeeCore;
|
||||
import de.steamwar.bungeecore.Message;
|
||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||
import net.md_5.bungee.api.CommandSender;
|
||||
@ -43,6 +44,11 @@ public class UnbanCommand extends BasicCommand {
|
||||
if(target == null)
|
||||
return;
|
||||
|
||||
if(!target.isBanned()) {
|
||||
BungeeCore.send(sender, BungeeCore.CHAT_PREFIX + "Der Spieler ist nicht gebannt.");
|
||||
return;
|
||||
}
|
||||
|
||||
Message.send("UNBAN_UNBANNED", sender, target.getUserName());
|
||||
target.ban(Timestamp.from(new Date().toInstant()), "");
|
||||
}
|
||||
|
@ -19,14 +19,17 @@
|
||||
|
||||
package de.steamwar.bungeecore.commands;
|
||||
|
||||
import de.steamwar.bungeecore.BungeeCore;
|
||||
import de.steamwar.bungeecore.Message;
|
||||
import de.steamwar.bungeecore.sql.Punishment;
|
||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||
import de.steamwar.bungeecore.sql.Team;
|
||||
import net.md_5.bungee.api.CommandSender;
|
||||
import net.md_5.bungee.api.chat.ClickEvent;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.List;
|
||||
|
||||
public class WhoisCommand extends BasicCommand {
|
||||
public WhoisCommand(){
|
||||
@ -40,7 +43,7 @@ public class WhoisCommand extends BasicCommand {
|
||||
ProxiedPlayer player = (ProxiedPlayer) sender;
|
||||
|
||||
if(args.length == 0){
|
||||
BungeeCore.send(player, BungeeCore.CHAT_PREFIX + "§c/whois [Spieler/ID]");
|
||||
Message.send("WHOIS_USAGE", player);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -53,7 +56,7 @@ public class WhoisCommand extends BasicCommand {
|
||||
}
|
||||
|
||||
if(user == null) {
|
||||
BungeeCore.send(player, BungeeCore.CHAT_PREFIX + "§cUnbekannter Spieler!");
|
||||
Message.send("UNKNOWN_PLAYER", player);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -61,20 +64,27 @@ public class WhoisCommand extends BasicCommand {
|
||||
}
|
||||
|
||||
private static void sendUserinfo(ProxiedPlayer player, SteamwarUser user) {
|
||||
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, "§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");
|
||||
Message.send("WHOIS_USERNAME", player, user.getUserName());
|
||||
Message.send("WHOIS_UUID", player, Message.parse("WHOIS_UUID_HOVER", player), new ClickEvent(ClickEvent.Action.COPY_TO_CLIPBOARD, user.getUuid().toString()), user.getUuid().toString());
|
||||
Message.send("WHOIS_ID", player, user.getId());
|
||||
Timestamp firstJoin = user.getFirstjoin();
|
||||
if(firstJoin == null)
|
||||
Message.send("WHOIS_JOINED_FIRST", player, "0000-00-00 00:00:00");
|
||||
else
|
||||
Message.send("WHOIS_JOINED_FIRST", player, firstJoin.toString());
|
||||
Message.send("WHOIS_HOURS_PLAYED", player, new DecimalFormat("###.##").format(user.getOnlinetime() / (double) 3600));
|
||||
|
||||
Team team = Team.get(user.getTeam());
|
||||
BungeeCore.send(player, "§7Team§8: §e" + team.getTeamName());
|
||||
Message.send("WHOIS_TEAM", player, Message.parse("WHOIS_TEAM_HOVER", player, team.getTeamName()), new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/team info " + team.getTeamKuerzel()), team.getTeamColor(), team.getTeamKuerzel(), team.getTeamName());
|
||||
|
||||
if(user.isBanned()){
|
||||
player.sendMessage(user.banMessage());
|
||||
Message.send("WHOIS_PUNISHMENTS", player);
|
||||
List<Punishment> punishmentList = Punishment.getAllPunishmentsOfPlayer(user.getId());
|
||||
if(punishmentList.isEmpty()) {
|
||||
Message.send("WHOIS_NO_PUNISHMENT", player);
|
||||
return;
|
||||
}
|
||||
if(user.isMuted()){
|
||||
player.sendMessage(user.muteMessage());
|
||||
for (Punishment punishment : punishmentList) {
|
||||
Message.sendPrefixless("WHOIS_PUNISHMENT", player, SteamwarUser.get(punishment.getPunisher()).getUserName(), punishment.getType().name(), punishment.getBantime(punishment.getStartTime(), false), punishment.getBantime(punishment.getEndTime(), punishment.isPerma()), punishment.getReason());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -19,7 +19,6 @@
|
||||
|
||||
package de.steamwar.bungeecore.listeners;
|
||||
|
||||
import de.steamwar.bungeecore.BungeeCore;
|
||||
import de.steamwar.bungeecore.Message;
|
||||
import de.steamwar.bungeecore.sql.BannedUserIPs;
|
||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||
@ -44,7 +43,7 @@ public class BanListener extends BasicListener {
|
||||
if(user.isBanned()) {
|
||||
user.updateBanIP(event.getConnection().getAddress().getAddress().getHostAddress());
|
||||
event.setCancelled(true);
|
||||
event.setCancelReason(user.banMessage());
|
||||
event.setCancelReason(user.banMessage(ProxyServer.getInstance().getPlayer(event.getConnection().getUniqueId())));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -70,7 +69,7 @@ public class BanListener extends BasicListener {
|
||||
for(BannedUserIPs banned : ips) {
|
||||
SteamwarUser bannedUser = SteamwarUser.get(banned.getUserID());
|
||||
potentialBan.append(Message.parse("BAN_AVOIDING_LIST", target, bannedUser.getUserName(),
|
||||
banned.getTimestamp().toLocalDateTime().format(BungeeCore.DATE_FORMAT)));
|
||||
banned.getTimestamp().toLocalDateTime().format(DateTimeFormatter.ofPattern(Message.parse("TIMEFORMAT", target)))));
|
||||
}
|
||||
|
||||
TextComponent msg = new TextComponent(potentialBan.toString());
|
||||
|
@ -133,7 +133,7 @@ public class ChatListener extends BasicListener {
|
||||
|
||||
SteamwarUser user = SteamwarUser.get(sender);
|
||||
if(user.isMuted()){
|
||||
sender.sendMessage(user.muteMessage());
|
||||
sender.sendMessage(user.muteMessage(sender));
|
||||
e.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
@ -197,7 +197,7 @@ public class ChatListener extends BasicListener {
|
||||
|
||||
SteamwarUser user = SteamwarUser.get(sender);
|
||||
if(user.isMuted()){
|
||||
sender.sendMessage(user.muteMessage());
|
||||
sender.sendMessage(user.muteMessage(sender));
|
||||
e.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
@ -20,6 +20,7 @@
|
||||
package de.steamwar.bungeecore.listeners.mods;
|
||||
|
||||
import de.steamwar.bungeecore.BungeeCore;
|
||||
import de.steamwar.bungeecore.Message;
|
||||
import de.steamwar.bungeecore.sql.Mod;
|
||||
import de.steamwar.bungeecore.sql.Mod.ModType;
|
||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||
@ -72,9 +73,9 @@ class Utils {
|
||||
|
||||
if(mods.size() == 1){
|
||||
if(max == ModType.YELLOW)
|
||||
player.disconnect(BungeeCore.stringToText("§7Deaktiviere den Mod §e" + mods.get(0).getModName() + "§7, um weiter auf §eSteam§8War §7spielen zu können."));
|
||||
player.disconnect(BungeeCore.stringToText(Message.parse("MOD_YELLOW_SING", player, mods.get(0).getModName())));
|
||||
else{
|
||||
user.ban(Timestamp.from(Instant.now().plus(7, ChronoUnit.DAYS)), "Versuchte Benutzung des Mods " + mods.get(0).getModName());
|
||||
user.ban(Timestamp.from(Instant.now().plus(7, ChronoUnit.DAYS)), Message.parse("MOD_RED_SING", player, mods.get(0).getModName()), 0, false);
|
||||
BungeeCore.log(Level.SEVERE, user.getUserName() + " " + user.getId() + " wurde automatisch wegen des Mods " + mods.get(0).getModName() + " gebannt.");
|
||||
}
|
||||
}else{
|
||||
@ -82,9 +83,9 @@ class Utils {
|
||||
mods.forEach(mod -> sb.append(mod.getModName()).append('\n'));
|
||||
|
||||
if(max == ModType.YELLOW)
|
||||
player.disconnect(BungeeCore.stringToText("§7Deaktiviere die Mods\n§e" + sb.toString() + "§7um weiter auf §eSteam§8War §7spielen zu können."));
|
||||
player.disconnect(BungeeCore.stringToText(Message.parse("MOD_YELLOW_PLUR", player, sb.toString())));
|
||||
else{
|
||||
user.ban(Timestamp.from(Instant.now().plus(7, ChronoUnit.DAYS)), "Versuchte Benutzung der Mods\n" + sb.toString());
|
||||
user.ban(Timestamp.from(Instant.now().plus(7, ChronoUnit.DAYS)), Message.parse("MOD_RED_PLUR", player, sb.toString()), 0, false);
|
||||
BungeeCore.log(Level.SEVERE, user.getUserName() + " " + user.getId() + " wurde automatisch wegen der Mods " + sb.toString() + " gebannt.");
|
||||
}
|
||||
}
|
||||
|
155
src/de/steamwar/bungeecore/sql/Punishment.java
Normale Datei
155
src/de/steamwar/bungeecore/sql/Punishment.java
Normale Datei
@ -0,0 +1,155 @@
|
||||
/*
|
||||
This file is a part of the SteamWar software.
|
||||
|
||||
Copyright (C) 2020 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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bungeecore.sql;
|
||||
|
||||
import de.steamwar.bungeecore.BungeeCore;
|
||||
import de.steamwar.bungeecore.Message;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Timestamp;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.*;
|
||||
|
||||
public class Punishment {
|
||||
|
||||
public static Punishment getPunishmentOfPlayer(int user, PunishmentType type) {
|
||||
ResultSet set = SQL.select("SELECT * FROM Punishments WHERE UserId = ? AND Type = ? ORDER BY PunishmentId DESC LIMIT 1", user, type.name());
|
||||
try {
|
||||
if(!set.next())
|
||||
return null;
|
||||
return new Punishment(set);
|
||||
} catch (SQLException e) {
|
||||
throw new SecurityException("Could not Load Punishments", e);
|
||||
}
|
||||
}
|
||||
|
||||
public static Map<PunishmentType, Punishment> getPunishmentsOfPlayer(int user) {
|
||||
ResultSet set = SQL.select("SELECT * FROM Punishments WHERE PunishmentId IN (SELECT MAX(PunishmentId) WHERE UserId = ? GROUP BY Type)", user);
|
||||
try {
|
||||
Map<PunishmentType, Punishment> punishments = new HashMap<>();
|
||||
while (set.next())
|
||||
punishments.put(PunishmentType.valueOf(set.getString("Type")), new Punishment(set));
|
||||
return punishments;
|
||||
} catch (SQLException e) {
|
||||
throw new SecurityException("Could not Load Punishments", e);
|
||||
}
|
||||
}
|
||||
|
||||
public static List<Punishment> getAllPunishmentsOfPlayer(int user) {
|
||||
ResultSet set = SQL.select("SELECT * FROM Punishments WHERE UserId = ? ORDER BY `PunishmentId` DESC", user);
|
||||
try {
|
||||
List<Punishment> punishments = new ArrayList<>();
|
||||
while (set.next()) {
|
||||
punishments.add(new Punishment(set));
|
||||
}
|
||||
return punishments;
|
||||
} catch (SQLException e) {
|
||||
throw new SecurityException("Could not Load all Punishments", e);
|
||||
}
|
||||
}
|
||||
|
||||
public static Punishment createPunishment(int user, int executor, PunishmentType type, String reason, Timestamp endTime, boolean perma) {
|
||||
SQL.update("INSERT INTO Punishments (UserId, Punisher, Type, Reason, EndTime, Perma) VALUES (?, ?, ?, ?, ?, ?)",
|
||||
user, executor, type.name(), reason, endTime, perma);
|
||||
return getPunishmentOfPlayer(user, type);
|
||||
}
|
||||
|
||||
private final Timestamp startTime;
|
||||
private Timestamp endTime;
|
||||
private final PunishmentType type;
|
||||
private final int user;
|
||||
private final int id;
|
||||
private String reason;
|
||||
private final int punisher;
|
||||
private boolean perma;
|
||||
|
||||
private Punishment(ResultSet set) throws SQLException {
|
||||
user = set.getInt("UserId");
|
||||
reason = set.getString("Reason");
|
||||
type = PunishmentType.valueOf(set.getString("Type"));
|
||||
startTime = set.getTimestamp("StartTime");
|
||||
endTime = set.getTimestamp("EndTime");
|
||||
punisher = set.getInt("Punisher");
|
||||
perma = set.getBoolean("Perma");
|
||||
id = set.getInt("PunishmentId");
|
||||
}
|
||||
|
||||
public Timestamp getStartTime() {
|
||||
return startTime;
|
||||
}
|
||||
|
||||
public Timestamp getEndTime() {
|
||||
return endTime;
|
||||
}
|
||||
|
||||
public PunishmentType getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public int getUser() {
|
||||
return user;
|
||||
}
|
||||
|
||||
public String getReason() {
|
||||
return reason;
|
||||
}
|
||||
|
||||
public int getPunisher() {
|
||||
return punisher;
|
||||
}
|
||||
|
||||
public boolean isPerma() {
|
||||
return perma;
|
||||
}
|
||||
|
||||
public void updateEndTime(int from, String newreason, Timestamp newUpdate, boolean perma) {
|
||||
if(newreason.equals(reason) && newUpdate.equals(endTime) && perma == perma)
|
||||
return;
|
||||
ProxiedPlayer player = BungeeCore.get().getProxy().getPlayer(SteamwarUser.get(from).getUuid());
|
||||
String newReason = Message.parse("BAN_CHANGED", player, reason,
|
||||
SteamwarUser.get(from).getUserName(),
|
||||
getBantime(endTime, this.perma),
|
||||
getBantime(newUpdate, perma),
|
||||
newreason);
|
||||
|
||||
SQL.update("UPDATE Punishments SET EndTime = ?, Reason = ?, Perma = ? WHERE PunishmentId = ?", newUpdate, newReason, perma, id);
|
||||
this.reason = newReason;
|
||||
this.perma = perma;
|
||||
this.endTime = newUpdate;
|
||||
}
|
||||
|
||||
public String getBantime(Timestamp endTime, boolean perma) {
|
||||
if(perma)
|
||||
return "permanent";
|
||||
else
|
||||
return endTime.toLocalDateTime().format(DateTimeFormatter.ofPattern("dd.MM.yyyy HH:mm"));
|
||||
}
|
||||
|
||||
public boolean isCurrent() {
|
||||
return isPerma() || getEndTime().after(new Date());
|
||||
}
|
||||
|
||||
public enum PunishmentType {
|
||||
Ban,
|
||||
Mute;
|
||||
}
|
||||
}
|
@ -20,6 +20,7 @@
|
||||
package de.steamwar.bungeecore.sql;
|
||||
|
||||
import de.steamwar.bungeecore.BungeeCore;
|
||||
import de.steamwar.bungeecore.Message;
|
||||
import de.steamwar.bungeecore.commands.WebregisterCommand;
|
||||
import de.steamwar.bungeecore.listeners.ConnectionListener;
|
||||
import net.md_5.bungee.api.ProxyServer;
|
||||
@ -32,8 +33,7 @@ import java.net.UnknownHostException;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Timestamp;
|
||||
import java.time.Instant;
|
||||
import java.util.Date;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
@ -43,16 +43,12 @@ public class SteamwarUser {
|
||||
private final UUID uuid;
|
||||
private String userName;
|
||||
private UserGroup userGroup;
|
||||
private Timestamp banTime;
|
||||
private String banReason;
|
||||
private int team;
|
||||
private Timestamp muteTime;
|
||||
private String muteReason;
|
||||
private Map<Punishment.PunishmentType, Punishment> punishments;
|
||||
|
||||
private static final Map<String, SteamwarUser> usersByName = new HashMap<>();
|
||||
private static final Map<UUID, SteamwarUser> usersByUUID = new HashMap<>();
|
||||
private static final Map<Integer, SteamwarUser> usersById = new HashMap<>();
|
||||
private static final Timestamp PERMA_BAN = Timestamp.from(Instant.ofEpochSecond(946684800));
|
||||
private static final InetAddress LIXFEL_DE;
|
||||
|
||||
static {
|
||||
@ -69,14 +65,11 @@ public class SteamwarUser {
|
||||
uuid = UUID.fromString(rs.getString("UUID"));
|
||||
userName = rs.getString("UserName");
|
||||
userGroup = UserGroup.getUsergroup(rs.getString("UserGroup"));
|
||||
banTime = rs.getTimestamp("BanTime");
|
||||
banReason = rs.getString("BanReason");
|
||||
team = rs.getInt("Team");
|
||||
muteTime = rs.getTimestamp("MuteTime");
|
||||
muteReason = rs.getString("MuteReason");
|
||||
usersById.put(id, this);
|
||||
usersByName.put(userName.toLowerCase(), this);
|
||||
usersByUUID.put(uuid, this);
|
||||
punishments = Punishment.getPunishmentsOfPlayer(id);
|
||||
}
|
||||
|
||||
public static SteamwarUser getOrCreate(PendingConnection connection){
|
||||
@ -157,47 +150,42 @@ public class SteamwarUser {
|
||||
}
|
||||
|
||||
public boolean isBanned() {
|
||||
if (banTime == null) {
|
||||
if(!punishments.containsKey(Punishment.PunishmentType.Ban))
|
||||
return false;
|
||||
} else if (banTime.after(new Date()) || banTime.before(PERMA_BAN)) {
|
||||
return true;
|
||||
} else {
|
||||
SQL.update("UPDATE UserData SET BanTime = NULL, BanReason = '' WHERE id = ?", id);
|
||||
if(!punishments.get(Punishment.PunishmentType.Ban).isCurrent()) {
|
||||
SQL.update("DELETE FROM BannedUserIPs WHERE UserID = ?", id);
|
||||
banTime = null;
|
||||
banReason = "";
|
||||
punishments.remove(Punishment.PunishmentType.Ban);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean isMuted(){
|
||||
if(muteTime == null){
|
||||
if(!punishments.containsKey(Punishment.PunishmentType.Mute))
|
||||
return false;
|
||||
}else if(muteTime.after(new Date()) || muteTime.before(PERMA_BAN)){
|
||||
if(!punishments.get(Punishment.PunishmentType.Mute).isCurrent()) {
|
||||
punishments.remove(Punishment.PunishmentType.Mute);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public TextComponent banMessage(ProxiedPlayer player){
|
||||
Punishment punishment = punishments.get(Punishment.PunishmentType.Ban);
|
||||
if (punishment.isPerma()) {
|
||||
return BungeeCore.stringToText(Message.parsePrefixed("BANNED_MESSAGE_PERMA", player, punishment.getReason()));
|
||||
} else {
|
||||
SQL.update("UPDATE UserData SET MuteTime = NULL, MuteReason = '' WHERE id = ?", id);
|
||||
muteTime = null;
|
||||
muteReason = "";
|
||||
return false;
|
||||
return BungeeCore.stringToText(Message.parsePrefixed("BANNED_MESSAGE_UNTIL", player, punishment.getEndTime().toLocalDateTime().format(DateTimeFormatter.ofPattern(Message.parse("TIMEFORMAT", player))),
|
||||
punishment.getReason()));
|
||||
}
|
||||
}
|
||||
|
||||
public TextComponent banMessage(){
|
||||
if (banTime.before(PERMA_BAN)) {
|
||||
return BungeeCore.stringToText(BungeeCore.CHAT_PREFIX + "§cDu bist permanent gebannt. §r§lGrund§r: §c" + banReason);
|
||||
public TextComponent muteMessage(ProxiedPlayer player){
|
||||
Punishment punishment = punishments.get(Punishment.PunishmentType.Mute);
|
||||
if (punishment.isPerma()) {
|
||||
return BungeeCore.stringToText(Message.parsePrefixed("MUTED_MESSAGE_PERMA", player, punishment.getReason()));
|
||||
} else {
|
||||
return BungeeCore.stringToText(BungeeCore.CHAT_PREFIX + " Du bist bis zum " +
|
||||
banTime.toLocalDateTime().format(BungeeCore.DATE_FORMAT) + " gebannt. §r§lGrund§r: §c" + banReason);
|
||||
}
|
||||
}
|
||||
|
||||
public TextComponent muteMessage(){
|
||||
if (muteTime.before(PERMA_BAN)) {
|
||||
return BungeeCore.stringToText(BungeeCore.CHAT_PREFIX + "§cDu bist permanent gemuted. §r§lGrund§r: §c" + muteReason);
|
||||
} else {
|
||||
return BungeeCore.stringToText(BungeeCore.CHAT_PREFIX + " Du bist bis zum " +
|
||||
muteTime.toLocalDateTime().format(BungeeCore.DATE_FORMAT) + " gemuted. §r§lGrund§r: §c" + muteReason);
|
||||
return BungeeCore.stringToText(Message.parsePrefixed("MUTED_MESSAGE_UNTIL", player, punishment.getEndTime().toLocalDateTime().format(DateTimeFormatter.ofPattern(Message.parse("TIMEFORMAT", player))), punishment.getReason()));
|
||||
}
|
||||
}
|
||||
|
||||
@ -205,29 +193,35 @@ public class SteamwarUser {
|
||||
BannedUserIPs.banIP(this, ip);
|
||||
}
|
||||
|
||||
public void ban(Timestamp time, String banReason){
|
||||
SQL.update("UPDATE UserData SET BanTime = ?, BanReason = ? WHERE id = ?", time, banReason, id);
|
||||
banTime = time;
|
||||
this.banReason = banReason;
|
||||
public void ban(Timestamp time, String banReason, int from, boolean perma){
|
||||
if(isBanned()) {
|
||||
punishments.get(Punishment.PunishmentType.Ban).updateEndTime(from, banReason, time, perma);
|
||||
return;
|
||||
}
|
||||
punishments.remove(Punishment.PunishmentType.Ban);
|
||||
punishments.put(Punishment.PunishmentType.Ban, Punishment.createPunishment(id, from, Punishment.PunishmentType.Ban, banReason, time, perma));
|
||||
|
||||
ProxiedPlayer player = ProxyServer.getInstance().getPlayer(uuid);
|
||||
if(player != null){
|
||||
updateBanIP(player.getAddress().getAddress().getHostAddress());
|
||||
player.disconnect(banMessage());
|
||||
player.disconnect(banMessage(player));
|
||||
for (BannedUserIPs banned:
|
||||
BannedUserIPs.get(player.getAddress().getAddress().getHostAddress())) {
|
||||
SteamwarUser bannedUser = SteamwarUser.get(banned.getUserID());
|
||||
if(bannedUser.isBanned() && banned.getTimestamp().before(time))
|
||||
bannedUser.ban(time, bannedUser.banReason);
|
||||
bannedUser.ban(time, banReason, from, perma);
|
||||
}
|
||||
}else
|
||||
updateBanIP("");
|
||||
}
|
||||
|
||||
public void mute(Timestamp time, String muteReason){
|
||||
SQL.update("UPDATE UserData SET MuteTime = ?, MuteReason = ? WHERE id = ?", time, muteReason, id);
|
||||
muteTime = time;
|
||||
this.muteReason = muteReason;
|
||||
public void mute(Timestamp time, String muteReason, int from, boolean perma){
|
||||
if(isMuted()) {
|
||||
punishments.get(Punishment.PunishmentType.Mute).updateEndTime(from, muteReason, time, perma);
|
||||
return;
|
||||
}
|
||||
punishments.remove(Punishment.PunishmentType.Mute);
|
||||
punishments.put(Punishment.PunishmentType.Mute, Punishment.createPunishment(id, from, Punishment.PunishmentType.Mute, muteReason, time, perma));
|
||||
}
|
||||
|
||||
private static SteamwarUser dbInit(ResultSet rs){
|
||||
@ -243,18 +237,21 @@ public class SteamwarUser {
|
||||
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();
|
||||
if(!set.next())
|
||||
return 0;
|
||||
return set.getBigDecimal("Playtime").doubleValue();
|
||||
} catch (SQLException throwables) {
|
||||
throwables.printStackTrace();
|
||||
}
|
||||
throw new SecurityException("Could not load Online Time", throwables);
|
||||
} catch (NullPointerException e) { //When no Sessions are recorded
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public Timestamp getFirstjoin() {
|
||||
ResultSet set = SQL.select("SELECT MIN(StartTime) AS FirstJoin FROM Session WHERE UserID = ?", id);
|
||||
try {
|
||||
set.next();
|
||||
if(!set.next())
|
||||
return null;
|
||||
return set.getTimestamp("FirstJoin");
|
||||
} catch (SQLException throwables) {
|
||||
throw new SecurityException("Could not load First Join");
|
||||
|
@ -3,10 +3,7 @@ SPACER=
|
||||
|
||||
UNKNOWN_COMMAND=§cUnbekannter Befehl.
|
||||
UNKNOWN_PLAYER=§cDiesen Spieler gibt es nicht.
|
||||
UNKNOWN_TEAM=§cDieses Team gibt es nicht.
|
||||
INVALID_TIME=§cUngültige Zeitangabe.
|
||||
JOIN_PLAYER_BLOCK=§cDu kannst diesem Spieler derzeit nicht folgen.
|
||||
CHECK_CHECKING=§cDu prüfst gerade eine Schematic!
|
||||
|
||||
#ModLoader blocker
|
||||
MODLOADER_INSTALLED=§7Du hast §e{0} §7installiert. Daher kannst du keinen Arenen beitreten.
|
||||
@ -97,16 +94,29 @@ USAGE_BAN=§8/§7ban §8[§eSpieler§8] [§edd§8.§emm§8.§eyyyy §7oder §edd
|
||||
USAGE_MUTE=§8/§7mute §8[§eSpieler§8] [§edd§8.§emm§8.§eyyyy §7oder §edd§8.§emm§8.§eyyyy§8_§ehh§8:§emm §7oder §eperma§8] [§eGrund§8]
|
||||
USAGE_IGNORE=§8/§7ignore §8[§eSpieler§8]
|
||||
|
||||
#ModListener
|
||||
MOD_RED_SING=Versuchte Benutzung des Mods {0}
|
||||
MOD_RED_PLUR=Versuchte Benutzung der Mods:\n{0}
|
||||
MOD_YELLOW_SING=§7Deaktiviere den Mod §e{0}§7, um weiter auf §eSteam§8War §7spielen zu können.
|
||||
MOD_YELLOW_PLUR=§7Deaktiviere die Mods\n§e{0}\n§7um weiter auf §eSteam§8War §7spielen zu können.
|
||||
|
||||
#Various commands
|
||||
ALERT=§f{0}
|
||||
|
||||
BAN_MESSAGE_YOU=§7Du hast §e{0} §7gebannt§8. §7Grund§8: §c{1}
|
||||
#Ban&Mute-Command
|
||||
BAN_TEAM_BANNED={0} §c{1} wurde von {2} {3} gebannt. §f§lGrund: §f{4}
|
||||
BANNED_MESSAGE_PERMA=§cDu bist permanent gebannt. §r§lGrund§r: §c{0}
|
||||
BANNED_MESSAGE_UNTIL=§cDu bist bis zum {0} gebannt. §r§lGrund§r: §c{1}
|
||||
MUTE_TEAM_MUTED={0} §c{1} wurde von {2} {3} gemuted. §f§lGrund: §f{4}
|
||||
MUTED_MESSAGE_PERMA=§cDu bist permanent gemuted. §r§lGrund§r: §c{0}
|
||||
MUTED_MESSAGE_UNTIL=§cDu bist bis zum {0} gemuted. §r§lGrund§r: §c{1}
|
||||
BAN_CHANGED={0}verändert von {1} von {2} auf {3} wegen {4}
|
||||
BAN_PERMA=permanent
|
||||
BAN_UNTIL=bis zum {0}
|
||||
BAN_AVOIDING_ALERT=§cMögliche Bannumgehung durch §r{0}§c: §c
|
||||
BAN_AVOIDING_LIST={0} §e{1} §c
|
||||
BAN_AVOIDING_BAN_HOVER=§cBanne Spieler wegen Bannumgehung
|
||||
|
||||
MUTE_MESSAGE_YOU=§7Du hast §e{0} §7gemutet§8. §7Grund§8: §c{1}
|
||||
|
||||
BUG_MESSAGE=§7Dein Bugreport wurde gespeichert.
|
||||
|
||||
IGNORE_YOURSELF=§cWie willst du dich selber ignorieren?
|
||||
@ -468,3 +478,18 @@ SERVER_ADD_MEMBER=§e{0} §7möchte auf deine Bauwelt.
|
||||
SERVER_ADD_MESSAGE=§7Klicke §ehier§7, wenn du das erlauben möchtest.
|
||||
SERVER_ADD_MESSAGE_HOVER=§8/§7bau addmember §e{0}
|
||||
SERVER_WORLD_ERROR=§cDas Erstellen der Welt ist fehlgeschlagen.
|
||||
|
||||
|
||||
#WhoisCommand
|
||||
WHOIS_USAGE=§c/whois [Spieler/ID]
|
||||
WHOIS_USERNAME=§7Username§8: §e{0}
|
||||
WHOIS_UUID=§7UUID§8: §e{0}
|
||||
WHOIS_UUID_HOVER=§eUUID Kopieren
|
||||
WHOIS_ID=§7ID§8: §e{0}
|
||||
WHOIS_JOINED_FIRST=§7Beigetreten am§8: §e{0}
|
||||
WHOIS_HOURS_PLAYED=§7Online Time§8: §e{0}h
|
||||
WHOIS_TEAM=§7Team§8: §e[§{0}{1}§e] {2}
|
||||
WHOIS_TEAM_HOVER=§e{0} anzeigen
|
||||
WHOIS_PUNISHMENTS=§7Strafen:
|
||||
WHOIS_PUNISHMENT=§7{0}§8» §f§l{1}: §e{2} - {3} §f{4}
|
||||
WHOIS_NO_PUNISHMENT=§a✓ §7Der Spieler hat noch nichts getan.
|
In neuem Issue referenzieren
Einen Benutzer sperren