Merge branch 'master' into seperate_schemdata
# Conflicts: # src/de/steamwar/bungeecore/sql/SchematicNode.java
Dieser Commit ist enthalten in:
Commit
a4509ab88e
@ -1 +1 @@
|
||||
Subproject commit aa70f423d87e9f6534ad2dd1f20a5122179c423f
|
||||
Subproject commit 95b46f3a9a83eb63f5770552134967a1921ae159
|
@ -19,7 +19,7 @@
|
||||
|
||||
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.config.Configuration;
|
||||
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.NetworkReceiver;
|
||||
import de.steamwar.bungeecore.network.SWScriptSyntaxForwarder;
|
||||
import de.steamwar.bungeecore.sql.Punishment;
|
||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||
import de.steamwar.bungeecore.sql.Team;
|
||||
import de.steamwar.bungeecore.sql.UserElo;
|
||||
import de.steamwar.sql.Punishment;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import de.steamwar.sql.UserElo;
|
||||
import de.steamwar.bungeecore.tablist.TablistManager;
|
||||
import de.steamwar.command.SWCommandUtils;
|
||||
import de.steamwar.command.SWTypeMapperCreator;
|
||||
import de.steamwar.command.TabCompletionCache;
|
||||
import de.steamwar.command.TypeMapper;
|
||||
import de.steamwar.sql.Team;
|
||||
import de.steamwar.sql.internal.Statement;
|
||||
import net.md_5.bungee.BungeeCord;
|
||||
import net.md_5.bungee.api.ChatMessageType;
|
||||
@ -141,7 +141,7 @@ public class BungeeCore extends Plugin {
|
||||
new KickCommand();
|
||||
new JoinmeCommand();
|
||||
new TpCommand();
|
||||
new HelpCommand();
|
||||
HelpCommand helpCommand = new HelpCommand();
|
||||
new TeamCommand();
|
||||
new ServerTeamchatCommand();
|
||||
new DevCommand();
|
||||
@ -183,7 +183,7 @@ public class BungeeCore extends Plugin {
|
||||
new PunishmentCommand("note", Punishment.PunishmentType.Note);
|
||||
|
||||
if(!EVENT_MODE){
|
||||
new BauCommand();
|
||||
new BauCommand(helpCommand);
|
||||
new WebpasswordCommand();
|
||||
new FightCommand();
|
||||
new ChallengeCommand();
|
||||
@ -205,9 +205,9 @@ public class BungeeCore extends Plugin {
|
||||
new SettingsChangedListener();
|
||||
|
||||
getProxy().getScheduler().schedule(this, () -> {
|
||||
SteamwarUser.clearCache();
|
||||
UserElo.clearCache();
|
||||
Team.clearCache();
|
||||
SteamwarUser.clear();
|
||||
UserElo.clear();
|
||||
Team.clear();
|
||||
}, 1, 1, TimeUnit.HOURS);
|
||||
|
||||
if (SteamwarDiscordBotConfig.loaded) {
|
||||
|
@ -19,7 +19,7 @@
|
||||
|
||||
package de.steamwar.bungeecore;
|
||||
|
||||
import de.steamwar.bungeecore.sql.SWException;
|
||||
import de.steamwar.sql.SWException;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.PrintStream;
|
||||
@ -61,7 +61,7 @@ public class ErrorLogger extends Handler {
|
||||
}
|
||||
|
||||
|
||||
SWException.log("Bungee", message, stacktrace);
|
||||
SWException.log(message, stacktrace);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -19,10 +19,10 @@
|
||||
|
||||
package de.steamwar.bungeecore;
|
||||
|
||||
import de.steamwar.bungeecore.sql.Event;
|
||||
import de.steamwar.bungeecore.sql.EventFight;
|
||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||
import de.steamwar.bungeecore.sql.Team;
|
||||
import de.steamwar.sql.EventFight;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import de.steamwar.sql.Team;
|
||||
import de.steamwar.sql.Event;
|
||||
import net.md_5.bungee.api.ProxyServer;
|
||||
import net.md_5.bungee.api.chat.ClickEvent;
|
||||
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()) {
|
||||
ServerStarter starter = new ServerStarter().event(next);
|
||||
|
||||
ProxiedPlayer leiter = ProxyServer.getInstance().getPlayer(SteamwarUser.get(next.getKampfleiter()).getUuid());
|
||||
ProxiedPlayer leiter = ProxyServer.getInstance().getPlayer(SteamwarUser.get(next.getKampfleiter()).getUUID());
|
||||
if(leiter != null)
|
||||
starter.send(leiter);
|
||||
|
||||
|
@ -1,9 +1,9 @@
|
||||
package de.steamwar.bungeecore;
|
||||
|
||||
import de.steamwar.bungeecore.sql.EventFight;
|
||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||
import de.steamwar.bungeecore.sql.Team;
|
||||
import de.steamwar.bungeecore.sql.Tutorial;
|
||||
import de.steamwar.sql.EventFight;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import de.steamwar.sql.Team;
|
||||
import de.steamwar.sql.Tutorial;
|
||||
import de.steamwar.messages.ChatSender;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
|
||||
@ -67,13 +67,13 @@ public class ServerStarter {
|
||||
}
|
||||
|
||||
public ServerStarter event(EventFight eventFight) {
|
||||
arena(eventFight.getSpielmodus(), eventFight.getMap());
|
||||
arena(ArenaMode.getByInternal(eventFight.getSpielmodus()), eventFight.getMap());
|
||||
node = BungeeCore.local;
|
||||
worldDir = EVENT_PATH;
|
||||
worldCleanup = () -> {};
|
||||
arguments.put("fightID", String.valueOf(eventFight.getFightID()));
|
||||
fightMap = eventFight.getMap();
|
||||
gameMode = eventFight.getSpielmodus().getInternalName();
|
||||
gameMode = eventFight.getSpielmodus();
|
||||
|
||||
String serverName = Team.get(eventFight.getTeamBlue()).getTeamKuerzel() + " vs " + Team.get(eventFight.getTeamRed()).getTeamKuerzel();
|
||||
serverNameProvider = port -> serverName;
|
||||
@ -144,8 +144,8 @@ public class ServerStarter {
|
||||
public ServerStarter tutorial(ProxiedPlayer owner, Tutorial tutorial) {
|
||||
directory = new File(SERVER_PATH, "Tutorial");
|
||||
buildWithTemp(owner);
|
||||
tempWorld(TUTORIAL_PATH + tutorial.id());
|
||||
arguments.put("tutorial", String.valueOf(tutorial.id()));
|
||||
tempWorld(TUTORIAL_PATH + tutorial.getTutorialId());
|
||||
arguments.put("tutorial", String.valueOf(tutorial.getTutorialId()));
|
||||
return send(owner);
|
||||
}
|
||||
|
||||
|
@ -21,8 +21,8 @@ package de.steamwar.bungeecore;
|
||||
|
||||
import de.steamwar.bungeecore.network.NetworkSender;
|
||||
import de.steamwar.bungeecore.network.handlers.FightInfoHandler;
|
||||
import de.steamwar.bungeecore.sql.IgnoreSystem;
|
||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||
import de.steamwar.sql.IgnoreSystem;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import de.steamwar.network.packets.server.StartingServerPacket;
|
||||
import net.md_5.bungee.api.ProxyServer;
|
||||
import net.md_5.bungee.api.chat.ClickEvent;
|
||||
@ -41,7 +41,7 @@ public class SubserverSystem {
|
||||
ProxiedPlayer o = ProxyServer.getInstance().getPlayer(owner);
|
||||
if(o == null)
|
||||
return;
|
||||
if(IgnoreSystem.isIgnored(o, p)){
|
||||
if(IgnoreSystem.isIgnored(owner, p.getUniqueId())){
|
||||
Message.send("SERVER_IGNORED", p);
|
||||
return;
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ package de.steamwar.bungeecore.bot;
|
||||
|
||||
import de.steamwar.bungeecore.BungeeCore;
|
||||
import de.steamwar.bungeecore.bot.config.SteamwarDiscordBotConfig;
|
||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import net.dv8tion.jda.api.MessageBuilder;
|
||||
import net.dv8tion.jda.api.entities.Emoji;
|
||||
import net.dv8tion.jda.api.entities.Member;
|
||||
|
@ -28,8 +28,8 @@ import de.steamwar.bungeecore.bot.listeners.*;
|
||||
import de.steamwar.bungeecore.bot.util.DiscordRolesMessage;
|
||||
import de.steamwar.bungeecore.bot.util.DiscordRulesMessage;
|
||||
import de.steamwar.bungeecore.bot.util.DiscordTicketMessage;
|
||||
import de.steamwar.bungeecore.sql.Event;
|
||||
import de.steamwar.messages.ChatSender;
|
||||
import de.steamwar.sql.Event;
|
||||
import lombok.Getter;
|
||||
import net.dv8tion.jda.api.JDA;
|
||||
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.commands.PunishmentCommand;
|
||||
import de.steamwar.bungeecore.sql.Punishment;
|
||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import net.dv8tion.jda.api.events.interaction.SlashCommandEvent;
|
||||
import net.dv8tion.jda.api.interactions.commands.OptionType;
|
||||
|
||||
@ -45,7 +44,7 @@ public class BanCommand extends BasicDiscordCommand {
|
||||
}
|
||||
|
||||
SteamwarUser sender = SteamwarUser.get(event.getMember().getIdLong());
|
||||
SteamwarUser target = SteamwarUser.getOrCreateOfflinePlayer(event.getOption("user").getAsString());
|
||||
SteamwarUser target = PunishmentCommand.getOrCreateOfflinePlayer(event.getOption("user").getAsString());
|
||||
if (target == null) {
|
||||
event.reply("Angegebener User invalide").setEphemeral(true).queue();
|
||||
return;
|
||||
@ -60,7 +59,7 @@ public class BanCommand extends BasicDiscordCommand {
|
||||
String msg = event.getOption("reason").getAsString();
|
||||
boolean isPerma = event.getOption("time").getAsString().equals("perma");
|
||||
|
||||
target.punish(Punishment.PunishmentType.Ban, time, msg, sender.getId(), isPerma);
|
||||
PunishmentCommand.ban(target, time, msg, sender, isPerma);
|
||||
Message.team("BAN_TEAM", new Message("PREFIX"), target.getUserName(), sender.getUserName(), new Message((isPerma ? "BAN_PERMA" : "BAN_UNTIL"), time), msg);
|
||||
event.reply("Erfolgreich " + target.getUserName() + (isPerma ? " permanent" : " bis " + time) + " gebannt").setEphemeral(true).queue();
|
||||
}
|
||||
|
@ -19,8 +19,8 @@
|
||||
|
||||
package de.steamwar.bungeecore.bot.commands;
|
||||
|
||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||
import de.steamwar.bungeecore.sql.UserGroup;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import de.steamwar.sql.UserGroup;
|
||||
import net.dv8tion.jda.api.entities.Member;
|
||||
import net.dv8tion.jda.api.events.interaction.SlashCommandEvent;
|
||||
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.commands.PunishmentCommand;
|
||||
import de.steamwar.bungeecore.sql.Punishment;
|
||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||
import de.steamwar.sql.Punishment;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import net.dv8tion.jda.api.events.interaction.SlashCommandEvent;
|
||||
import net.dv8tion.jda.api.interactions.commands.OptionType;
|
||||
|
||||
@ -45,7 +45,7 @@ public class MuteCommand extends BasicDiscordCommand {
|
||||
}
|
||||
|
||||
SteamwarUser sender = SteamwarUser.get(event.getMember().getIdLong());
|
||||
SteamwarUser target = SteamwarUser.getOrCreateOfflinePlayer(event.getOption("user").getAsString());
|
||||
SteamwarUser target = PunishmentCommand.getOrCreateOfflinePlayer(event.getOption("user").getAsString());
|
||||
if (target == null) {
|
||||
event.reply("Angegebener User invalide").setEphemeral(true).complete();
|
||||
return;
|
||||
|
@ -19,10 +19,10 @@
|
||||
|
||||
package de.steamwar.bungeecore.bot.commands;
|
||||
|
||||
import de.steamwar.bungeecore.sql.Event;
|
||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||
import de.steamwar.bungeecore.sql.Team;
|
||||
import de.steamwar.bungeecore.sql.TeamTeilnahme;
|
||||
import de.steamwar.sql.Event;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import de.steamwar.sql.Team;
|
||||
import de.steamwar.sql.TeamTeilnahme;
|
||||
import net.dv8tion.jda.api.EmbedBuilder;
|
||||
import net.dv8tion.jda.api.entities.Emoji;
|
||||
import net.dv8tion.jda.api.events.interaction.SlashCommandEvent;
|
||||
@ -91,6 +91,6 @@ public class TeamCommand extends BasicDiscordCommand {
|
||||
}
|
||||
|
||||
private boolean isOnline(SteamwarUser user) {
|
||||
return ProxyServer.getInstance().getPlayer(user.getUuid()) != null;
|
||||
return ProxyServer.getInstance().getPlayer(user.getUUID()) != null;
|
||||
}
|
||||
}
|
||||
|
@ -19,8 +19,10 @@
|
||||
|
||||
package de.steamwar.bungeecore.bot.commands;
|
||||
|
||||
import de.steamwar.bungeecore.sql.Punishment;
|
||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||
import de.steamwar.bungeecore.commands.PunishmentCommand;
|
||||
import de.steamwar.sql.BannedUserIPs;
|
||||
import de.steamwar.sql.Punishment;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import net.dv8tion.jda.api.events.interaction.SlashCommandEvent;
|
||||
import net.dv8tion.jda.api.interactions.commands.OptionType;
|
||||
|
||||
@ -42,7 +44,7 @@ public class UnbanCommand extends BasicDiscordCommand {
|
||||
}
|
||||
|
||||
SteamwarUser sender = SteamwarUser.get(event.getMember().getIdLong());
|
||||
SteamwarUser target = SteamwarUser.getOrCreateOfflinePlayer(event.getOption("user").getAsString());
|
||||
SteamwarUser target = PunishmentCommand.getOrCreateOfflinePlayer(event.getOption("user").getAsString());
|
||||
if (target == null) {
|
||||
event.reply("Angegebener User invalide").setEphemeral(true).queue();
|
||||
return;
|
||||
@ -54,6 +56,7 @@ public class UnbanCommand extends BasicDiscordCommand {
|
||||
}
|
||||
|
||||
target.punish(Punishment.PunishmentType.Ban, Timestamp.from(new Date().toInstant()), "Unban", sender.getId(), false);
|
||||
BannedUserIPs.unbanIPs(target.getId());
|
||||
event.reply("Erfolgreich " + target.getUserName() + " entbannt").setEphemeral(true).queue();
|
||||
}
|
||||
}
|
||||
|
@ -19,9 +19,9 @@
|
||||
|
||||
package de.steamwar.bungeecore.bot.commands;
|
||||
|
||||
import de.steamwar.bungeecore.sql.Punishment;
|
||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||
import de.steamwar.bungeecore.sql.Team;
|
||||
import de.steamwar.sql.Punishment;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import de.steamwar.sql.Team;
|
||||
import net.dv8tion.jda.api.EmbedBuilder;
|
||||
import net.dv8tion.jda.api.events.interaction.SlashCommandEvent;
|
||||
import net.dv8tion.jda.api.interactions.commands.OptionType;
|
||||
@ -72,7 +72,7 @@ public class WhoisCommand extends BasicDiscordCommand {
|
||||
EmbedBuilder embedBuilder = new EmbedBuilder();
|
||||
embedBuilder.setTitle("Whois: " + user.getUserName());
|
||||
StringBuilder st = new StringBuilder();
|
||||
st.append("UUID: ").append(user.getUuid()).append("\n");
|
||||
st.append("UUID: ").append(user.getUUID()).append("\n");
|
||||
st.append("ID: ").append(user.getId()).append("\n");
|
||||
if (user.getDiscordId() != null) {
|
||||
st.append("DiscordID: ").append(user.getDiscordId()).append("\n");
|
||||
|
@ -19,7 +19,7 @@
|
||||
|
||||
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 java.util.ArrayList;
|
||||
|
@ -21,10 +21,10 @@ package de.steamwar.bungeecore.bot.events;
|
||||
|
||||
import de.steamwar.bungeecore.bot.SteamwarDiscordBot;
|
||||
import de.steamwar.bungeecore.bot.config.SteamwarDiscordBotConfig;
|
||||
import de.steamwar.bungeecore.sql.Event;
|
||||
import de.steamwar.bungeecore.sql.EventFight;
|
||||
import de.steamwar.bungeecore.sql.Team;
|
||||
import de.steamwar.bungeecore.sql.TeamTeilnahme;
|
||||
import de.steamwar.sql.EventFight;
|
||||
import de.steamwar.sql.Team;
|
||||
import de.steamwar.sql.TeamTeilnahme;
|
||||
import de.steamwar.sql.Event;
|
||||
import lombok.experimental.UtilityClass;
|
||||
import net.dv8tion.jda.api.EmbedBuilder;
|
||||
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.config.SteamwarDiscordBotConfig;
|
||||
import de.steamwar.bungeecore.commands.CheckCommand;
|
||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import lombok.experimental.UtilityClass;
|
||||
import net.dv8tion.jda.api.EmbedBuilder;
|
||||
import net.dv8tion.jda.api.MessageBuilder;
|
||||
|
@ -21,7 +21,7 @@ package de.steamwar.bungeecore.bot.listeners;
|
||||
|
||||
import de.steamwar.bungeecore.bot.AuthManager;
|
||||
import de.steamwar.bungeecore.bot.config.SteamwarDiscordBotConfig;
|
||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import net.dv8tion.jda.api.entities.ChannelType;
|
||||
import net.dv8tion.jda.api.events.interaction.GenericComponentInteractionCreateEvent;
|
||||
import net.dv8tion.jda.api.interactions.InteractionType;
|
||||
|
@ -22,8 +22,8 @@ package de.steamwar.bungeecore.bot.listeners;
|
||||
import de.steamwar.bungeecore.bot.SteamwarDiscordBot;
|
||||
import de.steamwar.bungeecore.bot.config.SteamwarDiscordBotConfig;
|
||||
import de.steamwar.bungeecore.listeners.ChatListener;
|
||||
import de.steamwar.bungeecore.sql.Punishment;
|
||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||
import de.steamwar.sql.Punishment;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import de.steamwar.messages.ChatSender;
|
||||
import net.dv8tion.jda.api.MessageBuilder;
|
||||
import net.dv8tion.jda.api.entities.Member;
|
||||
|
@ -21,10 +21,10 @@ package de.steamwar.bungeecore.bot.listeners;
|
||||
|
||||
import de.steamwar.bungeecore.bot.config.SteamwarDiscordBotConfig;
|
||||
import de.steamwar.bungeecore.bot.events.EventManager;
|
||||
import de.steamwar.bungeecore.sql.Event;
|
||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||
import de.steamwar.bungeecore.sql.Team;
|
||||
import de.steamwar.bungeecore.sql.TeamTeilnahme;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import de.steamwar.sql.Team;
|
||||
import de.steamwar.sql.TeamTeilnahme;
|
||||
import de.steamwar.sql.Event;
|
||||
import net.dv8tion.jda.api.events.interaction.SelectionMenuEvent;
|
||||
import net.dv8tion.jda.api.interactions.components.Component;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
@ -23,7 +23,7 @@ import de.steamwar.bungeecore.BungeeCore;
|
||||
import de.steamwar.bungeecore.Message;
|
||||
import de.steamwar.bungeecore.bot.config.DiscordTicketType;
|
||||
import de.steamwar.bungeecore.bot.config.SteamwarDiscordBotConfig;
|
||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import net.dv8tion.jda.api.EmbedBuilder;
|
||||
import net.dv8tion.jda.api.MessageBuilder;
|
||||
import net.dv8tion.jda.api.Permission;
|
||||
@ -138,7 +138,7 @@ public class DiscordTicketListener extends BasicDiscordListener {
|
||||
if(!event.getChannel().getId().equals(SteamwarDiscordBotConfig.TICKET_CHANNEL) && !event.getChannel().getId().equals(SteamwarDiscordBotConfig.TICKET_LOG)) {
|
||||
BungeeCore.get().getProxy().getPlayers().forEach(player -> {
|
||||
if(event.getAuthor().isBot() || event.getAuthor().isSystem()) return;
|
||||
SteamwarUser user = SteamwarUser.get(player);
|
||||
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
|
||||
boolean sendMessage;
|
||||
if(user.getDiscordId() == null) {
|
||||
sendMessage = user.getUserGroup().isCheckSchematics();
|
||||
|
@ -19,14 +19,14 @@
|
||||
package de.steamwar.bungeecore.bot.listeners;
|
||||
|
||||
import de.steamwar.bungeecore.BungeeCore;
|
||||
import de.steamwar.bungeecore.sql.Punishment;
|
||||
import de.steamwar.bungeecore.sql.SchematicNode;
|
||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||
import de.steamwar.sql.Punishment;
|
||||
import de.steamwar.sql.SchematicData;
|
||||
import de.steamwar.sql.SchematicNode;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import net.dv8tion.jda.api.entities.Message;
|
||||
import net.dv8tion.jda.api.events.message.priv.PrivateMessageReceivedEvent;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
public class PrivateMessageListener extends BasicDiscordListener {
|
||||
|
||||
@ -67,7 +67,7 @@ public class PrivateMessageListener extends BasicDiscordListener {
|
||||
|
||||
try {
|
||||
InputStream in = attachment.retrieveInputStream().get();
|
||||
node.saveFromStream(in, newFormat);
|
||||
new SchematicData(node).saveFromStream(in, newFormat);
|
||||
in.close();
|
||||
event.getMessage().reply("`" + name + "` wurde erfolgreich hochgeladen").queue();
|
||||
} catch (Exception e) {
|
||||
|
@ -21,7 +21,7 @@ package de.steamwar.bungeecore.bot.util;
|
||||
|
||||
import de.steamwar.bungeecore.bot.SteamwarDiscordBot;
|
||||
import de.steamwar.bungeecore.bot.config.SteamwarDiscordBotConfig;
|
||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import lombok.experimental.UtilityClass;
|
||||
import net.dv8tion.jda.api.entities.Guild;
|
||||
import net.dv8tion.jda.api.entities.Role;
|
||||
|
@ -20,8 +20,8 @@
|
||||
package de.steamwar.bungeecore.bot.util;
|
||||
|
||||
import de.steamwar.bungeecore.bot.SteamwarDiscordBot;
|
||||
import de.steamwar.bungeecore.sql.SchematicNode;
|
||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||
import de.steamwar.sql.SchematicNode;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import lombok.experimental.UtilityClass;
|
||||
import net.dv8tion.jda.api.EmbedBuilder;
|
||||
import net.dv8tion.jda.api.MessageBuilder;
|
||||
|
@ -1,69 +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.commands;
|
||||
|
||||
import de.steamwar.bungeecore.BungeeCore;
|
||||
import de.steamwar.bungeecore.Message;
|
||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||
import net.md_5.bungee.api.CommandSender;
|
||||
import net.md_5.bungee.api.ProxyServer;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
import net.md_5.bungee.api.plugin.Command;
|
||||
import net.md_5.bungee.api.plugin.TabExecutor;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
abstract class BasicCommand extends Command implements TabExecutor {
|
||||
|
||||
public BasicCommand(String name, String permission, String... aliases) {
|
||||
super(name, permission, aliases);
|
||||
BungeeCore.commands.put("/" + name, permission);
|
||||
ProxyServer.getInstance().getPluginManager().registerCommand(BungeeCore.get(), this);
|
||||
}
|
||||
|
||||
Iterable<String> allPlayers(String begin) {
|
||||
List<String> suggestions = new ArrayList<>();
|
||||
for(ProxiedPlayer player : ProxyServer.getInstance().getPlayers()){
|
||||
String playerName = player.getName();
|
||||
if(playerName.startsWith(begin))
|
||||
suggestions.add(playerName);
|
||||
}
|
||||
return suggestions;
|
||||
}
|
||||
|
||||
public Iterable<String> onTabComplete(CommandSender commandSender, String[] args) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
protected SteamwarUser existingUser(CommandSender sender, String arg){
|
||||
SteamwarUser target = SteamwarUser.get(arg);
|
||||
if(target == null)
|
||||
Message.send("UNKNOWN_PLAYER", sender);
|
||||
return target;
|
||||
}
|
||||
|
||||
protected SteamwarUser unsafeUser(CommandSender sender, String arg){
|
||||
SteamwarUser target = SteamwarUser.getOrCreateOfflinePlayer(arg);
|
||||
if(target == null)
|
||||
Message.send("UNKNOWN_PLAYER", sender);
|
||||
return target;
|
||||
}
|
||||
}
|
@ -23,13 +23,16 @@ import de.steamwar.bungeecore.*;
|
||||
import de.steamwar.bungeecore.inventory.SWInventory;
|
||||
import de.steamwar.bungeecore.inventory.SWItem;
|
||||
import de.steamwar.bungeecore.network.NetworkSender;
|
||||
import de.steamwar.bungeecore.sql.*;
|
||||
import de.steamwar.bungeecore.util.BauLock;
|
||||
import de.steamwar.bungeecore.util.Chat19;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import de.steamwar.command.TypeMapper;
|
||||
import de.steamwar.command.TypeValidator;
|
||||
import de.steamwar.messages.ChatSender;
|
||||
import de.steamwar.network.packets.server.BaumemberUpdatePacket;
|
||||
import de.steamwar.bungeecore.util.BauLockState;
|
||||
import de.steamwar.sql.BauweltMember;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import net.md_5.bungee.api.CommandSender;
|
||||
import net.md_5.bungee.api.ProxyServer;
|
||||
import net.md_5.bungee.api.config.ServerInfo;
|
||||
@ -41,13 +44,16 @@ import java.util.Map;
|
||||
|
||||
public class BauCommand extends SWCommand {
|
||||
|
||||
public BauCommand(){
|
||||
private final HelpCommand command;
|
||||
|
||||
public BauCommand(HelpCommand command){
|
||||
super("bau", null, "b", "build", "gs");
|
||||
this.command = command;
|
||||
}
|
||||
|
||||
@Register(help = true)
|
||||
@Register(noTabComplete = true)
|
||||
public void genericHelp(ProxiedPlayer p, String... args) {
|
||||
HelpCommand.sendBauHelp(ChatSender.of(p));
|
||||
this.command.sendBauHelp(p);
|
||||
}
|
||||
|
||||
@Register
|
||||
@ -120,10 +126,10 @@ public class BauCommand extends SWCommand {
|
||||
|
||||
@Register(value = "addmember", description = "BAU_ADDMEMBER_USAGE")
|
||||
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);
|
||||
|
||||
ProxiedPlayer z = ProxyServer.getInstance().getPlayer(target.getUuid());
|
||||
ProxiedPlayer z = ProxyServer.getInstance().getPlayer(target.getUUID());
|
||||
if(z != null)
|
||||
Message.send("BAU_ADDMEMBER_ADDED_TARGET", z, p.getName());
|
||||
}
|
||||
@ -135,11 +141,11 @@ public class BauCommand extends SWCommand {
|
||||
messageSender.send("UNKNOWN_PLAYER");
|
||||
return false;
|
||||
}
|
||||
if (((ProxiedPlayer) sender).getUniqueId().equals(value.getUuid())) {
|
||||
if (((ProxiedPlayer) sender).getUniqueId().equals(value.getUUID())) {
|
||||
messageSender.send("BAU_ADDMEMBER_SELFADD");
|
||||
return false;
|
||||
}
|
||||
if (BauweltMember.getBauMember(((ProxiedPlayer) sender).getUniqueId(), value.getUuid()) != null) {
|
||||
if (BauweltMember.getBauMember(((ProxiedPlayer) sender).getUniqueId(), value.getUUID()) != null) {
|
||||
messageSender.send("BAU_ADDMEMBER_ISADDED");
|
||||
return false;
|
||||
}
|
||||
@ -151,9 +157,9 @@ public class BauCommand extends SWCommand {
|
||||
@Register("teleport")
|
||||
public void teleport(ProxiedPlayer p, @Validator("teleportTarget") SteamwarUser worldOwner, @Mapper("version") @OptionalValue(value = "", onlyUINIG = true) int version) {
|
||||
versionSelector(version,
|
||||
() -> new ServerStarter().build12(worldOwner.getUuid()).send(p).start(),
|
||||
() -> new ServerStarter().build15(worldOwner.getUuid()).send(p).start(),
|
||||
() -> new ServerStarter().build19(worldOwner.getUuid()).send(p).start()
|
||||
() -> new ServerStarter().build12(worldOwner.getUUID()).send(p).start(),
|
||||
() -> new ServerStarter().build15(worldOwner.getUUID()).send(p).start(),
|
||||
() -> new ServerStarter().build19(worldOwner.getUUID()).send(p).start()
|
||||
);
|
||||
}
|
||||
|
||||
@ -165,12 +171,12 @@ public class BauCommand extends SWCommand {
|
||||
return false;
|
||||
}
|
||||
ProxiedPlayer p = (ProxiedPlayer) sender;
|
||||
if (!p.getUniqueId().equals(value.getUuid()) && BauweltMember.getBauMember(value.getUuid(), p.getUniqueId()) == null) {
|
||||
SubserverSystem.sendDeniedMessage(p, value.getUuid());
|
||||
if (!p.getUniqueId().equals(value.getUUID()) && BauweltMember.getBauMember(value.getUUID(), p.getUniqueId()) == null) {
|
||||
SubserverSystem.sendDeniedMessage(p, value.getUUID());
|
||||
messageSender.send("BAU_TP_NOALLOWED");
|
||||
return false;
|
||||
}
|
||||
if(BauLock.isLocked(value, SteamwarUser.get(p))) {
|
||||
if(BauLock.isLocked(value, SteamwarUser.get(p.getUniqueId()))) {
|
||||
messageSender.send("BAU_LOCKED_NOALLOWED");
|
||||
return false;
|
||||
}
|
||||
@ -229,13 +235,13 @@ public class BauCommand extends SWCommand {
|
||||
if (target == null)
|
||||
return;
|
||||
|
||||
if(SteamwarUser.get(target.getMemberID()).getUuid().equals(p.getUniqueId())) {
|
||||
if(SteamwarUser.get(target.getMemberID()).getUUID().equals(p.getUniqueId())) {
|
||||
Message.send("BAU_DELMEMBER_SELFDEL", p);
|
||||
return;
|
||||
}
|
||||
|
||||
target.remove();
|
||||
ProxiedPlayer toRemove = ProxyServer.getInstance().getPlayer(SteamwarUser.get(target.getMemberID()).getUuid());
|
||||
ProxiedPlayer toRemove = ProxyServer.getInstance().getPlayer(SteamwarUser.get(target.getMemberID()).getUUID());
|
||||
if(toRemove != null){
|
||||
Message.send("BAU_DELMEMBER_DELETED_TARGET", toRemove, p.getName());
|
||||
Subserver currentServer = Subserver.getSubserver(toRemove.getServer().getInfo());
|
||||
@ -306,7 +312,7 @@ public class BauCommand extends SWCommand {
|
||||
return null;
|
||||
}
|
||||
|
||||
BauweltMember target = BauweltMember.getBauMember(p.getUniqueId(), member.getUuid());
|
||||
BauweltMember target = BauweltMember.getBauMember(p.getUniqueId(), member.getUUID());
|
||||
if (target == null) {
|
||||
Message.send("BAU_MEMBER_NOMEMBER", p);
|
||||
return null;
|
||||
@ -315,7 +321,7 @@ public class BauCommand extends SWCommand {
|
||||
}
|
||||
|
||||
private static void isAllowedTo(boolean permission, ProxiedPlayer p, BauweltMember target, String what){
|
||||
ProxiedPlayer player = ProxyServer.getInstance().getPlayer(SteamwarUser.get(target.getMemberID()).getUuid());
|
||||
ProxiedPlayer player = ProxyServer.getInstance().getPlayer(SteamwarUser.get(target.getMemberID()).getUUID());
|
||||
|
||||
if(permission){
|
||||
if(player != null)
|
||||
|
@ -19,8 +19,8 @@
|
||||
|
||||
package de.steamwar.bungeecore.commands;
|
||||
|
||||
import de.steamwar.bungeecore.sql.SWException;
|
||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||
import de.steamwar.sql.SWException;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import de.steamwar.messages.ChatSender;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
@ -34,7 +34,7 @@ public class BugCommand extends SWCommand {
|
||||
public void bugMessage(ProxiedPlayer player, String... message) {
|
||||
String server = player.getServer().getInfo().getName();
|
||||
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");
|
||||
}
|
||||
}
|
||||
|
@ -22,9 +22,9 @@ package de.steamwar.bungeecore.commands;
|
||||
import de.steamwar.bungeecore.Message;
|
||||
import de.steamwar.bungeecore.inventory.SWInventory;
|
||||
import de.steamwar.bungeecore.inventory.SWItem;
|
||||
import de.steamwar.bungeecore.sql.NodeMember;
|
||||
import de.steamwar.bungeecore.sql.SchematicNode;
|
||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||
import de.steamwar.sql.NodeMember;
|
||||
import de.steamwar.sql.SchematicNode;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
|
||||
|
@ -20,7 +20,7 @@
|
||||
package de.steamwar.bungeecore.commands;
|
||||
|
||||
import de.steamwar.bungeecore.*;
|
||||
import de.steamwar.bungeecore.sql.IgnoreSystem;
|
||||
import de.steamwar.sql.IgnoreSystem;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import de.steamwar.command.TypeValidator;
|
||||
import net.md_5.bungee.api.chat.ClickEvent;
|
||||
@ -74,7 +74,7 @@ public class ChallengeCommand extends SWCommand {
|
||||
messageSender.send("CHALLENGE_SELF");
|
||||
return false;
|
||||
}
|
||||
if (IgnoreSystem.isIgnored(value, (ProxiedPlayer) sender)) {
|
||||
if (IgnoreSystem.isIgnored(value.getUniqueId(), ((ProxiedPlayer) sender).getUniqueId())) {
|
||||
messageSender.send("CHALLENGE_IGNORED");
|
||||
return false;
|
||||
}
|
||||
|
@ -22,10 +22,10 @@ package de.steamwar.bungeecore.commands;
|
||||
import de.steamwar.bungeecore.*;
|
||||
import de.steamwar.bungeecore.bot.util.DiscordSchemAlert;
|
||||
import de.steamwar.bungeecore.listeners.ConnectionListener;
|
||||
import de.steamwar.bungeecore.sql.CheckedSchematic;
|
||||
import de.steamwar.bungeecore.sql.SchematicNode;
|
||||
import de.steamwar.bungeecore.sql.SchematicType;
|
||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||
import de.steamwar.sql.CheckedSchematic;
|
||||
import de.steamwar.sql.SchematicNode;
|
||||
import de.steamwar.sql.SchematicType;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
import net.md_5.bungee.api.ProxyServer;
|
||||
@ -41,6 +41,7 @@ import java.util.concurrent.TimeUnit;
|
||||
import java.util.logging.Level;
|
||||
|
||||
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>> ranks = new HashMap<>();
|
||||
|
||||
@ -53,6 +54,10 @@ public class CheckCommand extends SWCommand {
|
||||
ranks.put(checkType, config.getStringList("Ranks"));
|
||||
}
|
||||
|
||||
public static void addFightType(SchematicType checkType, SchematicType fightType) {
|
||||
fightTypes.put(checkType, fightType);
|
||||
}
|
||||
|
||||
public static boolean isChecking(ProxiedPlayer player){
|
||||
return currentCheckers.containsKey(player.getUniqueId());
|
||||
}
|
||||
@ -213,7 +218,7 @@ public class CheckCommand extends SWCommand {
|
||||
this.checkList = checkQuestions.get(schematic.getSchemtype()).listIterator();
|
||||
|
||||
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) {
|
||||
remove();
|
||||
return;
|
||||
@ -272,9 +277,9 @@ public class CheckCommand extends SWCommand {
|
||||
schematic.setRank(rank);
|
||||
}
|
||||
|
||||
schematic.setType(schematic.getSchemtype().fightType().toDB());
|
||||
schematic.setType(fightTypes.get(schematic.getSchemtype()).toDB());
|
||||
SteamwarUser user = SteamwarUser.get(schematic.getOwner());
|
||||
ProxiedPlayer player = ProxyServer.getInstance().getPlayer(user.getUuid());
|
||||
ProxiedPlayer player = ProxyServer.getInstance().getPlayer(user.getUUID());
|
||||
if(player != null) {
|
||||
Message.send("CHECK_ACCEPTED", player, schematic.getSchemtype().name(), schematic.getName());
|
||||
} else {
|
||||
@ -282,14 +287,13 @@ public class CheckCommand extends SWCommand {
|
||||
}
|
||||
Message.team("CHECK_ACCEPTED_TEAM", schematic.getName(), user.getUserName());
|
||||
}
|
||||
|
||||
stop();
|
||||
}
|
||||
|
||||
private void decline(String reason){
|
||||
if(createLog(reason)) {
|
||||
SteamwarUser user = SteamwarUser.get(schematic.getOwner());
|
||||
ProxiedPlayer player = ProxyServer.getInstance().getPlayer(user.getUuid());
|
||||
ProxiedPlayer player = ProxyServer.getInstance().getPlayer(user.getUUID());
|
||||
if(player != null) {
|
||||
Message.send("CHECK_DECLINED", player, schematic.getSchemtype().name(), schematic.getName(), reason);
|
||||
} else {
|
||||
|
@ -20,8 +20,8 @@
|
||||
package de.steamwar.bungeecore.commands;
|
||||
|
||||
import de.steamwar.bungeecore.Message;
|
||||
import de.steamwar.bungeecore.sql.Punishment;
|
||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||
import de.steamwar.sql.Punishment;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import de.steamwar.command.*;
|
||||
import de.steamwar.messages.ChatSender;
|
||||
import net.md_5.bungee.api.ProxyServer;
|
||||
@ -79,9 +79,9 @@ public class DevCommand extends SWCommand {
|
||||
@ClassValidator(value = ProxiedPlayer.class, local = true)
|
||||
public TypeValidator<ProxiedPlayer> punishmentGuardChecker() {
|
||||
return (sender, value, messageSender) -> {
|
||||
SteamwarUser user = SteamwarUser.get(value);
|
||||
SteamwarUser user = SteamwarUser.get(value.getUniqueId());
|
||||
if (user.isPunished(Punishment.PunishmentType.NoDevServer)) {
|
||||
Message message = user.punishmentMessage(Punishment.PunishmentType.NoDevServer);
|
||||
Message message = PunishmentCommand.punishmentMessage(user, Punishment.PunishmentType.NoDevServer);
|
||||
messageSender.send(message.getFormat(), message.getParams());
|
||||
return false;
|
||||
}
|
||||
|
@ -20,55 +20,38 @@
|
||||
package de.steamwar.bungeecore.commands;
|
||||
|
||||
import de.steamwar.bungeecore.*;
|
||||
import de.steamwar.bungeecore.sql.*;
|
||||
import net.md_5.bungee.api.CommandSender;
|
||||
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.SWCommandUtils;
|
||||
import de.steamwar.command.TypeMapper;
|
||||
import de.steamwar.command.TypeValidator;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class EventCommand extends BasicCommand {
|
||||
public class EventCommand extends SWCommand {
|
||||
|
||||
public EventCommand() {
|
||||
super("event", "");
|
||||
super("event");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
if(!(sender instanceof ProxiedPlayer))
|
||||
return;
|
||||
ProxiedPlayer player = (ProxiedPlayer) sender;
|
||||
|
||||
Event currentEvent = Event.get();
|
||||
|
||||
if(currentEvent == null) {
|
||||
noCurrentEvent(player);
|
||||
return;
|
||||
}
|
||||
|
||||
if(args.length != 1){
|
||||
eventOverview(player, currentEvent);
|
||||
return;
|
||||
}
|
||||
|
||||
Team team = Team.get(args[0]);
|
||||
if(team == null){
|
||||
Message.send("EVENT_NO_TEAM", player);
|
||||
return;
|
||||
}
|
||||
|
||||
Subserver eventArena = EventStarter.getEventServer().get(team.getTeamId());
|
||||
if(eventArena == null || !Subserver.getServerList().contains(eventArena)){
|
||||
Message.send("EVENT_NO_FIGHT_TEAM", player);
|
||||
return;
|
||||
}
|
||||
|
||||
SubserverSystem.sendPlayer(eventArena, player);
|
||||
@Validator("noEvent")
|
||||
public TypeValidator<ProxiedPlayer> noEventValidator() {
|
||||
return (sender, value, messageSender) -> Event.get() == null;
|
||||
}
|
||||
|
||||
private void noCurrentEvent(ProxiedPlayer player){
|
||||
@Register
|
||||
public void noCurrentEvent(@Validator("noEvent") ProxiedPlayer player){
|
||||
Message.send("EVENT_NO_CURRENT", player);
|
||||
List<Event> coming = Event.getComing();
|
||||
Instant now = Instant.now();
|
||||
@ -81,10 +64,9 @@ public class EventCommand extends BasicCommand {
|
||||
if(now.isBefore(e.getDeadline().toInstant())) {
|
||||
Message.send("EVENT_COMING_DEADLINE", player, e.getDeadline());
|
||||
}
|
||||
String schemType = e.getSchemType();
|
||||
SchematicType schemType = e.getSchematicType();
|
||||
if (schemType != null) {
|
||||
SchematicType schematicType = SchematicType.fromDB(schemType);
|
||||
if (schematicType != null && schematicType.deadline() != null && now.isBefore(schematicType.deadline().toInstant())) {
|
||||
if (schemType.getDeadline() != null && now.isBefore(schemType.getDeadline().toInstant())) {
|
||||
Message.send("EVENT_COMING_SCHEM_DEADLINE", player, e.getDeadline());
|
||||
}
|
||||
}
|
||||
@ -99,7 +81,9 @@ public class EventCommand extends BasicCommand {
|
||||
}
|
||||
}
|
||||
|
||||
private void eventOverview(ProxiedPlayer player, Event currentEvent){
|
||||
@Register
|
||||
public void eventOverview(@Validator(value = "noEvent", invert = true) ProxiedPlayer player) {
|
||||
Event currentEvent = Event.get();
|
||||
Message.send("EVENT_USAGE", player);
|
||||
|
||||
List<EventFight> fights = EventFight.getEvent(currentEvent.getEventID());
|
||||
@ -129,4 +113,26 @@ public class EventCommand extends BasicCommand {
|
||||
BungeeCore.send(player, fline.toString());
|
||||
}
|
||||
}
|
||||
|
||||
@Register
|
||||
public void eventWithTeam(@Validator(value = "noEvent", invert = true) ProxiedPlayer player, @ErrorMessage("EVENT_NO_TEAM") Team team) {
|
||||
Subserver eventArena = EventStarter.getEventServer().get(team.getTeamId());
|
||||
if(eventArena == null || !Subserver.getServerList().contains(eventArena)){
|
||||
Message.send("EVENT_NO_FIGHT_TEAM", player);
|
||||
return;
|
||||
}
|
||||
SubserverSystem.sendPlayer(eventArena, player);
|
||||
}
|
||||
|
||||
@ClassMapper(Team.class)
|
||||
@Cached(cacheDuration = 10, global = true)
|
||||
public TypeMapper<Team> teamMapper() {
|
||||
return SWCommandUtils.createMapper(Team::get, s -> EventStarter.getEventServer()
|
||||
.keySet()
|
||||
.stream()
|
||||
.map(Team::get)
|
||||
.map(t -> Arrays.asList(t.getTeamKuerzel(), t.getTeamColor()))
|
||||
.flatMap(Collection::stream)
|
||||
.collect(Collectors.toList()));
|
||||
}
|
||||
}
|
||||
|
@ -20,11 +20,11 @@
|
||||
package de.steamwar.bungeecore.commands;
|
||||
|
||||
import de.steamwar.bungeecore.Message;
|
||||
import de.steamwar.bungeecore.sql.Event;
|
||||
import de.steamwar.bungeecore.sql.EventFight;
|
||||
import de.steamwar.bungeecore.sql.Team;
|
||||
import de.steamwar.sql.EventFight;
|
||||
import de.steamwar.sql.Team;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import de.steamwar.command.TypeMapper;
|
||||
import de.steamwar.sql.Event;
|
||||
import net.md_5.bungee.api.CommandSender;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
|
||||
|
@ -19,7 +19,7 @@
|
||||
|
||||
package de.steamwar.bungeecore.commands;
|
||||
|
||||
import de.steamwar.bungeecore.sql.EventFight;
|
||||
import de.steamwar.sql.EventFight;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import net.md_5.bungee.api.CommandSender;
|
||||
|
||||
|
@ -22,13 +22,10 @@ package de.steamwar.bungeecore.commands;
|
||||
import de.steamwar.bungeecore.*;
|
||||
import de.steamwar.bungeecore.inventory.SWInventory;
|
||||
import de.steamwar.bungeecore.inventory.SWItem;
|
||||
import de.steamwar.bungeecore.listeners.mods.ModLoaderBlocker;
|
||||
import de.steamwar.bungeecore.sql.Punishment;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import de.steamwar.messages.ChatSender;
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
import net.md_5.bungee.api.ChatMessageType;
|
||||
import net.md_5.bungee.api.CommandSender;
|
||||
import net.md_5.bungee.api.chat.ClickEvent;
|
||||
import net.md_5.bungee.api.chat.HoverEvent;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
|
@ -3,7 +3,7 @@ package de.steamwar.bungeecore.commands;
|
||||
import de.steamwar.bungeecore.BungeeCore;
|
||||
import de.steamwar.bungeecore.Message;
|
||||
import de.steamwar.sql.internal.Statement;
|
||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import net.md_5.bungee.BungeeCord;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
@ -25,7 +25,7 @@ public class GDPRQuery extends SWCommand {
|
||||
|
||||
@Register
|
||||
public void generate(ProxiedPlayer player, ProxiedPlayer forPlayer) {
|
||||
SteamwarUser user = SteamwarUser.get(forPlayer);
|
||||
SteamwarUser user = SteamwarUser.get(forPlayer.getUniqueId());
|
||||
if(user == null) {
|
||||
Message.send("UNKNOWN_PLAYER", player);
|
||||
return;
|
||||
@ -49,7 +49,7 @@ public class GDPRQuery extends SWCommand {
|
||||
copy(getClass().getClassLoader().getResourceAsStream("GDPRQueryREADME.md"), out, "README.txt");
|
||||
|
||||
printUpdate(player, "GDPR_STATUS_WORLD");
|
||||
copyBauwelt(user, out, "/home/minecraft/userworlds/" + user.getUuid().toString(), "BuildWorld12");
|
||||
copyBauwelt(user, out, "/home/minecraft/userworlds/" + user.getUUID().toString(), "BuildWorld12");
|
||||
copyBauwelt(user, out, "/home/minecraft/userworlds15/" + user.getId(), "BuildWorld15");
|
||||
|
||||
printUpdate(player, "GDPR_STATUS_INVENTORIES");
|
||||
@ -214,14 +214,14 @@ public class GDPRQuery extends SWCommand {
|
||||
}
|
||||
}
|
||||
|
||||
File playerdata = new File(world, "playerdata/" + user.getUuid().toString() + ".dat");
|
||||
File playerdata = new File(world, "playerdata/" + user.getUUID().toString() + ".dat");
|
||||
if(playerdata.exists())
|
||||
copy(playerdata, out, outDir + "/playerdata/" + user.getUuid().toString() + ".dat");
|
||||
copy(playerdata, out, outDir + "/playerdata/" + user.getUUID().toString() + ".dat");
|
||||
}
|
||||
|
||||
private void copyPlayerdata(SteamwarUser user, ZipOutputStream out, String inDir, String outDir) throws IOException {
|
||||
File worlds = new File(inDir);
|
||||
String path = "playerdata/" + user.getUuid().toString() + ".dat";
|
||||
String path = "playerdata/" + user.getUUID().toString() + ".dat";
|
||||
|
||||
int i = 0;
|
||||
for(File world : worlds.listFiles()) {
|
||||
@ -229,7 +229,7 @@ public class GDPRQuery extends SWCommand {
|
||||
if(!playerdata.exists())
|
||||
continue;
|
||||
|
||||
copy(playerdata, out, outDir + "/" + (i++) + "/" + user.getUuid().toString() + ".dat");
|
||||
copy(playerdata, out, outDir + "/" + (i++) + "/" + user.getUUID().toString() + ".dat");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -20,72 +20,61 @@
|
||||
package de.steamwar.bungeecore.commands;
|
||||
|
||||
import de.steamwar.bungeecore.Message;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import de.steamwar.messages.ChatSender;
|
||||
import net.md_5.bungee.api.CommandSender;
|
||||
import net.md_5.bungee.api.chat.ClickEvent;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
import net.md_5.bungee.protocol.packet.Chat;
|
||||
|
||||
public class HelpCommand extends BasicCommand {
|
||||
public class HelpCommand extends SWCommand {
|
||||
|
||||
public HelpCommand() {
|
||||
super("help", "", "?");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender s, String[] args) {
|
||||
ChatSender sender = ChatSender.of(s);
|
||||
if (args.length < 1) {
|
||||
printPage(sender, ClickEvent.Action.RUN_COMMAND,
|
||||
"HELP_LOBBY", "/l",
|
||||
"HELP_BAU", "/build",
|
||||
"HELP_BAUSERVER", "/help build",
|
||||
"HELP_FIGHT", "/fight",
|
||||
"HELP_CHALLENGE", "/challenge",
|
||||
"HELP_HISTORIC", "/historic",
|
||||
"HELP_TEAM", "/team",
|
||||
"HELP_JOIN", "/join",
|
||||
"HELP_LOCAL", "/local");
|
||||
}else if (args[0].equalsIgnoreCase("buildserver")) {
|
||||
sendBauHelp(sender);
|
||||
}else if (args[0].equalsIgnoreCase("build")) {
|
||||
bauHelpGroup(sender, args);
|
||||
}
|
||||
}
|
||||
@Register
|
||||
public void genericCommand(ProxiedPlayer player) {
|
||||
ChatSender sender = ChatSender.of(player);
|
||||
|
||||
private static void bauHelpGroup(ChatSender sender, String[] args) {
|
||||
if (args.length < 2) {
|
||||
sendBauHelpGroup(sender);
|
||||
return;
|
||||
}
|
||||
|
||||
switch (args[1].toLowerCase()) {
|
||||
case "admin":
|
||||
case "owner":
|
||||
case "bauwelt":
|
||||
sender.system("HELP_BAU_GROUP_ADMIN_TITLE");
|
||||
sendBauHelp(sender);
|
||||
return;
|
||||
case "world":
|
||||
printPage(sender, "HELP_BAU_GROUP_WORLD_TITLE", "HELP_TNT", "HELP_FIRE", "HELP_FREEZE", "HELP_TPSLIMIT", "HELP_PROTECT", "HELP_RESET");
|
||||
return;
|
||||
case "player":
|
||||
printPage(sender, "HELP_BAU_GROUP_PLAYER_TITLE", "HELP_SPEED", "HELP_NV", "HELP_WV", "HELP_DEBUGSTICK", "HELP_TRACE", "HELP_LOADER");
|
||||
return;
|
||||
case "worldedit":
|
||||
case "we":
|
||||
case "world-edit":
|
||||
case "edit":
|
||||
printPage(sender, "HELP_BAU_GROUP_WE_TITLE", "HELP_WE_POS1", "HELP_WE_POS2", "HELP_WE_COPY", "HELP_WE_PASTE", "HELP_WE_FLOPY", "HELP_WE_FLOPYP", "HELP_WE_ROTATE_90", "HELP_WE_ROTATE_180", "HELP_WE_ROTATE_N90");
|
||||
return;
|
||||
case "other":
|
||||
printPage(sender, "HELP_BAU_GROUP_OTHER_TITLE", "HELP_TESTBLOCK", "HELP_SKULL", "HELP_BAUINFO");
|
||||
return;
|
||||
default:
|
||||
sendBauHelpGroup(sender);
|
||||
}
|
||||
}
|
||||
|
||||
private static void sendBauHelpGroup(ChatSender sender) {
|
||||
printPage(sender, ClickEvent.Action.RUN_COMMAND,
|
||||
"HELP_LOBBY", "/l",
|
||||
"HELP_BAU", "/build",
|
||||
"HELP_BAUSERVER", "/help build",
|
||||
"HELP_FIGHT", "/fight",
|
||||
"HELP_CHALLENGE", "/challenge",
|
||||
"HELP_HISTORIC", "/historic",
|
||||
"HELP_TEAM", "/team",
|
||||
"HELP_JOIN", "/join",
|
||||
"HELP_LOCAL", "/local");
|
||||
}
|
||||
|
||||
@Register({"build","world"})
|
||||
public void buildWorld(ProxiedPlayer player) {
|
||||
printPage(ChatSender.of(player), "HELP_BAU_GROUP_WORLD_TITLE", "HELP_TNT", "HELP_FIRE", "HELP_FREEZE", "HELP_TPSLIMIT", "HELP_PROTECT", "HELP_RESET");
|
||||
}
|
||||
|
||||
@Register({"build","player"})
|
||||
public void buildPlayer(ProxiedPlayer player) {
|
||||
printPage(ChatSender.of(player), "HELP_BAU_GROUP_PLAYER_TITLE", "HELP_SPEED", "HELP_NV", "HELP_WV", "HELP_DEBUGSTICK", "HELP_TRACE", "HELP_LOADER");
|
||||
}
|
||||
|
||||
@Register({"build","worldedit"})
|
||||
@Register({"build","we"})
|
||||
@Register({"build","world-edit"})
|
||||
@Register({"build","edit"})
|
||||
public void buildWorldedit(ProxiedPlayer player) {
|
||||
printPage(ChatSender.of(player), "HELP_BAU_GROUP_WE_TITLE", "HELP_WE_POS1", "HELP_WE_POS2", "HELP_WE_COPY", "HELP_WE_PASTE", "HELP_WE_FLOPY", "HELP_WE_FLOPYP", "HELP_WE_ROTATE_90", "HELP_WE_ROTATE_180", "HELP_WE_ROTATE_N90");
|
||||
}
|
||||
|
||||
@Register({"build","other"})
|
||||
public void buildOther(ProxiedPlayer player) {
|
||||
printPage(ChatSender.of(player), "HELP_BAU_GROUP_OTHER_TITLE", "HELP_TESTBLOCK", "HELP_SKULL", "HELP_BAUINFO");
|
||||
}
|
||||
|
||||
@Register("build")
|
||||
public void sendBauHelpGroup(ProxiedPlayer player) {
|
||||
printPage(ChatSender.of(player), ClickEvent.Action.RUN_COMMAND,
|
||||
"HELP_BAU_GROUP_ADMIN", "/help build admin",
|
||||
"HELP_BAU_GROUP_WORLD", "/help build world",
|
||||
"HELP_BAU_GROUP_PLAYER", "/help build player",
|
||||
@ -93,8 +82,12 @@ public class HelpCommand extends BasicCommand {
|
||||
"HELP_BAU_GROUP_OTHER", "/help build other");
|
||||
}
|
||||
|
||||
static void sendBauHelp(ChatSender sender) {
|
||||
printPage(sender, ClickEvent.Action.SUGGEST_COMMAND,
|
||||
@Register("buildserver")
|
||||
@Register({"build","admin"})
|
||||
@Register({"build","owner"})
|
||||
@Register({"build","bauwelt"})
|
||||
public void sendBauHelp(ProxiedPlayer player) {
|
||||
printPage(ChatSender.of(player), ClickEvent.Action.SUGGEST_COMMAND,
|
||||
"HELP_BAU_TP", "/build tp ",
|
||||
"HELP_BAU_ADDMEMBER", "/build addmember ",
|
||||
"HELP_BAU_DELMEMBER", "/build delmember ",
|
||||
|
@ -20,13 +20,12 @@
|
||||
package de.steamwar.bungeecore.commands;
|
||||
|
||||
import de.steamwar.bungeecore.Message;
|
||||
import de.steamwar.bungeecore.sql.IgnoreSystem;
|
||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||
import de.steamwar.sql.IgnoreSystem;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import de.steamwar.command.SWCommandUtils;
|
||||
import de.steamwar.command.TypeMapper;
|
||||
import net.md_5.bungee.BungeeCord;
|
||||
import net.md_5.bungee.api.CommandSender;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
|
||||
import java.util.stream.Collectors;
|
||||
|
@ -20,78 +20,75 @@
|
||||
package de.steamwar.bungeecore.commands;
|
||||
|
||||
import de.steamwar.bungeecore.*;
|
||||
import de.steamwar.bungeecore.sql.BauweltMember;
|
||||
import de.steamwar.sql.BauweltMember;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import de.steamwar.command.TypeValidator;
|
||||
import net.md_5.bungee.api.CommandSender;
|
||||
import net.md_5.bungee.api.ProxyServer;
|
||||
import net.md_5.bungee.api.chat.ClickEvent;
|
||||
import net.md_5.bungee.api.config.ServerInfo;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class JoinmeCommand extends BasicCommand {
|
||||
public class JoinmeCommand extends SWCommand {
|
||||
|
||||
public JoinmeCommand() {
|
||||
super("joinme", "");
|
||||
super("joinme");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
if(sender instanceof ProxiedPlayer) {
|
||||
ProxiedPlayer player = (ProxiedPlayer) sender;
|
||||
@Register(description = "JOINME_USAGE")
|
||||
public void genericCommand(ProxiedPlayer player) {
|
||||
if (!player.hasPermission("bungeecore.joinme")) {
|
||||
Message.send("JOINME_USAGE", player);
|
||||
return;
|
||||
}
|
||||
Message.broadcast("JOINME_BROADCAST", "JOINME_BROADCAST_HOVER",
|
||||
new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/join " + player.getName()), player.getName(), player.getServer().getInfo().getName());
|
||||
}
|
||||
|
||||
if (args.length == 0 && player.hasPermission("bungeecore.joinme")) {
|
||||
Message.broadcast("JOINME_BROADCAST", "JOINME_BROADCAST_HOVER"
|
||||
, new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/join " + player.getName()), player.getName(), player.getServer().getInfo().getName());
|
||||
} else if (args.length == 1) {
|
||||
ProxiedPlayer target = ProxyServer.getInstance().getPlayer(args[0]);
|
||||
if(target == null || !target.isConnected()){
|
||||
Message.send("JOINME_PLAYER_OFFLINE", player);
|
||||
return;
|
||||
}else if(target.equals(player)){
|
||||
Message.send("JOINME_PLAYER_SELF", player);
|
||||
return;
|
||||
}
|
||||
ServerInfo server = target.getServer().getInfo();
|
||||
String serverPerm = BungeeCore.serverPermissions.get(server.getName());
|
||||
Subserver subserver = Subserver.getSubserver(target);
|
||||
@Register
|
||||
public void genericCommand(ProxiedPlayer player, @Validator ProxiedPlayer target) {
|
||||
if (target.equals(player)){
|
||||
Message.send("JOINME_PLAYER_SELF", player);
|
||||
return;
|
||||
}
|
||||
ServerInfo server = target.getServer().getInfo();
|
||||
String serverPerm = BungeeCore.serverPermissions.get(server.getName());
|
||||
Subserver subserver = Subserver.getSubserver(target);
|
||||
|
||||
if(subserver != null) {
|
||||
Servertype type = subserver.getType();
|
||||
if (type == Servertype.ARENA) {
|
||||
SubserverSystem.sendPlayer(subserver, player);
|
||||
} else if (type == Servertype.BAUSERVER) {
|
||||
Bauserver bauserver = (Bauserver) subserver;
|
||||
if (bauserver.getOwner().equals(player.getUniqueId()) ||
|
||||
BauweltMember.getBauMember(bauserver.getOwner(), player.getUniqueId()) != null) {
|
||||
SubserverSystem.sendPlayer(subserver, player);
|
||||
} else {
|
||||
SubserverSystem.sendDeniedMessage(player, bauserver.getOwner());
|
||||
Message.send("JOIN_PLAYER_BLOCK", player);
|
||||
}
|
||||
} else if(type == Servertype.BUILDER && !player.hasPermission("bungeecore.server.team")) {
|
||||
Message.send("JOIN_PLAYER_BLOCK", player);
|
||||
} else {
|
||||
SubserverSystem.sendPlayer(subserver, player);
|
||||
}
|
||||
}else if(serverPerm != null && !player.hasPermission(serverPerm)){
|
||||
if(subserver != null) {
|
||||
Servertype type = subserver.getType();
|
||||
if (type == Servertype.ARENA) {
|
||||
SubserverSystem.sendPlayer(subserver, player);
|
||||
} else if (type == Servertype.BAUSERVER) {
|
||||
Bauserver bauserver = (Bauserver) subserver;
|
||||
if (bauserver.getOwner().equals(player.getUniqueId()) ||
|
||||
BauweltMember.getBauMember(bauserver.getOwner(), player.getUniqueId()) != null) {
|
||||
SubserverSystem.sendPlayer(subserver, player);
|
||||
} else {
|
||||
SubserverSystem.sendDeniedMessage(player, bauserver.getOwner());
|
||||
Message.send("JOIN_PLAYER_BLOCK", player);
|
||||
}else if(serverPerm == null && !player.getGroups().contains("team")) {
|
||||
Message.send("JOIN_PLAYER_BLOCK", player);
|
||||
}else{
|
||||
player.connect(server);
|
||||
}
|
||||
} else if(type == Servertype.BUILDER && !player.hasPermission("bungeecore.server.team")) {
|
||||
Message.send("JOIN_PLAYER_BLOCK", player);
|
||||
} else {
|
||||
Message.send("JOINME_USAGE", player);
|
||||
SubserverSystem.sendPlayer(subserver, player);
|
||||
}
|
||||
}else if(serverPerm != null && !player.hasPermission(serverPerm)){
|
||||
Message.send("JOIN_PLAYER_BLOCK", player);
|
||||
}else if(serverPerm == null && !player.getGroups().contains("team")) {
|
||||
Message.send("JOIN_PLAYER_BLOCK", player);
|
||||
}else{
|
||||
player.connect(server);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<String> onTabComplete(CommandSender commandSender, String[] args) {
|
||||
if(args.length == 1){
|
||||
return allPlayers(args[0]);
|
||||
}
|
||||
return new ArrayList<>();
|
||||
@ClassValidator(ProxiedPlayer.class)
|
||||
public TypeValidator<ProxiedPlayer> playerMapper() {
|
||||
return (sender, value, messageSender) -> {
|
||||
if (value == null || !value.isConnected()) {
|
||||
messageSender.send("JOINME_PLAYER_OFFLINE", sender);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -24,8 +24,8 @@ import de.steamwar.bungeecore.inventory.SWInventory;
|
||||
import de.steamwar.bungeecore.inventory.SWItem;
|
||||
import de.steamwar.bungeecore.inventory.SWListInv;
|
||||
import de.steamwar.bungeecore.inventory.SWStreamInv;
|
||||
import de.steamwar.bungeecore.sql.*;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import de.steamwar.sql.Mod;
|
||||
import net.md_5.bungee.api.chat.ClickEvent;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
|
||||
@ -39,7 +39,7 @@ public class ModCommand extends SWCommand {
|
||||
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
|
||||
public void genericCommand(ProxiedPlayer p) {
|
||||
|
@ -20,7 +20,7 @@
|
||||
package de.steamwar.bungeecore.commands;
|
||||
|
||||
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.messages.ChatSender;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
@ -47,7 +47,7 @@ public class MsgCommand extends SWCommand {
|
||||
return;
|
||||
}
|
||||
|
||||
if (IgnoreSystem.isIgnored(target, player)) {
|
||||
if (IgnoreSystem.isIgnored(target.getUniqueId(), player.getUniqueId())) {
|
||||
sender.system("MSG_IGNORED");
|
||||
return;
|
||||
}
|
||||
|
@ -20,15 +20,11 @@
|
||||
package de.steamwar.bungeecore.commands;
|
||||
|
||||
import de.steamwar.bungeecore.Message;
|
||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import net.md_5.bungee.api.CommandSender;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
import org.apache.commons.lang3.LocaleUtils;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
import java.text.NumberFormat;
|
||||
import java.util.Locale;
|
||||
|
||||
public class PlaytimeCommand extends SWCommand {
|
||||
|
||||
@ -40,7 +36,7 @@ public class PlaytimeCommand extends SWCommand {
|
||||
public void genericCommand(ProxiedPlayer player) {
|
||||
NumberFormat format = NumberFormat.getNumberInstance((player).getLocale());
|
||||
format.setMaximumFractionDigits(2);
|
||||
String formattedText = format.format((SteamwarUser.get(player).getOnlinetime() / (double) 3600));
|
||||
String formattedText = format.format((SteamwarUser.get(player.getUniqueId()).getOnlinetime() / (double) 3600));
|
||||
|
||||
Message.send("HOURS_PLAYED", player, formattedText);
|
||||
}
|
||||
|
@ -21,8 +21,8 @@ package de.steamwar.bungeecore.commands;
|
||||
|
||||
import de.steamwar.bungeecore.Message;
|
||||
import de.steamwar.bungeecore.listeners.PollSystem;
|
||||
import de.steamwar.bungeecore.sql.PollAnswer;
|
||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||
import de.steamwar.sql.PollAnswer;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import de.steamwar.command.TypeValidator;
|
||||
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.listeners.PollSystem;
|
||||
import de.steamwar.bungeecore.sql.PollAnswer;
|
||||
import de.steamwar.sql.PollAnswer;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import de.steamwar.command.TypeValidator;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
@ -36,10 +36,10 @@ public class PollresultCommand extends SWCommand {
|
||||
|
||||
@Register
|
||||
public void genericCommand(@Validator ProxiedPlayer player) {
|
||||
Map<String, Integer> voted = PollAnswer.getCurrentResults();
|
||||
Message.send("POLLRESULT_HEADER", player, voted.values().stream().reduce(Integer::sum).orElse(0), PollSystem.getQuestion());
|
||||
for (Map.Entry<String, Integer> e: voted.entrySet()) {
|
||||
Message.send("POLLRESULT_LIST", player, e.getKey(), e.getValue());
|
||||
Map<Integer, Integer> voted = PollAnswer.getCurrentResults();
|
||||
Message.send("POLLRESULT_HEADER", player, voted.values().stream().reduce(Integer::sum).orElse(0), PollAnswer.getCurrentPoll());
|
||||
for (Map.Entry<Integer, Integer> e: voted.entrySet()) {
|
||||
Message.send("POLLRESULT_LIST", player, PollSystem.getAnswer(e.getKey()), e.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -19,13 +19,20 @@
|
||||
|
||||
package de.steamwar.bungeecore.commands;
|
||||
|
||||
import com.google.gson.JsonParser;
|
||||
import de.steamwar.bungeecore.BungeeCore;
|
||||
import de.steamwar.bungeecore.Message;
|
||||
import de.steamwar.bungeecore.sql.Punishment;
|
||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import de.steamwar.messages.ChatSender;
|
||||
import de.steamwar.sql.BannedUserIPs;
|
||||
import de.steamwar.sql.Punishment;
|
||||
import net.md_5.bungee.api.CommandSender;
|
||||
import net.md_5.bungee.api.ProxyServer;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.sql.Timestamp;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
@ -33,17 +40,84 @@ import java.time.Duration;
|
||||
import java.time.Instant;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import java.util.Date;
|
||||
import java.util.regex.MatchResult;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.NoSuchElementException;
|
||||
import java.util.Scanner;
|
||||
import java.util.UUID;
|
||||
import java.util.logging.Level;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class PunishmentCommand {
|
||||
|
||||
private static final String API_URL = "https://api.mojang.com/users/profiles/minecraft/";
|
||||
private static final JsonParser jsonParser = new JsonParser();
|
||||
|
||||
public static SteamwarUser getOrCreateOfflinePlayer(String name) {
|
||||
SteamwarUser user = SteamwarUser.get(name);
|
||||
if (user != null) {
|
||||
return user;
|
||||
}
|
||||
|
||||
UUID uuid = getUUIDofOfflinePlayer(name);
|
||||
if (uuid == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return SteamwarUser.getOrCreate(uuid, name, u -> {}, (o, n) -> {});
|
||||
}
|
||||
|
||||
private static UUID getUUIDofOfflinePlayer(String playerName) {
|
||||
try {
|
||||
final URL url = new URL(API_URL + playerName);
|
||||
String uuid = jsonParser.parse(new Scanner(url.openConnection().getInputStream()).nextLine()).getAsJsonObject().get("id").getAsString();
|
||||
return UUID.fromString(uuid.replaceFirst("(\\w{8})(\\w{4})(\\w{4})(\\w{4})(\\w{12})", "$1-$2-$3-$4-$5"));
|
||||
} catch (NoSuchElementException e) {
|
||||
// ignore, player does not exist
|
||||
} catch (IOException e) {
|
||||
BungeeCore.get().getLogger().log(Level.SEVERE, "Could not get offline player UUID " + playerName, e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static boolean isPunishedWithMessage(ChatSender player, Punishment.PunishmentType punishment) {
|
||||
SteamwarUser user = player.user();
|
||||
if (!user.isPunished(punishment)) {
|
||||
return false;
|
||||
}
|
||||
player.system(punishmentMessage(user, punishment));
|
||||
return true;
|
||||
}
|
||||
|
||||
public static void ban(SteamwarUser user, Timestamp time, String banReason, SteamwarUser punisher, boolean perma) {
|
||||
user.punish(Punishment.PunishmentType.Ban, time, banReason, punisher.getId(), perma);
|
||||
|
||||
ProxiedPlayer player = ProxyServer.getInstance().getPlayer(user.getUUID());
|
||||
if (player != null) {
|
||||
ChatSender.disconnect(player).system(punishmentMessage(user, Punishment.PunishmentType.Ban));
|
||||
for (BannedUserIPs banned : BannedUserIPs.get(player.getAddress().getAddress().getHostAddress())) {
|
||||
SteamwarUser bannedUser = SteamwarUser.get(banned.getUserID());
|
||||
if (bannedUser.isPunished(Punishment.PunishmentType.Ban) && bannedUser.getPunishment(Punishment.PunishmentType.Ban).getEndTime().before(time)) {
|
||||
bannedUser.punish(Punishment.PunishmentType.Ban, time, banReason, punisher.getId(), perma);
|
||||
}
|
||||
}
|
||||
BannedUserIPs.banIP(user.getId(), player.getAddress().getAddress().getHostAddress());
|
||||
}
|
||||
}
|
||||
|
||||
public static Message punishmentMessage(SteamwarUser user, Punishment.PunishmentType punishment) {
|
||||
Punishment currentPunishment = user.getPunishment(punishment);
|
||||
if (currentPunishment.isPerma()) {
|
||||
return new Message(punishment.getPlayerMessagePerma(), currentPunishment.getReason());
|
||||
} else {
|
||||
return new Message(punishment.getPlayerMessageUntil(), currentPunishment.getEndTime(), currentPunishment.getReason());
|
||||
}
|
||||
}
|
||||
|
||||
public PunishmentCommand(String command, Punishment.PunishmentType punishmentType) {
|
||||
new SWCommand(command, "bungeecore.ban") {
|
||||
@Register(description = "PUNISHMENT_USAGE")
|
||||
public void genericCommand(ProxiedPlayer player, String toPunish, String date, String... message) {
|
||||
if (punishmentType.isNeedsAdmin() && !SteamwarUser.get(player).getUserGroup().isAdminGroup()) {
|
||||
SteamwarUser punisher = SteamwarUser.get(player.getUniqueId());
|
||||
if (punishmentType.isNeedsAdmin() && !punisher.getUserGroup().isAdminGroup()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -57,7 +131,10 @@ public class PunishmentCommand {
|
||||
|
||||
boolean isPerma = date.equalsIgnoreCase("perma");
|
||||
String msg = String.join(" ", message);
|
||||
target.punish(punishmentType, banTime, msg, SteamwarUser.get(player.getName()).getId(), isPerma);
|
||||
if(punishmentType == Punishment.PunishmentType.Ban)
|
||||
ban(target, banTime, msg, punisher, isPerma);
|
||||
else
|
||||
target.punish(punishmentType, banTime, msg, punisher.getId(), isPerma);
|
||||
Message.team(punishmentType.getTeamMessage(), new Message("PREFIX"), target.getUserName(), player.getName(), new Message((isPerma ? "PUNISHMENT_PERMA" : "PUNISHMENT_UNTIL"), banTime), msg);
|
||||
}
|
||||
};
|
||||
@ -68,7 +145,7 @@ public class PunishmentCommand {
|
||||
new SWCommand(antiCommand, "bungeecore.ban") {
|
||||
@Register(description = "PUNISHMENT_USAGE")
|
||||
public void genericCommand(ProxiedPlayer player, String toUnpunish) {
|
||||
if (punishmentType.isNeedsAdmin() && !SteamwarUser.get(player).getUserGroup().isAdminGroup()) {
|
||||
if (punishmentType.isNeedsAdmin() && !SteamwarUser.get(player.getUniqueId()).getUserGroup().isAdminGroup()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -83,6 +160,8 @@ public class PunishmentCommand {
|
||||
|
||||
Message.send(punishmentType.getUnpunishmentMessage(), player, target.getUserName());
|
||||
target.punish(punishmentType, Timestamp.from(new Date().toInstant()), antiCommand, SteamwarUser.get(player.getName()).getId(), false);
|
||||
if(punishmentType == Punishment.PunishmentType.Ban)
|
||||
BannedUserIPs.unbanIPs(target.getId());
|
||||
}
|
||||
};
|
||||
}
|
||||
@ -95,7 +174,7 @@ public class PunishmentCommand {
|
||||
}
|
||||
|
||||
protected SteamwarUser unsafeUser(CommandSender sender, String arg){
|
||||
SteamwarUser target = SteamwarUser.getOrCreateOfflinePlayer(arg);
|
||||
SteamwarUser target = getOrCreateOfflinePlayer(arg);
|
||||
if(target == null)
|
||||
Message.send("UNKNOWN_PLAYER", sender);
|
||||
return target;
|
||||
|
@ -21,13 +21,12 @@ package de.steamwar.bungeecore.commands;
|
||||
|
||||
import de.steamwar.bungeecore.ArenaMode;
|
||||
import de.steamwar.bungeecore.Message;
|
||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||
import de.steamwar.bungeecore.sql.UserElo;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import de.steamwar.sql.UserElo;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import de.steamwar.command.SWCommandUtils;
|
||||
import de.steamwar.command.TypeMapper;
|
||||
import net.md_5.bungee.BungeeCord;
|
||||
import net.md_5.bungee.api.CommandSender;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
|
||||
import java.util.Optional;
|
||||
@ -68,10 +67,18 @@ public class RankCommand extends SWCommand {
|
||||
} else {
|
||||
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)
|
||||
public TypeMapper<String> playerTypeMapper() {
|
||||
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.SWListInv;
|
||||
import de.steamwar.bungeecore.inventory.SWStreamInv;
|
||||
import de.steamwar.bungeecore.sql.Fight;
|
||||
import de.steamwar.bungeecore.sql.Punishment;
|
||||
import de.steamwar.bungeecore.sql.SchematicType;
|
||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||
import de.steamwar.sql.Fight;
|
||||
import de.steamwar.sql.Punishment;
|
||||
import de.steamwar.sql.SchematicType;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import de.steamwar.messages.ChatSender;
|
||||
import net.md_5.bungee.api.CommandSender;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@ -45,12 +44,12 @@ public class ReplayCommand extends SWCommand {
|
||||
@Register
|
||||
public void genericCommand(ProxiedPlayer player, @OptionalValue("") String optionalMap) {
|
||||
ChatSender sender = ChatSender.of(player);
|
||||
if (sender.user().isPunishedWithMessage(sender, Punishment.PunishmentType.NoFightServer))
|
||||
if (PunishmentCommand.isPunishedWithMessage(sender, Punishment.PunishmentType.NoFightServer))
|
||||
return;
|
||||
|
||||
new SWStreamInv<>(player, Message.parse("REPLAY_TITLE", player), (click, fight) -> {
|
||||
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
|
||||
ArenaMode mode = fight.getGameMode();
|
||||
ArenaMode mode = ArenaMode.getBySchemType(fight.getSchemType());
|
||||
ServerStarter starter = new ServerStarter().replay(fight.getFightID()).blueLeader(player);
|
||||
|
||||
String map = mode.getRandomMap();
|
||||
|
@ -19,8 +19,10 @@
|
||||
|
||||
package de.steamwar.bungeecore.commands;
|
||||
|
||||
import de.steamwar.bungeecore.network.NetworkSender;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import de.steamwar.messages.ChatSender;
|
||||
import de.steamwar.network.packets.server.LocaleInvalidationPacket;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
|
||||
import java.util.Objects;
|
||||
@ -35,6 +37,7 @@ public class SetLocaleCommand extends SWCommand {
|
||||
public void genericCommand(ProxiedPlayer player) {
|
||||
ChatSender sender = ChatSender.of(player);
|
||||
sender.user().setLocale(Objects.requireNonNull(player.getLocale()), true);
|
||||
NetworkSender.send(player, new LocaleInvalidationPacket(sender.user().getId()));
|
||||
sender.system("LOCK_LOCALE_CHANGED");
|
||||
}
|
||||
}
|
||||
|
@ -23,8 +23,15 @@ import de.steamwar.bungeecore.Message;
|
||||
import de.steamwar.bungeecore.Storage;
|
||||
import de.steamwar.bungeecore.inventory.SWItem;
|
||||
import de.steamwar.bungeecore.inventory.SWListInv;
|
||||
import de.steamwar.bungeecore.sql.*;
|
||||
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.SWCommand;
|
||||
import de.steamwar.command.TypeMapper;
|
||||
import de.steamwar.messages.ChatSender;
|
||||
import de.steamwar.sql.Event;
|
||||
import net.md_5.bungee.BungeeCord;
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
import net.md_5.bungee.api.CommandSender;
|
||||
@ -41,15 +48,12 @@ import net.md_5.bungee.api.event.ServerConnectEvent;
|
||||
import java.net.*;
|
||||
import java.time.Instant;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static de.steamwar.bungeecore.Storage.teamInvitations;
|
||||
|
||||
public class TeamCommand extends BasicCommand {
|
||||
public class TeamCommand extends SWCommand {
|
||||
|
||||
private static final List<SWListInv.SWListEntry<String>> COLOR_CODES = new ArrayList<>();
|
||||
|
||||
@ -77,16 +81,17 @@ public class TeamCommand extends BasicCommand {
|
||||
}
|
||||
|
||||
public TeamCommand() {
|
||||
super("team", "");
|
||||
super("team");
|
||||
}
|
||||
|
||||
private void help(CommandSender sender){
|
||||
@Register(noTabComplete = true)
|
||||
public void help(CommandSender sender, String... args){
|
||||
Message.send("TEAM_HELP_HEADER", sender);
|
||||
Message.send("TEAM_HELP_LIST", sender);
|
||||
Message.send("TEAM_HELP_INFO", sender);
|
||||
Message.send("TEAM_HELP_TP", sender);
|
||||
if(!(sender instanceof ProxiedPlayer))
|
||||
return;
|
||||
Message.send("TEAM_HELP_TP", sender);
|
||||
|
||||
ProxiedPlayer player = (ProxiedPlayer) sender;
|
||||
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
|
||||
@ -111,93 +116,28 @@ public class TeamCommand extends BasicCommand {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args){
|
||||
if(args.length < 1){
|
||||
help(sender);
|
||||
return;
|
||||
}
|
||||
|
||||
if(!(sender instanceof ProxiedPlayer))
|
||||
return;
|
||||
|
||||
ProxiedPlayer player = (ProxiedPlayer) sender;
|
||||
@Register(value = "create", description = "TEAM_CREATE_USAGE")
|
||||
public void create(ProxiedPlayer player, @Length(min = 2, max = 4) @ErrorMessage("TEAM_KUERZEL_LENGTH") String kuerzel, @Length(min = 4, max = 15) @ErrorMessage("TEAM_NAME_LENGTH") String name){
|
||||
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
|
||||
Team team = Team.get(user.getTeam());
|
||||
|
||||
switch(args[0].toLowerCase()){
|
||||
case "create":
|
||||
create(player, user, team, args);
|
||||
break;
|
||||
case "join":
|
||||
join(player, user, args);
|
||||
break;
|
||||
case "stepback":
|
||||
stepBack(player,user,team);
|
||||
break;
|
||||
case "leave":
|
||||
leave(player, user, team);
|
||||
break;
|
||||
case "invite":
|
||||
invite(player, user, team, args);
|
||||
break;
|
||||
case "remove":
|
||||
remove(player, user, team, args);
|
||||
break;
|
||||
case "changekuerzel":
|
||||
changekuerzel(player, user, team, args);
|
||||
break;
|
||||
case "changename":
|
||||
changename(player, user, team, args);
|
||||
break;
|
||||
case "promote":
|
||||
promote(player, user, team, args);
|
||||
break;
|
||||
case "changecolor":
|
||||
changeColor(player, user, team);
|
||||
break;
|
||||
case "info":
|
||||
info(player, user, team, args);
|
||||
break;
|
||||
case "list":
|
||||
list(player, args);
|
||||
break;
|
||||
case "event":
|
||||
event(player, user, team, args);
|
||||
break;
|
||||
case "tp":
|
||||
tp(player, user, team, args);
|
||||
break;
|
||||
case "server":
|
||||
server(player, user, team, args);
|
||||
break;
|
||||
default:
|
||||
help(player);
|
||||
}
|
||||
}
|
||||
|
||||
private void create(ProxiedPlayer player, SteamwarUser user, Team team, String[] args){
|
||||
if(unwantedInTeam(player, user))
|
||||
return;
|
||||
|
||||
if(args.length < 3){
|
||||
Message.send("TEAM_CREATE_USAGE", player);
|
||||
return;
|
||||
}
|
||||
|
||||
if(checkTeamKuerzel(player, team, args[1]))
|
||||
if(checkTeamKuerzel(player, team, kuerzel))
|
||||
return;
|
||||
|
||||
if(checkTeamName(player, team, args[2]))
|
||||
if(checkTeamName(player, team, name))
|
||||
return;
|
||||
|
||||
Team.create(args[1], args[2]);
|
||||
user.setTeam(Team.get(args[1]).getTeamId());
|
||||
Team.create(kuerzel, name);
|
||||
user.setTeam(Team.get(kuerzel).getTeamId());
|
||||
user.setLeader(true);
|
||||
Message.send("TEAM_CREATE_CREATED", player, args[2]);
|
||||
Message.send("TEAM_CREATE_CREATED", player, name);
|
||||
}
|
||||
|
||||
private void join(ProxiedPlayer player, SteamwarUser user, String[] args){
|
||||
@Register("join")
|
||||
public void join(ProxiedPlayer player, String... args){
|
||||
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
|
||||
if(unwantedInTeam(player, user))
|
||||
return;
|
||||
|
||||
@ -215,7 +155,7 @@ public class TeamCommand extends BasicCommand {
|
||||
if(invs.size() == 1){
|
||||
t = invs.get(0);
|
||||
}else{
|
||||
if(args.length != 2){
|
||||
if(args.length != 1){
|
||||
Message.send("TEAM_JOIN_USAGE", player);
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for(int inv : invs){
|
||||
@ -228,7 +168,7 @@ public class TeamCommand extends BasicCommand {
|
||||
|
||||
for(int inv : invs){
|
||||
Team team = Team.get(inv);
|
||||
if(team.getTeamName().equals(args[1])){
|
||||
if(team.getTeamName().equals(args[0])){
|
||||
t = inv;
|
||||
break;
|
||||
}
|
||||
@ -245,8 +185,11 @@ public class TeamCommand extends BasicCommand {
|
||||
Message.send("TEAM_JOIN_JOINED", player, Team.get(t).getTeamName());
|
||||
}
|
||||
|
||||
private void stepBack(ProxiedPlayer player, SteamwarUser user, Team team) {
|
||||
if(notLeader(player, user, team))
|
||||
@Register("stepback")
|
||||
public void stepBack(ProxiedPlayer player) {
|
||||
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
|
||||
Team team = Team.get(user.getTeam());
|
||||
if(notLeader(player, user))
|
||||
return;
|
||||
|
||||
if(team.size() > 1 && team.getMembers().stream().map(SteamwarUser::get).filter(member -> user != member).noneMatch(SteamwarUser::isLeader)){
|
||||
@ -258,7 +201,10 @@ public class TeamCommand extends BasicCommand {
|
||||
Message.send("TEAM_STEP_BACK", player);
|
||||
}
|
||||
|
||||
private void leave(ProxiedPlayer player, SteamwarUser user, Team team){
|
||||
@Register("leave")
|
||||
public void leave(ProxiedPlayer player){
|
||||
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
|
||||
Team team = Team.get(user.getTeam());
|
||||
if(notInTeam(player, user))
|
||||
return;
|
||||
|
||||
@ -278,19 +224,17 @@ public class TeamCommand extends BasicCommand {
|
||||
}
|
||||
|
||||
|
||||
private void invite(ProxiedPlayer player, SteamwarUser user, Team team, String[] args){
|
||||
if(notLeader(player, user, team))
|
||||
@Register(value = "invite", description = "TEAM_INVITE_USAGE")
|
||||
public void invite(ProxiedPlayer player, String toInvite){
|
||||
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
|
||||
Team team = Team.get(user.getTeam());
|
||||
if(notLeader(player, user))
|
||||
return;
|
||||
|
||||
if(notDuringEvent(player))
|
||||
return;
|
||||
|
||||
if(args.length != 2){
|
||||
Message.send("TEAM_INVITE_USAGE", player);
|
||||
return;
|
||||
}
|
||||
|
||||
SteamwarUser target = SteamwarUser.get(args[1]);
|
||||
SteamwarUser target = SteamwarUser.get(toInvite);
|
||||
if(target == null){
|
||||
Message.send("TEAM_INVITE_NO_PLAYER", player);
|
||||
return;
|
||||
@ -309,22 +253,20 @@ public class TeamCommand extends BasicCommand {
|
||||
|
||||
teamInvitations.get(target.getId()).add(team.getTeamId());
|
||||
|
||||
Message.send("TEAM_INVITE_INVITED", player, args[1]);
|
||||
ProxiedPlayer p = ProxyServer.getInstance().getPlayer(target.getUuid());
|
||||
Message.send("TEAM_INVITE_INVITED", player, toInvite);
|
||||
ProxiedPlayer p = ProxyServer.getInstance().getPlayer(target.getUUID());
|
||||
if(p != null)
|
||||
Message.send("TEAM_INVITE_INVITED_TARGET", p, team.getTeamColor(), team.getTeamName());
|
||||
}
|
||||
|
||||
private void remove(ProxiedPlayer player, SteamwarUser user, Team team, String[] args){
|
||||
if(notLeader(player, user, team))
|
||||
@Register(value = "remove", description = "TEAM_REMOVE_USAGE")
|
||||
public void remove(ProxiedPlayer player, String toRemove){
|
||||
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
|
||||
Team team = Team.get(user.getTeam());
|
||||
if(notLeader(player, user))
|
||||
return;
|
||||
|
||||
if(args.length != 2){
|
||||
Message.send("TEAM_REMOVE_USAGE", player);
|
||||
return;
|
||||
}
|
||||
|
||||
SteamwarUser target = SteamwarUser.get(args[1]);
|
||||
SteamwarUser target = SteamwarUser.get(toRemove);
|
||||
if(target == null){
|
||||
Message.send("TEAM_REMOVE_NOT_PLAYER", player);
|
||||
return;
|
||||
@ -354,64 +296,57 @@ public class TeamCommand extends BasicCommand {
|
||||
target.setTeam(0);
|
||||
|
||||
Message.send("TEAM_REMOVE_REMOVED", player);
|
||||
ProxiedPlayer p = ProxyServer.getInstance().getPlayer(target.getUuid());
|
||||
ProxiedPlayer p = ProxyServer.getInstance().getPlayer(target.getUUID());
|
||||
if(p != null)
|
||||
Message.send("TEAM_REMOVE_REMOVED_TARGET", player);
|
||||
}
|
||||
|
||||
private void changekuerzel(ProxiedPlayer player, SteamwarUser user, Team team, String[] args){
|
||||
if(notLeader(player, user, team))
|
||||
@Register(value = "changekurzel", description = "TEAM_KUERZEL_USAGE")
|
||||
public void changekuerzel(ProxiedPlayer player, @Length(min = 2, max = 4) @ErrorMessage("TEAM_KUERZEL_LENGTH") String kuerzel){
|
||||
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
|
||||
Team team = Team.get(user.getTeam());
|
||||
if(notLeader(player, user))
|
||||
return;
|
||||
|
||||
if(notDuringEvent(player))
|
||||
return;
|
||||
|
||||
if(args.length < 2){
|
||||
Message.send("TEAM_KUERZEL_USAGE", player);
|
||||
return;
|
||||
}
|
||||
|
||||
if(checkTeamKuerzel(player, team, args[1]))
|
||||
if(checkTeamKuerzel(player, team, kuerzel))
|
||||
return;
|
||||
|
||||
team.setTeamKuerzel(args[1]);
|
||||
team.setTeamKuerzel(kuerzel);
|
||||
Message.send("TEAM_KUERZEL_CHANGED", player);
|
||||
}
|
||||
|
||||
private void changename(ProxiedPlayer player, SteamwarUser user, Team team, String[] args){
|
||||
if(notLeader(player, user, team))
|
||||
@Register(value = "changename", description = "TEAM_NAME_USAGE")
|
||||
public void changename(ProxiedPlayer player, @Length(min = 4, max = 15) @ErrorMessage("TEAM_NAME_LENGTH") String name){
|
||||
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
|
||||
Team team = Team.get(user.getTeam());
|
||||
if(notLeader(player, user))
|
||||
return;
|
||||
|
||||
if(notDuringEvent(player))
|
||||
return;
|
||||
|
||||
if(args.length < 2){
|
||||
Message.send("TEAM_NAME_USAGE", player);
|
||||
return;
|
||||
}
|
||||
|
||||
if(checkTeamName(player, team, args[1]))
|
||||
if(checkTeamName(player, team, name))
|
||||
return;
|
||||
|
||||
team.setTeamName(args[1]);
|
||||
team.setTeamName(name);
|
||||
Message.send("TEAM_NAME_CHANGED", player);
|
||||
}
|
||||
|
||||
private void promote(ProxiedPlayer player, SteamwarUser user, Team team, String[] args){
|
||||
if(notLeader(player, user, team))
|
||||
@Register(value = "promote", description = "TEAM_LEADER_USAGE")
|
||||
public void promote(ProxiedPlayer player, String toPromote){
|
||||
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
|
||||
if(notLeader(player, user))
|
||||
return;
|
||||
|
||||
if(notDuringEvent(player))
|
||||
return;
|
||||
|
||||
if(args.length < 2){
|
||||
Message.send("TEAM_LEADER_USAGE", player);
|
||||
return;
|
||||
}
|
||||
|
||||
SteamwarUser target = SteamwarUser.get(args[1]);
|
||||
SteamwarUser target = SteamwarUser.get(toPromote);
|
||||
if(target == null){
|
||||
Message.send("TEAM_LEADER_NOT_USER", player, args[1]);
|
||||
Message.send("TEAM_LEADER_NOT_USER", player, toPromote);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -421,19 +356,22 @@ public class TeamCommand extends BasicCommand {
|
||||
}
|
||||
|
||||
target.setLeader(true);
|
||||
Message.send("TEAM_LEADER_PROMOTED", player, args[1]);
|
||||
Message.send("TEAM_LEADER_PROMOTED", player, toPromote);
|
||||
}
|
||||
|
||||
private String playerName(SteamwarUser user){
|
||||
return ProxyServer.getInstance().getPlayer(user.getUuid()) != null ? "§a" + user.getUserName() : "§e" + user.getUserName();
|
||||
return ProxyServer.getInstance().getPlayer(user.getUUID()) != null ? "§a" + user.getUserName() : "§e" + user.getUserName();
|
||||
}
|
||||
|
||||
private void info(ProxiedPlayer player, SteamwarUser user, Team team, String[] args){
|
||||
@Register("info")
|
||||
public void info(ProxiedPlayer player, String... args){
|
||||
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
|
||||
Team team = Team.get(user.getTeam());
|
||||
if(args.length == 1 && user.getTeam() == 0){
|
||||
Message.send("TEAM_INFO_USAGE", player);
|
||||
return;
|
||||
}else if(user.getTeam() == 0 || args.length == 2){
|
||||
team = Team.get(args[1]);
|
||||
}else if(user.getTeam() == 0 || args.length == 1){
|
||||
team = Team.get(args[0]);
|
||||
}
|
||||
|
||||
if(team == null){
|
||||
@ -469,21 +407,10 @@ public class TeamCommand extends BasicCommand {
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
private void list(ProxiedPlayer player, String[] args){
|
||||
|
||||
@Register("list")
|
||||
public void list(ProxiedPlayer player, @Min(intValue = 1) @OptionalValue("1") @ErrorMessage("TEAM_LIST_NOT_PAGE") int page){
|
||||
final int TEAMS_PER_PAGE = 10;
|
||||
|
||||
int page;
|
||||
if(args.length > 1){
|
||||
try{
|
||||
page = Integer.parseInt(args[1]);
|
||||
}catch(NumberFormatException e){
|
||||
Message.send("TEAM_LIST_NOT_PAGE", player);
|
||||
return;
|
||||
}
|
||||
}else
|
||||
page = 1;
|
||||
|
||||
List<Team> all = Team.getAll();
|
||||
final int lastPage = ((all.size() - 1) / 10) + 1;
|
||||
if(page < 1 || page > lastPage){
|
||||
@ -520,34 +447,36 @@ public class TeamCommand extends BasicCommand {
|
||||
player.sendMessage(beforePage);
|
||||
}
|
||||
|
||||
private void event(ProxiedPlayer player, SteamwarUser user, Team team, String[] args){
|
||||
@Register("event")
|
||||
public void event(ProxiedPlayer player) {
|
||||
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
|
||||
Team team = Team.get(user.getTeam());
|
||||
if(notInTeam(player, user))
|
||||
return;
|
||||
|
||||
if(args.length < 2){
|
||||
Message.send("TEAM_EVENT_USAGE", player);
|
||||
Set<Event> events = TeamTeilnahme.getEvents(team.getTeamId());
|
||||
if(!events.isEmpty()){
|
||||
Message.send("TEAM_EVENT_HEADER", player);
|
||||
DateTimeFormatter dateFormat = DateTimeFormatter.ofPattern(Message.parse("EVENT_DATE_FORMAT", player));
|
||||
for(Event e : events)
|
||||
Message.sendPrefixless("TEAM_EVENT_EVENT", player, e.getStart().toLocalDateTime().format(dateFormat), e.getEventName());
|
||||
}
|
||||
return;
|
||||
Message.send("TEAM_EVENT_USAGE", player);
|
||||
Set<Event> events = TeamTeilnahme.getEvents(team.getTeamId());
|
||||
if(!events.isEmpty()){
|
||||
Message.send("TEAM_EVENT_HEADER", player);
|
||||
DateTimeFormatter dateFormat = DateTimeFormatter.ofPattern(Message.parse("EVENT_DATE_FORMAT", player));
|
||||
for(Event e : events)
|
||||
Message.sendPrefixless("TEAM_EVENT_EVENT", player, e.getStart().toLocalDateTime().format(dateFormat), e.getEventName());
|
||||
}
|
||||
}
|
||||
|
||||
if(notLeader(player, user, team))
|
||||
@Register("event")
|
||||
public void event(ProxiedPlayer player, Event event){
|
||||
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
|
||||
Team team = Team.get(user.getTeam());
|
||||
if(notInTeam(player, user))
|
||||
return;
|
||||
|
||||
if(notLeader(player, user))
|
||||
return;
|
||||
|
||||
if(notDuringEvent(player))
|
||||
return;
|
||||
|
||||
Event event = Event.get(args[1]);
|
||||
if(event == null){
|
||||
Message.send("TEAM_EVENT_NO_EVENT", player);
|
||||
return;
|
||||
}
|
||||
|
||||
if(Instant.now().isAfter(event.getDeadline().toInstant())){
|
||||
Message.send("TEAM_EVENT_OVER", player);
|
||||
return;
|
||||
@ -563,14 +492,17 @@ public class TeamCommand extends BasicCommand {
|
||||
}
|
||||
}
|
||||
|
||||
private void tp(ProxiedPlayer player, SteamwarUser user, Team team, String[] args){
|
||||
if(args.length == 1){
|
||||
@Register("tp")
|
||||
public void tp(ProxiedPlayer player, String... args){
|
||||
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
|
||||
Team team = Team.get(user.getTeam());
|
||||
if(args.length == 0){
|
||||
if(notInTeam(player, user))
|
||||
return;
|
||||
tp(player, team);
|
||||
return;
|
||||
}
|
||||
Team targetTeam = Team.get(args[1]);
|
||||
Team targetTeam = Team.get(args[0]);
|
||||
if(targetTeam == null){
|
||||
Message.send("TEAM_TP_NO_TEAM", player);
|
||||
return;
|
||||
@ -609,17 +541,16 @@ public class TeamCommand extends BasicCommand {
|
||||
*/
|
||||
}
|
||||
|
||||
private void server(ProxiedPlayer player, SteamwarUser user, Team team, String[] args){
|
||||
if(notLeader(player, user, team))
|
||||
@Register(value = "server", description = "TEAM_SERVER_USAGE")
|
||||
public void server(ProxiedPlayer player, String server, @Min(intValue = 1) @Max(intValue = 65535) @ErrorMessage("TEAM_SERVER_PORT_INVALID") int port){
|
||||
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
|
||||
Team team = Team.get(user.getTeam());
|
||||
if(notLeader(player, user))
|
||||
return;
|
||||
if (user.isPunishedWithMessage(ChatSender.of(player), Punishment.PunishmentType.NoTeamServer)) {
|
||||
if (PunishmentCommand.isPunishedWithMessage(ChatSender.of(player), Punishment.PunishmentType.NoTeamServer)) {
|
||||
return;
|
||||
}
|
||||
if (args.length < 2) {
|
||||
Message.send("TEAM_SERVER_USAGE", player);
|
||||
return;
|
||||
}
|
||||
String server = args[1];
|
||||
|
||||
try {
|
||||
if (isLocalhost(InetAddress.getByName(server))) {
|
||||
Message.send("TEAM_SERVER_ADDRESS_INVALID", player);
|
||||
@ -629,19 +560,7 @@ public class TeamCommand extends BasicCommand {
|
||||
Message.send("TEAM_SERVER_ADDRESS_INVALID", player);
|
||||
return;
|
||||
}
|
||||
int port = 25565;
|
||||
if (args.length == 3) {
|
||||
try {
|
||||
port = Integer.parseInt(args[2]);
|
||||
if (port < 1 || port > 65535) {
|
||||
Message.send("TEAM_SERVER_PORT_INVALID", player);
|
||||
return;
|
||||
}
|
||||
} catch (NumberFormatException e) {
|
||||
Message.send("TEAM_SERVER_PORT_INVALID", player);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
team.setAddress(server);
|
||||
team.setPort(port);
|
||||
Storage.teamServers.remove(team.getTeamId());
|
||||
@ -661,8 +580,11 @@ public class TeamCommand extends BasicCommand {
|
||||
}
|
||||
}
|
||||
|
||||
private void changeColor(ProxiedPlayer player, SteamwarUser user, Team team) {
|
||||
if(notLeader(player, user, team))
|
||||
@Register("color")
|
||||
public void changeColor(ProxiedPlayer player) {
|
||||
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
|
||||
Team team = Team.get(user.getTeam());
|
||||
if(notLeader(player, user))
|
||||
return;
|
||||
|
||||
if(notDuringEvent(player))
|
||||
@ -683,12 +605,32 @@ public class TeamCommand extends BasicCommand {
|
||||
inv.open();
|
||||
}
|
||||
|
||||
private boolean checkTeamName(ProxiedPlayer player, Team team, String arg){
|
||||
if(arg.length() < 4 || arg.length() > 15){
|
||||
Message.send("TEAM_NAME_LENGHT", player);
|
||||
return true;
|
||||
}
|
||||
@ClassMapper(Event.class)
|
||||
public TypeMapper<Event> eventTypeMapper() {
|
||||
return new TypeMapper<Event>() {
|
||||
@Override
|
||||
public Event map(CommandSender commandSender, String[] previousArguments, String s) {
|
||||
return Event.get(s);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean validate(CommandSender sender, Event value, MessageSender messageSender) {
|
||||
if (value == null) {
|
||||
messageSender.send("TEAM_EVENT_NO_EVENT", sender);
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<String> tabCompletes(CommandSender sender, PreviousArguments previousArguments, String s) {
|
||||
return Event.getComing().stream().map(Event::getEventName).collect(Collectors.toList());
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private boolean checkTeamName(ProxiedPlayer player, Team team, String arg){
|
||||
Team t = Team.get(arg);
|
||||
if(t != null && t.getTeamId() != team.getTeamId()){
|
||||
Message.send("TEAM_NAME_TAKEN", player);
|
||||
@ -698,11 +640,6 @@ public class TeamCommand extends BasicCommand {
|
||||
}
|
||||
|
||||
private boolean checkTeamKuerzel(ProxiedPlayer player, Team team, String arg){
|
||||
if(arg.length() < 2 || arg.length() > 4){
|
||||
Message.send("TEAM_KUERZEL_LENGHT", player);
|
||||
return true;
|
||||
}
|
||||
|
||||
Team t = Team.get(arg);
|
||||
if(t != null && (team == null || t.getTeamId() != team.getTeamId())){
|
||||
Message.send("TEAM_KUERZEL_TAKEN", player);
|
||||
@ -727,7 +664,7 @@ public class TeamCommand extends BasicCommand {
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean notLeader(ProxiedPlayer player, SteamwarUser user, Team team){
|
||||
private boolean notLeader(ProxiedPlayer player, SteamwarUser user){
|
||||
if(notInTeam(player, user))
|
||||
return true;
|
||||
if(!user.isLeader()){
|
||||
@ -744,37 +681,4 @@ public class TeamCommand extends BasicCommand {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<String> onTabComplete(CommandSender commandSender, String[] args){
|
||||
List<String> tab = new ArrayList<>();
|
||||
if(args.length == 1){
|
||||
tab.add("create");
|
||||
tab.add("join");
|
||||
tab.add("invite");
|
||||
tab.add("stepback");
|
||||
tab.add("leave");
|
||||
tab.add("info");
|
||||
tab.add("remove");
|
||||
tab.add("event");
|
||||
tab.add("changekuerzel");
|
||||
tab.add("changename");
|
||||
tab.add("promote");
|
||||
tab.add("changecolor");
|
||||
tab.add("tp");
|
||||
tab.add("server");
|
||||
}else if(args.length == 2){
|
||||
if(args[1].equalsIgnoreCase("event")){
|
||||
List<Event> coming = Event.getComing();
|
||||
coming.forEach(event -> tab.add(event.getEventName()));
|
||||
}else if(args[1].equalsIgnoreCase("join") || args[1].equalsIgnoreCase("info") || args[1].equalsIgnoreCase("tp")){
|
||||
List<Team> teams = Team.getAll();
|
||||
teams.forEach(team -> {
|
||||
tab.add(team.getTeamName());
|
||||
tab.add(team.getTeamKuerzel());
|
||||
});
|
||||
}
|
||||
}
|
||||
return tab;
|
||||
}
|
||||
}
|
||||
|
@ -20,30 +20,28 @@
|
||||
package de.steamwar.bungeecore.commands;
|
||||
|
||||
import de.steamwar.bungeecore.listeners.ChatListener;
|
||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import de.steamwar.messages.ChatSender;
|
||||
import net.md_5.bungee.api.CommandSender;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
|
||||
public class TeamchatCommand extends BasicCommand {
|
||||
public class TeamchatCommand extends SWCommand {
|
||||
|
||||
public TeamchatCommand() {
|
||||
super("tc", "","teamchat");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender s, String[] args) {
|
||||
ChatSender sender = ChatSender.of(s);
|
||||
if(args.length == 0){
|
||||
sender.system("TC_USAGE");
|
||||
return;
|
||||
}
|
||||
|
||||
@Register(description = "TC_USAGE")
|
||||
public void genericCommand(ProxiedPlayer player, @ErrorMessage(value = "TC_USAGE", allowEAs = false) String... args) {
|
||||
ChatSender sender = ChatSender.of(player);
|
||||
SteamwarUser user = sender.user();
|
||||
|
||||
if(user.getTeam() == 0){
|
||||
sender.system("TC_NO_TEAM");
|
||||
return;
|
||||
}
|
||||
|
||||
ChatListener.sendChat(sender, ChatSender.allReceivers().filter(player -> player.user().getTeam() == user.getTeam()), "CHAT_TEAM", null, String.join(" ", args));
|
||||
ChatListener.sendChat(sender, ChatSender.allReceivers().filter(p -> p.user().getTeam() == user.getTeam()), "CHAT_TEAM", null, String.join(" ", args));
|
||||
}
|
||||
}
|
||||
|
@ -20,9 +20,16 @@
|
||||
package de.steamwar.bungeecore.commands;
|
||||
|
||||
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.command.SWCommand;
|
||||
import de.steamwar.command.TypeMapper;
|
||||
import de.steamwar.messages.ChatSender;
|
||||
import de.steamwar.sql.Event;
|
||||
import net.md_5.bungee.BungeeCord;
|
||||
import net.md_5.bungee.api.CommandSender;
|
||||
import net.md_5.bungee.api.ProxyServer;
|
||||
@ -30,45 +37,62 @@ import net.md_5.bungee.api.config.ServerInfo;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
public class TpCommand extends BasicCommand {
|
||||
public class TpCommand extends SWCommand {
|
||||
|
||||
public TpCommand(){
|
||||
super("join", null, "tp", "teleport");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender s, String[] args) {
|
||||
if(!(s instanceof ProxiedPlayer))
|
||||
return;
|
||||
ProxiedPlayer player = (ProxiedPlayer) s;
|
||||
|
||||
ChatSender sender = ChatSender.of(player);
|
||||
if(args.length == 0){
|
||||
if(Event.get() == null)
|
||||
sender.system("TP_USAGE");
|
||||
else
|
||||
sender.system("TP_USAGE_EVENT");
|
||||
return;
|
||||
}
|
||||
|
||||
ServerInfo server = getTarget(args[0]);
|
||||
boolean onTeamServer = Storage.teamServers.containsValue(player.getServer().getInfo());
|
||||
|
||||
//Give control of teleport command to server
|
||||
if (server == player.getServer().getInfo() || onTeamServer || server == null) {
|
||||
Chat19.chat(player, "/tp " + String.join(" ", args));
|
||||
return;
|
||||
}
|
||||
|
||||
teleport(player, server);
|
||||
@Register
|
||||
public void genericCommand(ProxiedPlayer p) {
|
||||
ChatSender.of(p).system(Event.get() == null ? "TP_USAGE" : "TP_USAGE_EVENT");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<String> onTabComplete(CommandSender commandSender, String[] args) {
|
||||
if(args.length > 0)
|
||||
return allPlayers(args[args.length - 1]);
|
||||
return new ArrayList<>();
|
||||
@Register
|
||||
public void teleportCommand(ProxiedPlayer p, @Mapper("to") String to, String... rest) {
|
||||
ServerInfo server = getTarget(to);
|
||||
|
||||
//Give control of teleport command to server
|
||||
if (server == p.getServer().getInfo() || server == null) {
|
||||
if (rest.length == 0) {
|
||||
Chat19.chat(p, "/tp " + to);
|
||||
} else {
|
||||
Chat19.chat(p, "/tp " + to + " " + String.join(" ", rest));
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
teleport(p, server);
|
||||
}
|
||||
|
||||
@Mapper("to")
|
||||
@Cached(cacheDuration = 10, global = true)
|
||||
public TypeMapper<String> tabCompleter() {
|
||||
return new TypeMapper<String>() {
|
||||
@Override
|
||||
public String map(CommandSender commandSender, String[] previousArguments, String s) {
|
||||
return s;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<String> tabCompletes(CommandSender sender, String[] previousArguments, String s) {
|
||||
List<String> list = new ArrayList<>();
|
||||
for (ProxiedPlayer player : BungeeCord.getInstance().getPlayers()) {
|
||||
list.add(player.getName());
|
||||
}
|
||||
if (Event.get() != null) {
|
||||
EventStarter.getEventServer().keySet().forEach(teamId -> {
|
||||
Team team = Team.get(teamId);
|
||||
list.add(team.getTeamName());
|
||||
list.add(team.getTeamKuerzel());
|
||||
});
|
||||
}
|
||||
return list;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public static void teleport(ProxiedPlayer player, ServerInfo server){
|
||||
@ -82,14 +106,14 @@ public class TpCommand extends BasicCommand {
|
||||
Subserver subserver = Subserver.getSubserver(server);
|
||||
|
||||
if (subserver != null && subserver.getType() == Servertype.ARENA) {
|
||||
if (!sender.user().isPunishedWithMessage(sender, Punishment.PunishmentType.NoFightServer))
|
||||
if (!PunishmentCommand.isPunishedWithMessage(sender, Punishment.PunishmentType.NoFightServer))
|
||||
SubserverSystem.sendPlayer(subserver, player);
|
||||
|
||||
} else if(subserver instanceof Bauserver) {
|
||||
Bauserver bauserver = (Bauserver) subserver;
|
||||
ProxiedPlayer checker = BungeeCord.getInstance().getPlayer(bauserver.getOwner());
|
||||
if (checker != null && CheckCommand.isChecking(checker)) {
|
||||
SteamwarUser steamwarUser = SteamwarUser.get(player);
|
||||
SteamwarUser steamwarUser = SteamwarUser.get(player.getUniqueId());
|
||||
if (steamwarUser.getUserGroup().isCheckSchematics() || CheckCommand.getCheckingSchem(checker).getOwner() == steamwarUser.getId()) {
|
||||
SubserverSystem.sendPlayer(subserver, player);
|
||||
} else {
|
||||
|
@ -24,8 +24,8 @@ import de.steamwar.bungeecore.inventory.SWInventory;
|
||||
import de.steamwar.bungeecore.inventory.SWItem;
|
||||
import de.steamwar.bungeecore.inventory.SWListInv;
|
||||
import de.steamwar.bungeecore.inventory.SWStreamInv;
|
||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||
import de.steamwar.bungeecore.sql.Tutorial;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import de.steamwar.sql.Tutorial;
|
||||
import de.steamwar.bungeecore.util.Chat19;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import de.steamwar.command.TypeValidator;
|
||||
@ -96,36 +96,37 @@ public class TutorialCommand extends SWCommand {
|
||||
player,
|
||||
Message.parse("TUTORIAL_TITLE", player),
|
||||
(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();
|
||||
openInventory(player, released, own);
|
||||
return;
|
||||
} else if(own && click.isShiftClick() && click.isRightClick()) {
|
||||
tutorial.delete();
|
||||
SubserverSystem.deleteFolder(BungeeCore.local, world(tutorial).getPath());
|
||||
openInventory(player, released, own);
|
||||
return;
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
List<String> lore = new ArrayList<>();
|
||||
lore.add(Message.parse("TUTORIAL_BY", player, tutorial.creator().getUserName()));
|
||||
lore.add(Message.parse("TUTORIAL_STARS", player, String.format("%.1f", tutorial.stars())));
|
||||
lore.add(Message.parse("TUTORIAL_BY", player, SteamwarUser.get(tutorial.getCreator()).getUserName()));
|
||||
lore.add(Message.parse("TUTORIAL_STARS", player, String.format("%.1f", tutorial.getStars())));
|
||||
|
||||
if (personalHighlights)
|
||||
lore.add(Message.parse("TUTORIAL_DELETE", player));
|
||||
|
||||
item.setLore(lore);
|
||||
|
||||
if (personalHighlights && tutorial.released())
|
||||
if (personalHighlights && tutorial.isReleased())
|
||||
item.setEnchanted(true);
|
||||
|
||||
return item;
|
||||
@ -136,7 +137,7 @@ public class TutorialCommand extends SWCommand {
|
||||
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) -> {
|
||||
tutorial.rate(user, rate);
|
||||
tutorial.rate(user.getId(), rate);
|
||||
SWInventory.close(player);
|
||||
}).open();
|
||||
}
|
||||
@ -153,8 +154,8 @@ public class TutorialCommand extends SWCommand {
|
||||
|
||||
subserver.execute("save-all");
|
||||
ProxyServer.getInstance().getScheduler().schedule(BungeeCore.get(), () -> {
|
||||
Tutorial tutorial = Tutorial.create(user, name, item);
|
||||
File tutorialWorld = tutorial.world();
|
||||
Tutorial tutorial = Tutorial.create(user.getId(), name, item);
|
||||
File tutorialWorld = world(tutorial);
|
||||
|
||||
if (tutorialWorld.exists())
|
||||
SubserverSystem.deleteFolder(BungeeCore.local, tutorialWorld.getPath());
|
||||
@ -162,4 +163,8 @@ public class TutorialCommand extends SWCommand {
|
||||
Message.send("TUTORIAL_CREATED", player);
|
||||
}, 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.listeners.mods.ModLoaderBlocker;
|
||||
import de.steamwar.bungeecore.sql.Punishment;
|
||||
import de.steamwar.sql.Punishment;
|
||||
import de.steamwar.command.SWCommandUtils;
|
||||
import de.steamwar.command.TypeMapper;
|
||||
import de.steamwar.command.TypeValidator;
|
||||
@ -33,7 +33,6 @@ import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@UtilityClass
|
||||
public class TypeMappers {
|
||||
@ -48,7 +47,7 @@ public class TypeMappers {
|
||||
private static TypeValidator<ProxiedPlayer> arenaPlayer() {
|
||||
return (sender, value, messageSender) -> {
|
||||
ChatSender player = ChatSender.of(value);
|
||||
if (player.user().isPunishedWithMessage(player, Punishment.PunishmentType.NoFightServer)) {
|
||||
if (PunishmentCommand.isPunishedWithMessage(player, Punishment.PunishmentType.NoFightServer)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -20,8 +20,8 @@
|
||||
package de.steamwar.bungeecore.commands;
|
||||
|
||||
import de.steamwar.bungeecore.Message;
|
||||
import de.steamwar.bungeecore.sql.IgnoreSystem;
|
||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||
import de.steamwar.sql.IgnoreSystem;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
|
||||
|
@ -22,7 +22,7 @@ package de.steamwar.bungeecore.commands;
|
||||
import de.steamwar.bungeecore.BungeeCore;
|
||||
import de.steamwar.bungeecore.Message;
|
||||
import de.steamwar.bungeecore.bot.AuthManager;
|
||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import net.dv8tion.jda.api.entities.Member;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
|
@ -22,10 +22,10 @@ package de.steamwar.bungeecore.commands;
|
||||
import de.steamwar.bungeecore.Message;
|
||||
import de.steamwar.bungeecore.Storage;
|
||||
import de.steamwar.bungeecore.listeners.mods.Utils;
|
||||
import de.steamwar.bungeecore.sql.*;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import de.steamwar.command.SWCommandUtils;
|
||||
import de.steamwar.command.TypeMapper;
|
||||
import de.steamwar.sql.*;
|
||||
import lombok.Getter;
|
||||
import net.md_5.bungee.BungeeCord;
|
||||
import net.md_5.bungee.api.CommandSender;
|
||||
@ -87,7 +87,7 @@ public class WhoisCommand extends SWCommand {
|
||||
if (!userGroup.isTeamGroup()) return;
|
||||
|
||||
if (userGroup.isAdminGroup()) {
|
||||
Message.send("WHOIS_UUID", player, Message.parse("WHOIS_UUID_HOVER", player), new ClickEvent(ClickEvent.Action.COPY_TO_CLIPBOARD, user.getUuid().toString()), user.getUuid().toString());
|
||||
Message.send("WHOIS_UUID", player, Message.parse("WHOIS_UUID_HOVER", player), new ClickEvent(ClickEvent.Action.COPY_TO_CLIPBOARD, user.getUUID().toString()), user.getUUID().toString());
|
||||
Message.send("WHOIS_ID", player, user.getId());
|
||||
if (user.getDiscordId() != null) {
|
||||
Message.send("WHOIS_DISCORD_ID", player, user.getDiscordId());
|
||||
@ -102,20 +102,20 @@ public class WhoisCommand extends SWCommand {
|
||||
}
|
||||
Message.send("WHOIS_HOURS_PLAYED", player, new DecimalFormat("###.##").format(user.getOnlinetime() / 3600d));
|
||||
|
||||
if(BungeeCord.getInstance().getPlayer(user.getUuid()) != null) {
|
||||
ProxiedPlayer target = BungeeCord.getInstance().getPlayer(user.getUuid());
|
||||
if(BungeeCord.getInstance().getPlayer(user.getUUID()) != null) {
|
||||
ProxiedPlayer target = BungeeCord.getInstance().getPlayer(user.getUUID());
|
||||
Message.send("WHOIS_CURRENT_PLAYED", player, new DecimalFormat("####.##").format((Instant.now().getEpochSecond() - Storage.sessions.get(target).toInstant().getEpochSecond()) / 60d));
|
||||
Message.send("WHOIS_CURRENT_SERVER", player, target.getServer().getInfo().getName());
|
||||
Message.send("WHOIS_CURRENT_PROTOCOL", player, target.getPendingConnection().getVersion());
|
||||
}
|
||||
|
||||
if (Utils.playerModMap.containsKey(user.getUuid())) {
|
||||
Mod.Platform modPlatform = Utils.playerModMap.get(user.getUuid()).get(0).getPlatform();
|
||||
if (Utils.playerModMap.containsKey(user.getUUID())) {
|
||||
Mod.Platform modPlatform = Utils.playerModMap.get(user.getUUID()).get(0).getPlatform();
|
||||
Message.send("WHOIS_PLATFORM", player, modPlatform.toString());
|
||||
}
|
||||
|
||||
if (parameterTypes.contains(WhoisParameterTypes.MOD)) {
|
||||
List<Mod> activeMods = Utils.playerModMap.get(user.getUuid());
|
||||
List<Mod> activeMods = Utils.playerModMap.get(user.getUUID());
|
||||
|
||||
if (activeMods != null && !activeMods.isEmpty()) {
|
||||
Message.send("WHOIS_ACTIVE_MODS", player,activeMods.size());
|
||||
|
@ -21,7 +21,7 @@ package de.steamwar.bungeecore.inventory;
|
||||
|
||||
import de.steamwar.bungeecore.network.NetworkSender;
|
||||
import de.steamwar.bungeecore.network.handlers.InventoryCallbackHandler;
|
||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import de.steamwar.network.packets.server.CloseInventoryPacket;
|
||||
import de.steamwar.network.packets.server.InventoryPacket;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
@ -46,7 +46,7 @@ public class SWInventory {
|
||||
|
||||
public SWInventory(ProxiedPlayer proxiedPlayer, int size, String title) {
|
||||
itemMap = new HashMap<>();
|
||||
InventoryCallbackHandler.inventoryHashMap.put(SteamwarUser.get(proxiedPlayer).getId(), this);
|
||||
InventoryCallbackHandler.inventoryHashMap.put(SteamwarUser.get(proxiedPlayer.getUniqueId()).getId(), this);
|
||||
this.player = proxiedPlayer;
|
||||
this.size = size;
|
||||
this.title = title;
|
||||
@ -114,7 +114,7 @@ public class SWInventory {
|
||||
|
||||
public void handleClose() {
|
||||
if(processingClick.compareAndSet(false, true)) {
|
||||
InventoryCallbackHandler.inventoryHashMap.remove(SteamwarUser.get(player).getId(), this);
|
||||
InventoryCallbackHandler.inventoryHashMap.remove(SteamwarUser.get(player.getUniqueId()).getId(), this);
|
||||
if(close != null)
|
||||
close.clicked(null);
|
||||
processingClick.set(false);
|
||||
@ -122,7 +122,7 @@ public class SWInventory {
|
||||
}
|
||||
|
||||
public void open() {
|
||||
InventoryPacket inv = new InventoryPacket(title, SteamwarUser.get(player).getId(), size, map(itemMap, (integer, swItem) -> swItem.writeToString(integer).toString()));
|
||||
InventoryPacket inv = new InventoryPacket(title, SteamwarUser.get(player.getUniqueId()).getId(), size, map(itemMap, (integer, swItem) -> swItem.writeToString(integer).toString()));
|
||||
NetworkSender.send(player, inv);
|
||||
}
|
||||
|
||||
@ -137,7 +137,7 @@ public class SWInventory {
|
||||
}
|
||||
|
||||
public static void close(ProxiedPlayer player) {
|
||||
NetworkSender.send(player, new CloseInventoryPacket(SteamwarUser.get(player).getId()));
|
||||
NetworkSender.send(player, new CloseInventoryPacket(SteamwarUser.get(player.getUniqueId()).getId()));
|
||||
}
|
||||
|
||||
public void setClose(InvCallback close) {
|
||||
|
@ -21,16 +21,19 @@ package de.steamwar.bungeecore.listeners;
|
||||
|
||||
import de.steamwar.bungeecore.BungeeCore;
|
||||
import de.steamwar.bungeecore.Message;
|
||||
import de.steamwar.bungeecore.commands.PunishmentCommand;
|
||||
import de.steamwar.bungeecore.commands.WebpasswordCommand;
|
||||
import de.steamwar.bungeecore.listeners.mods.Forge;
|
||||
import de.steamwar.bungeecore.sql.BannedUserIPs;
|
||||
import de.steamwar.bungeecore.sql.Punishment;
|
||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||
import de.steamwar.sql.BannedUserIPs;
|
||||
import de.steamwar.sql.Punishment;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import de.steamwar.messages.ChatSender;
|
||||
import net.md_5.bungee.api.ProxyServer;
|
||||
import net.md_5.bungee.api.chat.ClickEvent;
|
||||
import net.md_5.bungee.api.chat.ComponentBuilder;
|
||||
import net.md_5.bungee.api.chat.HoverEvent;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
import net.md_5.bungee.api.connection.PendingConnection;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
import net.md_5.bungee.api.event.LoginEvent;
|
||||
import net.md_5.bungee.event.EventHandler;
|
||||
@ -45,16 +48,17 @@ public class BanListener extends BasicListener {
|
||||
public void onLogin(LoginEvent event) {
|
||||
event.registerIntent(BungeeCore.get());
|
||||
ProxyServer.getInstance().getScheduler().runAsync(BungeeCore.get(), () -> {
|
||||
SteamwarUser user = SteamwarUser.getOrCreate(event.getConnection());
|
||||
PendingConnection connection = event.getConnection();
|
||||
SteamwarUser user = SteamwarUser.getOrCreate(connection.getUniqueId(), connection.getName(), ConnectionListener::newPlayer, WebpasswordCommand::changeUsername);
|
||||
if (user.isPunished(Punishment.PunishmentType.Ban)) {
|
||||
user.updateBanIP(event.getConnection().getAddress().getAddress().getHostAddress());
|
||||
event.setCancelled(true);
|
||||
ChatSender.of(event).system(user.punishmentMessage(Punishment.PunishmentType.Ban));
|
||||
BannedUserIPs.banIP(user.getId(), connection.getAddress().getAddress().getHostAddress());
|
||||
ChatSender.of(event).system(PunishmentCommand.punishmentMessage(user, Punishment.PunishmentType.Ban));
|
||||
event.completeIntent(BungeeCore.get());
|
||||
return;
|
||||
}
|
||||
|
||||
List<BannedUserIPs> ips = BannedUserIPs.get(event.getConnection().getAddress().getAddress().getHostAddress());
|
||||
List<BannedUserIPs> ips = BannedUserIPs.get(connection.getAddress().getAddress().getHostAddress());
|
||||
if(!ips.isEmpty()){
|
||||
|
||||
Timestamp highestBan = ips.get(0).getTimestamp();
|
||||
|
@ -21,11 +21,12 @@ package de.steamwar.bungeecore.listeners;
|
||||
|
||||
import de.steamwar.bungeecore.*;
|
||||
import de.steamwar.bungeecore.bot.SteamwarDiscordBot;
|
||||
import de.steamwar.bungeecore.commands.PunishmentCommand;
|
||||
import de.steamwar.bungeecore.network.NetworkSender;
|
||||
import de.steamwar.bungeecore.sql.*;
|
||||
import de.steamwar.bungeecore.util.Chat19;
|
||||
import de.steamwar.messages.ChatSender;
|
||||
import de.steamwar.network.packets.server.PingPacket;
|
||||
import de.steamwar.sql.*;
|
||||
import net.md_5.bungee.api.*;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
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.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.logging.Level;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
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<>();
|
||||
static {
|
||||
coloredTeams.add(12);
|
||||
@ -59,7 +63,9 @@ public class ChatListener extends BasicListener {
|
||||
e.setCancelled(true);
|
||||
|
||||
if (message.contains("jndi:ldap")) {
|
||||
SteamwarUser.get(player).punishPerma(Punishment.PunishmentType.Ban, "Versuchte Exploit-Ausnutzung", 0);
|
||||
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
|
||||
PunishmentCommand.ban(user, Punishment.PERMA_TIME, "Versuchte Exploit-Ausnutzung", SteamwarUser.get(-1), true);
|
||||
BungeeCore.log(Level.SEVERE, user.getUserName() + " " + user.getId() + " wurde automatisch wegen jndi:ldap gebannt.");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -153,7 +159,7 @@ public class ChatListener extends BasicListener {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (user.isPunishedWithMessage(sender, Punishment.PunishmentType.Mute))
|
||||
if (PunishmentCommand.isPunishedWithMessage(sender, Punishment.PunishmentType.Mute))
|
||||
return true;
|
||||
|
||||
if (message.contains("LIXFEL"))
|
||||
@ -171,7 +177,7 @@ public class ChatListener extends BasicListener {
|
||||
msgReceiver == null ? receiver : msgReceiver,
|
||||
highlightMentions(message, group.getChatColorCode(), receiver),
|
||||
sender.getTeam() == 0 ? "" : "§" + Team.get(sender.getTeam()).getTeamColor() + Team.get(sender.getTeam()).getTeamKuerzel() + " ",
|
||||
UserElo.getEmblem(sender),
|
||||
UserElo.getEmblem(sender, rankedModes),
|
||||
group.getColorCode(),
|
||||
group.getChatPrefix().length() == 0 ? "§f" : group.getChatPrefix() + " ",
|
||||
group.getChatColorCode()));
|
||||
@ -202,7 +208,7 @@ public class ChatListener extends BasicListener {
|
||||
String mark = "@" + player.user().getUserName();
|
||||
return Arrays.stream(message.split(" ")).map(cur -> {
|
||||
if(cur.equalsIgnoreCase(mark)) {
|
||||
NetworkSender.send(player.user().getPlayer(), new PingPacket(player.user().getId()));
|
||||
NetworkSender.send(ProxyServer.getInstance().getPlayer(player.user().getUUID()), new PingPacket(player.user().getId()));
|
||||
return "§e" + cur + returnColor;
|
||||
}
|
||||
return cur;
|
||||
|
@ -21,9 +21,9 @@ package de.steamwar.bungeecore.listeners;
|
||||
|
||||
import de.steamwar.bungeecore.*;
|
||||
import de.steamwar.bungeecore.commands.CheckCommand;
|
||||
import de.steamwar.bungeecore.sql.SchematicNode;
|
||||
import de.steamwar.bungeecore.sql.SchematicType;
|
||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||
import de.steamwar.sql.SchematicNode;
|
||||
import de.steamwar.sql.SchematicType;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
import net.md_5.bungee.api.event.PlayerDisconnectEvent;
|
||||
import net.md_5.bungee.api.event.PostLoginEvent;
|
||||
|
@ -30,8 +30,8 @@ import de.steamwar.bungeecore.commands.CheckCommand;
|
||||
import de.steamwar.bungeecore.commands.ModCommand;
|
||||
import de.steamwar.bungeecore.commands.MsgCommand;
|
||||
import de.steamwar.bungeecore.listeners.mods.Utils;
|
||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||
import de.steamwar.bungeecore.sql.UserGroup;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import de.steamwar.sql.UserGroup;
|
||||
import net.md_5.bungee.api.AbstractReconnectHandler;
|
||||
import net.md_5.bungee.api.ProxyServer;
|
||||
import net.md_5.bungee.api.chat.ClickEvent;
|
||||
|
@ -1,10 +1,10 @@
|
||||
package de.steamwar.bungeecore.listeners;
|
||||
|
||||
import de.steamwar.bungeecore.Message;
|
||||
import de.steamwar.bungeecore.sql.Event;
|
||||
import de.steamwar.bungeecore.sql.EventFight;
|
||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||
import de.steamwar.bungeecore.sql.TeamTeilnahme;
|
||||
import de.steamwar.sql.EventFight;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import de.steamwar.sql.TeamTeilnahme;
|
||||
import de.steamwar.sql.Event;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
import net.md_5.bungee.api.event.PostLoginEvent;
|
||||
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<ProxiedPlayer> checking = new HashSet<>();
|
||||
private final Set<ProxiedPlayer> vanilla = new HashSet<>();
|
||||
|
||||
{
|
||||
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))
|
||||
return;
|
||||
|
||||
if(!e.getTag().equals("minecraft:brand"))
|
||||
return;
|
||||
|
||||
if(!new String(e.getData()).equals("vanilla")){
|
||||
ProxiedPlayer p = (ProxiedPlayer) sender;
|
||||
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 (!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;
|
||||
}
|
||||
|
||||
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(), () -> {
|
||||
if (!p.isConnected()) return;
|
||||
@ -82,5 +92,6 @@ public class NonFabricFabricCheck extends BasicListener {
|
||||
if (checking.remove(e.getPlayer())) {
|
||||
usingFabric.add(e.getPlayer().getUniqueId());
|
||||
}
|
||||
vanilla.remove(e.getPlayer());
|
||||
}
|
||||
}
|
||||
|
@ -20,8 +20,8 @@
|
||||
package de.steamwar.bungeecore.listeners;
|
||||
|
||||
import de.steamwar.bungeecore.Message;
|
||||
import de.steamwar.bungeecore.sql.PollAnswer;
|
||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||
import de.steamwar.sql.PollAnswer;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import net.md_5.bungee.api.chat.ClickEvent;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
import net.md_5.bungee.api.event.PostLoginEvent;
|
||||
@ -40,6 +40,8 @@ public class PollSystem extends BasicListener {
|
||||
|
||||
if(noCurrentPoll())
|
||||
return;
|
||||
|
||||
PollAnswer.setCurrentPoll(question);
|
||||
new PollSystem();
|
||||
}
|
||||
|
||||
@ -70,10 +72,6 @@ public class PollSystem extends BasicListener {
|
||||
return question == null || question.equals("");
|
||||
}
|
||||
|
||||
public static String getQuestion() {
|
||||
return question;
|
||||
}
|
||||
|
||||
public static int answers(){
|
||||
return answers.size();
|
||||
}
|
||||
|
@ -20,8 +20,8 @@
|
||||
package de.steamwar.bungeecore.listeners;
|
||||
|
||||
import de.steamwar.bungeecore.BungeeCore;
|
||||
import de.steamwar.bungeecore.sql.Session;
|
||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||
import de.steamwar.sql.Session;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import net.md_5.bungee.api.ProxyServer;
|
||||
import net.md_5.bungee.api.event.PlayerDisconnectEvent;
|
||||
import net.md_5.bungee.api.event.PostLoginEvent;
|
||||
@ -43,7 +43,7 @@ public class SessionManager extends BasicListener {
|
||||
public void onDisconnect(PlayerDisconnectEvent e){
|
||||
Timestamp timestamp = sessions.remove(e.getPlayer());
|
||||
if(timestamp != null) {
|
||||
ProxyServer.getInstance().getScheduler().runAsync(BungeeCore.get(), () -> Session.insertSession(SteamwarUser.get(e.getPlayer()).getId(), timestamp));
|
||||
ProxyServer.getInstance().getScheduler().runAsync(BungeeCore.get(), () -> Session.insertSession(SteamwarUser.get(e.getPlayer().getUniqueId()).getId(), timestamp));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -20,7 +20,9 @@
|
||||
package de.steamwar.bungeecore.listeners;
|
||||
|
||||
import de.steamwar.bungeecore.BungeeCore;
|
||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||
import de.steamwar.bungeecore.network.NetworkSender;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import de.steamwar.network.packets.server.LocaleInvalidationPacket;
|
||||
import net.md_5.bungee.BungeeCord;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
import net.md_5.bungee.api.event.SettingsChangedEvent;
|
||||
@ -32,7 +34,9 @@ public class SettingsChangedListener extends BasicListener {
|
||||
public void onSettingsChanged(SettingsChangedEvent event) {
|
||||
BungeeCord.getInstance().getScheduler().runAsync(BungeeCore.get(), () -> {
|
||||
ProxiedPlayer player = event.getPlayer();
|
||||
SteamwarUser.get(player).setLocale(player.getLocale(), false);
|
||||
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
|
||||
user.setLocale(player.getLocale(), false);
|
||||
NetworkSender.send(player, new LocaleInvalidationPacket(user.getId()));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -27,9 +27,9 @@ import de.steamwar.bungeecore.BungeeCore;
|
||||
import de.steamwar.bungeecore.Message;
|
||||
import de.steamwar.bungeecore.Storage;
|
||||
import de.steamwar.bungeecore.listeners.BasicListener;
|
||||
import de.steamwar.bungeecore.sql.Mod;
|
||||
import de.steamwar.bungeecore.sql.SWException;
|
||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||
import de.steamwar.sql.Mod;
|
||||
import de.steamwar.sql.SWException;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import net.md_5.bungee.BungeeCord;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
import net.md_5.bungee.api.event.PluginMessageEvent;
|
||||
@ -58,7 +58,7 @@ public class Fabric extends BasicListener {
|
||||
continue;
|
||||
}
|
||||
if (System.currentTimeMillis() - entry.getValue() > TimeUnit.SECONDS.toMillis(20)) {
|
||||
logMessage(SteamwarUser.get(entry.getKey()), "Expected message not received", String.valueOf(entry.getValue()));
|
||||
logMessage(SteamwarUser.get(entry.getKey().getUniqueId()), "Expected message not received", String.valueOf(entry.getValue()));
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -156,7 +156,7 @@ public class Fabric extends BasicListener {
|
||||
}
|
||||
|
||||
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) {
|
||||
|
@ -21,7 +21,7 @@ package de.steamwar.bungeecore.listeners.mods;
|
||||
|
||||
import de.steamwar.bungeecore.BungeeCore;
|
||||
import de.steamwar.bungeecore.listeners.BasicListener;
|
||||
import de.steamwar.bungeecore.sql.Mod;
|
||||
import de.steamwar.sql.Mod;
|
||||
import io.netty.channel.ChannelPipeline;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
import net.md_5.bungee.api.connection.PendingConnection;
|
||||
|
@ -21,7 +21,7 @@ package de.steamwar.bungeecore.listeners.mods;
|
||||
|
||||
import de.steamwar.bungeecore.BungeeCore;
|
||||
import de.steamwar.bungeecore.listeners.BasicListener;
|
||||
import de.steamwar.bungeecore.sql.Mod;
|
||||
import de.steamwar.sql.Mod;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.UnpooledByteBufAllocator;
|
||||
import net.md_5.bungee.api.ProxyServer;
|
||||
|
@ -23,7 +23,7 @@ import com.google.gson.JsonObject;
|
||||
import com.google.gson.stream.JsonReader;
|
||||
import de.steamwar.bungeecore.BungeeCore;
|
||||
import de.steamwar.bungeecore.listeners.BasicListener;
|
||||
import de.steamwar.bungeecore.sql.Mod;
|
||||
import de.steamwar.sql.Mod;
|
||||
import net.md_5.bungee.api.ProxyServer;
|
||||
import net.md_5.bungee.api.connection.Connection;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
|
@ -21,11 +21,11 @@ package de.steamwar.bungeecore.listeners.mods;
|
||||
|
||||
import de.steamwar.bungeecore.BungeeCore;
|
||||
import de.steamwar.bungeecore.Message;
|
||||
import de.steamwar.bungeecore.sql.Mod;
|
||||
import de.steamwar.bungeecore.sql.Mod.ModType;
|
||||
import de.steamwar.bungeecore.sql.Punishment;
|
||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||
import de.steamwar.bungeecore.commands.PunishmentCommand;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import de.steamwar.messages.ChatSender;
|
||||
import de.steamwar.sql.Mod;
|
||||
import de.steamwar.sql.Mod.ModType;
|
||||
import net.md_5.bungee.api.chat.BaseComponent;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
@ -68,7 +68,7 @@ public class Utils {
|
||||
|
||||
static boolean handleMods(UUID uuid, Locale locale, Consumer<BaseComponent[]> disconnect, List<Mod> mods){
|
||||
SteamwarUser user = SteamwarUser.get(uuid);
|
||||
boolean privileged = user.getUserGroup().privilegedMods();
|
||||
boolean privileged = user.getUserGroup().isPrivilegedMods();
|
||||
playerModMap.put(uuid,new ArrayList<>(mods));
|
||||
|
||||
ModType max = ModType.YELLOW;
|
||||
@ -97,7 +97,7 @@ public class Utils {
|
||||
}
|
||||
|
||||
if(max == ModType.RED) {
|
||||
user.punish(Punishment.PunishmentType.Ban, Timestamp.from(Instant.now().plus(7, ChronoUnit.DAYS)), message, 0, false);
|
||||
PunishmentCommand.ban(user, Timestamp.from(Instant.now().plus(7, ChronoUnit.DAYS)), message, SteamwarUser.get(-1), false);
|
||||
BungeeCore.log(Level.SEVERE, user.getUserName() + " " + user.getId() + " wurde automatisch wegen der Mods " + modList + " gebannt.");
|
||||
}
|
||||
|
||||
|
@ -3,7 +3,7 @@ package de.steamwar.bungeecore.listeners.mods;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Sets;
|
||||
import de.steamwar.bungeecore.listeners.BasicListener;
|
||||
import de.steamwar.bungeecore.sql.Mod;
|
||||
import de.steamwar.sql.Mod;
|
||||
import net.md_5.bungee.api.connection.Connection;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
import net.md_5.bungee.api.event.PluginMessageEvent;
|
||||
|
@ -22,7 +22,7 @@ package de.steamwar.bungeecore.network;
|
||||
import de.steamwar.bungeecore.BungeeCore;
|
||||
import de.steamwar.bungeecore.commands.TeamCommand;
|
||||
import de.steamwar.bungeecore.listeners.BasicListener;
|
||||
import de.steamwar.bungeecore.sql.SWException;
|
||||
import de.steamwar.sql.SWException;
|
||||
import de.steamwar.network.packets.NetworkPacket;
|
||||
import net.md_5.bungee.api.ProxyServer;
|
||||
import net.md_5.bungee.api.connection.Server;
|
||||
@ -42,7 +42,7 @@ public class NetworkReceiver extends BasicListener {
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void onPluginMessage(PluginMessageEvent event) {
|
||||
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);
|
||||
return;
|
||||
}
|
||||
|
@ -19,7 +19,7 @@
|
||||
|
||||
package de.steamwar.bungeecore.network.handlers;
|
||||
|
||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import de.steamwar.network.packets.PacketHandler;
|
||||
import de.steamwar.network.packets.client.ExecuteCommandPacket;
|
||||
import net.md_5.bungee.api.ProxyServer;
|
||||
@ -31,6 +31,6 @@ public class ExecuteCommandHandler extends PacketHandler {
|
||||
SteamwarUser target = SteamwarUser.get(packet.getPlayerId());
|
||||
String command = packet.getCommand();
|
||||
|
||||
ProxyServer.getInstance().getPluginManager().dispatchCommand(ProxyServer.getInstance().getPlayer(target.getUuid()), command);
|
||||
ProxyServer.getInstance().getPluginManager().dispatchCommand(ProxyServer.getInstance().getPlayer(target.getUUID()), command);
|
||||
}
|
||||
}
|
||||
|
@ -20,9 +20,9 @@
|
||||
package de.steamwar.bungeecore.network.handlers;
|
||||
|
||||
import de.steamwar.bungeecore.ArenaMode;
|
||||
import de.steamwar.bungeecore.sql.*;
|
||||
import de.steamwar.network.packets.PacketHandler;
|
||||
import de.steamwar.network.packets.common.FightEndsPacket;
|
||||
import de.steamwar.sql.*;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
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()));
|
||||
}
|
||||
|
||||
int blueSchemElo = SchemElo.getElo(fightEndsPacket.getBlueSchem());
|
||||
int redSchemElo = SchemElo.getElo(fightEndsPacket.getRedSchem());
|
||||
int blueSchemElo = SchemElo.getCurrentElo(fightEndsPacket.getBlueSchem());
|
||||
int redSchemElo = SchemElo.getCurrentElo(fightEndsPacket.getRedSchem());
|
||||
|
||||
int blueTeamElo = fightEndsPacket.getBluePlayers().stream().mapToInt(player -> UserElo.getEloOrDefault(player, fightEndsPacket.getGameMode())).sum();
|
||||
int redTeamElo = fightEndsPacket.getRedPlayers().stream().mapToInt(player -> UserElo.getEloOrDefault(player, fightEndsPacket.getGameMode())).sum();
|
||||
|
@ -22,15 +22,13 @@ package de.steamwar.bungeecore.network.handlers;
|
||||
import de.steamwar.bungeecore.BungeeCore;
|
||||
import de.steamwar.bungeecore.inventory.InvCallback;
|
||||
import de.steamwar.bungeecore.inventory.SWInventory;
|
||||
import de.steamwar.bungeecore.network.NetworkReceiver;
|
||||
import de.steamwar.bungeecore.network.NetworkSender;
|
||||
import de.steamwar.bungeecore.network.ServerMetaInfo;
|
||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import de.steamwar.network.packets.PacketHandler;
|
||||
import de.steamwar.network.packets.client.InventoryCallbackPacket;
|
||||
import de.steamwar.network.packets.server.CloseInventoryPacket;
|
||||
import net.md_5.bungee.api.ProxyServer;
|
||||
import net.md_5.bungee.api.config.ServerInfo;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
@ -44,7 +42,7 @@ public class InventoryCallbackHandler extends PacketHandler {
|
||||
SteamwarUser owner = SteamwarUser.get(packet.getOwner());
|
||||
InventoryCallbackPacket.CallbackType type = packet.getType();
|
||||
if(!inventoryHashMap.containsKey(owner.getId())) {
|
||||
BungeeCore.send(ProxyServer.getInstance().getPlayer(owner.getUuid()), BungeeCore.CHAT_PREFIX + "§cBitte erneut versuchen. Durch ein Softwareupdate konnte die übliche Aktion nicht durchgeführt werden.");
|
||||
BungeeCore.send(ProxyServer.getInstance().getPlayer(owner.getUUID()), BungeeCore.CHAT_PREFIX + "§cBitte erneut versuchen. Durch ein Softwareupdate konnte die übliche Aktion nicht durchgeführt werden.");
|
||||
if(type == InventoryCallbackPacket.CallbackType.CLICK) {
|
||||
NetworkSender.send(((ServerMetaInfo) packet.getMetaInfos()).getSender(), new CloseInventoryPacket(owner.getId()));
|
||||
}
|
||||
|
@ -21,8 +21,8 @@ package de.steamwar.bungeecore.network.handlers;
|
||||
|
||||
import de.steamwar.bungeecore.ArenaMode;
|
||||
import de.steamwar.bungeecore.ServerStarter;
|
||||
import de.steamwar.bungeecore.sql.SchematicType;
|
||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||
import de.steamwar.sql.SchematicType;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import de.steamwar.network.packets.PacketHandler;
|
||||
import de.steamwar.network.packets.client.PrepareSchemPacket;
|
||||
import net.md_5.bungee.api.ProxyServer;
|
||||
@ -32,7 +32,7 @@ public class PrepareSchemHandler extends PacketHandler {
|
||||
|
||||
@Handler
|
||||
public void handle(PrepareSchemPacket packet) {
|
||||
ProxiedPlayer player = ProxyServer.getInstance().getPlayer(SteamwarUser.get(packet.getPlayer()).getUuid());
|
||||
ProxiedPlayer player = ProxyServer.getInstance().getPlayer(SteamwarUser.get(packet.getPlayer()).getUUID());
|
||||
int schematicID = packet.getSchem();
|
||||
ArenaMode mode = ArenaMode.getBySchemType(SchematicType.fromDB(packet.getSchemType()));
|
||||
|
||||
|
@ -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,502 +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, 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, 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, LastUpdate FROM SchematicNode WHERE ParentNode is NULL");
|
||||
private static final Statement getSchematicsInNode = new Statement("SELECT NodeId, NodeName, NodeOwner, ParentNode, NodeType, NodeItem, NodeRank, LastUpdate FROM SchematicNode WHERE ParentNode = ?");
|
||||
private static final Statement getDirsInNode_Null = new Statement("SELECT NodeId, NodeName, NodeOwner, ParentNode, NodeType, NodeItem, NodeRank, 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, 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, LastUpdate FROM SchematicNode WHERE NodeName = ? AND ParentNode is NULL");
|
||||
private static final Statement getSchematicDirectory = new Statement("SELECT NodeId, NodeName, NodeOwner, ParentNode, NodeType, NodeItem, NodeRank, LastUpdate FROM SchematicNode WHERE NodeName = ? AND ParentNode = ?");
|
||||
private static final Statement getSchematicNodeO_Null = new Statement("SELECT NodeId, NodeName, NodeOwner, ParentNode, NodeType, NodeItem, NodeRank, LastUpdate FROM SchematicNode WHERE NodeName = ? AND ParentNode is NULL");
|
||||
private static final Statement getSchematicNodeO = new Statement("SELECT NodeId, NodeName, NodeOwner, ParentNode, NodeType, NodeItem, NodeRank, LastUpdate FROM SchematicNode WHERE NodeName = ? AND ParentNode = ?");
|
||||
private static final Statement getSchematicNodeId = new Statement("SELECT NodeId, NodeName, NodeOwner, ParentNode, NodeType, NodeItem, NodeRank, LastUpdate FROM SchematicNode WHERE NodeId = ?");
|
||||
private static final Statement getAllSchemsOfTypeOwner = new Statement("SELECT NodeId, NodeName, NodeOwner, ParentNode, NodeType, NodeItem, NodeRank, LastUpdate FROM SchematicNode WHERE NodeOwner = ? AND NodeType = ?");
|
||||
private static final Statement getAllSchemsOfType = new Statement("SELECT NodeId, NodeName, NodeOwner, ParentNode, NodeType, NodeItem, NodeRank, 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.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.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.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.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.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.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.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.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.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.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.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, LastUpdate FROM SchematicNode WHERE NodeId = ? union select SN.NodeId, SN.NodeName, SN.NodeOwner, SN.ParentNode, SN.NodeType, SN.NodeItem, SN.NodeRank, 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, LastUpdate FROM SchematicNode WHERE NodeId = ? UNION SELECT SN.NodeId, SN.NodeName, SN.NodeOwner, SN.ParentNode, SN.NodeType, SN.NodeItem, SN.NodeRank, 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 NodeData SET SchemData = ?, NodeFormat = ? WHERE NodeId = ?");
|
||||
private static final Statement selSchemData = new Statement("SELECT SchemData FROM NodeData 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");
|
||||
} 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 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;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public boolean getSchemFormat() {
|
||||
if(isDir)
|
||||
throw new SecurityException("Node is Directory");
|
||||
return true;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
Einige Dateien werden nicht angezeigt, da zu viele Dateien in diesem Diff geändert wurden Mehr anzeigen
In neuem Issue referenzieren
Einen Benutzer sperren