Signed-off-by: Lixfel <agga-games@gmx.de>
Dieser Commit ist enthalten in:
Ursprung
4d535c5550
Commit
c4bafb4591
@ -1 +1 @@
|
||||
Subproject commit 3e1c4e9059ef2400c79aaa5089eaafca075640c6
|
||||
Subproject commit 8dbf62e560de95615d93057481e8202ec11c85c4
|
@ -28,9 +28,8 @@ import de.steamwar.bungeecore.listeners.ping.PingListener;
|
||||
import de.steamwar.bungeecore.network.BungeeNetworkHandler;
|
||||
import de.steamwar.bungeecore.network.NetworkReceiver;
|
||||
import de.steamwar.bungeecore.network.SWScriptSyntaxForwarder;
|
||||
import de.steamwar.bungeecore.sql.Punishment;
|
||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||
import de.steamwar.bungeecore.sql.Team;
|
||||
import de.steamwar.sql.Punishment;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import de.steamwar.bungeecore.sql.UserElo;
|
||||
import de.steamwar.bungeecore.tablist.TablistManager;
|
||||
import de.steamwar.command.SWCommandUtils;
|
||||
@ -206,7 +205,7 @@ public class BungeeCore extends Plugin {
|
||||
new SettingsChangedListener();
|
||||
|
||||
getProxy().getScheduler().schedule(this, () -> {
|
||||
SteamwarUser.clearCache();
|
||||
SteamwarUser.clear();
|
||||
UserElo.clearCache();
|
||||
Team.clear();
|
||||
}, 1, 1, TimeUnit.HOURS);
|
||||
|
@ -19,8 +19,8 @@
|
||||
|
||||
package de.steamwar.bungeecore;
|
||||
|
||||
import de.steamwar.bungeecore.sql.EventFight;
|
||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||
import de.steamwar.sql.EventFight;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import de.steamwar.sql.Team;
|
||||
import de.steamwar.sql.Event;
|
||||
import net.md_5.bungee.api.ProxyServer;
|
||||
@ -66,7 +66,7 @@ public class EventStarter implements Runnable {
|
||||
if(BungeeCore.EVENT_MODE || !Event.get(next.getEventID()).spectateSystem()) {
|
||||
ServerStarter starter = new ServerStarter().event(next);
|
||||
|
||||
ProxiedPlayer leiter = ProxyServer.getInstance().getPlayer(SteamwarUser.get(next.getKampfleiter()).getUuid());
|
||||
ProxiedPlayer leiter = ProxyServer.getInstance().getPlayer(SteamwarUser.get(next.getKampfleiter()).getUUID());
|
||||
if(leiter != null)
|
||||
starter.send(leiter);
|
||||
|
||||
|
@ -1,9 +1,9 @@
|
||||
package de.steamwar.bungeecore;
|
||||
|
||||
import de.steamwar.bungeecore.sql.EventFight;
|
||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||
import de.steamwar.sql.EventFight;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import de.steamwar.sql.Team;
|
||||
import de.steamwar.bungeecore.sql.Tutorial;
|
||||
import de.steamwar.sql.Tutorial;
|
||||
import de.steamwar.messages.ChatSender;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
|
||||
@ -67,13 +67,13 @@ public class ServerStarter {
|
||||
}
|
||||
|
||||
public ServerStarter event(EventFight eventFight) {
|
||||
arena(eventFight.getSpielmodus(), eventFight.getMap());
|
||||
arena(ArenaMode.getByInternal(eventFight.getSpielmodus()), eventFight.getMap());
|
||||
node = BungeeCore.local;
|
||||
worldDir = EVENT_PATH;
|
||||
worldCleanup = () -> {};
|
||||
arguments.put("fightID", String.valueOf(eventFight.getFightID()));
|
||||
fightMap = eventFight.getMap();
|
||||
gameMode = eventFight.getSpielmodus().getInternalName();
|
||||
gameMode = eventFight.getSpielmodus();
|
||||
|
||||
String serverName = Team.get(eventFight.getTeamBlue()).getTeamKuerzel() + " vs " + Team.get(eventFight.getTeamRed()).getTeamKuerzel();
|
||||
serverNameProvider = port -> serverName;
|
||||
|
@ -22,7 +22,7 @@ package de.steamwar.bungeecore;
|
||||
import de.steamwar.bungeecore.network.NetworkSender;
|
||||
import de.steamwar.bungeecore.network.handlers.FightInfoHandler;
|
||||
import de.steamwar.bungeecore.sql.IgnoreSystem;
|
||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import de.steamwar.network.packets.server.StartingServerPacket;
|
||||
import net.md_5.bungee.api.ProxyServer;
|
||||
import net.md_5.bungee.api.chat.ClickEvent;
|
||||
|
@ -21,7 +21,7 @@ package de.steamwar.bungeecore.bot;
|
||||
|
||||
import de.steamwar.bungeecore.BungeeCore;
|
||||
import de.steamwar.bungeecore.bot.config.SteamwarDiscordBotConfig;
|
||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import net.dv8tion.jda.api.MessageBuilder;
|
||||
import net.dv8tion.jda.api.entities.Emoji;
|
||||
import net.dv8tion.jda.api.entities.Member;
|
||||
|
@ -21,8 +21,7 @@ package de.steamwar.bungeecore.bot.commands;
|
||||
|
||||
import de.steamwar.bungeecore.Message;
|
||||
import de.steamwar.bungeecore.commands.PunishmentCommand;
|
||||
import de.steamwar.bungeecore.sql.Punishment;
|
||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import net.dv8tion.jda.api.events.interaction.SlashCommandEvent;
|
||||
import net.dv8tion.jda.api.interactions.commands.OptionType;
|
||||
|
||||
@ -45,7 +44,7 @@ public class BanCommand extends BasicDiscordCommand {
|
||||
}
|
||||
|
||||
SteamwarUser sender = SteamwarUser.get(event.getMember().getIdLong());
|
||||
SteamwarUser target = SteamwarUser.getOrCreateOfflinePlayer(event.getOption("user").getAsString());
|
||||
SteamwarUser target = PunishmentCommand.getOrCreateOfflinePlayer(event.getOption("user").getAsString());
|
||||
if (target == null) {
|
||||
event.reply("Angegebener User invalide").setEphemeral(true).queue();
|
||||
return;
|
||||
@ -60,7 +59,7 @@ public class BanCommand extends BasicDiscordCommand {
|
||||
String msg = event.getOption("reason").getAsString();
|
||||
boolean isPerma = event.getOption("time").getAsString().equals("perma");
|
||||
|
||||
target.punish(Punishment.PunishmentType.Ban, time, msg, sender.getId(), isPerma);
|
||||
PunishmentCommand.ban(target, time, msg, sender, isPerma);
|
||||
Message.team("BAN_TEAM", new Message("PREFIX"), target.getUserName(), sender.getUserName(), new Message((isPerma ? "BAN_PERMA" : "BAN_UNTIL"), time), msg);
|
||||
event.reply("Erfolgreich " + target.getUserName() + (isPerma ? " permanent" : " bis " + time) + " gebannt").setEphemeral(true).queue();
|
||||
}
|
||||
|
@ -19,7 +19,7 @@
|
||||
|
||||
package de.steamwar.bungeecore.bot.commands;
|
||||
|
||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import de.steamwar.sql.UserGroup;
|
||||
import net.dv8tion.jda.api.entities.Member;
|
||||
import net.dv8tion.jda.api.events.interaction.SlashCommandEvent;
|
||||
|
@ -21,8 +21,8 @@ package de.steamwar.bungeecore.bot.commands;
|
||||
|
||||
import de.steamwar.bungeecore.Message;
|
||||
import de.steamwar.bungeecore.commands.PunishmentCommand;
|
||||
import de.steamwar.bungeecore.sql.Punishment;
|
||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||
import de.steamwar.sql.Punishment;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import net.dv8tion.jda.api.events.interaction.SlashCommandEvent;
|
||||
import net.dv8tion.jda.api.interactions.commands.OptionType;
|
||||
|
||||
@ -45,7 +45,7 @@ public class MuteCommand extends BasicDiscordCommand {
|
||||
}
|
||||
|
||||
SteamwarUser sender = SteamwarUser.get(event.getMember().getIdLong());
|
||||
SteamwarUser target = SteamwarUser.getOrCreateOfflinePlayer(event.getOption("user").getAsString());
|
||||
SteamwarUser target = PunishmentCommand.getOrCreateOfflinePlayer(event.getOption("user").getAsString());
|
||||
if (target == null) {
|
||||
event.reply("Angegebener User invalide").setEphemeral(true).complete();
|
||||
return;
|
||||
|
@ -20,7 +20,7 @@
|
||||
package de.steamwar.bungeecore.bot.commands;
|
||||
|
||||
import de.steamwar.sql.Event;
|
||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import de.steamwar.sql.Team;
|
||||
import de.steamwar.sql.TeamTeilnahme;
|
||||
import net.dv8tion.jda.api.EmbedBuilder;
|
||||
@ -91,6 +91,6 @@ public class TeamCommand extends BasicDiscordCommand {
|
||||
}
|
||||
|
||||
private boolean isOnline(SteamwarUser user) {
|
||||
return ProxyServer.getInstance().getPlayer(user.getUuid()) != null;
|
||||
return ProxyServer.getInstance().getPlayer(user.getUUID()) != null;
|
||||
}
|
||||
}
|
||||
|
@ -19,8 +19,10 @@
|
||||
|
||||
package de.steamwar.bungeecore.bot.commands;
|
||||
|
||||
import de.steamwar.bungeecore.sql.Punishment;
|
||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||
import de.steamwar.bungeecore.commands.PunishmentCommand;
|
||||
import de.steamwar.sql.BannedUserIPs;
|
||||
import de.steamwar.sql.Punishment;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import net.dv8tion.jda.api.events.interaction.SlashCommandEvent;
|
||||
import net.dv8tion.jda.api.interactions.commands.OptionType;
|
||||
|
||||
@ -42,7 +44,7 @@ public class UnbanCommand extends BasicDiscordCommand {
|
||||
}
|
||||
|
||||
SteamwarUser sender = SteamwarUser.get(event.getMember().getIdLong());
|
||||
SteamwarUser target = SteamwarUser.getOrCreateOfflinePlayer(event.getOption("user").getAsString());
|
||||
SteamwarUser target = PunishmentCommand.getOrCreateOfflinePlayer(event.getOption("user").getAsString());
|
||||
if (target == null) {
|
||||
event.reply("Angegebener User invalide").setEphemeral(true).queue();
|
||||
return;
|
||||
@ -54,6 +56,7 @@ public class UnbanCommand extends BasicDiscordCommand {
|
||||
}
|
||||
|
||||
target.punish(Punishment.PunishmentType.Ban, Timestamp.from(new Date().toInstant()), "Unban", sender.getId(), false);
|
||||
BannedUserIPs.unbanIPs(target.getId());
|
||||
event.reply("Erfolgreich " + target.getUserName() + " entbannt").setEphemeral(true).queue();
|
||||
}
|
||||
}
|
||||
|
@ -19,8 +19,8 @@
|
||||
|
||||
package de.steamwar.bungeecore.bot.commands;
|
||||
|
||||
import de.steamwar.bungeecore.sql.Punishment;
|
||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||
import de.steamwar.sql.Punishment;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import de.steamwar.sql.Team;
|
||||
import net.dv8tion.jda.api.EmbedBuilder;
|
||||
import net.dv8tion.jda.api.events.interaction.SlashCommandEvent;
|
||||
@ -72,7 +72,7 @@ public class WhoisCommand extends BasicDiscordCommand {
|
||||
EmbedBuilder embedBuilder = new EmbedBuilder();
|
||||
embedBuilder.setTitle("Whois: " + user.getUserName());
|
||||
StringBuilder st = new StringBuilder();
|
||||
st.append("UUID: ").append(user.getUuid()).append("\n");
|
||||
st.append("UUID: ").append(user.getUUID()).append("\n");
|
||||
st.append("ID: ").append(user.getId()).append("\n");
|
||||
if (user.getDiscordId() != null) {
|
||||
st.append("DiscordID: ").append(user.getDiscordId()).append("\n");
|
||||
|
@ -21,7 +21,7 @@ package de.steamwar.bungeecore.bot.events;
|
||||
|
||||
import de.steamwar.bungeecore.bot.SteamwarDiscordBot;
|
||||
import de.steamwar.bungeecore.bot.config.SteamwarDiscordBotConfig;
|
||||
import de.steamwar.bungeecore.sql.EventFight;
|
||||
import de.steamwar.sql.EventFight;
|
||||
import de.steamwar.sql.Team;
|
||||
import de.steamwar.sql.TeamTeilnahme;
|
||||
import de.steamwar.sql.Event;
|
||||
|
@ -22,7 +22,7 @@ package de.steamwar.bungeecore.bot.events;
|
||||
import de.steamwar.bungeecore.bot.SteamwarDiscordBot;
|
||||
import de.steamwar.bungeecore.bot.config.SteamwarDiscordBotConfig;
|
||||
import de.steamwar.bungeecore.commands.CheckCommand;
|
||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import lombok.experimental.UtilityClass;
|
||||
import net.dv8tion.jda.api.EmbedBuilder;
|
||||
import net.dv8tion.jda.api.MessageBuilder;
|
||||
|
@ -21,7 +21,7 @@ package de.steamwar.bungeecore.bot.listeners;
|
||||
|
||||
import de.steamwar.bungeecore.bot.AuthManager;
|
||||
import de.steamwar.bungeecore.bot.config.SteamwarDiscordBotConfig;
|
||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import net.dv8tion.jda.api.entities.ChannelType;
|
||||
import net.dv8tion.jda.api.events.interaction.GenericComponentInteractionCreateEvent;
|
||||
import net.dv8tion.jda.api.interactions.InteractionType;
|
||||
|
@ -22,8 +22,8 @@ package de.steamwar.bungeecore.bot.listeners;
|
||||
import de.steamwar.bungeecore.bot.SteamwarDiscordBot;
|
||||
import de.steamwar.bungeecore.bot.config.SteamwarDiscordBotConfig;
|
||||
import de.steamwar.bungeecore.listeners.ChatListener;
|
||||
import de.steamwar.bungeecore.sql.Punishment;
|
||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||
import de.steamwar.sql.Punishment;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import de.steamwar.messages.ChatSender;
|
||||
import net.dv8tion.jda.api.MessageBuilder;
|
||||
import net.dv8tion.jda.api.entities.Member;
|
||||
|
@ -21,7 +21,7 @@ package de.steamwar.bungeecore.bot.listeners;
|
||||
|
||||
import de.steamwar.bungeecore.bot.config.SteamwarDiscordBotConfig;
|
||||
import de.steamwar.bungeecore.bot.events.EventManager;
|
||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import de.steamwar.sql.Team;
|
||||
import de.steamwar.sql.TeamTeilnahme;
|
||||
import de.steamwar.sql.Event;
|
||||
|
@ -23,7 +23,7 @@ import de.steamwar.bungeecore.BungeeCore;
|
||||
import de.steamwar.bungeecore.Message;
|
||||
import de.steamwar.bungeecore.bot.config.DiscordTicketType;
|
||||
import de.steamwar.bungeecore.bot.config.SteamwarDiscordBotConfig;
|
||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import net.dv8tion.jda.api.EmbedBuilder;
|
||||
import net.dv8tion.jda.api.MessageBuilder;
|
||||
import net.dv8tion.jda.api.Permission;
|
||||
@ -138,7 +138,7 @@ public class DiscordTicketListener extends BasicDiscordListener {
|
||||
if(!event.getChannel().getId().equals(SteamwarDiscordBotConfig.TICKET_CHANNEL) && !event.getChannel().getId().equals(SteamwarDiscordBotConfig.TICKET_LOG)) {
|
||||
BungeeCore.get().getProxy().getPlayers().forEach(player -> {
|
||||
if(event.getAuthor().isBot() || event.getAuthor().isSystem()) return;
|
||||
SteamwarUser user = SteamwarUser.get(player);
|
||||
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
|
||||
boolean sendMessage;
|
||||
if(user.getDiscordId() == null) {
|
||||
sendMessage = user.getUserGroup().isCheckSchematics();
|
||||
|
@ -19,14 +19,13 @@
|
||||
package de.steamwar.bungeecore.bot.listeners;
|
||||
|
||||
import de.steamwar.bungeecore.BungeeCore;
|
||||
import de.steamwar.bungeecore.sql.Punishment;
|
||||
import de.steamwar.sql.Punishment;
|
||||
import de.steamwar.bungeecore.sql.SchematicNode;
|
||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import net.dv8tion.jda.api.entities.Message;
|
||||
import net.dv8tion.jda.api.events.message.priv.PrivateMessageReceivedEvent;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
public class PrivateMessageListener extends BasicDiscordListener {
|
||||
|
||||
|
@ -21,7 +21,7 @@ package de.steamwar.bungeecore.bot.util;
|
||||
|
||||
import de.steamwar.bungeecore.bot.SteamwarDiscordBot;
|
||||
import de.steamwar.bungeecore.bot.config.SteamwarDiscordBotConfig;
|
||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import lombok.experimental.UtilityClass;
|
||||
import net.dv8tion.jda.api.entities.Guild;
|
||||
import net.dv8tion.jda.api.entities.Role;
|
||||
|
@ -21,7 +21,7 @@ package de.steamwar.bungeecore.bot.util;
|
||||
|
||||
import de.steamwar.bungeecore.bot.SteamwarDiscordBot;
|
||||
import de.steamwar.bungeecore.sql.SchematicNode;
|
||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import lombok.experimental.UtilityClass;
|
||||
import net.dv8tion.jda.api.EmbedBuilder;
|
||||
import net.dv8tion.jda.api.MessageBuilder;
|
||||
|
@ -21,7 +21,7 @@ package de.steamwar.bungeecore.commands;
|
||||
|
||||
import de.steamwar.bungeecore.BungeeCore;
|
||||
import de.steamwar.bungeecore.Message;
|
||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import net.md_5.bungee.api.CommandSender;
|
||||
import net.md_5.bungee.api.ProxyServer;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
@ -61,7 +61,7 @@ abstract class BasicCommand extends Command implements TabExecutor {
|
||||
}
|
||||
|
||||
protected SteamwarUser unsafeUser(CommandSender sender, String arg){
|
||||
SteamwarUser target = SteamwarUser.getOrCreateOfflinePlayer(arg);
|
||||
SteamwarUser target = PunishmentCommand.getOrCreateOfflinePlayer(arg);
|
||||
if(target == null)
|
||||
Message.send("UNKNOWN_PLAYER", sender);
|
||||
return target;
|
||||
|
@ -23,7 +23,6 @@ import de.steamwar.bungeecore.*;
|
||||
import de.steamwar.bungeecore.inventory.SWInventory;
|
||||
import de.steamwar.bungeecore.inventory.SWItem;
|
||||
import de.steamwar.bungeecore.network.NetworkSender;
|
||||
import de.steamwar.bungeecore.sql.*;
|
||||
import de.steamwar.bungeecore.util.BauLock;
|
||||
import de.steamwar.bungeecore.util.Chat19;
|
||||
import de.steamwar.command.SWCommand;
|
||||
@ -33,6 +32,7 @@ import de.steamwar.messages.ChatSender;
|
||||
import de.steamwar.network.packets.server.BaumemberUpdatePacket;
|
||||
import de.steamwar.bungeecore.util.BauLockState;
|
||||
import de.steamwar.sql.BauweltMember;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import net.md_5.bungee.api.CommandSender;
|
||||
import net.md_5.bungee.api.ProxyServer;
|
||||
import net.md_5.bungee.api.config.ServerInfo;
|
||||
@ -123,10 +123,10 @@ public class BauCommand extends SWCommand {
|
||||
|
||||
@Register(value = "addmember", description = "BAU_ADDMEMBER_USAGE")
|
||||
public void addmember(ProxiedPlayer p, @Validator("addMemberTarget") SteamwarUser target) {
|
||||
BauweltMember.addMember(p.getUniqueId(), target.getUuid());
|
||||
BauweltMember.addMember(p.getUniqueId(), target.getUUID());
|
||||
Message.send("BAU_ADDMEMBER_ADDED", p);
|
||||
|
||||
ProxiedPlayer z = ProxyServer.getInstance().getPlayer(target.getUuid());
|
||||
ProxiedPlayer z = ProxyServer.getInstance().getPlayer(target.getUUID());
|
||||
if(z != null)
|
||||
Message.send("BAU_ADDMEMBER_ADDED_TARGET", z, p.getName());
|
||||
}
|
||||
@ -138,11 +138,11 @@ public class BauCommand extends SWCommand {
|
||||
messageSender.send("UNKNOWN_PLAYER");
|
||||
return false;
|
||||
}
|
||||
if (((ProxiedPlayer) sender).getUniqueId().equals(value.getUuid())) {
|
||||
if (((ProxiedPlayer) sender).getUniqueId().equals(value.getUUID())) {
|
||||
messageSender.send("BAU_ADDMEMBER_SELFADD");
|
||||
return false;
|
||||
}
|
||||
if (BauweltMember.getBauMember(((ProxiedPlayer) sender).getUniqueId(), value.getUuid()) != null) {
|
||||
if (BauweltMember.getBauMember(((ProxiedPlayer) sender).getUniqueId(), value.getUUID()) != null) {
|
||||
messageSender.send("BAU_ADDMEMBER_ISADDED");
|
||||
return false;
|
||||
}
|
||||
@ -154,9 +154,9 @@ public class BauCommand extends SWCommand {
|
||||
@Register("teleport")
|
||||
public void teleport(ProxiedPlayer p, @Validator("teleportTarget") SteamwarUser worldOwner, @Mapper("version") @OptionalValue(value = "", onlyUINIG = true) int version) {
|
||||
versionSelector(version,
|
||||
() -> new ServerStarter().build12(worldOwner.getUuid()).send(p).start(),
|
||||
() -> new ServerStarter().build15(worldOwner.getUuid()).send(p).start(),
|
||||
() -> new ServerStarter().build19(worldOwner.getUuid()).send(p).start()
|
||||
() -> new ServerStarter().build12(worldOwner.getUUID()).send(p).start(),
|
||||
() -> new ServerStarter().build15(worldOwner.getUUID()).send(p).start(),
|
||||
() -> new ServerStarter().build19(worldOwner.getUUID()).send(p).start()
|
||||
);
|
||||
}
|
||||
|
||||
@ -168,12 +168,12 @@ public class BauCommand extends SWCommand {
|
||||
return false;
|
||||
}
|
||||
ProxiedPlayer p = (ProxiedPlayer) sender;
|
||||
if (!p.getUniqueId().equals(value.getUuid()) && BauweltMember.getBauMember(value.getUuid(), p.getUniqueId()) == null) {
|
||||
SubserverSystem.sendDeniedMessage(p, value.getUuid());
|
||||
if (!p.getUniqueId().equals(value.getUUID()) && BauweltMember.getBauMember(value.getUUID(), p.getUniqueId()) == null) {
|
||||
SubserverSystem.sendDeniedMessage(p, value.getUUID());
|
||||
messageSender.send("BAU_TP_NOALLOWED");
|
||||
return false;
|
||||
}
|
||||
if(BauLock.isLocked(value, SteamwarUser.get(p))) {
|
||||
if(BauLock.isLocked(value, SteamwarUser.get(p.getUniqueId()))) {
|
||||
messageSender.send("BAU_LOCKED_NOALLOWED");
|
||||
return false;
|
||||
}
|
||||
@ -232,13 +232,13 @@ public class BauCommand extends SWCommand {
|
||||
if (target == null)
|
||||
return;
|
||||
|
||||
if(SteamwarUser.get(target.getMemberID()).getUuid().equals(p.getUniqueId())) {
|
||||
if(SteamwarUser.get(target.getMemberID()).getUUID().equals(p.getUniqueId())) {
|
||||
Message.send("BAU_DELMEMBER_SELFDEL", p);
|
||||
return;
|
||||
}
|
||||
|
||||
target.remove();
|
||||
ProxiedPlayer toRemove = ProxyServer.getInstance().getPlayer(SteamwarUser.get(target.getMemberID()).getUuid());
|
||||
ProxiedPlayer toRemove = ProxyServer.getInstance().getPlayer(SteamwarUser.get(target.getMemberID()).getUUID());
|
||||
if(toRemove != null){
|
||||
Message.send("BAU_DELMEMBER_DELETED_TARGET", toRemove, p.getName());
|
||||
Subserver currentServer = Subserver.getSubserver(toRemove.getServer().getInfo());
|
||||
@ -309,7 +309,7 @@ public class BauCommand extends SWCommand {
|
||||
return null;
|
||||
}
|
||||
|
||||
BauweltMember target = BauweltMember.getBauMember(p.getUniqueId(), member.getUuid());
|
||||
BauweltMember target = BauweltMember.getBauMember(p.getUniqueId(), member.getUUID());
|
||||
if (target == null) {
|
||||
Message.send("BAU_MEMBER_NOMEMBER", p);
|
||||
return null;
|
||||
@ -318,7 +318,7 @@ public class BauCommand extends SWCommand {
|
||||
}
|
||||
|
||||
private static void isAllowedTo(boolean permission, ProxiedPlayer p, BauweltMember target, String what){
|
||||
ProxiedPlayer player = ProxyServer.getInstance().getPlayer(SteamwarUser.get(target.getMemberID()).getUuid());
|
||||
ProxiedPlayer player = ProxyServer.getInstance().getPlayer(SteamwarUser.get(target.getMemberID()).getUUID());
|
||||
|
||||
if(permission){
|
||||
if(player != null)
|
||||
|
@ -20,7 +20,7 @@
|
||||
package de.steamwar.bungeecore.commands;
|
||||
|
||||
import de.steamwar.sql.SWException;
|
||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import de.steamwar.messages.ChatSender;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
|
@ -22,9 +22,9 @@ package de.steamwar.bungeecore.commands;
|
||||
import de.steamwar.bungeecore.Message;
|
||||
import de.steamwar.bungeecore.inventory.SWInventory;
|
||||
import de.steamwar.bungeecore.inventory.SWItem;
|
||||
import de.steamwar.bungeecore.sql.NodeMember;
|
||||
import de.steamwar.sql.NodeMember;
|
||||
import de.steamwar.bungeecore.sql.SchematicNode;
|
||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
|
||||
|
@ -25,7 +25,7 @@ import de.steamwar.bungeecore.listeners.ConnectionListener;
|
||||
import de.steamwar.bungeecore.sql.CheckedSchematic;
|
||||
import de.steamwar.bungeecore.sql.SchematicNode;
|
||||
import de.steamwar.sql.SchematicType;
|
||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
import net.md_5.bungee.api.ProxyServer;
|
||||
@ -279,7 +279,7 @@ public class CheckCommand extends SWCommand {
|
||||
|
||||
schematic.setType(fightTypes.get(schematic.getSchemtype()).toDB());
|
||||
SteamwarUser user = SteamwarUser.get(schematic.getOwner());
|
||||
ProxiedPlayer player = ProxyServer.getInstance().getPlayer(user.getUuid());
|
||||
ProxiedPlayer player = ProxyServer.getInstance().getPlayer(user.getUUID());
|
||||
if(player != null) {
|
||||
Message.send("CHECK_ACCEPTED", player, schematic.getSchemtype().name(), schematic.getName());
|
||||
} else {
|
||||
@ -293,7 +293,7 @@ public class CheckCommand extends SWCommand {
|
||||
private void decline(String reason){
|
||||
if(createLog(reason)) {
|
||||
SteamwarUser user = SteamwarUser.get(schematic.getOwner());
|
||||
ProxiedPlayer player = ProxyServer.getInstance().getPlayer(user.getUuid());
|
||||
ProxiedPlayer player = ProxyServer.getInstance().getPlayer(user.getUUID());
|
||||
if(player != null) {
|
||||
Message.send("CHECK_DECLINED", player, schematic.getSchemtype().name(), schematic.getName(), reason);
|
||||
} else {
|
||||
|
@ -20,8 +20,8 @@
|
||||
package de.steamwar.bungeecore.commands;
|
||||
|
||||
import de.steamwar.bungeecore.Message;
|
||||
import de.steamwar.bungeecore.sql.Punishment;
|
||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||
import de.steamwar.sql.Punishment;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import de.steamwar.command.*;
|
||||
import de.steamwar.messages.ChatSender;
|
||||
import net.md_5.bungee.api.ProxyServer;
|
||||
@ -79,9 +79,9 @@ public class DevCommand extends SWCommand {
|
||||
@ClassValidator(value = ProxiedPlayer.class, local = true)
|
||||
public TypeValidator<ProxiedPlayer> punishmentGuardChecker() {
|
||||
return (sender, value, messageSender) -> {
|
||||
SteamwarUser user = SteamwarUser.get(value);
|
||||
SteamwarUser user = SteamwarUser.get(value.getUniqueId());
|
||||
if (user.isPunished(Punishment.PunishmentType.NoDevServer)) {
|
||||
Message message = user.punishmentMessage(Punishment.PunishmentType.NoDevServer);
|
||||
Message message = PunishmentCommand.punishmentMessage(user, Punishment.PunishmentType.NoDevServer);
|
||||
messageSender.send(message.getFormat(), message.getParams());
|
||||
return false;
|
||||
}
|
||||
|
@ -20,7 +20,7 @@
|
||||
package de.steamwar.bungeecore.commands;
|
||||
|
||||
import de.steamwar.bungeecore.*;
|
||||
import de.steamwar.bungeecore.sql.EventFight;
|
||||
import de.steamwar.sql.EventFight;
|
||||
import de.steamwar.sql.SchematicType;
|
||||
import de.steamwar.sql.Team;
|
||||
import de.steamwar.sql.TeamTeilnahme;
|
||||
|
@ -20,7 +20,7 @@
|
||||
package de.steamwar.bungeecore.commands;
|
||||
|
||||
import de.steamwar.bungeecore.Message;
|
||||
import de.steamwar.bungeecore.sql.EventFight;
|
||||
import de.steamwar.sql.EventFight;
|
||||
import de.steamwar.sql.Team;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import de.steamwar.command.TypeMapper;
|
||||
|
@ -19,7 +19,7 @@
|
||||
|
||||
package de.steamwar.bungeecore.commands;
|
||||
|
||||
import de.steamwar.bungeecore.sql.EventFight;
|
||||
import de.steamwar.sql.EventFight;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import net.md_5.bungee.api.CommandSender;
|
||||
|
||||
|
@ -22,13 +22,10 @@ package de.steamwar.bungeecore.commands;
|
||||
import de.steamwar.bungeecore.*;
|
||||
import de.steamwar.bungeecore.inventory.SWInventory;
|
||||
import de.steamwar.bungeecore.inventory.SWItem;
|
||||
import de.steamwar.bungeecore.listeners.mods.ModLoaderBlocker;
|
||||
import de.steamwar.bungeecore.sql.Punishment;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import de.steamwar.messages.ChatSender;
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
import net.md_5.bungee.api.ChatMessageType;
|
||||
import net.md_5.bungee.api.CommandSender;
|
||||
import net.md_5.bungee.api.chat.ClickEvent;
|
||||
import net.md_5.bungee.api.chat.HoverEvent;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
|
@ -3,7 +3,7 @@ package de.steamwar.bungeecore.commands;
|
||||
import de.steamwar.bungeecore.BungeeCore;
|
||||
import de.steamwar.bungeecore.Message;
|
||||
import de.steamwar.sql.internal.Statement;
|
||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import net.md_5.bungee.BungeeCord;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
@ -25,7 +25,7 @@ public class GDPRQuery extends SWCommand {
|
||||
|
||||
@Register
|
||||
public void generate(ProxiedPlayer player, ProxiedPlayer forPlayer) {
|
||||
SteamwarUser user = SteamwarUser.get(forPlayer);
|
||||
SteamwarUser user = SteamwarUser.get(forPlayer.getUniqueId());
|
||||
if(user == null) {
|
||||
Message.send("UNKNOWN_PLAYER", player);
|
||||
return;
|
||||
@ -49,7 +49,7 @@ public class GDPRQuery extends SWCommand {
|
||||
copy(getClass().getClassLoader().getResourceAsStream("GDPRQueryREADME.md"), out, "README.txt");
|
||||
|
||||
printUpdate(player, "GDPR_STATUS_WORLD");
|
||||
copyBauwelt(user, out, "/home/minecraft/userworlds/" + user.getUuid().toString(), "BuildWorld12");
|
||||
copyBauwelt(user, out, "/home/minecraft/userworlds/" + user.getUUID().toString(), "BuildWorld12");
|
||||
copyBauwelt(user, out, "/home/minecraft/userworlds15/" + user.getId(), "BuildWorld15");
|
||||
|
||||
printUpdate(player, "GDPR_STATUS_INVENTORIES");
|
||||
@ -214,14 +214,14 @@ public class GDPRQuery extends SWCommand {
|
||||
}
|
||||
}
|
||||
|
||||
File playerdata = new File(world, "playerdata/" + user.getUuid().toString() + ".dat");
|
||||
File playerdata = new File(world, "playerdata/" + user.getUUID().toString() + ".dat");
|
||||
if(playerdata.exists())
|
||||
copy(playerdata, out, outDir + "/playerdata/" + user.getUuid().toString() + ".dat");
|
||||
copy(playerdata, out, outDir + "/playerdata/" + user.getUUID().toString() + ".dat");
|
||||
}
|
||||
|
||||
private void copyPlayerdata(SteamwarUser user, ZipOutputStream out, String inDir, String outDir) throws IOException {
|
||||
File worlds = new File(inDir);
|
||||
String path = "playerdata/" + user.getUuid().toString() + ".dat";
|
||||
String path = "playerdata/" + user.getUUID().toString() + ".dat";
|
||||
|
||||
int i = 0;
|
||||
for(File world : worlds.listFiles()) {
|
||||
@ -229,7 +229,7 @@ public class GDPRQuery extends SWCommand {
|
||||
if(!playerdata.exists())
|
||||
continue;
|
||||
|
||||
copy(playerdata, out, outDir + "/" + (i++) + "/" + user.getUuid().toString() + ".dat");
|
||||
copy(playerdata, out, outDir + "/" + (i++) + "/" + user.getUUID().toString() + ".dat");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -21,12 +21,11 @@ package de.steamwar.bungeecore.commands;
|
||||
|
||||
import de.steamwar.bungeecore.Message;
|
||||
import de.steamwar.bungeecore.sql.IgnoreSystem;
|
||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import de.steamwar.command.SWCommandUtils;
|
||||
import de.steamwar.command.TypeMapper;
|
||||
import net.md_5.bungee.BungeeCord;
|
||||
import net.md_5.bungee.api.CommandSender;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
|
||||
import java.util.stream.Collectors;
|
||||
|
@ -24,8 +24,8 @@ import de.steamwar.bungeecore.inventory.SWInventory;
|
||||
import de.steamwar.bungeecore.inventory.SWItem;
|
||||
import de.steamwar.bungeecore.inventory.SWListInv;
|
||||
import de.steamwar.bungeecore.inventory.SWStreamInv;
|
||||
import de.steamwar.bungeecore.sql.*;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import de.steamwar.sql.Mod;
|
||||
import net.md_5.bungee.api.chat.ClickEvent;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
|
||||
|
@ -20,15 +20,11 @@
|
||||
package de.steamwar.bungeecore.commands;
|
||||
|
||||
import de.steamwar.bungeecore.Message;
|
||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import net.md_5.bungee.api.CommandSender;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
import org.apache.commons.lang3.LocaleUtils;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
import java.text.NumberFormat;
|
||||
import java.util.Locale;
|
||||
|
||||
public class PlaytimeCommand extends SWCommand {
|
||||
|
||||
@ -40,7 +36,7 @@ public class PlaytimeCommand extends SWCommand {
|
||||
public void genericCommand(ProxiedPlayer player) {
|
||||
NumberFormat format = NumberFormat.getNumberInstance((player).getLocale());
|
||||
format.setMaximumFractionDigits(2);
|
||||
String formattedText = format.format((SteamwarUser.get(player).getOnlinetime() / (double) 3600));
|
||||
String formattedText = format.format((SteamwarUser.get(player.getUniqueId()).getOnlinetime() / (double) 3600));
|
||||
|
||||
Message.send("HOURS_PLAYED", player, formattedText);
|
||||
}
|
||||
|
@ -22,7 +22,7 @@ package de.steamwar.bungeecore.commands;
|
||||
import de.steamwar.bungeecore.Message;
|
||||
import de.steamwar.bungeecore.listeners.PollSystem;
|
||||
import de.steamwar.sql.PollAnswer;
|
||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import de.steamwar.command.TypeValidator;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
|
@ -19,13 +19,20 @@
|
||||
|
||||
package de.steamwar.bungeecore.commands;
|
||||
|
||||
import com.google.gson.JsonParser;
|
||||
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.sql.SteamwarUser;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import de.steamwar.messages.ChatSender;
|
||||
import de.steamwar.sql.BannedUserIPs;
|
||||
import de.steamwar.sql.Punishment;
|
||||
import net.md_5.bungee.api.CommandSender;
|
||||
import net.md_5.bungee.api.ProxyServer;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.sql.Timestamp;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
@ -33,17 +40,84 @@ import java.time.Duration;
|
||||
import java.time.Instant;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import java.util.Date;
|
||||
import java.util.regex.MatchResult;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.NoSuchElementException;
|
||||
import java.util.Scanner;
|
||||
import java.util.UUID;
|
||||
import java.util.logging.Level;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class PunishmentCommand {
|
||||
|
||||
private static final String API_URL = "https://api.mojang.com/users/profiles/minecraft/";
|
||||
private static final JsonParser jsonParser = new JsonParser();
|
||||
|
||||
public static SteamwarUser getOrCreateOfflinePlayer(String name) {
|
||||
SteamwarUser user = SteamwarUser.get(name);
|
||||
if (user != null) {
|
||||
return user;
|
||||
}
|
||||
|
||||
UUID uuid = getUUIDofOfflinePlayer(name);
|
||||
if (uuid == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return SteamwarUser.getOrCreate(uuid, name, u -> {}, (o, n) -> {});
|
||||
}
|
||||
|
||||
private static UUID getUUIDofOfflinePlayer(String playerName) {
|
||||
try {
|
||||
final URL url = new URL(API_URL + playerName);
|
||||
String uuid = jsonParser.parse(new Scanner(url.openConnection().getInputStream()).nextLine()).getAsJsonObject().get("id").getAsString();
|
||||
return UUID.fromString(uuid.replaceFirst("(\\w{8})(\\w{4})(\\w{4})(\\w{4})(\\w{12})", "$1-$2-$3-$4-$5"));
|
||||
} catch (NoSuchElementException e) {
|
||||
// ignore, player does not exist
|
||||
} catch (IOException e) {
|
||||
BungeeCore.get().getLogger().log(Level.SEVERE, "Could not get offline player UUID " + playerName, e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static boolean isPunishedWithMessage(ChatSender player, Punishment.PunishmentType punishment) {
|
||||
SteamwarUser user = player.user();
|
||||
if (!user.isPunished(punishment)) {
|
||||
return false;
|
||||
}
|
||||
player.system(punishmentMessage(user, punishment));
|
||||
return true;
|
||||
}
|
||||
|
||||
public static void ban(SteamwarUser user, Timestamp time, String banReason, SteamwarUser punisher, boolean perma) {
|
||||
user.punish(Punishment.PunishmentType.Ban, time, banReason, punisher.getId(), perma);
|
||||
|
||||
ProxiedPlayer player = ProxyServer.getInstance().getPlayer(user.getUUID());
|
||||
if (player != null) {
|
||||
ChatSender.disconnect(player).system(punishmentMessage(user, Punishment.PunishmentType.Ban));
|
||||
for (BannedUserIPs banned : BannedUserIPs.get(player.getAddress().getAddress().getHostAddress())) {
|
||||
SteamwarUser bannedUser = SteamwarUser.get(banned.getUserID());
|
||||
if (bannedUser.isPunished(Punishment.PunishmentType.Ban) && bannedUser.getPunishment(Punishment.PunishmentType.Ban).getEndTime().before(time)) {
|
||||
bannedUser.punish(Punishment.PunishmentType.Ban, time, banReason, punisher.getId(), perma);
|
||||
}
|
||||
}
|
||||
BannedUserIPs.banIP(user.getId(), player.getAddress().getAddress().getHostAddress());
|
||||
}
|
||||
}
|
||||
|
||||
public static Message punishmentMessage(SteamwarUser user, Punishment.PunishmentType punishment) {
|
||||
Punishment currentPunishment = user.getPunishment(punishment);
|
||||
if (currentPunishment.isPerma()) {
|
||||
return new Message(punishment.getPlayerMessagePerma(), currentPunishment.getReason());
|
||||
} else {
|
||||
return new Message(punishment.getPlayerMessageUntil(), currentPunishment.getEndTime(), currentPunishment.getReason());
|
||||
}
|
||||
}
|
||||
|
||||
public PunishmentCommand(String command, Punishment.PunishmentType punishmentType) {
|
||||
new SWCommand(command, "bungeecore.ban") {
|
||||
@Register(description = "PUNISHMENT_USAGE")
|
||||
public void genericCommand(ProxiedPlayer player, String toPunish, String date, String... message) {
|
||||
if (punishmentType.isNeedsAdmin() && !SteamwarUser.get(player).getUserGroup().isAdminGroup()) {
|
||||
SteamwarUser punisher = SteamwarUser.get(player.getUniqueId());
|
||||
if (punishmentType.isNeedsAdmin() && !punisher.getUserGroup().isAdminGroup()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -57,7 +131,10 @@ public class PunishmentCommand {
|
||||
|
||||
boolean isPerma = date.equalsIgnoreCase("perma");
|
||||
String msg = String.join(" ", message);
|
||||
target.punish(punishmentType, banTime, msg, SteamwarUser.get(player.getName()).getId(), isPerma);
|
||||
if(punishmentType == Punishment.PunishmentType.Ban)
|
||||
ban(target, banTime, msg, punisher, isPerma);
|
||||
else
|
||||
target.punish(punishmentType, banTime, msg, punisher.getId(), isPerma);
|
||||
Message.team(punishmentType.getTeamMessage(), new Message("PREFIX"), target.getUserName(), player.getName(), new Message((isPerma ? "PUNISHMENT_PERMA" : "PUNISHMENT_UNTIL"), banTime), msg);
|
||||
}
|
||||
};
|
||||
@ -68,7 +145,7 @@ public class PunishmentCommand {
|
||||
new SWCommand(antiCommand, "bungeecore.ban") {
|
||||
@Register(description = "PUNISHMENT_USAGE")
|
||||
public void genericCommand(ProxiedPlayer player, String toUnpunish) {
|
||||
if (punishmentType.isNeedsAdmin() && !SteamwarUser.get(player).getUserGroup().isAdminGroup()) {
|
||||
if (punishmentType.isNeedsAdmin() && !SteamwarUser.get(player.getUniqueId()).getUserGroup().isAdminGroup()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -83,6 +160,8 @@ public class PunishmentCommand {
|
||||
|
||||
Message.send(punishmentType.getUnpunishmentMessage(), player, target.getUserName());
|
||||
target.punish(punishmentType, Timestamp.from(new Date().toInstant()), antiCommand, SteamwarUser.get(player.getName()).getId(), false);
|
||||
if(punishmentType == Punishment.PunishmentType.Ban)
|
||||
BannedUserIPs.unbanIPs(target.getId());
|
||||
}
|
||||
};
|
||||
}
|
||||
@ -95,7 +174,7 @@ public class PunishmentCommand {
|
||||
}
|
||||
|
||||
protected SteamwarUser unsafeUser(CommandSender sender, String arg){
|
||||
SteamwarUser target = SteamwarUser.getOrCreateOfflinePlayer(arg);
|
||||
SteamwarUser target = getOrCreateOfflinePlayer(arg);
|
||||
if(target == null)
|
||||
Message.send("UNKNOWN_PLAYER", sender);
|
||||
return target;
|
||||
|
@ -21,13 +21,12 @@ package de.steamwar.bungeecore.commands;
|
||||
|
||||
import de.steamwar.bungeecore.ArenaMode;
|
||||
import de.steamwar.bungeecore.Message;
|
||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import de.steamwar.bungeecore.sql.UserElo;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import de.steamwar.command.SWCommandUtils;
|
||||
import de.steamwar.command.TypeMapper;
|
||||
import net.md_5.bungee.BungeeCord;
|
||||
import net.md_5.bungee.api.CommandSender;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
|
||||
import java.util.Optional;
|
||||
|
@ -23,10 +23,10 @@ import de.steamwar.bungeecore.*;
|
||||
import de.steamwar.bungeecore.inventory.SWItem;
|
||||
import de.steamwar.bungeecore.inventory.SWListInv;
|
||||
import de.steamwar.bungeecore.inventory.SWStreamInv;
|
||||
import de.steamwar.bungeecore.sql.Fight;
|
||||
import de.steamwar.bungeecore.sql.Punishment;
|
||||
import de.steamwar.sql.Fight;
|
||||
import de.steamwar.sql.Punishment;
|
||||
import de.steamwar.sql.SchematicType;
|
||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import de.steamwar.messages.ChatSender;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
@ -44,12 +44,12 @@ public class ReplayCommand extends SWCommand {
|
||||
@Register
|
||||
public void genericCommand(ProxiedPlayer player, @OptionalValue("") String optionalMap) {
|
||||
ChatSender sender = ChatSender.of(player);
|
||||
if (sender.user().isPunishedWithMessage(sender, Punishment.PunishmentType.NoFightServer))
|
||||
if (PunishmentCommand.isPunishedWithMessage(sender, Punishment.PunishmentType.NoFightServer))
|
||||
return;
|
||||
|
||||
new SWStreamInv<>(player, Message.parse("REPLAY_TITLE", player), (click, fight) -> {
|
||||
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
|
||||
ArenaMode mode = fight.getGameMode();
|
||||
ArenaMode mode = ArenaMode.getBySchemType(fight.getSchemType());
|
||||
ServerStarter starter = new ServerStarter().replay(fight.getFightID()).blueLeader(player);
|
||||
|
||||
String map = mode.getRandomMap();
|
||||
|
@ -19,8 +19,10 @@
|
||||
|
||||
package de.steamwar.bungeecore.commands;
|
||||
|
||||
import de.steamwar.bungeecore.network.NetworkSender;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import de.steamwar.messages.ChatSender;
|
||||
import de.steamwar.network.packets.server.LocaleInvalidationPacket;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
|
||||
import java.util.Objects;
|
||||
@ -35,6 +37,7 @@ public class SetLocaleCommand extends SWCommand {
|
||||
public void genericCommand(ProxiedPlayer player) {
|
||||
ChatSender sender = ChatSender.of(player);
|
||||
sender.user().setLocale(Objects.requireNonNull(player.getLocale()), true);
|
||||
NetworkSender.send(player, new LocaleInvalidationPacket(sender.user().getId()));
|
||||
sender.system("LOCK_LOCALE_CHANGED");
|
||||
}
|
||||
}
|
||||
|
@ -23,8 +23,8 @@ import de.steamwar.bungeecore.Message;
|
||||
import de.steamwar.bungeecore.Storage;
|
||||
import de.steamwar.bungeecore.inventory.SWItem;
|
||||
import de.steamwar.bungeecore.inventory.SWListInv;
|
||||
import de.steamwar.bungeecore.sql.Punishment;
|
||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||
import de.steamwar.sql.Punishment;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import de.steamwar.sql.Team;
|
||||
import de.steamwar.sql.TeamTeilnahme;
|
||||
import de.steamwar.messages.ChatSender;
|
||||
@ -314,7 +314,7 @@ public class TeamCommand extends BasicCommand {
|
||||
teamInvitations.get(target.getId()).add(team.getTeamId());
|
||||
|
||||
Message.send("TEAM_INVITE_INVITED", player, args[1]);
|
||||
ProxiedPlayer p = ProxyServer.getInstance().getPlayer(target.getUuid());
|
||||
ProxiedPlayer p = ProxyServer.getInstance().getPlayer(target.getUUID());
|
||||
if(p != null)
|
||||
Message.send("TEAM_INVITE_INVITED_TARGET", p, team.getTeamColor(), team.getTeamName());
|
||||
}
|
||||
@ -358,7 +358,7 @@ public class TeamCommand extends BasicCommand {
|
||||
target.setTeam(0);
|
||||
|
||||
Message.send("TEAM_REMOVE_REMOVED", player);
|
||||
ProxiedPlayer p = ProxyServer.getInstance().getPlayer(target.getUuid());
|
||||
ProxiedPlayer p = ProxyServer.getInstance().getPlayer(target.getUUID());
|
||||
if(p != null)
|
||||
Message.send("TEAM_REMOVE_REMOVED_TARGET", player);
|
||||
}
|
||||
@ -429,7 +429,7 @@ public class TeamCommand extends BasicCommand {
|
||||
}
|
||||
|
||||
private String playerName(SteamwarUser user){
|
||||
return ProxyServer.getInstance().getPlayer(user.getUuid()) != null ? "§a" + user.getUserName() : "§e" + user.getUserName();
|
||||
return ProxyServer.getInstance().getPlayer(user.getUUID()) != null ? "§a" + user.getUserName() : "§e" + user.getUserName();
|
||||
}
|
||||
|
||||
private void info(ProxiedPlayer player, SteamwarUser user, Team team, String[] args){
|
||||
@ -616,7 +616,7 @@ public class TeamCommand extends BasicCommand {
|
||||
private void server(ProxiedPlayer player, SteamwarUser user, Team team, String[] args){
|
||||
if(notLeader(player, user, team))
|
||||
return;
|
||||
if (user.isPunishedWithMessage(ChatSender.of(player), Punishment.PunishmentType.NoTeamServer)) {
|
||||
if (PunishmentCommand.isPunishedWithMessage(ChatSender.of(player), Punishment.PunishmentType.NoTeamServer)) {
|
||||
return;
|
||||
}
|
||||
if (args.length < 2) {
|
||||
|
@ -20,7 +20,7 @@
|
||||
package de.steamwar.bungeecore.commands;
|
||||
|
||||
import de.steamwar.bungeecore.listeners.ChatListener;
|
||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import de.steamwar.messages.ChatSender;
|
||||
import net.md_5.bungee.api.CommandSender;
|
||||
|
||||
|
@ -21,8 +21,8 @@ package de.steamwar.bungeecore.commands;
|
||||
|
||||
import de.steamwar.bungeecore.*;
|
||||
import de.steamwar.sql.BauweltMember;
|
||||
import de.steamwar.bungeecore.sql.Punishment;
|
||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||
import de.steamwar.sql.Punishment;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import de.steamwar.sql.Team;
|
||||
import de.steamwar.bungeecore.util.BauLock;
|
||||
import de.steamwar.bungeecore.util.Chat19;
|
||||
@ -87,14 +87,14 @@ public class TpCommand extends BasicCommand {
|
||||
Subserver subserver = Subserver.getSubserver(server);
|
||||
|
||||
if (subserver != null && subserver.getType() == Servertype.ARENA) {
|
||||
if (!sender.user().isPunishedWithMessage(sender, Punishment.PunishmentType.NoFightServer))
|
||||
if (!PunishmentCommand.isPunishedWithMessage(sender, Punishment.PunishmentType.NoFightServer))
|
||||
SubserverSystem.sendPlayer(subserver, player);
|
||||
|
||||
} else if(subserver instanceof Bauserver) {
|
||||
Bauserver bauserver = (Bauserver) subserver;
|
||||
ProxiedPlayer checker = BungeeCord.getInstance().getPlayer(bauserver.getOwner());
|
||||
if (checker != null && CheckCommand.isChecking(checker)) {
|
||||
SteamwarUser steamwarUser = SteamwarUser.get(player);
|
||||
SteamwarUser steamwarUser = SteamwarUser.get(player.getUniqueId());
|
||||
if (steamwarUser.getUserGroup().isCheckSchematics() || CheckCommand.getCheckingSchem(checker).getOwner() == steamwarUser.getId()) {
|
||||
SubserverSystem.sendPlayer(subserver, player);
|
||||
} else {
|
||||
|
@ -24,8 +24,8 @@ import de.steamwar.bungeecore.inventory.SWInventory;
|
||||
import de.steamwar.bungeecore.inventory.SWItem;
|
||||
import de.steamwar.bungeecore.inventory.SWListInv;
|
||||
import de.steamwar.bungeecore.inventory.SWStreamInv;
|
||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||
import de.steamwar.bungeecore.sql.Tutorial;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import de.steamwar.sql.Tutorial;
|
||||
import de.steamwar.bungeecore.util.Chat19;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import de.steamwar.command.TypeValidator;
|
||||
|
@ -21,7 +21,7 @@ package de.steamwar.bungeecore.commands;
|
||||
|
||||
import de.steamwar.bungeecore.ArenaMode;
|
||||
import de.steamwar.bungeecore.listeners.mods.ModLoaderBlocker;
|
||||
import de.steamwar.bungeecore.sql.Punishment;
|
||||
import de.steamwar.sql.Punishment;
|
||||
import de.steamwar.command.SWCommandUtils;
|
||||
import de.steamwar.command.TypeMapper;
|
||||
import de.steamwar.command.TypeValidator;
|
||||
@ -33,7 +33,6 @@ import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@UtilityClass
|
||||
public class TypeMappers {
|
||||
@ -48,7 +47,7 @@ public class TypeMappers {
|
||||
private static TypeValidator<ProxiedPlayer> arenaPlayer() {
|
||||
return (sender, value, messageSender) -> {
|
||||
ChatSender player = ChatSender.of(value);
|
||||
if (player.user().isPunishedWithMessage(player, Punishment.PunishmentType.NoFightServer)) {
|
||||
if (PunishmentCommand.isPunishedWithMessage(player, Punishment.PunishmentType.NoFightServer)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -21,7 +21,7 @@ package de.steamwar.bungeecore.commands;
|
||||
|
||||
import de.steamwar.bungeecore.Message;
|
||||
import de.steamwar.bungeecore.sql.IgnoreSystem;
|
||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
|
||||
|
@ -22,7 +22,7 @@ package de.steamwar.bungeecore.commands;
|
||||
import de.steamwar.bungeecore.BungeeCore;
|
||||
import de.steamwar.bungeecore.Message;
|
||||
import de.steamwar.bungeecore.bot.AuthManager;
|
||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import net.dv8tion.jda.api.entities.Member;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
|
@ -22,12 +22,10 @@ package de.steamwar.bungeecore.commands;
|
||||
import de.steamwar.bungeecore.Message;
|
||||
import de.steamwar.bungeecore.Storage;
|
||||
import de.steamwar.bungeecore.listeners.mods.Utils;
|
||||
import de.steamwar.bungeecore.sql.*;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import de.steamwar.command.SWCommandUtils;
|
||||
import de.steamwar.command.TypeMapper;
|
||||
import de.steamwar.sql.Team;
|
||||
import de.steamwar.sql.UserGroup;
|
||||
import de.steamwar.sql.*;
|
||||
import lombok.Getter;
|
||||
import net.md_5.bungee.BungeeCord;
|
||||
import net.md_5.bungee.api.CommandSender;
|
||||
@ -89,7 +87,7 @@ public class WhoisCommand extends SWCommand {
|
||||
if (!userGroup.isTeamGroup()) return;
|
||||
|
||||
if (userGroup.isAdminGroup()) {
|
||||
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_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());
|
||||
if (user.getDiscordId() != null) {
|
||||
Message.send("WHOIS_DISCORD_ID", player, user.getDiscordId());
|
||||
@ -104,20 +102,20 @@ public class WhoisCommand extends SWCommand {
|
||||
}
|
||||
Message.send("WHOIS_HOURS_PLAYED", player, new DecimalFormat("###.##").format(user.getOnlinetime() / 3600d));
|
||||
|
||||
if(BungeeCord.getInstance().getPlayer(user.getUuid()) != null) {
|
||||
ProxiedPlayer target = BungeeCord.getInstance().getPlayer(user.getUuid());
|
||||
if(BungeeCord.getInstance().getPlayer(user.getUUID()) != null) {
|
||||
ProxiedPlayer target = BungeeCord.getInstance().getPlayer(user.getUUID());
|
||||
Message.send("WHOIS_CURRENT_PLAYED", player, new DecimalFormat("####.##").format((Instant.now().getEpochSecond() - Storage.sessions.get(target).toInstant().getEpochSecond()) / 60d));
|
||||
Message.send("WHOIS_CURRENT_SERVER", player, target.getServer().getInfo().getName());
|
||||
Message.send("WHOIS_CURRENT_PROTOCOL", player, target.getPendingConnection().getVersion());
|
||||
}
|
||||
|
||||
if (Utils.playerModMap.containsKey(user.getUuid())) {
|
||||
Mod.Platform modPlatform = Utils.playerModMap.get(user.getUuid()).get(0).getPlatform();
|
||||
if (Utils.playerModMap.containsKey(user.getUUID())) {
|
||||
Mod.Platform modPlatform = Utils.playerModMap.get(user.getUUID()).get(0).getPlatform();
|
||||
Message.send("WHOIS_PLATFORM", player, modPlatform.toString());
|
||||
}
|
||||
|
||||
if (parameterTypes.contains(WhoisParameterTypes.MOD)) {
|
||||
List<Mod> activeMods = Utils.playerModMap.get(user.getUuid());
|
||||
List<Mod> activeMods = Utils.playerModMap.get(user.getUUID());
|
||||
|
||||
if (activeMods != null && !activeMods.isEmpty()) {
|
||||
Message.send("WHOIS_ACTIVE_MODS", player,activeMods.size());
|
||||
|
@ -21,7 +21,7 @@ package de.steamwar.bungeecore.inventory;
|
||||
|
||||
import de.steamwar.bungeecore.network.NetworkSender;
|
||||
import de.steamwar.bungeecore.network.handlers.InventoryCallbackHandler;
|
||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import de.steamwar.network.packets.server.CloseInventoryPacket;
|
||||
import de.steamwar.network.packets.server.InventoryPacket;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
@ -46,7 +46,7 @@ public class SWInventory {
|
||||
|
||||
public SWInventory(ProxiedPlayer proxiedPlayer, int size, String title) {
|
||||
itemMap = new HashMap<>();
|
||||
InventoryCallbackHandler.inventoryHashMap.put(SteamwarUser.get(proxiedPlayer).getId(), this);
|
||||
InventoryCallbackHandler.inventoryHashMap.put(SteamwarUser.get(proxiedPlayer.getUniqueId()).getId(), this);
|
||||
this.player = proxiedPlayer;
|
||||
this.size = size;
|
||||
this.title = title;
|
||||
@ -114,7 +114,7 @@ public class SWInventory {
|
||||
|
||||
public void handleClose() {
|
||||
if(processingClick.compareAndSet(false, true)) {
|
||||
InventoryCallbackHandler.inventoryHashMap.remove(SteamwarUser.get(player).getId(), this);
|
||||
InventoryCallbackHandler.inventoryHashMap.remove(SteamwarUser.get(player.getUniqueId()).getId(), this);
|
||||
if(close != null)
|
||||
close.clicked(null);
|
||||
processingClick.set(false);
|
||||
@ -122,7 +122,7 @@ public class SWInventory {
|
||||
}
|
||||
|
||||
public void open() {
|
||||
InventoryPacket inv = new InventoryPacket(title, SteamwarUser.get(player).getId(), size, map(itemMap, (integer, swItem) -> swItem.writeToString(integer).toString()));
|
||||
InventoryPacket inv = new InventoryPacket(title, SteamwarUser.get(player.getUniqueId()).getId(), size, map(itemMap, (integer, swItem) -> swItem.writeToString(integer).toString()));
|
||||
NetworkSender.send(player, inv);
|
||||
}
|
||||
|
||||
@ -137,7 +137,7 @@ public class SWInventory {
|
||||
}
|
||||
|
||||
public static void close(ProxiedPlayer player) {
|
||||
NetworkSender.send(player, new CloseInventoryPacket(SteamwarUser.get(player).getId()));
|
||||
NetworkSender.send(player, new CloseInventoryPacket(SteamwarUser.get(player.getUniqueId()).getId()));
|
||||
}
|
||||
|
||||
public void setClose(InvCallback close) {
|
||||
|
@ -21,16 +21,19 @@ package de.steamwar.bungeecore.listeners;
|
||||
|
||||
import de.steamwar.bungeecore.BungeeCore;
|
||||
import de.steamwar.bungeecore.Message;
|
||||
import de.steamwar.bungeecore.commands.PunishmentCommand;
|
||||
import de.steamwar.bungeecore.commands.WebpasswordCommand;
|
||||
import de.steamwar.bungeecore.listeners.mods.Forge;
|
||||
import de.steamwar.sql.BannedUserIPs;
|
||||
import de.steamwar.bungeecore.sql.Punishment;
|
||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||
import de.steamwar.sql.Punishment;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import de.steamwar.messages.ChatSender;
|
||||
import net.md_5.bungee.api.ProxyServer;
|
||||
import net.md_5.bungee.api.chat.ClickEvent;
|
||||
import net.md_5.bungee.api.chat.ComponentBuilder;
|
||||
import net.md_5.bungee.api.chat.HoverEvent;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
import net.md_5.bungee.api.connection.PendingConnection;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
import net.md_5.bungee.api.event.LoginEvent;
|
||||
import net.md_5.bungee.event.EventHandler;
|
||||
@ -45,16 +48,17 @@ public class BanListener extends BasicListener {
|
||||
public void onLogin(LoginEvent event) {
|
||||
event.registerIntent(BungeeCore.get());
|
||||
ProxyServer.getInstance().getScheduler().runAsync(BungeeCore.get(), () -> {
|
||||
SteamwarUser user = SteamwarUser.getOrCreate(event.getConnection());
|
||||
PendingConnection connection = event.getConnection();
|
||||
SteamwarUser user = SteamwarUser.getOrCreate(connection.getUniqueId(), connection.getName(), ConnectionListener::newPlayer, WebpasswordCommand::changeUsername);
|
||||
if (user.isPunished(Punishment.PunishmentType.Ban)) {
|
||||
user.updateBanIP(event.getConnection().getAddress().getAddress().getHostAddress());
|
||||
event.setCancelled(true);
|
||||
ChatSender.of(event).system(user.punishmentMessage(Punishment.PunishmentType.Ban));
|
||||
BannedUserIPs.banIP(user.getId(), connection.getAddress().getAddress().getHostAddress());
|
||||
ChatSender.of(event).system(PunishmentCommand.punishmentMessage(user, Punishment.PunishmentType.Ban));
|
||||
event.completeIntent(BungeeCore.get());
|
||||
return;
|
||||
}
|
||||
|
||||
List<BannedUserIPs> ips = BannedUserIPs.get(event.getConnection().getAddress().getAddress().getHostAddress());
|
||||
List<BannedUserIPs> ips = BannedUserIPs.get(connection.getAddress().getAddress().getHostAddress());
|
||||
if(!ips.isEmpty()){
|
||||
|
||||
Timestamp highestBan = ips.get(0).getTimestamp();
|
||||
|
@ -21,11 +21,14 @@ package de.steamwar.bungeecore.listeners;
|
||||
|
||||
import de.steamwar.bungeecore.*;
|
||||
import de.steamwar.bungeecore.bot.SteamwarDiscordBot;
|
||||
import de.steamwar.bungeecore.commands.PunishmentCommand;
|
||||
import de.steamwar.bungeecore.network.NetworkSender;
|
||||
import de.steamwar.bungeecore.sql.*;
|
||||
import de.steamwar.bungeecore.util.Chat19;
|
||||
import de.steamwar.messages.ChatSender;
|
||||
import de.steamwar.network.packets.server.PingPacket;
|
||||
import de.steamwar.sql.Punishment;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import de.steamwar.sql.Team;
|
||||
import de.steamwar.sql.UserGroup;
|
||||
import net.md_5.bungee.api.*;
|
||||
@ -39,6 +42,7 @@ import net.md_5.bungee.event.EventHandler;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.logging.Level;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
@ -61,7 +65,9 @@ public class ChatListener extends BasicListener {
|
||||
e.setCancelled(true);
|
||||
|
||||
if (message.contains("jndi:ldap")) {
|
||||
SteamwarUser.get(player).punishPerma(Punishment.PunishmentType.Ban, "Versuchte Exploit-Ausnutzung", 0);
|
||||
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
|
||||
PunishmentCommand.ban(user, Punishment.PERMA_TIME, "Versuchte Exploit-Ausnutzung", SteamwarUser.get(-1), true);
|
||||
BungeeCore.log(Level.SEVERE, user.getUserName() + " " + user.getId() + " wurde automatisch wegen jndi:ldap gebannt.");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -155,7 +161,7 @@ public class ChatListener extends BasicListener {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (user.isPunishedWithMessage(sender, Punishment.PunishmentType.Mute))
|
||||
if (PunishmentCommand.isPunishedWithMessage(sender, Punishment.PunishmentType.Mute))
|
||||
return true;
|
||||
|
||||
if (message.contains("LIXFEL"))
|
||||
@ -204,7 +210,7 @@ public class ChatListener extends BasicListener {
|
||||
String mark = "@" + player.user().getUserName();
|
||||
return Arrays.stream(message.split(" ")).map(cur -> {
|
||||
if(cur.equalsIgnoreCase(mark)) {
|
||||
NetworkSender.send(player.user().getPlayer(), new PingPacket(player.user().getId()));
|
||||
NetworkSender.send(ProxyServer.getInstance().getPlayer(player.user().getUUID()), new PingPacket(player.user().getId()));
|
||||
return "§e" + cur + returnColor;
|
||||
}
|
||||
return cur;
|
||||
|
@ -23,7 +23,7 @@ import de.steamwar.bungeecore.*;
|
||||
import de.steamwar.bungeecore.commands.CheckCommand;
|
||||
import de.steamwar.bungeecore.sql.SchematicNode;
|
||||
import de.steamwar.sql.SchematicType;
|
||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
import net.md_5.bungee.api.event.PlayerDisconnectEvent;
|
||||
import net.md_5.bungee.api.event.PostLoginEvent;
|
||||
|
@ -30,7 +30,7 @@ import de.steamwar.bungeecore.commands.CheckCommand;
|
||||
import de.steamwar.bungeecore.commands.ModCommand;
|
||||
import de.steamwar.bungeecore.commands.MsgCommand;
|
||||
import de.steamwar.bungeecore.listeners.mods.Utils;
|
||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import de.steamwar.sql.UserGroup;
|
||||
import net.md_5.bungee.api.AbstractReconnectHandler;
|
||||
import net.md_5.bungee.api.ProxyServer;
|
||||
|
@ -1,8 +1,8 @@
|
||||
package de.steamwar.bungeecore.listeners;
|
||||
|
||||
import de.steamwar.bungeecore.Message;
|
||||
import de.steamwar.bungeecore.sql.EventFight;
|
||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||
import de.steamwar.sql.EventFight;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import de.steamwar.sql.TeamTeilnahme;
|
||||
import de.steamwar.sql.Event;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
|
@ -21,7 +21,7 @@ package de.steamwar.bungeecore.listeners;
|
||||
|
||||
import de.steamwar.bungeecore.Message;
|
||||
import de.steamwar.sql.PollAnswer;
|
||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import net.md_5.bungee.api.chat.ClickEvent;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
import net.md_5.bungee.api.event.PostLoginEvent;
|
||||
|
@ -21,7 +21,7 @@ package de.steamwar.bungeecore.listeners;
|
||||
|
||||
import de.steamwar.bungeecore.BungeeCore;
|
||||
import de.steamwar.sql.Session;
|
||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import net.md_5.bungee.api.ProxyServer;
|
||||
import net.md_5.bungee.api.event.PlayerDisconnectEvent;
|
||||
import net.md_5.bungee.api.event.PostLoginEvent;
|
||||
@ -43,7 +43,7 @@ public class SessionManager extends BasicListener {
|
||||
public void onDisconnect(PlayerDisconnectEvent e){
|
||||
Timestamp timestamp = sessions.remove(e.getPlayer());
|
||||
if(timestamp != null) {
|
||||
ProxyServer.getInstance().getScheduler().runAsync(BungeeCore.get(), () -> Session.insertSession(SteamwarUser.get(e.getPlayer()).getId(), timestamp));
|
||||
ProxyServer.getInstance().getScheduler().runAsync(BungeeCore.get(), () -> Session.insertSession(SteamwarUser.get(e.getPlayer().getUniqueId()).getId(), timestamp));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -20,7 +20,9 @@
|
||||
package de.steamwar.bungeecore.listeners;
|
||||
|
||||
import de.steamwar.bungeecore.BungeeCore;
|
||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||
import de.steamwar.bungeecore.network.NetworkSender;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import de.steamwar.network.packets.server.LocaleInvalidationPacket;
|
||||
import net.md_5.bungee.BungeeCord;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
import net.md_5.bungee.api.event.SettingsChangedEvent;
|
||||
@ -32,7 +34,9 @@ public class SettingsChangedListener extends BasicListener {
|
||||
public void onSettingsChanged(SettingsChangedEvent event) {
|
||||
BungeeCord.getInstance().getScheduler().runAsync(BungeeCore.get(), () -> {
|
||||
ProxiedPlayer player = event.getPlayer();
|
||||
SteamwarUser.get(player).setLocale(player.getLocale(), false);
|
||||
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
|
||||
user.setLocale(player.getLocale(), false);
|
||||
NetworkSender.send(player, new LocaleInvalidationPacket(user.getId()));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -27,9 +27,9 @@ import de.steamwar.bungeecore.BungeeCore;
|
||||
import de.steamwar.bungeecore.Message;
|
||||
import de.steamwar.bungeecore.Storage;
|
||||
import de.steamwar.bungeecore.listeners.BasicListener;
|
||||
import de.steamwar.bungeecore.sql.Mod;
|
||||
import de.steamwar.sql.Mod;
|
||||
import de.steamwar.sql.SWException;
|
||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import net.md_5.bungee.BungeeCord;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
import net.md_5.bungee.api.event.PluginMessageEvent;
|
||||
@ -58,7 +58,7 @@ public class Fabric extends BasicListener {
|
||||
continue;
|
||||
}
|
||||
if (System.currentTimeMillis() - entry.getValue() > TimeUnit.SECONDS.toMillis(20)) {
|
||||
logMessage(SteamwarUser.get(entry.getKey()), "Expected message not received", String.valueOf(entry.getValue()));
|
||||
logMessage(SteamwarUser.get(entry.getKey().getUniqueId()), "Expected message not received", String.valueOf(entry.getValue()));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ package de.steamwar.bungeecore.listeners.mods;
|
||||
|
||||
import de.steamwar.bungeecore.BungeeCore;
|
||||
import de.steamwar.bungeecore.listeners.BasicListener;
|
||||
import de.steamwar.bungeecore.sql.Mod;
|
||||
import de.steamwar.sql.Mod;
|
||||
import io.netty.channel.ChannelPipeline;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
import net.md_5.bungee.api.connection.PendingConnection;
|
||||
|
@ -21,7 +21,7 @@ package de.steamwar.bungeecore.listeners.mods;
|
||||
|
||||
import de.steamwar.bungeecore.BungeeCore;
|
||||
import de.steamwar.bungeecore.listeners.BasicListener;
|
||||
import de.steamwar.bungeecore.sql.Mod;
|
||||
import de.steamwar.sql.Mod;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.UnpooledByteBufAllocator;
|
||||
import net.md_5.bungee.api.ProxyServer;
|
||||
|
@ -23,7 +23,7 @@ import com.google.gson.JsonObject;
|
||||
import com.google.gson.stream.JsonReader;
|
||||
import de.steamwar.bungeecore.BungeeCore;
|
||||
import de.steamwar.bungeecore.listeners.BasicListener;
|
||||
import de.steamwar.bungeecore.sql.Mod;
|
||||
import de.steamwar.sql.Mod;
|
||||
import net.md_5.bungee.api.ProxyServer;
|
||||
import net.md_5.bungee.api.connection.Connection;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
|
@ -21,11 +21,11 @@ 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.Punishment;
|
||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||
import de.steamwar.bungeecore.commands.PunishmentCommand;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import de.steamwar.messages.ChatSender;
|
||||
import de.steamwar.sql.Mod;
|
||||
import de.steamwar.sql.Mod.ModType;
|
||||
import net.md_5.bungee.api.chat.BaseComponent;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
@ -97,7 +97,7 @@ public class Utils {
|
||||
}
|
||||
|
||||
if(max == ModType.RED) {
|
||||
user.punish(Punishment.PunishmentType.Ban, Timestamp.from(Instant.now().plus(7, ChronoUnit.DAYS)), message, 0, false);
|
||||
PunishmentCommand.ban(user, Timestamp.from(Instant.now().plus(7, ChronoUnit.DAYS)), message, SteamwarUser.get(-1), false);
|
||||
BungeeCore.log(Level.SEVERE, user.getUserName() + " " + user.getId() + " wurde automatisch wegen der Mods " + modList + " gebannt.");
|
||||
}
|
||||
|
||||
|
@ -3,7 +3,7 @@ package de.steamwar.bungeecore.listeners.mods;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Sets;
|
||||
import de.steamwar.bungeecore.listeners.BasicListener;
|
||||
import de.steamwar.bungeecore.sql.Mod;
|
||||
import de.steamwar.sql.Mod;
|
||||
import net.md_5.bungee.api.connection.Connection;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
import net.md_5.bungee.api.event.PluginMessageEvent;
|
||||
|
@ -19,7 +19,7 @@
|
||||
|
||||
package de.steamwar.bungeecore.network.handlers;
|
||||
|
||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import de.steamwar.network.packets.PacketHandler;
|
||||
import de.steamwar.network.packets.client.ExecuteCommandPacket;
|
||||
import net.md_5.bungee.api.ProxyServer;
|
||||
@ -31,6 +31,6 @@ public class ExecuteCommandHandler extends PacketHandler {
|
||||
SteamwarUser target = SteamwarUser.get(packet.getPlayerId());
|
||||
String command = packet.getCommand();
|
||||
|
||||
ProxyServer.getInstance().getPluginManager().dispatchCommand(ProxyServer.getInstance().getPlayer(target.getUuid()), command);
|
||||
ProxyServer.getInstance().getPluginManager().dispatchCommand(ProxyServer.getInstance().getPlayer(target.getUUID()), command);
|
||||
}
|
||||
}
|
||||
|
@ -23,7 +23,9 @@ import de.steamwar.bungeecore.ArenaMode;
|
||||
import de.steamwar.bungeecore.sql.*;
|
||||
import de.steamwar.network.packets.PacketHandler;
|
||||
import de.steamwar.network.packets.common.FightEndsPacket;
|
||||
import de.steamwar.sql.SchemElo;
|
||||
import de.steamwar.sql.SchematicType;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
import java.util.*;
|
||||
@ -91,8 +93,8 @@ public class FightEndsHandler extends PacketHandler {
|
||||
gameModeGames.computeIfAbsent(fightEndsPacket.getGameMode(), s -> new LinkedList<>()).add(new Game(fightEndsPacket.getBluePlayers(), fightEndsPacket.getRedPlayers()));
|
||||
}
|
||||
|
||||
int blueSchemElo = SchemElo.getElo(fightEndsPacket.getBlueSchem());
|
||||
int redSchemElo = SchemElo.getElo(fightEndsPacket.getRedSchem());
|
||||
int blueSchemElo = SchemElo.getCurrentElo(fightEndsPacket.getBlueSchem());
|
||||
int redSchemElo = SchemElo.getCurrentElo(fightEndsPacket.getRedSchem());
|
||||
|
||||
int blueTeamElo = fightEndsPacket.getBluePlayers().stream().mapToInt(player -> UserElo.getEloOrDefault(player, fightEndsPacket.getGameMode())).sum();
|
||||
int redTeamElo = fightEndsPacket.getRedPlayers().stream().mapToInt(player -> UserElo.getEloOrDefault(player, fightEndsPacket.getGameMode())).sum();
|
||||
|
@ -22,15 +22,13 @@ package de.steamwar.bungeecore.network.handlers;
|
||||
import de.steamwar.bungeecore.BungeeCore;
|
||||
import de.steamwar.bungeecore.inventory.InvCallback;
|
||||
import de.steamwar.bungeecore.inventory.SWInventory;
|
||||
import de.steamwar.bungeecore.network.NetworkReceiver;
|
||||
import de.steamwar.bungeecore.network.NetworkSender;
|
||||
import de.steamwar.bungeecore.network.ServerMetaInfo;
|
||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import de.steamwar.network.packets.PacketHandler;
|
||||
import de.steamwar.network.packets.client.InventoryCallbackPacket;
|
||||
import de.steamwar.network.packets.server.CloseInventoryPacket;
|
||||
import net.md_5.bungee.api.ProxyServer;
|
||||
import net.md_5.bungee.api.config.ServerInfo;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
@ -44,7 +42,7 @@ public class InventoryCallbackHandler extends PacketHandler {
|
||||
SteamwarUser owner = SteamwarUser.get(packet.getOwner());
|
||||
InventoryCallbackPacket.CallbackType type = packet.getType();
|
||||
if(!inventoryHashMap.containsKey(owner.getId())) {
|
||||
BungeeCore.send(ProxyServer.getInstance().getPlayer(owner.getUuid()), BungeeCore.CHAT_PREFIX + "§cBitte erneut versuchen. Durch ein Softwareupdate konnte die übliche Aktion nicht durchgeführt werden.");
|
||||
BungeeCore.send(ProxyServer.getInstance().getPlayer(owner.getUUID()), BungeeCore.CHAT_PREFIX + "§cBitte erneut versuchen. Durch ein Softwareupdate konnte die übliche Aktion nicht durchgeführt werden.");
|
||||
if(type == InventoryCallbackPacket.CallbackType.CLICK) {
|
||||
NetworkSender.send(((ServerMetaInfo) packet.getMetaInfos()).getSender(), new CloseInventoryPacket(owner.getId()));
|
||||
}
|
||||
|
@ -22,7 +22,7 @@ package de.steamwar.bungeecore.network.handlers;
|
||||
import de.steamwar.bungeecore.ArenaMode;
|
||||
import de.steamwar.bungeecore.ServerStarter;
|
||||
import de.steamwar.sql.SchematicType;
|
||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import de.steamwar.network.packets.PacketHandler;
|
||||
import de.steamwar.network.packets.client.PrepareSchemPacket;
|
||||
import net.md_5.bungee.api.ProxyServer;
|
||||
@ -32,7 +32,7 @@ public class PrepareSchemHandler extends PacketHandler {
|
||||
|
||||
@Handler
|
||||
public void handle(PrepareSchemPacket packet) {
|
||||
ProxiedPlayer player = ProxyServer.getInstance().getPlayer(SteamwarUser.get(packet.getPlayer()).getUuid());
|
||||
ProxiedPlayer player = ProxyServer.getInstance().getPlayer(SteamwarUser.get(packet.getPlayer()).getUUID());
|
||||
int schematicID = packet.getSchem();
|
||||
ArenaMode mode = ArenaMode.getBySchemType(SchematicType.fromDB(packet.getSchemType()));
|
||||
|
||||
|
@ -19,6 +19,7 @@
|
||||
|
||||
package de.steamwar.bungeecore.sql;
|
||||
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import de.steamwar.sql.internal.Statement;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
|
@ -1,150 +0,0 @@
|
||||
/*
|
||||
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.sql.internal.Statement;
|
||||
import de.steamwar.bungeecore.ArenaMode;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Timestamp;
|
||||
import java.util.*;
|
||||
|
||||
import static java.time.temporal.ChronoUnit.SECONDS;
|
||||
|
||||
public class EventFight implements Comparable<EventFight> {
|
||||
|
||||
private static final Statement reschedule = new Statement("UPDATE EventFight SET StartTime = ? WHERE EventID = ? AND FightID = ?");
|
||||
private static final Statement allComing = new Statement("SELECT * FROM EventFight WHERE StartTime > now() ORDER BY `StartTime` ASC");
|
||||
private static final Statement event = new Statement("SELECT * FROM EventFight WHERE EventID = ? ORDER BY `StartTime` ASC");
|
||||
|
||||
private static final Queue<EventFight> fights = new PriorityQueue<>();
|
||||
|
||||
private final int eventID;
|
||||
private final int fightID;
|
||||
private Timestamp startTime;
|
||||
private final ArenaMode spielmodus;
|
||||
private final String map;
|
||||
private final int teamBlue;
|
||||
private final int teamRed;
|
||||
private final int kampfleiter;
|
||||
private final int ergebnis;
|
||||
private final int fight;
|
||||
|
||||
private EventFight(ResultSet rs) throws SQLException {
|
||||
eventID = rs.getInt("EventID");
|
||||
fightID = rs.getInt("FightID");
|
||||
startTime = rs.getTimestamp("StartTime");
|
||||
spielmodus = ArenaMode.getByInternal(rs.getString("Spielmodus"));
|
||||
map = rs.getString("Map");
|
||||
teamBlue = rs.getInt("TeamBlue");
|
||||
teamRed = rs.getInt("TeamRed");
|
||||
kampfleiter = rs.getInt("Kampfleiter");
|
||||
ergebnis = rs.getInt("Ergebnis");
|
||||
fight = rs.getInt("Fight");
|
||||
}
|
||||
|
||||
public void reschedule(){
|
||||
startTime = Timestamp.from(new Date().toInstant().plus(30, SECONDS));
|
||||
reschedule.update(startTime, eventID, fightID);
|
||||
}
|
||||
|
||||
public static void loadAllComingFights(){
|
||||
allComing.select(rs -> {
|
||||
fights.clear();
|
||||
while(rs.next()){
|
||||
fights.add(new EventFight(rs));
|
||||
}
|
||||
return null;
|
||||
});
|
||||
}
|
||||
|
||||
public static List<EventFight> getEvent(int eventID){
|
||||
return event.select(rs -> {
|
||||
List<EventFight> fights = new LinkedList<>();
|
||||
while(rs.next())
|
||||
fights.add(new EventFight(rs));
|
||||
return fights;
|
||||
}, eventID);
|
||||
}
|
||||
|
||||
public static Queue<EventFight> getFights() {
|
||||
return fights;
|
||||
}
|
||||
|
||||
public Timestamp getStartTime() {
|
||||
return startTime;
|
||||
}
|
||||
|
||||
public ArenaMode getSpielmodus() {
|
||||
return spielmodus;
|
||||
}
|
||||
|
||||
public String getMap() {
|
||||
return map;
|
||||
}
|
||||
|
||||
public int getTeamBlue() {
|
||||
return teamBlue;
|
||||
}
|
||||
|
||||
public int getTeamRed() {
|
||||
return teamRed;
|
||||
}
|
||||
|
||||
public int getEventID() {
|
||||
return eventID;
|
||||
}
|
||||
|
||||
public int getFightID() {
|
||||
return fightID;
|
||||
}
|
||||
|
||||
public int getKampfleiter() {
|
||||
return kampfleiter;
|
||||
}
|
||||
|
||||
public int getErgebnis() {
|
||||
return ergebnis;
|
||||
}
|
||||
|
||||
public boolean hasFinished() {
|
||||
return fight != 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode(){
|
||||
return fightID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o){
|
||||
if(o == null)
|
||||
return false;
|
||||
if(!(o instanceof EventFight))
|
||||
return false;
|
||||
return fightID == ((EventFight) o).fightID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(EventFight o) {
|
||||
return startTime.compareTo(o.startTime);
|
||||
}
|
||||
}
|
@ -1,145 +0,0 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2023 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.sql.FightPlayer;
|
||||
import de.steamwar.sql.SchematicType;
|
||||
import de.steamwar.sql.internal.Statement;
|
||||
import de.steamwar.bungeecore.ArenaMode;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Timestamp;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class Fight {
|
||||
|
||||
private static final Statement getPage = new Statement("SELECT f.FightID, f.GameMode, f.Server, f.StartTime, f.BlueLeader, f.RedLeader, (b.NodeId IS NULL OR b.AllowReplay) AND (r.NodeId IS NULL OR r.AllowReplay) AS ReplayAllowed, f.Win, (SELECT COUNT(1) FROM Replay WHERE Replay.FightID = f.FightID) as ReplayAvailable FROM Fight f LEFT OUTER JOIN SchematicNode b ON f.BlueSchem = b.NodeId LEFT OUTER JOIN SchematicNode r ON f.RedSchem = r.NodeId ORDER BY FightID DESC LIMIT ?, ?");
|
||||
|
||||
private final int fightID;
|
||||
private final String gameMode;
|
||||
private final String server;
|
||||
private final Timestamp startTime;
|
||||
|
||||
private final int blueLeader;
|
||||
private final int redLeader;
|
||||
private final int win;
|
||||
|
||||
private final boolean replayAllowed;
|
||||
private final boolean replayAvailable;
|
||||
|
||||
private final List<FightPlayer> bluePlayers = new ArrayList<>();
|
||||
private final List<FightPlayer> redPlayers = new ArrayList<>();
|
||||
|
||||
private Fight(ResultSet rs) throws SQLException {
|
||||
fightID = rs.getInt("FightID");
|
||||
gameMode = rs.getString("GameMode");
|
||||
server = rs.getString("Server");
|
||||
startTime = rs.getTimestamp("StartTime");
|
||||
blueLeader = rs.getInt("BlueLeader");
|
||||
redLeader = rs.getInt("RedLeader");
|
||||
replayAllowed = rs.getBoolean("ReplayAllowed");
|
||||
replayAvailable = rs.getBoolean("ReplayAvailable");
|
||||
win = rs.getInt("Win");
|
||||
}
|
||||
|
||||
private void initPlayers(List<FightPlayer> fightPlayers) {
|
||||
for(FightPlayer fp : fightPlayers) {
|
||||
if(fp.getFightID() != fightID)
|
||||
continue;
|
||||
|
||||
if(fp.getTeam() == 1)
|
||||
bluePlayers.add(fp);
|
||||
else
|
||||
redPlayers.add(fp);
|
||||
}
|
||||
}
|
||||
|
||||
public static List<Fight> getPage(int page, int elementsPerPage) {
|
||||
List<Fight> fights = getPage.select(rs -> {
|
||||
List<Fight> f = new ArrayList<>();
|
||||
while(rs.next()){
|
||||
f.add(new Fight(rs));
|
||||
}
|
||||
return f;
|
||||
}, page * elementsPerPage, elementsPerPage);
|
||||
|
||||
List<FightPlayer> fightPlayers = FightPlayer.batchGet(fights.stream().map(f -> f.fightID).toArray(Integer[]::new));
|
||||
for(Fight fight : fights) {
|
||||
fight.initPlayers(fightPlayers);
|
||||
}
|
||||
|
||||
de.steamwar.bungeecore.sql.SteamwarUser.batchCache(fightPlayers.stream().map(FightPlayer::getUserID).collect(Collectors.toSet()));
|
||||
return fights;
|
||||
}
|
||||
|
||||
public SchematicType getSchemType() {
|
||||
return SchematicType.fromDB(gameMode);
|
||||
}
|
||||
|
||||
public ArenaMode getGameMode() {
|
||||
SchematicType schemType = getSchemType();
|
||||
if(schemType == null)
|
||||
return null;
|
||||
return ArenaMode.getBySchemType(schemType);
|
||||
}
|
||||
|
||||
public int getFightID() {
|
||||
return fightID;
|
||||
}
|
||||
|
||||
public Timestamp getStartTime() {
|
||||
return startTime;
|
||||
}
|
||||
|
||||
public de.steamwar.bungeecore.sql.SteamwarUser getBlueLeader() {
|
||||
return de.steamwar.bungeecore.sql.SteamwarUser.get(blueLeader);
|
||||
}
|
||||
|
||||
public de.steamwar.bungeecore.sql.SteamwarUser getRedLeader() {
|
||||
return SteamwarUser.get(redLeader);
|
||||
}
|
||||
|
||||
public int getWin() {
|
||||
return win;
|
||||
}
|
||||
|
||||
public String getServer() {
|
||||
return server;
|
||||
}
|
||||
|
||||
public List<FightPlayer> getBluePlayers() {
|
||||
return bluePlayers;
|
||||
}
|
||||
|
||||
public List<FightPlayer> getRedPlayers() {
|
||||
return redPlayers;
|
||||
}
|
||||
|
||||
public boolean replayAllowed() {
|
||||
return replayExists() && replayAllowed;
|
||||
}
|
||||
|
||||
public boolean replayExists() {
|
||||
return getGameMode() != null && replayAvailable;
|
||||
}
|
||||
}
|
@ -19,6 +19,7 @@
|
||||
|
||||
package de.steamwar.bungeecore.sql;
|
||||
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import de.steamwar.sql.internal.Statement;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
|
||||
|
@ -1,127 +0,0 @@
|
||||
/*
|
||||
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.sql.internal.Statement;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class Mod {
|
||||
|
||||
private static final Statement get = new Statement("SELECT * FROM Mods WHERE ModName = ? AND Platform = ?");
|
||||
private static final Statement insert = new Statement("INSERT INTO Mods (ModName, Platform) VALUES (?, ?)");
|
||||
|
||||
private static final Statement set = new Statement("UPDATE Mods Set ModType = ? WHERE ModName = ? AND Platform = ?");
|
||||
private static final Statement findFirst = new Statement("SELECT * FROM Mods WHERE ModType = 0 LIMIT 1");
|
||||
|
||||
private static final Statement getPageOfType = new Statement("SELECT * FROM Mods WHERE ModType = ? ORDER BY ModName DESC LIMIT ?, ?");
|
||||
|
||||
private final String modName;
|
||||
private final Platform platform;
|
||||
private final ModType modType;
|
||||
|
||||
private Mod(String modName, Platform platform, ModType modType) {
|
||||
this.modName = modName;
|
||||
this.platform = platform;
|
||||
this.modType = modType;
|
||||
}
|
||||
|
||||
private Mod(ResultSet resultSet) throws SQLException {
|
||||
this(resultSet.getString("ModName"), Mod.Platform.values()[resultSet.getInt("Platform")], ModType.values()[resultSet.getInt("ModType")]);
|
||||
}
|
||||
|
||||
public static Mod get(String name, Platform platform) {
|
||||
return get.select(rs -> {
|
||||
if(rs.next())
|
||||
return new Mod(rs);
|
||||
return null;
|
||||
}, name, platform.ordinal());
|
||||
}
|
||||
|
||||
public static Mod getOrCreate(String name, Platform platform) {
|
||||
Mod mod = get(name, platform);
|
||||
if(mod != null)
|
||||
return mod;
|
||||
|
||||
insert.update(name, platform.ordinal());
|
||||
return new Mod(name, platform, ModType.UNKLASSIFIED);
|
||||
}
|
||||
|
||||
public void setModType(Mod.ModType newModType) {
|
||||
set.update(newModType.ordinal(), modName, platform.ordinal());
|
||||
}
|
||||
|
||||
public static List<Mod> getAllModsFiltered(int page,int elementsPerPage, Mod.ModType filter) {
|
||||
return Mod.getPageOfType.select(rs -> {
|
||||
List<Mod> f = new ArrayList<>();
|
||||
|
||||
while(rs.next())
|
||||
f.add(new Mod(rs));
|
||||
|
||||
return f;
|
||||
},filter.ordinal(), page * elementsPerPage, elementsPerPage);
|
||||
}
|
||||
|
||||
public static Mod findFirstMod() {
|
||||
return findFirst.select(rs -> {
|
||||
if(rs.next())
|
||||
return new Mod(rs);
|
||||
return null;
|
||||
});
|
||||
}
|
||||
|
||||
public String getModName() {
|
||||
return modName;
|
||||
}
|
||||
|
||||
public Platform getPlatform() {
|
||||
return platform;
|
||||
}
|
||||
|
||||
public ModType getModType() {
|
||||
return modType;
|
||||
}
|
||||
|
||||
public enum Platform{
|
||||
FORGE,
|
||||
LABYMOD,
|
||||
FABRIC
|
||||
}
|
||||
|
||||
public enum ModType {
|
||||
UNKLASSIFIED("7"),
|
||||
GREEN("a"),
|
||||
YELLOW("e"),
|
||||
RED("c"),
|
||||
YOUTUBER_ONLY("6");
|
||||
|
||||
ModType(String colorcode) {
|
||||
this.colorcode = colorcode;
|
||||
}
|
||||
private final String colorcode;
|
||||
|
||||
public String getColorCode() {
|
||||
return colorcode;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,86 +0,0 @@
|
||||
/*
|
||||
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.sql.internal.Statement;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
public class NodeMember {
|
||||
private static final Statement getNodeMember = new Statement("SELECT * FROM NodeMember WHERE NodeId = ? AND UserId = ?");
|
||||
private static final Statement getNodeMembers = new Statement("SELECT * FROM NodeMember WHERE NodeId = ?");
|
||||
private static final Statement getSchematics = new Statement("SELECT * FROM NodeMember WHERE UserId = ?");
|
||||
private static final Statement createNodeMember = new Statement("INSERT INTO NodeMember (NodeId, UserId) VALUES (?, ?)");
|
||||
private static final Statement deleteNodeMember = new Statement("DELETE FROM NodeMember WHERE NodeId = ? AND UserId = ?");
|
||||
|
||||
public static NodeMember getNodeMember(int node, int member) {
|
||||
return getNodeMember.select(rs -> {
|
||||
if(!rs.next())
|
||||
return null;
|
||||
return new NodeMember(rs);
|
||||
}, node, member);
|
||||
}
|
||||
|
||||
public static Set<NodeMember> getNodeMembers(int node) {
|
||||
return getNodeMembers.select(rs -> {
|
||||
Set<NodeMember> members = new HashSet<>();
|
||||
while (rs.next())
|
||||
members.add(new NodeMember(rs));
|
||||
return members;
|
||||
}, node);
|
||||
}
|
||||
|
||||
public static Set<NodeMember> getSchematics(int member) {
|
||||
return getSchematics.select(rs -> {
|
||||
Set<NodeMember> members = new HashSet<>();
|
||||
while (rs.next())
|
||||
members.add(new NodeMember(rs));
|
||||
return members;
|
||||
}, member);
|
||||
}
|
||||
|
||||
public static NodeMember createNodeMember(int node, int member) {
|
||||
createNodeMember.update(node, member);
|
||||
return getNodeMember(node, member);
|
||||
}
|
||||
|
||||
final int node;
|
||||
final int member;
|
||||
|
||||
private NodeMember(ResultSet set) throws SQLException {
|
||||
node = set.getInt("NodeId");
|
||||
member = set.getInt("UserId");
|
||||
}
|
||||
|
||||
public int getNode() {
|
||||
return node;
|
||||
}
|
||||
|
||||
public int getMember() {
|
||||
return member;
|
||||
}
|
||||
|
||||
public void delete() {
|
||||
deleteNodeMember.update(node, member);
|
||||
}
|
||||
}
|
@ -1,160 +0,0 @@
|
||||
/*
|
||||
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.sql.internal.Statement;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Timestamp;
|
||||
import java.time.Instant;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.*;
|
||||
|
||||
public class Punishment {
|
||||
|
||||
private static final Statement getPunishment = new Statement("SELECT * FROM Punishments WHERE UserId = ? AND Type = ? ORDER BY PunishmentId DESC LIMIT 1");
|
||||
private static final Statement getPunishments = new Statement("SELECT * FROM Punishments WHERE PunishmentId IN (SELECT MAX(PunishmentId) FROM Punishments WHERE UserId = ? GROUP BY Type)");
|
||||
private static final Statement getAllPunishments = new Statement("SELECT * FROM Punishments WHERE UserId = ? ORDER BY `PunishmentId` DESC");
|
||||
private static final Statement insert = new Statement("INSERT INTO Punishments (UserId, Punisher, Type, Reason, EndTime, Perma) VALUES (?, ?, ?, ?, ?, ?)");
|
||||
|
||||
public static final Timestamp PERMA_TIME = Timestamp.from(Instant.ofEpochSecond(946674800));
|
||||
|
||||
public static Punishment getPunishmentOfPlayer(int user, PunishmentType type) {
|
||||
return getPunishment.select(rs -> {
|
||||
if (rs.next())
|
||||
return new Punishment(rs);
|
||||
return null;
|
||||
}, user, type.name());
|
||||
}
|
||||
|
||||
public static Map<PunishmentType, Punishment> getPunishmentsOfPlayer(int user) {
|
||||
return getPunishments.select(rs -> {
|
||||
Map<PunishmentType, Punishment> punishments = new HashMap<>();
|
||||
while (rs.next())
|
||||
punishments.put(PunishmentType.valueOf(rs.getString("Type")), new Punishment(rs));
|
||||
return punishments;
|
||||
}, user);
|
||||
}
|
||||
|
||||
public static List<Punishment> getAllPunishmentsOfPlayer(int user) {
|
||||
return getAllPunishments.select(rs -> {
|
||||
List<Punishment> punishments = new ArrayList<>();
|
||||
while (rs.next())
|
||||
punishments.add(new Punishment(rs));
|
||||
return punishments;
|
||||
}, user);
|
||||
}
|
||||
|
||||
public static Punishment createPunishment(int user, int executor, PunishmentType type, String reason, Timestamp endTime, boolean perma) {
|
||||
if(perma && !endTime.equals(PERMA_TIME)) {
|
||||
throw new IllegalArgumentException("Permanent punishments must have an end time of `Punishment.PERMA_TIME`");
|
||||
}
|
||||
insert.update(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 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());
|
||||
}
|
||||
|
||||
@AllArgsConstructor
|
||||
@RequiredArgsConstructor
|
||||
@Getter
|
||||
public enum PunishmentType {
|
||||
Ban(false, "BAN_TEAM", "BAN_PERMA", "BAN_UNTIL", "UNBAN_ERROR", "UNBAN"),
|
||||
Mute( false, "MUTE_TEAM", "MUTE_PERMA", "MUTE_UNTIL", "UNMUTE_ERROR", "UNMUTE"),
|
||||
NoSchemReceiving(false, "NOSCHEMRECEIVING_TEAM", "NOSCHEMRECEIVING_PERMA", "NOSCHEMRECEIVING_UNTIL", "UNNOSCHEMRECEIVING_ERROR", "UNNOSCHEMRECEIVING"),
|
||||
NoSchemSharing(false, "NOSCHEMSHARING_TEAM", "NOSCHEMSHARING_PERMA", "NOSCHEMSHARING_UNTIL", "UNNOSCHEMSHARING_ERROR", "UNNOSCHEMSHARING"),
|
||||
NoSchemSubmitting(true, "NOSCHEMSUBMITTING_TEAM", "NOSCHEMSUBMITTING_PERMA", "NOSCHEMSUBMITTING_UNTIL", "UNNOSCHEMSUBMITTING_ERROR", "UNNOSCHEMSUBMITTING"),
|
||||
NoDevServer(true, "NODEVSERVER_TEAM", "NODEVSERVER_PERMA", "NODEVSERVER_UNTIL", "UNNODEVSERVER_ERROR", "UNNODEVSERVER"),
|
||||
NoFightServer(false, "NOFIGHTSERVER_TEAM", "NOFIGHTSERVER_PERMA", "NOFIGHTSERVER_UNTIL", "UNNOFIGHTSERVER_ERROR", "UNNOFIGHTSERVER"),
|
||||
NoTeamServer(true, "NOTEAMSERVER_TEAM", "NOTEAMSERVER_PERMA", "NOTEAMSERVER_UNTIL", "UNNOTEAMSERVER_ERROR", "UNNOTEAMSERVER"),
|
||||
Note(false, "NOTE_TEAM", null, null, null, null, true),
|
||||
;
|
||||
|
||||
private final boolean needsAdmin;
|
||||
private final String teamMessage;
|
||||
private final String playerMessagePerma;
|
||||
private final String playerMessageUntil;
|
||||
private final String usageNotPunished;
|
||||
private final String unpunishmentMessage;
|
||||
private boolean multi = false;
|
||||
}
|
||||
}
|
@ -1,52 +0,0 @@
|
||||
/*
|
||||
* 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.sql.Season;
|
||||
import de.steamwar.sql.internal.Statement;
|
||||
|
||||
import static de.steamwar.bungeecore.sql.UserElo.ELO_DEFAULT;
|
||||
|
||||
public class SchemElo {
|
||||
private SchemElo() {}
|
||||
|
||||
private static final Statement elo = new Statement("SELECT Elo FROM SchemElo WHERE SchemID = ? AND Season = ?");
|
||||
private static final Statement setElo = new Statement("INSERT INTO SchemElo (Season, SchemID, Elo) VALUES (?, ?, ?) ON DUPLICATE KEY UPDATE Elo = VALUES(Elo)");
|
||||
|
||||
public static int getElo(int schemID) {
|
||||
return getElo(Season.getSeason(), schemID);
|
||||
}
|
||||
|
||||
public static int getElo(int season, int schemID) {
|
||||
return elo.select(rs -> {
|
||||
if (rs.next())
|
||||
return rs.getInt("Elo");
|
||||
return ELO_DEFAULT;
|
||||
}, schemID, season);
|
||||
}
|
||||
|
||||
public static void setElo(int schemID, int elo) {
|
||||
setElo(Season.getSeason(), schemID, elo);
|
||||
}
|
||||
|
||||
public static void setElo(int season, int schemID, int elo) {
|
||||
setElo.update(season, schemID, elo);
|
||||
}
|
||||
}
|
@ -20,7 +20,9 @@
|
||||
package de.steamwar.bungeecore.sql;
|
||||
|
||||
|
||||
import de.steamwar.sql.NodeMember;
|
||||
import de.steamwar.sql.SchematicType;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import de.steamwar.sql.internal.Statement;
|
||||
|
||||
import java.io.InputStream;
|
||||
|
@ -1,398 +0,0 @@
|
||||
/*
|
||||
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 com.google.gson.JsonParser;
|
||||
import de.steamwar.bungeecore.BungeeCore;
|
||||
import de.steamwar.bungeecore.Message;
|
||||
import de.steamwar.bungeecore.commands.WebpasswordCommand;
|
||||
import de.steamwar.bungeecore.listeners.ConnectionListener;
|
||||
import de.steamwar.bungeecore.network.NetworkSender;
|
||||
import de.steamwar.messages.ChatSender;
|
||||
import de.steamwar.network.packets.server.LocaleInvalidationPacket;
|
||||
import de.steamwar.sql.BannedUserIPs;
|
||||
import de.steamwar.sql.UserGroup;
|
||||
import de.steamwar.sql.internal.Statement;
|
||||
import net.md_5.bungee.api.ProxyServer;
|
||||
import net.md_5.bungee.api.connection.PendingConnection;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.InetAddress;
|
||||
import java.net.URL;
|
||||
import java.net.UnknownHostException;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Timestamp;
|
||||
import java.util.*;
|
||||
import java.util.logging.Level;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
public class SteamwarUser {
|
||||
|
||||
private static final Statement updateName = new Statement("UPDATE UserData SET UserName = ? WHERE id = ?");
|
||||
private static final Statement updateBedrock = new Statement("UPDATE UserData SET Bedrock = ? WHERE id = ?");
|
||||
private static final Statement updateLocale = new Statement("UPDATE UserData SET Locale = ?, ManualLocale = ? WHERE id = ?");
|
||||
private static final Statement insert = new Statement("INSERT INTO UserData (UUID, UserName, UserGroup) VALUES (?, ?, 'Member')");
|
||||
private static final Statement byUUID = new Statement("SELECT * FROM UserData WHERE UUID = ?");
|
||||
private static final Statement byName = new Statement("SELECT * FROM UserData WHERE lower(UserName) = ?");
|
||||
private static final Statement byID = new Statement("SELECT * FROM UserData WHERE id = ?");
|
||||
private static final Statement byDiscord = new Statement("SELECT * FROM UserData WHERE DiscordId = ?");
|
||||
private static final Statement updateTeam = new Statement("Update UserData SET Team = ? WHERE id = ?");
|
||||
private static final Statement updateDiscord = new Statement("Update UserData SET DiscordId = ? WHERE id = ?");
|
||||
private static final Statement deleteIPs = new Statement("DELETE FROM BannedUserIPs WHERE UserID = ?");
|
||||
private static final Statement updateLeader = new Statement("Update UserData SET Leader = ? WHERE id = ?");
|
||||
private static final Statement getPlaytime = new Statement("SELECT SUM(UNIX_TIMESTAMP(EndTime) - UNIX_TIMESTAMP(StartTime)) as Playtime FROM Session WHERE UserID = ?");
|
||||
private static final Statement getFirstjoin = new Statement("SELECT MIN(StartTime) AS FirstJoin FROM Session WHERE UserID = ?");
|
||||
|
||||
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 Map<Long, SteamwarUser> usersByDiscord = new HashMap<>();
|
||||
private static final InetAddress LIXFEL_DE;
|
||||
private static final String API_URL = "https://api.mojang.com/users/profiles/minecraft/";
|
||||
private static final JsonParser jsonParser = new JsonParser();
|
||||
|
||||
private final int id;
|
||||
private final UUID uuid;
|
||||
private String userName;
|
||||
private final UserGroup userGroup;
|
||||
private int team;
|
||||
private boolean leader;
|
||||
private final Map<Punishment.PunishmentType, Punishment> punishments;
|
||||
private Long discordId;
|
||||
|
||||
private Locale locale;
|
||||
private boolean manualLocale;
|
||||
|
||||
static {
|
||||
try {
|
||||
LIXFEL_DE = InetAddress.getByAddress(new byte[]{(byte) 195, (byte) 201, (byte) 242, 43});
|
||||
} catch (UnknownHostException e) {
|
||||
ProxyServer.getInstance().stop();
|
||||
throw new SecurityException("Could not initialise address!", e);
|
||||
}
|
||||
}
|
||||
|
||||
private SteamwarUser(ResultSet rs) throws SQLException {
|
||||
id = rs.getInt("id");
|
||||
uuid = UUID.fromString(rs.getString("UUID"));
|
||||
userName = rs.getString("UserName");
|
||||
userGroup = UserGroup.getUsergroup(rs.getString("UserGroup"));
|
||||
team = rs.getInt("Team");
|
||||
leader = rs.getBoolean("Leader");
|
||||
discordId = rs.getLong("DiscordId");
|
||||
if(rs.wasNull()) {
|
||||
discordId = null;
|
||||
}
|
||||
|
||||
String dbLocale = rs.getString("Locale");
|
||||
locale = dbLocale != null ? Locale.forLanguageTag(dbLocale) : null;
|
||||
manualLocale = rs.getBoolean("ManualLocale");
|
||||
|
||||
usersById.put(id, this);
|
||||
usersByName.put(userName.toLowerCase(), this);
|
||||
usersByUUID.put(uuid, this);
|
||||
if (discordId != null) {
|
||||
usersByDiscord.put(discordId, this);
|
||||
}
|
||||
punishments = Punishment.getPunishmentsOfPlayer(id);
|
||||
}
|
||||
|
||||
public static SteamwarUser getOrCreate(PendingConnection connection) {
|
||||
SteamwarUser user = SteamwarUser.get(connection.getUniqueId());
|
||||
|
||||
if (user != null) {
|
||||
String userName = connection.getName();
|
||||
if (!user.userName.equals(userName)) {
|
||||
updateName.update(userName, user.id);
|
||||
WebpasswordCommand.changeUsername(user.userName, userName);
|
||||
user.userName = userName;
|
||||
}
|
||||
} else {
|
||||
user = SteamwarUser.createUserInDatabase(connection.getUniqueId(), connection.getName());
|
||||
if (user == null) {
|
||||
throw new SecurityException("user == null");
|
||||
}
|
||||
ConnectionListener.newPlayer(user.uuid);
|
||||
}
|
||||
|
||||
boolean bedrock = connection.getAddress().getAddress().equals(LIXFEL_DE);
|
||||
updateBedrock.update(bedrock, user.id);
|
||||
return user;
|
||||
}
|
||||
|
||||
public static SteamwarUser getOrCreateOfflinePlayer(String name) {
|
||||
SteamwarUser user = SteamwarUser.get(name);
|
||||
if (user != null) {
|
||||
return user;
|
||||
}
|
||||
|
||||
UUID uuid = SteamwarUser.getUUIDofOfflinePlayer(name);
|
||||
if (uuid == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
user = SteamwarUser.get(uuid);
|
||||
if (user != null) {
|
||||
return user;
|
||||
}
|
||||
|
||||
return SteamwarUser.createUserInDatabase(uuid, name);
|
||||
}
|
||||
|
||||
private static SteamwarUser createUserInDatabase(UUID uuid, String name) {
|
||||
insert.update(uuid.toString(), name);
|
||||
return get(uuid);
|
||||
}
|
||||
|
||||
public static SteamwarUser get(String userName) {
|
||||
userName = userName.toLowerCase();
|
||||
if (usersByName.containsKey(userName)) {
|
||||
return usersByName.get(userName);
|
||||
}
|
||||
return byName.select(rs -> {
|
||||
if (rs.next())
|
||||
return new SteamwarUser(rs);
|
||||
return null;
|
||||
}, userName);
|
||||
}
|
||||
|
||||
public static SteamwarUser get(UUID uuid) {
|
||||
if (usersByUUID.containsKey(uuid)) {
|
||||
return usersByUUID.get(uuid);
|
||||
}
|
||||
return byUUID.select(rs -> {
|
||||
if (rs.next())
|
||||
return new SteamwarUser(rs);
|
||||
return null;
|
||||
}, uuid.toString());
|
||||
}
|
||||
|
||||
public static SteamwarUser get(ProxiedPlayer player) {
|
||||
return get(player.getUniqueId());
|
||||
}
|
||||
|
||||
public static SteamwarUser get(int id) {
|
||||
if (usersById.containsKey(id)) {
|
||||
return usersById.get(id);
|
||||
}
|
||||
return byID.select(rs -> {
|
||||
rs.next();
|
||||
return new SteamwarUser(rs);
|
||||
}, id);
|
||||
}
|
||||
|
||||
public static void batchCache(Set<Integer> ids) {
|
||||
ids.removeIf(usersById::containsKey);
|
||||
if(ids.isEmpty())
|
||||
return;
|
||||
|
||||
try (Statement batch = new Statement("SELECT * FROM UserData WHERE id IN (" + ids.stream().map(Object::toString).collect(Collectors.joining(", ")) + ")")) {
|
||||
batch.select(rs -> {
|
||||
while (rs.next())
|
||||
new SteamwarUser(rs);
|
||||
return null;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public static SteamwarUser get(Long discordId) {
|
||||
if(usersByDiscord.containsKey(discordId))
|
||||
return usersByDiscord.get(discordId);
|
||||
return byDiscord.select(rs -> {
|
||||
if (rs.next())
|
||||
return new SteamwarUser(rs);
|
||||
return null;
|
||||
}, discordId);
|
||||
}
|
||||
|
||||
public static void clearCache() {
|
||||
usersById.clear();
|
||||
usersByName.clear();
|
||||
usersByUUID.clear();
|
||||
usersByDiscord.clear();
|
||||
}
|
||||
|
||||
private static UUID getUUIDofOfflinePlayer(String playerName) {
|
||||
try {
|
||||
final URL url = new URL(API_URL + playerName);
|
||||
String uuid = jsonParser.parse(new Scanner(url.openConnection().getInputStream()).nextLine()).getAsJsonObject().get("id").getAsString();
|
||||
return UUID.fromString(uuid.replaceFirst("(\\w{8})(\\w{4})(\\w{4})(\\w{4})(\\w{12})", "$1-$2-$3-$4-$5"));
|
||||
} catch (NoSuchElementException e) {
|
||||
// ignore, player does not exist
|
||||
} catch (IOException e) {
|
||||
BungeeCore.get().getLogger().log(Level.SEVERE, "Could not get offline player UUID " + playerName, e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setTeam(int team) {
|
||||
this.team = team;
|
||||
updateTeam.update(team, id);
|
||||
setLeader(false);
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public UUID getUuid() {
|
||||
return uuid;
|
||||
}
|
||||
|
||||
public String getUserName() {
|
||||
return userName;
|
||||
}
|
||||
|
||||
public UserGroup getUserGroup() {
|
||||
return userGroup;
|
||||
}
|
||||
|
||||
public int getTeam() {
|
||||
return team;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public ProxiedPlayer getPlayer() {
|
||||
return ProxyServer.getInstance().getPlayer(uuid);
|
||||
}
|
||||
|
||||
public Punishment getPunishment(Punishment.PunishmentType type) {
|
||||
return punishments.getOrDefault(type, null);
|
||||
}
|
||||
|
||||
public Long getDiscordId() {
|
||||
return discordId;
|
||||
}
|
||||
|
||||
public void setDiscordId(Long discordId) {
|
||||
usersByDiscord.remove(this.discordId);
|
||||
this.discordId = discordId;
|
||||
updateDiscord.update(discordId, id);
|
||||
if (discordId != null) {
|
||||
usersByDiscord.put(discordId, this);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isPunished(Punishment.PunishmentType punishment) {
|
||||
if (!punishments.containsKey(punishment)) {
|
||||
return false;
|
||||
}
|
||||
if (!punishments.get(punishment).isCurrent()) {
|
||||
if (punishment == Punishment.PunishmentType.Ban) {
|
||||
deleteIPs.update(id);
|
||||
}
|
||||
punishments.remove(punishment);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean isPunishedWithMessage(ChatSender player, Punishment.PunishmentType punishment) {
|
||||
if (!isPunished(punishment)) {
|
||||
return false;
|
||||
}
|
||||
player.system(punishmentMessage(punishment));
|
||||
return true;
|
||||
}
|
||||
|
||||
public void punishPerma(Punishment.PunishmentType type, String reason, int from) {
|
||||
punish(type, Punishment.PERMA_TIME, reason, from, true);
|
||||
}
|
||||
|
||||
public void punish(Punishment.PunishmentType punishment, Timestamp time, String banReason, int from, boolean perma) {
|
||||
punishments.remove(punishment);
|
||||
punishments.put(punishment, Punishment.createPunishment(id, from, punishment, banReason, time, perma));
|
||||
|
||||
if (punishment != Punishment.PunishmentType.Ban) {
|
||||
return;
|
||||
}
|
||||
|
||||
ProxiedPlayer player = ProxyServer.getInstance().getPlayer(uuid);
|
||||
if (player != null) {
|
||||
ChatSender.disconnect(player).system(punishmentMessage(punishment));
|
||||
for (BannedUserIPs banned : BannedUserIPs.get(player.getAddress().getAddress().getHostAddress())) {
|
||||
SteamwarUser bannedUser = SteamwarUser.get(banned.getUserID());
|
||||
if (bannedUser.isPunished(punishment) && bannedUser.getPunishment(punishment).getEndTime().before(time)) {
|
||||
bannedUser.punish(punishment, time, banReason, from, perma);
|
||||
}
|
||||
}
|
||||
updateBanIP(player.getAddress().getAddress().getHostAddress());
|
||||
} else {
|
||||
updateBanIP("");
|
||||
}
|
||||
}
|
||||
|
||||
public Message punishmentMessage(Punishment.PunishmentType punishment) {
|
||||
Punishment currentPunishment = punishments.get(punishment);
|
||||
if (currentPunishment.isPerma()) {
|
||||
return new Message(punishment.getPlayerMessagePerma(), currentPunishment.getReason());
|
||||
} else {
|
||||
return new Message(punishment.getPlayerMessageUntil(), currentPunishment.getEndTime(), currentPunishment.getReason());
|
||||
}
|
||||
}
|
||||
|
||||
public void updateBanIP(String ip) {
|
||||
BannedUserIPs.banIP(id, ip);
|
||||
}
|
||||
|
||||
public double getOnlinetime() {
|
||||
return getPlaytime.select(rs -> {
|
||||
if (rs.next() && rs.getBigDecimal("Playtime") != null)
|
||||
return rs.getBigDecimal("Playtime").doubleValue();
|
||||
return 0.0;
|
||||
}, id);
|
||||
}
|
||||
|
||||
public Timestamp getFirstjoin() {
|
||||
return getFirstjoin.select(rs -> {
|
||||
if (rs.next())
|
||||
return rs.getTimestamp("FirstJoin");
|
||||
return null;
|
||||
}, id);
|
||||
}
|
||||
|
||||
public boolean isLeader() {
|
||||
return leader;
|
||||
}
|
||||
|
||||
public void setLeader(boolean leader) {
|
||||
this.leader = leader;
|
||||
updateLeader.update(leader, id);
|
||||
}
|
||||
|
||||
public Locale getLocale() {
|
||||
if (locale != null)
|
||||
return locale;
|
||||
return Locale.getDefault();
|
||||
}
|
||||
|
||||
public void setLocale(Locale locale, boolean manualLocale) {
|
||||
if (locale == null || (this.manualLocale && !manualLocale))
|
||||
return;
|
||||
|
||||
this.locale = locale;
|
||||
this.manualLocale = manualLocale;
|
||||
updateLocale.update(locale.toLanguageTag(), manualLocale, id);
|
||||
NetworkSender.send(getPlayer(), new LocaleInvalidationPacket(id));
|
||||
}
|
||||
}
|
@ -1,123 +0,0 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2022 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.sql.internal.Field;
|
||||
import de.steamwar.sql.internal.Statement;
|
||||
import de.steamwar.sql.internal.Table;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@AllArgsConstructor
|
||||
public class Tutorial {
|
||||
|
||||
private static final Table<Tutorial> table = new Table<>(Tutorial.class);
|
||||
private static final Statement release = table.update(Table.PRIMARY, "released");
|
||||
private static final Statement delete = table.delete(Table.PRIMARY);
|
||||
|
||||
private static final Statement by_popularity = new Statement("SELECT t.*, AVG(r.Stars) AS Stars FROM Tutorial t LEFT OUTER JOIN TutorialRating r ON t.TutorialID = r.TutorialID WHERE t.Released = ? GROUP BY t.TutorialID ORDER BY SUM(r.Stars) DESC LIMIT ?, ?");
|
||||
private static final Statement own = new Statement("SELECT t.*, AVG(r.Stars) AS Stars FROM Tutorial t LEFT OUTER JOIN TutorialRating r ON t.TutorialID = r.TutorialID WHERE t.Creator = ? GROUP BY t.TutorialID ORDER BY t.TutorialID ASC LIMIT ?, ?");
|
||||
private static final Statement by_creator_name = new Statement("SELECT t.*, AVG(r.Stars) AS Stars FROM Tutorial t LEFT OUTER JOIN TutorialRating r ON t.TutorialID = r.TutorialID WHERE t.Creator = ? AND t.Name = ? GROUP BY t.TutorialID");
|
||||
private static final Statement by_id = new Statement("SELECT t.*, AVG(r.Stars) AS Stars FROM Tutorial t LEFT OUTER JOIN TutorialRating r ON t.TutorialID = r.TutorialID WHERE t.TutorialID = ? GROUP BY t.TutorialID");
|
||||
private static final Statement rate = new Statement("INSERT INTO TutorialRating (TutorialID, UserID, Stars) VALUES (?, ?, ?) ON DUPLICATE KEY UPDATE Stars = VALUES(Stars)");
|
||||
private static final Statement create = new Statement("INSERT INTO Tutorial (Creator, Name, Item) VALUES (?, ?, ?) ON DUPLICATE KEY UPDATE Item = VALUES(Item), Released = 0");
|
||||
|
||||
public static List<Tutorial> getPage(int page, int elementsPerPage, boolean released) {
|
||||
List<Tutorial> tutorials = by_popularity.select(rs -> {
|
||||
List<Tutorial> t = new ArrayList<>();
|
||||
while(rs.next())
|
||||
t.add(new Tutorial(rs));
|
||||
return t;
|
||||
}, released, page * elementsPerPage, elementsPerPage);
|
||||
|
||||
SteamwarUser.batchCache(tutorials.stream().map(tutorial -> tutorial.creator).collect(Collectors.toSet()));
|
||||
return tutorials;
|
||||
}
|
||||
|
||||
public static List<Tutorial> getOwn(int user, int page, int elementsPerPage) {
|
||||
return own.select(rs -> {
|
||||
List<Tutorial> t = new ArrayList<>();
|
||||
while(rs.next())
|
||||
t.add(new Tutorial(rs));
|
||||
return t;
|
||||
}, user, page * elementsPerPage, elementsPerPage);
|
||||
}
|
||||
|
||||
public static Tutorial create(int creator, String name, String item) {
|
||||
create.update(creator, name, item);
|
||||
return by_creator_name.select(rs -> {
|
||||
rs.next();
|
||||
return new Tutorial(rs);
|
||||
}, creator, name);
|
||||
}
|
||||
|
||||
public static Tutorial get(int id) {
|
||||
return by_id.select(rs -> {
|
||||
if(rs.next())
|
||||
return new Tutorial(rs);
|
||||
return null;
|
||||
}, id);
|
||||
}
|
||||
|
||||
@Getter
|
||||
@Field(keys = {Table.PRIMARY}, autoincrement = true)
|
||||
private final int id;
|
||||
@Getter
|
||||
@Field(keys = {"CreatorName"})
|
||||
private final int creator;
|
||||
@Getter
|
||||
@Field(keys = {"CreatorName"})
|
||||
private final String name;
|
||||
@Getter
|
||||
@Field(def = "'BOOK'")
|
||||
private final String item;
|
||||
@Getter
|
||||
@Field(def = "0")
|
||||
private final boolean released;
|
||||
@Getter
|
||||
private final double stars;
|
||||
|
||||
public Tutorial(ResultSet rs) throws SQLException {
|
||||
this.id = rs.getInt("TutorialID");
|
||||
this.creator = rs.getInt("Creator");
|
||||
this.name = rs.getString("Name");
|
||||
this.item = rs.getString("Item");
|
||||
this.released = rs.getBoolean("Released");
|
||||
this.stars = rs.getDouble("Stars");
|
||||
}
|
||||
|
||||
public void release() {
|
||||
release.update(id);
|
||||
}
|
||||
|
||||
public void delete() {
|
||||
delete.update(id);
|
||||
}
|
||||
|
||||
public void rate(int user, int rating) {
|
||||
rate.update(id, user, rating);
|
||||
}
|
||||
}
|
@ -22,6 +22,7 @@ package de.steamwar.bungeecore.sql;
|
||||
import de.steamwar.bungeecore.ArenaMode;
|
||||
import de.steamwar.bungeecore.Message;
|
||||
import de.steamwar.sql.Season;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import de.steamwar.sql.internal.Statement;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
|
||||
|
@ -19,7 +19,7 @@
|
||||
|
||||
package de.steamwar.bungeecore.tablist;
|
||||
|
||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import de.steamwar.sql.UserGroup;
|
||||
import de.steamwar.messages.ChatSender;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
|
@ -21,7 +21,7 @@ package de.steamwar.bungeecore.tablist;
|
||||
|
||||
import de.steamwar.bungeecore.Servertype;
|
||||
import de.steamwar.bungeecore.Subserver;
|
||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import de.steamwar.messages.ChatSender;
|
||||
import de.steamwar.network.packets.common.FightInfoPacket;
|
||||
import net.md_5.bungee.BungeeCord;
|
||||
@ -82,7 +82,7 @@ public class TablistServer implements TablistPart {
|
||||
|
||||
private void addPlayers(String prefix, List<Integer> teamPlayers, Collection<ProxiedPlayer> onlinePlayers){
|
||||
teamPlayers.stream().map(SteamwarUser::get).map(
|
||||
user -> onlinePlayers.stream().filter(player -> player.getUniqueId().equals(user.getUuid())).findAny()
|
||||
user -> onlinePlayers.stream().filter(player -> player.getUniqueId().equals(user.getUUID())).findAny()
|
||||
).filter(Optional::isPresent).map(Optional::get).sorted(
|
||||
(p1, p2) -> p1.getName().compareToIgnoreCase(p2.getName())
|
||||
).forEachOrdered(player -> players.add(new Item(player.getUniqueId(), prefix + player.getName(), Item.playerProperties(player))));
|
||||
|
@ -20,7 +20,7 @@
|
||||
package de.steamwar.bungeecore.util;
|
||||
|
||||
import de.steamwar.bungeecore.Message;
|
||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import de.steamwar.sql.UserConfig;
|
||||
import lombok.experimental.UtilityClass;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
@ -32,7 +32,7 @@ public class BauLock {
|
||||
public static void setLocked(ProxiedPlayer p, BauLockState state) {
|
||||
SteamwarUser owner = SteamwarUser.get(p.getUniqueId());
|
||||
UserConfig.updatePlayerConfig(owner.getId(), BAU_LOCK_CONFIG_NAME, state == BauLockState.OPEN ? null : state.name());
|
||||
Message.send("BAU_LOCKED_" + state.name(), owner.getPlayer());
|
||||
Message.send("BAU_LOCKED_" + state.name(), p);
|
||||
}
|
||||
|
||||
public static boolean isLocked(SteamwarUser owner, SteamwarUser target) {
|
||||
|
@ -20,7 +20,7 @@
|
||||
package de.steamwar.command;
|
||||
|
||||
import de.steamwar.bungeecore.commands.TypeMappers;
|
||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import lombok.experimental.UtilityClass;
|
||||
import net.md_5.bungee.BungeeCord;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
|
@ -21,7 +21,7 @@ package de.steamwar.messages;
|
||||
|
||||
import de.steamwar.bungeecore.*;
|
||||
import de.steamwar.bungeecore.bot.listeners.DiscordChatListener;
|
||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import net.md_5.bungee.api.ChatMessageType;
|
||||
import net.md_5.bungee.api.CommandSender;
|
||||
import net.md_5.bungee.api.ProxyServer;
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren