BungeeCord Support

* Provides support for IP forwarding via BungeeCord.
* Treats Bungee as Online Mode.

By: md_5 <git@md-5.net>
This commit is contained in:
CraftBukkit/Spigot 2014-04-12 21:23:58 +10:00
parent 496995ccaa
commit 3d4c222263
11 changed files with 206 additions and 56 deletions

View File

@ -1,6 +1,17 @@
--- a/net/minecraft/network/Connection.java
+++ b/net/minecraft/network/Connection.java
@@ -114,6 +114,7 @@
@@ -96,6 +96,10 @@
private final Queue<Consumer<Connection>> pendingActions = Queues.newConcurrentLinkedQueue();
public Channel channel;
public SocketAddress address;
+ // Spigot Start
+ public java.util.UUID spoofedUUID;
+ public com.mojang.authlib.properties.Property[] spoofedProfile;
+ // Spigot End
@Nullable
private volatile PacketListener disconnectListener;
@Nullable
@@ -114,6 +118,7 @@
private volatile DisconnectionDetails delayedDisconnect;
@Nullable
BandwidthDebugMonitor bandwidthDebugMonitor;
@ -8,7 +19,7 @@
public Connection(PacketFlow side) {
this.receiving = side;
@@ -205,7 +206,7 @@
@@ -205,7 +210,7 @@
}
private static <T extends PacketListener> void genericsFtw(Packet<T> packet, PacketListener listener) {
@ -17,7 +28,7 @@
}
private void validateListener(ProtocolInfo<?> state, PacketListener listener) {
@@ -469,7 +470,7 @@
@@ -469,7 +474,7 @@
}
if (this.isConnected()) {
@ -26,7 +37,7 @@
this.disconnectionDetails = disconnectionInfo;
}
@@ -537,7 +538,7 @@
@@ -537,7 +542,7 @@
}
public void configurePacketHandler(ChannelPipeline pipeline) {

View File

@ -5,3 +5,13 @@
package net.minecraft.network.protocol.handshake;
import net.minecraft.network.FriendlyByteBuf;
@@ -11,7 +12,8 @@
private static final int MAX_HOST_LENGTH = 255;
private ClientIntentionPacket(FriendlyByteBuf buf) {
- this(buf.readVarInt(), buf.readUtf(255), buf.readUnsignedShort(), ClientIntent.byId(buf.readVarInt()));
+ // Spigot - increase max hostName length
+ this(buf.readVarInt(), buf.readUtf(Short.MAX_VALUE), buf.readUnsignedShort(), ClientIntent.byId(buf.readVarInt()));
}
private void write(FriendlyByteBuf buf) {

View File

@ -152,20 +152,33 @@
DedicatedServer.LOGGER.info("Default game type: {}", dedicatedserverproperties.gamemode);
InetAddress inetaddress = null;
@@ -156,6 +229,12 @@
@@ -155,11 +228,24 @@
DedicatedServer.LOGGER.warn("Perhaps a server is already running on that port?");
return false;
}
+
+ // CraftBukkit start
+ // this.setPlayerList(new DedicatedPlayerList(this, this.registries(), this.playerDataStorage)); // Spigot - moved up
+ this.server.loadPlugins();
+ this.server.enablePlugins(org.bukkit.plugin.PluginLoadOrder.STARTUP);
+ // CraftBukkit end
+
if (!this.usesAuthentication()) {
DedicatedServer.LOGGER.warn("**** SERVER IS RUNNING IN OFFLINE/INSECURE MODE!");
DedicatedServer.LOGGER.warn("The server will make no attempt to authenticate usernames. Beware.");
@@ -170,7 +249,7 @@
- DedicatedServer.LOGGER.warn("While this makes the game possible to play without internet access, it also opens up the ability for hackers to connect with any username they choose.");
+ // Spigot start
+ if (org.spigotmc.SpigotConfig.bungee) {
+ DedicatedServer.LOGGER.warn("Whilst this makes it possible to use BungeeCord, unless access to your server is properly restricted, it also opens up the ability for hackers to connect with any username they choose.");
+ DedicatedServer.LOGGER.warn("Please see http://www.spigotmc.org/wiki/firewall-guide/ for further information.");
+ } else {
+ DedicatedServer.LOGGER.warn("While this makes the game possible to play without internet access, it also opens up the ability for hackers to connect with any username they choose.");
+ }
+ // Spigot end
DedicatedServer.LOGGER.warn("To change this, set \"online-mode\" to \"true\" in the server.properties file.");
}
@@ -170,7 +256,7 @@
if (!OldUsersConverter.serverReadyAfterUserconversion(this)) {
return false;
} else {
@ -174,7 +187,7 @@
this.debugSampleSubscriptionTracker = new DebugSampleSubscriptionTracker(this.getPlayerList());
this.tickTimeLogger = new RemoteSampleLogger(TpsDebugDimensions.values().length, this.debugSampleSubscriptionTracker, RemoteDebugSampleType.TICK_TIME);
long i = Util.getNanos();
@@ -178,13 +257,13 @@
@@ -178,13 +264,13 @@
SkullBlockEntity.setup(this.services, this);
GameProfileCache.setUsesAuthentication(this.usesAuthentication());
DedicatedServer.LOGGER.info("Preparing level \"{}\"", this.getLevelIdName());
@ -190,7 +203,7 @@
}
if (dedicatedserverproperties.enableQuery) {
@@ -197,7 +276,7 @@
@@ -197,7 +283,7 @@
this.rconThread = RconThread.create(this);
}
@ -199,7 +212,7 @@
Thread thread1 = new Thread(new ServerWatchdog(this));
thread1.setUncaughtExceptionHandler(new DefaultUncaughtExceptionHandlerWithName(DedicatedServer.LOGGER));
@@ -293,6 +372,7 @@
@@ -293,6 +379,7 @@
this.queryThreadGs4.stop();
}
@ -207,7 +220,7 @@
}
@Override
@@ -302,8 +382,8 @@
@@ -302,8 +389,8 @@
}
@Override
@ -218,7 +231,7 @@
}
public void handleConsoleInput(String command, CommandSourceStack commandSource) {
@@ -311,12 +391,22 @@
@@ -311,12 +398,22 @@
}
public void handleConsoleInputs() {
@ -242,7 +255,7 @@
}
@Override
@@ -383,7 +473,7 @@
@@ -383,7 +480,7 @@
@Override
public boolean isUnderSpawnProtection(ServerLevel world, BlockPos pos, Player player) {
@ -251,7 +264,7 @@
return false;
} else if (this.getPlayerList().getOps().isEmpty()) {
return false;
@@ -541,16 +631,52 @@
@@ -541,16 +638,52 @@
@Override
public String getPluginNames() {
@ -308,7 +321,7 @@
}
public void storeUsingWhiteList(boolean useWhitelist) {
@@ -660,4 +786,15 @@
@@ -660,4 +793,15 @@
}
}
}

View File

@ -40,7 +40,7 @@
import net.minecraft.world.level.GameRules;
import net.minecraft.world.level.GameType;
import net.minecraft.world.level.Level;
@@ -192,12 +195,70 @@
@@ -192,11 +195,69 @@
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.AABB;
import net.minecraft.world.phys.BlockHitResult;
@ -50,7 +50,7 @@
import net.minecraft.world.phys.shapes.Shapes;
import net.minecraft.world.phys.shapes.VoxelShape;
import org.slf4j.Logger;
+
+// CraftBukkit start
+import com.mojang.datafixers.util.Pair;
+import java.util.Arrays;
@ -107,10 +107,9 @@
+import org.bukkit.inventory.InventoryView;
+import org.bukkit.inventory.SmithingInventory;
+// CraftBukkit end
+
public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl implements ServerGamePacketListener, ServerPlayerConnection, TickablePacketListener {
static final Logger LOGGER = LogUtils.getLogger();
@@ -247,7 +308,7 @@
private boolean waitingForSwitchToConfig;
@ -127,7 +126,7 @@
- this.chatMessageChain = new FutureChain(server);
+ this.chatMessageChain = new FutureChain(server.chatExecutor); // CraftBukkit - async chat
}
+
+ // CraftBukkit start - add fields and methods
+ private int lastTick = MinecraftServer.currentTick;
+ private int allowedPlayerTicks = 1;
@ -143,7 +142,7 @@
+ private float lastYaw = Float.MAX_VALUE;
+ private boolean justTeleported = false;
+ // CraftBukkit end
+
@Override
public void tick() {
+ org.bukkit.craftbukkit.SpigotTimings.playerConnectionTimer.startTiming(); // Spigot
@ -959,12 +958,10 @@
}
}
@@ -1564,8 +2066,123 @@
}
@@ -1566,6 +2068,121 @@
return false;
+ }
+
}
+ // CraftBukkit start - add method
+ public void chat(String s, PlayerChatMessage original, boolean async) {
+ if (s.isEmpty() || this.player.getChatVisibility() == ChatVisiblity.HIDDEN) {
@ -997,7 +994,7 @@
+
+ String message = String.format(queueEvent.getFormat(), queueEvent.getPlayer().getDisplayName(), queueEvent.getMessage());
+ if (((LazyPlayerSet) queueEvent.getRecipients()).isLazy()) {
+ if (originalFormat.equals(queueEvent.getFormat()) && originalMessage.equals(queueEvent.getMessage()) && queueEvent.getPlayer().getName().equalsIgnoreCase(queueEvent.getPlayer().getDisplayName())) {
+ if (!org.spigotmc.SpigotConfig.bungee && originalFormat.equals(queueEvent.getFormat()) && originalMessage.equals(queueEvent.getMessage()) && queueEvent.getPlayer().getName().equalsIgnoreCase(queueEvent.getPlayer().getDisplayName())) { // Spigot
+ ServerGamePacketListenerImpl.this.server.getPlayerList().broadcastChatMessage(original, ServerGamePacketListenerImpl.this.player, ChatType.bind(ChatType.CHAT, (Entity) ServerGamePacketListenerImpl.this.player));
+ return null;
+ }
@ -1033,7 +1030,7 @@
+
+ s = String.format(event.getFormat(), event.getPlayer().getDisplayName(), event.getMessage());
+ if (((LazyPlayerSet) event.getRecipients()).isLazy()) {
+ if (originalFormat.equals(event.getFormat()) && originalMessage.equals(event.getMessage()) && event.getPlayer().getName().equalsIgnoreCase(event.getPlayer().getDisplayName())) {
+ if (!org.spigotmc.SpigotConfig.bungee && originalFormat.equals(event.getFormat()) && originalMessage.equals(event.getMessage()) && event.getPlayer().getName().equalsIgnoreCase(event.getPlayer().getDisplayName())) { // Spigot
+ ServerGamePacketListenerImpl.this.server.getPlayerList().broadcastChatMessage(original, ServerGamePacketListenerImpl.this.player, ChatType.bind(ChatType.CHAT, (Entity) ServerGamePacketListenerImpl.this.player));
+ return;
+ }
@ -1049,8 +1046,8 @@
+ this.server.console.sendMessage(s);
+ }
+ }
}
+ }
+
+ private void handleCommand(String s) {
+ org.bukkit.craftbukkit.SpigotTimings.playerCommandTimer.startTiming(); // Spigot
+ if ( org.spigotmc.SpigotConfig.logCommands ) // Spigot
@ -1197,7 +1194,21 @@
this.send(new ClientboundPlayerChatPacket(message.link().sender(), message.link().index(), message.signature(), message.signedBody().pack(this.messageSignatureCache), message.unsignedContent(), message.filterMask(), params));
this.addPendingMessage(message);
}
@@ -1718,9 +2410,17 @@
@@ -1703,6 +2395,13 @@
return this.connection.getRemoteAddress();
}
+ // Spigot Start
+ public SocketAddress getRawAddress()
+ {
+ return this.connection.channel.remoteAddress();
+ }
+ // Spigot End
+
public void switchToConfig() {
this.waitingForSwitchToConfig = true;
this.removePlayerFromWorld();
@@ -1718,9 +2417,17 @@
@Override
public void handleInteract(ServerboundInteractPacket packet) {
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel());
@ -1215,7 +1226,7 @@
this.player.resetLastActionTime();
this.player.setShiftKeyDown(packet.isUsingSecondaryAction());
@@ -1733,20 +2433,58 @@
@@ -1733,20 +2440,58 @@
if (this.player.canInteractWithEntity(axisalignedbb, 3.0D)) {
packet.dispatch(new ServerboundInteractPacket.Handler() {
@ -1278,7 +1289,7 @@
}
}
@@ -1755,19 +2493,20 @@
@@ -1755,19 +2500,20 @@
@Override
public void onInteraction(InteractionHand hand) {
@ -1302,7 +1313,7 @@
label23:
{
if (entity instanceof AbstractArrow) {
@@ -1785,6 +2524,11 @@
@@ -1785,6 +2531,11 @@
}
ServerGamePacketListenerImpl.this.player.attack(entity);
@ -1314,7 +1325,7 @@
return;
}
}
@@ -1809,7 +2553,7 @@
@@ -1809,7 +2560,7 @@
case PERFORM_RESPAWN:
if (this.player.wonGame) {
this.player.wonGame = false;
@ -1323,7 +1334,7 @@
this.resetPosition();
CriteriaTriggers.CHANGED_DIMENSION.trigger(this.player, Level.END, Level.OVERWORLD);
} else {
@@ -1817,11 +2561,11 @@
@@ -1817,11 +2568,11 @@
return;
}
@ -1337,7 +1348,7 @@
}
}
break;
@@ -1834,15 +2578,21 @@
@@ -1834,15 +2585,21 @@
@Override
public void handleContainerClose(ServerboundContainerClosePacket packet) {
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel());
@ -1361,7 +1372,7 @@
this.player.containerMenu.sendAllDataToRemote();
} else if (!this.player.containerMenu.stillValid(this.player)) {
ServerGamePacketListenerImpl.LOGGER.debug("Player {} interacted with invalid menu {}", this.player, this.player.containerMenu);
@@ -1855,7 +2605,284 @@
@@ -1855,7 +2612,284 @@
boolean flag = packet.getStateId() != this.player.containerMenu.getStateId();
this.player.containerMenu.suppressRemoteUpdates();
@ -1647,7 +1658,7 @@
ObjectIterator objectiterator = Int2ObjectMaps.fastIterable(packet.getChangedSlots()).iterator();
while (objectiterator.hasNext()) {
@@ -1901,8 +2928,22 @@
@@ -1901,8 +2935,22 @@
return;
}
@ -1671,7 +1682,7 @@
if (containerrecipebook_a == RecipeBookMenu.PostPlaceAction.PLACE_GHOST_RECIPE) {
this.player.connection.send(new ClientboundPlaceGhostRecipePacket(this.player.containerMenu.containerId, craftingmanager_d.display().display()));
}
@@ -1917,6 +2958,7 @@
@@ -1917,6 +2965,7 @@
@Override
public void handleContainerButtonClick(ServerboundContainerButtonClickPacket packet) {
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel());
@ -1679,7 +1690,7 @@
this.player.resetLastActionTime();
if (this.player.containerMenu.containerId == packet.containerId() && !this.player.isSpectator()) {
if (!this.player.containerMenu.stillValid(this.player)) {
@@ -1945,7 +2987,44 @@
@@ -1945,7 +2994,44 @@
boolean flag1 = packet.slotNum() >= 1 && packet.slotNum() <= 45;
boolean flag2 = itemstack.isEmpty() || itemstack.getCount() <= itemstack.getMaxStackSize();
@ -1724,7 +1735,7 @@
if (flag1 && flag2) {
this.player.inventoryMenu.getSlot(packet.slotNum()).setByPlayer(itemstack);
this.player.inventoryMenu.setRemoteSlot(packet.slotNum(), itemstack);
@@ -1972,6 +3051,7 @@
@@ -1972,6 +3058,7 @@
}
private void updateSignText(ServerboundSignUpdatePacket packet, List<FilteredText> signText) {
@ -1732,7 +1743,7 @@
this.player.resetLastActionTime();
ServerLevel worldserver = this.player.serverLevel();
BlockPos blockposition = packet.getPos();
@@ -1993,7 +3073,17 @@
@@ -1993,7 +3080,17 @@
@Override
public void handlePlayerAbilities(ServerboundPlayerAbilitiesPacket packet) {
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel());
@ -1751,7 +1762,7 @@
}
@Override
@@ -2058,7 +3148,7 @@
@@ -2058,7 +3155,7 @@
if (!this.waitingForSwitchToConfig) {
throw new IllegalStateException("Client acknowledged config, but none was requested");
} else {
@ -1760,7 +1771,7 @@
}
}
@@ -2083,8 +3173,10 @@
@@ -2083,8 +3180,10 @@
});
}

View File

@ -1,6 +1,6 @@
--- a/net/minecraft/server/network/ServerHandshakePacketListenerImpl.java
+++ b/net/minecraft/server/network/ServerHandshakePacketListenerImpl.java
@@ -13,8 +13,17 @@
@@ -13,8 +13,22 @@
import net.minecraft.network.protocol.status.StatusProtocols;
import net.minecraft.server.MinecraftServer;
@ -11,6 +11,11 @@
+
public class ServerHandshakePacketListenerImpl implements ServerHandshakePacketListener {
+ // Spigot start
+ private static final com.google.gson.Gson gson = new com.google.gson.Gson();
+ static final java.util.regex.Pattern HOST_PATTERN = java.util.regex.Pattern.compile("[0-9a-f\\.:]{0,45}");
+ static final java.util.regex.Pattern PROP_PATTERN = java.util.regex.Pattern.compile("\\w{0,16}");
+ // Spigot end
+ // CraftBukkit start - add fields
+ private static final HashMap<InetAddress, Long> throttleTracker = new HashMap<InetAddress, Long>();
+ private static int throttleCounter = 0;
@ -18,7 +23,7 @@
private static final Component IGNORE_STATUS_REASON = Component.translatable("disconnect.ignoring_status_request");
private final MinecraftServer server;
private final Connection connection;
@@ -26,6 +35,7 @@
@@ -26,6 +40,7 @@
@Override
public void handleIntention(ClientIntentionPacket packet) {
@ -26,7 +31,7 @@
switch (packet.intention()) {
case LOGIN:
this.beginLogin(packet, false);
@@ -59,13 +69,47 @@
@@ -59,19 +74,78 @@
private void beginLogin(ClientIntentionPacket packet, boolean transfer) {
this.connection.setupOutboundProtocol(LoginProtocols.CLIENTBOUND);
@ -77,3 +82,34 @@
}
this.connection.send(new ClientboundLoginDisconnectPacket(ichatmutablecomponent));
this.connection.disconnect((Component) ichatmutablecomponent);
} else {
this.connection.setupInboundProtocol(LoginProtocols.SERVERBOUND, new ServerLoginPacketListenerImpl(this.server, this.connection, transfer));
+ // Spigot Start
+ String[] split = packet.hostName().split("\00");
+ if (org.spigotmc.SpigotConfig.bungee) {
+ if ( ( split.length == 3 || split.length == 4 ) && ( ServerHandshakePacketListenerImpl.HOST_PATTERN.matcher( split[1] ).matches() ) ) {
+ this.connection.hostname = split[0];
+ this.connection.address = new java.net.InetSocketAddress(split[1], ((java.net.InetSocketAddress) this.connection.getRemoteAddress()).getPort());
+ this.connection.spoofedUUID = com.mojang.util.UndashedUuid.fromStringLenient( split[2] );
+ } else
+ {
+ Component chatmessage = Component.literal("If you wish to use IP forwarding, please enable it in your BungeeCord config as well!");
+ this.connection.send(new ClientboundLoginDisconnectPacket(chatmessage));
+ this.connection.disconnect(chatmessage);
+ return;
+ }
+ if ( split.length == 4 )
+ {
+ this.connection.spoofedProfile = ServerHandshakePacketListenerImpl.gson.fromJson(split[3], com.mojang.authlib.properties.Property[].class);
+ }
+ } else if ( ( split.length == 3 || split.length == 4 ) && ( ServerHandshakePacketListenerImpl.HOST_PATTERN.matcher( split[1] ).matches() ) ) {
+ Component chatmessage = Component.literal("Unknown data in login hostname, did you forget to enable BungeeCord in spigot.yml?");
+ this.connection.send(new ClientboundLoginDisconnectPacket(chatmessage));
+ this.connection.disconnect(chatmessage);
+ return;
+ }
+ // Spigot End
}
}

View File

@ -99,7 +99,7 @@
+ @Override
+ public void run() {
+ try {
+ GameProfile gameprofile = UUIDUtil.createOfflineProfile(ServerLoginPacketListenerImpl.this.requestedUsername);
+ GameProfile gameprofile = ServerLoginPacketListenerImpl.this.createOfflineProfile(ServerLoginPacketListenerImpl.this.requestedUsername); // Spigot
+
+ ServerLoginPacketListenerImpl.this.callPlayerPreLoginEvents(gameprofile);
+ ServerLoginPacketListenerImpl.LOGGER.info("UUID of player {} is {}", gameprofile.getName(), gameprofile.getId());
@ -160,7 +160,7 @@
}
}
@@ -205,6 +281,12 @@
@@ -205,11 +281,17 @@
if (profileresult != null) {
GameProfile gameprofile = profileresult.profile();
@ -173,7 +173,19 @@
ServerLoginPacketListenerImpl.LOGGER.info("UUID of player {} is {}", gameprofile.getName(), gameprofile.getId());
ServerLoginPacketListenerImpl.this.startClientVerification(gameprofile);
} else if (ServerLoginPacketListenerImpl.this.server.isSingleplayer()) {
@@ -222,6 +304,11 @@
ServerLoginPacketListenerImpl.LOGGER.warn("Failed to verify username but will let them in anyway!");
- ServerLoginPacketListenerImpl.this.startClientVerification(UUIDUtil.createOfflineProfile(s1));
+ ServerLoginPacketListenerImpl.this.startClientVerification(ServerLoginPacketListenerImpl.this.createOfflineProfile(s1)); // Spigot
} else {
ServerLoginPacketListenerImpl.this.disconnect(Component.translatable("multiplayer.disconnect.unverified_username"));
ServerLoginPacketListenerImpl.LOGGER.error("Username '{}' tried to join with an invalid session", s1);
@@ -217,11 +299,16 @@
} catch (AuthenticationUnavailableException authenticationunavailableexception) {
if (ServerLoginPacketListenerImpl.this.server.isSingleplayer()) {
ServerLoginPacketListenerImpl.LOGGER.warn("Authentication servers are down but will let them in anyway!");
- ServerLoginPacketListenerImpl.this.startClientVerification(UUIDUtil.createOfflineProfile(s1));
+ ServerLoginPacketListenerImpl.this.startClientVerification(ServerLoginPacketListenerImpl.this.createOfflineProfile(s1)); // Spigot
} else {
ServerLoginPacketListenerImpl.this.disconnect(Component.translatable("multiplayer.disconnect.authservers_down"));
ServerLoginPacketListenerImpl.LOGGER.error("Couldn't verify username because servers are unavailable");
}
@ -242,7 +254,7 @@
this.connection.setupInboundProtocol(ConfigurationProtocols.SERVERBOUND, serverconfigurationpacketlistenerimpl);
serverconfigurationpacketlistenerimpl.startConfiguration();
@@ -264,12 +389,18 @@
@@ -264,12 +389,44 @@
@Override
public void handleCookieResponse(ServerboundCookieResponsePacket packet) {
@ -255,6 +267,32 @@
this.disconnect(ServerCommonPacketListenerImpl.DISCONNECT_UNEXPECTED_QUERY);
}
+ // Spigot start
+ protected GameProfile createOfflineProfile(String s) {
+ java.util.UUID uuid;
+ if ( this.connection.spoofedUUID != null )
+ {
+ uuid = this.connection.spoofedUUID;
+ } else
+ {
+ uuid = UUIDUtil.createOfflinePlayerUUID( s );
+ }
+
+ GameProfile gameProfile = new GameProfile( uuid, s );
+
+ if (this.connection.spoofedProfile != null)
+ {
+ for ( com.mojang.authlib.properties.Property property : this.connection.spoofedProfile )
+ {
+ if ( !ServerHandshakePacketListenerImpl.PROP_PATTERN.matcher( property.name()).matches() ) continue;
+ gameProfile.getProperties().put( property.name(), property );
+ }
+ }
+
+ return gameProfile;
+ }
+ // Spigot end
+
public static enum State {
- HELLO, KEY, AUTHENTICATING, NEGOTIATING, VERIFYING, WAITING_FOR_DUPE_DISCONNECT, PROTOCOL_SWITCHING, ACCEPTED;

View File

@ -10,6 +10,15 @@
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.dedicated.DedicatedServer;
import net.minecraft.util.StringUtil;
@@ -62,7 +65,7 @@
return new String[i];
});
- if (server.usesAuthentication()) {
+ if (server.usesAuthentication() || org.spigotmc.SpigotConfig.bungee) { // Spigot: bungee = online mode, for now.
server.getProfileRepository().findProfilesByNames(astring, callback);
} else {
String[] astring1 = astring;
@@ -85,7 +88,7 @@
try {
gameprofilebanlist.load();

View File

@ -431,7 +431,7 @@
+ ServerPlayer entity = new ServerPlayer(this.server, this.server.getLevel(Level.OVERWORLD), gameprofile, ClientInformation.createDefault());
+ entity.transferCookieConnection = loginlistener;
+ Player player = entity.getBukkitEntity();
+ PlayerLoginEvent event = new PlayerLoginEvent(player, loginlistener.connection.hostname, ((java.net.InetSocketAddress) socketaddress).getAddress());
+ PlayerLoginEvent event = new PlayerLoginEvent(player, loginlistener.connection.hostname, ((java.net.InetSocketAddress) socketaddress).getAddress(), ((java.net.InetSocketAddress) loginlistener.connection.channel.remoteAddress()).getAddress());
+
+ if (this.bans.isBanned(gameprofile)) {
+ UserBanListEntry gameprofilebanentry = (UserBanListEntry) this.bans.get(gameprofile);

View File

@ -803,7 +803,13 @@ public final class CraftServer implements Server {
@Override
public long getConnectionThrottle() {
return this.configuration.getInt("settings.connection-throttle");
// Spigot Start - Automatically set connection throttle for bungee configurations
if (org.spigotmc.SpigotConfig.bungee) {
return -1;
} else {
return this.configuration.getInt("settings.connection-throttle");
}
// Spigot End
}
@Override
@ -1814,7 +1820,7 @@ public final class CraftServer implements Server {
if (result == null) {
GameProfile profile = null;
// Only fetch an online UUID in online mode
if (this.getOnlineMode()) {
if (this.getOnlineMode() || org.spigotmc.SpigotConfig.bungee) { // Spigot: bungee = online mode, for now.
// This is potentially blocking :(
profile = this.console.getProfileCache().get(name).orElse(null);
}

View File

@ -2344,6 +2344,12 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
private final Player.Spigot spigot = new Player.Spigot()
{
@Override
public InetSocketAddress getRawAddress()
{
return (InetSocketAddress) CraftPlayer.this.getHandle().connection.getRawAddress();
}
@Override
public void respawn()
{

View File

@ -214,4 +214,14 @@ public class SpigotConfig
SpigotConfig.commands.put( "restart", new RestartCommand( "restart" ) );
WatchdogThread.doStart( SpigotConfig.timeoutTime, SpigotConfig.restartOnCrash );
}
public static boolean bungee;
private static void bungee() {
if ( SpigotConfig.version < 4 )
{
SpigotConfig.set( "settings.bungeecord", false );
System.out.println( "Outdated config, disabling BungeeCord support!" );
}
SpigotConfig.bungee = SpigotConfig.getBoolean( "settings.bungeecord", false );
}
}