Merge pull request 'Add custom Branding for Bungee' (#203) from custom_brand into master
Reviewed-on: #203 Reviewed-by: YoyoNow <jwsteam@nidido.de>
Dieser Commit ist enthalten in:
Commit
b3594f7c4e
@ -84,6 +84,7 @@ public class BungeeCore extends Plugin {
|
|||||||
new CheckListener();
|
new CheckListener();
|
||||||
new ModLoaderBlocker();
|
new ModLoaderBlocker();
|
||||||
new WorldDownloader();
|
new WorldDownloader();
|
||||||
|
new BrandListener();
|
||||||
|
|
||||||
commands.put("/b", null);
|
commands.put("/b", null);
|
||||||
commands.put("/gs", null);
|
commands.put("/gs", null);
|
||||||
|
65
src/de/steamwar/bungeecore/listeners/BrandListener.java
Normale Datei
65
src/de/steamwar/bungeecore/listeners/BrandListener.java
Normale Datei
@ -0,0 +1,65 @@
|
|||||||
|
/*
|
||||||
|
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();
|
||||||
|
|
||||||
|
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, 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.
|
UNKNOWN_TEAM=§cDieses Team gibt es nicht.
|
||||||
INVALID_TIME=§cUngültige Zeitangabe.
|
INVALID_TIME=§cUngültige Zeitangabe.
|
||||||
|
|
||||||
|
STEAMWAR_BRAND=§eSteam§8War.de §7({0}) §r<- §e{1} §7({2})§r
|
||||||
|
|
||||||
#ModLoader blocker
|
#ModLoader blocker
|
||||||
MODLOADER_INSTALLED=§7Du hast §e{0} §7installiert. Daher kannst du keinen Arenen beitreten.
|
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.
|
MODLOADER_DENIED=§cMit Fabric, Forge und LiteLoader kannst du keinen Arenen beitreten.
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren