diff --git a/CommonCore b/CommonCore
index aa70f42..b2b96cf 160000
--- a/CommonCore
+++ b/CommonCore
@@ -1 +1 @@
-Subproject commit aa70f423d87e9f6534ad2dd1f20a5122179c423f
+Subproject commit b2b96cff0477dc3078c1abfd8f8b047e3a6d903d
diff --git a/src/de/steamwar/bungeecore/ArenaMode.java b/src/de/steamwar/bungeecore/ArenaMode.java
index abb6b77..d33aeeb 100644
--- a/src/de/steamwar/bungeecore/ArenaMode.java
+++ b/src/de/steamwar/bungeecore/ArenaMode.java
@@ -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;
diff --git a/src/de/steamwar/bungeecore/BungeeCore.java b/src/de/steamwar/bungeecore/BungeeCore.java
index ea959b7..4070bd7 100644
--- a/src/de/steamwar/bungeecore/BungeeCore.java
+++ b/src/de/steamwar/bungeecore/BungeeCore.java
@@ -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) {
diff --git a/src/de/steamwar/bungeecore/ErrorLogger.java b/src/de/steamwar/bungeecore/ErrorLogger.java
index d1af128..279a627 100644
--- a/src/de/steamwar/bungeecore/ErrorLogger.java
+++ b/src/de/steamwar/bungeecore/ErrorLogger.java
@@ -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
diff --git a/src/de/steamwar/bungeecore/EventStarter.java b/src/de/steamwar/bungeecore/EventStarter.java
index 0de5667..ddf78bd 100644
--- a/src/de/steamwar/bungeecore/EventStarter.java
+++ b/src/de/steamwar/bungeecore/EventStarter.java
@@ -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);
diff --git a/src/de/steamwar/bungeecore/ServerStarter.java b/src/de/steamwar/bungeecore/ServerStarter.java
index 9373b57..48aa65a 100644
--- a/src/de/steamwar/bungeecore/ServerStarter.java
+++ b/src/de/steamwar/bungeecore/ServerStarter.java
@@ -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);
}
diff --git a/src/de/steamwar/bungeecore/SubserverSystem.java b/src/de/steamwar/bungeecore/SubserverSystem.java
index 9842154..71b5809 100644
--- a/src/de/steamwar/bungeecore/SubserverSystem.java
+++ b/src/de/steamwar/bungeecore/SubserverSystem.java
@@ -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;
}
diff --git a/src/de/steamwar/bungeecore/bot/AuthManager.java b/src/de/steamwar/bungeecore/bot/AuthManager.java
index 948c35c..7423d8d 100644
--- a/src/de/steamwar/bungeecore/bot/AuthManager.java
+++ b/src/de/steamwar/bungeecore/bot/AuthManager.java
@@ -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.entities.Member;
import net.dv8tion.jda.api.entities.emoji.Emoji;
import net.dv8tion.jda.api.interactions.components.ActionRow;
diff --git a/src/de/steamwar/bungeecore/bot/SteamwarDiscordBot.java b/src/de/steamwar/bungeecore/bot/SteamwarDiscordBot.java
index cfa552f..0900437 100644
--- a/src/de/steamwar/bungeecore/bot/SteamwarDiscordBot.java
+++ b/src/de/steamwar/bungeecore/bot/SteamwarDiscordBot.java
@@ -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;
diff --git a/src/de/steamwar/bungeecore/bot/commands/BanCommand.java b/src/de/steamwar/bungeecore/bot/commands/BanCommand.java
index 7acf722..01f3020 100644
--- a/src/de/steamwar/bungeecore/bot/commands/BanCommand.java
+++ b/src/de/steamwar/bungeecore/bot/commands/BanCommand.java
@@ -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.command.SlashCommandInteractionEvent;
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();
}
diff --git a/src/de/steamwar/bungeecore/bot/commands/BasicDiscordCommand.java b/src/de/steamwar/bungeecore/bot/commands/BasicDiscordCommand.java
index a82e6e3..d140739 100644
--- a/src/de/steamwar/bungeecore/bot/commands/BasicDiscordCommand.java
+++ b/src/de/steamwar/bungeecore/bot/commands/BasicDiscordCommand.java
@@ -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.command.SlashCommandInteractionEvent;
import net.dv8tion.jda.api.hooks.ListenerAdapter;
diff --git a/src/de/steamwar/bungeecore/bot/commands/MuteCommand.java b/src/de/steamwar/bungeecore/bot/commands/MuteCommand.java
index 792ea4a..ff5d295 100644
--- a/src/de/steamwar/bungeecore/bot/commands/MuteCommand.java
+++ b/src/de/steamwar/bungeecore/bot/commands/MuteCommand.java
@@ -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.command.SlashCommandInteractionEvent;
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;
diff --git a/src/de/steamwar/bungeecore/bot/commands/TeamCommand.java b/src/de/steamwar/bungeecore/bot/commands/TeamCommand.java
index 2199123..26fc652 100644
--- a/src/de/steamwar/bungeecore/bot/commands/TeamCommand.java
+++ b/src/de/steamwar/bungeecore/bot/commands/TeamCommand.java
@@ -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.Emoji;
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent;
@@ -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;
}
}
diff --git a/src/de/steamwar/bungeecore/bot/commands/UnbanCommand.java b/src/de/steamwar/bungeecore/bot/commands/UnbanCommand.java
index 4ffba5d..20f310e 100644
--- a/src/de/steamwar/bungeecore/bot/commands/UnbanCommand.java
+++ b/src/de/steamwar/bungeecore/bot/commands/UnbanCommand.java
@@ -19,8 +19,9 @@
package de.steamwar.bungeecore.bot.commands;
-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 net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent;
import net.dv8tion.jda.api.interactions.commands.OptionType;
@@ -42,7 +43,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 +55,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();
}
}
diff --git a/src/de/steamwar/bungeecore/bot/commands/WhoisCommand.java b/src/de/steamwar/bungeecore/bot/commands/WhoisCommand.java
index 3df56ff..53ca7f2 100644
--- a/src/de/steamwar/bungeecore/bot/commands/WhoisCommand.java
+++ b/src/de/steamwar/bungeecore/bot/commands/WhoisCommand.java
@@ -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.command.SlashCommandInteractionEvent;
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");
diff --git a/src/de/steamwar/bungeecore/bot/config/SteamwarDiscordBotConfig.java b/src/de/steamwar/bungeecore/bot/config/SteamwarDiscordBotConfig.java
index 34c65e8..844d1e2 100644
--- a/src/de/steamwar/bungeecore/bot/config/SteamwarDiscordBotConfig.java
+++ b/src/de/steamwar/bungeecore/bot/config/SteamwarDiscordBotConfig.java
@@ -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;
diff --git a/src/de/steamwar/bungeecore/bot/events/EventManager.java b/src/de/steamwar/bungeecore/bot/events/EventManager.java
index d0e3544..5d877bd 100644
--- a/src/de/steamwar/bungeecore/bot/events/EventManager.java
+++ b/src/de/steamwar/bungeecore/bot/events/EventManager.java
@@ -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.entities.Message;
diff --git a/src/de/steamwar/bungeecore/bot/events/SchematicsManager.java b/src/de/steamwar/bungeecore/bot/events/SchematicsManager.java
index da158f1..4fd80a9 100644
--- a/src/de/steamwar/bungeecore/bot/events/SchematicsManager.java
+++ b/src/de/steamwar/bungeecore/bot/events/SchematicsManager.java
@@ -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.entities.Message;
diff --git a/src/de/steamwar/bungeecore/bot/listeners/DiscordAuthListener.java b/src/de/steamwar/bungeecore/bot/listeners/DiscordAuthListener.java
index 3d85caa..801a3b7 100644
--- a/src/de/steamwar/bungeecore/bot/listeners/DiscordAuthListener.java
+++ b/src/de/steamwar/bungeecore/bot/listeners/DiscordAuthListener.java
@@ -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.channel.ChannelType;
import net.dv8tion.jda.api.events.interaction.component.GenericComponentInteractionCreateEvent;
import net.dv8tion.jda.api.interactions.InteractionType;
diff --git a/src/de/steamwar/bungeecore/bot/listeners/DiscordChatListener.java b/src/de/steamwar/bungeecore/bot/listeners/DiscordChatListener.java
index 47d6bb6..4c20f94 100644
--- a/src/de/steamwar/bungeecore/bot/listeners/DiscordChatListener.java
+++ b/src/de/steamwar/bungeecore/bot/listeners/DiscordChatListener.java
@@ -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.entities.Member;
import net.dv8tion.jda.api.entities.channel.concrete.TextChannel;
diff --git a/src/de/steamwar/bungeecore/bot/listeners/DiscordEventListener.java b/src/de/steamwar/bungeecore/bot/listeners/DiscordEventListener.java
index 031ae4d..3bd9bf7 100644
--- a/src/de/steamwar/bungeecore/bot/listeners/DiscordEventListener.java
+++ b/src/de/steamwar/bungeecore/bot/listeners/DiscordEventListener.java
@@ -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.component.StringSelectInteractionEvent;
import net.dv8tion.jda.api.interactions.components.Component;
import org.jetbrains.annotations.NotNull;
diff --git a/src/de/steamwar/bungeecore/bot/listeners/DiscordTicketListener.java b/src/de/steamwar/bungeecore/bot/listeners/DiscordTicketListener.java
index 1f0a941..63bfce2 100644
--- a/src/de/steamwar/bungeecore/bot/listeners/DiscordTicketListener.java
+++ b/src/de/steamwar/bungeecore/bot/listeners/DiscordTicketListener.java
@@ -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.Permission;
import net.dv8tion.jda.api.entities.*;
@@ -144,7 +144,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();
diff --git a/src/de/steamwar/bungeecore/bot/listeners/PrivateMessageListener.java b/src/de/steamwar/bungeecore/bot/listeners/PrivateMessageListener.java
index fbad3c0..6a9b1ca 100644
--- a/src/de/steamwar/bungeecore/bot/listeners/PrivateMessageListener.java
+++ b/src/de/steamwar/bungeecore/bot/listeners/PrivateMessageListener.java
@@ -19,9 +19,10 @@
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.entities.channel.ChannelType;
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
@@ -72,7 +73,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) {
diff --git a/src/de/steamwar/bungeecore/bot/util/DiscordRanks.java b/src/de/steamwar/bungeecore/bot/util/DiscordRanks.java
index 7224576..e9ec857 100644
--- a/src/de/steamwar/bungeecore/bot/util/DiscordRanks.java
+++ b/src/de/steamwar/bungeecore/bot/util/DiscordRanks.java
@@ -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;
diff --git a/src/de/steamwar/bungeecore/bot/util/DiscordSchemAlert.java b/src/de/steamwar/bungeecore/bot/util/DiscordSchemAlert.java
index d1cb559..fe779c0 100644
--- a/src/de/steamwar/bungeecore/bot/util/DiscordSchemAlert.java
+++ b/src/de/steamwar/bungeecore/bot/util/DiscordSchemAlert.java
@@ -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.entities.User;
diff --git a/src/de/steamwar/bungeecore/commands/BasicCommand.java b/src/de/steamwar/bungeecore/commands/BasicCommand.java
deleted file mode 100644
index d4b9c0a..0000000
--- a/src/de/steamwar/bungeecore/commands/BasicCommand.java
+++ /dev/null
@@ -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 .
-*/
-
-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 allPlayers(String begin) {
- List suggestions = new ArrayList<>();
- for(ProxiedPlayer player : ProxyServer.getInstance().getPlayers()){
- String playerName = player.getName();
- if(playerName.startsWith(begin))
- suggestions.add(playerName);
- }
- return suggestions;
- }
-
- public Iterable 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;
- }
-}
diff --git a/src/de/steamwar/bungeecore/commands/BauCommand.java b/src/de/steamwar/bungeecore/commands/BauCommand.java
index 06dc3bc..1ecc809 100644
--- a/src/de/steamwar/bungeecore/commands/BauCommand.java
+++ b/src/de/steamwar/bungeecore/commands/BauCommand.java
@@ -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)
diff --git a/src/de/steamwar/bungeecore/commands/BugCommand.java b/src/de/steamwar/bungeecore/commands/BugCommand.java
index 9648423..f93e23d 100644
--- a/src/de/steamwar/bungeecore/commands/BugCommand.java
+++ b/src/de/steamwar/bungeecore/commands/BugCommand.java
@@ -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");
}
}
diff --git a/src/de/steamwar/bungeecore/commands/CalendarCommand.java b/src/de/steamwar/bungeecore/commands/CalendarCommand.java
index 5d203db..b1d3c9f 100644
--- a/src/de/steamwar/bungeecore/commands/CalendarCommand.java
+++ b/src/de/steamwar/bungeecore/commands/CalendarCommand.java
@@ -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;
diff --git a/src/de/steamwar/bungeecore/commands/ChallengeCommand.java b/src/de/steamwar/bungeecore/commands/ChallengeCommand.java
index 6f050ac..51bfa43 100644
--- a/src/de/steamwar/bungeecore/commands/ChallengeCommand.java
+++ b/src/de/steamwar/bungeecore/commands/ChallengeCommand.java
@@ -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;
}
diff --git a/src/de/steamwar/bungeecore/commands/CheckCommand.java b/src/de/steamwar/bungeecore/commands/CheckCommand.java
index 061b254..b2aee64 100644
--- a/src/de/steamwar/bungeecore/commands/CheckCommand.java
+++ b/src/de/steamwar/bungeecore/commands/CheckCommand.java
@@ -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 fightTypes = new HashMap<>();
private static Map> checkQuestions = new HashMap<>();
private static Map> 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 {
diff --git a/src/de/steamwar/bungeecore/commands/DevCommand.java b/src/de/steamwar/bungeecore/commands/DevCommand.java
index 5858a49..834f96d 100644
--- a/src/de/steamwar/bungeecore/commands/DevCommand.java
+++ b/src/de/steamwar/bungeecore/commands/DevCommand.java
@@ -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 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;
}
diff --git a/src/de/steamwar/bungeecore/commands/EventCommand.java b/src/de/steamwar/bungeecore/commands/EventCommand.java
index 75f718f..9ea7c9b 100644
--- a/src/de/steamwar/bungeecore/commands/EventCommand.java
+++ b/src/de/steamwar/bungeecore/commands/EventCommand.java
@@ -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 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 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 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 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()));
+ }
}
diff --git a/src/de/steamwar/bungeecore/commands/EventRescheduleCommand.java b/src/de/steamwar/bungeecore/commands/EventRescheduleCommand.java
index 4a95e46..13e8f59 100644
--- a/src/de/steamwar/bungeecore/commands/EventRescheduleCommand.java
+++ b/src/de/steamwar/bungeecore/commands/EventRescheduleCommand.java
@@ -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;
diff --git a/src/de/steamwar/bungeecore/commands/EventreloadCommand.java b/src/de/steamwar/bungeecore/commands/EventreloadCommand.java
index 9d5008a..1c3d173 100644
--- a/src/de/steamwar/bungeecore/commands/EventreloadCommand.java
+++ b/src/de/steamwar/bungeecore/commands/EventreloadCommand.java
@@ -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;
diff --git a/src/de/steamwar/bungeecore/commands/FightCommand.java b/src/de/steamwar/bungeecore/commands/FightCommand.java
index 5911db5..e5cf3e4 100644
--- a/src/de/steamwar/bungeecore/commands/FightCommand.java
+++ b/src/de/steamwar/bungeecore/commands/FightCommand.java
@@ -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;
diff --git a/src/de/steamwar/bungeecore/commands/GDPRQuery.java b/src/de/steamwar/bungeecore/commands/GDPRQuery.java
index 25e37fa..0158edf 100644
--- a/src/de/steamwar/bungeecore/commands/GDPRQuery.java
+++ b/src/de/steamwar/bungeecore/commands/GDPRQuery.java
@@ -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");
}
}
diff --git a/src/de/steamwar/bungeecore/commands/HelpCommand.java b/src/de/steamwar/bungeecore/commands/HelpCommand.java
index d3fb3fe..7da1ba7 100644
--- a/src/de/steamwar/bungeecore/commands/HelpCommand.java
+++ b/src/de/steamwar/bungeecore/commands/HelpCommand.java
@@ -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 ",
diff --git a/src/de/steamwar/bungeecore/commands/IgnoreCommand.java b/src/de/steamwar/bungeecore/commands/IgnoreCommand.java
index 0c11ee0..e52e35f 100644
--- a/src/de/steamwar/bungeecore/commands/IgnoreCommand.java
+++ b/src/de/steamwar/bungeecore/commands/IgnoreCommand.java
@@ -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;
diff --git a/src/de/steamwar/bungeecore/commands/JoinmeCommand.java b/src/de/steamwar/bungeecore/commands/JoinmeCommand.java
index e897ba0..073fc80 100644
--- a/src/de/steamwar/bungeecore/commands/JoinmeCommand.java
+++ b/src/de/steamwar/bungeecore/commands/JoinmeCommand.java
@@ -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 onTabComplete(CommandSender commandSender, String[] args) {
- if(args.length == 1){
- return allPlayers(args[0]);
- }
- return new ArrayList<>();
+ @ClassValidator(ProxiedPlayer.class)
+ public TypeValidator playerMapper() {
+ return (sender, value, messageSender) -> {
+ if (value == null || !value.isConnected()) {
+ messageSender.send("JOINME_PLAYER_OFFLINE", sender);
+ return false;
+ }
+ return true;
+ };
}
}
diff --git a/src/de/steamwar/bungeecore/commands/ModCommand.java b/src/de/steamwar/bungeecore/commands/ModCommand.java
index f5b4c66..ed6bbd7 100644
--- a/src/de/steamwar/bungeecore/commands/ModCommand.java
+++ b/src/de/steamwar/bungeecore/commands/ModCommand.java
@@ -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 playerFilterType = new HashMap<>();
+ public static final Map playerFilterType = new HashMap<>();
@Register
public void genericCommand(ProxiedPlayer p) {
diff --git a/src/de/steamwar/bungeecore/commands/MsgCommand.java b/src/de/steamwar/bungeecore/commands/MsgCommand.java
index 8dd8e50..9bd550c 100644
--- a/src/de/steamwar/bungeecore/commands/MsgCommand.java
+++ b/src/de/steamwar/bungeecore/commands/MsgCommand.java
@@ -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;
}
diff --git a/src/de/steamwar/bungeecore/commands/PlaytimeCommand.java b/src/de/steamwar/bungeecore/commands/PlaytimeCommand.java
index c9c3850..c483ec9 100644
--- a/src/de/steamwar/bungeecore/commands/PlaytimeCommand.java
+++ b/src/de/steamwar/bungeecore/commands/PlaytimeCommand.java
@@ -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);
}
diff --git a/src/de/steamwar/bungeecore/commands/PollCommand.java b/src/de/steamwar/bungeecore/commands/PollCommand.java
index 5e179cd..6cae84d 100644
--- a/src/de/steamwar/bungeecore/commands/PollCommand.java
+++ b/src/de/steamwar/bungeecore/commands/PollCommand.java
@@ -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;
diff --git a/src/de/steamwar/bungeecore/commands/PollresultCommand.java b/src/de/steamwar/bungeecore/commands/PollresultCommand.java
index 554efcc..4951771 100644
--- a/src/de/steamwar/bungeecore/commands/PollresultCommand.java
+++ b/src/de/steamwar/bungeecore/commands/PollresultCommand.java
@@ -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 voted = PollAnswer.getCurrentResults();
- Message.send("POLLRESULT_HEADER", player, voted.values().stream().reduce(Integer::sum).orElse(0), PollSystem.getQuestion());
- for (Map.Entry e: voted.entrySet()) {
- Message.send("POLLRESULT_LIST", player, e.getKey(), e.getValue());
+ Map voted = PollAnswer.getCurrentResults();
+ Message.send("POLLRESULT_HEADER", player, voted.values().stream().reduce(Integer::sum).orElse(0), PollAnswer.getCurrentPoll());
+ for (Map.Entry e: voted.entrySet()) {
+ Message.send("POLLRESULT_LIST", player, PollSystem.getAnswer(e.getKey()), e.getValue());
}
}
diff --git a/src/de/steamwar/bungeecore/commands/PunishmentCommand.java b/src/de/steamwar/bungeecore/commands/PunishmentCommand.java
index 62e9831..23ba5f2 100644
--- a/src/de/steamwar/bungeecore/commands/PunishmentCommand.java
+++ b/src/de/steamwar/bungeecore/commands/PunishmentCommand.java
@@ -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;
diff --git a/src/de/steamwar/bungeecore/commands/RankCommand.java b/src/de/steamwar/bungeecore/commands/RankCommand.java
index eca5518..b009872 100644
--- a/src/de/steamwar/bungeecore/commands/RankCommand.java
+++ b/src/de/steamwar/bungeecore/commands/RankCommand.java
@@ -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 playerTypeMapper() {
return SWCommandUtils.createMapper(s -> s, s -> BungeeCord.getInstance().getPlayers().stream().map(ProxiedPlayer::getName).collect(Collectors.toList()));
diff --git a/src/de/steamwar/bungeecore/commands/ReplayCommand.java b/src/de/steamwar/bungeecore/commands/ReplayCommand.java
index 1130108..e318938 100644
--- a/src/de/steamwar/bungeecore/commands/ReplayCommand.java
+++ b/src/de/steamwar/bungeecore/commands/ReplayCommand.java
@@ -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();
diff --git a/src/de/steamwar/bungeecore/commands/SetLocaleCommand.java b/src/de/steamwar/bungeecore/commands/SetLocaleCommand.java
index 798a58c..d02c53c 100644
--- a/src/de/steamwar/bungeecore/commands/SetLocaleCommand.java
+++ b/src/de/steamwar/bungeecore/commands/SetLocaleCommand.java
@@ -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");
}
}
diff --git a/src/de/steamwar/bungeecore/commands/TeamCommand.java b/src/de/steamwar/bungeecore/commands/TeamCommand.java
index 9ae3799..95d308e 100644
--- a/src/de/steamwar/bungeecore/commands/TeamCommand.java
+++ b/src/de/steamwar/bungeecore/commands/TeamCommand.java
@@ -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> 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 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 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 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 eventTypeMapper() {
+ return new TypeMapper() {
+ @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 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 onTabComplete(CommandSender commandSender, String[] args){
- List 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 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 teams = Team.getAll();
- teams.forEach(team -> {
- tab.add(team.getTeamName());
- tab.add(team.getTeamKuerzel());
- });
- }
- }
- return tab;
- }
}
diff --git a/src/de/steamwar/bungeecore/commands/TeamchatCommand.java b/src/de/steamwar/bungeecore/commands/TeamchatCommand.java
index 60e57dc..9d691a5 100644
--- a/src/de/steamwar/bungeecore/commands/TeamchatCommand.java
+++ b/src/de/steamwar/bungeecore/commands/TeamchatCommand.java
@@ -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));
}
}
diff --git a/src/de/steamwar/bungeecore/commands/TpCommand.java b/src/de/steamwar/bungeecore/commands/TpCommand.java
index de61885..b4d9399 100644
--- a/src/de/steamwar/bungeecore/commands/TpCommand.java
+++ b/src/de/steamwar/bungeecore/commands/TpCommand.java
@@ -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 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 tabCompleter() {
+ return new TypeMapper() {
+ @Override
+ public String map(CommandSender commandSender, String[] previousArguments, String s) {
+ return s;
+ }
+
+ @Override
+ public Collection tabCompletes(CommandSender sender, String[] previousArguments, String s) {
+ List 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 {
diff --git a/src/de/steamwar/bungeecore/commands/TutorialCommand.java b/src/de/steamwar/bungeecore/commands/TutorialCommand.java
index d0ff147..9fdc967 100644
--- a/src/de/steamwar/bungeecore/commands/TutorialCommand.java
+++ b/src/de/steamwar/bungeecore/commands/TutorialCommand.java
@@ -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 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()));
+ }
}
diff --git a/src/de/steamwar/bungeecore/commands/TypeMappers.java b/src/de/steamwar/bungeecore/commands/TypeMappers.java
index bf882fd..5b5b409 100644
--- a/src/de/steamwar/bungeecore/commands/TypeMappers.java
+++ b/src/de/steamwar/bungeecore/commands/TypeMappers.java
@@ -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 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;
}
diff --git a/src/de/steamwar/bungeecore/commands/UnIgnoreCommand.java b/src/de/steamwar/bungeecore/commands/UnIgnoreCommand.java
index d0755bd..bbd0dd4 100644
--- a/src/de/steamwar/bungeecore/commands/UnIgnoreCommand.java
+++ b/src/de/steamwar/bungeecore/commands/UnIgnoreCommand.java
@@ -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;
diff --git a/src/de/steamwar/bungeecore/commands/VerifyCommand.java b/src/de/steamwar/bungeecore/commands/VerifyCommand.java
index 08aee06..4d2cf64 100644
--- a/src/de/steamwar/bungeecore/commands/VerifyCommand.java
+++ b/src/de/steamwar/bungeecore/commands/VerifyCommand.java
@@ -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;
diff --git a/src/de/steamwar/bungeecore/commands/WhoisCommand.java b/src/de/steamwar/bungeecore/commands/WhoisCommand.java
index 1b80d75..581e618 100644
--- a/src/de/steamwar/bungeecore/commands/WhoisCommand.java
+++ b/src/de/steamwar/bungeecore/commands/WhoisCommand.java
@@ -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 activeMods = Utils.playerModMap.get(user.getUuid());
+ List activeMods = Utils.playerModMap.get(user.getUUID());
if (activeMods != null && !activeMods.isEmpty()) {
Message.send("WHOIS_ACTIVE_MODS", player,activeMods.size());
diff --git a/src/de/steamwar/bungeecore/inventory/SWInventory.java b/src/de/steamwar/bungeecore/inventory/SWInventory.java
index dac6be9..637668c 100644
--- a/src/de/steamwar/bungeecore/inventory/SWInventory.java
+++ b/src/de/steamwar/bungeecore/inventory/SWInventory.java
@@ -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) {
diff --git a/src/de/steamwar/bungeecore/listeners/BanListener.java b/src/de/steamwar/bungeecore/listeners/BanListener.java
index a868ba3..51ded5c 100644
--- a/src/de/steamwar/bungeecore/listeners/BanListener.java
+++ b/src/de/steamwar/bungeecore/listeners/BanListener.java
@@ -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 ips = BannedUserIPs.get(event.getConnection().getAddress().getAddress().getHostAddress());
+ List ips = BannedUserIPs.get(connection.getAddress().getAddress().getHostAddress());
if(!ips.isEmpty()){
Timestamp highestBan = ips.get(0).getTimestamp();
diff --git a/src/de/steamwar/bungeecore/listeners/ChatListener.java b/src/de/steamwar/bungeecore/listeners/ChatListener.java
index 827fe3e..622d6bd 100644
--- a/src/de/steamwar/bungeecore/listeners/ChatListener.java
+++ b/src/de/steamwar/bungeecore/listeners/ChatListener.java
@@ -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 rankedModes = ArenaMode.getAllModes().stream().filter(ArenaMode::isRanked).map(ArenaMode::getSchemType).collect(Collectors.toList());
+
private static final Set 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;
diff --git a/src/de/steamwar/bungeecore/listeners/CheckListener.java b/src/de/steamwar/bungeecore/listeners/CheckListener.java
index 1370a0d..8d27ba0 100644
--- a/src/de/steamwar/bungeecore/listeners/CheckListener.java
+++ b/src/de/steamwar/bungeecore/listeners/CheckListener.java
@@ -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;
diff --git a/src/de/steamwar/bungeecore/listeners/ConnectionListener.java b/src/de/steamwar/bungeecore/listeners/ConnectionListener.java
index a1b2e82..ddde4f7 100644
--- a/src/de/steamwar/bungeecore/listeners/ConnectionListener.java
+++ b/src/de/steamwar/bungeecore/listeners/ConnectionListener.java
@@ -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;
diff --git a/src/de/steamwar/bungeecore/listeners/EventModeListener.java b/src/de/steamwar/bungeecore/listeners/EventModeListener.java
index 852703c..4d2b23f 100644
--- a/src/de/steamwar/bungeecore/listeners/EventModeListener.java
+++ b/src/de/steamwar/bungeecore/listeners/EventModeListener.java
@@ -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;
diff --git a/src/de/steamwar/bungeecore/listeners/NonFabricFabricCheck.java b/src/de/steamwar/bungeecore/listeners/NonFabricFabricCheck.java
index b903b9c..0f825ab 100644
--- a/src/de/steamwar/bungeecore/listeners/NonFabricFabricCheck.java
+++ b/src/de/steamwar/bungeecore/listeners/NonFabricFabricCheck.java
@@ -41,6 +41,7 @@ public class NonFabricFabricCheck extends BasicListener {
private final Set usingFabric = new HashSet<>();
private final Set checking = new HashSet<>();
+ private final Set 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());
}
}
diff --git a/src/de/steamwar/bungeecore/listeners/PollSystem.java b/src/de/steamwar/bungeecore/listeners/PollSystem.java
index 85ca553..b0bf952 100644
--- a/src/de/steamwar/bungeecore/listeners/PollSystem.java
+++ b/src/de/steamwar/bungeecore/listeners/PollSystem.java
@@ -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();
}
diff --git a/src/de/steamwar/bungeecore/listeners/SessionManager.java b/src/de/steamwar/bungeecore/listeners/SessionManager.java
index aa3e5c8..db5a820 100644
--- a/src/de/steamwar/bungeecore/listeners/SessionManager.java
+++ b/src/de/steamwar/bungeecore/listeners/SessionManager.java
@@ -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));
}
}
}
diff --git a/src/de/steamwar/bungeecore/listeners/SettingsChangedListener.java b/src/de/steamwar/bungeecore/listeners/SettingsChangedListener.java
index 5affb64..ec11c46 100644
--- a/src/de/steamwar/bungeecore/listeners/SettingsChangedListener.java
+++ b/src/de/steamwar/bungeecore/listeners/SettingsChangedListener.java
@@ -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()));
});
}
}
diff --git a/src/de/steamwar/bungeecore/listeners/mods/Fabric.java b/src/de/steamwar/bungeecore/listeners/mods/Fabric.java
index 2822bed..9bed4e0 100644
--- a/src/de/steamwar/bungeecore/listeners/mods/Fabric.java
+++ b/src/de/steamwar/bungeecore/listeners/mods/Fabric.java
@@ -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) {
diff --git a/src/de/steamwar/bungeecore/listeners/mods/Forge.java b/src/de/steamwar/bungeecore/listeners/mods/Forge.java
index d6ebf21..ff5efb9 100644
--- a/src/de/steamwar/bungeecore/listeners/mods/Forge.java
+++ b/src/de/steamwar/bungeecore/listeners/mods/Forge.java
@@ -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;
diff --git a/src/de/steamwar/bungeecore/listeners/mods/Forge12.java b/src/de/steamwar/bungeecore/listeners/mods/Forge12.java
index 2bdd5a8..02a9082 100644
--- a/src/de/steamwar/bungeecore/listeners/mods/Forge12.java
+++ b/src/de/steamwar/bungeecore/listeners/mods/Forge12.java
@@ -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;
diff --git a/src/de/steamwar/bungeecore/listeners/mods/LabyMod.java b/src/de/steamwar/bungeecore/listeners/mods/LabyMod.java
index 22887d4..20fcaca 100644
--- a/src/de/steamwar/bungeecore/listeners/mods/LabyMod.java
+++ b/src/de/steamwar/bungeecore/listeners/mods/LabyMod.java
@@ -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;
diff --git a/src/de/steamwar/bungeecore/listeners/mods/Utils.java b/src/de/steamwar/bungeecore/listeners/mods/Utils.java
index db569c1..15e66bb 100644
--- a/src/de/steamwar/bungeecore/listeners/mods/Utils.java
+++ b/src/de/steamwar/bungeecore/listeners/mods/Utils.java
@@ -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 disconnect, List 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.");
}
diff --git a/src/de/steamwar/bungeecore/listeners/mods/WorldDownloader.java b/src/de/steamwar/bungeecore/listeners/mods/WorldDownloader.java
index 1b39625..f003098 100644
--- a/src/de/steamwar/bungeecore/listeners/mods/WorldDownloader.java
+++ b/src/de/steamwar/bungeecore/listeners/mods/WorldDownloader.java
@@ -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;
diff --git a/src/de/steamwar/bungeecore/network/NetworkReceiver.java b/src/de/steamwar/bungeecore/network/NetworkReceiver.java
index f01bf44..f1fcd5a 100644
--- a/src/de/steamwar/bungeecore/network/NetworkReceiver.java
+++ b/src/de/steamwar/bungeecore/network/NetworkReceiver.java
@@ -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;
}
diff --git a/src/de/steamwar/bungeecore/network/handlers/ExecuteCommandHandler.java b/src/de/steamwar/bungeecore/network/handlers/ExecuteCommandHandler.java
index ae31db5..91f8027 100644
--- a/src/de/steamwar/bungeecore/network/handlers/ExecuteCommandHandler.java
+++ b/src/de/steamwar/bungeecore/network/handlers/ExecuteCommandHandler.java
@@ -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);
}
}
diff --git a/src/de/steamwar/bungeecore/network/handlers/FightEndsHandler.java b/src/de/steamwar/bungeecore/network/handlers/FightEndsHandler.java
index b6a3f6b..48de642 100644
--- a/src/de/steamwar/bungeecore/network/handlers/FightEndsHandler.java
+++ b/src/de/steamwar/bungeecore/network/handlers/FightEndsHandler.java
@@ -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();
diff --git a/src/de/steamwar/bungeecore/network/handlers/InventoryCallbackHandler.java b/src/de/steamwar/bungeecore/network/handlers/InventoryCallbackHandler.java
index 03da0f9..b759f8c 100644
--- a/src/de/steamwar/bungeecore/network/handlers/InventoryCallbackHandler.java
+++ b/src/de/steamwar/bungeecore/network/handlers/InventoryCallbackHandler.java
@@ -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()));
}
diff --git a/src/de/steamwar/bungeecore/network/handlers/PrepareSchemHandler.java b/src/de/steamwar/bungeecore/network/handlers/PrepareSchemHandler.java
index c59c8df..d9eae09 100644
--- a/src/de/steamwar/bungeecore/network/handlers/PrepareSchemHandler.java
+++ b/src/de/steamwar/bungeecore/network/handlers/PrepareSchemHandler.java
@@ -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()));
diff --git a/src/de/steamwar/bungeecore/sql/BannedUserIPs.java b/src/de/steamwar/bungeecore/sql/BannedUserIPs.java
deleted file mode 100644
index 3d77919..0000000
--- a/src/de/steamwar/bungeecore/sql/BannedUserIPs.java
+++ /dev/null
@@ -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 .
-*/
-
-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 get(int userID){
- return getByID.select(rs -> {
- List userIPs = new ArrayList<>();
- while(rs.next()) {
- userIPs.add(new BannedUserIPs(
- userID,
- rs.getTimestamp("Timestamp")));
- }
- return userIPs;
- }, userID);
- }
-
- public static List get(String ip){
- return getByIP.select(rs -> {
- List 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;
- }
-}
diff --git a/src/de/steamwar/bungeecore/sql/BauLock.java b/src/de/steamwar/bungeecore/sql/BauLock.java
deleted file mode 100644
index f69a771..0000000
--- a/src/de/steamwar/bungeecore/sql/BauLock.java
+++ /dev/null
@@ -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 .
-*/
-
-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;
- }
- }
-
-}
diff --git a/src/de/steamwar/bungeecore/sql/BauLockState.java b/src/de/steamwar/bungeecore/sql/BauLockState.java
deleted file mode 100644
index 5d75fc3..0000000
--- a/src/de/steamwar/bungeecore/sql/BauLockState.java
+++ /dev/null
@@ -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 .
-*/
-
-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
-}
diff --git a/src/de/steamwar/bungeecore/sql/BauweltMember.java b/src/de/steamwar/bungeecore/sql/BauweltMember.java
deleted file mode 100644
index 66222bf..0000000
--- a/src/de/steamwar/bungeecore/sql/BauweltMember.java
+++ /dev/null
@@ -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 .
-*/
-
-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 getMembers(UUID bauweltID){
- return getMembers(SteamwarUser.get(bauweltID).getId());
- }
-
- public static List getMembers(int bauweltID){
- return getMembers.select(rs -> {
- List 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();
- }
-}
diff --git a/src/de/steamwar/bungeecore/sql/CheckedSchematic.java b/src/de/steamwar/bungeecore/sql/CheckedSchematic.java
deleted file mode 100644
index 77815c4..0000000
--- a/src/de/steamwar/bungeecore/sql/CheckedSchematic.java
+++ /dev/null
@@ -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 .
-*/
-
-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 previousChecks(SchematicNode node){
- return nodeHistory.select(rs -> {
- List schematics = new ArrayList<>();
- while(rs.next())
- schematics.add(new CheckedSchematic(rs));
- return schematics;
- }, node.getId());
- }
-
- public static List getLastDeclinedOfNode(SchematicNode node){
- return getLastDeclinedOfNode(node.getId());
- }
-
- public static List getLastDeclinedOfNode(int node){
- return nodeHistory.select(rs -> {
- List lastDeclined = new ArrayList<>();
- while(rs.next()){
- lastDeclined.add(new CheckedSchematic(rs));
- }
- return lastDeclined;
- }, node);
- }
-
- public static List getLastDeclined(UUID uuid){
- return getLastDelined(SteamwarUser.get(uuid).getId());
- }
-
- public static List getLastDelined(int schemOwner){
- return checkHistory.select(rs -> {
- List 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();
- }
-}
diff --git a/src/de/steamwar/bungeecore/sql/Event.java b/src/de/steamwar/bungeecore/sql/Event.java
deleted file mode 100644
index c2ad2ad..0000000
--- a/src/de/steamwar/bungeecore/sql/Event.java
+++ /dev/null
@@ -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 .
-*/
-
-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 getComing(){
- return byComing.select(rs -> {
- List 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;
- }
-}
diff --git a/src/de/steamwar/bungeecore/sql/EventFight.java b/src/de/steamwar/bungeecore/sql/EventFight.java
deleted file mode 100644
index 0a7072e..0000000
--- a/src/de/steamwar/bungeecore/sql/EventFight.java
+++ /dev/null
@@ -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 .
-*/
-
-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 {
-
- 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 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 getEvent(int eventID){
- return event.select(rs -> {
- List fights = new LinkedList<>();
- while(rs.next())
- fights.add(new EventFight(rs));
- return fights;
- }, eventID);
- }
-
- public static Queue 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);
- }
-}
diff --git a/src/de/steamwar/bungeecore/sql/Fight.java b/src/de/steamwar/bungeecore/sql/Fight.java
deleted file mode 100644
index 6cde50c..0000000
--- a/src/de/steamwar/bungeecore/sql/Fight.java
+++ /dev/null
@@ -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 bluePlayers = new ArrayList<>();
- private final List 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 fightPlayers) {
- for(FightPlayer fp : fightPlayers) {
- if(fp.getFightID() != fightID)
- continue;
-
- if(fp.getTeam() == 1)
- bluePlayers.add(fp);
- else
- redPlayers.add(fp);
- }
- }
-
- public static List getPage(int page, int elementsPerPage) {
- List fights = getPage.select(rs -> {
- List f = new ArrayList<>();
- while(rs.next()){
- f.add(new Fight(rs));
- }
- return f;
- }, page * elementsPerPage, elementsPerPage);
-
- List 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 getBluePlayers() {
- return bluePlayers;
- }
-
- public List getRedPlayers() {
- return redPlayers;
- }
-
- public boolean replayAllowed() {
- return replayExists() && replayAllowed;
- }
-
- public boolean replayExists() {
- return getGameMode() != null && replayAvailable;
- }
-}
diff --git a/src/de/steamwar/bungeecore/sql/FightPlayer.java b/src/de/steamwar/bungeecore/sql/FightPlayer.java
deleted file mode 100644
index 8416cb0..0000000
--- a/src/de/steamwar/bungeecore/sql/FightPlayer.java
+++ /dev/null
@@ -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 batchGet(Set fightIds) {
- List 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;
- }
-}
diff --git a/src/de/steamwar/bungeecore/sql/IgnoreSystem.java b/src/de/steamwar/bungeecore/sql/IgnoreSystem.java
deleted file mode 100644
index b152805..0000000
--- a/src/de/steamwar/bungeecore/sql/IgnoreSystem.java
+++ /dev/null
@@ -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 .
-*/
-
-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());
- }
-}
diff --git a/src/de/steamwar/bungeecore/sql/Mod.java b/src/de/steamwar/bungeecore/sql/Mod.java
deleted file mode 100644
index 897b7f9..0000000
--- a/src/de/steamwar/bungeecore/sql/Mod.java
+++ /dev/null
@@ -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 .
-*/
-
-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 getAllModsFiltered(int page,int elementsPerPage, Mod.ModType filter) {
- return Mod.getPageOfType.select(rs -> {
- List 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;
- }
- }
-}
diff --git a/src/de/steamwar/bungeecore/sql/NodeMember.java b/src/de/steamwar/bungeecore/sql/NodeMember.java
deleted file mode 100644
index 878982c..0000000
--- a/src/de/steamwar/bungeecore/sql/NodeMember.java
+++ /dev/null
@@ -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 .
- */
-
-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 getNodeMembers(int node) {
- return getNodeMembers.select(rs -> {
- Set members = new HashSet<>();
- while (rs.next())
- members.add(new NodeMember(rs));
- return members;
- }, node);
- }
-
- public static Set getSchematics(int member) {
- return getSchematics.select(rs -> {
- Set 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);
- }
-}
diff --git a/src/de/steamwar/bungeecore/sql/PollAnswer.java b/src/de/steamwar/bungeecore/sql/PollAnswer.java
deleted file mode 100644
index 8f9a64e..0000000
--- a/src/de/steamwar/bungeecore/sql/PollAnswer.java
+++ /dev/null
@@ -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 .
-*/
-
-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 getCurrentResults() {
- return getResults.select(rs -> {
- Map 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);
- }
-}
diff --git a/src/de/steamwar/bungeecore/sql/Punishment.java b/src/de/steamwar/bungeecore/sql/Punishment.java
deleted file mode 100644
index 8bc3b4a..0000000
--- a/src/de/steamwar/bungeecore/sql/Punishment.java
+++ /dev/null
@@ -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 .
- */
-
-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 getPunishmentsOfPlayer(int user) {
- return getPunishments.select(rs -> {
- Map punishments = new HashMap<>();
- while (rs.next())
- punishments.put(PunishmentType.valueOf(rs.getString("Type")), new Punishment(rs));
- return punishments;
- }, user);
- }
-
- public static List getAllPunishmentsOfPlayer(int user) {
- return getAllPunishments.select(rs -> {
- List 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;
- }
-}
diff --git a/src/de/steamwar/bungeecore/sql/SWException.java b/src/de/steamwar/bungeecore/sql/SWException.java
deleted file mode 100644
index 29e127a..0000000
--- a/src/de/steamwar/bungeecore/sql/SWException.java
+++ /dev/null
@@ -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 .
-*/
-
-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);
- }
-}
diff --git a/src/de/steamwar/bungeecore/sql/SchemElo.java b/src/de/steamwar/bungeecore/sql/SchemElo.java
deleted file mode 100644
index c5f0a34..0000000
--- a/src/de/steamwar/bungeecore/sql/SchemElo.java
+++ /dev/null
@@ -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 .
- */
-
-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);
- }
-}
diff --git a/src/de/steamwar/bungeecore/sql/SchematicNode.java b/src/de/steamwar/bungeecore/sql/SchematicNode.java
deleted file mode 100644
index 66a9183..0000000
--- a/src/de/steamwar/bungeecore/sql/SchematicNode.java
+++ /dev/null
@@ -1,504 +0,0 @@
-/*
- * This file is a part of the SteamWar software.
- *
- * Copyright (C) 2020 SteamWar.de-Serverteam
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see .
- */
-
-package de.steamwar.bungeecore.sql;
-
-
-import de.steamwar.sql.internal.Statement;
-
-import java.io.InputStream;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.sql.Timestamp;
-import java.time.Instant;
-import java.util.*;
-import java.util.function.Predicate;
-
-public class SchematicNode {
- private static final Statement createNode = new Statement("INSERT INTO SchematicNode (NodeName, NodeOwner, ParentNode, NodeType, NodeItem) VALUES (?, ?, ?, ?, ?) ON DUPLICATE KEY UPDATE NodeName = VALUES(NodeName), ParentNode = VALUES(ParentNode), NodeItem = VALUES(NodeItem), NodeType = VALUES(NodeType), NodeItem = VALUES(NodeItem)");
- private static final Statement getSchematicNode_Null = new Statement("SELECT NodeId, NodeName, NodeOwner, ParentNode, NodeType, NodeItem, NodeRank, NodeFormat, LastUpdate FROM SchematicNode WHERE NodeOwner = ? AND NodeName = ? AND ParentNode is NULL");
- private static final Statement getSchematicNode = new Statement("SELECT NodeId, NodeName, NodeOwner, ParentNode, NodeType, NodeItem, NodeRank, NodeFormat, LastUpdate FROM SchematicNode WHERE NodeOwner = ? AND NodeName = ? AND ParentNode = ?");
- private static final Statement getSchematicsInNode_Null = new Statement("SELECT NodeId, NodeName, NodeOwner, ParentNode, NodeType, NodeItem, NodeRank, NodeFormat, LastUpdate FROM SchematicNode WHERE ParentNode is NULL");
- private static final Statement getSchematicsInNode = new Statement("SELECT NodeId, NodeName, NodeOwner, ParentNode, NodeType, NodeItem, NodeRank, NodeFormat, LastUpdate FROM SchematicNode WHERE ParentNode = ?");
- private static final Statement getDirsInNode_Null = new Statement("SELECT NodeId, NodeName, NodeOwner, ParentNode, NodeType, NodeItem, NodeRank, NodeFormat, LastUpdate FROM SchematicNode WHERE ParentNode is NULL AND NodeType is NULL");
- private static final Statement getDirsInNode = new Statement("SELECT NodeId, NodeName, NodeOwner, ParentNode, NodeType, NodeItem, NodeRank, NodeFormat, LastUpdate FROM SchematicNode WHERE ParentNode = ? AND NodeType is NULL");
- private static final Statement getSchematicDirectory_Null = new Statement("SELECT NodeId, NodeName, NodeOwner, ParentNode, NodeType, NodeItem, NodeRank, NodeFormat, LastUpdate FROM SchematicNode WHERE NodeName = ? AND ParentNode is NULL");
- private static final Statement getSchematicDirectory = new Statement("SELECT NodeId, NodeName, NodeOwner, ParentNode, NodeType, NodeItem, NodeRank, NodeFormat, LastUpdate FROM SchematicNode WHERE NodeName = ? AND ParentNode = ?");
- private static final Statement getSchematicNodeO_Null = new Statement("SELECT NodeId, NodeName, NodeOwner, ParentNode, NodeType, NodeItem, NodeRank, NodeFormat, LastUpdate FROM SchematicNode WHERE NodeName = ? AND ParentNode is NULL");
- private static final Statement getSchematicNodeO = new Statement("SELECT NodeId, NodeName, NodeOwner, ParentNode, NodeType, NodeItem, NodeRank, NodeFormat, LastUpdate FROM SchematicNode WHERE NodeName = ? AND ParentNode = ?");
- private static final Statement getSchematicNodeId = new Statement("SELECT NodeId, NodeName, NodeOwner, ParentNode, NodeType, NodeItem, NodeRank, NodeFormat, LastUpdate FROM SchematicNode WHERE NodeId = ?");
- private static final Statement getAllSchemsOfTypeOwner = new Statement("SELECT NodeId, NodeName, NodeOwner, ParentNode, NodeType, NodeItem, NodeRank, NodeFormat, LastUpdate FROM SchematicNode WHERE NodeOwner = ? AND NodeType = ?");
- private static final Statement getAllSchemsOfType = new Statement("SELECT NodeId, NodeName, NodeOwner, ParentNode, NodeType, NodeItem, NodeRank, NodeFormat, LastUpdate FROM SchematicNode WHERE NodeType = ?");
- private static final Statement getAccessibleByUser = new Statement("SELECT s.NodeId, s.NodeName, s.NodeOwner, s.NodeItem, s.NodeType, s.ParentNode, s.NodeRank, s.NodeFormat, s.LastUpdate FROM SchematicNode s LEFT JOIN NodeMember n ON s.NodeId = n.NodeId WHERE (s.NodeOwner = ? OR n.UserId = ?) AND ((s.NodeOwner = ? AND s.ParentNode IS NULL) OR NOT s.NodeOwner = ?) GROUP BY s.NodeId ORDER BY s.NodeName");
- private static final Statement getAccessibleByUserByTypeInNode = new Statement("WITH RECURSIVE RSNB AS (WITH RECURSIVE RSN as (SELECT s.NodeId, s.NodeName, s.NodeOwner, s.NodeItem, s.NodeType, s.ParentNode, s.NodeRank, s.NodeFormat, s.LastUpdate FROM SchematicNode s LEFT JOIN NodeMember n ON s.NodeId = n.NodeId WHERE (s.NodeOwner = ? OR n.UserId = ?) GROUP BY s.NodeId union select SN.NodeId, SN.NodeName, SN.NodeOwner, SN.NodeItem, SN.NodeType, SN.ParentNode, SN.NodeRank, SN.NodeFormat, SN.LastUpdate FROM SchematicNode AS SN, RSN WHERE SN.ParentNode = RSN.NodeId) SELECT * FROM RSN WHERE NodeType = ? union select SN.NodeId, SN.NodeName, SN.NodeOwner, SN.NodeItem, SN.NodeType, SN.ParentNode, SN.NodeRank, SN.NodeFormat, SN.LastUpdate FROM SchematicNode AS SN, RSNB WHERE SN.NodeId = RSNB.ParentNode)SELECT * FROM RSNB WHERE ParentNode = ?");
- private static final Statement getAccessibleByUserByTypeInNode_Null = new Statement("WITH RECURSIVE RSNB AS (WITH RECURSIVE RSN as (SELECT s.NodeId, s.NodeName, s.NodeOwner, s.NodeItem, s.NodeType, s.ParentNode, s.NodeRank, s.NodeFormat, s.LastUpdate FROM SchematicNode s LEFT JOIN NodeMember n ON s.NodeId = n.NodeId WHERE (s.NodeOwner = ? OR n.UserId = ?) GROUP BY s.NodeId union select SN.NodeId, SN.NodeName, SN.NodeOwner, SN.NodeItem, SN.NodeType, SN.ParentNode, SN.NodeRank, SN.NodeFormat, SN.LastUpdate FROM SchematicNode AS SN, RSN WHERE SN.ParentNode = RSN.NodeId) SELECT * FROM RSN WHERE NodeType = ? union select SN.NodeId, SN.NodeName, SN.NodeOwner, SN.NodeItem, SN.NodeType, SN.ParentNode, SN.NodeRank, SN.NodeFormat, SN.LastUpdate FROM SchematicNode AS SN, RSNB WHERE SN.NodeId = RSNB.ParentNode)SELECT * FROM RSNB WHERE ParentNode is null");
- private static final Statement getAccessibleByUserByType = new Statement("WITH RECURSIVE RSN as (SELECT s.NodeId, s.NodeName, s.NodeOwner, s.NodeItem, s.NodeType, s.ParentNode, s.NodeRank, s.NodeFormat, s.LastUpdate FROM SchematicNode s LEFT JOIN NodeMember n ON s.NodeId = n.NodeId WHERE (s.NodeOwner = ? OR n.UserId = ?) GROUP BY s.NodeId union select SN.NodeId, SN.NodeName, SN.NodeOwner, SN.NodeItem, SN.NodeType, SN.ParentNode, SN.NodeRank, SN.NodeFormat, SN.LastUpdate FROM SchematicNode AS SN, RSN WHERE SN.ParentNode = RSN.NodeId) SELECT * FROM RSN WHERE NodeType = ?");
- private static final Statement getAllSchematicsAccessibleByUser = new Statement("WITH RECURSIVE RSN as (SELECT s.NodeId, s.NodeName, s.NodeOwner, s.NodeItem, s.NodeType, s.ParentNode, s.NodeRank, s.NodeFormat, s.LastUpdate FROM SchematicNode s LEFT JOIN NodeMember n ON s.NodeId = n.NodeId WHERE (s.NodeOwner = ? OR n.UserId = ?) GROUP BY s.NodeId union select SN.NodeId, SN.NodeName, SN.NodeOwner, SN.NodeItem, SN.NodeType, SN.ParentNode, SN.NodeRank, SN.NodeFormat, SN.LastUpdate FROM SchematicNode AS SN, RSN WHERE SN.ParentNode = RSN.NodeId) SELECT * FROM RSN");
- private static final Statement isSchematicAccessibleForUser = new Statement("WITH RECURSIVE RSN AS (SELECT NodeId, NodeName, NodeOwner, ParentNode, NodeType, NodeItem, NodeRank, NodeFormat, LastUpdate FROM SchematicNode WHERE NodeId = ? union select SN.NodeId, SN.NodeName, SN.NodeOwner, SN.ParentNode, SN.NodeType, SN.NodeItem, SN.NodeRank, SN.NodeFormat, SN.LastUpdate FROM SchematicNode SN, RSN WHERE RSN.ParentNode = SN.NodeId) SELECT COUNT(RSN.NodeId) AS `Accessible` FROM RSN LEFT Join NodeMember NM On NM.NodeId = RSN.NodeId WHERE NodeOwner = ? OR UserId = ? LIMIT 1");
- private static final Statement getAllParentsOfNode = new Statement("WITH RECURSIVE RSN AS (SELECT NodeId, NodeName, NodeOwner, ParentNode, NodeType, NodeItem, NodeRank, NodeFormat, LastUpdate FROM SchematicNode WHERE NodeId = ? UNION SELECT SN.NodeId, SN.NodeName, SN.NodeOwner, SN.ParentNode, SN.NodeType, SN.NodeItem, SN.NodeRank, SN.NodeFormat, SN.LastUpdate FROM SchematicNode SN, RSN WHERE RSN.ParentNode = SN.NodeId) SELECT * FROM RSN");
- private static final Statement countNodes = new Statement("SELECT COUNT(NodeId) AS 'count' FROM SchematicNode");
- private static final Statement updateDB = new Statement("UPDATE SchematicNode SET NodeName = ?, NodeOwner = ?, ParentNode = ?, NodeItem = ?, NodeType = ?, NodeRank = ? WHERE NodeId = ?");
- private static final Statement updateDatabase = new Statement("UPDATE SchematicNode SET NodeData = ?, NodeFormat = ? WHERE NodeId = ?");
- private static final Statement selSchemData = new Statement("SELECT NodeData FROM SchematicNode WHERE NodeId = ?");
- private static final Statement deleteNode = new Statement("DELETE FROM SchematicNode WHERE NodeId = ?");
-
- public static SchematicNode createSchematic(int owner, String name, Integer parent) {
- return createSchematicNode(owner, name, parent, SchematicType.Normal.toDB(), "");
- }
-
- public static SchematicNode createSchematicDirectory(int owner, String name, Integer parent) {
- return createSchematicNode(owner, name, parent, null, "");
- }
-
- public static SchematicNode createSchematicNode(int owner, String name, Integer parent, String type, String item) {
- if (parent != null && parent == 0)
- parent = null;
- createNode.update(name, owner, parent, type, item);
- return getSchematicNode(owner, name, parent);
- }
-
- private Timestamp lastUpdate;
-
- public static SchematicNode getSchematicNode(int owner, String name, SchematicNode parent) {
- return getSchematicNode(owner, name, parent.getId());
- }
-
- private SchematicNode(ResultSet set) throws SQLException {
- id = set.getInt("NodeId");
- owner = set.getInt("NodeOwner");
- name = set.getString("NodeName");
- parent = set.getInt("ParentNode");
- if(set.wasNull()) {
- parent = null;
- }
- item = set.getString("NodeItem");
- type = set.getString("NodeType");
- lastUpdate = set.getTimestamp("LastUpdate");
- if (type != null) {
- isDir = false;
- rank = set.getInt("NodeRank");
- schemFormat = set.getBoolean("NodeFormat");
- } else {
- isDir = true;
- }
- }
-
- public static List 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 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 getSchematicNodeInNode(Integer parent) {
- if(parent != null && parent == 0)
- parent = null;
- Statement.ResultSetUser> user = rs -> {
- List 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 getSchematicDirectoryInNode(Integer parent) {
- if(parent != null && parent == 0)
- parent = null;
- Statement.ResultSetUser> user = rs -> {
- List 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 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 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 getAccessibleSchematicsOfTypeInParent(int owner, String schemType, Integer parent) {
- Statement.ResultSetUser> user = rs -> {
- List 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 getAllAccessibleSchematicsOfType(int user, String schemType) {
- return getAccessibleByUserByType.select(rs -> {
- List nodes = new ArrayList<>();
- while (rs.next()) {
- nodes.add(new SchematicNode(rs));
- }
- return nodes;
- }, user, user, schemType);
- }
-
- public static List getAllSchematicsOfType(int owner, String schemType) {
- return getAllSchemsOfTypeOwner.select(rs -> {
- List nodes = new ArrayList<>();
- while (rs.next())
- nodes.add(new SchematicNode(rs));
- return nodes;
- }, owner, schemType);
- }
-
- public static List getAllSchematicsOfType(String schemType) {
- return getAllSchemsOfType.select(rs -> {
- List nodes = new ArrayList<>();
- while (rs.next())
- nodes.add(new SchematicNode(rs));
- return nodes;
- }, schemType);
- }
-
- public static List deepGet(Integer parent, Predicate filter) {
- List finalList = new ArrayList<>();
- List 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 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 nodes = new ArrayList<>();
- while(rs.next())
- nodes.add(new SchematicNode(rs));
- return nodes;
- }, user, user, user, user);
- }
- return Collections.emptyList();
- }
-
- public static List getAllSchematicsAccessibleByUser(int user) {
- return getAllSchematicsAccessibleByUser.select(rs -> {
- List nodes = new ArrayList<>();
- while(rs.next()) {
- nodes.add(new SchematicNode(rs));
- }
- return nodes;
- }, user, user);
- }
-
- public static List getAllParentsOfNode(SchematicNode node) {
- return getAllParentsOfNode(node.getId());
- }
-
- public static List getAllParentsOfNode(int node) {
- return getAllParentsOfNode.select(rs -> {
- List nodes = new ArrayList<>();
- while(rs.next()) {
- nodes.add(new SchematicNode(rs));
- }
- return nodes;
- }, node);
- }
-
- private final int id;
- private final int owner;
- private String name;
- private Integer parent;
- private String item;
- private String type;
- private boolean schemFormat;
- private int rank;
- private final boolean isDir;
- private Map brCache = new HashMap<>();
-
- public static List filterSchems(int user, Predicate filter) {
- List finalList = new ArrayList<>();
- List nodes = SchematicNode.getSchematicsAccessibleByUser(user, null);
- nodes.forEach(node -> {
- if (node.isDir()) {
- finalList.addAll(deepGet(node.getId(), filter));
- } else {
- if (filter.test(node))
- finalList.add(node);
- }
- });
- return finalList;
- }
-
- public static Integer countNodes() {
- return countNodes.select(rs -> {
- if (rs.next()) {
- return rs.getInt("count");
- }
- return 0;
- });
- }
-
- public int getId() {
- return id;
- }
-
- public int getOwner() {
- return owner;
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- updateDB();
- }
-
- public Integer getParent() {
- return parent;
- }
-
- public void setParent(Integer parent) {
- this.parent = parent;
- updateDB();
- }
-
- public String getItem() {
- return item;
- }
-
- public void setItem(String item) {
- this.item = item;
- updateDB();
- }
-
- public String getType() {
- if(isDir)
- throw new SecurityException("Node is Directory");
- return type;
- }
-
- public void setType(String type) {
- if(isDir)
- throw new SecurityException("Node is Directory");
- this.type = type;
- updateDB();
- }
-
- public boolean isDir() {
- return isDir;
- }
-
- public boolean getSchemFormat() {
- if(isDir)
- throw new SecurityException("Node is Directory");
- return schemFormat;
- }
-
- public int getRank() {
- if(isDir)
- throw new SecurityException("Node is Directory");
- return rank;
- }
-
- public void setRank(int rank) {
- if(isDir)
- throw new SecurityException("Node is Directory");
- this.rank = rank;
- }
-
- public SchematicType getSchemtype() {
- if(isDir())
- throw new RuntimeException("Is Directory");
- return SchematicType.fromDB(type);
- }
-
- public SchematicNode getParentNode() {
- if(parent == null) return null;
- return SchematicNode.getSchematicNode(parent);
- }
-
- public boolean accessibleByUser(int user) {
- return NodeMember.getNodeMember(id, user) != null;
- }
-
- public Set getMembers() {
- return NodeMember.getNodeMembers(id);
- }
-
- public Timestamp getLastUpdate() {
- return lastUpdate;
- }
-
- public String generateBreadcrumbs(SteamwarUser user) {
- return brCache.computeIfAbsent(user.getId(), integer -> generateBreadcrumbs("/", user));
- }
-
- public String generateBreadcrumbs(String split, SteamwarUser user) {
- StringBuilder builder = new StringBuilder(getName());
- SchematicNode currentNode = this;
- if (currentNode.isDir()) builder.append("/");
- while (currentNode.getParentNode() != null) {
- currentNode = currentNode.getParentNode();
- builder.insert(0, split)
- .insert(0, currentNode.getName());
- if (currentNode.getMembers().stream().anyMatch(member -> member.getMember() == user.getId())) {
- break;
- }
- }
- return builder.toString();
- }
-
- private void updateDB() {
- updateDB.update(name, owner, parent, item, type, rank, id);
- this.lastUpdate = Timestamp.from(Instant.now());
- this.brCache.clear();
- }
-
- public void delete() {
- if (isDir()) {
- getSchematicNodeInNode(getId()).forEach(SchematicNode::delete);
- }
- deleteNode.update(id);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (!(obj instanceof SchematicNode))
- return false;
-
- SchematicNode node = (SchematicNode) obj;
- return node.getId() == id;
- }
-
- public void saveFromStream(InputStream stream, boolean newFormat) {
- if(isDir)
- throw new SecurityException("Node is Directory");
- updateDatabase(stream, newFormat);
- }
-
- private void updateDatabase(InputStream blob, boolean newFormat) {
- updateDatabase.update(blob, newFormat, id);
- schemFormat = newFormat;
- }
-
- private static final List 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;
- }
-}
diff --git a/src/de/steamwar/bungeecore/sql/SchematicType.java b/src/de/steamwar/bungeecore/sql/SchematicType.java
deleted file mode 100644
index 9592070..0000000
--- a/src/de/steamwar/bungeecore/sql/SchematicType.java
+++ /dev/null
@@ -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 .
-*/
-
-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 fromDB;
- private static final Map fightType;
- private static final List types;
-
- static {
- File folder = new File(ProxyServer.getInstance().getPluginsFolder(), "FightSystem");
-
- List tmpTypes = new LinkedList<>();
- Map tmpFromDB = new HashMap<>();
- Map 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 values(){
- return types;
- }
-
- enum Type{
- NORMAL,
- CHECK_TYPE,
- FIGHT_TYPE
- }
-}
diff --git a/src/de/steamwar/bungeecore/sql/Season.java b/src/de/steamwar/bungeecore/sql/Season.java
deleted file mode 100644
index 093165f..0000000
--- a/src/de/steamwar/bungeecore/sql/Season.java
+++ /dev/null
@@ -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 .
- */
-
-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;
- }
- }
-}
diff --git a/src/de/steamwar/bungeecore/sql/Session.java b/src/de/steamwar/bungeecore/sql/Session.java
deleted file mode 100644
index f5eae0d..0000000
--- a/src/de/steamwar/bungeecore/sql/Session.java
+++ /dev/null
@@ -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 .
-*/
-
-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);
- }
-}
diff --git a/src/de/steamwar/bungeecore/sql/SteamwarUser.java b/src/de/steamwar/bungeecore/sql/SteamwarUser.java
deleted file mode 100644
index 3fad94e..0000000
--- a/src/de/steamwar/bungeecore/sql/SteamwarUser.java
+++ /dev/null
@@ -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 .
-*/
-
-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 usersByName = new HashMap<>();
- private static final Map usersByUUID = new HashMap<>();
- private static final Map usersById = new HashMap<>();
- private static final Map 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 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 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));
- }
-}
diff --git a/src/de/steamwar/bungeecore/sql/Team.java b/src/de/steamwar/bungeecore/sql/Team.java
deleted file mode 100644
index 83e8e0a..0000000
--- a/src/de/steamwar/bungeecore/sql/Team.java
+++ /dev/null
@@ -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 .
-*/
-
-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 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 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 getMembers(){
- return getMembers.select(rs -> {
- List members = new ArrayList<>();
- while(rs.next())
- members.add(rs.getInt("id"));
- return members;
- }, teamId);
- }
-}
diff --git a/src/de/steamwar/bungeecore/sql/TeamTeilnahme.java b/src/de/steamwar/bungeecore/sql/TeamTeilnahme.java
deleted file mode 100644
index a77f33d..0000000
--- a/src/de/steamwar/bungeecore/sql/TeamTeilnahme.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- This file is a part of the SteamWar software.
-
- Copyright (C) 2020 SteamWar.de-Serverteam
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU Affero General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Affero General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public License
- along with this program. If not, see .
-*/
-
-package de.steamwar.bungeecore.sql;
-
-import de.steamwar.sql.internal.Statement;
-
-import java.sql.ResultSet;
-import java.util.HashSet;
-import java.util.Set;
-
-public class TeamTeilnahme {
- private TeamTeilnahme(){}
-
- private static final Statement insert = new Statement("INSERT INTO TeamTeilnahme (TeamID, EventID) VALUES (?, ?)");
- private static final Statement delete = new Statement("DELETE FROM TeamTeilnahme WHERE TeamID = ? AND EventID = ?");
- private static final Statement deleteFuture = new Statement("DELETE t FROM TeamTeilnahme t INNER JOIN Event e ON t.EventID = e.EventID WHERE t.TeamID = ? AND e.Start > NOW()");
- private static final Statement byEventTeam = new Statement("SELECT * FROM TeamTeilnahme WHERE TeamID = ? AND EventID = ?");
- private static final Statement byEvent = new Statement("SELECT * FROM TeamTeilnahme WHERE EventID = ?");
- private static final Statement byTeam = new Statement("SELECT * FROM TeamTeilnahme WHERE TeamID = ?");
-
- public static void teilnehmen(int teamID, int eventID){
- insert.update(teamID, eventID);
- }
-
- public static void notTeilnehmen(int teamID, int eventID){
- delete.update(teamID, eventID);
- }
-
- public static boolean nimmtTeil(int teamID, int eventID){
- return byEventTeam.select(ResultSet::next, teamID, eventID);
- }
-
- public static void deleteFuture(int teamID) {
- deleteFuture.update(teamID);
- }
-
- public static Set getTeams(int eventID){
- return byEvent.select(rs -> {
- Set teams = new HashSet<>();
- while(rs.next())
- teams.add(Team.get(rs.getInt("TeamID")));
- return teams;
- }, eventID);
- }
-
- public static Set getEvents(int teamID){
- return byTeam.select(rs -> {
- Set events = new HashSet<>();
- while(rs.next())
- events.add(Event.get(rs.getInt("EventID")));
- return events;
- }, teamID);
- }
-}
diff --git a/src/de/steamwar/bungeecore/sql/Tutorial.java b/src/de/steamwar/bungeecore/sql/Tutorial.java
deleted file mode 100644
index 6196ad6..0000000
--- a/src/de/steamwar/bungeecore/sql/Tutorial.java
+++ /dev/null
@@ -1,139 +0,0 @@
-/*
- * This file is a part of the SteamWar software.
- *
- * Copyright (C) 2022 SteamWar.de-Serverteam
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see .
- */
-
-package de.steamwar.bungeecore.sql;
-
-import de.steamwar.sql.internal.Statement;
-
-import de.steamwar.bungeecore.BungeeCore;
-import de.steamwar.bungeecore.ServerStarter;
-import de.steamwar.bungeecore.SubserverSystem;
-
-import java.io.File;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.stream.Collectors;
-
-public class Tutorial {
-
- private static final Statement by_popularity = new Statement("SELECT t.*, AVG(r.Stars) AS Stars FROM Tutorial t LEFT OUTER JOIN TutorialRating r ON t.TutorialID = r.TutorialID WHERE t.Released = ? GROUP BY t.TutorialID ORDER BY SUM(r.Stars) DESC LIMIT ?, ?");
- private static final Statement own = new Statement("SELECT t.*, AVG(r.Stars) AS Stars FROM Tutorial t LEFT OUTER JOIN TutorialRating r ON t.TutorialID = r.TutorialID WHERE t.Creator = ? GROUP BY t.TutorialID ORDER BY t.TutorialID ASC LIMIT ?, ?");
- private static final Statement by_creator_name = new Statement("SELECT t.*, AVG(r.Stars) AS Stars FROM Tutorial t LEFT OUTER JOIN TutorialRating r ON t.TutorialID = r.TutorialID WHERE t.Creator = ? AND t.Name = ? GROUP BY t.TutorialID");
- private static final Statement by_id = new Statement("SELECT t.*, AVG(r.Stars) AS Stars FROM Tutorial t LEFT OUTER JOIN TutorialRating r ON t.TutorialID = r.TutorialID WHERE t.TutorialID = ? GROUP BY t.TutorialID");
- private static final Statement rate = new Statement("INSERT INTO TutorialRating (TutorialID, UserID, Stars) VALUES (?, ?, ?) ON DUPLICATE KEY UPDATE Stars = VALUES(Stars)");
- private static final Statement create = new Statement("INSERT INTO Tutorial (Creator, Name, Item) VALUES (?, ?, ?) ON DUPLICATE KEY UPDATE Item = VALUES(Item), Released = 0");
- private static final Statement release = new Statement("UPDATE Tutorial SET Released = 1 WHERE TutorialID = ?");
- private static final Statement delete = new Statement("DELETE FROM Tutorial WHERE TutorialID = ?");
-
- public static List getPage(int page, int elementsPerPage, boolean released) {
- List tutorials = by_popularity.select(rs -> {
- List t = new ArrayList<>();
- while(rs.next())
- t.add(new Tutorial(rs));
- return t;
- }, released, page * elementsPerPage, elementsPerPage);
-
- SteamwarUser.batchCache(tutorials.stream().map(tutorial -> tutorial.creator).collect(Collectors.toSet()));
- return tutorials;
- }
-
- public static List getOwn(SteamwarUser user, int page, int elementsPerPage) {
- return own.select(rs -> {
- List t = new ArrayList<>();
- while(rs.next())
- t.add(new Tutorial(rs));
- return t;
- }, user.getId(), page * elementsPerPage, elementsPerPage);
- }
-
- public static Tutorial create(SteamwarUser creator, String name, String item) {
- create.update(creator.getId(), name, item);
- return by_creator_name.select(rs -> {
- rs.next();
- return new Tutorial(rs);
- }, creator.getId(), name);
- }
-
- public static Tutorial get(int id) {
- return by_id.select(rs -> {
- if(rs.next())
- return new Tutorial(rs);
- return null;
- }, id);
- }
-
- private final int id;
- private final int creator;
- private final String name;
- private final String item;
- private final double stars;
- private final boolean released;
-
- public Tutorial(ResultSet rs) throws SQLException {
- this.id = rs.getInt("TutorialID");
- this.creator = rs.getInt("Creator");
- this.name = rs.getString("Name");
- this.item = rs.getString("Item");
- this.released = rs.getBoolean("Released");
- this.stars = rs.getDouble("Stars");
- }
-
- public SteamwarUser creator() {
- return SteamwarUser.get(creator);
- }
-
- public double stars() {
- return stars;
- }
-
- public int id() {
- return id;
- }
-
- public String name() {
- return name;
- }
-
- public String item() {
- return item;
- }
-
- public boolean released() {
- return released;
- }
-
- public void release() {
- release.update(id);
- }
-
- public void delete() {
- delete.update(id);
- SubserverSystem.deleteFolder(BungeeCore.local, world().getPath());
- }
-
- public File world() {
- return new File(ServerStarter.TUTORIAL_PATH, String.valueOf(id));
- }
-
- public void rate(SteamwarUser user, int rating) {
- rate.update(id, user.getId(), rating);
- }
-}
diff --git a/src/de/steamwar/bungeecore/sql/UserConfig.java b/src/de/steamwar/bungeecore/sql/UserConfig.java
deleted file mode 100644
index b2c79bd..0000000
--- a/src/de/steamwar/bungeecore/sql/UserConfig.java
+++ /dev/null
@@ -1,48 +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 .
-*/
-
-
-package de.steamwar.bungeecore.sql;
-
-import de.steamwar.sql.internal.Statement;
-
-public class UserConfig {
- private UserConfig() {}
-
- private static final Statement insert = new Statement("INSERT INTO UserConfig (User, Config, Value) VALUES (?,?,?) ON DUPLICATE KEY UPDATE Value = VALUES(Value)");
- private static final Statement select = new Statement("SELECT Value FROM UserConfig WHERE User = ? AND Config = ?");
- private static final Statement delete = new Statement("DELETE FROM UserConfig WHERE User = ? AND Config = ?");
-
- public static String getConfig(int userID, String config) {
- return select.select(rs -> {
- if(rs.next())
- return rs.getString("Value");
- return null;
- }, userID, config);
- }
-
- public static void updateUserConfig(int userID, String config, String value) {
- if(value == null) {
- delete.update(userID, config);
- return;
- }
-
- insert.update(userID, config, value);
- }
-}
diff --git a/src/de/steamwar/bungeecore/sql/UserElo.java b/src/de/steamwar/bungeecore/sql/UserElo.java
deleted file mode 100644
index ed5df18..0000000
--- a/src/de/steamwar/bungeecore/sql/UserElo.java
+++ /dev/null
@@ -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 .
- */
-
-package de.steamwar.bungeecore.sql;
-
-import de.steamwar.sql.internal.Statement;
-import de.steamwar.bungeecore.ArenaMode;
-import de.steamwar.bungeecore.Message;
-import net.md_5.bungee.api.connection.ProxiedPlayer;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Optional;
-import java.util.concurrent.ConcurrentHashMap;
-
-public class UserElo {
- private UserElo() {}
-
- public static final int ELO_DEFAULT = 1000;
-
- private static final Map>> gameModeUserEloCache = new ConcurrentHashMap<>();
- private static final Map maxEloCache = new ConcurrentHashMap<>();
- private static final Map emblemCache = new ConcurrentHashMap<>();
-
- private static final Statement elo = new Statement("SELECT Elo FROM UserElo WHERE UserID = ? AND GameMode = ? AND Season = ?");
- private static final Statement setElo = new Statement("INSERT INTO UserElo (Season, GameMode, UserID, Elo) VALUES (?, ?, ?, ?) ON DUPLICATE KEY UPDATE Elo = VALUES(Elo)");
- private static final Statement maxElo = new Statement("SELECT MAX(Elo) AS MaxElo FROM UserElo WHERE Season = ? AND GameMode = ?");
-
- private static final Statement place = new Statement("SELECT COUNT(*) AS Place FROM UserElo WHERE GameMode = ? AND Elo > ? AND Season = ?");
- private static final Statement fightsOfSeason = new Statement("SELECT COUNT(*) AS Fights FROM FightPlayer INNER JOIN Fight F on FightPlayer.FightID = F.FightID WHERE UserID = ? AND GameMode = ? AND UNIX_TIMESTAMP(StartTime) + Duration >= UNIX_TIMESTAMP(?)");
-
- public static int getEloOrDefault(int userID, String gameMode) {
- return getElo(userID, gameMode).orElse(ELO_DEFAULT);
- }
-
- public static Optional getElo(int userID, String gameMode) {
- return gameModeUserEloCache.computeIfAbsent(gameMode, gm -> new HashMap<>()).computeIfAbsent(userID, uid -> elo.select(rs -> {
- if (rs.next())
- return Optional.of(rs.getInt("Elo"));
- return Optional.empty();
- }, userID, gameMode, Season.getSeason()));
- }
-
- public static int getFightsOfSeason(int userID, String gameMode) {
- return fightsOfSeason.select(rs -> {
- if (rs.next())
- return rs.getInt("Fights");
- return 0;
- }, userID, gameMode, Season.getSeasonStart());
- }
-
- private static int getMaxElo(String gameMode) {
- return maxEloCache.computeIfAbsent(gameMode, gm -> maxElo.select(rs -> {
- if (rs.next())
- return rs.getInt("MaxElo");
- return 0;
- }, Season.getSeason(), gameMode));
- }
-
- public static void setElo(int userId, String gameMode, int elo) {
- emblemCache.remove(userId);
-
- Optional oldElo = Optional.ofNullable(gameModeUserEloCache.computeIfAbsent(gameMode, gm -> new HashMap<>()).put(userId, Optional.of(elo))).orElse(Optional.empty());
- int maxElo = getMaxElo(gameMode);
- if (elo > maxElo || (oldElo.isPresent() && oldElo.get() == maxElo)) {
- maxEloCache.remove(gameMode);
- emblemCache.clear();
- }
-
- setElo.update(Season.getSeason(), gameMode, userId, elo);
- }
-
- public static int getPlacement(int elo, String gameMode) {
- return place.select(rs -> {
- if (rs.next())
- return rs.getInt("Place") + 1;
- return -1;
- }, gameMode, elo, Season.getSeason());
- }
-
- public static String getEmblem(SteamwarUser user) {
- return emblemCache.computeIfAbsent(user.getId(), userId -> {
- switch(
- ArenaMode.getAllModes().stream().filter(
- ArenaMode::isRanked
- ).filter(
- mode -> UserElo.getFightsOfSeason(user.getId(), mode.getSchemType()) >= 10
- ).map(
- mode -> getProgression(user.getId(), mode.getSchemType())
- ).max(Integer::compareTo).orElse(0)
- ) {
- case 0:
- return "";
- case 1:
- return "§7✧ ";
- case 2:
- return "§f✦ ";
- case 3:
- return "§e✶ ";
- case 4:
- return "§a✷ ";
- case 5:
- return "§b✸ ";
- case 6:
- return "§c✹ ";
- case 7:
- return "§5❂ ";
- default:
- throw new SecurityException("Progression out of range");
- }
- });
- }
-
- public static String getEmblemProgression(ProxiedPlayer player, String gameMode, int userId) {
- int fightsOfSeason = getFightsOfSeason(userId, gameMode);
- if (fightsOfSeason < 10)
- return Message.parse("RANK_NEEDED_FIGHTS_LEFT", player, "§8✧ ✦ ✶ ✷ ✸ ✹ ❂", 10 - fightsOfSeason);
-
- switch (getProgression(userId, gameMode)) {
- case 0:
- return "§8✧ ✦ ✶ ✷ ✸ ✹ ❂";
- case 1:
- return "§7✧ §8✦ ✶ ✷ ✸ ✹ ❂";
- case 2:
- return "§8✧ §f✦ §8✶ ✷ ✸ ✹ ❂";
- case 3:
- return "§8✧ ✦ §e✶ §8✷ ✸ ✹ ❂";
- case 4:
- return "§8✧ ✦ ✶ §a✷ §8✸ ✹ ❂";
- case 5:
- return "§8✧ ✦ ✶ ✷ §b✸ §8✹ ❂";
- case 6:
- return "§8✧ ✦ ✶ ✷ ✸ §c✹ §8❂";
- case 7:
- return "§8✧ ✦ ✶ ✷ ✸ ✹ §5❂";
- default:
- throw new SecurityException("Progression is not in range");
- }
- }
-
- private static int getProgression(int userId, String gameMode) {
- int elo = UserElo.getElo(userId, gameMode).orElse(0);
- if(elo == 0)
- return 0;
- int maxElo = UserElo.getMaxElo(gameMode);
-
- if (elo > maxElo * 0.99) return 7;
- if (elo > maxElo * 0.97) return 6;
- if (elo > maxElo * 0.94) return 5;
- if (elo > maxElo * 0.88) return 4;
- if (elo > maxElo * 0.76) return 3;
- if (elo > maxElo * 0.51) return 2;
- return 1;
- }
-
- public static void clearCache() {
- gameModeUserEloCache.clear();
- maxEloCache.clear();
- emblemCache.clear();
- }
-}
diff --git a/src/de/steamwar/bungeecore/sql/UserGroup.java b/src/de/steamwar/bungeecore/sql/UserGroup.java
deleted file mode 100644
index 6ca7a9a..0000000
--- a/src/de/steamwar/bungeecore/sql/UserGroup.java
+++ /dev/null
@@ -1,84 +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 .
- */
-
-package de.steamwar.bungeecore.sql;
-
-import java.util.Arrays;
-import java.util.stream.Collectors;
-
-public enum UserGroup {
-
- Admin("§4", "§e", "Admin", true, true, true, true),
- Developer("§3", "§f", "Dev", true, true, true, true),
- Moderator("§c", "§f", "Mod", true, true, true, true),
- Supporter("§9", "§f", "Sup", false, true, true, true),
- Builder("§2", "§f", "Arch", false, true, false, true),
- YouTuber("§5", "§f", "YT", false, false, false, true),
- Member("§7", "§7", "", false, false, false, false);
-
- private final String colorCode;
- private final String chatColorCode;
- private final String chatPrefix;
- private final boolean adminGroup;
- private final boolean teamGroup;
- private final boolean checkSchematics;
- private final boolean privilegedMods;
-
- UserGroup(String colorCode, String chatColorCode, String chatPrefix, boolean adminGroup, boolean teamGroup, boolean checkSchematics, boolean privilegedMods) {
- this.colorCode = colorCode;
- this.chatColorCode = chatColorCode;
- this.chatPrefix = chatPrefix;
- this.adminGroup = adminGroup;
- this.teamGroup = teamGroup;
- this.checkSchematics = checkSchematics;
- this.privilegedMods = privilegedMods;
- }
-
- public String getColorCode() {
- return colorCode;
- }
-
- public boolean isAdminGroup() {
- return adminGroup;
- }
-
- public boolean isTeamGroup() {
- return teamGroup;
- }
-
- public boolean isCheckSchematics() {
- return checkSchematics;
- }
-
- public boolean privilegedMods() {
- return privilegedMods;
- }
-
- public String getChatColorCode() {
- return chatColorCode;
- }
-
- public static UserGroup getUsergroup(String name) {
- return Arrays.stream(UserGroup.values()).filter(userGroup -> userGroup.name().equalsIgnoreCase(name)).collect(Collectors.toList()).get(0);
- }
-
- public String getChatPrefix() {
- return chatPrefix;
- }
-}
\ No newline at end of file
diff --git a/src/de/steamwar/bungeecore/tablist/TablistPart.java b/src/de/steamwar/bungeecore/tablist/TablistPart.java
index 30c848f..061ae92 100644
--- a/src/de/steamwar/bungeecore/tablist/TablistPart.java
+++ b/src/de/steamwar/bungeecore/tablist/TablistPart.java
@@ -19,8 +19,8 @@
package de.steamwar.bungeecore.tablist;
-import de.steamwar.bungeecore.sql.SteamwarUser;
-import de.steamwar.bungeecore.sql.UserGroup;
+import de.steamwar.sql.SteamwarUser;
+import de.steamwar.sql.UserGroup;
import de.steamwar.messages.ChatSender;
import net.md_5.bungee.api.chat.TextComponent;
import net.md_5.bungee.api.connection.ProxiedPlayer;
diff --git a/src/de/steamwar/bungeecore/tablist/TablistServer.java b/src/de/steamwar/bungeecore/tablist/TablistServer.java
index 5480940..812588d 100644
--- a/src/de/steamwar/bungeecore/tablist/TablistServer.java
+++ b/src/de/steamwar/bungeecore/tablist/TablistServer.java
@@ -21,7 +21,7 @@ package de.steamwar.bungeecore.tablist;
import de.steamwar.bungeecore.Servertype;
import de.steamwar.bungeecore.Subserver;
-import de.steamwar.bungeecore.sql.SteamwarUser;
+import de.steamwar.sql.SteamwarUser;
import de.steamwar.messages.ChatSender;
import de.steamwar.network.packets.common.FightInfoPacket;
import net.md_5.bungee.BungeeCord;
@@ -82,7 +82,7 @@ public class TablistServer implements TablistPart {
private void addPlayers(String prefix, List teamPlayers, Collection onlinePlayers){
teamPlayers.stream().map(SteamwarUser::get).map(
- user -> onlinePlayers.stream().filter(player -> player.getUniqueId().equals(user.getUuid())).findAny()
+ user -> onlinePlayers.stream().filter(player -> player.getUniqueId().equals(user.getUUID())).findAny()
).filter(Optional::isPresent).map(Optional::get).sorted(
(p1, p2) -> p1.getName().compareToIgnoreCase(p2.getName())
).forEachOrdered(player -> players.add(new Item(player.getUniqueId(), prefix + player.getName(), Item.playerProperties(player))));
diff --git a/src/de/steamwar/bungeecore/util/BauLock.java b/src/de/steamwar/bungeecore/util/BauLock.java
new file mode 100644
index 0000000..43926dd
--- /dev/null
+++ b/src/de/steamwar/bungeecore/util/BauLock.java
@@ -0,0 +1,54 @@
+/*
+ * This file is a part of the SteamWar software.
+ *
+ * Copyright (C) 2023 SteamWar.de-Serverteam
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ */
+
+package de.steamwar.bungeecore.util;
+
+import de.steamwar.bungeecore.Message;
+import de.steamwar.sql.SteamwarUser;
+import de.steamwar.sql.UserConfig;
+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.updatePlayerConfig(owner.getId(), BAU_LOCK_CONFIG_NAME, state == BauLockState.OPEN ? null : state.name());
+ Message.send("BAU_LOCKED_" + state.name(), p);
+ }
+
+ 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;
+ }
+ }
+
+}
diff --git a/src/de/steamwar/bungeecore/util/BauLockState.java b/src/de/steamwar/bungeecore/util/BauLockState.java
new file mode 100644
index 0000000..a5626b1
--- /dev/null
+++ b/src/de/steamwar/bungeecore/util/BauLockState.java
@@ -0,0 +1,27 @@
+/*
+ * This file is a part of the SteamWar software.
+ *
+ * Copyright (C) 2023 SteamWar.de-Serverteam
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ */
+
+package de.steamwar.bungeecore.util;
+
+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
+}
diff --git a/src/de/steamwar/command/SWCommand.java b/src/de/steamwar/command/SWCommand.java
index 63bbace..83b4d8d 100644
--- a/src/de/steamwar/command/SWCommand.java
+++ b/src/de/steamwar/command/SWCommand.java
@@ -120,7 +120,7 @@ public class SWCommand extends AbstractSWCommand {
ChatSender.of(sender).system(message, args);
}
- @Register(help = true)
+ @Register(noTabComplete = true)
public void internalHelp(ProxiedPlayer p, String... args) {
ChatSender chatSender = ChatSender.of(p);
try {
diff --git a/src/de/steamwar/command/TypeUtils.java b/src/de/steamwar/command/TypeUtils.java
index 833cd4b..b83cb96 100644
--- a/src/de/steamwar/command/TypeUtils.java
+++ b/src/de/steamwar/command/TypeUtils.java
@@ -20,7 +20,7 @@
package de.steamwar.command;
import de.steamwar.bungeecore.commands.TypeMappers;
-import de.steamwar.bungeecore.sql.SteamwarUser;
+import de.steamwar.sql.SteamwarUser;
import lombok.experimental.UtilityClass;
import net.md_5.bungee.BungeeCord;
import net.md_5.bungee.api.connection.ProxiedPlayer;
diff --git a/src/de/steamwar/messages/BungeeCore.properties b/src/de/steamwar/messages/BungeeCore.properties
index b4256b2..1845f38 100644
--- a/src/de/steamwar/messages/BungeeCore.properties
+++ b/src/de/steamwar/messages/BungeeCore.properties
@@ -446,13 +446,13 @@ TEAM_REMOVE_REMOVED_TARGET=§cYou were removed from the team.
#Team Kuerzel
TEAM_KUERZEL_USAGE=§8/§7team changekuerzel §8[§eshortcut§8]
TEAM_KUERZEL_CHANGED=§7You changed your teams shortcut!
-TEAM_KUERZEL_LENGHT=§cA team shortcut has to consist of 2 to 4 characters.
+TEAM_KUERZEL_LENGTH=§cA team shortcut has to consist of 2 to 4 characters.
TEAM_KUERZEL_TAKEN=§cThere is already a team with that shortcut.
#Team Name
TEAM_NAME_USAGE=§8/§7team changename §8[§eteam name§8]
TEAM_NAME_CHANGED=§7You have renamed your team!
-TEAM_NAME_LENGHT=§cA team name has to consist of 4 to 15 characters.
+TEAM_NAME_LENGTH=§cA team name has to consist of 4 to 15 characters.
TEAM_NAME_TAKEN=§cThere is already a team with that name.
#Team Leader
diff --git a/src/de/steamwar/messages/BungeeCore_de.properties b/src/de/steamwar/messages/BungeeCore_de.properties
index 83de9f6..d1f8a22 100644
--- a/src/de/steamwar/messages/BungeeCore_de.properties
+++ b/src/de/steamwar/messages/BungeeCore_de.properties
@@ -424,13 +424,13 @@ TEAM_REMOVE_REMOVED_TARGET=§cDu wurdest aus dem Team entfernt.
#Team Kuerzel
TEAM_KUERZEL_USAGE=§8/§7team changekuerzel §8[§eTeamkürzel§8]
TEAM_KUERZEL_CHANGED=§7Du hast das Kürzel des Teams geändert!
-TEAM_KUERZEL_LENGHT=§cEin Teamkürzel muss aus 2 bis 4 Buchstaben bestehen.
+TEAM_KUERZEL_LENGTH=§cEin Teamkürzel muss aus 2 bis 4 Buchstaben bestehen.
TEAM_KUERZEL_TAKEN=§cEs gibt bereits ein Team mit diesem Namen.
#Team Name
TEAM_NAME_USAGE=§8/§7team changename §8[§eTeamname§8]
TEAM_NAME_CHANGED=§7Du hast das Team umbenannt!
-TEAM_NAME_LENGHT=§cEin Teamname muss aus 4 bis 15 Buchstaben bestehen.
+TEAM_NAME_LENGTH=§cEin Teamname muss aus 4 bis 15 Buchstaben bestehen.
TEAM_NAME_TAKEN=§cEs gibt bereits ein Team mit diesem Namen.
#Team Leader
diff --git a/src/de/steamwar/messages/ChatSender.java b/src/de/steamwar/messages/ChatSender.java
index 5b79204..65834f6 100644
--- a/src/de/steamwar/messages/ChatSender.java
+++ b/src/de/steamwar/messages/ChatSender.java
@@ -21,7 +21,7 @@ package de.steamwar.messages;
import de.steamwar.bungeecore.*;
import de.steamwar.bungeecore.bot.listeners.DiscordChatListener;
-import de.steamwar.bungeecore.sql.SteamwarUser;
+import de.steamwar.sql.SteamwarUser;
import net.md_5.bungee.api.ChatMessageType;
import net.md_5.bungee.api.CommandSender;
import net.md_5.bungee.api.ProxyServer;
diff --git a/src/de/steamwar/sql/SQLWrapperImpl.java b/src/de/steamwar/sql/SQLWrapperImpl.java
index f564ff2..176dfd4 100644
--- a/src/de/steamwar/sql/SQLWrapperImpl.java
+++ b/src/de/steamwar/sql/SQLWrapperImpl.java
@@ -20,6 +20,7 @@
package de.steamwar.sql;
import de.steamwar.bungeecore.BungeeCore;
+import de.steamwar.bungeecore.commands.CheckCommand;
import net.md_5.bungee.api.ProxyServer;
import net.md_5.bungee.api.config.ServerInfo;
import net.md_5.bungee.api.connection.ProxiedPlayer;
@@ -29,12 +30,28 @@ 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.Arrays;
+import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
public class SQLWrapperImpl implements SQLWrapper {
+
+ private static final SimpleDateFormat deadlineFormat = new SimpleDateFormat("dd.MM.yyyy HH:mm");
+ private static Date parseDeadline(String deadline) {
+ if(deadline == null)
+ return null;
+
+ try {
+ return deadlineFormat.parse(deadline);
+ } catch (ParseException e) {
+ throw new SecurityException(e.getMessage(), e);
+ }
+ }
+
@Override
public void loadSchemTypes(List tmpTypes, Map tmpFromDB) {
File folder = new File(BungeeCore.get().getDataFolder().getParentFile(), "FightSystem");
@@ -63,11 +80,14 @@ public class SQLWrapperImpl implements SQLWrapper {
checktype = new SchematicType("C" + type, "C" + shortcut, SchematicType.Type.CHECK_TYPE, null, material);
tmpTypes.add(checktype);
tmpFromDB.put(checktype.toDB(), checktype);
+ CheckCommand.setCheckQuestions(checktype, config);
}
- SchematicType current = new SchematicType(type, shortcut, !config.contains("Server") ? SchematicType.Type.FIGHT_TYPE : SchematicType.Type.NORMAL, checktype, material);
+ SchematicType current = new SchematicType(type, shortcut, !config.contains("Server") ? SchematicType.Type.FIGHT_TYPE : SchematicType.Type.NORMAL, checktype, material, parseDeadline(config.getString("deadline", null)));
tmpTypes.add(current);
tmpFromDB.put(type.toLowerCase(), current);
+ if(checktype != null)
+ CheckCommand.addFightType(checktype, current);
}
}
}
diff --git a/src/de/steamwar/sql/SchematicData.java b/src/de/steamwar/sql/SchematicData.java
new file mode 100644
index 0000000..6152ad9
--- /dev/null
+++ b/src/de/steamwar/sql/SchematicData.java
@@ -0,0 +1,47 @@
+/*
+ * This file is a part of the SteamWar software.
+ *
+ * Copyright (C) 2023 SteamWar.de-Serverteam
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ */
+
+package de.steamwar.sql;
+
+import de.steamwar.sql.internal.SqlTypeMapper;
+import de.steamwar.sql.internal.Statement;
+
+import java.io.BufferedInputStream;
+import java.io.InputStream;
+import java.sql.PreparedStatement;
+
+public class SchematicData {
+
+ static {
+ new SqlTypeMapper<>(BufferedInputStream.class, "BLOB", (rs, identifier) -> { throw new SecurityException("PipedInputStream is write only datatype"); }, PreparedStatement::setBinaryStream);
+ }
+
+ private static final Statement updateDatabase = new Statement("UPDATE SchematicNode SET NodeData = ?, NodeFormat = ? WHERE NodeId = ?");
+
+ private final SchematicNode node;
+
+ public SchematicData(SchematicNode node) {
+ this.node = node;
+ }
+
+ public void saveFromStream(InputStream blob, boolean newFormat) {
+ updateDatabase.update(new BufferedInputStream(blob), newFormat, node.getId());
+ node.setNodeFormat(newFormat);
+ }
+}
\ No newline at end of file