Dieser Commit ist enthalten in:
Ursprung
24075306fd
Commit
3ecd31c41e
@ -1,17 +1,40 @@
|
||||
/*
|
||||
This file is a part of the SteamWar software.
|
||||
|
||||
Copyright (C) 2020 SteamWar.de-Serverteam
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bungeecore.listeners.mods;
|
||||
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParser;
|
||||
import de.steamwar.bungeecore.BungeeCore;
|
||||
import de.steamwar.bungeecore.listeners.BasicListener;
|
||||
import de.steamwar.bungeecore.sql.Mod;
|
||||
import io.netty.util.internal.StringUtil;
|
||||
import net.md_5.bungee.api.connection.PendingConnection;
|
||||
import de.steamwar.bungeecore.sql.Punishment;
|
||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
import net.md_5.bungee.api.event.PluginMessageEvent;
|
||||
import net.md_5.bungee.event.EventHandler;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.sql.Timestamp;
|
||||
import java.time.Instant;
|
||||
import java.util.*;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class Fabric extends BasicListener {
|
||||
|
||||
@ -20,26 +43,50 @@ public class Fabric extends BasicListener {
|
||||
if(!e.getTag().equals("fabricmodsender:mods"))
|
||||
return;
|
||||
|
||||
String dataString = new String(e.getData()).substring(2);
|
||||
dataString = StringUtils.chop(dataString);
|
||||
char x = 34;
|
||||
dataString = dataString.replace(x, ' ');
|
||||
dataString = dataString.replaceAll("\\s+","");
|
||||
|
||||
String[] parts = dataString.split(",");
|
||||
|
||||
List<Mod> mods = new ArrayList<>();
|
||||
|
||||
for(String mod : parts) {
|
||||
mods.add(Mod.get(mod, Mod.Platform.FABRIC));
|
||||
if (!(e.getSender() instanceof ProxiedPlayer)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (e.getSender() instanceof ProxiedPlayer) {
|
||||
ProxiedPlayer player = (ProxiedPlayer) e.getSender();
|
||||
ProxiedPlayer player = (ProxiedPlayer) e.getSender();
|
||||
|
||||
if(!Utils.handleMods(player, mods))
|
||||
player.disconnect("");
|
||||
List<Mod> mods = new LinkedList<>();
|
||||
|
||||
String dataString = new String(e.getData()).substring(1);
|
||||
String dataString2 = "{:" + dataString + "}";
|
||||
|
||||
System.out.println(dataString2);
|
||||
|
||||
try {
|
||||
JsonArray array = new JsonParser().parse(dataString).getAsJsonArray();
|
||||
|
||||
for(int i = 0; i < array.size(); i++) {
|
||||
mods.add(Mod.get(array.get(i).getAsString(), Mod.Platform.FABRIC));
|
||||
}
|
||||
|
||||
boolean isSorted = isSortedAlphabetically(mods);
|
||||
|
||||
if(!isSorted) {
|
||||
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
|
||||
user.punish(Punishment.PunishmentType.Ban, Timestamp.from(Instant.now()), "§7Du hast probiert den FabricModSender zu umgehen!", 0, true);
|
||||
BungeeCore.log(Level.SEVERE, user.getUserName() + " " + user.getId() + " wurde automatisch gebannt, da er den FabricModSender editiert hatte");
|
||||
return;
|
||||
}
|
||||
|
||||
Utils.handleMods(player,mods);
|
||||
}catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
player.disconnect("§7Mod Verification failed! Contact a Developer");
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isSortedAlphabetically(List<Mod> mods) {
|
||||
boolean isSorted = true;
|
||||
for(int i = 0; i < mods.size() - 1; i++) {
|
||||
if(mods.get(i).getModName().compareToIgnoreCase(mods.get(i + 1).getModName()) > 0) {
|
||||
isSorted = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return isSorted;
|
||||
}
|
||||
}
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren