Archiviert
1
0

Add NonFabricFabricCheck

Dieser Commit ist enthalten in:
yoyosource 2023-02-17 17:13:46 +01:00
Ursprung e26ee5f389
Commit bc44380c32
4 geänderte Dateien mit 92 neuen und 1 gelöschten Zeilen

Datei anzeigen

@ -28,7 +28,10 @@ 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.*;
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.bungeecore.tablist.TablistManager;
import de.steamwar.command.SWCommandUtils;
import de.steamwar.command.SWTypeMapperCreator;
@ -102,6 +105,8 @@ public class BungeeCore extends Plugin {
});
BungeeCord.getInstance().getScheduler().schedule(this, TabCompletionCache::invalidateOldEntries, 1, 1, TimeUnit.SECONDS);
new NonFabricFabricCheck();
new SWScriptSyntaxForwarder();
new ConnectionListener();
new Forge();

Datei anzeigen

@ -0,0 +1,82 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2022 SteamWar.de-Serverteam
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.bungeecore.listeners;
import de.steamwar.bungeecore.BungeeCore;
import de.steamwar.bungeecore.Message;
import de.steamwar.bungeecore.Storage;
import net.md_5.bungee.BungeeCord;
import net.md_5.bungee.api.connection.Connection;
import net.md_5.bungee.api.connection.ProxiedPlayer;
import net.md_5.bungee.api.event.PlayerDisconnectEvent;
import net.md_5.bungee.api.event.PluginMessageEvent;
import net.md_5.bungee.api.event.PostLoginEvent;
import net.md_5.bungee.event.EventHandler;
import java.util.HashSet;
import java.util.Set;
import java.util.concurrent.TimeUnit;
public class NonFabricFabricCheck extends BasicListener {
private Set<ProxiedPlayer> usingFabric = new HashSet<>();
private Set<ProxiedPlayer> checking = new HashSet<>();
@EventHandler
public void pluginMessageEvent(PluginMessageEvent e) {
Connection sender = e.getSender();
if(!(sender instanceof ProxiedPlayer))
return;
if(!e.getTag().equals("minecraft:brand"))
return;
if(!new String(e.getData()).contains("vanilla")){
return;
}
ProxiedPlayer p = (ProxiedPlayer) sender;
BungeeCord.getInstance().getScheduler().schedule(BungeeCore.get(), () -> {
if (!p.isConnected()) return;
if (Storage.fabricCheckedPlayers.containsKey(p)) return;
checking.add(p);
p.sendData("fabric-screen-handler-api-v1:open_screen", new byte[] {0});
BungeeCord.getInstance().getScheduler().schedule(BungeeCore.get(), () -> checking.remove(p), 1, TimeUnit.SECONDS);
}, 30, TimeUnit.SECONDS);
}
@EventHandler
public void onPlayerPreLogin(PostLoginEvent e) {
if (usingFabric.contains(e.getPlayer())) {
e.getPlayer().disconnect(Message.parse("MOD_USE_MODSENDER", e.getPlayer()));
usingFabric.remove(e.getPlayer());
}
}
@EventHandler
public void onPlayerDisconnect(PlayerDisconnectEvent e) {
if (checking.contains(e.getPlayer())) {
usingFabric.add(e.getPlayer());
}
checking.remove(e.getPlayer());
}
}

Datei anzeigen

@ -116,6 +116,8 @@ MOD_RED_PLUR=Attempted use of mods:\n{0}
MOD_YELLOW_SING=§7Deactivate the mod §e{0}§7 to continue playing on §eSteam§8War§7.
MOD_YELLOW_PLUR=§7Deactivate the mods\n§e{0}\n§7to continue playing on §eSteam§8War§7.
MOD_USE_MODSENDER=§cPlease use the §c§lSteamWarModSender§c.
#Various commands
ALERT=§f{0}
STAT_SERVER=§7Server §e{0}§8: §7Below limit §e{1} §7Server count §e{2}

Datei anzeigen

@ -102,6 +102,8 @@ MOD_RED_PLUR=Versuchte Benutzung der Mods:\n{0}
MOD_YELLOW_SING=§7Deaktiviere den Mod §e{0}§7, um weiter auf §eSteam§8War §7spielen zu können.
MOD_YELLOW_PLUR=§7Deaktiviere die Mods\n§e{0}\n§7um weiter auf §eSteam§8War §7spielen zu können.
MOD_USE_MODSENDER=§cBitte nutze den §c§lSteamWarModSender§c.
#Various commands
STAT_SERVER=§7Server §e{0}§8: §7Startfähig §e{1} §7Serveranzahl §e{2}