Add custom Branding for Bungee
Dieser Commit ist enthalten in:
Ursprung
956339faf6
Commit
ea9a98ec11
@ -84,6 +84,7 @@ public class BungeeCore extends Plugin {
|
||||
new CheckListener();
|
||||
new ModLoaderBlocker();
|
||||
new WorldDownloader();
|
||||
new BrandListener();
|
||||
|
||||
commands.put("/b", null);
|
||||
commands.put("/gs", null);
|
||||
|
66
src/de/steamwar/bungeecore/listeners/BrandListener.java
Normale Datei
66
src/de/steamwar/bungeecore/listeners/BrandListener.java
Normale Datei
@ -0,0 +1,66 @@
|
||||
/*
|
||||
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;
|
||||
|
||||
import de.steamwar.bungeecore.BungeeCore;
|
||||
import de.steamwar.bungeecore.Message;
|
||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.ByteBufAllocator;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
import net.md_5.bungee.api.event.PluginMessageEvent;
|
||||
import net.md_5.bungee.event.EventHandler;
|
||||
import net.md_5.bungee.protocol.DefinedPacket;
|
||||
import net.md_5.bungee.protocol.ProtocolConstants;
|
||||
import net.md_5.bungee.protocol.packet.PluginMessage;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public class BrandListener extends BasicListener {
|
||||
|
||||
@EventHandler
|
||||
public void onServerSwitch(PluginMessageEvent event) {
|
||||
if(event.getTag().equals("minecraft:brand") || event.getTag().equals("MC|Brand")) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(event.getReceiver().getAddress().getHostName().contains("localhost")) {
|
||||
return;
|
||||
}
|
||||
|
||||
BungeeCore.get().getProxy().getScheduler().schedule(BungeeCore.get(), () -> {
|
||||
ProxiedPlayer player = (ProxiedPlayer) event.getReceiver();
|
||||
SteamwarUser user = SteamwarUser.get(player);
|
||||
|
||||
String channel = player.getPendingConnection().getVersion() >= ProtocolConstants.MINECRAFT_1_13 ? "minecraft:brand" : "MC|Brand";
|
||||
StringBuilder serverBrand = new StringBuilder();
|
||||
for (byte b:event.getData()) {
|
||||
serverBrand.append((char) b);
|
||||
}
|
||||
|
||||
String brandString = Message.parse("STEAMWAR_BRAND", player, user.getUserGroup().getColorCode(), player.getName(), BungeeCore.get().getProxy().getName(), player.getServer().getInfo().getName(), serverBrand.substring(1));
|
||||
|
||||
ByteBuf brand = ByteBufAllocator.DEFAULT.heapBuffer();
|
||||
DefinedPacket.writeString(brandString, brand);
|
||||
player.sendData(channel, DefinedPacket.toArray(brand));
|
||||
brand.release();
|
||||
}, 50, TimeUnit.MILLISECONDS);
|
||||
}
|
||||
}
|
@ -7,6 +7,8 @@ UNKNOWN_PLAYER=§cDiesen Spieler gibt es nicht.
|
||||
UNKNOWN_TEAM=§cDieses Team gibt es nicht.
|
||||
INVALID_TIME=§cUngültige Zeitangabe.
|
||||
|
||||
STEAMWAR_BRAND={0}{1} §r<- §eSteam§8War.de §7({2}) §r<- §e{3} §7({4})§r
|
||||
|
||||
#ModLoader blocker
|
||||
MODLOADER_INSTALLED=§7Du hast §e{0} §7installiert. Daher kannst du keinen Arenen beitreten.
|
||||
MODLOADER_DENIED=§cMit Fabric, Forge und LiteLoader kannst du keinen Arenen beitreten.
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren