SteamWar/BungeeCore
Archiviert
13
2
Dieser Commit ist enthalten in:
Chaoscaot 2020-12-30 13:28:09 +01:00
Ursprung 5fb8a617a7
Commit fec517f5a1
11 geänderte Dateien mit 40 neuen und 33 gelöschten Zeilen

Datei anzeigen

@ -55,7 +55,6 @@ public class BungeeCore extends Plugin {
public static final String SERVER_TEAMCHAT_PREFIX = "§8STC §e";
public static final String TEAMCHAT_PREFIX = "§8TC §e";
public static final DateTimeFormatter DATE_FORMAT = DateTimeFormatter.ofPattern("dd.MM.yyyy HH:mm");
public static String CHAT_PREFIX;
public static String WORLD_FOLDER;

Datei anzeigen

@ -31,6 +31,7 @@ import net.md_5.bungee.api.connection.ProxiedPlayer;
import java.text.MessageFormat;
import java.util.Locale;
import java.util.ResourceBundle;
import java.util.function.Function;
public class Message {
private Message(){}
@ -119,14 +120,19 @@ public class Message {
}
}
public static void team(String message, Object... params){
public static void team(String message, Function<ProxiedPlayer, Object>... params){
team(message, ChatMessageType.SYSTEM, params);
}
public static void team(String message, ChatMessageType type, Object... params){
public static void team(String message, ChatMessageType type, Function<ProxiedPlayer, Object>... params){
for(ProxiedPlayer player : ProxyServer.getInstance().getPlayers()){
if(player.getGroups().contains(ConnectionListener.TEAM_GROUP))
sendPrefixless(message, player, type, params);
if(player.getGroups().contains(ConnectionListener.TEAM_GROUP)) {
Object[] objects = new Object[params.length];
for (int i = 0; i < params.length; i++) {
objects[i] = params[i].apply(player);
}
sendPrefixless(message, player, type, objects);
}
}
}
}

Datei anzeigen

@ -19,7 +19,6 @@
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;
@ -28,6 +27,7 @@ import java.sql.Timestamp;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.Instant;
import java.time.format.DateTimeFormatter;
import java.util.Date;
public class BanCommand extends BasicCommand {
@ -58,7 +58,7 @@ public class BanCommand extends BasicCommand {
String msg = banReason.toString();
target.ban(banTime, msg, SteamwarUser.get(sender.getName()).getId(), args[1].equalsIgnoreCase("perma"));
Message.team("BAN_TEAM_BANNED", target.getUserName(), sender.getName(),
(args[1].equalsIgnoreCase("perma")?Message.parse("BAN_PERMA", sender):Message.parse("BAN_UNTIL", sender) + banTime.toLocalDateTime().format(BungeeCore.DATE_FORMAT)), msg);
(args[1].equalsIgnoreCase("perma")?Message.parse("BAN_PERMA", sender):Message.parse("BAN_UNTIL", sender) + banTime.toLocalDateTime().format(DateTimeFormatter.ofPattern(Message.parse("TIMEFORMAT", sender)))), msg);
}
public static Timestamp parseTime(CommandSender sender, String arg){

Datei anzeigen

@ -48,7 +48,7 @@ public class MsgCommand extends BasicCommand {
SteamwarUser user = SteamwarUser.get(player);
if(user.isMuted()){
sender.sendMessage(user.muteMessage());
sender.sendMessage(user.muteMessage(player));
return;
}

Datei anzeigen

@ -19,12 +19,12 @@
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;
import java.sql.Timestamp;
import java.time.format.DateTimeFormatter;
public class MuteCommand extends BasicCommand {
@ -53,7 +53,7 @@ public class MuteCommand extends BasicCommand {
}
String msg = muteReason.toString();
target.mute(muteTime, msg, SteamwarUser.get(sender.getName()).getId(), args[1].equalsIgnoreCase("perma"));
Message.team("MUTE_TEAM_MUTED", target.getUserName(), sender.getName(),
(args[1].equalsIgnoreCase("perma")?Message.parse("BAN_PERMA", sender):Message.parse("BAN_UNTIL", sender) + muteTime.toLocalDateTime().format(BungeeCore.DATE_FORMAT)), msg);
Message.team("MUTE_TEAM_MUTED", player -> target.getUserName(), player -> sender.getName(),
player -> (args[1].equalsIgnoreCase("perma")?Message.parse("BAN_PERMA", player):Message.parse("BAN_UNTIL", player) + muteTime.toLocalDateTime().format(DateTimeFormatter.ofPattern(Message.parse("TIMEFORMAT", player)))), player -> msg);
}
}

Datei anzeigen

@ -44,7 +44,7 @@ public class RCommand extends BasicCommand {
SteamwarUser user = SteamwarUser.get(player);
if(user.isMuted()){
sender.sendMessage(user.muteMessage());
sender.sendMessage(user.muteMessage(player));
return;
}

Datei anzeigen

@ -44,7 +44,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((ProxiedPlayer) event.getConnection()));
return;
}

Datei anzeigen

@ -137,7 +137,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;
}
@ -200,7 +200,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;
}

Datei anzeigen

@ -21,10 +21,12 @@ 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 {
@ -119,22 +121,24 @@ public class Punishment {
}
public void updateEndTime(int from, String newreason, Timestamp newUpdate, boolean perma) {
String newReason = Message.parse("BAN_CHANGED", SteamwarUser.get(from).getPlayer(), SteamwarUser.get(from).getUserName(),
ProxiedPlayer player = BungeeCore.get().getProxy().getPlayer(SteamwarUser.get(from).getUuid());
String newReason = Message.parse("BAN_CHANGED", player, SteamwarUser.get(from).getUserName(),
getBantime(endTime, this.perma),
getBantime(newUpdate, perma),
newreason);
//TODO Add User
SQL.update("UPDATE Punishments SET EndTime = ?, Reason = ?, Perma = ? WHERE PunishmentId = ?", newUpdate, newReason.toString(), perma, id);
this.reason = newReason.toString();
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) {
public String getBantime(Timestamp endTime, boolean perma, ProxiedPlayer player) {
if(perma)
return Message.parse("BAN_PERMA", SteamwarUser.get(user).getPlayer());
return Message.parse("BAN_PERMA", player);
else
return endTime.toLocalDateTime().format(BungeeCore.DATE_FORMAT);
return endTime.toLocalDateTime().format(DateTimeFormatter.ofPattern(Message.parse("TIMEFORMAT", player)));
}
public enum PunishmentType {

Datei anzeigen

@ -33,6 +33,7 @@ import java.net.UnknownHostException;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Timestamp;
import java.time.format.DateTimeFormatter;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
@ -149,10 +150,6 @@ public class SteamwarUser {
return team;
}
public ProxiedPlayer getPlayer() {
return BungeeCore.get().getProxy().getPlayer(uuid);
}
public boolean isBanned() {
if(!punishments.containsKey(Punishment.PunishmentType.Ban))
return false;
@ -174,22 +171,22 @@ public class SteamwarUser {
return punishment.isPerma() || punishment.getEndTime().after(new Date());
}
public TextComponent banMessage(){
public TextComponent banMessage(ProxiedPlayer player){
Punishment punishment = punishments.get(Punishment.PunishmentType.Ban);
if (punishment.isPerma()) {
return BungeeCore.stringToText(Message.parsePrefixed("BANNED_MESSAGE_PERMA", getPlayer(), punishment.getReason()));
return BungeeCore.stringToText(Message.parsePrefixed("BANNED_MESSAGE_PERMA", player, punishment.getReason()));
} else {
return BungeeCore.stringToText(Message.parsePrefixed("BANNED_MESSAGE_UNTIL", getPlayer(), punishment.getEndTime().toLocalDateTime().format(BungeeCore.DATE_FORMAT),
return BungeeCore.stringToText(Message.parsePrefixed("BANNED_MESSAGE_UNTIL", player, punishment.getEndTime().toLocalDateTime().format(DateTimeFormatter.ofPattern(Message.parse("TIMEFORMAT", player))),
punishment.getReason()));
}
}
public TextComponent muteMessage(){
public TextComponent muteMessage(ProxiedPlayer player){
Punishment punishment = punishments.get(Punishment.PunishmentType.Mute);
if (punishment.isPerma()) {
return BungeeCore.stringToText(Message.parsePrefixed("MUTED_MESSAGE_PERMA", getPlayer(), punishment.getReason()));
return BungeeCore.stringToText(Message.parsePrefixed("MUTED_MESSAGE_PERMA", player, punishment.getReason()));
} else {
return BungeeCore.stringToText(Message.parsePrefixed("MUTED_MESSAGE_UNTIL",getPlayer(), punishment.getEndTime().toLocalDateTime().format(BungeeCore.DATE_FORMAT), punishment.getReason()));
return BungeeCore.stringToText(Message.parsePrefixed("MUTED_MESSAGE_UNTIL", player, punishment.getEndTime().toLocalDateTime().format(DateTimeFormatter.ofPattern(Message.parse("TIMEFORMAT", player))), punishment.getReason()));
}
}
@ -208,12 +205,12 @@ public class SteamwarUser {
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("");

Datei anzeigen

@ -1,5 +1,6 @@
PREFIX=§eSteam§8War»
SPACER=
TIMEFORMAT=dd.MM.yyyy HH:mm
UNKNOWN_COMMAND=§cUnbekannter Befehl.
UNKNOWN_PLAYER=§cDiesen Spieler gibt es nicht.