geforkt von SteamWar/BungeeCore
Merge remote-tracking branch 'origin/master'
Dieser Commit ist enthalten in:
Commit
ad535f2788
@ -1 +1 @@
|
|||||||
Subproject commit aa70f423d87e9f6534ad2dd1f20a5122179c423f
|
Subproject commit ec9d56dab9091ddf514b5d8066c8313f5ad18c75
|
@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
package de.steamwar.bungeecore;
|
package de.steamwar.bungeecore;
|
||||||
|
|
||||||
import de.steamwar.bungeecore.sql.SchematicType;
|
import de.steamwar.sql.SchematicType;
|
||||||
import net.md_5.bungee.api.ProxyServer;
|
import net.md_5.bungee.api.ProxyServer;
|
||||||
import net.md_5.bungee.config.Configuration;
|
import net.md_5.bungee.config.Configuration;
|
||||||
import net.md_5.bungee.config.ConfigurationProvider;
|
import net.md_5.bungee.config.ConfigurationProvider;
|
||||||
|
@ -28,15 +28,15 @@ import de.steamwar.bungeecore.listeners.ping.PingListener;
|
|||||||
import de.steamwar.bungeecore.network.BungeeNetworkHandler;
|
import de.steamwar.bungeecore.network.BungeeNetworkHandler;
|
||||||
import de.steamwar.bungeecore.network.NetworkReceiver;
|
import de.steamwar.bungeecore.network.NetworkReceiver;
|
||||||
import de.steamwar.bungeecore.network.SWScriptSyntaxForwarder;
|
import de.steamwar.bungeecore.network.SWScriptSyntaxForwarder;
|
||||||
import de.steamwar.bungeecore.sql.Punishment;
|
import de.steamwar.sql.Punishment;
|
||||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
import de.steamwar.sql.SteamwarUser;
|
||||||
import de.steamwar.bungeecore.sql.Team;
|
import de.steamwar.sql.UserElo;
|
||||||
import de.steamwar.bungeecore.sql.UserElo;
|
|
||||||
import de.steamwar.bungeecore.tablist.TablistManager;
|
import de.steamwar.bungeecore.tablist.TablistManager;
|
||||||
import de.steamwar.command.SWCommandUtils;
|
import de.steamwar.command.SWCommandUtils;
|
||||||
import de.steamwar.command.SWTypeMapperCreator;
|
import de.steamwar.command.SWTypeMapperCreator;
|
||||||
import de.steamwar.command.TabCompletionCache;
|
import de.steamwar.command.TabCompletionCache;
|
||||||
import de.steamwar.command.TypeMapper;
|
import de.steamwar.command.TypeMapper;
|
||||||
|
import de.steamwar.sql.Team;
|
||||||
import de.steamwar.sql.internal.Statement;
|
import de.steamwar.sql.internal.Statement;
|
||||||
import net.md_5.bungee.BungeeCord;
|
import net.md_5.bungee.BungeeCord;
|
||||||
import net.md_5.bungee.api.ChatMessageType;
|
import net.md_5.bungee.api.ChatMessageType;
|
||||||
@ -205,9 +205,9 @@ public class BungeeCore extends Plugin {
|
|||||||
new SettingsChangedListener();
|
new SettingsChangedListener();
|
||||||
|
|
||||||
getProxy().getScheduler().schedule(this, () -> {
|
getProxy().getScheduler().schedule(this, () -> {
|
||||||
SteamwarUser.clearCache();
|
SteamwarUser.clear();
|
||||||
UserElo.clearCache();
|
UserElo.clear();
|
||||||
Team.clearCache();
|
Team.clear();
|
||||||
}, 1, 1, TimeUnit.HOURS);
|
}, 1, 1, TimeUnit.HOURS);
|
||||||
|
|
||||||
if (SteamwarDiscordBotConfig.loaded) {
|
if (SteamwarDiscordBotConfig.loaded) {
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
package de.steamwar.bungeecore;
|
package de.steamwar.bungeecore;
|
||||||
|
|
||||||
import de.steamwar.bungeecore.sql.SWException;
|
import de.steamwar.sql.SWException;
|
||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.PrintStream;
|
import java.io.PrintStream;
|
||||||
@ -61,7 +61,7 @@ public class ErrorLogger extends Handler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
SWException.log("Bungee", message, stacktrace);
|
SWException.log(message, stacktrace);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -19,10 +19,10 @@
|
|||||||
|
|
||||||
package de.steamwar.bungeecore;
|
package de.steamwar.bungeecore;
|
||||||
|
|
||||||
import de.steamwar.bungeecore.sql.Event;
|
import de.steamwar.sql.EventFight;
|
||||||
import de.steamwar.bungeecore.sql.EventFight;
|
import de.steamwar.sql.SteamwarUser;
|
||||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
import de.steamwar.sql.Team;
|
||||||
import de.steamwar.bungeecore.sql.Team;
|
import de.steamwar.sql.Event;
|
||||||
import net.md_5.bungee.api.ProxyServer;
|
import net.md_5.bungee.api.ProxyServer;
|
||||||
import net.md_5.bungee.api.chat.ClickEvent;
|
import net.md_5.bungee.api.chat.ClickEvent;
|
||||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||||
@ -66,7 +66,7 @@ public class EventStarter implements Runnable {
|
|||||||
if(BungeeCore.EVENT_MODE || !Event.get(next.getEventID()).spectateSystem()) {
|
if(BungeeCore.EVENT_MODE || !Event.get(next.getEventID()).spectateSystem()) {
|
||||||
ServerStarter starter = new ServerStarter().event(next);
|
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)
|
if(leiter != null)
|
||||||
starter.send(leiter);
|
starter.send(leiter);
|
||||||
|
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
package de.steamwar.bungeecore;
|
package de.steamwar.bungeecore;
|
||||||
|
|
||||||
import de.steamwar.bungeecore.sql.EventFight;
|
import de.steamwar.sql.EventFight;
|
||||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
import de.steamwar.sql.SteamwarUser;
|
||||||
import de.steamwar.bungeecore.sql.Team;
|
import de.steamwar.sql.Team;
|
||||||
import de.steamwar.bungeecore.sql.Tutorial;
|
import de.steamwar.sql.Tutorial;
|
||||||
import de.steamwar.messages.ChatSender;
|
import de.steamwar.messages.ChatSender;
|
||||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||||
|
|
||||||
@ -67,13 +67,13 @@ public class ServerStarter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public ServerStarter event(EventFight eventFight) {
|
public ServerStarter event(EventFight eventFight) {
|
||||||
arena(eventFight.getSpielmodus(), eventFight.getMap());
|
arena(ArenaMode.getByInternal(eventFight.getSpielmodus()), eventFight.getMap());
|
||||||
node = BungeeCore.local;
|
node = BungeeCore.local;
|
||||||
worldDir = EVENT_PATH;
|
worldDir = EVENT_PATH;
|
||||||
worldCleanup = () -> {};
|
worldCleanup = () -> {};
|
||||||
arguments.put("fightID", String.valueOf(eventFight.getFightID()));
|
arguments.put("fightID", String.valueOf(eventFight.getFightID()));
|
||||||
fightMap = eventFight.getMap();
|
fightMap = eventFight.getMap();
|
||||||
gameMode = eventFight.getSpielmodus().getInternalName();
|
gameMode = eventFight.getSpielmodus();
|
||||||
|
|
||||||
String serverName = Team.get(eventFight.getTeamBlue()).getTeamKuerzel() + " vs " + Team.get(eventFight.getTeamRed()).getTeamKuerzel();
|
String serverName = Team.get(eventFight.getTeamBlue()).getTeamKuerzel() + " vs " + Team.get(eventFight.getTeamRed()).getTeamKuerzel();
|
||||||
serverNameProvider = port -> serverName;
|
serverNameProvider = port -> serverName;
|
||||||
@ -144,8 +144,8 @@ public class ServerStarter {
|
|||||||
public ServerStarter tutorial(ProxiedPlayer owner, Tutorial tutorial) {
|
public ServerStarter tutorial(ProxiedPlayer owner, Tutorial tutorial) {
|
||||||
directory = new File(SERVER_PATH, "Tutorial");
|
directory = new File(SERVER_PATH, "Tutorial");
|
||||||
buildWithTemp(owner);
|
buildWithTemp(owner);
|
||||||
tempWorld(TUTORIAL_PATH + tutorial.id());
|
tempWorld(TUTORIAL_PATH + tutorial.getTutorialId());
|
||||||
arguments.put("tutorial", String.valueOf(tutorial.id()));
|
arguments.put("tutorial", String.valueOf(tutorial.getTutorialId()));
|
||||||
return send(owner);
|
return send(owner);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,8 +21,8 @@ package de.steamwar.bungeecore;
|
|||||||
|
|
||||||
import de.steamwar.bungeecore.network.NetworkSender;
|
import de.steamwar.bungeecore.network.NetworkSender;
|
||||||
import de.steamwar.bungeecore.network.handlers.FightInfoHandler;
|
import de.steamwar.bungeecore.network.handlers.FightInfoHandler;
|
||||||
import de.steamwar.bungeecore.sql.IgnoreSystem;
|
import de.steamwar.sql.IgnoreSystem;
|
||||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
import de.steamwar.sql.SteamwarUser;
|
||||||
import de.steamwar.network.packets.server.StartingServerPacket;
|
import de.steamwar.network.packets.server.StartingServerPacket;
|
||||||
import net.md_5.bungee.api.ProxyServer;
|
import net.md_5.bungee.api.ProxyServer;
|
||||||
import net.md_5.bungee.api.chat.ClickEvent;
|
import net.md_5.bungee.api.chat.ClickEvent;
|
||||||
@ -41,7 +41,7 @@ public class SubserverSystem {
|
|||||||
ProxiedPlayer o = ProxyServer.getInstance().getPlayer(owner);
|
ProxiedPlayer o = ProxyServer.getInstance().getPlayer(owner);
|
||||||
if(o == null)
|
if(o == null)
|
||||||
return;
|
return;
|
||||||
if(IgnoreSystem.isIgnored(o, p)){
|
if(IgnoreSystem.isIgnored(owner, p.getUniqueId())){
|
||||||
Message.send("SERVER_IGNORED", p);
|
Message.send("SERVER_IGNORED", p);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,7 @@ package de.steamwar.bungeecore.bot;
|
|||||||
|
|
||||||
import de.steamwar.bungeecore.BungeeCore;
|
import de.steamwar.bungeecore.BungeeCore;
|
||||||
import de.steamwar.bungeecore.bot.config.SteamwarDiscordBotConfig;
|
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.MessageBuilder;
|
||||||
import net.dv8tion.jda.api.entities.Emoji;
|
import net.dv8tion.jda.api.entities.Emoji;
|
||||||
import net.dv8tion.jda.api.entities.Member;
|
import net.dv8tion.jda.api.entities.Member;
|
||||||
|
@ -28,8 +28,8 @@ import de.steamwar.bungeecore.bot.listeners.*;
|
|||||||
import de.steamwar.bungeecore.bot.util.DiscordRolesMessage;
|
import de.steamwar.bungeecore.bot.util.DiscordRolesMessage;
|
||||||
import de.steamwar.bungeecore.bot.util.DiscordRulesMessage;
|
import de.steamwar.bungeecore.bot.util.DiscordRulesMessage;
|
||||||
import de.steamwar.bungeecore.bot.util.DiscordTicketMessage;
|
import de.steamwar.bungeecore.bot.util.DiscordTicketMessage;
|
||||||
import de.steamwar.bungeecore.sql.Event;
|
|
||||||
import de.steamwar.messages.ChatSender;
|
import de.steamwar.messages.ChatSender;
|
||||||
|
import de.steamwar.sql.Event;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import net.dv8tion.jda.api.JDA;
|
import net.dv8tion.jda.api.JDA;
|
||||||
import net.dv8tion.jda.api.JDABuilder;
|
import net.dv8tion.jda.api.JDABuilder;
|
||||||
|
@ -21,8 +21,7 @@ package de.steamwar.bungeecore.bot.commands;
|
|||||||
|
|
||||||
import de.steamwar.bungeecore.Message;
|
import de.steamwar.bungeecore.Message;
|
||||||
import de.steamwar.bungeecore.commands.PunishmentCommand;
|
import de.steamwar.bungeecore.commands.PunishmentCommand;
|
||||||
import de.steamwar.bungeecore.sql.Punishment;
|
import de.steamwar.sql.SteamwarUser;
|
||||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
|
||||||
import net.dv8tion.jda.api.events.interaction.SlashCommandEvent;
|
import net.dv8tion.jda.api.events.interaction.SlashCommandEvent;
|
||||||
import net.dv8tion.jda.api.interactions.commands.OptionType;
|
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 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) {
|
if (target == null) {
|
||||||
event.reply("Angegebener User invalide").setEphemeral(true).queue();
|
event.reply("Angegebener User invalide").setEphemeral(true).queue();
|
||||||
return;
|
return;
|
||||||
@ -60,7 +59,7 @@ public class BanCommand extends BasicDiscordCommand {
|
|||||||
String msg = event.getOption("reason").getAsString();
|
String msg = event.getOption("reason").getAsString();
|
||||||
boolean isPerma = event.getOption("time").getAsString().equals("perma");
|
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);
|
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();
|
event.reply("Erfolgreich " + target.getUserName() + (isPerma ? " permanent" : " bis " + time) + " gebannt").setEphemeral(true).queue();
|
||||||
}
|
}
|
||||||
|
@ -19,8 +19,8 @@
|
|||||||
|
|
||||||
package de.steamwar.bungeecore.bot.commands;
|
package de.steamwar.bungeecore.bot.commands;
|
||||||
|
|
||||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
import de.steamwar.sql.SteamwarUser;
|
||||||
import de.steamwar.bungeecore.sql.UserGroup;
|
import de.steamwar.sql.UserGroup;
|
||||||
import net.dv8tion.jda.api.entities.Member;
|
import net.dv8tion.jda.api.entities.Member;
|
||||||
import net.dv8tion.jda.api.events.interaction.SlashCommandEvent;
|
import net.dv8tion.jda.api.events.interaction.SlashCommandEvent;
|
||||||
import net.dv8tion.jda.api.interactions.commands.build.CommandData;
|
import net.dv8tion.jda.api.interactions.commands.build.CommandData;
|
||||||
|
@ -21,8 +21,8 @@ package de.steamwar.bungeecore.bot.commands;
|
|||||||
|
|
||||||
import de.steamwar.bungeecore.Message;
|
import de.steamwar.bungeecore.Message;
|
||||||
import de.steamwar.bungeecore.commands.PunishmentCommand;
|
import de.steamwar.bungeecore.commands.PunishmentCommand;
|
||||||
import de.steamwar.bungeecore.sql.Punishment;
|
import de.steamwar.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.events.interaction.SlashCommandEvent;
|
||||||
import net.dv8tion.jda.api.interactions.commands.OptionType;
|
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 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) {
|
if (target == null) {
|
||||||
event.reply("Angegebener User invalide").setEphemeral(true).complete();
|
event.reply("Angegebener User invalide").setEphemeral(true).complete();
|
||||||
return;
|
return;
|
||||||
|
@ -19,10 +19,10 @@
|
|||||||
|
|
||||||
package de.steamwar.bungeecore.bot.commands;
|
package de.steamwar.bungeecore.bot.commands;
|
||||||
|
|
||||||
import de.steamwar.bungeecore.sql.Event;
|
import de.steamwar.sql.Event;
|
||||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
import de.steamwar.sql.SteamwarUser;
|
||||||
import de.steamwar.bungeecore.sql.Team;
|
import de.steamwar.sql.Team;
|
||||||
import de.steamwar.bungeecore.sql.TeamTeilnahme;
|
import de.steamwar.sql.TeamTeilnahme;
|
||||||
import net.dv8tion.jda.api.EmbedBuilder;
|
import net.dv8tion.jda.api.EmbedBuilder;
|
||||||
import net.dv8tion.jda.api.entities.Emoji;
|
import net.dv8tion.jda.api.entities.Emoji;
|
||||||
import net.dv8tion.jda.api.events.interaction.SlashCommandEvent;
|
import net.dv8tion.jda.api.events.interaction.SlashCommandEvent;
|
||||||
@ -91,6 +91,6 @@ public class TeamCommand extends BasicDiscordCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean isOnline(SteamwarUser user) {
|
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;
|
package de.steamwar.bungeecore.bot.commands;
|
||||||
|
|
||||||
import de.steamwar.bungeecore.sql.Punishment;
|
import de.steamwar.bungeecore.commands.PunishmentCommand;
|
||||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
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.events.interaction.SlashCommandEvent;
|
||||||
import net.dv8tion.jda.api.interactions.commands.OptionType;
|
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 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) {
|
if (target == null) {
|
||||||
event.reply("Angegebener User invalide").setEphemeral(true).queue();
|
event.reply("Angegebener User invalide").setEphemeral(true).queue();
|
||||||
return;
|
return;
|
||||||
@ -54,6 +56,7 @@ public class UnbanCommand extends BasicDiscordCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
target.punish(Punishment.PunishmentType.Ban, Timestamp.from(new Date().toInstant()), "Unban", sender.getId(), false);
|
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();
|
event.reply("Erfolgreich " + target.getUserName() + " entbannt").setEphemeral(true).queue();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,9 +19,9 @@
|
|||||||
|
|
||||||
package de.steamwar.bungeecore.bot.commands;
|
package de.steamwar.bungeecore.bot.commands;
|
||||||
|
|
||||||
import de.steamwar.bungeecore.sql.Punishment;
|
import de.steamwar.sql.Punishment;
|
||||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
import de.steamwar.sql.SteamwarUser;
|
||||||
import de.steamwar.bungeecore.sql.Team;
|
import de.steamwar.sql.Team;
|
||||||
import net.dv8tion.jda.api.EmbedBuilder;
|
import net.dv8tion.jda.api.EmbedBuilder;
|
||||||
import net.dv8tion.jda.api.events.interaction.SlashCommandEvent;
|
import net.dv8tion.jda.api.events.interaction.SlashCommandEvent;
|
||||||
import net.dv8tion.jda.api.interactions.commands.OptionType;
|
import net.dv8tion.jda.api.interactions.commands.OptionType;
|
||||||
@ -72,7 +72,7 @@ public class WhoisCommand extends BasicDiscordCommand {
|
|||||||
EmbedBuilder embedBuilder = new EmbedBuilder();
|
EmbedBuilder embedBuilder = new EmbedBuilder();
|
||||||
embedBuilder.setTitle("Whois: " + user.getUserName());
|
embedBuilder.setTitle("Whois: " + user.getUserName());
|
||||||
StringBuilder st = new StringBuilder();
|
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");
|
st.append("ID: ").append(user.getId()).append("\n");
|
||||||
if (user.getDiscordId() != null) {
|
if (user.getDiscordId() != null) {
|
||||||
st.append("DiscordID: ").append(user.getDiscordId()).append("\n");
|
st.append("DiscordID: ").append(user.getDiscordId()).append("\n");
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
package de.steamwar.bungeecore.bot.config;
|
package de.steamwar.bungeecore.bot.config;
|
||||||
|
|
||||||
import de.steamwar.bungeecore.sql.UserGroup;
|
import de.steamwar.sql.UserGroup;
|
||||||
import net.md_5.bungee.config.Configuration;
|
import net.md_5.bungee.config.Configuration;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -21,10 +21,10 @@ package de.steamwar.bungeecore.bot.events;
|
|||||||
|
|
||||||
import de.steamwar.bungeecore.bot.SteamwarDiscordBot;
|
import de.steamwar.bungeecore.bot.SteamwarDiscordBot;
|
||||||
import de.steamwar.bungeecore.bot.config.SteamwarDiscordBotConfig;
|
import de.steamwar.bungeecore.bot.config.SteamwarDiscordBotConfig;
|
||||||
import de.steamwar.bungeecore.sql.Event;
|
import de.steamwar.sql.EventFight;
|
||||||
import de.steamwar.bungeecore.sql.EventFight;
|
import de.steamwar.sql.Team;
|
||||||
import de.steamwar.bungeecore.sql.Team;
|
import de.steamwar.sql.TeamTeilnahme;
|
||||||
import de.steamwar.bungeecore.sql.TeamTeilnahme;
|
import de.steamwar.sql.Event;
|
||||||
import lombok.experimental.UtilityClass;
|
import lombok.experimental.UtilityClass;
|
||||||
import net.dv8tion.jda.api.EmbedBuilder;
|
import net.dv8tion.jda.api.EmbedBuilder;
|
||||||
import net.dv8tion.jda.api.MessageBuilder;
|
import net.dv8tion.jda.api.MessageBuilder;
|
||||||
|
@ -22,7 +22,7 @@ package de.steamwar.bungeecore.bot.events;
|
|||||||
import de.steamwar.bungeecore.bot.SteamwarDiscordBot;
|
import de.steamwar.bungeecore.bot.SteamwarDiscordBot;
|
||||||
import de.steamwar.bungeecore.bot.config.SteamwarDiscordBotConfig;
|
import de.steamwar.bungeecore.bot.config.SteamwarDiscordBotConfig;
|
||||||
import de.steamwar.bungeecore.commands.CheckCommand;
|
import de.steamwar.bungeecore.commands.CheckCommand;
|
||||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
import de.steamwar.sql.SteamwarUser;
|
||||||
import lombok.experimental.UtilityClass;
|
import lombok.experimental.UtilityClass;
|
||||||
import net.dv8tion.jda.api.EmbedBuilder;
|
import net.dv8tion.jda.api.EmbedBuilder;
|
||||||
import net.dv8tion.jda.api.MessageBuilder;
|
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.AuthManager;
|
||||||
import de.steamwar.bungeecore.bot.config.SteamwarDiscordBotConfig;
|
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.entities.ChannelType;
|
||||||
import net.dv8tion.jda.api.events.interaction.GenericComponentInteractionCreateEvent;
|
import net.dv8tion.jda.api.events.interaction.GenericComponentInteractionCreateEvent;
|
||||||
import net.dv8tion.jda.api.interactions.InteractionType;
|
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.SteamwarDiscordBot;
|
||||||
import de.steamwar.bungeecore.bot.config.SteamwarDiscordBotConfig;
|
import de.steamwar.bungeecore.bot.config.SteamwarDiscordBotConfig;
|
||||||
import de.steamwar.bungeecore.listeners.ChatListener;
|
import de.steamwar.bungeecore.listeners.ChatListener;
|
||||||
import de.steamwar.bungeecore.sql.Punishment;
|
import de.steamwar.sql.Punishment;
|
||||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
import de.steamwar.sql.SteamwarUser;
|
||||||
import de.steamwar.messages.ChatSender;
|
import de.steamwar.messages.ChatSender;
|
||||||
import net.dv8tion.jda.api.MessageBuilder;
|
import net.dv8tion.jda.api.MessageBuilder;
|
||||||
import net.dv8tion.jda.api.entities.Member;
|
import net.dv8tion.jda.api.entities.Member;
|
||||||
|
@ -21,10 +21,10 @@ package de.steamwar.bungeecore.bot.listeners;
|
|||||||
|
|
||||||
import de.steamwar.bungeecore.bot.config.SteamwarDiscordBotConfig;
|
import de.steamwar.bungeecore.bot.config.SteamwarDiscordBotConfig;
|
||||||
import de.steamwar.bungeecore.bot.events.EventManager;
|
import de.steamwar.bungeecore.bot.events.EventManager;
|
||||||
import de.steamwar.bungeecore.sql.Event;
|
import de.steamwar.sql.SteamwarUser;
|
||||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
import de.steamwar.sql.Team;
|
||||||
import de.steamwar.bungeecore.sql.Team;
|
import de.steamwar.sql.TeamTeilnahme;
|
||||||
import de.steamwar.bungeecore.sql.TeamTeilnahme;
|
import de.steamwar.sql.Event;
|
||||||
import net.dv8tion.jda.api.events.interaction.SelectionMenuEvent;
|
import net.dv8tion.jda.api.events.interaction.SelectionMenuEvent;
|
||||||
import net.dv8tion.jda.api.interactions.components.Component;
|
import net.dv8tion.jda.api.interactions.components.Component;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
@ -23,7 +23,7 @@ import de.steamwar.bungeecore.BungeeCore;
|
|||||||
import de.steamwar.bungeecore.Message;
|
import de.steamwar.bungeecore.Message;
|
||||||
import de.steamwar.bungeecore.bot.config.DiscordTicketType;
|
import de.steamwar.bungeecore.bot.config.DiscordTicketType;
|
||||||
import de.steamwar.bungeecore.bot.config.SteamwarDiscordBotConfig;
|
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.EmbedBuilder;
|
||||||
import net.dv8tion.jda.api.MessageBuilder;
|
import net.dv8tion.jda.api.MessageBuilder;
|
||||||
import net.dv8tion.jda.api.Permission;
|
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)) {
|
if(!event.getChannel().getId().equals(SteamwarDiscordBotConfig.TICKET_CHANNEL) && !event.getChannel().getId().equals(SteamwarDiscordBotConfig.TICKET_LOG)) {
|
||||||
BungeeCore.get().getProxy().getPlayers().forEach(player -> {
|
BungeeCore.get().getProxy().getPlayers().forEach(player -> {
|
||||||
if(event.getAuthor().isBot() || event.getAuthor().isSystem()) return;
|
if(event.getAuthor().isBot() || event.getAuthor().isSystem()) return;
|
||||||
SteamwarUser user = SteamwarUser.get(player);
|
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
|
||||||
boolean sendMessage;
|
boolean sendMessage;
|
||||||
if(user.getDiscordId() == null) {
|
if(user.getDiscordId() == null) {
|
||||||
sendMessage = user.getUserGroup().isCheckSchematics();
|
sendMessage = user.getUserGroup().isCheckSchematics();
|
||||||
|
@ -19,14 +19,14 @@
|
|||||||
package de.steamwar.bungeecore.bot.listeners;
|
package de.steamwar.bungeecore.bot.listeners;
|
||||||
|
|
||||||
import de.steamwar.bungeecore.BungeeCore;
|
import de.steamwar.bungeecore.BungeeCore;
|
||||||
import de.steamwar.bungeecore.sql.Punishment;
|
import de.steamwar.sql.NodeData;
|
||||||
import de.steamwar.bungeecore.sql.SchematicNode;
|
import de.steamwar.sql.Punishment;
|
||||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
import de.steamwar.sql.SchematicNode;
|
||||||
|
import de.steamwar.sql.SteamwarUser;
|
||||||
import net.dv8tion.jda.api.entities.Message;
|
import net.dv8tion.jda.api.entities.Message;
|
||||||
import net.dv8tion.jda.api.events.message.priv.PrivateMessageReceivedEvent;
|
import net.dv8tion.jda.api.events.message.priv.PrivateMessageReceivedEvent;
|
||||||
|
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.util.concurrent.CompletableFuture;
|
|
||||||
|
|
||||||
public class PrivateMessageListener extends BasicDiscordListener {
|
public class PrivateMessageListener extends BasicDiscordListener {
|
||||||
|
|
||||||
@ -60,14 +60,14 @@ public class PrivateMessageListener extends BasicDiscordListener {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
SchematicNode node = SchematicNode.getSchematicNode(user.getId(), name, 0);
|
SchematicNode node = SchematicNode.getSchematicNode(user.getId(), name, (Integer) null);
|
||||||
if(node == null) {
|
if(node == null) {
|
||||||
node = SchematicNode.createSchematic(user.getId(), name, null);
|
node = SchematicNode.createSchematic(user.getId(), name, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
InputStream in = attachment.retrieveInputStream().get();
|
InputStream in = attachment.retrieveInputStream().get();
|
||||||
node.saveFromStream(in, newFormat);
|
NodeData.get(node).saveFromStream(in, newFormat);
|
||||||
in.close();
|
in.close();
|
||||||
event.getMessage().reply("`" + name + "` wurde erfolgreich hochgeladen").queue();
|
event.getMessage().reply("`" + name + "` wurde erfolgreich hochgeladen").queue();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
@ -21,7 +21,7 @@ package de.steamwar.bungeecore.bot.util;
|
|||||||
|
|
||||||
import de.steamwar.bungeecore.bot.SteamwarDiscordBot;
|
import de.steamwar.bungeecore.bot.SteamwarDiscordBot;
|
||||||
import de.steamwar.bungeecore.bot.config.SteamwarDiscordBotConfig;
|
import de.steamwar.bungeecore.bot.config.SteamwarDiscordBotConfig;
|
||||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
import de.steamwar.sql.SteamwarUser;
|
||||||
import lombok.experimental.UtilityClass;
|
import lombok.experimental.UtilityClass;
|
||||||
import net.dv8tion.jda.api.entities.Guild;
|
import net.dv8tion.jda.api.entities.Guild;
|
||||||
import net.dv8tion.jda.api.entities.Role;
|
import net.dv8tion.jda.api.entities.Role;
|
||||||
|
@ -20,8 +20,8 @@
|
|||||||
package de.steamwar.bungeecore.bot.util;
|
package de.steamwar.bungeecore.bot.util;
|
||||||
|
|
||||||
import de.steamwar.bungeecore.bot.SteamwarDiscordBot;
|
import de.steamwar.bungeecore.bot.SteamwarDiscordBot;
|
||||||
import de.steamwar.bungeecore.sql.SchematicNode;
|
import de.steamwar.sql.SchematicNode;
|
||||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
import de.steamwar.sql.SteamwarUser;
|
||||||
import lombok.experimental.UtilityClass;
|
import lombok.experimental.UtilityClass;
|
||||||
import net.dv8tion.jda.api.EmbedBuilder;
|
import net.dv8tion.jda.api.EmbedBuilder;
|
||||||
import net.dv8tion.jda.api.MessageBuilder;
|
import net.dv8tion.jda.api.MessageBuilder;
|
||||||
|
@ -23,13 +23,16 @@ import de.steamwar.bungeecore.*;
|
|||||||
import de.steamwar.bungeecore.inventory.SWInventory;
|
import de.steamwar.bungeecore.inventory.SWInventory;
|
||||||
import de.steamwar.bungeecore.inventory.SWItem;
|
import de.steamwar.bungeecore.inventory.SWItem;
|
||||||
import de.steamwar.bungeecore.network.NetworkSender;
|
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.bungeecore.util.Chat19;
|
||||||
import de.steamwar.command.SWCommand;
|
import de.steamwar.command.SWCommand;
|
||||||
import de.steamwar.command.TypeMapper;
|
import de.steamwar.command.TypeMapper;
|
||||||
import de.steamwar.command.TypeValidator;
|
import de.steamwar.command.TypeValidator;
|
||||||
import de.steamwar.messages.ChatSender;
|
import de.steamwar.messages.ChatSender;
|
||||||
import de.steamwar.network.packets.server.BaumemberUpdatePacket;
|
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.CommandSender;
|
||||||
import net.md_5.bungee.api.ProxyServer;
|
import net.md_5.bungee.api.ProxyServer;
|
||||||
import net.md_5.bungee.api.config.ServerInfo;
|
import net.md_5.bungee.api.config.ServerInfo;
|
||||||
@ -123,10 +126,10 @@ public class BauCommand extends SWCommand {
|
|||||||
|
|
||||||
@Register(value = "addmember", description = "BAU_ADDMEMBER_USAGE")
|
@Register(value = "addmember", description = "BAU_ADDMEMBER_USAGE")
|
||||||
public void addmember(ProxiedPlayer p, @Validator("addMemberTarget") SteamwarUser target) {
|
public void addmember(ProxiedPlayer p, @Validator("addMemberTarget") SteamwarUser target) {
|
||||||
new BauweltMember(p.getUniqueId(), target.getUuid(), false, false);
|
BauweltMember.addMember(p.getUniqueId(), target.getUUID());
|
||||||
Message.send("BAU_ADDMEMBER_ADDED", p);
|
Message.send("BAU_ADDMEMBER_ADDED", p);
|
||||||
|
|
||||||
ProxiedPlayer z = ProxyServer.getInstance().getPlayer(target.getUuid());
|
ProxiedPlayer z = ProxyServer.getInstance().getPlayer(target.getUUID());
|
||||||
if(z != null)
|
if(z != null)
|
||||||
Message.send("BAU_ADDMEMBER_ADDED_TARGET", z, p.getName());
|
Message.send("BAU_ADDMEMBER_ADDED_TARGET", z, p.getName());
|
||||||
}
|
}
|
||||||
@ -138,11 +141,11 @@ public class BauCommand extends SWCommand {
|
|||||||
messageSender.send("UNKNOWN_PLAYER");
|
messageSender.send("UNKNOWN_PLAYER");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (((ProxiedPlayer) sender).getUniqueId().equals(value.getUuid())) {
|
if (((ProxiedPlayer) sender).getUniqueId().equals(value.getUUID())) {
|
||||||
messageSender.send("BAU_ADDMEMBER_SELFADD");
|
messageSender.send("BAU_ADDMEMBER_SELFADD");
|
||||||
return false;
|
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");
|
messageSender.send("BAU_ADDMEMBER_ISADDED");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -154,9 +157,9 @@ public class BauCommand extends SWCommand {
|
|||||||
@Register("teleport")
|
@Register("teleport")
|
||||||
public void teleport(ProxiedPlayer p, @Validator("teleportTarget") SteamwarUser worldOwner, @Mapper("version") @OptionalValue(value = "", onlyUINIG = true) int version) {
|
public void teleport(ProxiedPlayer p, @Validator("teleportTarget") SteamwarUser worldOwner, @Mapper("version") @OptionalValue(value = "", onlyUINIG = true) int version) {
|
||||||
versionSelector(version,
|
versionSelector(version,
|
||||||
() -> new ServerStarter().build12(worldOwner.getUuid()).send(p).start(),
|
() -> new ServerStarter().build12(worldOwner.getUUID()).send(p).start(),
|
||||||
() -> new ServerStarter().build15(worldOwner.getUuid()).send(p).start(),
|
() -> new ServerStarter().build15(worldOwner.getUUID()).send(p).start(),
|
||||||
() -> new ServerStarter().build19(worldOwner.getUuid()).send(p).start()
|
() -> new ServerStarter().build19(worldOwner.getUUID()).send(p).start()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -168,12 +171,12 @@ public class BauCommand extends SWCommand {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
ProxiedPlayer p = (ProxiedPlayer) sender;
|
ProxiedPlayer p = (ProxiedPlayer) sender;
|
||||||
if (!p.getUniqueId().equals(value.getUuid()) && BauweltMember.getBauMember(value.getUuid(), p.getUniqueId()) == null) {
|
if (!p.getUniqueId().equals(value.getUUID()) && BauweltMember.getBauMember(value.getUUID(), p.getUniqueId()) == null) {
|
||||||
SubserverSystem.sendDeniedMessage(p, value.getUuid());
|
SubserverSystem.sendDeniedMessage(p, value.getUUID());
|
||||||
messageSender.send("BAU_TP_NOALLOWED");
|
messageSender.send("BAU_TP_NOALLOWED");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if(BauLock.isLocked(value, SteamwarUser.get(p))) {
|
if(BauLock.isLocked(value, SteamwarUser.get(p.getUniqueId()))) {
|
||||||
messageSender.send("BAU_LOCKED_NOALLOWED");
|
messageSender.send("BAU_LOCKED_NOALLOWED");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -232,13 +235,13 @@ public class BauCommand extends SWCommand {
|
|||||||
if (target == null)
|
if (target == null)
|
||||||
return;
|
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);
|
Message.send("BAU_DELMEMBER_SELFDEL", p);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
target.remove();
|
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){
|
if(toRemove != null){
|
||||||
Message.send("BAU_DELMEMBER_DELETED_TARGET", toRemove, p.getName());
|
Message.send("BAU_DELMEMBER_DELETED_TARGET", toRemove, p.getName());
|
||||||
Subserver currentServer = Subserver.getSubserver(toRemove.getServer().getInfo());
|
Subserver currentServer = Subserver.getSubserver(toRemove.getServer().getInfo());
|
||||||
@ -309,7 +312,7 @@ public class BauCommand extends SWCommand {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
BauweltMember target = BauweltMember.getBauMember(p.getUniqueId(), member.getUuid());
|
BauweltMember target = BauweltMember.getBauMember(p.getUniqueId(), member.getUUID());
|
||||||
if (target == null) {
|
if (target == null) {
|
||||||
Message.send("BAU_MEMBER_NOMEMBER", p);
|
Message.send("BAU_MEMBER_NOMEMBER", p);
|
||||||
return null;
|
return null;
|
||||||
@ -318,7 +321,7 @@ public class BauCommand extends SWCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static void isAllowedTo(boolean permission, ProxiedPlayer p, BauweltMember target, String what){
|
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(permission){
|
||||||
if(player != null)
|
if(player != null)
|
||||||
|
@ -19,8 +19,8 @@
|
|||||||
|
|
||||||
package de.steamwar.bungeecore.commands;
|
package de.steamwar.bungeecore.commands;
|
||||||
|
|
||||||
import de.steamwar.bungeecore.sql.SWException;
|
import de.steamwar.sql.SWException;
|
||||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
import de.steamwar.sql.SteamwarUser;
|
||||||
import de.steamwar.command.SWCommand;
|
import de.steamwar.command.SWCommand;
|
||||||
import de.steamwar.messages.ChatSender;
|
import de.steamwar.messages.ChatSender;
|
||||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||||
@ -34,7 +34,7 @@ public class BugCommand extends SWCommand {
|
|||||||
public void bugMessage(ProxiedPlayer player, String... message) {
|
public void bugMessage(ProxiedPlayer player, String... message) {
|
||||||
String server = player.getServer().getInfo().getName();
|
String server = player.getServer().getInfo().getName();
|
||||||
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
|
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
|
||||||
SWException.log(server, String.join(" ", message), player.getName() + " " + user.getId());
|
SWException.log(String.join(" ", message), server + " " + player.getName() + " " + user.getId());
|
||||||
ChatSender.of(player).system("BUG_MESSAGE");
|
ChatSender.of(player).system("BUG_MESSAGE");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,9 +22,9 @@ package de.steamwar.bungeecore.commands;
|
|||||||
import de.steamwar.bungeecore.Message;
|
import de.steamwar.bungeecore.Message;
|
||||||
import de.steamwar.bungeecore.inventory.SWInventory;
|
import de.steamwar.bungeecore.inventory.SWInventory;
|
||||||
import de.steamwar.bungeecore.inventory.SWItem;
|
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.sql.SchematicNode;
|
||||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
import de.steamwar.sql.SteamwarUser;
|
||||||
import de.steamwar.command.SWCommand;
|
import de.steamwar.command.SWCommand;
|
||||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
package de.steamwar.bungeecore.commands;
|
package de.steamwar.bungeecore.commands;
|
||||||
|
|
||||||
import de.steamwar.bungeecore.*;
|
import de.steamwar.bungeecore.*;
|
||||||
import de.steamwar.bungeecore.sql.IgnoreSystem;
|
import de.steamwar.sql.IgnoreSystem;
|
||||||
import de.steamwar.command.SWCommand;
|
import de.steamwar.command.SWCommand;
|
||||||
import de.steamwar.command.TypeValidator;
|
import de.steamwar.command.TypeValidator;
|
||||||
import net.md_5.bungee.api.chat.ClickEvent;
|
import net.md_5.bungee.api.chat.ClickEvent;
|
||||||
@ -74,7 +74,7 @@ public class ChallengeCommand extends SWCommand {
|
|||||||
messageSender.send("CHALLENGE_SELF");
|
messageSender.send("CHALLENGE_SELF");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (IgnoreSystem.isIgnored(value, (ProxiedPlayer) sender)) {
|
if (IgnoreSystem.isIgnored(value.getUniqueId(), ((ProxiedPlayer) sender).getUniqueId())) {
|
||||||
messageSender.send("CHALLENGE_IGNORED");
|
messageSender.send("CHALLENGE_IGNORED");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -22,10 +22,10 @@ package de.steamwar.bungeecore.commands;
|
|||||||
import de.steamwar.bungeecore.*;
|
import de.steamwar.bungeecore.*;
|
||||||
import de.steamwar.bungeecore.bot.util.DiscordSchemAlert;
|
import de.steamwar.bungeecore.bot.util.DiscordSchemAlert;
|
||||||
import de.steamwar.bungeecore.listeners.ConnectionListener;
|
import de.steamwar.bungeecore.listeners.ConnectionListener;
|
||||||
import de.steamwar.bungeecore.sql.CheckedSchematic;
|
import de.steamwar.sql.CheckedSchematic;
|
||||||
import de.steamwar.bungeecore.sql.SchematicNode;
|
import de.steamwar.sql.SchematicNode;
|
||||||
import de.steamwar.bungeecore.sql.SchematicType;
|
import de.steamwar.sql.SchematicType;
|
||||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
import de.steamwar.sql.SteamwarUser;
|
||||||
import de.steamwar.command.SWCommand;
|
import de.steamwar.command.SWCommand;
|
||||||
import net.md_5.bungee.api.ChatColor;
|
import net.md_5.bungee.api.ChatColor;
|
||||||
import net.md_5.bungee.api.ProxyServer;
|
import net.md_5.bungee.api.ProxyServer;
|
||||||
@ -41,6 +41,7 @@ import java.util.concurrent.TimeUnit;
|
|||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
public class CheckCommand extends SWCommand {
|
public class CheckCommand extends SWCommand {
|
||||||
|
private static final Map<SchematicType, SchematicType> fightTypes = new HashMap<>();
|
||||||
private static Map<SchematicType, List<String>> checkQuestions = new HashMap<>();
|
private static Map<SchematicType, List<String>> checkQuestions = new HashMap<>();
|
||||||
private static Map<SchematicType, List<String>> ranks = new HashMap<>();
|
private static Map<SchematicType, List<String>> ranks = new HashMap<>();
|
||||||
|
|
||||||
@ -53,6 +54,10 @@ public class CheckCommand extends SWCommand {
|
|||||||
ranks.put(checkType, config.getStringList("Ranks"));
|
ranks.put(checkType, config.getStringList("Ranks"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void addFightType(SchematicType checkType, SchematicType fightType) {
|
||||||
|
fightTypes.put(checkType, fightType);
|
||||||
|
}
|
||||||
|
|
||||||
public static boolean isChecking(ProxiedPlayer player){
|
public static boolean isChecking(ProxiedPlayer player){
|
||||||
return currentCheckers.containsKey(player.getUniqueId());
|
return currentCheckers.containsKey(player.getUniqueId());
|
||||||
}
|
}
|
||||||
@ -213,7 +218,7 @@ public class CheckCommand extends SWCommand {
|
|||||||
this.checkList = checkQuestions.get(schematic.getSchemtype()).listIterator();
|
this.checkList = checkQuestions.get(schematic.getSchemtype()).listIterator();
|
||||||
|
|
||||||
ProxyServer.getInstance().getScheduler().runAsync(BungeeCore.get(), () -> {
|
ProxyServer.getInstance().getScheduler().runAsync(BungeeCore.get(), () -> {
|
||||||
ArenaMode mode = ArenaMode.getBySchemType(schematic.getSchemtype().fightType());
|
ArenaMode mode = ArenaMode.getBySchemType(fightTypes.get(schematic.getSchemtype()));
|
||||||
if(new ServerStarter().test(mode, mode.getRandomMap(), checker).check(schematic.getId()).start() == null) {
|
if(new ServerStarter().test(mode, mode.getRandomMap(), checker).check(schematic.getId()).start() == null) {
|
||||||
remove();
|
remove();
|
||||||
return;
|
return;
|
||||||
@ -272,9 +277,9 @@ public class CheckCommand extends SWCommand {
|
|||||||
schematic.setRank(rank);
|
schematic.setRank(rank);
|
||||||
}
|
}
|
||||||
|
|
||||||
schematic.setType(schematic.getSchemtype().fightType().toDB());
|
schematic.setType(fightTypes.get(schematic.getSchemtype()).toDB());
|
||||||
SteamwarUser user = SteamwarUser.get(schematic.getOwner());
|
SteamwarUser user = SteamwarUser.get(schematic.getOwner());
|
||||||
ProxiedPlayer player = ProxyServer.getInstance().getPlayer(user.getUuid());
|
ProxiedPlayer player = ProxyServer.getInstance().getPlayer(user.getUUID());
|
||||||
if(player != null) {
|
if(player != null) {
|
||||||
Message.send("CHECK_ACCEPTED", player, schematic.getSchemtype().name(), schematic.getName());
|
Message.send("CHECK_ACCEPTED", player, schematic.getSchemtype().name(), schematic.getName());
|
||||||
} else {
|
} else {
|
||||||
@ -282,14 +287,13 @@ public class CheckCommand extends SWCommand {
|
|||||||
}
|
}
|
||||||
Message.team("CHECK_ACCEPTED_TEAM", schematic.getName(), user.getUserName());
|
Message.team("CHECK_ACCEPTED_TEAM", schematic.getName(), user.getUserName());
|
||||||
}
|
}
|
||||||
|
|
||||||
stop();
|
stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void decline(String reason){
|
private void decline(String reason){
|
||||||
if(createLog(reason)) {
|
if(createLog(reason)) {
|
||||||
SteamwarUser user = SteamwarUser.get(schematic.getOwner());
|
SteamwarUser user = SteamwarUser.get(schematic.getOwner());
|
||||||
ProxiedPlayer player = ProxyServer.getInstance().getPlayer(user.getUuid());
|
ProxiedPlayer player = ProxyServer.getInstance().getPlayer(user.getUUID());
|
||||||
if(player != null) {
|
if(player != null) {
|
||||||
Message.send("CHECK_DECLINED", player, schematic.getSchemtype().name(), schematic.getName(), reason);
|
Message.send("CHECK_DECLINED", player, schematic.getSchemtype().name(), schematic.getName(), reason);
|
||||||
} else {
|
} else {
|
||||||
|
@ -20,8 +20,8 @@
|
|||||||
package de.steamwar.bungeecore.commands;
|
package de.steamwar.bungeecore.commands;
|
||||||
|
|
||||||
import de.steamwar.bungeecore.Message;
|
import de.steamwar.bungeecore.Message;
|
||||||
import de.steamwar.bungeecore.sql.Punishment;
|
import de.steamwar.sql.Punishment;
|
||||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
import de.steamwar.sql.SteamwarUser;
|
||||||
import de.steamwar.command.*;
|
import de.steamwar.command.*;
|
||||||
import de.steamwar.messages.ChatSender;
|
import de.steamwar.messages.ChatSender;
|
||||||
import net.md_5.bungee.api.ProxyServer;
|
import net.md_5.bungee.api.ProxyServer;
|
||||||
@ -79,9 +79,9 @@ public class DevCommand extends SWCommand {
|
|||||||
@ClassValidator(value = ProxiedPlayer.class, local = true)
|
@ClassValidator(value = ProxiedPlayer.class, local = true)
|
||||||
public TypeValidator<ProxiedPlayer> punishmentGuardChecker() {
|
public TypeValidator<ProxiedPlayer> punishmentGuardChecker() {
|
||||||
return (sender, value, messageSender) -> {
|
return (sender, value, messageSender) -> {
|
||||||
SteamwarUser user = SteamwarUser.get(value);
|
SteamwarUser user = SteamwarUser.get(value.getUniqueId());
|
||||||
if (user.isPunished(Punishment.PunishmentType.NoDevServer)) {
|
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());
|
messageSender.send(message.getFormat(), message.getParams());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,11 @@
|
|||||||
package de.steamwar.bungeecore.commands;
|
package de.steamwar.bungeecore.commands;
|
||||||
|
|
||||||
import de.steamwar.bungeecore.*;
|
import de.steamwar.bungeecore.*;
|
||||||
import de.steamwar.bungeecore.sql.*;
|
import de.steamwar.sql.EventFight;
|
||||||
|
import de.steamwar.sql.SchematicType;
|
||||||
|
import de.steamwar.sql.Team;
|
||||||
|
import de.steamwar.sql.TeamTeilnahme;
|
||||||
|
import de.steamwar.sql.Event;
|
||||||
import de.steamwar.command.SWCommand;
|
import de.steamwar.command.SWCommand;
|
||||||
import de.steamwar.command.SWCommandUtils;
|
import de.steamwar.command.SWCommandUtils;
|
||||||
import de.steamwar.command.TypeMapper;
|
import de.steamwar.command.TypeMapper;
|
||||||
@ -60,10 +64,9 @@ public class EventCommand extends SWCommand {
|
|||||||
if(now.isBefore(e.getDeadline().toInstant())) {
|
if(now.isBefore(e.getDeadline().toInstant())) {
|
||||||
Message.send("EVENT_COMING_DEADLINE", player, e.getDeadline());
|
Message.send("EVENT_COMING_DEADLINE", player, e.getDeadline());
|
||||||
}
|
}
|
||||||
String schemType = e.getSchemType();
|
SchematicType schemType = e.getSchematicType();
|
||||||
if (schemType != null) {
|
if (schemType != null) {
|
||||||
SchematicType schematicType = SchematicType.fromDB(schemType);
|
if (schemType.getDeadline() != null && now.isBefore(schemType.getDeadline().toInstant())) {
|
||||||
if (schematicType != null && schematicType.deadline() != null && now.isBefore(schematicType.deadline().toInstant())) {
|
|
||||||
Message.send("EVENT_COMING_SCHEM_DEADLINE", player, e.getDeadline());
|
Message.send("EVENT_COMING_SCHEM_DEADLINE", player, e.getDeadline());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,11 +20,11 @@
|
|||||||
package de.steamwar.bungeecore.commands;
|
package de.steamwar.bungeecore.commands;
|
||||||
|
|
||||||
import de.steamwar.bungeecore.Message;
|
import de.steamwar.bungeecore.Message;
|
||||||
import de.steamwar.bungeecore.sql.Event;
|
import de.steamwar.sql.EventFight;
|
||||||
import de.steamwar.bungeecore.sql.EventFight;
|
import de.steamwar.sql.Team;
|
||||||
import de.steamwar.bungeecore.sql.Team;
|
|
||||||
import de.steamwar.command.SWCommand;
|
import de.steamwar.command.SWCommand;
|
||||||
import de.steamwar.command.TypeMapper;
|
import de.steamwar.command.TypeMapper;
|
||||||
|
import de.steamwar.sql.Event;
|
||||||
import net.md_5.bungee.api.CommandSender;
|
import net.md_5.bungee.api.CommandSender;
|
||||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
package de.steamwar.bungeecore.commands;
|
package de.steamwar.bungeecore.commands;
|
||||||
|
|
||||||
import de.steamwar.bungeecore.sql.EventFight;
|
import de.steamwar.sql.EventFight;
|
||||||
import de.steamwar.command.SWCommand;
|
import de.steamwar.command.SWCommand;
|
||||||
import net.md_5.bungee.api.CommandSender;
|
import net.md_5.bungee.api.CommandSender;
|
||||||
|
|
||||||
|
@ -22,13 +22,10 @@ package de.steamwar.bungeecore.commands;
|
|||||||
import de.steamwar.bungeecore.*;
|
import de.steamwar.bungeecore.*;
|
||||||
import de.steamwar.bungeecore.inventory.SWInventory;
|
import de.steamwar.bungeecore.inventory.SWInventory;
|
||||||
import de.steamwar.bungeecore.inventory.SWItem;
|
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.command.SWCommand;
|
||||||
import de.steamwar.messages.ChatSender;
|
import de.steamwar.messages.ChatSender;
|
||||||
import net.md_5.bungee.api.ChatColor;
|
import net.md_5.bungee.api.ChatColor;
|
||||||
import net.md_5.bungee.api.ChatMessageType;
|
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.ClickEvent;
|
||||||
import net.md_5.bungee.api.chat.HoverEvent;
|
import net.md_5.bungee.api.chat.HoverEvent;
|
||||||
import net.md_5.bungee.api.chat.TextComponent;
|
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.BungeeCore;
|
||||||
import de.steamwar.bungeecore.Message;
|
import de.steamwar.bungeecore.Message;
|
||||||
import de.steamwar.sql.internal.Statement;
|
import de.steamwar.sql.internal.Statement;
|
||||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
import de.steamwar.sql.SteamwarUser;
|
||||||
import de.steamwar.command.SWCommand;
|
import de.steamwar.command.SWCommand;
|
||||||
import net.md_5.bungee.BungeeCord;
|
import net.md_5.bungee.BungeeCord;
|
||||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||||
@ -25,7 +25,7 @@ public class GDPRQuery extends SWCommand {
|
|||||||
|
|
||||||
@Register
|
@Register
|
||||||
public void generate(ProxiedPlayer player, ProxiedPlayer forPlayer) {
|
public void generate(ProxiedPlayer player, ProxiedPlayer forPlayer) {
|
||||||
SteamwarUser user = SteamwarUser.get(forPlayer);
|
SteamwarUser user = SteamwarUser.get(forPlayer.getUniqueId());
|
||||||
if(user == null) {
|
if(user == null) {
|
||||||
Message.send("UNKNOWN_PLAYER", player);
|
Message.send("UNKNOWN_PLAYER", player);
|
||||||
return;
|
return;
|
||||||
@ -49,7 +49,7 @@ public class GDPRQuery extends SWCommand {
|
|||||||
copy(getClass().getClassLoader().getResourceAsStream("GDPRQueryREADME.md"), out, "README.txt");
|
copy(getClass().getClassLoader().getResourceAsStream("GDPRQueryREADME.md"), out, "README.txt");
|
||||||
|
|
||||||
printUpdate(player, "GDPR_STATUS_WORLD");
|
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");
|
copyBauwelt(user, out, "/home/minecraft/userworlds15/" + user.getId(), "BuildWorld15");
|
||||||
|
|
||||||
printUpdate(player, "GDPR_STATUS_INVENTORIES");
|
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())
|
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 {
|
private void copyPlayerdata(SteamwarUser user, ZipOutputStream out, String inDir, String outDir) throws IOException {
|
||||||
File worlds = new File(inDir);
|
File worlds = new File(inDir);
|
||||||
String path = "playerdata/" + user.getUuid().toString() + ".dat";
|
String path = "playerdata/" + user.getUUID().toString() + ".dat";
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for(File world : worlds.listFiles()) {
|
for(File world : worlds.listFiles()) {
|
||||||
@ -229,7 +229,7 @@ public class GDPRQuery extends SWCommand {
|
|||||||
if(!playerdata.exists())
|
if(!playerdata.exists())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
copy(playerdata, out, outDir + "/" + (i++) + "/" + user.getUuid().toString() + ".dat");
|
copy(playerdata, out, outDir + "/" + (i++) + "/" + user.getUUID().toString() + ".dat");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,13 +20,12 @@
|
|||||||
package de.steamwar.bungeecore.commands;
|
package de.steamwar.bungeecore.commands;
|
||||||
|
|
||||||
import de.steamwar.bungeecore.Message;
|
import de.steamwar.bungeecore.Message;
|
||||||
import de.steamwar.bungeecore.sql.IgnoreSystem;
|
import de.steamwar.sql.IgnoreSystem;
|
||||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
import de.steamwar.sql.SteamwarUser;
|
||||||
import de.steamwar.command.SWCommand;
|
import de.steamwar.command.SWCommand;
|
||||||
import de.steamwar.command.SWCommandUtils;
|
import de.steamwar.command.SWCommandUtils;
|
||||||
import de.steamwar.command.TypeMapper;
|
import de.steamwar.command.TypeMapper;
|
||||||
import net.md_5.bungee.BungeeCord;
|
import net.md_5.bungee.BungeeCord;
|
||||||
import net.md_5.bungee.api.CommandSender;
|
|
||||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||||
|
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
package de.steamwar.bungeecore.commands;
|
package de.steamwar.bungeecore.commands;
|
||||||
|
|
||||||
import de.steamwar.bungeecore.*;
|
import de.steamwar.bungeecore.*;
|
||||||
import de.steamwar.bungeecore.sql.BauweltMember;
|
import de.steamwar.sql.BauweltMember;
|
||||||
import de.steamwar.command.SWCommand;
|
import de.steamwar.command.SWCommand;
|
||||||
import de.steamwar.command.TypeValidator;
|
import de.steamwar.command.TypeValidator;
|
||||||
import net.md_5.bungee.api.CommandSender;
|
import net.md_5.bungee.api.CommandSender;
|
||||||
|
@ -24,8 +24,8 @@ import de.steamwar.bungeecore.inventory.SWInventory;
|
|||||||
import de.steamwar.bungeecore.inventory.SWItem;
|
import de.steamwar.bungeecore.inventory.SWItem;
|
||||||
import de.steamwar.bungeecore.inventory.SWListInv;
|
import de.steamwar.bungeecore.inventory.SWListInv;
|
||||||
import de.steamwar.bungeecore.inventory.SWStreamInv;
|
import de.steamwar.bungeecore.inventory.SWStreamInv;
|
||||||
import de.steamwar.bungeecore.sql.*;
|
|
||||||
import de.steamwar.command.SWCommand;
|
import de.steamwar.command.SWCommand;
|
||||||
|
import de.steamwar.sql.Mod;
|
||||||
import net.md_5.bungee.api.chat.ClickEvent;
|
import net.md_5.bungee.api.chat.ClickEvent;
|
||||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||||
|
|
||||||
@ -39,7 +39,7 @@ public class ModCommand extends SWCommand {
|
|||||||
super("mod", "bungeecore.softreload", "mods");
|
super("mod", "bungeecore.softreload", "mods");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final Map<ProxiedPlayer,Mod.ModType> playerFilterType = new HashMap<>();
|
public static final Map<ProxiedPlayer, Mod.ModType> playerFilterType = new HashMap<>();
|
||||||
|
|
||||||
@Register
|
@Register
|
||||||
public void genericCommand(ProxiedPlayer p) {
|
public void genericCommand(ProxiedPlayer p) {
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
package de.steamwar.bungeecore.commands;
|
package de.steamwar.bungeecore.commands;
|
||||||
|
|
||||||
import de.steamwar.bungeecore.listeners.ChatListener;
|
import de.steamwar.bungeecore.listeners.ChatListener;
|
||||||
import de.steamwar.bungeecore.sql.IgnoreSystem;
|
import de.steamwar.sql.IgnoreSystem;
|
||||||
import de.steamwar.command.SWCommand;
|
import de.steamwar.command.SWCommand;
|
||||||
import de.steamwar.messages.ChatSender;
|
import de.steamwar.messages.ChatSender;
|
||||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||||
@ -47,7 +47,7 @@ public class MsgCommand extends SWCommand {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IgnoreSystem.isIgnored(target, player)) {
|
if (IgnoreSystem.isIgnored(target.getUniqueId(), player.getUniqueId())) {
|
||||||
sender.system("MSG_IGNORED");
|
sender.system("MSG_IGNORED");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -20,15 +20,11 @@
|
|||||||
package de.steamwar.bungeecore.commands;
|
package de.steamwar.bungeecore.commands;
|
||||||
|
|
||||||
import de.steamwar.bungeecore.Message;
|
import de.steamwar.bungeecore.Message;
|
||||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
import de.steamwar.sql.SteamwarUser;
|
||||||
import de.steamwar.command.SWCommand;
|
import de.steamwar.command.SWCommand;
|
||||||
import net.md_5.bungee.api.CommandSender;
|
|
||||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||||
import org.apache.commons.lang3.LocaleUtils;
|
|
||||||
|
|
||||||
import java.text.DecimalFormat;
|
|
||||||
import java.text.NumberFormat;
|
import java.text.NumberFormat;
|
||||||
import java.util.Locale;
|
|
||||||
|
|
||||||
public class PlaytimeCommand extends SWCommand {
|
public class PlaytimeCommand extends SWCommand {
|
||||||
|
|
||||||
@ -40,7 +36,7 @@ public class PlaytimeCommand extends SWCommand {
|
|||||||
public void genericCommand(ProxiedPlayer player) {
|
public void genericCommand(ProxiedPlayer player) {
|
||||||
NumberFormat format = NumberFormat.getNumberInstance((player).getLocale());
|
NumberFormat format = NumberFormat.getNumberInstance((player).getLocale());
|
||||||
format.setMaximumFractionDigits(2);
|
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);
|
Message.send("HOURS_PLAYED", player, formattedText);
|
||||||
}
|
}
|
||||||
|
@ -21,8 +21,8 @@ package de.steamwar.bungeecore.commands;
|
|||||||
|
|
||||||
import de.steamwar.bungeecore.Message;
|
import de.steamwar.bungeecore.Message;
|
||||||
import de.steamwar.bungeecore.listeners.PollSystem;
|
import de.steamwar.bungeecore.listeners.PollSystem;
|
||||||
import de.steamwar.bungeecore.sql.PollAnswer;
|
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.SWCommand;
|
||||||
import de.steamwar.command.TypeValidator;
|
import de.steamwar.command.TypeValidator;
|
||||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||||
|
@ -21,7 +21,7 @@ package de.steamwar.bungeecore.commands;
|
|||||||
|
|
||||||
import de.steamwar.bungeecore.Message;
|
import de.steamwar.bungeecore.Message;
|
||||||
import de.steamwar.bungeecore.listeners.PollSystem;
|
import de.steamwar.bungeecore.listeners.PollSystem;
|
||||||
import de.steamwar.bungeecore.sql.PollAnswer;
|
import de.steamwar.sql.PollAnswer;
|
||||||
import de.steamwar.command.SWCommand;
|
import de.steamwar.command.SWCommand;
|
||||||
import de.steamwar.command.TypeValidator;
|
import de.steamwar.command.TypeValidator;
|
||||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||||
@ -36,10 +36,10 @@ public class PollresultCommand extends SWCommand {
|
|||||||
|
|
||||||
@Register
|
@Register
|
||||||
public void genericCommand(@Validator ProxiedPlayer player) {
|
public void genericCommand(@Validator ProxiedPlayer player) {
|
||||||
Map<String, Integer> voted = PollAnswer.getCurrentResults();
|
Map<Integer, Integer> voted = PollAnswer.getCurrentResults();
|
||||||
Message.send("POLLRESULT_HEADER", player, voted.values().stream().reduce(Integer::sum).orElse(0), PollSystem.getQuestion());
|
Message.send("POLLRESULT_HEADER", player, voted.values().stream().reduce(Integer::sum).orElse(0), PollAnswer.getCurrentPoll());
|
||||||
for (Map.Entry<String, Integer> e: voted.entrySet()) {
|
for (Map.Entry<Integer, Integer> e: voted.entrySet()) {
|
||||||
Message.send("POLLRESULT_LIST", player, e.getKey(), e.getValue());
|
Message.send("POLLRESULT_LIST", player, PollSystem.getAnswer(e.getKey()), e.getValue());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,13 +19,20 @@
|
|||||||
|
|
||||||
package de.steamwar.bungeecore.commands;
|
package de.steamwar.bungeecore.commands;
|
||||||
|
|
||||||
|
import com.google.gson.JsonParser;
|
||||||
|
import de.steamwar.bungeecore.BungeeCore;
|
||||||
import de.steamwar.bungeecore.Message;
|
import de.steamwar.bungeecore.Message;
|
||||||
import de.steamwar.bungeecore.sql.Punishment;
|
import de.steamwar.sql.SteamwarUser;
|
||||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
|
||||||
import de.steamwar.command.SWCommand;
|
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.CommandSender;
|
||||||
|
import net.md_5.bungee.api.ProxyServer;
|
||||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.net.URL;
|
||||||
import java.sql.Timestamp;
|
import java.sql.Timestamp;
|
||||||
import java.text.ParseException;
|
import java.text.ParseException;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
@ -33,17 +40,84 @@ import java.time.Duration;
|
|||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
import java.time.temporal.ChronoUnit;
|
import java.time.temporal.ChronoUnit;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.regex.MatchResult;
|
import java.util.NoSuchElementException;
|
||||||
import java.util.regex.Matcher;
|
import java.util.Scanner;
|
||||||
|
import java.util.UUID;
|
||||||
|
import java.util.logging.Level;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
public class PunishmentCommand {
|
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) {
|
public PunishmentCommand(String command, Punishment.PunishmentType punishmentType) {
|
||||||
new SWCommand(command, "bungeecore.ban") {
|
new SWCommand(command, "bungeecore.ban") {
|
||||||
@Register(description = "PUNISHMENT_USAGE")
|
@Register(description = "PUNISHMENT_USAGE")
|
||||||
public void genericCommand(ProxiedPlayer player, String toPunish, String date, String... message) {
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -57,7 +131,10 @@ public class PunishmentCommand {
|
|||||||
|
|
||||||
boolean isPerma = date.equalsIgnoreCase("perma");
|
boolean isPerma = date.equalsIgnoreCase("perma");
|
||||||
String msg = String.join(" ", message);
|
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);
|
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") {
|
new SWCommand(antiCommand, "bungeecore.ban") {
|
||||||
@Register(description = "PUNISHMENT_USAGE")
|
@Register(description = "PUNISHMENT_USAGE")
|
||||||
public void genericCommand(ProxiedPlayer player, String toUnpunish) {
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -83,6 +160,8 @@ public class PunishmentCommand {
|
|||||||
|
|
||||||
Message.send(punishmentType.getUnpunishmentMessage(), player, target.getUserName());
|
Message.send(punishmentType.getUnpunishmentMessage(), player, target.getUserName());
|
||||||
target.punish(punishmentType, Timestamp.from(new Date().toInstant()), antiCommand, SteamwarUser.get(player.getName()).getId(), false);
|
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){
|
protected SteamwarUser unsafeUser(CommandSender sender, String arg){
|
||||||
SteamwarUser target = SteamwarUser.getOrCreateOfflinePlayer(arg);
|
SteamwarUser target = getOrCreateOfflinePlayer(arg);
|
||||||
if(target == null)
|
if(target == null)
|
||||||
Message.send("UNKNOWN_PLAYER", sender);
|
Message.send("UNKNOWN_PLAYER", sender);
|
||||||
return target;
|
return target;
|
||||||
|
@ -21,13 +21,12 @@ package de.steamwar.bungeecore.commands;
|
|||||||
|
|
||||||
import de.steamwar.bungeecore.ArenaMode;
|
import de.steamwar.bungeecore.ArenaMode;
|
||||||
import de.steamwar.bungeecore.Message;
|
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.sql.UserElo;
|
||||||
import de.steamwar.command.SWCommand;
|
import de.steamwar.command.SWCommand;
|
||||||
import de.steamwar.command.SWCommandUtils;
|
import de.steamwar.command.SWCommandUtils;
|
||||||
import de.steamwar.command.TypeMapper;
|
import de.steamwar.command.TypeMapper;
|
||||||
import net.md_5.bungee.BungeeCord;
|
import net.md_5.bungee.BungeeCord;
|
||||||
import net.md_5.bungee.api.CommandSender;
|
|
||||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||||
|
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
@ -68,10 +67,18 @@ public class RankCommand extends SWCommand {
|
|||||||
} else {
|
} else {
|
||||||
Message.send("RANK_UNPLACED", player);
|
Message.send("RANK_UNPLACED", player);
|
||||||
}
|
}
|
||||||
Message.send("RANK_EMBLEM", player, UserElo.getEmblemProgression(player, mode.getChatName(), user.getId()));
|
Message.send("RANK_EMBLEM", player, getEmblemProgression(player, mode.getChatName(), user.getId()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static String getEmblemProgression(ProxiedPlayer player, String gameMode, int userId) {
|
||||||
|
int fightsOfSeason = UserElo.getFightsOfSeason(userId, gameMode);
|
||||||
|
if (fightsOfSeason < 10)
|
||||||
|
return Message.parse("RANK_NEEDED_FIGHTS_LEFT", player, "§8✧ ✦ ✶ ✷ ✸ ✹ ❂", 10 - fightsOfSeason);
|
||||||
|
|
||||||
|
return UserElo.getEmblemProgression(gameMode, userId);
|
||||||
|
}
|
||||||
|
|
||||||
@Mapper(value = "player", local = true)
|
@Mapper(value = "player", local = true)
|
||||||
public TypeMapper<String> playerTypeMapper() {
|
public TypeMapper<String> playerTypeMapper() {
|
||||||
return SWCommandUtils.createMapper(s -> s, s -> BungeeCord.getInstance().getPlayers().stream().map(ProxiedPlayer::getName).collect(Collectors.toList()));
|
return SWCommandUtils.createMapper(s -> s, s -> BungeeCord.getInstance().getPlayers().stream().map(ProxiedPlayer::getName).collect(Collectors.toList()));
|
||||||
|
@ -23,13 +23,12 @@ import de.steamwar.bungeecore.*;
|
|||||||
import de.steamwar.bungeecore.inventory.SWItem;
|
import de.steamwar.bungeecore.inventory.SWItem;
|
||||||
import de.steamwar.bungeecore.inventory.SWListInv;
|
import de.steamwar.bungeecore.inventory.SWListInv;
|
||||||
import de.steamwar.bungeecore.inventory.SWStreamInv;
|
import de.steamwar.bungeecore.inventory.SWStreamInv;
|
||||||
import de.steamwar.bungeecore.sql.Fight;
|
import de.steamwar.sql.Fight;
|
||||||
import de.steamwar.bungeecore.sql.Punishment;
|
import de.steamwar.sql.Punishment;
|
||||||
import de.steamwar.bungeecore.sql.SchematicType;
|
import de.steamwar.sql.SchematicType;
|
||||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
import de.steamwar.sql.SteamwarUser;
|
||||||
import de.steamwar.command.SWCommand;
|
import de.steamwar.command.SWCommand;
|
||||||
import de.steamwar.messages.ChatSender;
|
import de.steamwar.messages.ChatSender;
|
||||||
import net.md_5.bungee.api.CommandSender;
|
|
||||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -45,12 +44,12 @@ public class ReplayCommand extends SWCommand {
|
|||||||
@Register
|
@Register
|
||||||
public void genericCommand(ProxiedPlayer player, @OptionalValue("") String optionalMap) {
|
public void genericCommand(ProxiedPlayer player, @OptionalValue("") String optionalMap) {
|
||||||
ChatSender sender = ChatSender.of(player);
|
ChatSender sender = ChatSender.of(player);
|
||||||
if (sender.user().isPunishedWithMessage(sender, Punishment.PunishmentType.NoFightServer))
|
if (PunishmentCommand.isPunishedWithMessage(sender, Punishment.PunishmentType.NoFightServer))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
new SWStreamInv<>(player, Message.parse("REPLAY_TITLE", player), (click, fight) -> {
|
new SWStreamInv<>(player, Message.parse("REPLAY_TITLE", player), (click, fight) -> {
|
||||||
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
|
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);
|
ServerStarter starter = new ServerStarter().replay(fight.getFightID()).blueLeader(player);
|
||||||
|
|
||||||
String map = mode.getRandomMap();
|
String map = mode.getRandomMap();
|
||||||
|
@ -19,8 +19,10 @@
|
|||||||
|
|
||||||
package de.steamwar.bungeecore.commands;
|
package de.steamwar.bungeecore.commands;
|
||||||
|
|
||||||
|
import de.steamwar.bungeecore.network.NetworkSender;
|
||||||
import de.steamwar.command.SWCommand;
|
import de.steamwar.command.SWCommand;
|
||||||
import de.steamwar.messages.ChatSender;
|
import de.steamwar.messages.ChatSender;
|
||||||
|
import de.steamwar.network.packets.server.LocaleInvalidationPacket;
|
||||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||||
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
@ -35,6 +37,7 @@ public class SetLocaleCommand extends SWCommand {
|
|||||||
public void genericCommand(ProxiedPlayer player) {
|
public void genericCommand(ProxiedPlayer player) {
|
||||||
ChatSender sender = ChatSender.of(player);
|
ChatSender sender = ChatSender.of(player);
|
||||||
sender.user().setLocale(Objects.requireNonNull(player.getLocale()), true);
|
sender.user().setLocale(Objects.requireNonNull(player.getLocale()), true);
|
||||||
|
NetworkSender.send(player, new LocaleInvalidationPacket(sender.user().getId()));
|
||||||
sender.system("LOCK_LOCALE_CHANGED");
|
sender.system("LOCK_LOCALE_CHANGED");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,11 +23,15 @@ import de.steamwar.bungeecore.Message;
|
|||||||
import de.steamwar.bungeecore.Storage;
|
import de.steamwar.bungeecore.Storage;
|
||||||
import de.steamwar.bungeecore.inventory.SWItem;
|
import de.steamwar.bungeecore.inventory.SWItem;
|
||||||
import de.steamwar.bungeecore.inventory.SWListInv;
|
import de.steamwar.bungeecore.inventory.SWListInv;
|
||||||
import de.steamwar.bungeecore.sql.*;
|
import de.steamwar.sql.Punishment;
|
||||||
|
import de.steamwar.sql.SteamwarUser;
|
||||||
|
import de.steamwar.sql.Team;
|
||||||
|
import de.steamwar.sql.TeamTeilnahme;
|
||||||
import de.steamwar.command.PreviousArguments;
|
import de.steamwar.command.PreviousArguments;
|
||||||
import de.steamwar.command.SWCommand;
|
import de.steamwar.command.SWCommand;
|
||||||
import de.steamwar.command.TypeMapper;
|
import de.steamwar.command.TypeMapper;
|
||||||
import de.steamwar.messages.ChatSender;
|
import de.steamwar.messages.ChatSender;
|
||||||
|
import de.steamwar.sql.Event;
|
||||||
import net.md_5.bungee.BungeeCord;
|
import net.md_5.bungee.BungeeCord;
|
||||||
import net.md_5.bungee.api.ChatColor;
|
import net.md_5.bungee.api.ChatColor;
|
||||||
import net.md_5.bungee.api.CommandSender;
|
import net.md_5.bungee.api.CommandSender;
|
||||||
@ -250,7 +254,7 @@ public class TeamCommand extends SWCommand {
|
|||||||
teamInvitations.get(target.getId()).add(team.getTeamId());
|
teamInvitations.get(target.getId()).add(team.getTeamId());
|
||||||
|
|
||||||
Message.send("TEAM_INVITE_INVITED", player, toInvite);
|
Message.send("TEAM_INVITE_INVITED", player, toInvite);
|
||||||
ProxiedPlayer p = ProxyServer.getInstance().getPlayer(target.getUuid());
|
ProxiedPlayer p = ProxyServer.getInstance().getPlayer(target.getUUID());
|
||||||
if(p != null)
|
if(p != null)
|
||||||
Message.send("TEAM_INVITE_INVITED_TARGET", p, team.getTeamColor(), team.getTeamName());
|
Message.send("TEAM_INVITE_INVITED_TARGET", p, team.getTeamColor(), team.getTeamName());
|
||||||
}
|
}
|
||||||
@ -292,7 +296,7 @@ public class TeamCommand extends SWCommand {
|
|||||||
target.setTeam(0);
|
target.setTeam(0);
|
||||||
|
|
||||||
Message.send("TEAM_REMOVE_REMOVED", player);
|
Message.send("TEAM_REMOVE_REMOVED", player);
|
||||||
ProxiedPlayer p = ProxyServer.getInstance().getPlayer(target.getUuid());
|
ProxiedPlayer p = ProxyServer.getInstance().getPlayer(target.getUUID());
|
||||||
if(p != null)
|
if(p != null)
|
||||||
Message.send("TEAM_REMOVE_REMOVED_TARGET", player);
|
Message.send("TEAM_REMOVE_REMOVED_TARGET", player);
|
||||||
}
|
}
|
||||||
@ -356,7 +360,7 @@ public class TeamCommand extends SWCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private String playerName(SteamwarUser user){
|
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();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Register("info")
|
@Register("info")
|
||||||
@ -543,7 +547,7 @@ public class TeamCommand extends SWCommand {
|
|||||||
Team team = Team.get(user.getTeam());
|
Team team = Team.get(user.getTeam());
|
||||||
if(notLeader(player, user))
|
if(notLeader(player, user))
|
||||||
return;
|
return;
|
||||||
if (user.isPunishedWithMessage(ChatSender.of(player), Punishment.PunishmentType.NoTeamServer)) {
|
if (PunishmentCommand.isPunishedWithMessage(ChatSender.of(player), Punishment.PunishmentType.NoTeamServer)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
package de.steamwar.bungeecore.commands;
|
package de.steamwar.bungeecore.commands;
|
||||||
|
|
||||||
import de.steamwar.bungeecore.listeners.ChatListener;
|
import de.steamwar.bungeecore.listeners.ChatListener;
|
||||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
import de.steamwar.sql.SteamwarUser;
|
||||||
import de.steamwar.command.SWCommand;
|
import de.steamwar.command.SWCommand;
|
||||||
import de.steamwar.messages.ChatSender;
|
import de.steamwar.messages.ChatSender;
|
||||||
import net.md_5.bungee.api.CommandSender;
|
import net.md_5.bungee.api.CommandSender;
|
||||||
|
@ -20,11 +20,16 @@
|
|||||||
package de.steamwar.bungeecore.commands;
|
package de.steamwar.bungeecore.commands;
|
||||||
|
|
||||||
import de.steamwar.bungeecore.*;
|
import de.steamwar.bungeecore.*;
|
||||||
import de.steamwar.bungeecore.sql.*;
|
import de.steamwar.sql.BauweltMember;
|
||||||
|
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;
|
import de.steamwar.bungeecore.util.Chat19;
|
||||||
import de.steamwar.command.SWCommand;
|
import de.steamwar.command.SWCommand;
|
||||||
import de.steamwar.command.TypeMapper;
|
import de.steamwar.command.TypeMapper;
|
||||||
import de.steamwar.messages.ChatSender;
|
import de.steamwar.messages.ChatSender;
|
||||||
|
import de.steamwar.sql.Event;
|
||||||
import net.md_5.bungee.BungeeCord;
|
import net.md_5.bungee.BungeeCord;
|
||||||
import net.md_5.bungee.api.CommandSender;
|
import net.md_5.bungee.api.CommandSender;
|
||||||
import net.md_5.bungee.api.ProxyServer;
|
import net.md_5.bungee.api.ProxyServer;
|
||||||
@ -101,14 +106,14 @@ public class TpCommand extends SWCommand {
|
|||||||
Subserver subserver = Subserver.getSubserver(server);
|
Subserver subserver = Subserver.getSubserver(server);
|
||||||
|
|
||||||
if (subserver != null && subserver.getType() == Servertype.ARENA) {
|
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);
|
SubserverSystem.sendPlayer(subserver, player);
|
||||||
|
|
||||||
} else if(subserver instanceof Bauserver) {
|
} else if(subserver instanceof Bauserver) {
|
||||||
Bauserver bauserver = (Bauserver) subserver;
|
Bauserver bauserver = (Bauserver) subserver;
|
||||||
ProxiedPlayer checker = BungeeCord.getInstance().getPlayer(bauserver.getOwner());
|
ProxiedPlayer checker = BungeeCord.getInstance().getPlayer(bauserver.getOwner());
|
||||||
if (checker != null && CheckCommand.isChecking(checker)) {
|
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()) {
|
if (steamwarUser.getUserGroup().isCheckSchematics() || CheckCommand.getCheckingSchem(checker).getOwner() == steamwarUser.getId()) {
|
||||||
SubserverSystem.sendPlayer(subserver, player);
|
SubserverSystem.sendPlayer(subserver, player);
|
||||||
} else {
|
} else {
|
||||||
|
@ -24,8 +24,8 @@ import de.steamwar.bungeecore.inventory.SWInventory;
|
|||||||
import de.steamwar.bungeecore.inventory.SWItem;
|
import de.steamwar.bungeecore.inventory.SWItem;
|
||||||
import de.steamwar.bungeecore.inventory.SWListInv;
|
import de.steamwar.bungeecore.inventory.SWListInv;
|
||||||
import de.steamwar.bungeecore.inventory.SWStreamInv;
|
import de.steamwar.bungeecore.inventory.SWStreamInv;
|
||||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
import de.steamwar.sql.SteamwarUser;
|
||||||
import de.steamwar.bungeecore.sql.Tutorial;
|
import de.steamwar.sql.Tutorial;
|
||||||
import de.steamwar.bungeecore.util.Chat19;
|
import de.steamwar.bungeecore.util.Chat19;
|
||||||
import de.steamwar.command.SWCommand;
|
import de.steamwar.command.SWCommand;
|
||||||
import de.steamwar.command.TypeValidator;
|
import de.steamwar.command.TypeValidator;
|
||||||
@ -96,36 +96,37 @@ public class TutorialCommand extends SWCommand {
|
|||||||
player,
|
player,
|
||||||
Message.parse("TUTORIAL_TITLE", player),
|
Message.parse("TUTORIAL_TITLE", player),
|
||||||
(click, tutorial) -> {
|
(click, tutorial) -> {
|
||||||
if(!released && click.isShiftClick() && user.getUserGroup().isTeamGroup() && user != tutorial.creator()) {
|
if(!released && click.isShiftClick() && user.getUserGroup().isTeamGroup() && user.getId() != tutorial.getCreator()) {
|
||||||
tutorial.release();
|
tutorial.release();
|
||||||
openInventory(player, released, own);
|
openInventory(player, released, own);
|
||||||
return;
|
return;
|
||||||
} else if(own && click.isShiftClick() && click.isRightClick()) {
|
} else if(own && click.isShiftClick() && click.isRightClick()) {
|
||||||
tutorial.delete();
|
tutorial.delete();
|
||||||
|
SubserverSystem.deleteFolder(BungeeCore.local, world(tutorial).getPath());
|
||||||
openInventory(player, released, own);
|
openInventory(player, released, own);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
new ServerStarter().tutorial(player, tutorial).start();
|
new ServerStarter().tutorial(player, tutorial).start();
|
||||||
},
|
},
|
||||||
page -> (own ? Tutorial.getOwn(user, page, 45) : Tutorial.getPage(page, 45, released)).stream().map(tutorial -> new SWListInv.SWListEntry<>(getTutorialItem(player, tutorial, own), tutorial)).collect(Collectors.toList())
|
page -> (own ? Tutorial.getOwn(user.getId(), page, 45) : Tutorial.getPage(page, 45, released)).stream().map(tutorial -> new SWListInv.SWListEntry<>(getTutorialItem(player, tutorial, own), tutorial)).collect(Collectors.toList())
|
||||||
).open();
|
).open();
|
||||||
}
|
}
|
||||||
|
|
||||||
private SWItem getTutorialItem(ProxiedPlayer player, Tutorial tutorial, boolean personalHighlights) {
|
private SWItem getTutorialItem(ProxiedPlayer player, Tutorial tutorial, boolean personalHighlights) {
|
||||||
SWItem item = new SWItem(tutorial.item(), Message.parse("TUTORIAL_NAME", player, tutorial.name()));
|
SWItem item = new SWItem(tutorial.getItem(), Message.parse("TUTORIAL_NAME", player, tutorial.getName()));
|
||||||
item.setHideAttributes(true);
|
item.setHideAttributes(true);
|
||||||
|
|
||||||
List<String> lore = new ArrayList<>();
|
List<String> lore = new ArrayList<>();
|
||||||
lore.add(Message.parse("TUTORIAL_BY", player, tutorial.creator().getUserName()));
|
lore.add(Message.parse("TUTORIAL_BY", player, SteamwarUser.get(tutorial.getCreator()).getUserName()));
|
||||||
lore.add(Message.parse("TUTORIAL_STARS", player, String.format("%.1f", tutorial.stars())));
|
lore.add(Message.parse("TUTORIAL_STARS", player, String.format("%.1f", tutorial.getStars())));
|
||||||
|
|
||||||
if (personalHighlights)
|
if (personalHighlights)
|
||||||
lore.add(Message.parse("TUTORIAL_DELETE", player));
|
lore.add(Message.parse("TUTORIAL_DELETE", player));
|
||||||
|
|
||||||
item.setLore(lore);
|
item.setLore(lore);
|
||||||
|
|
||||||
if (personalHighlights && tutorial.released())
|
if (personalHighlights && tutorial.isReleased())
|
||||||
item.setEnchanted(true);
|
item.setEnchanted(true);
|
||||||
|
|
||||||
return item;
|
return item;
|
||||||
@ -136,7 +137,7 @@ public class TutorialCommand extends SWCommand {
|
|||||||
int[] rates = new int[]{1, 2, 3, 4, 5};
|
int[] rates = new int[]{1, 2, 3, 4, 5};
|
||||||
|
|
||||||
new SWListInv<>(player, Message.parse("TUTORIAL_RATE_TITLE", player), Arrays.stream(rates).mapToObj(rate -> new SWListInv.SWListEntry<>(new SWItem("NETHER_STAR", Message.parse("TUTORIAL_RATE", player, rate)), rate)).collect(Collectors.toList()), (click, rate) -> {
|
new SWListInv<>(player, Message.parse("TUTORIAL_RATE_TITLE", player), Arrays.stream(rates).mapToObj(rate -> new SWListInv.SWListEntry<>(new SWItem("NETHER_STAR", Message.parse("TUTORIAL_RATE", player, rate)), rate)).collect(Collectors.toList()), (click, rate) -> {
|
||||||
tutorial.rate(user, rate);
|
tutorial.rate(user.getId(), rate);
|
||||||
SWInventory.close(player);
|
SWInventory.close(player);
|
||||||
}).open();
|
}).open();
|
||||||
}
|
}
|
||||||
@ -153,8 +154,8 @@ public class TutorialCommand extends SWCommand {
|
|||||||
|
|
||||||
subserver.execute("save-all");
|
subserver.execute("save-all");
|
||||||
ProxyServer.getInstance().getScheduler().schedule(BungeeCore.get(), () -> {
|
ProxyServer.getInstance().getScheduler().schedule(BungeeCore.get(), () -> {
|
||||||
Tutorial tutorial = Tutorial.create(user, name, item);
|
Tutorial tutorial = Tutorial.create(user.getId(), name, item);
|
||||||
File tutorialWorld = tutorial.world();
|
File tutorialWorld = world(tutorial);
|
||||||
|
|
||||||
if (tutorialWorld.exists())
|
if (tutorialWorld.exists())
|
||||||
SubserverSystem.deleteFolder(BungeeCore.local, tutorialWorld.getPath());
|
SubserverSystem.deleteFolder(BungeeCore.local, tutorialWorld.getPath());
|
||||||
@ -162,4 +163,8 @@ public class TutorialCommand extends SWCommand {
|
|||||||
Message.send("TUTORIAL_CREATED", player);
|
Message.send("TUTORIAL_CREATED", player);
|
||||||
}, 1, TimeUnit.SECONDS);
|
}, 1, TimeUnit.SECONDS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private File world(Tutorial tutorial) {
|
||||||
|
return new File(ServerStarter.TUTORIAL_PATH, String.valueOf(tutorial.getTutorialId()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,7 @@ package de.steamwar.bungeecore.commands;
|
|||||||
|
|
||||||
import de.steamwar.bungeecore.ArenaMode;
|
import de.steamwar.bungeecore.ArenaMode;
|
||||||
import de.steamwar.bungeecore.listeners.mods.ModLoaderBlocker;
|
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.SWCommandUtils;
|
||||||
import de.steamwar.command.TypeMapper;
|
import de.steamwar.command.TypeMapper;
|
||||||
import de.steamwar.command.TypeValidator;
|
import de.steamwar.command.TypeValidator;
|
||||||
@ -33,7 +33,6 @@ import net.md_5.bungee.api.connection.ProxiedPlayer;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
@UtilityClass
|
@UtilityClass
|
||||||
public class TypeMappers {
|
public class TypeMappers {
|
||||||
@ -48,7 +47,7 @@ public class TypeMappers {
|
|||||||
private static TypeValidator<ProxiedPlayer> arenaPlayer() {
|
private static TypeValidator<ProxiedPlayer> arenaPlayer() {
|
||||||
return (sender, value, messageSender) -> {
|
return (sender, value, messageSender) -> {
|
||||||
ChatSender player = ChatSender.of(value);
|
ChatSender player = ChatSender.of(value);
|
||||||
if (player.user().isPunishedWithMessage(player, Punishment.PunishmentType.NoFightServer)) {
|
if (PunishmentCommand.isPunishedWithMessage(player, Punishment.PunishmentType.NoFightServer)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,8 +20,8 @@
|
|||||||
package de.steamwar.bungeecore.commands;
|
package de.steamwar.bungeecore.commands;
|
||||||
|
|
||||||
import de.steamwar.bungeecore.Message;
|
import de.steamwar.bungeecore.Message;
|
||||||
import de.steamwar.bungeecore.sql.IgnoreSystem;
|
import de.steamwar.sql.IgnoreSystem;
|
||||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
import de.steamwar.sql.SteamwarUser;
|
||||||
import de.steamwar.command.SWCommand;
|
import de.steamwar.command.SWCommand;
|
||||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
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.BungeeCore;
|
||||||
import de.steamwar.bungeecore.Message;
|
import de.steamwar.bungeecore.Message;
|
||||||
import de.steamwar.bungeecore.bot.AuthManager;
|
import de.steamwar.bungeecore.bot.AuthManager;
|
||||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
import de.steamwar.sql.SteamwarUser;
|
||||||
import de.steamwar.command.SWCommand;
|
import de.steamwar.command.SWCommand;
|
||||||
import net.dv8tion.jda.api.entities.Member;
|
import net.dv8tion.jda.api.entities.Member;
|
||||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||||
|
@ -22,10 +22,10 @@ package de.steamwar.bungeecore.commands;
|
|||||||
import de.steamwar.bungeecore.Message;
|
import de.steamwar.bungeecore.Message;
|
||||||
import de.steamwar.bungeecore.Storage;
|
import de.steamwar.bungeecore.Storage;
|
||||||
import de.steamwar.bungeecore.listeners.mods.Utils;
|
import de.steamwar.bungeecore.listeners.mods.Utils;
|
||||||
import de.steamwar.bungeecore.sql.*;
|
|
||||||
import de.steamwar.command.SWCommand;
|
import de.steamwar.command.SWCommand;
|
||||||
import de.steamwar.command.SWCommandUtils;
|
import de.steamwar.command.SWCommandUtils;
|
||||||
import de.steamwar.command.TypeMapper;
|
import de.steamwar.command.TypeMapper;
|
||||||
|
import de.steamwar.sql.*;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import net.md_5.bungee.BungeeCord;
|
import net.md_5.bungee.BungeeCord;
|
||||||
import net.md_5.bungee.api.CommandSender;
|
import net.md_5.bungee.api.CommandSender;
|
||||||
@ -87,7 +87,7 @@ public class WhoisCommand extends SWCommand {
|
|||||||
if (!userGroup.isTeamGroup()) return;
|
if (!userGroup.isTeamGroup()) return;
|
||||||
|
|
||||||
if (userGroup.isAdminGroup()) {
|
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());
|
Message.send("WHOIS_ID", player, user.getId());
|
||||||
if (user.getDiscordId() != null) {
|
if (user.getDiscordId() != null) {
|
||||||
Message.send("WHOIS_DISCORD_ID", player, user.getDiscordId());
|
Message.send("WHOIS_DISCORD_ID", player, user.getDiscordId());
|
||||||
@ -102,20 +102,20 @@ public class WhoisCommand extends SWCommand {
|
|||||||
}
|
}
|
||||||
Message.send("WHOIS_HOURS_PLAYED", player, new DecimalFormat("###.##").format(user.getOnlinetime() / 3600d));
|
Message.send("WHOIS_HOURS_PLAYED", player, new DecimalFormat("###.##").format(user.getOnlinetime() / 3600d));
|
||||||
|
|
||||||
if(BungeeCord.getInstance().getPlayer(user.getUuid()) != null) {
|
if(BungeeCord.getInstance().getPlayer(user.getUUID()) != null) {
|
||||||
ProxiedPlayer target = BungeeCord.getInstance().getPlayer(user.getUuid());
|
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_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_SERVER", player, target.getServer().getInfo().getName());
|
||||||
Message.send("WHOIS_CURRENT_PROTOCOL", player, target.getPendingConnection().getVersion());
|
Message.send("WHOIS_CURRENT_PROTOCOL", player, target.getPendingConnection().getVersion());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Utils.playerModMap.containsKey(user.getUuid())) {
|
if (Utils.playerModMap.containsKey(user.getUUID())) {
|
||||||
Mod.Platform modPlatform = Utils.playerModMap.get(user.getUuid()).get(0).getPlatform();
|
Mod.Platform modPlatform = Utils.playerModMap.get(user.getUUID()).get(0).getPlatform();
|
||||||
Message.send("WHOIS_PLATFORM", player, modPlatform.toString());
|
Message.send("WHOIS_PLATFORM", player, modPlatform.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (parameterTypes.contains(WhoisParameterTypes.MOD)) {
|
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()) {
|
if (activeMods != null && !activeMods.isEmpty()) {
|
||||||
Message.send("WHOIS_ACTIVE_MODS", player,activeMods.size());
|
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.NetworkSender;
|
||||||
import de.steamwar.bungeecore.network.handlers.InventoryCallbackHandler;
|
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.CloseInventoryPacket;
|
||||||
import de.steamwar.network.packets.server.InventoryPacket;
|
import de.steamwar.network.packets.server.InventoryPacket;
|
||||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||||
@ -46,7 +46,7 @@ public class SWInventory {
|
|||||||
|
|
||||||
public SWInventory(ProxiedPlayer proxiedPlayer, int size, String title) {
|
public SWInventory(ProxiedPlayer proxiedPlayer, int size, String title) {
|
||||||
itemMap = new HashMap<>();
|
itemMap = new HashMap<>();
|
||||||
InventoryCallbackHandler.inventoryHashMap.put(SteamwarUser.get(proxiedPlayer).getId(), this);
|
InventoryCallbackHandler.inventoryHashMap.put(SteamwarUser.get(proxiedPlayer.getUniqueId()).getId(), this);
|
||||||
this.player = proxiedPlayer;
|
this.player = proxiedPlayer;
|
||||||
this.size = size;
|
this.size = size;
|
||||||
this.title = title;
|
this.title = title;
|
||||||
@ -114,7 +114,7 @@ public class SWInventory {
|
|||||||
|
|
||||||
public void handleClose() {
|
public void handleClose() {
|
||||||
if(processingClick.compareAndSet(false, true)) {
|
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)
|
if(close != null)
|
||||||
close.clicked(null);
|
close.clicked(null);
|
||||||
processingClick.set(false);
|
processingClick.set(false);
|
||||||
@ -122,7 +122,7 @@ public class SWInventory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void open() {
|
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);
|
NetworkSender.send(player, inv);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -137,7 +137,7 @@ public class SWInventory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void close(ProxiedPlayer player) {
|
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) {
|
public void setClose(InvCallback close) {
|
||||||
|
@ -21,16 +21,19 @@ package de.steamwar.bungeecore.listeners;
|
|||||||
|
|
||||||
import de.steamwar.bungeecore.BungeeCore;
|
import de.steamwar.bungeecore.BungeeCore;
|
||||||
import de.steamwar.bungeecore.Message;
|
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.bungeecore.listeners.mods.Forge;
|
||||||
import de.steamwar.bungeecore.sql.BannedUserIPs;
|
import de.steamwar.sql.BannedUserIPs;
|
||||||
import de.steamwar.bungeecore.sql.Punishment;
|
import de.steamwar.sql.Punishment;
|
||||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
import de.steamwar.sql.SteamwarUser;
|
||||||
import de.steamwar.messages.ChatSender;
|
import de.steamwar.messages.ChatSender;
|
||||||
import net.md_5.bungee.api.ProxyServer;
|
import net.md_5.bungee.api.ProxyServer;
|
||||||
import net.md_5.bungee.api.chat.ClickEvent;
|
import net.md_5.bungee.api.chat.ClickEvent;
|
||||||
import net.md_5.bungee.api.chat.ComponentBuilder;
|
import net.md_5.bungee.api.chat.ComponentBuilder;
|
||||||
import net.md_5.bungee.api.chat.HoverEvent;
|
import net.md_5.bungee.api.chat.HoverEvent;
|
||||||
import net.md_5.bungee.api.chat.TextComponent;
|
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.connection.ProxiedPlayer;
|
||||||
import net.md_5.bungee.api.event.LoginEvent;
|
import net.md_5.bungee.api.event.LoginEvent;
|
||||||
import net.md_5.bungee.event.EventHandler;
|
import net.md_5.bungee.event.EventHandler;
|
||||||
@ -45,16 +48,17 @@ public class BanListener extends BasicListener {
|
|||||||
public void onLogin(LoginEvent event) {
|
public void onLogin(LoginEvent event) {
|
||||||
event.registerIntent(BungeeCore.get());
|
event.registerIntent(BungeeCore.get());
|
||||||
ProxyServer.getInstance().getScheduler().runAsync(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)) {
|
if (user.isPunished(Punishment.PunishmentType.Ban)) {
|
||||||
user.updateBanIP(event.getConnection().getAddress().getAddress().getHostAddress());
|
|
||||||
event.setCancelled(true);
|
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());
|
event.completeIntent(BungeeCore.get());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
List<BannedUserIPs> ips = BannedUserIPs.get(event.getConnection().getAddress().getAddress().getHostAddress());
|
List<BannedUserIPs> ips = BannedUserIPs.get(connection.getAddress().getAddress().getHostAddress());
|
||||||
if(!ips.isEmpty()){
|
if(!ips.isEmpty()){
|
||||||
|
|
||||||
Timestamp highestBan = ips.get(0).getTimestamp();
|
Timestamp highestBan = ips.get(0).getTimestamp();
|
||||||
|
@ -21,11 +21,12 @@ package de.steamwar.bungeecore.listeners;
|
|||||||
|
|
||||||
import de.steamwar.bungeecore.*;
|
import de.steamwar.bungeecore.*;
|
||||||
import de.steamwar.bungeecore.bot.SteamwarDiscordBot;
|
import de.steamwar.bungeecore.bot.SteamwarDiscordBot;
|
||||||
|
import de.steamwar.bungeecore.commands.PunishmentCommand;
|
||||||
import de.steamwar.bungeecore.network.NetworkSender;
|
import de.steamwar.bungeecore.network.NetworkSender;
|
||||||
import de.steamwar.bungeecore.sql.*;
|
|
||||||
import de.steamwar.bungeecore.util.Chat19;
|
import de.steamwar.bungeecore.util.Chat19;
|
||||||
import de.steamwar.messages.ChatSender;
|
import de.steamwar.messages.ChatSender;
|
||||||
import de.steamwar.network.packets.server.PingPacket;
|
import de.steamwar.network.packets.server.PingPacket;
|
||||||
|
import de.steamwar.sql.*;
|
||||||
import net.md_5.bungee.api.*;
|
import net.md_5.bungee.api.*;
|
||||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||||
import net.md_5.bungee.api.event.ChatEvent;
|
import net.md_5.bungee.api.event.ChatEvent;
|
||||||
@ -37,11 +38,14 @@ import net.md_5.bungee.event.EventHandler;
|
|||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
|
import java.util.logging.Level;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
public class ChatListener extends BasicListener {
|
public class ChatListener extends BasicListener {
|
||||||
|
|
||||||
|
private static final List<String> rankedModes = ArenaMode.getAllModes().stream().filter(ArenaMode::isRanked).map(ArenaMode::getSchemType).collect(Collectors.toList());
|
||||||
|
|
||||||
private static final Set<Integer> coloredTeams = new HashSet<>();
|
private static final Set<Integer> coloredTeams = new HashSet<>();
|
||||||
static {
|
static {
|
||||||
coloredTeams.add(12);
|
coloredTeams.add(12);
|
||||||
@ -59,7 +63,9 @@ public class ChatListener extends BasicListener {
|
|||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
|
|
||||||
if (message.contains("jndi:ldap")) {
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -153,7 +159,7 @@ public class ChatListener extends BasicListener {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (user.isPunishedWithMessage(sender, Punishment.PunishmentType.Mute))
|
if (PunishmentCommand.isPunishedWithMessage(sender, Punishment.PunishmentType.Mute))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (message.contains("LIXFEL"))
|
if (message.contains("LIXFEL"))
|
||||||
@ -171,7 +177,7 @@ public class ChatListener extends BasicListener {
|
|||||||
msgReceiver == null ? receiver : msgReceiver,
|
msgReceiver == null ? receiver : msgReceiver,
|
||||||
highlightMentions(message, group.getChatColorCode(), receiver),
|
highlightMentions(message, group.getChatColorCode(), receiver),
|
||||||
sender.getTeam() == 0 ? "" : "§" + Team.get(sender.getTeam()).getTeamColor() + Team.get(sender.getTeam()).getTeamKuerzel() + " ",
|
sender.getTeam() == 0 ? "" : "§" + Team.get(sender.getTeam()).getTeamColor() + Team.get(sender.getTeam()).getTeamKuerzel() + " ",
|
||||||
UserElo.getEmblem(sender),
|
UserElo.getEmblem(sender, rankedModes),
|
||||||
group.getColorCode(),
|
group.getColorCode(),
|
||||||
group.getChatPrefix().length() == 0 ? "§f" : group.getChatPrefix() + " ",
|
group.getChatPrefix().length() == 0 ? "§f" : group.getChatPrefix() + " ",
|
||||||
group.getChatColorCode()));
|
group.getChatColorCode()));
|
||||||
@ -202,7 +208,7 @@ public class ChatListener extends BasicListener {
|
|||||||
String mark = "@" + player.user().getUserName();
|
String mark = "@" + player.user().getUserName();
|
||||||
return Arrays.stream(message.split(" ")).map(cur -> {
|
return Arrays.stream(message.split(" ")).map(cur -> {
|
||||||
if(cur.equalsIgnoreCase(mark)) {
|
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 "§e" + cur + returnColor;
|
||||||
}
|
}
|
||||||
return cur;
|
return cur;
|
||||||
|
@ -21,9 +21,9 @@ package de.steamwar.bungeecore.listeners;
|
|||||||
|
|
||||||
import de.steamwar.bungeecore.*;
|
import de.steamwar.bungeecore.*;
|
||||||
import de.steamwar.bungeecore.commands.CheckCommand;
|
import de.steamwar.bungeecore.commands.CheckCommand;
|
||||||
import de.steamwar.bungeecore.sql.SchematicNode;
|
import de.steamwar.sql.SchematicNode;
|
||||||
import de.steamwar.bungeecore.sql.SchematicType;
|
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.connection.ProxiedPlayer;
|
||||||
import net.md_5.bungee.api.event.PlayerDisconnectEvent;
|
import net.md_5.bungee.api.event.PlayerDisconnectEvent;
|
||||||
import net.md_5.bungee.api.event.PostLoginEvent;
|
import net.md_5.bungee.api.event.PostLoginEvent;
|
||||||
|
@ -30,8 +30,8 @@ import de.steamwar.bungeecore.commands.CheckCommand;
|
|||||||
import de.steamwar.bungeecore.commands.ModCommand;
|
import de.steamwar.bungeecore.commands.ModCommand;
|
||||||
import de.steamwar.bungeecore.commands.MsgCommand;
|
import de.steamwar.bungeecore.commands.MsgCommand;
|
||||||
import de.steamwar.bungeecore.listeners.mods.Utils;
|
import de.steamwar.bungeecore.listeners.mods.Utils;
|
||||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
import de.steamwar.sql.SteamwarUser;
|
||||||
import de.steamwar.bungeecore.sql.UserGroup;
|
import de.steamwar.sql.UserGroup;
|
||||||
import net.md_5.bungee.api.AbstractReconnectHandler;
|
import net.md_5.bungee.api.AbstractReconnectHandler;
|
||||||
import net.md_5.bungee.api.ProxyServer;
|
import net.md_5.bungee.api.ProxyServer;
|
||||||
import net.md_5.bungee.api.chat.ClickEvent;
|
import net.md_5.bungee.api.chat.ClickEvent;
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
package de.steamwar.bungeecore.listeners;
|
package de.steamwar.bungeecore.listeners;
|
||||||
|
|
||||||
import de.steamwar.bungeecore.Message;
|
import de.steamwar.bungeecore.Message;
|
||||||
import de.steamwar.bungeecore.sql.Event;
|
import de.steamwar.sql.EventFight;
|
||||||
import de.steamwar.bungeecore.sql.EventFight;
|
import de.steamwar.sql.SteamwarUser;
|
||||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
import de.steamwar.sql.TeamTeilnahme;
|
||||||
import de.steamwar.bungeecore.sql.TeamTeilnahme;
|
import de.steamwar.sql.Event;
|
||||||
import net.md_5.bungee.api.chat.TextComponent;
|
import net.md_5.bungee.api.chat.TextComponent;
|
||||||
import net.md_5.bungee.api.event.PostLoginEvent;
|
import net.md_5.bungee.api.event.PostLoginEvent;
|
||||||
import net.md_5.bungee.event.EventHandler;
|
import net.md_5.bungee.event.EventHandler;
|
||||||
|
@ -41,6 +41,7 @@ public class NonFabricFabricCheck extends BasicListener {
|
|||||||
private final Set<UUID> usingFabric = new HashSet<>();
|
private final Set<UUID> usingFabric = new HashSet<>();
|
||||||
|
|
||||||
private final Set<ProxiedPlayer> checking = new HashSet<>();
|
private final Set<ProxiedPlayer> checking = new HashSet<>();
|
||||||
|
private final Set<ProxiedPlayer> vanilla = new HashSet<>();
|
||||||
|
|
||||||
{
|
{
|
||||||
BungeeCord.getInstance().getScheduler().schedule(BungeeCore.get(), usingFabric::clear, 0, 15, TimeUnit.MINUTES);
|
BungeeCord.getInstance().getScheduler().schedule(BungeeCore.get(), usingFabric::clear, 0, 15, TimeUnit.MINUTES);
|
||||||
@ -52,14 +53,23 @@ public class NonFabricFabricCheck extends BasicListener {
|
|||||||
if(!(sender instanceof ProxiedPlayer))
|
if(!(sender instanceof ProxiedPlayer))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if(!e.getTag().equals("minecraft:brand"))
|
ProxiedPlayer p = (ProxiedPlayer) sender;
|
||||||
return;
|
if (e.getTag().equals("minecraft:register") && new String(e.getData()).contains("fabric-screen-handler-api-v1:open_screen")) {
|
||||||
|
BungeeCord.getInstance().getScheduler().schedule(BungeeCore.get(), () -> {
|
||||||
if(!new String(e.getData()).equals("vanilla")){
|
if (!sender.isConnected()) return;
|
||||||
|
if (!vanilla.remove(p)) return;
|
||||||
|
if (Storage.fabricCheckedPlayers.containsKey(p)) return;
|
||||||
|
p.disconnect(Message.parse("MOD_USE_MODSENDER", p));
|
||||||
|
}, 25, TimeUnit.SECONDS);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ProxiedPlayer p = (ProxiedPlayer) sender;
|
if(!e.getTag().equals("minecraft:brand"))
|
||||||
|
return;
|
||||||
|
|
||||||
|
if(!new String(e.getData()).equals("vanilla"))
|
||||||
|
return;
|
||||||
|
vanilla.add(p);
|
||||||
|
|
||||||
BungeeCord.getInstance().getScheduler().schedule(BungeeCore.get(), () -> {
|
BungeeCord.getInstance().getScheduler().schedule(BungeeCore.get(), () -> {
|
||||||
if (!p.isConnected()) return;
|
if (!p.isConnected()) return;
|
||||||
@ -82,5 +92,6 @@ public class NonFabricFabricCheck extends BasicListener {
|
|||||||
if (checking.remove(e.getPlayer())) {
|
if (checking.remove(e.getPlayer())) {
|
||||||
usingFabric.add(e.getPlayer().getUniqueId());
|
usingFabric.add(e.getPlayer().getUniqueId());
|
||||||
}
|
}
|
||||||
|
vanilla.remove(e.getPlayer());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,8 +20,8 @@
|
|||||||
package de.steamwar.bungeecore.listeners;
|
package de.steamwar.bungeecore.listeners;
|
||||||
|
|
||||||
import de.steamwar.bungeecore.Message;
|
import de.steamwar.bungeecore.Message;
|
||||||
import de.steamwar.bungeecore.sql.PollAnswer;
|
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.chat.ClickEvent;
|
||||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||||
import net.md_5.bungee.api.event.PostLoginEvent;
|
import net.md_5.bungee.api.event.PostLoginEvent;
|
||||||
@ -40,6 +40,8 @@ public class PollSystem extends BasicListener {
|
|||||||
|
|
||||||
if(noCurrentPoll())
|
if(noCurrentPoll())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
PollAnswer.setCurrentPoll(question);
|
||||||
new PollSystem();
|
new PollSystem();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -70,10 +72,6 @@ public class PollSystem extends BasicListener {
|
|||||||
return question == null || question.equals("");
|
return question == null || question.equals("");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getQuestion() {
|
|
||||||
return question;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static int answers(){
|
public static int answers(){
|
||||||
return answers.size();
|
return answers.size();
|
||||||
}
|
}
|
||||||
|
@ -20,8 +20,8 @@
|
|||||||
package de.steamwar.bungeecore.listeners;
|
package de.steamwar.bungeecore.listeners;
|
||||||
|
|
||||||
import de.steamwar.bungeecore.BungeeCore;
|
import de.steamwar.bungeecore.BungeeCore;
|
||||||
import de.steamwar.bungeecore.sql.Session;
|
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.ProxyServer;
|
||||||
import net.md_5.bungee.api.event.PlayerDisconnectEvent;
|
import net.md_5.bungee.api.event.PlayerDisconnectEvent;
|
||||||
import net.md_5.bungee.api.event.PostLoginEvent;
|
import net.md_5.bungee.api.event.PostLoginEvent;
|
||||||
@ -43,7 +43,7 @@ public class SessionManager extends BasicListener {
|
|||||||
public void onDisconnect(PlayerDisconnectEvent e){
|
public void onDisconnect(PlayerDisconnectEvent e){
|
||||||
Timestamp timestamp = sessions.remove(e.getPlayer());
|
Timestamp timestamp = sessions.remove(e.getPlayer());
|
||||||
if(timestamp != null) {
|
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;
|
package de.steamwar.bungeecore.listeners;
|
||||||
|
|
||||||
import de.steamwar.bungeecore.BungeeCore;
|
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.BungeeCord;
|
||||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||||
import net.md_5.bungee.api.event.SettingsChangedEvent;
|
import net.md_5.bungee.api.event.SettingsChangedEvent;
|
||||||
@ -32,7 +34,9 @@ public class SettingsChangedListener extends BasicListener {
|
|||||||
public void onSettingsChanged(SettingsChangedEvent event) {
|
public void onSettingsChanged(SettingsChangedEvent event) {
|
||||||
BungeeCord.getInstance().getScheduler().runAsync(BungeeCore.get(), () -> {
|
BungeeCord.getInstance().getScheduler().runAsync(BungeeCore.get(), () -> {
|
||||||
ProxiedPlayer player = event.getPlayer();
|
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.Message;
|
||||||
import de.steamwar.bungeecore.Storage;
|
import de.steamwar.bungeecore.Storage;
|
||||||
import de.steamwar.bungeecore.listeners.BasicListener;
|
import de.steamwar.bungeecore.listeners.BasicListener;
|
||||||
import de.steamwar.bungeecore.sql.Mod;
|
import de.steamwar.sql.Mod;
|
||||||
import de.steamwar.bungeecore.sql.SWException;
|
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.BungeeCord;
|
||||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||||
import net.md_5.bungee.api.event.PluginMessageEvent;
|
import net.md_5.bungee.api.event.PluginMessageEvent;
|
||||||
@ -58,7 +58,7 @@ public class Fabric extends BasicListener {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (System.currentTimeMillis() - entry.getValue() > TimeUnit.SECONDS.toMillis(20)) {
|
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;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -156,7 +156,7 @@ public class Fabric extends BasicListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void logMessage(SteamwarUser user, String reason, String data) {
|
public void logMessage(SteamwarUser user, String reason, String data) {
|
||||||
SWException.log("Bungee", "FabricModSender " + user.getUserName() + ": " + reason, data);
|
SWException.log("FabricModSender " + user.getUserName() + ": " + reason, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void remove(ProxiedPlayer player) {
|
public static void remove(ProxiedPlayer player) {
|
||||||
|
@ -21,7 +21,7 @@ package de.steamwar.bungeecore.listeners.mods;
|
|||||||
|
|
||||||
import de.steamwar.bungeecore.BungeeCore;
|
import de.steamwar.bungeecore.BungeeCore;
|
||||||
import de.steamwar.bungeecore.listeners.BasicListener;
|
import de.steamwar.bungeecore.listeners.BasicListener;
|
||||||
import de.steamwar.bungeecore.sql.Mod;
|
import de.steamwar.sql.Mod;
|
||||||
import io.netty.channel.ChannelPipeline;
|
import io.netty.channel.ChannelPipeline;
|
||||||
import net.md_5.bungee.api.chat.TextComponent;
|
import net.md_5.bungee.api.chat.TextComponent;
|
||||||
import net.md_5.bungee.api.connection.PendingConnection;
|
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.BungeeCore;
|
||||||
import de.steamwar.bungeecore.listeners.BasicListener;
|
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.ByteBuf;
|
||||||
import io.netty.buffer.UnpooledByteBufAllocator;
|
import io.netty.buffer.UnpooledByteBufAllocator;
|
||||||
import net.md_5.bungee.api.ProxyServer;
|
import net.md_5.bungee.api.ProxyServer;
|
||||||
|
@ -23,7 +23,7 @@ import com.google.gson.JsonObject;
|
|||||||
import com.google.gson.stream.JsonReader;
|
import com.google.gson.stream.JsonReader;
|
||||||
import de.steamwar.bungeecore.BungeeCore;
|
import de.steamwar.bungeecore.BungeeCore;
|
||||||
import de.steamwar.bungeecore.listeners.BasicListener;
|
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.ProxyServer;
|
||||||
import net.md_5.bungee.api.connection.Connection;
|
import net.md_5.bungee.api.connection.Connection;
|
||||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
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.BungeeCore;
|
||||||
import de.steamwar.bungeecore.Message;
|
import de.steamwar.bungeecore.Message;
|
||||||
import de.steamwar.bungeecore.sql.Mod;
|
import de.steamwar.bungeecore.commands.PunishmentCommand;
|
||||||
import de.steamwar.bungeecore.sql.Mod.ModType;
|
import de.steamwar.sql.SteamwarUser;
|
||||||
import de.steamwar.bungeecore.sql.Punishment;
|
|
||||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
|
||||||
import de.steamwar.messages.ChatSender;
|
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.BaseComponent;
|
||||||
import net.md_5.bungee.api.chat.TextComponent;
|
import net.md_5.bungee.api.chat.TextComponent;
|
||||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||||
@ -68,7 +68,7 @@ public class Utils {
|
|||||||
|
|
||||||
static boolean handleMods(UUID uuid, Locale locale, Consumer<BaseComponent[]> disconnect, List<Mod> mods){
|
static boolean handleMods(UUID uuid, Locale locale, Consumer<BaseComponent[]> disconnect, List<Mod> mods){
|
||||||
SteamwarUser user = SteamwarUser.get(uuid);
|
SteamwarUser user = SteamwarUser.get(uuid);
|
||||||
boolean privileged = user.getUserGroup().privilegedMods();
|
boolean privileged = user.getUserGroup().isPrivilegedMods();
|
||||||
playerModMap.put(uuid,new ArrayList<>(mods));
|
playerModMap.put(uuid,new ArrayList<>(mods));
|
||||||
|
|
||||||
ModType max = ModType.YELLOW;
|
ModType max = ModType.YELLOW;
|
||||||
@ -97,7 +97,7 @@ public class Utils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(max == ModType.RED) {
|
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.");
|
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.Lists;
|
||||||
import com.google.common.collect.Sets;
|
import com.google.common.collect.Sets;
|
||||||
import de.steamwar.bungeecore.listeners.BasicListener;
|
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.Connection;
|
||||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||||
import net.md_5.bungee.api.event.PluginMessageEvent;
|
import net.md_5.bungee.api.event.PluginMessageEvent;
|
||||||
|
@ -22,7 +22,7 @@ package de.steamwar.bungeecore.network;
|
|||||||
import de.steamwar.bungeecore.BungeeCore;
|
import de.steamwar.bungeecore.BungeeCore;
|
||||||
import de.steamwar.bungeecore.commands.TeamCommand;
|
import de.steamwar.bungeecore.commands.TeamCommand;
|
||||||
import de.steamwar.bungeecore.listeners.BasicListener;
|
import de.steamwar.bungeecore.listeners.BasicListener;
|
||||||
import de.steamwar.bungeecore.sql.SWException;
|
import de.steamwar.sql.SWException;
|
||||||
import de.steamwar.network.packets.NetworkPacket;
|
import de.steamwar.network.packets.NetworkPacket;
|
||||||
import net.md_5.bungee.api.ProxyServer;
|
import net.md_5.bungee.api.ProxyServer;
|
||||||
import net.md_5.bungee.api.connection.Server;
|
import net.md_5.bungee.api.connection.Server;
|
||||||
@ -42,7 +42,7 @@ public class NetworkReceiver extends BasicListener {
|
|||||||
@EventHandler(priority = EventPriority.HIGHEST)
|
@EventHandler(priority = EventPriority.HIGHEST)
|
||||||
public void onPluginMessage(PluginMessageEvent event) {
|
public void onPluginMessage(PluginMessageEvent event) {
|
||||||
if (blockedTags.contains(event.getTag()) && !TeamCommand.isLocalhost(((InetSocketAddress) event.getSender().getSocketAddress()).getAddress())) {
|
if (blockedTags.contains(event.getTag()) && !TeamCommand.isLocalhost(((InetSocketAddress) event.getSender().getSocketAddress()).getAddress())) {
|
||||||
SWException.log("Bungee", ((InetSocketAddress) event.getSender().getSocketAddress()).getHostString() + " tried to send a plugin message with tag " + event.getTag(), Base64.getEncoder().encodeToString(event.getData()));
|
SWException.log(((InetSocketAddress) event.getSender().getSocketAddress()).getHostString() + " tried to send a plugin message with tag " + event.getTag(), Base64.getEncoder().encodeToString(event.getData()));
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
package de.steamwar.bungeecore.network.handlers;
|
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.PacketHandler;
|
||||||
import de.steamwar.network.packets.client.ExecuteCommandPacket;
|
import de.steamwar.network.packets.client.ExecuteCommandPacket;
|
||||||
import net.md_5.bungee.api.ProxyServer;
|
import net.md_5.bungee.api.ProxyServer;
|
||||||
@ -31,6 +31,6 @@ public class ExecuteCommandHandler extends PacketHandler {
|
|||||||
SteamwarUser target = SteamwarUser.get(packet.getPlayerId());
|
SteamwarUser target = SteamwarUser.get(packet.getPlayerId());
|
||||||
String command = packet.getCommand();
|
String command = packet.getCommand();
|
||||||
|
|
||||||
ProxyServer.getInstance().getPluginManager().dispatchCommand(ProxyServer.getInstance().getPlayer(target.getUuid()), command);
|
ProxyServer.getInstance().getPluginManager().dispatchCommand(ProxyServer.getInstance().getPlayer(target.getUUID()), command);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,9 +20,9 @@
|
|||||||
package de.steamwar.bungeecore.network.handlers;
|
package de.steamwar.bungeecore.network.handlers;
|
||||||
|
|
||||||
import de.steamwar.bungeecore.ArenaMode;
|
import de.steamwar.bungeecore.ArenaMode;
|
||||||
import de.steamwar.bungeecore.sql.*;
|
|
||||||
import de.steamwar.network.packets.PacketHandler;
|
import de.steamwar.network.packets.PacketHandler;
|
||||||
import de.steamwar.network.packets.common.FightEndsPacket;
|
import de.steamwar.network.packets.common.FightEndsPacket;
|
||||||
|
import de.steamwar.sql.*;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
@ -90,8 +90,8 @@ public class FightEndsHandler extends PacketHandler {
|
|||||||
gameModeGames.computeIfAbsent(fightEndsPacket.getGameMode(), s -> new LinkedList<>()).add(new Game(fightEndsPacket.getBluePlayers(), fightEndsPacket.getRedPlayers()));
|
gameModeGames.computeIfAbsent(fightEndsPacket.getGameMode(), s -> new LinkedList<>()).add(new Game(fightEndsPacket.getBluePlayers(), fightEndsPacket.getRedPlayers()));
|
||||||
}
|
}
|
||||||
|
|
||||||
int blueSchemElo = SchemElo.getElo(fightEndsPacket.getBlueSchem());
|
int blueSchemElo = SchemElo.getCurrentElo(fightEndsPacket.getBlueSchem());
|
||||||
int redSchemElo = SchemElo.getElo(fightEndsPacket.getRedSchem());
|
int redSchemElo = SchemElo.getCurrentElo(fightEndsPacket.getRedSchem());
|
||||||
|
|
||||||
int blueTeamElo = fightEndsPacket.getBluePlayers().stream().mapToInt(player -> UserElo.getEloOrDefault(player, fightEndsPacket.getGameMode())).sum();
|
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();
|
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.BungeeCore;
|
||||||
import de.steamwar.bungeecore.inventory.InvCallback;
|
import de.steamwar.bungeecore.inventory.InvCallback;
|
||||||
import de.steamwar.bungeecore.inventory.SWInventory;
|
import de.steamwar.bungeecore.inventory.SWInventory;
|
||||||
import de.steamwar.bungeecore.network.NetworkReceiver;
|
|
||||||
import de.steamwar.bungeecore.network.NetworkSender;
|
import de.steamwar.bungeecore.network.NetworkSender;
|
||||||
import de.steamwar.bungeecore.network.ServerMetaInfo;
|
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.PacketHandler;
|
||||||
import de.steamwar.network.packets.client.InventoryCallbackPacket;
|
import de.steamwar.network.packets.client.InventoryCallbackPacket;
|
||||||
import de.steamwar.network.packets.server.CloseInventoryPacket;
|
import de.steamwar.network.packets.server.CloseInventoryPacket;
|
||||||
import net.md_5.bungee.api.ProxyServer;
|
import net.md_5.bungee.api.ProxyServer;
|
||||||
import net.md_5.bungee.api.config.ServerInfo;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@ -44,7 +42,7 @@ public class InventoryCallbackHandler extends PacketHandler {
|
|||||||
SteamwarUser owner = SteamwarUser.get(packet.getOwner());
|
SteamwarUser owner = SteamwarUser.get(packet.getOwner());
|
||||||
InventoryCallbackPacket.CallbackType type = packet.getType();
|
InventoryCallbackPacket.CallbackType type = packet.getType();
|
||||||
if(!inventoryHashMap.containsKey(owner.getId())) {
|
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) {
|
if(type == InventoryCallbackPacket.CallbackType.CLICK) {
|
||||||
NetworkSender.send(((ServerMetaInfo) packet.getMetaInfos()).getSender(), new CloseInventoryPacket(owner.getId()));
|
NetworkSender.send(((ServerMetaInfo) packet.getMetaInfos()).getSender(), new CloseInventoryPacket(owner.getId()));
|
||||||
}
|
}
|
||||||
|
@ -21,8 +21,8 @@ package de.steamwar.bungeecore.network.handlers;
|
|||||||
|
|
||||||
import de.steamwar.bungeecore.ArenaMode;
|
import de.steamwar.bungeecore.ArenaMode;
|
||||||
import de.steamwar.bungeecore.ServerStarter;
|
import de.steamwar.bungeecore.ServerStarter;
|
||||||
import de.steamwar.bungeecore.sql.SchematicType;
|
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.PacketHandler;
|
||||||
import de.steamwar.network.packets.client.PrepareSchemPacket;
|
import de.steamwar.network.packets.client.PrepareSchemPacket;
|
||||||
import net.md_5.bungee.api.ProxyServer;
|
import net.md_5.bungee.api.ProxyServer;
|
||||||
@ -32,7 +32,7 @@ public class PrepareSchemHandler extends PacketHandler {
|
|||||||
|
|
||||||
@Handler
|
@Handler
|
||||||
public void handle(PrepareSchemPacket packet) {
|
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();
|
int schematicID = packet.getSchem();
|
||||||
ArenaMode mode = ArenaMode.getBySchemType(SchematicType.fromDB(packet.getSchemType()));
|
ArenaMode mode = ArenaMode.getBySchemType(SchematicType.fromDB(packet.getSchemType()));
|
||||||
|
|
||||||
|
@ -1,77 +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.Timestamp;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class BannedUserIPs {
|
|
||||||
|
|
||||||
private static final Statement getByID = new Statement("SELECT * FROM BannedUserIPs WHERE UserID = ? ORDER BY Timestamp ASC");
|
|
||||||
private static final Statement getByIP = new Statement("SELECT * FROM BannedUserIPs WHERE IP = ? ORDER BY Timestamp DESC");
|
|
||||||
private static final Statement banIP = new Statement("INSERT INTO BannedUserIPs (UserID, Timestamp, IP) VALUES (?, NOW(), ?) ON DUPLICATE KEY UPDATE Timestamp=NOW()");
|
|
||||||
|
|
||||||
private final int userID;
|
|
||||||
private final Timestamp timestamp;
|
|
||||||
|
|
||||||
private BannedUserIPs(int userID, Timestamp timestamp){
|
|
||||||
this.userID = userID;
|
|
||||||
this.timestamp = timestamp;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static List<BannedUserIPs> get(int userID){
|
|
||||||
return getByID.select(rs -> {
|
|
||||||
List<BannedUserIPs> userIPs = new ArrayList<>();
|
|
||||||
while(rs.next()) {
|
|
||||||
userIPs.add(new BannedUserIPs(
|
|
||||||
userID,
|
|
||||||
rs.getTimestamp("Timestamp")));
|
|
||||||
}
|
|
||||||
return userIPs;
|
|
||||||
}, userID);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static List<BannedUserIPs> get(String ip){
|
|
||||||
return getByIP.select(rs -> {
|
|
||||||
List<BannedUserIPs> userIDs = new ArrayList<>();
|
|
||||||
while(rs.next()) {
|
|
||||||
userIDs.add(new BannedUserIPs(
|
|
||||||
rs.getInt("UserID"),
|
|
||||||
rs.getTimestamp("Timestamp")));
|
|
||||||
}
|
|
||||||
return userIDs;
|
|
||||||
}, ip);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void banIP(SteamwarUser user, String ip){
|
|
||||||
banIP.update(user.getId(), ip);
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getUserID() {
|
|
||||||
return userID;
|
|
||||||
}
|
|
||||||
|
|
||||||
public java.sql.Timestamp getTimestamp() {
|
|
||||||
return timestamp;
|
|
||||||
}
|
|
||||||
}
|
|
@ -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.bungeecore.Message;
|
|
||||||
import lombok.experimental.UtilityClass;
|
|
||||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
|
||||||
|
|
||||||
@UtilityClass
|
|
||||||
public class BauLock {
|
|
||||||
|
|
||||||
private static final String BAU_LOCK_CONFIG_NAME = "baulockstate";
|
|
||||||
public static void setLocked(ProxiedPlayer p, BauLockState state) {
|
|
||||||
SteamwarUser owner = SteamwarUser.get(p.getUniqueId());
|
|
||||||
UserConfig.updateUserConfig(owner.getId(), BAU_LOCK_CONFIG_NAME, state == BauLockState.OPEN ? null : state.name());
|
|
||||||
Message.send("BAU_LOCKED_" + state.name(), owner.getPlayer());
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean isLocked(SteamwarUser owner, SteamwarUser target) {
|
|
||||||
if (owner.getId() == target.getId())
|
|
||||||
return false;
|
|
||||||
|
|
||||||
String state = UserConfig.getConfig(owner.getId(), BAU_LOCK_CONFIG_NAME);
|
|
||||||
switch (state == null ? BauLockState.OPEN : BauLockState.valueOf(state)) {
|
|
||||||
case NOBODY:
|
|
||||||
return true;
|
|
||||||
case TEAM:
|
|
||||||
return owner.getTeam() != target.getTeam();
|
|
||||||
case OPEN:
|
|
||||||
default:
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,27 +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;
|
|
||||||
|
|
||||||
public enum BauLockState {
|
|
||||||
|
|
||||||
NOBODY, // Locks the build server for all users
|
|
||||||
TEAM, //opens the build server only for every added user which is in the same team as the buildOwner
|
|
||||||
OPEN //unlocks the build server for all users
|
|
||||||
}
|
|
@ -1,118 +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.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
public class BauweltMember{
|
|
||||||
|
|
||||||
private static final Statement delete = new Statement("DELETE FROM BauweltMember WHERE BauweltID = ? AND MemberID = ?");
|
|
||||||
private static final Statement update = new Statement("INSERT INTO BauweltMember (BauweltID, MemberID, WorldEdit, World) VALUES (?, ?, ?, ?) ON DUPLICATE KEY UPDATE WorldEdit = VALUES(WorldEdit), World = VALUES(World)");
|
|
||||||
private static final Statement getMember = new Statement("SELECT * FROM BauweltMember WHERE BauweltID = ? AND MemberID = ?");
|
|
||||||
private static final Statement getMembers = new Statement("SELECT * FROM BauweltMember WHERE BauweltID = ?");
|
|
||||||
|
|
||||||
private final int bauweltID;
|
|
||||||
private final int memberID;
|
|
||||||
private boolean worldEdit;
|
|
||||||
private boolean world;
|
|
||||||
|
|
||||||
|
|
||||||
private BauweltMember(int ownerID, int memberID, boolean worldEdit, boolean world, boolean updateDB){
|
|
||||||
bauweltID = ownerID;
|
|
||||||
this.memberID = memberID;
|
|
||||||
this.worldEdit = worldEdit;
|
|
||||||
this.world = world;
|
|
||||||
if(updateDB)
|
|
||||||
updateDB();
|
|
||||||
}
|
|
||||||
|
|
||||||
public BauweltMember(int ownerID, int memberID, boolean worldEdit, boolean world){
|
|
||||||
this(ownerID, memberID, worldEdit, world, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
public BauweltMember(UUID ownerID, UUID memberID, boolean worldEdit, boolean world){
|
|
||||||
this(SteamwarUser.get(ownerID).getId(), SteamwarUser.get(memberID).getId(), worldEdit, world);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void remove(){
|
|
||||||
delete.update(bauweltID, memberID);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void updateDB(){
|
|
||||||
update.update(bauweltID, memberID, worldEdit, world);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static BauweltMember getBauMember(UUID ownerID, UUID memberID){
|
|
||||||
return getBauMember(SteamwarUser.get(ownerID).getId(), SteamwarUser.get(memberID).getId());
|
|
||||||
}
|
|
||||||
|
|
||||||
public static BauweltMember getBauMember(int ownerID, int memberID){
|
|
||||||
return getMember.select(rs -> {
|
|
||||||
if(!rs.next())
|
|
||||||
return null;
|
|
||||||
|
|
||||||
return new BauweltMember(ownerID, memberID, rs.getBoolean("WorldEdit"), rs.getBoolean("World"), false);
|
|
||||||
}, ownerID, memberID);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static List<BauweltMember> getMembers(UUID bauweltID){
|
|
||||||
return getMembers(SteamwarUser.get(bauweltID).getId());
|
|
||||||
}
|
|
||||||
|
|
||||||
public static List<BauweltMember> getMembers(int bauweltID){
|
|
||||||
return getMembers.select(rs -> {
|
|
||||||
List<BauweltMember> members = new ArrayList<>();
|
|
||||||
while(rs.next()){
|
|
||||||
members.add(new BauweltMember(bauweltID, rs.getInt("MemberID"), rs.getBoolean("WorldEdit"), rs.getBoolean("World"), false));
|
|
||||||
}
|
|
||||||
return members;
|
|
||||||
}, bauweltID);
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getBauweltID() {
|
|
||||||
return bauweltID;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getMemberID() {
|
|
||||||
return memberID;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isWorldEdit() {
|
|
||||||
return worldEdit;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setWorldEdit(boolean worldEdit) {
|
|
||||||
this.worldEdit = worldEdit;
|
|
||||||
updateDB();
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isWorld() {
|
|
||||||
return world;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setWorld(boolean world) {
|
|
||||||
this.world = world;
|
|
||||||
updateDB();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,122 +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.sql.Timestamp;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
public class CheckedSchematic {
|
|
||||||
|
|
||||||
private static final Statement checkHistory = new Statement("SELECT * FROM CheckedSchematic WHERE NodeId IN (SELECT NodeId FROM SchematicNode WHERE NodeOwner = ?) AND DeclineReason != '' AND DeclineReason != 'Prüfvorgang abgebrochen' AND NodeId is not NULL ORDER BY EndTime DESC");
|
|
||||||
private static final Statement nodeHistory = new Statement("SELECT * FROM CheckedSchematic WHERE NodeId = ? AND DeclineReason != '' AND DeclineReason != 'Prüfvorgang abgebrochen' ORDER BY EndTime DESC");
|
|
||||||
private static final Statement insert = new Statement("INSERT INTO CheckedSchematic (NodeId, NodeName, NodeOwner, Validator, StartTime, EndTime, DeclineReason) VALUES (?, ?, ?, ?, ?, ?, ?)");
|
|
||||||
|
|
||||||
private final Integer node;
|
|
||||||
private final int validator;
|
|
||||||
private final Timestamp startTime;
|
|
||||||
private final Timestamp endTime;
|
|
||||||
private final String declineReason;
|
|
||||||
|
|
||||||
private CheckedSchematic(ResultSet rs) throws SQLException {
|
|
||||||
this.node = rs.getInt("NodeId");
|
|
||||||
this.validator = rs.getInt("Validator");
|
|
||||||
this.startTime = rs.getTimestamp("StartTime");
|
|
||||||
this.endTime = rs.getTimestamp("EndTime");
|
|
||||||
this.declineReason = rs.getString("DeclineReason");
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void create(int nodeId, String name, int owner, int validator, Timestamp startTime, Timestamp endTime, String reason){
|
|
||||||
insert.update(nodeId, name, owner, validator, startTime, endTime, reason);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void create(SchematicNode node, int validator, Timestamp startTime, Timestamp endTime, String reason){
|
|
||||||
create(node.getId(), node.getName(), node.getOwner(), validator, startTime, endTime, reason);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static List<CheckedSchematic> previousChecks(SchematicNode node){
|
|
||||||
return nodeHistory.select(rs -> {
|
|
||||||
List<CheckedSchematic> schematics = new ArrayList<>();
|
|
||||||
while(rs.next())
|
|
||||||
schematics.add(new CheckedSchematic(rs));
|
|
||||||
return schematics;
|
|
||||||
}, node.getId());
|
|
||||||
}
|
|
||||||
|
|
||||||
public static List<CheckedSchematic> getLastDeclinedOfNode(SchematicNode node){
|
|
||||||
return getLastDeclinedOfNode(node.getId());
|
|
||||||
}
|
|
||||||
|
|
||||||
public static List<CheckedSchematic> getLastDeclinedOfNode(int node){
|
|
||||||
return nodeHistory.select(rs -> {
|
|
||||||
List<CheckedSchematic> lastDeclined = new ArrayList<>();
|
|
||||||
while(rs.next()){
|
|
||||||
lastDeclined.add(new CheckedSchematic(rs));
|
|
||||||
}
|
|
||||||
return lastDeclined;
|
|
||||||
}, node);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static List<CheckedSchematic> getLastDeclined(UUID uuid){
|
|
||||||
return getLastDelined(SteamwarUser.get(uuid).getId());
|
|
||||||
}
|
|
||||||
|
|
||||||
public static List<CheckedSchematic> getLastDelined(int schemOwner){
|
|
||||||
return checkHistory.select(rs -> {
|
|
||||||
List<CheckedSchematic> history = new ArrayList<>();
|
|
||||||
while(rs.next())
|
|
||||||
history.add(new CheckedSchematic(rs));
|
|
||||||
return history;
|
|
||||||
}, schemOwner);
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getValidator() {
|
|
||||||
return validator;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Timestamp getStartTime() {
|
|
||||||
return startTime;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Timestamp getEndTime() {
|
|
||||||
return endTime;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getDeclineReason() {
|
|
||||||
return declineReason;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getNode() {
|
|
||||||
return node;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getSchemName() {
|
|
||||||
return SchematicNode.getSchematicNode(node).getName();
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getSchemOwner() {
|
|
||||||
return SchematicNode.getSchematicNode(node).getId();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,133 +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.sql.Timestamp;
|
|
||||||
import java.time.Instant;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class Event {
|
|
||||||
|
|
||||||
private static final Statement byCurrent = new Statement("SELECT * FROM Event WHERE Start < now() AND End > now()");
|
|
||||||
private static final Statement byId = new Statement("SELECT * FROM Event WHERE EventID = ?");
|
|
||||||
private static final Statement byName = new Statement("SELECT * FROM Event WHERE lower(EventName) = ?");
|
|
||||||
private static final Statement byComing = new Statement("SELECT * FROM Event WHERE Start > now()");
|
|
||||||
|
|
||||||
private final int eventID;
|
|
||||||
private final String eventName;
|
|
||||||
private final Timestamp start;
|
|
||||||
private final Timestamp end;
|
|
||||||
private final int maximumTeamMembers;
|
|
||||||
private final boolean publicSchemsOnly;
|
|
||||||
private final boolean spectateSystem;
|
|
||||||
private final Timestamp deadline;
|
|
||||||
private final String schemType;
|
|
||||||
|
|
||||||
private static Event current = null;
|
|
||||||
|
|
||||||
private Event(ResultSet rs) throws SQLException{
|
|
||||||
this.eventID = rs.getInt("EventID");
|
|
||||||
this.eventName = rs.getString("EventName");
|
|
||||||
this.start = rs.getTimestamp("Start");
|
|
||||||
this.end = rs.getTimestamp("End");
|
|
||||||
this.maximumTeamMembers = rs.getInt("MaximumTeamMembers");
|
|
||||||
this.publicSchemsOnly = rs.getBoolean("PublicSchemsOnly");
|
|
||||||
this.spectateSystem = rs.getBoolean("SpectateSystem");
|
|
||||||
this.deadline = rs.getTimestamp("Deadline");
|
|
||||||
this.schemType = rs.getString("SchemType");
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Event get(){
|
|
||||||
if(current != null && current.now())
|
|
||||||
return current;
|
|
||||||
|
|
||||||
return byCurrent.select(rs -> {
|
|
||||||
if(rs.next())
|
|
||||||
current = new Event(rs);
|
|
||||||
else
|
|
||||||
current = null;
|
|
||||||
return current;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Event get(int eventID){
|
|
||||||
return byId.select(rs -> {
|
|
||||||
if(!rs.next())
|
|
||||||
throw new SQLException("Couldn't find event " + eventID);
|
|
||||||
return new Event(rs);
|
|
||||||
}, eventID);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Event get(String eventName){
|
|
||||||
return byName.select(rs -> {
|
|
||||||
if(!rs.next())
|
|
||||||
return null;
|
|
||||||
|
|
||||||
return new Event(rs);
|
|
||||||
}, eventName.toLowerCase());
|
|
||||||
}
|
|
||||||
|
|
||||||
public static List<Event> getComing(){
|
|
||||||
return byComing.select(rs -> {
|
|
||||||
List<Event> events = new ArrayList<>();
|
|
||||||
while(rs.next())
|
|
||||||
events.add(new Event(rs));
|
|
||||||
return events;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean now(){
|
|
||||||
Instant now = Instant.now();
|
|
||||||
return now.isAfter(start.toInstant()) && now.isBefore(end.toInstant());
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getEventID() {
|
|
||||||
return eventID;
|
|
||||||
}
|
|
||||||
public String getEventName() {
|
|
||||||
return eventName;
|
|
||||||
}
|
|
||||||
public Timestamp getStart() {
|
|
||||||
return start;
|
|
||||||
}
|
|
||||||
public Timestamp getEnd() {
|
|
||||||
return end;
|
|
||||||
}
|
|
||||||
public int getMaximumTeamMembers() {
|
|
||||||
return maximumTeamMembers;
|
|
||||||
}
|
|
||||||
public boolean publicSchemsOnly() {
|
|
||||||
return publicSchemsOnly;
|
|
||||||
}
|
|
||||||
public boolean spectateSystem(){
|
|
||||||
return spectateSystem;
|
|
||||||
}
|
|
||||||
public Timestamp getDeadline() {
|
|
||||||
return deadline;
|
|
||||||
}
|
|
||||||
public String getSchemType() {
|
|
||||||
return schemType;
|
|
||||||
}
|
|
||||||
}
|
|
@ -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,124 +0,0 @@
|
|||||||
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.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).collect(Collectors.toSet()));
|
|
||||||
for(Fight fight : fights) {
|
|
||||||
fight.initPlayers(fightPlayers);
|
|
||||||
}
|
|
||||||
|
|
||||||
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 SteamwarUser getBlueLeader() {
|
|
||||||
return SteamwarUser.get(blueLeader);
|
|
||||||
}
|
|
||||||
|
|
||||||
public 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;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,56 +0,0 @@
|
|||||||
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;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
public class FightPlayer {
|
|
||||||
|
|
||||||
private final int fightID;
|
|
||||||
private final int userID;
|
|
||||||
private final int team;
|
|
||||||
private final String kit;
|
|
||||||
private final int kills;
|
|
||||||
private final boolean isOut;
|
|
||||||
|
|
||||||
private FightPlayer(ResultSet rs) throws SQLException {
|
|
||||||
fightID = rs.getInt("FightID");
|
|
||||||
userID = rs.getInt("UserID");
|
|
||||||
team = rs.getInt("Team");
|
|
||||||
kit = rs.getString("Kit");
|
|
||||||
kills = rs.getInt("Kills");
|
|
||||||
isOut = rs.getBoolean("IsOut");
|
|
||||||
}
|
|
||||||
|
|
||||||
public static List<FightPlayer> batchGet(Set<Integer> fightIds) {
|
|
||||||
List<FightPlayer> fightPlayers = new ArrayList<>();
|
|
||||||
if(fightIds.isEmpty())
|
|
||||||
return fightPlayers;
|
|
||||||
|
|
||||||
try (Statement batch = new Statement("SELECT * FROM FightPlayer WHERE FightID IN (" + fightIds.stream().map(Object::toString).collect(Collectors.joining(", ")) + ")")) {
|
|
||||||
batch.select(rs -> {
|
|
||||||
while(rs.next())
|
|
||||||
fightPlayers.add(new FightPlayer(rs));
|
|
||||||
return null;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
return fightPlayers;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getFightID() {
|
|
||||||
return fightID;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getTeam() {
|
|
||||||
return team;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getUserID() {
|
|
||||||
return userID;
|
|
||||||
}
|
|
||||||
}
|
|
@ -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.internal.Statement;
|
|
||||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
|
||||||
|
|
||||||
import java.sql.ResultSet;
|
|
||||||
|
|
||||||
public class IgnoreSystem{
|
|
||||||
|
|
||||||
private static final Statement select = new Statement("SELECT * FROM IgnoredPlayers WHERE Ignorer = ? AND Ignored = ?");
|
|
||||||
private static final Statement insert = new Statement("INSERT INTO IgnoredPlayers (Ignorer, Ignored) VALUES (?, ?)");
|
|
||||||
private static final Statement delete = new Statement("DELETE FROM IgnoredPlayers WHERE Ignorer = ? AND Ignored = ?");
|
|
||||||
|
|
||||||
private IgnoreSystem(){}
|
|
||||||
|
|
||||||
public static boolean isIgnored(ProxiedPlayer ignorer, ProxiedPlayer ignored){
|
|
||||||
SteamwarUser user = SteamwarUser.get(ignorer.getUniqueId());
|
|
||||||
SteamwarUser target = SteamwarUser.get(ignored.getUniqueId());
|
|
||||||
return isIgnored(user, target);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean isIgnored(SteamwarUser ignorer, SteamwarUser ignored) {
|
|
||||||
return select.select(ResultSet::next, ignorer.getId(), ignored.getId());
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void ignore(SteamwarUser ignorer, SteamwarUser ignored) {
|
|
||||||
insert.update(ignorer.getId(), ignored.getId());
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void unIgnore(SteamwarUser ignorer, SteamwarUser ignored) {
|
|
||||||
delete.update(ignorer.getId(), ignored.getId());
|
|
||||||
}
|
|
||||||
}
|
|
@ -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,75 +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.listeners.PollSystem;
|
|
||||||
|
|
||||||
import java.sql.ResultSet;
|
|
||||||
import java.sql.SQLException;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
public class PollAnswer {
|
|
||||||
|
|
||||||
private static final Statement get = new Statement("SELECT * FROM PollAnswer WHERE UserID = ? AND Question = ?");
|
|
||||||
private static final Statement getResults = new Statement("SELECT Count(UserID) AS Times, Answer FROM PollAnswer WHERE Question = ? GROUP BY Answer ORDER BY `Times` ASC");
|
|
||||||
private static final Statement insert = new Statement("INSERT INTO PollAnswer (UserID, Question, Answer) VALUES (?, ?, ?) ON DUPLICATE KEY UPDATE Answer = VALUES(Answer)");
|
|
||||||
|
|
||||||
private final int userID;
|
|
||||||
private final String question;
|
|
||||||
private int answer;
|
|
||||||
|
|
||||||
private PollAnswer(ResultSet rs) throws SQLException {
|
|
||||||
this(rs.getInt("UserID"), rs.getString("Question"));
|
|
||||||
answer = rs.getInt("Answer");
|
|
||||||
}
|
|
||||||
private PollAnswer(int userID, String question){
|
|
||||||
this.userID = userID;
|
|
||||||
this.question = question;
|
|
||||||
answer = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static PollAnswer get(int userID){
|
|
||||||
return get.select(rs -> {
|
|
||||||
if(rs.next())
|
|
||||||
return new PollAnswer(rs);
|
|
||||||
return new PollAnswer(userID, PollSystem.getQuestion());
|
|
||||||
}, userID, PollSystem.getQuestion());
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Map<String, Integer> getCurrentResults() {
|
|
||||||
return getResults.select(rs -> {
|
|
||||||
Map<String, Integer> retMap = new HashMap<>();
|
|
||||||
while (rs.next())
|
|
||||||
retMap.put(PollSystem.getAnswer(rs.getInt("Answer")-1), rs.getInt("Times"));
|
|
||||||
return retMap;
|
|
||||||
}, PollSystem.getQuestion());
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean hasAnswered(){
|
|
||||||
return answer != 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setAnswer(int answer){
|
|
||||||
this.answer = answer;
|
|
||||||
insert.update(userID, question, answer);
|
|
||||||
}
|
|
||||||
}
|
|
@ -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,32 +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;
|
|
||||||
|
|
||||||
public class SWException {
|
|
||||||
private SWException(){}
|
|
||||||
|
|
||||||
private static final Statement insert = new Statement("INSERT INTO Exception (server, message, stacktrace) VALUES (?, ?, ?)");
|
|
||||||
|
|
||||||
public static void log(String server, String message, String stacktrace){
|
|
||||||
insert.update(server, message, stacktrace);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,50 +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 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);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,504 +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.io.InputStream;
|
|
||||||
import java.sql.ResultSet;
|
|
||||||
import java.sql.SQLException;
|
|
||||||
import java.sql.Timestamp;
|
|
||||||
import java.time.Instant;
|
|
||||||
import java.util.*;
|
|
||||||
import java.util.function.Predicate;
|
|
||||||
|
|
||||||
public class SchematicNode {
|
|
||||||
private static final Statement createNode = new Statement("INSERT INTO SchematicNode (NodeName, NodeOwner, ParentNode, NodeType, NodeItem) VALUES (?, ?, ?, ?, ?) ON DUPLICATE KEY UPDATE NodeName = VALUES(NodeName), ParentNode = VALUES(ParentNode), NodeItem = VALUES(NodeItem), NodeType = VALUES(NodeType), NodeItem = VALUES(NodeItem)");
|
|
||||||
private static final Statement getSchematicNode_Null = new Statement("SELECT NodeId, NodeName, NodeOwner, ParentNode, NodeType, NodeItem, NodeRank, NodeFormat, LastUpdate FROM SchematicNode WHERE NodeOwner = ? AND NodeName = ? AND ParentNode is NULL");
|
|
||||||
private static final Statement getSchematicNode = new Statement("SELECT NodeId, NodeName, NodeOwner, ParentNode, NodeType, NodeItem, NodeRank, NodeFormat, LastUpdate FROM SchematicNode WHERE NodeOwner = ? AND NodeName = ? AND ParentNode = ?");
|
|
||||||
private static final Statement getSchematicsInNode_Null = new Statement("SELECT NodeId, NodeName, NodeOwner, ParentNode, NodeType, NodeItem, NodeRank, NodeFormat, LastUpdate FROM SchematicNode WHERE ParentNode is NULL");
|
|
||||||
private static final Statement getSchematicsInNode = new Statement("SELECT NodeId, NodeName, NodeOwner, ParentNode, NodeType, NodeItem, NodeRank, NodeFormat, LastUpdate FROM SchematicNode WHERE ParentNode = ?");
|
|
||||||
private static final Statement getDirsInNode_Null = new Statement("SELECT NodeId, NodeName, NodeOwner, ParentNode, NodeType, NodeItem, NodeRank, NodeFormat, LastUpdate FROM SchematicNode WHERE ParentNode is NULL AND NodeType is NULL");
|
|
||||||
private static final Statement getDirsInNode = new Statement("SELECT NodeId, NodeName, NodeOwner, ParentNode, NodeType, NodeItem, NodeRank, NodeFormat, LastUpdate FROM SchematicNode WHERE ParentNode = ? AND NodeType is NULL");
|
|
||||||
private static final Statement getSchematicDirectory_Null = new Statement("SELECT NodeId, NodeName, NodeOwner, ParentNode, NodeType, NodeItem, NodeRank, NodeFormat, LastUpdate FROM SchematicNode WHERE NodeName = ? AND ParentNode is NULL");
|
|
||||||
private static final Statement getSchematicDirectory = new Statement("SELECT NodeId, NodeName, NodeOwner, ParentNode, NodeType, NodeItem, NodeRank, NodeFormat, LastUpdate FROM SchematicNode WHERE NodeName = ? AND ParentNode = ?");
|
|
||||||
private static final Statement getSchematicNodeO_Null = new Statement("SELECT NodeId, NodeName, NodeOwner, ParentNode, NodeType, NodeItem, NodeRank, NodeFormat, LastUpdate FROM SchematicNode WHERE NodeName = ? AND ParentNode is NULL");
|
|
||||||
private static final Statement getSchematicNodeO = new Statement("SELECT NodeId, NodeName, NodeOwner, ParentNode, NodeType, NodeItem, NodeRank, NodeFormat, LastUpdate FROM SchematicNode WHERE NodeName = ? AND ParentNode = ?");
|
|
||||||
private static final Statement getSchematicNodeId = new Statement("SELECT NodeId, NodeName, NodeOwner, ParentNode, NodeType, NodeItem, NodeRank, NodeFormat, LastUpdate FROM SchematicNode WHERE NodeId = ?");
|
|
||||||
private static final Statement getAllSchemsOfTypeOwner = new Statement("SELECT NodeId, NodeName, NodeOwner, ParentNode, NodeType, NodeItem, NodeRank, NodeFormat, LastUpdate FROM SchematicNode WHERE NodeOwner = ? AND NodeType = ?");
|
|
||||||
private static final Statement getAllSchemsOfType = new Statement("SELECT NodeId, NodeName, NodeOwner, ParentNode, NodeType, NodeItem, NodeRank, NodeFormat, LastUpdate FROM SchematicNode WHERE NodeType = ?");
|
|
||||||
private static final Statement getAccessibleByUser = new Statement("SELECT s.NodeId, s.NodeName, s.NodeOwner, s.NodeItem, s.NodeType, s.ParentNode, s.NodeRank, s.NodeFormat, s.LastUpdate FROM SchematicNode s LEFT JOIN NodeMember n ON s.NodeId = n.NodeId WHERE (s.NodeOwner = ? OR n.UserId = ?) AND ((s.NodeOwner = ? AND s.ParentNode IS NULL) OR NOT s.NodeOwner = ?) GROUP BY s.NodeId ORDER BY s.NodeName");
|
|
||||||
private static final Statement getAccessibleByUserByTypeInNode = new Statement("WITH RECURSIVE RSNB AS (WITH RECURSIVE RSN as (SELECT s.NodeId, s.NodeName, s.NodeOwner, s.NodeItem, s.NodeType, s.ParentNode, s.NodeRank, s.NodeFormat, s.LastUpdate FROM SchematicNode s LEFT JOIN NodeMember n ON s.NodeId = n.NodeId WHERE (s.NodeOwner = ? OR n.UserId = ?) GROUP BY s.NodeId union select SN.NodeId, SN.NodeName, SN.NodeOwner, SN.NodeItem, SN.NodeType, SN.ParentNode, SN.NodeRank, SN.NodeFormat, SN.LastUpdate FROM SchematicNode AS SN, RSN WHERE SN.ParentNode = RSN.NodeId) SELECT * FROM RSN WHERE NodeType = ? union select SN.NodeId, SN.NodeName, SN.NodeOwner, SN.NodeItem, SN.NodeType, SN.ParentNode, SN.NodeRank, SN.NodeFormat, SN.LastUpdate FROM SchematicNode AS SN, RSNB WHERE SN.NodeId = RSNB.ParentNode)SELECT * FROM RSNB WHERE ParentNode = ?");
|
|
||||||
private static final Statement getAccessibleByUserByTypeInNode_Null = new Statement("WITH RECURSIVE RSNB AS (WITH RECURSIVE RSN as (SELECT s.NodeId, s.NodeName, s.NodeOwner, s.NodeItem, s.NodeType, s.ParentNode, s.NodeRank, s.NodeFormat, s.LastUpdate FROM SchematicNode s LEFT JOIN NodeMember n ON s.NodeId = n.NodeId WHERE (s.NodeOwner = ? OR n.UserId = ?) GROUP BY s.NodeId union select SN.NodeId, SN.NodeName, SN.NodeOwner, SN.NodeItem, SN.NodeType, SN.ParentNode, SN.NodeRank, SN.NodeFormat, SN.LastUpdate FROM SchematicNode AS SN, RSN WHERE SN.ParentNode = RSN.NodeId) SELECT * FROM RSN WHERE NodeType = ? union select SN.NodeId, SN.NodeName, SN.NodeOwner, SN.NodeItem, SN.NodeType, SN.ParentNode, SN.NodeRank, SN.NodeFormat, SN.LastUpdate FROM SchematicNode AS SN, RSNB WHERE SN.NodeId = RSNB.ParentNode)SELECT * FROM RSNB WHERE ParentNode is null");
|
|
||||||
private static final Statement getAccessibleByUserByType = new Statement("WITH RECURSIVE RSN as (SELECT s.NodeId, s.NodeName, s.NodeOwner, s.NodeItem, s.NodeType, s.ParentNode, s.NodeRank, s.NodeFormat, s.LastUpdate FROM SchematicNode s LEFT JOIN NodeMember n ON s.NodeId = n.NodeId WHERE (s.NodeOwner = ? OR n.UserId = ?) GROUP BY s.NodeId union select SN.NodeId, SN.NodeName, SN.NodeOwner, SN.NodeItem, SN.NodeType, SN.ParentNode, SN.NodeRank, SN.NodeFormat, SN.LastUpdate FROM SchematicNode AS SN, RSN WHERE SN.ParentNode = RSN.NodeId) SELECT * FROM RSN WHERE NodeType = ?");
|
|
||||||
private static final Statement getAllSchematicsAccessibleByUser = new Statement("WITH RECURSIVE RSN as (SELECT s.NodeId, s.NodeName, s.NodeOwner, s.NodeItem, s.NodeType, s.ParentNode, s.NodeRank, s.NodeFormat, s.LastUpdate FROM SchematicNode s LEFT JOIN NodeMember n ON s.NodeId = n.NodeId WHERE (s.NodeOwner = ? OR n.UserId = ?) GROUP BY s.NodeId union select SN.NodeId, SN.NodeName, SN.NodeOwner, SN.NodeItem, SN.NodeType, SN.ParentNode, SN.NodeRank, SN.NodeFormat, SN.LastUpdate FROM SchematicNode AS SN, RSN WHERE SN.ParentNode = RSN.NodeId) SELECT * FROM RSN");
|
|
||||||
private static final Statement isSchematicAccessibleForUser = new Statement("WITH RECURSIVE RSN AS (SELECT NodeId, NodeName, NodeOwner, ParentNode, NodeType, NodeItem, NodeRank, NodeFormat, LastUpdate FROM SchematicNode WHERE NodeId = ? union select SN.NodeId, SN.NodeName, SN.NodeOwner, SN.ParentNode, SN.NodeType, SN.NodeItem, SN.NodeRank, SN.NodeFormat, SN.LastUpdate FROM SchematicNode SN, RSN WHERE RSN.ParentNode = SN.NodeId) SELECT COUNT(RSN.NodeId) AS `Accessible` FROM RSN LEFT Join NodeMember NM On NM.NodeId = RSN.NodeId WHERE NodeOwner = ? OR UserId = ? LIMIT 1");
|
|
||||||
private static final Statement getAllParentsOfNode = new Statement("WITH RECURSIVE RSN AS (SELECT NodeId, NodeName, NodeOwner, ParentNode, NodeType, NodeItem, NodeRank, NodeFormat, LastUpdate FROM SchematicNode WHERE NodeId = ? UNION SELECT SN.NodeId, SN.NodeName, SN.NodeOwner, SN.ParentNode, SN.NodeType, SN.NodeItem, SN.NodeRank, SN.NodeFormat, SN.LastUpdate FROM SchematicNode SN, RSN WHERE RSN.ParentNode = SN.NodeId) SELECT * FROM RSN");
|
|
||||||
private static final Statement countNodes = new Statement("SELECT COUNT(NodeId) AS 'count' FROM SchematicNode");
|
|
||||||
private static final Statement updateDB = new Statement("UPDATE SchematicNode SET NodeName = ?, NodeOwner = ?, ParentNode = ?, NodeItem = ?, NodeType = ?, NodeRank = ? WHERE NodeId = ?");
|
|
||||||
private static final Statement updateDatabase = new Statement("UPDATE SchematicNode SET NodeData = ?, NodeFormat = ? WHERE NodeId = ?");
|
|
||||||
private static final Statement selSchemData = new Statement("SELECT NodeData FROM SchematicNode WHERE NodeId = ?");
|
|
||||||
private static final Statement deleteNode = new Statement("DELETE FROM SchematicNode WHERE NodeId = ?");
|
|
||||||
|
|
||||||
public static SchematicNode createSchematic(int owner, String name, Integer parent) {
|
|
||||||
return createSchematicNode(owner, name, parent, SchematicType.Normal.toDB(), "");
|
|
||||||
}
|
|
||||||
|
|
||||||
public static SchematicNode createSchematicDirectory(int owner, String name, Integer parent) {
|
|
||||||
return createSchematicNode(owner, name, parent, null, "");
|
|
||||||
}
|
|
||||||
|
|
||||||
public static SchematicNode createSchematicNode(int owner, String name, Integer parent, String type, String item) {
|
|
||||||
if (parent != null && parent == 0)
|
|
||||||
parent = null;
|
|
||||||
createNode.update(name, owner, parent, type, item);
|
|
||||||
return getSchematicNode(owner, name, parent);
|
|
||||||
}
|
|
||||||
|
|
||||||
private Timestamp lastUpdate;
|
|
||||||
|
|
||||||
public static SchematicNode getSchematicNode(int owner, String name, SchematicNode parent) {
|
|
||||||
return getSchematicNode(owner, name, parent.getId());
|
|
||||||
}
|
|
||||||
|
|
||||||
private SchematicNode(ResultSet set) throws SQLException {
|
|
||||||
id = set.getInt("NodeId");
|
|
||||||
owner = set.getInt("NodeOwner");
|
|
||||||
name = set.getString("NodeName");
|
|
||||||
parent = set.getInt("ParentNode");
|
|
||||||
if(set.wasNull()) {
|
|
||||||
parent = null;
|
|
||||||
}
|
|
||||||
item = set.getString("NodeItem");
|
|
||||||
type = set.getString("NodeType");
|
|
||||||
lastUpdate = set.getTimestamp("LastUpdate");
|
|
||||||
if (type != null) {
|
|
||||||
isDir = false;
|
|
||||||
rank = set.getInt("NodeRank");
|
|
||||||
schemFormat = set.getBoolean("NodeFormat");
|
|
||||||
} else {
|
|
||||||
isDir = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static List<SchematicNode> getSchematicNodeInNode(SchematicNode parent) {
|
|
||||||
return getSchematicNodeInNode(parent.getId());
|
|
||||||
}
|
|
||||||
|
|
||||||
public static SchematicNode getSchematicDirectory(String name, SchematicNode parent) {
|
|
||||||
return getSchematicDirectory(name, parent.getId());
|
|
||||||
}
|
|
||||||
|
|
||||||
public static SchematicNode getSchematicNode(int owner, String name, Integer parent) {
|
|
||||||
if (parent != null && parent == 0) {
|
|
||||||
parent = null;
|
|
||||||
}
|
|
||||||
Statement.ResultSetUser<SchematicNode> user = rs -> {
|
|
||||||
while (rs.next()) {
|
|
||||||
SchematicNode node = new SchematicNode(rs);
|
|
||||||
return node;
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
};
|
|
||||||
if(parent == null) {
|
|
||||||
return getSchematicNode_Null.select(user, owner, name);
|
|
||||||
} else {
|
|
||||||
return getSchematicNode.select(user, owner, name, parent);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static List<SchematicNode> getSchematicNodeInNode(Integer parent) {
|
|
||||||
if(parent != null && parent == 0)
|
|
||||||
parent = null;
|
|
||||||
Statement.ResultSetUser<List<SchematicNode>> user = rs -> {
|
|
||||||
List<SchematicNode> nodes = new ArrayList<>();
|
|
||||||
while (rs.next())
|
|
||||||
nodes.add(new SchematicNode(rs));
|
|
||||||
return nodes;
|
|
||||||
};
|
|
||||||
if(parent == null) {
|
|
||||||
return getSchematicsInNode_Null.select(user);
|
|
||||||
}else {
|
|
||||||
return getSchematicsInNode.select(user, parent);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static List<SchematicNode> getSchematicDirectoryInNode(Integer parent) {
|
|
||||||
if(parent != null && parent == 0)
|
|
||||||
parent = null;
|
|
||||||
Statement.ResultSetUser<List<SchematicNode>> user = rs -> {
|
|
||||||
List<SchematicNode> nodes = new ArrayList<>();
|
|
||||||
while (rs.next())
|
|
||||||
nodes.add(new SchematicNode(rs));
|
|
||||||
return nodes;
|
|
||||||
};
|
|
||||||
if(parent == null) {
|
|
||||||
return getDirsInNode_Null.select(user);
|
|
||||||
}else {
|
|
||||||
return getDirsInNode.select(user, parent);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static SchematicNode getSchematicDirectory(String name, Integer parent) {
|
|
||||||
if(parent != null && parent == 0)
|
|
||||||
parent = null;
|
|
||||||
Statement.ResultSetUser<SchematicNode> user = rs -> {
|
|
||||||
while (rs.next()) {
|
|
||||||
SchematicNode node = new SchematicNode(rs);
|
|
||||||
if(node.isDir())
|
|
||||||
return node;
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
};
|
|
||||||
|
|
||||||
if(parent == null) {
|
|
||||||
return getSchematicDirectory_Null.select(user, name);
|
|
||||||
}else {
|
|
||||||
return getSchematicDirectory.select(user, name, parent);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static SchematicNode getSchematicNode(String name, Integer parent) {
|
|
||||||
if(parent != null && parent == 0)
|
|
||||||
parent = null;
|
|
||||||
Statement.ResultSetUser<SchematicNode> user = rs -> {
|
|
||||||
while (rs.next()) {
|
|
||||||
return new SchematicNode(rs);
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
};
|
|
||||||
if(parent == null) {
|
|
||||||
return getSchematicNodeO_Null.select(user, name);
|
|
||||||
}else {
|
|
||||||
return getSchematicNodeO.select(user, name, parent);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static SchematicNode getSchematicNode(int id) {
|
|
||||||
return getSchematicNodeId.select(rs -> {
|
|
||||||
if (!rs.next())
|
|
||||||
return null;
|
|
||||||
return new SchematicNode(rs);
|
|
||||||
}, id);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static List<SchematicNode> getAccessibleSchematicsOfTypeInParent(int owner, String schemType, Integer parent) {
|
|
||||||
Statement.ResultSetUser<List<SchematicNode>> user = rs -> {
|
|
||||||
List<SchematicNode> nodes = new ArrayList<>();
|
|
||||||
while (rs.next()) {
|
|
||||||
nodes.add(new SchematicNode(rs));
|
|
||||||
}
|
|
||||||
return nodes;
|
|
||||||
};
|
|
||||||
if(parent == null || parent == 0) {
|
|
||||||
return getAccessibleByUserByTypeInNode_Null.select(user, owner, owner, schemType);
|
|
||||||
} else {
|
|
||||||
return getAccessibleByUserByTypeInNode.select(user, owner, owner, schemType, parent);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static List<SchematicNode> getAllAccessibleSchematicsOfType(int user, String schemType) {
|
|
||||||
return getAccessibleByUserByType.select(rs -> {
|
|
||||||
List<SchematicNode> nodes = new ArrayList<>();
|
|
||||||
while (rs.next()) {
|
|
||||||
nodes.add(new SchematicNode(rs));
|
|
||||||
}
|
|
||||||
return nodes;
|
|
||||||
}, user, user, schemType);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static List<SchematicNode> getAllSchematicsOfType(int owner, String schemType) {
|
|
||||||
return getAllSchemsOfTypeOwner.select(rs -> {
|
|
||||||
List<SchematicNode> nodes = new ArrayList<>();
|
|
||||||
while (rs.next())
|
|
||||||
nodes.add(new SchematicNode(rs));
|
|
||||||
return nodes;
|
|
||||||
}, owner, schemType);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static List<SchematicNode> getAllSchematicsOfType(String schemType) {
|
|
||||||
return getAllSchemsOfType.select(rs -> {
|
|
||||||
List<SchematicNode> nodes = new ArrayList<>();
|
|
||||||
while (rs.next())
|
|
||||||
nodes.add(new SchematicNode(rs));
|
|
||||||
return nodes;
|
|
||||||
}, schemType);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static List<SchematicNode> deepGet(Integer parent, Predicate<SchematicNode> filter) {
|
|
||||||
List<SchematicNode> finalList = new ArrayList<>();
|
|
||||||
List<SchematicNode> nodes = SchematicNode.getSchematicNodeInNode(parent);
|
|
||||||
nodes.forEach(node -> {
|
|
||||||
if (node.isDir()) {
|
|
||||||
finalList.addAll(deepGet(node.getId(), filter));
|
|
||||||
} else {
|
|
||||||
if (filter.test(node))
|
|
||||||
finalList.add(node);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return finalList;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static List<SchematicNode> getSchematicsAccessibleByUser(int user, Integer parent) {
|
|
||||||
if (parent != null && parent != 0) {
|
|
||||||
if(isSchematicAccessibleForUser.select(rs -> {
|
|
||||||
rs.next();
|
|
||||||
return rs.getInt("Accessible") > 0;
|
|
||||||
}, parent, user, user))
|
|
||||||
return getSchematicNodeInNode(parent);
|
|
||||||
} else {
|
|
||||||
return getAccessibleByUser.select(rs -> {
|
|
||||||
List<SchematicNode> nodes = new ArrayList<>();
|
|
||||||
while(rs.next())
|
|
||||||
nodes.add(new SchematicNode(rs));
|
|
||||||
return nodes;
|
|
||||||
}, user, user, user, user);
|
|
||||||
}
|
|
||||||
return Collections.emptyList();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static List<SchematicNode> getAllSchematicsAccessibleByUser(int user) {
|
|
||||||
return getAllSchematicsAccessibleByUser.select(rs -> {
|
|
||||||
List<SchematicNode> nodes = new ArrayList<>();
|
|
||||||
while(rs.next()) {
|
|
||||||
nodes.add(new SchematicNode(rs));
|
|
||||||
}
|
|
||||||
return nodes;
|
|
||||||
}, user, user);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static List<SchematicNode> getAllParentsOfNode(SchematicNode node) {
|
|
||||||
return getAllParentsOfNode(node.getId());
|
|
||||||
}
|
|
||||||
|
|
||||||
public static List<SchematicNode> getAllParentsOfNode(int node) {
|
|
||||||
return getAllParentsOfNode.select(rs -> {
|
|
||||||
List<SchematicNode> nodes = new ArrayList<>();
|
|
||||||
while(rs.next()) {
|
|
||||||
nodes.add(new SchematicNode(rs));
|
|
||||||
}
|
|
||||||
return nodes;
|
|
||||||
}, node);
|
|
||||||
}
|
|
||||||
|
|
||||||
private final int id;
|
|
||||||
private final int owner;
|
|
||||||
private String name;
|
|
||||||
private Integer parent;
|
|
||||||
private String item;
|
|
||||||
private String type;
|
|
||||||
private boolean schemFormat;
|
|
||||||
private int rank;
|
|
||||||
private final boolean isDir;
|
|
||||||
private Map<Integer, String> brCache = new HashMap<>();
|
|
||||||
|
|
||||||
public static List<SchematicNode> filterSchems(int user, Predicate<SchematicNode> filter) {
|
|
||||||
List<SchematicNode> finalList = new ArrayList<>();
|
|
||||||
List<SchematicNode> nodes = SchematicNode.getSchematicsAccessibleByUser(user, null);
|
|
||||||
nodes.forEach(node -> {
|
|
||||||
if (node.isDir()) {
|
|
||||||
finalList.addAll(deepGet(node.getId(), filter));
|
|
||||||
} else {
|
|
||||||
if (filter.test(node))
|
|
||||||
finalList.add(node);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return finalList;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Integer countNodes() {
|
|
||||||
return countNodes.select(rs -> {
|
|
||||||
if (rs.next()) {
|
|
||||||
return rs.getInt("count");
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getId() {
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getOwner() {
|
|
||||||
return owner;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getName() {
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setName(String name) {
|
|
||||||
this.name = name;
|
|
||||||
updateDB();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Integer getParent() {
|
|
||||||
return parent;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setParent(Integer parent) {
|
|
||||||
this.parent = parent;
|
|
||||||
updateDB();
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getItem() {
|
|
||||||
return item;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setItem(String item) {
|
|
||||||
this.item = item;
|
|
||||||
updateDB();
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getType() {
|
|
||||||
if(isDir)
|
|
||||||
throw new SecurityException("Node is Directory");
|
|
||||||
return type;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setType(String type) {
|
|
||||||
if(isDir)
|
|
||||||
throw new SecurityException("Node is Directory");
|
|
||||||
this.type = type;
|
|
||||||
updateDB();
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isDir() {
|
|
||||||
return isDir;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean getSchemFormat() {
|
|
||||||
if(isDir)
|
|
||||||
throw new SecurityException("Node is Directory");
|
|
||||||
return schemFormat;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getRank() {
|
|
||||||
if(isDir)
|
|
||||||
throw new SecurityException("Node is Directory");
|
|
||||||
return rank;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setRank(int rank) {
|
|
||||||
if(isDir)
|
|
||||||
throw new SecurityException("Node is Directory");
|
|
||||||
this.rank = rank;
|
|
||||||
}
|
|
||||||
|
|
||||||
public SchematicType getSchemtype() {
|
|
||||||
if(isDir())
|
|
||||||
throw new RuntimeException("Is Directory");
|
|
||||||
return SchematicType.fromDB(type);
|
|
||||||
}
|
|
||||||
|
|
||||||
public SchematicNode getParentNode() {
|
|
||||||
if(parent == null) return null;
|
|
||||||
return SchematicNode.getSchematicNode(parent);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean accessibleByUser(int user) {
|
|
||||||
return NodeMember.getNodeMember(id, user) != null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Set<NodeMember> getMembers() {
|
|
||||||
return NodeMember.getNodeMembers(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Timestamp getLastUpdate() {
|
|
||||||
return lastUpdate;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String generateBreadcrumbs(SteamwarUser user) {
|
|
||||||
return brCache.computeIfAbsent(user.getId(), integer -> generateBreadcrumbs("/", user));
|
|
||||||
}
|
|
||||||
|
|
||||||
public String generateBreadcrumbs(String split, SteamwarUser user) {
|
|
||||||
StringBuilder builder = new StringBuilder(getName());
|
|
||||||
SchematicNode currentNode = this;
|
|
||||||
if (currentNode.isDir()) builder.append("/");
|
|
||||||
while (currentNode.getParentNode() != null) {
|
|
||||||
currentNode = currentNode.getParentNode();
|
|
||||||
builder.insert(0, split)
|
|
||||||
.insert(0, currentNode.getName());
|
|
||||||
if (currentNode.getMembers().stream().anyMatch(member -> member.getMember() == user.getId())) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return builder.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void updateDB() {
|
|
||||||
updateDB.update(name, owner, parent, item, type, rank, id);
|
|
||||||
this.lastUpdate = Timestamp.from(Instant.now());
|
|
||||||
this.brCache.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void delete() {
|
|
||||||
if (isDir()) {
|
|
||||||
getSchematicNodeInNode(getId()).forEach(SchematicNode::delete);
|
|
||||||
}
|
|
||||||
deleteNode.update(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object obj) {
|
|
||||||
if (!(obj instanceof SchematicNode))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
SchematicNode node = (SchematicNode) obj;
|
|
||||||
return node.getId() == id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void saveFromStream(InputStream stream, boolean newFormat) {
|
|
||||||
if(isDir)
|
|
||||||
throw new SecurityException("Node is Directory");
|
|
||||||
updateDatabase(stream, newFormat);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void updateDatabase(InputStream blob, boolean newFormat) {
|
|
||||||
updateDatabase.update(blob, newFormat, id);
|
|
||||||
schemFormat = newFormat;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static final List<String> FORBIDDEN_NAMES = Collections.unmodifiableList(Arrays.asList("public"));
|
|
||||||
|
|
||||||
public static boolean invalidSchemName(String[] layers) {
|
|
||||||
for (String layer : layers) {
|
|
||||||
if (layer.isEmpty()) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (layer.contains("/") ||
|
|
||||||
layer.contains("\\") ||
|
|
||||||
layer.contains("<") ||
|
|
||||||
layer.contains(">") ||
|
|
||||||
layer.contains("^") ||
|
|
||||||
layer.contains("°") ||
|
|
||||||
layer.contains("'") ||
|
|
||||||
layer.contains("\"")) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if(FORBIDDEN_NAMES.contains(layer.toLowerCase())) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,177 +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.bungeecore.commands.CheckCommand;
|
|
||||||
import net.md_5.bungee.api.ProxyServer;
|
|
||||||
import net.md_5.bungee.config.Configuration;
|
|
||||||
import net.md_5.bungee.config.ConfigurationProvider;
|
|
||||||
import net.md_5.bungee.config.YamlConfiguration;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.text.ParseException;
|
|
||||||
import java.text.SimpleDateFormat;
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
public class SchematicType {
|
|
||||||
public static final SchematicType Normal = new SchematicType("Normal", "", null, Type.NORMAL, null, null); //Has to stay publicly availible
|
|
||||||
|
|
||||||
private static final Map<String, SchematicType> fromDB;
|
|
||||||
private static final Map<SchematicType, SchematicType> fightType;
|
|
||||||
private static final List<SchematicType> types;
|
|
||||||
|
|
||||||
static {
|
|
||||||
File folder = new File(ProxyServer.getInstance().getPluginsFolder(), "FightSystem");
|
|
||||||
|
|
||||||
List<SchematicType> tmpTypes = new LinkedList<>();
|
|
||||||
Map<String, SchematicType> tmpFromDB = new HashMap<>();
|
|
||||||
Map<SchematicType, SchematicType> tmpFightType = new HashMap<>();
|
|
||||||
|
|
||||||
tmpTypes.add(Normal);
|
|
||||||
tmpFromDB.put(Normal.name().toLowerCase(), Normal);
|
|
||||||
|
|
||||||
if(folder.exists()) {
|
|
||||||
for(File configFile : folder.listFiles((file, name) -> name.endsWith(".yml") && !name.endsWith(".kits.yml"))) {
|
|
||||||
Configuration config;
|
|
||||||
try {
|
|
||||||
config = ConfigurationProvider.getProvider(YamlConfiguration.class).load(configFile);
|
|
||||||
} catch (IOException e) {
|
|
||||||
throw new SecurityException("Could not load SchematicTypes", e);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!config.contains("Schematic"))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
String type = config.getString("Schematic.Type");
|
|
||||||
assert type != null;
|
|
||||||
String shortcut = config.getString("Schematic.Shortcut");
|
|
||||||
if(tmpFromDB.containsKey(type.toLowerCase()))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
String material = config.getString("Schematic.Material");
|
|
||||||
|
|
||||||
SchematicType checktype = null;
|
|
||||||
if(!config.getStringList("CheckQuestions").isEmpty()) {
|
|
||||||
checktype = new SchematicType("C" + type, "C" + shortcut, material, Type.CHECK_TYPE, null, null);
|
|
||||||
tmpTypes.add(checktype);
|
|
||||||
tmpFromDB.put(checktype.toDB(), checktype);
|
|
||||||
CheckCommand.setCheckQuestions(checktype, config);
|
|
||||||
}
|
|
||||||
|
|
||||||
Date deadline;
|
|
||||||
String deadlineString = config.getString("deadline", null);
|
|
||||||
if (deadlineString != null) {
|
|
||||||
try {
|
|
||||||
SimpleDateFormat dateFormat = new SimpleDateFormat("dd.MM.yyyy HH:mm");
|
|
||||||
deadline = dateFormat.parse(deadlineString);
|
|
||||||
} catch (ParseException e) {
|
|
||||||
throw new SecurityException(e.getMessage(), e);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
deadline = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
SchematicType current = new SchematicType(type, shortcut, material, config.getKeys().contains("Server") ? Type.FIGHT_TYPE : Type.NORMAL, checktype, deadline);
|
|
||||||
if(checktype != null)
|
|
||||||
tmpFightType.put(checktype, current);
|
|
||||||
tmpFromDB.put(type.toLowerCase(), current);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fromDB = Collections.unmodifiableMap(tmpFromDB);
|
|
||||||
fightType = Collections.unmodifiableMap(tmpFightType);
|
|
||||||
types = Collections.unmodifiableList(tmpTypes);
|
|
||||||
}
|
|
||||||
|
|
||||||
private final String name;
|
|
||||||
private final String kuerzel;
|
|
||||||
private final String material;
|
|
||||||
private final Type type;
|
|
||||||
private final SchematicType checkType;
|
|
||||||
private final Date deadline;
|
|
||||||
|
|
||||||
private SchematicType(String name, String kuerzel, String material, Type type, SchematicType checkType, Date deadline){
|
|
||||||
this.name = name;
|
|
||||||
this.kuerzel = kuerzel;
|
|
||||||
this.material = material != null && !"".equals(material) ? material : "STONE_BUTTON";
|
|
||||||
this.type = type;
|
|
||||||
this.checkType = checkType;
|
|
||||||
this.deadline = deadline;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isAssignable(){
|
|
||||||
return type == Type.NORMAL || (type == Type.FIGHT_TYPE && checkType != null);
|
|
||||||
}
|
|
||||||
|
|
||||||
public SchematicType checkType(){
|
|
||||||
return checkType;
|
|
||||||
}
|
|
||||||
|
|
||||||
public SchematicType fightType(){
|
|
||||||
return fightType.get(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean check(){
|
|
||||||
return type == Type.CHECK_TYPE;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean fight(){
|
|
||||||
return type == Type.FIGHT_TYPE;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean writeable(){
|
|
||||||
return type == Type.NORMAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String name(){
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getMaterial() {
|
|
||||||
return material;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getKuerzel() {
|
|
||||||
return kuerzel;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String toDB(){
|
|
||||||
return name.toLowerCase();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Date deadline() {
|
|
||||||
return deadline;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static SchematicType fromDB(String input){
|
|
||||||
return fromDB.getOrDefault(input.toLowerCase(), null);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static List<SchematicType> values(){
|
|
||||||
return types;
|
|
||||||
}
|
|
||||||
|
|
||||||
enum Type{
|
|
||||||
NORMAL,
|
|
||||||
CHECK_TYPE,
|
|
||||||
FIGHT_TYPE
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,54 +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 java.util.Calendar;
|
|
||||||
|
|
||||||
public class Season {
|
|
||||||
private Season() {}
|
|
||||||
|
|
||||||
public static int getSeason() {
|
|
||||||
Calendar calendar = Calendar.getInstance();
|
|
||||||
int yearIndex = calendar.get(Calendar.MONTH) / 4;
|
|
||||||
return (calendar.get(Calendar.YEAR) * 3 + yearIndex);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String getSeasonStart() {
|
|
||||||
Calendar calendar = Calendar.getInstance();
|
|
||||||
return calendar.get(Calendar.YEAR) + "-" + (calendar.get(Calendar.MONTH) / 4 * 3 + 1) + "-1";
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String convertSeasonToString(int season){
|
|
||||||
if (season == -1) return "";
|
|
||||||
int yearSeason = season % 3;
|
|
||||||
int year = (season - yearSeason) / 3;
|
|
||||||
return String.format("%d-%d", year, yearSeason);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static int convertSeasonToNumber(String season){
|
|
||||||
if (season.isEmpty()) return -1;
|
|
||||||
String[] split = season.split("-");
|
|
||||||
try {
|
|
||||||
return Integer.parseInt(split[0]) * 3 + Integer.parseInt(split[1]);
|
|
||||||
} catch (NumberFormatException e) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,35 +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.Timestamp;
|
|
||||||
|
|
||||||
public class Session {
|
|
||||||
|
|
||||||
private static final Statement insert = new Statement("INSERT INTO Session (UserID, StartTime, EndTime) VALUES (?, ?, NOW())");
|
|
||||||
|
|
||||||
private Session(){}
|
|
||||||
|
|
||||||
public static void insertSession(int userID, Timestamp startTime){
|
|
||||||
insert.update(userID, startTime);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,396 +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 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 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(this, 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,184 +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.LinkedList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class Team {
|
|
||||||
|
|
||||||
private static final Statement insert = new Statement("INSERT INTO Team (TeamKuerzel, TeamName) VALUES (?, ?)");
|
|
||||||
private static final Statement delete = new Statement("UPDATE Team SET TeamDeleted = 1 WHERE TeamID = ?");
|
|
||||||
private static final Statement update = new Statement("INSERT INTO Team (TeamID, TeamKuerzel, TeamName, TeamColor, Address, Port) VALUES (?, ?, ?, ?, ?, ?) ON DUPLICATE KEY UPDATE TeamName = VALUES(TeamName), TeamKuerzel = VALUES(TeamKuerzel), TeamColor = VALUES(TeamColor), Address = VALUES(Address), Port = VALUES(Port)");
|
|
||||||
private static final Statement getSize = new Statement("SELECT COUNT(id) FROM UserData WHERE Team = ?");
|
|
||||||
private static final Statement getMembers = new Statement("SELECT id FROM UserData WHERE Team = ?");
|
|
||||||
private static final Statement byId = new Statement("SELECT * FROM Team WHERE TeamID = ?");
|
|
||||||
private static final Statement byName = new Statement("SELECT * FROM Team WHERE (lower(TeamName) = ? OR lower(TeamKuerzel) = ?) AND NOT TeamDeleted");
|
|
||||||
private static final Statement all = new Statement("SELECT * FROM Team WHERE NOT TeamDeleted");
|
|
||||||
|
|
||||||
private static final List<Team> teamCache = new LinkedList<>();
|
|
||||||
private static final Team pub = new Team(0, "PUB", "Öffentlich", "8", null, 25565);
|
|
||||||
|
|
||||||
private final int teamId;
|
|
||||||
private String teamKuerzel;
|
|
||||||
private String teamName;
|
|
||||||
private String teamColor;
|
|
||||||
private String address;
|
|
||||||
private int port;
|
|
||||||
|
|
||||||
private Team(int id, String kuerzel, String name, String color, String address, int port){
|
|
||||||
teamId = id;
|
|
||||||
teamKuerzel = kuerzel;
|
|
||||||
teamName = name;
|
|
||||||
teamColor = color;
|
|
||||||
if (id != 0) {
|
|
||||||
teamCache.add(this);
|
|
||||||
}
|
|
||||||
this.address = address;
|
|
||||||
this.port = port;
|
|
||||||
}
|
|
||||||
|
|
||||||
private Team(ResultSet rs) throws SQLException {
|
|
||||||
this(rs.getInt("TeamID"), rs.getString("TeamKuerzel"), rs.getString("TeamName"), rs.getString("TeamColor"), rs.getString("Address"), rs.getInt("Port"));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void create(String kuerzel, String name){
|
|
||||||
insert.update(kuerzel, name);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Team get(int id){
|
|
||||||
if(id == -1)
|
|
||||||
return new Team(-1, "?", "?", "8", null, 25565);
|
|
||||||
if(id == 0)
|
|
||||||
return pub;
|
|
||||||
for(Team team : teamCache)
|
|
||||||
if(team.teamId == id)
|
|
||||||
return team;
|
|
||||||
return byId.select(rs -> {
|
|
||||||
rs.next();
|
|
||||||
return new Team(rs);
|
|
||||||
}, id);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Team get(String name){
|
|
||||||
for(Team team : teamCache)
|
|
||||||
if(team.teamName.equalsIgnoreCase(name) || team.teamKuerzel.equalsIgnoreCase(name))
|
|
||||||
return team;
|
|
||||||
return byName.select(rs -> {
|
|
||||||
if(rs.next())
|
|
||||||
return new Team(rs);
|
|
||||||
return null;
|
|
||||||
}, name.toLowerCase(), name.toLowerCase());
|
|
||||||
}
|
|
||||||
|
|
||||||
public static List<Team> getAll(){
|
|
||||||
clearCache();
|
|
||||||
return all.select(rs -> {
|
|
||||||
while(rs.next())
|
|
||||||
new Team(rs);
|
|
||||||
return teamCache;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void clearCache(){
|
|
||||||
teamCache.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void updateDB(){
|
|
||||||
update.update(teamId, teamKuerzel, teamName, teamColor, address, port);
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getTeamId() {
|
|
||||||
return teamId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getTeamKuerzel() {
|
|
||||||
return teamKuerzel;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setTeamKuerzel(String teamKuerzel) {
|
|
||||||
this.teamKuerzel = teamKuerzel;
|
|
||||||
updateDB();
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getTeamName() {
|
|
||||||
return teamName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setTeamName(String teamName) {
|
|
||||||
this.teamName = teamName;
|
|
||||||
updateDB();
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getTeamColor() {
|
|
||||||
return teamColor;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setTeamColor(String teamColor) {
|
|
||||||
this.teamColor = teamColor;
|
|
||||||
updateDB();
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getAddress() {
|
|
||||||
return address;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setAddress(String address) {
|
|
||||||
this.address = address;
|
|
||||||
updateDB();
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getPort() {
|
|
||||||
return port;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPort(int port) {
|
|
||||||
this.port = port;
|
|
||||||
updateDB();
|
|
||||||
}
|
|
||||||
|
|
||||||
public int size(){
|
|
||||||
return getSize.select(rs -> {
|
|
||||||
rs.next();
|
|
||||||
return rs.getInt("COUNT(id)");
|
|
||||||
}, teamId);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void disband(SteamwarUser user){
|
|
||||||
user.setLeader(false);
|
|
||||||
delete.update(teamId);
|
|
||||||
teamCache.remove(this);
|
|
||||||
TeamTeilnahme.deleteFuture(teamId);
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<Integer> getMembers(){
|
|
||||||
return getMembers.select(rs -> {
|
|
||||||
List<Integer> members = new ArrayList<>();
|
|
||||||
while(rs.next())
|
|
||||||
members.add(rs.getInt("id"));
|
|
||||||
return members;
|
|
||||||
}, teamId);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,71 +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.util.HashSet;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
public class TeamTeilnahme {
|
|
||||||
private TeamTeilnahme(){}
|
|
||||||
|
|
||||||
private static final Statement insert = new Statement("INSERT INTO TeamTeilnahme (TeamID, EventID) VALUES (?, ?)");
|
|
||||||
private static final Statement delete = new Statement("DELETE FROM TeamTeilnahme WHERE TeamID = ? AND EventID = ?");
|
|
||||||
private static final Statement deleteFuture = new Statement("DELETE t FROM TeamTeilnahme t INNER JOIN Event e ON t.EventID = e.EventID WHERE t.TeamID = ? AND e.Start > NOW()");
|
|
||||||
private static final Statement byEventTeam = new Statement("SELECT * FROM TeamTeilnahme WHERE TeamID = ? AND EventID = ?");
|
|
||||||
private static final Statement byEvent = new Statement("SELECT * FROM TeamTeilnahme WHERE EventID = ?");
|
|
||||||
private static final Statement byTeam = new Statement("SELECT * FROM TeamTeilnahme WHERE TeamID = ?");
|
|
||||||
|
|
||||||
public static void teilnehmen(int teamID, int eventID){
|
|
||||||
insert.update(teamID, eventID);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void notTeilnehmen(int teamID, int eventID){
|
|
||||||
delete.update(teamID, eventID);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean nimmtTeil(int teamID, int eventID){
|
|
||||||
return byEventTeam.select(ResultSet::next, teamID, eventID);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void deleteFuture(int teamID) {
|
|
||||||
deleteFuture.update(teamID);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Set<Team> getTeams(int eventID){
|
|
||||||
return byEvent.select(rs -> {
|
|
||||||
Set<Team> teams = new HashSet<>();
|
|
||||||
while(rs.next())
|
|
||||||
teams.add(Team.get(rs.getInt("TeamID")));
|
|
||||||
return teams;
|
|
||||||
}, eventID);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Set<Event> getEvents(int teamID){
|
|
||||||
return byTeam.select(rs -> {
|
|
||||||
Set<Event> events = new HashSet<>();
|
|
||||||
while(rs.next())
|
|
||||||
events.add(Event.get(rs.getInt("EventID")));
|
|
||||||
return events;
|
|
||||||
}, teamID);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,139 +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.Statement;
|
|
||||||
|
|
||||||
import de.steamwar.bungeecore.BungeeCore;
|
|
||||||
import de.steamwar.bungeecore.ServerStarter;
|
|
||||||
import de.steamwar.bungeecore.SubserverSystem;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.sql.ResultSet;
|
|
||||||
import java.sql.SQLException;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
public class Tutorial {
|
|
||||||
|
|
||||||
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");
|
|
||||||
private static final Statement release = new Statement("UPDATE Tutorial SET Released = 1 WHERE TutorialID = ?");
|
|
||||||
private static final Statement delete = new Statement("DELETE FROM Tutorial WHERE TutorialID = ?");
|
|
||||||
|
|
||||||
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(SteamwarUser 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.getId(), page * elementsPerPage, elementsPerPage);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Tutorial create(SteamwarUser creator, String name, String item) {
|
|
||||||
create.update(creator.getId(), name, item);
|
|
||||||
return by_creator_name.select(rs -> {
|
|
||||||
rs.next();
|
|
||||||
return new Tutorial(rs);
|
|
||||||
}, creator.getId(), name);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Tutorial get(int id) {
|
|
||||||
return by_id.select(rs -> {
|
|
||||||
if(rs.next())
|
|
||||||
return new Tutorial(rs);
|
|
||||||
return null;
|
|
||||||
}, id);
|
|
||||||
}
|
|
||||||
|
|
||||||
private final int id;
|
|
||||||
private final int creator;
|
|
||||||
private final String name;
|
|
||||||
private final String item;
|
|
||||||
private final double stars;
|
|
||||||
private final boolean released;
|
|
||||||
|
|
||||||
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 SteamwarUser creator() {
|
|
||||||
return SteamwarUser.get(creator);
|
|
||||||
}
|
|
||||||
|
|
||||||
public double stars() {
|
|
||||||
return stars;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int id() {
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String name() {
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String item() {
|
|
||||||
return item;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean released() {
|
|
||||||
return released;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void release() {
|
|
||||||
release.update(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void delete() {
|
|
||||||
delete.update(id);
|
|
||||||
SubserverSystem.deleteFolder(BungeeCore.local, world().getPath());
|
|
||||||
}
|
|
||||||
|
|
||||||
public File world() {
|
|
||||||
return new File(ServerStarter.TUTORIAL_PATH, String.valueOf(id));
|
|
||||||
}
|
|
||||||
|
|
||||||
public void rate(SteamwarUser user, int rating) {
|
|
||||||
rate.update(id, user.getId(), rating);
|
|
||||||
}
|
|
||||||
}
|
|
Einige Dateien werden nicht angezeigt, da zu viele Dateien in diesem Diff geändert wurden Mehr anzeigen
In neuem Issue referenzieren
Einen Benutzer sperren