Merge branch 'master' into port_to_commandframework
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Dieser Commit ist enthalten in:
Commit
dfcb754a83
@ -164,6 +164,8 @@ public class BungeeCore extends Plugin {
|
|||||||
new CalendarCommand();
|
new CalendarCommand();
|
||||||
new CalendarListener();
|
new CalendarListener();
|
||||||
|
|
||||||
|
new ModCommand();
|
||||||
|
|
||||||
// Punishment Commands:
|
// Punishment Commands:
|
||||||
new PunishmentCommand("ban", Punishment.PunishmentType.Ban);
|
new PunishmentCommand("ban", Punishment.PunishmentType.Ban);
|
||||||
new PunishmentCommand("mute", Punishment.PunishmentType.Mute);
|
new PunishmentCommand("mute", Punishment.PunishmentType.Mute);
|
||||||
|
@ -72,7 +72,7 @@ public class PrivateMessageListener extends BasicDiscordListener {
|
|||||||
event.getMessage().reply("`" + name + "` wurde erfolgreich hochgeladen").queue();
|
event.getMessage().reply("`" + name + "` wurde erfolgreich hochgeladen").queue();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
event.getMessage().reply("`" + name + "` konnte nicht hochgeladen werden, bitte versuche es später nochmal oder wende dich an einen Developer").queue();
|
event.getMessage().reply("`" + name + "` konnte nicht hochgeladen werden, bitte versuche es später nochmal oder wende dich an einen Developer").queue();
|
||||||
BungeeCore.log("Could not Upload Schem \"" + name + "\" from User \"" + user.getUserName() + "\"" + e);
|
BungeeCore.log("Could not Upload Schem \"" + name + "\" from User \"" + user.getUserName() + "\"", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,6 @@ import de.steamwar.bungeecore.sql.SchematicType;
|
|||||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||||
import de.steamwar.command.SWCommand;
|
import de.steamwar.command.SWCommand;
|
||||||
import net.md_5.bungee.api.ChatColor;
|
import net.md_5.bungee.api.ChatColor;
|
||||||
import net.md_5.bungee.api.CommandSender;
|
|
||||||
import net.md_5.bungee.api.ProxyServer;
|
import net.md_5.bungee.api.ProxyServer;
|
||||||
import net.md_5.bungee.api.chat.ClickEvent;
|
import net.md_5.bungee.api.chat.ClickEvent;
|
||||||
import net.md_5.bungee.api.chat.TextComponent;
|
import net.md_5.bungee.api.chat.TextComponent;
|
||||||
@ -37,7 +36,6 @@ import net.md_5.bungee.config.Configuration;
|
|||||||
|
|
||||||
import java.sql.Timestamp;
|
import java.sql.Timestamp;
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
import java.time.format.DateTimeFormatter;
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
@ -265,43 +263,47 @@ public class CheckCommand extends SWCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void accept(int rank){
|
private void accept(int rank){
|
||||||
if(ranks.containsKey(schematic.getSchemtype())){
|
if(createLog("freigegeben")) {
|
||||||
if(rank <= 0 || ranks.get(schematic.getSchemtype()).size() < rank){
|
if(ranks.containsKey(schematic.getSchemtype())){
|
||||||
Message.send("CHECK_INVALID_RANK", checker);
|
if(rank <= 0 || ranks.get(schematic.getSchemtype()).size() < rank){
|
||||||
return;
|
Message.send("CHECK_INVALID_RANK", checker);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
schematic.setRank(rank);
|
||||||
}
|
}
|
||||||
schematic.setRank(rank);
|
|
||||||
|
schematic.setType(schematic.getSchemtype().fightType().toDB());
|
||||||
|
SteamwarUser user = SteamwarUser.get(schematic.getOwner());
|
||||||
|
ProxiedPlayer player = ProxyServer.getInstance().getPlayer(user.getUuid());
|
||||||
|
if(player != null) {
|
||||||
|
Message.send("CHECK_ACCEPTED", player, schematic.getSchemtype().name(), schematic.getName());
|
||||||
|
} else {
|
||||||
|
DiscordSchemAlert.sendAccept(schematic, user);
|
||||||
|
}
|
||||||
|
Message.team("CHECK_ACCEPTED_TEAM", schematic.getName(), user.getUserName());
|
||||||
}
|
}
|
||||||
|
|
||||||
schematic.setType(schematic.getSchemtype().fightType().toDB());
|
|
||||||
CheckedSchematic.create(schematic, SteamwarUser.get(checker.getUniqueId()).getId(), startTime, Timestamp.from(Instant.now()), "freigegeben");
|
|
||||||
SteamwarUser user = SteamwarUser.get(schematic.getOwner());
|
|
||||||
ProxiedPlayer player = ProxyServer.getInstance().getPlayer(user.getUuid());
|
|
||||||
if(player != null) {
|
|
||||||
Message.send("CHECK_ACCEPTED", player, schematic.getSchemtype().name(), schematic.getName());
|
|
||||||
} else {
|
|
||||||
DiscordSchemAlert.sendAccept(schematic, user);
|
|
||||||
}
|
|
||||||
Message.team("CHECK_ACCEPTED_TEAM", schematic.getName(), user.getUserName());
|
|
||||||
stop();
|
stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void decline(String reason){
|
private void decline(String reason){
|
||||||
CheckedSchematic.create(schematic, SteamwarUser.get(checker.getUniqueId()).getId(), startTime, Timestamp.from(Instant.now()), reason);
|
if(createLog(reason)) {
|
||||||
SteamwarUser user = SteamwarUser.get(schematic.getOwner());
|
SteamwarUser user = SteamwarUser.get(schematic.getOwner());
|
||||||
ProxiedPlayer player = ProxyServer.getInstance().getPlayer(user.getUuid());
|
ProxiedPlayer player = ProxyServer.getInstance().getPlayer(user.getUuid());
|
||||||
if(player != null) {
|
if(player != null) {
|
||||||
Message.send("CHECK_DECLINED", player, schematic.getSchemtype().name(), schematic.getName(), reason);
|
Message.send("CHECK_DECLINED", player, schematic.getSchemtype().name(), schematic.getName(), reason);
|
||||||
} else {
|
} else {
|
||||||
DiscordSchemAlert.sendDecline(schematic, user, reason);
|
DiscordSchemAlert.sendDecline(schematic, user, reason);
|
||||||
|
}
|
||||||
|
Message.team("CHECK_DECLINED_TEAM", schematic.getName(), user.getUserName(), reason);
|
||||||
|
schematic.setType(SchematicType.Normal.toDB());
|
||||||
}
|
}
|
||||||
Message.team("CHECK_DECLINED_TEAM", schematic.getName(), user.getUserName(), reason);
|
|
||||||
schematic.setType(SchematicType.Normal.toDB());
|
|
||||||
stop();
|
stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void abort(){
|
private void abort(){
|
||||||
CheckedSchematic.create(schematic, SteamwarUser.get(checker.getUniqueId()).getId(), startTime, Timestamp.from(Instant.now()), "Prüfvorgang abgebrochen");
|
createLog("Prüfvorgang abgebrochen");
|
||||||
stop();
|
stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -322,5 +324,13 @@ public class CheckCommand extends SWCommand {
|
|||||||
currentCheckers.remove(checker.getUniqueId());
|
currentCheckers.remove(checker.getUniqueId());
|
||||||
currentSchems.remove(schematic.getId());
|
currentSchems.remove(schematic.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean createLog(String reason) {
|
||||||
|
if(SchematicNode.getSchematicNode(schematic.getId()) == null) // Schematic was deleted
|
||||||
|
return false;
|
||||||
|
|
||||||
|
CheckedSchematic.create(schematic, SteamwarUser.get(checker.getUniqueId()).getId(), startTime, Timestamp.from(Instant.now()), reason);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
147
src/de/steamwar/bungeecore/commands/ModCommand.java
Normale Datei
147
src/de/steamwar/bungeecore/commands/ModCommand.java
Normale Datei
@ -0,0 +1,147 @@
|
|||||||
|
/*
|
||||||
|
This file is a part of the SteamWar software.
|
||||||
|
|
||||||
|
Copyright (C) 2023 SteamWar.de-Serverteam
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Affero General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU Affero General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Affero General Public License
|
||||||
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package de.steamwar.bungeecore.commands;
|
||||||
|
|
||||||
|
import de.steamwar.bungeecore.Message;
|
||||||
|
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 net.md_5.bungee.api.chat.ClickEvent;
|
||||||
|
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
public class ModCommand extends SWCommand {
|
||||||
|
|
||||||
|
public ModCommand() {
|
||||||
|
super("mod", "bungeecore.softreload", "mods");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final Map<ProxiedPlayer,Mod.ModType> playerFilterType = new HashMap<>();
|
||||||
|
|
||||||
|
@Register
|
||||||
|
public void genericCommand(ProxiedPlayer p) {
|
||||||
|
playerFilterType.putIfAbsent(p,Mod.ModType.UNKLASSIFIED);
|
||||||
|
openGui(p);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void openGui(ProxiedPlayer p) {
|
||||||
|
SWStreamInv<Mod> swStreamInv = new SWStreamInv<>(p,Message.parse("MOD_COMMAND_GUI_TITLE",p), (click, element) -> {
|
||||||
|
openClassificationGui(p,element);
|
||||||
|
},page -> {
|
||||||
|
Mod.ModType filtertype = playerFilterType.get(p);
|
||||||
|
return Mod.getAllModsFiltered(page,45, filtertype).stream().map(mod -> new SWListInv.SWListEntry<>(getModItem(mod),mod)).collect(Collectors.toList());
|
||||||
|
});
|
||||||
|
|
||||||
|
swStreamInv.addItem(52,new SWItem("NAME_TAG","Filter"), click -> {
|
||||||
|
swStreamInv.close();
|
||||||
|
openFilterGui(p);
|
||||||
|
});
|
||||||
|
|
||||||
|
swStreamInv.open();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updateAndCloseGui(Mod.ModType modType, Mod mod, SWInventory toClose, ProxiedPlayer p) {
|
||||||
|
mod.setModType(modType);
|
||||||
|
toClose.close();
|
||||||
|
openGui(p);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void openFilterGui(ProxiedPlayer p) {
|
||||||
|
SWInventory inv = new SWInventory(p, 9, "Filter");
|
||||||
|
|
||||||
|
inv.addItem(1, new SWItem(Message.parse("MOD_UNCLASSIFIED",p),8), click -> playerFilterType.replace(p, Mod.ModType.UNKLASSIFIED));
|
||||||
|
inv.addItem(2, new SWItem(Message.parse("MOD_ALLOWED",p),2), click -> playerFilterType.replace(p, Mod.ModType.GREEN));
|
||||||
|
inv.addItem(3, new SWItem(Message.parse("MOD_FORBIDDEN",p), 11), click -> playerFilterType.replace(p, Mod.ModType.YELLOW));
|
||||||
|
inv.addItem(4, new SWItem(Message.parse("MOD_AUTOBAN",p),1), click -> playerFilterType.replace(p, Mod.ModType.RED));
|
||||||
|
inv.addItem(5, new SWItem(Message.parse("MOD_YT",p),13), click -> playerFilterType.replace(p, Mod.ModType.YOUTUBER_ONLY));
|
||||||
|
|
||||||
|
inv.addItem(8, new SWItem("ARROW", Message.parse("MOD_ITEM_BACK",p)), click -> {
|
||||||
|
inv.close();
|
||||||
|
openGui(p);
|
||||||
|
});
|
||||||
|
|
||||||
|
inv.open();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void openClassificationGui(ProxiedPlayer p,Mod element) {
|
||||||
|
SWInventory swInventory = new SWInventory(p,9,Message.parse("MOD_COMMAND_CLASSICIATION_GUI",p));
|
||||||
|
|
||||||
|
swInventory.addItem(2, new SWItem(Message.parse("MOD_UNCLASSIFIED",p),8), (click1 -> updateAndCloseGui(Mod.ModType.UNKLASSIFIED,element,swInventory,p)));
|
||||||
|
swInventory.addItem(3, new SWItem(Message.parse("MOD_ALLOWED",p), 2), (click1 -> updateAndCloseGui(Mod.ModType.GREEN,element,swInventory,p)));
|
||||||
|
swInventory.addItem(4, new SWItem(Message.parse("MOD_FORBIDDEN",p), 11), (click1 -> updateAndCloseGui(Mod.ModType.YELLOW,element,swInventory,p)));
|
||||||
|
swInventory.addItem(5, new SWItem(Message.parse("MOD_AUTOBAN",p),1), (click1 -> updateAndCloseGui(Mod.ModType.RED,element,swInventory,p)));
|
||||||
|
swInventory.addItem(6, new SWItem(Message.parse("MOD_YT",p), 13), (click1 -> updateAndCloseGui(Mod.ModType.YOUTUBER_ONLY,element,swInventory,p)));
|
||||||
|
|
||||||
|
swInventory.addItem(8,new SWItem("ARROW",Message.parse("MOD_ITEM_BACK",p)), click1 -> {
|
||||||
|
swInventory.close();
|
||||||
|
openGui(p);
|
||||||
|
});
|
||||||
|
|
||||||
|
swInventory.open();
|
||||||
|
}
|
||||||
|
|
||||||
|
private SWItem getModItem(Mod modEntry) {
|
||||||
|
SWItem item = new SWItem("NAME_TAG", modEntry.getModName());
|
||||||
|
|
||||||
|
item.addLore(modEntry.getPlatform().name());
|
||||||
|
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Register(value = {"set"},description = "MOD_COMMAND_SET_USAGE")
|
||||||
|
public void set(ProxiedPlayer p,String modName,Mod.Platform platform,Mod.ModType newModType) {
|
||||||
|
Mod mod = Mod.get(modName, platform);
|
||||||
|
if(mod == null) {
|
||||||
|
Message.send("MOD_COMMAND_NOT_FOUND_IN_DATABASE",p,modName, platform.name());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
mod.setModType(newModType);
|
||||||
|
Message.send("MOD_CHANGED_TYPE",p,modName,platform.name(),newModType.name());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Register(value = {"get"},description = "MOD_COMMAND_GET_USAGE")
|
||||||
|
public void get(ProxiedPlayer p,String modName,Mod.Platform platform) {
|
||||||
|
Mod mod = Mod.get(modName, platform);
|
||||||
|
if(mod == null) {
|
||||||
|
Message.send("MOD_COMMAND_NOT_FOUND_IN_DATABASE", p, modName, platform.name());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Message.send("MOD_COMMAND_INFO", p, modName, platform.name(), mod.getModType().name());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Register(value = {"next"})
|
||||||
|
public void next(ProxiedPlayer p) {
|
||||||
|
Mod mod = Mod.findFirstMod();
|
||||||
|
if(mod == null) {
|
||||||
|
Message.send("MOD_NO_MORE_UNCLASSIFIED_MODS",p);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Message.send("MOD_FOUND_NEXT_MOD",p,"MOD_OPEN_GUI",new ClickEvent(ClickEvent.Action.RUN_COMMAND,""),mod.getModName(),mod.getPlatform().name());
|
||||||
|
}
|
||||||
|
}
|
@ -27,6 +27,7 @@ import de.steamwar.bungeecore.bot.config.SteamwarDiscordBotConfig;
|
|||||||
import de.steamwar.bungeecore.bot.util.DiscordRanks;
|
import de.steamwar.bungeecore.bot.util.DiscordRanks;
|
||||||
import de.steamwar.bungeecore.commands.ChallengeCommand;
|
import de.steamwar.bungeecore.commands.ChallengeCommand;
|
||||||
import de.steamwar.bungeecore.commands.CheckCommand;
|
import de.steamwar.bungeecore.commands.CheckCommand;
|
||||||
|
import de.steamwar.bungeecore.commands.ModCommand;
|
||||||
import de.steamwar.bungeecore.commands.MsgCommand;
|
import de.steamwar.bungeecore.commands.MsgCommand;
|
||||||
import de.steamwar.bungeecore.listeners.mods.Utils;
|
import de.steamwar.bungeecore.listeners.mods.Utils;
|
||||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||||
@ -137,6 +138,7 @@ public class ConnectionListener extends BasicListener {
|
|||||||
ChallengeCommand.remove(e.getPlayer());
|
ChallengeCommand.remove(e.getPlayer());
|
||||||
MsgCommand.remove(e.getPlayer());
|
MsgCommand.remove(e.getPlayer());
|
||||||
Utils.playerModMap.remove(e.getPlayer().getUniqueId());
|
Utils.playerModMap.remove(e.getPlayer().getUniqueId());
|
||||||
|
ModCommand.playerFilterType.remove(e.getPlayer());
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
|
@ -119,15 +119,11 @@ public class Fabric extends BasicListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for(JsonElement mod : array) {
|
for(JsonElement mod : array) {
|
||||||
mods.add(Mod.get(mod.getAsString(), Mod.Platform.FABRIC));
|
mods.add(Mod.getOrCreate(mod.getAsString(), Mod.Platform.FABRIC));
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!neededModsContained(mods)) {
|
boolean neededMods = neededModsContained(mods);
|
||||||
logMessage(user, "Needed mods are not contained", dataString);
|
if(Utils.handleMods(player,mods) && neededMods) {
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(Utils.handleMods(player,mods)) {
|
|
||||||
if (Storage.fabricCheckedPlayers.containsKey(player)) {
|
if (Storage.fabricCheckedPlayers.containsKey(player)) {
|
||||||
long current = Storage.fabricCheckedPlayers.get(player);
|
long current = Storage.fabricCheckedPlayers.get(player);
|
||||||
if (current != dataString.hashCode()) {
|
if (current != dataString.hashCode()) {
|
||||||
@ -139,6 +135,8 @@ public class Fabric extends BasicListener {
|
|||||||
Storage.fabricCheckedPlayers.put(player, dataString.hashCode());
|
Storage.fabricCheckedPlayers.put(player, dataString.hashCode());
|
||||||
}
|
}
|
||||||
Storage.fabricPlayers.remove(player);
|
Storage.fabricPlayers.remove(player);
|
||||||
|
} else if (!neededMods) {
|
||||||
|
logMessage(user, "Needed mods are not contained", dataString);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,9 +26,7 @@ import io.netty.channel.ChannelPipeline;
|
|||||||
import net.md_5.bungee.api.chat.TextComponent;
|
import net.md_5.bungee.api.chat.TextComponent;
|
||||||
import net.md_5.bungee.api.connection.PendingConnection;
|
import net.md_5.bungee.api.connection.PendingConnection;
|
||||||
import net.md_5.bungee.api.event.LoginEvent;
|
import net.md_5.bungee.api.event.LoginEvent;
|
||||||
import net.md_5.bungee.api.event.ProxyPingEvent;
|
|
||||||
import net.md_5.bungee.connection.InitialHandler;
|
import net.md_5.bungee.connection.InitialHandler;
|
||||||
import net.md_5.bungee.event.EventHandler;
|
|
||||||
import net.md_5.bungee.netty.ChannelWrapper;
|
import net.md_5.bungee.netty.ChannelWrapper;
|
||||||
import net.md_5.bungee.netty.HandlerBoss;
|
import net.md_5.bungee.netty.HandlerBoss;
|
||||||
import net.md_5.bungee.netty.PacketHandler;
|
import net.md_5.bungee.netty.PacketHandler;
|
||||||
@ -135,7 +133,7 @@ public class Forge extends BasicListener {
|
|||||||
Utils.VarInt nameLength = Utils.readVarInt(data, pos);
|
Utils.VarInt nameLength = Utils.readVarInt(data, pos);
|
||||||
pos += nameLength.length;
|
pos += nameLength.length;
|
||||||
|
|
||||||
mods.add(Mod.get(new String(data, pos, nameLength.value), Mod.Platform.FORGE));
|
mods.add(Mod.getOrCreate(new String(data, pos, nameLength.value), Mod.Platform.FORGE));
|
||||||
pos += nameLength.value;
|
pos += nameLength.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -92,7 +92,7 @@ public class Forge12 extends BasicListener {
|
|||||||
//Version information is unused
|
//Version information is unused
|
||||||
bytePos += 1 + data[bytePos];
|
bytePos += 1 + data[bytePos];
|
||||||
|
|
||||||
mods.add(Mod.get(new String(name), Mod.Platform.FORGE));
|
mods.add(Mod.getOrCreate(new String(name), Mod.Platform.FORGE));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Utils.handleMods(p, mods)) {
|
if (Utils.handleMods(p, mods)) {
|
||||||
|
@ -67,7 +67,7 @@ public class LabyMod extends BasicListener {
|
|||||||
try{
|
try{
|
||||||
InfoPacket info = new InfoPacket(value.value);
|
InfoPacket info = new InfoPacket(value.value);
|
||||||
for(InfoPacket.Addon addon : info.addons) {
|
for(InfoPacket.Addon addon : info.addons) {
|
||||||
mods.add(Mod.get(addon.name, Mod.Platform.LABYMOD));
|
mods.add(Mod.getOrCreate(addon.name, Mod.Platform.LABYMOD));
|
||||||
}
|
}
|
||||||
}catch(IOException e){
|
}catch(IOException e){
|
||||||
BungeeCore.log("Could not read JSON", e);
|
BungeeCore.log("Could not read JSON", e);
|
||||||
|
@ -28,6 +28,6 @@ public class WorldDownloader extends BasicListener {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
Utils.handleMods((ProxiedPlayer) sender, Lists.newArrayList(Mod.get("wdl", Mod.Platform.FORGE)));
|
Utils.handleMods((ProxiedPlayer) sender, Lists.newArrayList(Mod.getOrCreate("wdl", Mod.Platform.FORGE)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,11 +21,21 @@ package de.steamwar.bungeecore.sql;
|
|||||||
|
|
||||||
import de.steamwar.sql.internal.Statement;
|
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 {
|
public class Mod {
|
||||||
|
|
||||||
private static final Statement get = new Statement("SELECT * FROM Mods WHERE ModName = ? AND Platform = ?");
|
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 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 String modName;
|
||||||
private final Platform platform;
|
private final Platform platform;
|
||||||
private final ModType modType;
|
private final ModType modType;
|
||||||
@ -36,17 +46,48 @@ public class Mod {
|
|||||||
this.modType = modType;
|
this.modType = modType;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Mod get(String modName, Platform platform){
|
private Mod(ResultSet resultSet) throws SQLException {
|
||||||
Mod mod = get.select(rs -> {
|
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())
|
if(rs.next())
|
||||||
return new Mod(modName, platform, ModType.valueOf(rs.getInt("ModType")));
|
return new Mod(rs);
|
||||||
return null;
|
return null;
|
||||||
}, modName, platform.value);
|
}, name, platform.ordinal());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Mod getOrCreate(String name, Platform platform) {
|
||||||
|
Mod mod = get(name, platform);
|
||||||
if(mod != null)
|
if(mod != null)
|
||||||
return mod;
|
return mod;
|
||||||
|
|
||||||
insert.update(modName, platform.value);
|
insert.update(name, platform.ordinal());
|
||||||
return new Mod(modName, platform, ModType.UNKLASSIFIED);
|
return new Mod(name, platform, ModType.UNKLASSIFIED);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setModType(Mod.ModType newModType) {
|
||||||
|
set.update(newModType.ordinal(), modName, platform.ordinal());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List<Mod> getAllModsFiltered(int page,int elementsPerPage, Mod.ModType filter) {
|
||||||
|
return Mod.getPageOfType.select(rs -> {
|
||||||
|
List<Mod> f = new ArrayList<>();
|
||||||
|
|
||||||
|
while(rs.next())
|
||||||
|
f.add(new Mod(rs));
|
||||||
|
|
||||||
|
return f;
|
||||||
|
},filter.ordinal(), page * elementsPerPage, elementsPerPage);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Mod findFirstMod() {
|
||||||
|
return findFirst.select(rs -> {
|
||||||
|
if(rs.next())
|
||||||
|
return new Mod(rs);
|
||||||
|
return null;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getModName() {
|
public String getModName() {
|
||||||
@ -62,40 +103,22 @@ public class Mod {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public enum Platform{
|
public enum Platform{
|
||||||
FORGE(0),
|
FORGE,
|
||||||
LABYMOD(1),
|
LABYMOD,
|
||||||
FABRIC(2);
|
FABRIC
|
||||||
|
|
||||||
Platform(int value){
|
|
||||||
this.value = value;
|
|
||||||
}
|
|
||||||
int value;
|
|
||||||
public int get() {
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum ModType {
|
public enum ModType {
|
||||||
UNKLASSIFIED(0,"7"),
|
UNKLASSIFIED("7"),
|
||||||
GREEN(1,"a"),
|
GREEN("a"),
|
||||||
YELLOW(2,"e"),
|
YELLOW("e"),
|
||||||
RED(3,"c"),
|
RED("c"),
|
||||||
YOUTUBER_ONLY(4,"6");
|
YOUTUBER_ONLY("6");
|
||||||
|
|
||||||
static ModType valueOf(int value){
|
ModType(String colorcode) {
|
||||||
for(ModType mt : values()){
|
|
||||||
if(value == mt.value)
|
|
||||||
return mt;
|
|
||||||
}
|
|
||||||
throw new EnumConstantNotPresentException(ModType.class, Integer.toString(value));
|
|
||||||
}
|
|
||||||
|
|
||||||
ModType(int value,String colorcode){
|
|
||||||
this.value = value;
|
|
||||||
this.colorcode = colorcode;
|
this.colorcode = colorcode;
|
||||||
}
|
}
|
||||||
int value;
|
private final String colorcode;
|
||||||
String colorcode;
|
|
||||||
|
|
||||||
public String getColorCode() {
|
public String getColorCode() {
|
||||||
return colorcode;
|
return colorcode;
|
||||||
|
@ -660,3 +660,21 @@ ADVENT_CALENDAR_DAY=§7Day§8: §e{0}
|
|||||||
ADVENT_CALENDAR_MESSAGE=§eDid you already open your advent calendar?
|
ADVENT_CALENDAR_MESSAGE=§eDid you already open your advent calendar?
|
||||||
ADVENT_CALENDAR_MESSAGE_HOVER=§eClick to open!
|
ADVENT_CALENDAR_MESSAGE_HOVER=§eClick to open!
|
||||||
ADVENT_CALENDAR_OPEN=§7You got §e{0} §7from the advent calendar!
|
ADVENT_CALENDAR_OPEN=§7You got §e{0} §7from the advent calendar!
|
||||||
|
|
||||||
|
#Mod Command
|
||||||
|
MOD_COMMAND_SET_USAGE=§7/mod set [mod name] [platform] [ModType 1-4]
|
||||||
|
MOD_COMMAND_GET_USAGE=§7/mod get [mod name] [platform]
|
||||||
|
MOD_CHANGED_TYPE=§7Successfully reclassified mod {0} on platform {1} to type {2}!
|
||||||
|
MOD_NO_MORE_UNCLASSIFIED_MODS=§7No more unclassified mods found in databank!
|
||||||
|
MOD_FOUND_NEXT_MOD=§7Next unclassified mod is {0} on platform {1}!
|
||||||
|
MOD_COMMAND_NOT_FOUND_IN_DATABASE=§7The Mod {0} on platform {1} was§c not §7found in the database!
|
||||||
|
MOD_COMMAND_INFO=§7The mod {0} on platform {1} is of the type {2}.
|
||||||
|
MOD_COMMAND_GUI_TITLE=Unclassified Mods
|
||||||
|
MOD_COMMAND_CLASSICIATION_GUI=Mod Type Changer
|
||||||
|
MOD_OPEN_GUI=§7Open Gui
|
||||||
|
MOD_UNCLASSIFIED=§7Unclassified
|
||||||
|
MOD_ALLOWED=§aAllowed
|
||||||
|
MOD_FORBIDDEN=§eForbidden
|
||||||
|
MOD_AUTOBAN=§cAutoban
|
||||||
|
MOD_YT=§5YT Only
|
||||||
|
MOD_ITEM_BACK=§7Back
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren