Skip to content
This repository has been archived by the owner on Jul 15, 2022. It is now read-only.

Commit

Permalink
Merge branch 'SpigotMC-master'
Browse files Browse the repository at this point in the history
  • Loading branch information
sleiss committed Apr 29, 2016
2 parents 9a4191b + e8f9165 commit 7ee40a0
Show file tree
Hide file tree
Showing 28 changed files with 413 additions and 379 deletions.
16 changes: 10 additions & 6 deletions api/src/main/java/net/md_5/bungee/api/ServerPing.java
Original file line number Diff line number Diff line change
Expand Up @@ -104,13 +104,13 @@ public static class ModItem
@Deprecated
public ServerPing(Protocol version, Players players, String description, String favicon)
{
this( version, players, new TextComponent( TextComponent.fromLegacyText(description) ), favicon == null ? null : Favicon.create( favicon ) );
this( version, players, new TextComponent( TextComponent.fromLegacyText( description ) ), favicon == null ? null : Favicon.create( favicon ) );
}

@Deprecated
public ServerPing(Protocol version, Players players, String description, Favicon favicon)
{
this( version, players, new TextComponent( TextComponent.fromLegacyText(description) ), favicon );
this( version, players, new TextComponent( TextComponent.fromLegacyText( description ) ), favicon );
}

@Deprecated
Expand All @@ -136,20 +136,24 @@ public void setFavicon(Favicon favicon)
}

@Deprecated
public void setDescription(String description) {
public void setDescription(String description)
{
this.description = new TextComponent( TextComponent.fromLegacyText( description ) );
}

@Deprecated
public String getDescription() {
public String getDescription()
{
return BaseComponent.toLegacyText( description );
}

public void setDescriptionComponent(BaseComponent description) {
public void setDescriptionComponent(BaseComponent description)
{
this.description = description;
}

public BaseComponent getDescriptionComponent() {
public BaseComponent getDescriptionComponent()
{
return description;
}
}
3 changes: 2 additions & 1 deletion api/src/main/java/net/md_5/bungee/api/event/AsyncEvent.java
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ public void completeIntent(Plugin plugin)
{
done.done( (T) this, null );
}
} else {
} else
{
latch.decrementAndGet();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -250,19 +250,22 @@ public static enum FormatRetention
{

/**
* Specify that we do not want to retain anything from the previous component.
* Specify that we do not want to retain anything from the previous
* component.
*/
NONE,
/**
* Specify that we want the formatting retained from the previous component.
* Specify that we want the formatting retained from the previous
* component.
*/
FORMATTING,
/**
* Specify that we want the events retained from the previous component.
*/
EVENTS,
/**
* Specify that we want to retain everything from the previous component.
* Specify that we want to retain everything from the previous
* component.
*/
ALL
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,8 @@ protected void toPlainText(StringBuilder builder)
try
{
trans = locales.getString( translate );
} catch ( MissingResourceException e ) {
} catch ( MissingResourceException ex )
{
trans = translate;
}

Expand Down Expand Up @@ -184,7 +185,8 @@ protected void toLegacyText(StringBuilder builder)
try
{
trans = locales.getString( translate );
} catch ( MissingResourceException e ) {
} catch ( MissingResourceException e )
{
trans = translate;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@

import static org.junit.Assert.assertEquals;

public class TranslatableComponentTest {
public class TranslatableComponentTest
{

@Test
public void testMissingPlaceholdersAdded()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ public static ConfigurationProvider getProvider(Class<? extends ConfigurationPro
{
return providers.get( provider );
}
/*------------------------------------------------------------------------*/

/*------------------------------------------------------------------------*/
public abstract void save(Configuration config, File file) throws IOException;

public abstract void save(Configuration config, Writer writer);
Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,8 @@
<action>
<execute>
<runOnIncremental>false</runOnIncremental>
</execute >
</action>
</execute>
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
Expand Down
99 changes: 49 additions & 50 deletions protocol/src/main/java/net/md_5/bungee/protocol/Protocol.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,67 +44,67 @@ public enum Protocol

// Undef
HANDSHAKE
{
{

{
TO_SERVER.registerPacket( 0x00, Handshake.class );
}
},
{
TO_SERVER.registerPacket( 0x00, Handshake.class );
}
},
// 0
GAME
{
{

{
TO_CLIENT.registerPacket( 0x00, 0x1F, KeepAlive.class );
TO_CLIENT.registerPacket( 0x01, 0x23, Login.class );
TO_CLIENT.registerPacket( 0x02, 0x0F, Chat.class );
TO_CLIENT.registerPacket( 0x07, 0x33, Respawn.class );
TO_CLIENT.registerPacket( 0x0C, 0x0C, BossBar.class, true, false );
TO_CLIENT.registerPacket( 0x38, 0x2D, PlayerListItem.class ); // PlayerInfo
TO_CLIENT.registerPacket( 0x3A, 0x0E, TabCompleteResponse.class );
TO_CLIENT.registerPacket( 0x3B, 0x3F, ScoreboardObjective.class );
TO_CLIENT.registerPacket( 0x3C, 0x42, ScoreboardScore.class );
TO_CLIENT.registerPacket( 0x3D, 0x38, ScoreboardDisplay.class );
TO_CLIENT.registerPacket( 0x3E, 0x41, Team.class );
TO_CLIENT.registerPacket( 0x3F, 0x18, PluginMessage.class );
TO_CLIENT.registerPacket( 0x40, 0x1A, Kick.class );
TO_CLIENT.registerPacket( 0x45, 0x45, Title.class );
TO_CLIENT.registerPacket( 0x46, 0x46, SetCompression.class, false , true );
TO_CLIENT.registerPacket( 0x47, 0x48, PlayerListHeaderFooter.class );

TO_SERVER.registerPacket( 0x00, 0x0B, KeepAlive.class );
TO_SERVER.registerPacket( 0x01, 0x02, Chat.class );
TO_SERVER.registerPacket( 0x14, 0x01, TabCompleteRequest.class );
TO_SERVER.registerPacket( 0x15, 0x04, ClientSettings.class );
TO_SERVER.registerPacket( 0x17, 0x09, PluginMessage.class );
}
},
{
TO_CLIENT.registerPacket( 0x00, 0x1F, KeepAlive.class );
TO_CLIENT.registerPacket( 0x01, 0x23, Login.class );
TO_CLIENT.registerPacket( 0x02, 0x0F, Chat.class );
TO_CLIENT.registerPacket( 0x07, 0x33, Respawn.class );
TO_CLIENT.registerPacket( 0x0C, 0x0C, BossBar.class, true, false );
TO_CLIENT.registerPacket( 0x38, 0x2D, PlayerListItem.class ); // PlayerInfo
TO_CLIENT.registerPacket( 0x3A, 0x0E, TabCompleteResponse.class );
TO_CLIENT.registerPacket( 0x3B, 0x3F, ScoreboardObjective.class );
TO_CLIENT.registerPacket( 0x3C, 0x42, ScoreboardScore.class );
TO_CLIENT.registerPacket( 0x3D, 0x38, ScoreboardDisplay.class );
TO_CLIENT.registerPacket( 0x3E, 0x41, Team.class );
TO_CLIENT.registerPacket( 0x3F, 0x18, PluginMessage.class );
TO_CLIENT.registerPacket( 0x40, 0x1A, Kick.class );
TO_CLIENT.registerPacket( 0x45, 0x45, Title.class );
TO_CLIENT.registerPacket( 0x46, 0x46, SetCompression.class, false , true );
TO_CLIENT.registerPacket( 0x47, 0x48, PlayerListHeaderFooter.class );

TO_SERVER.registerPacket( 0x00, 0x0B, KeepAlive.class );
TO_SERVER.registerPacket( 0x01, 0x02, Chat.class );
TO_SERVER.registerPacket( 0x14, 0x01, TabCompleteRequest.class );
TO_SERVER.registerPacket( 0x15, 0x04, ClientSettings.class );
TO_SERVER.registerPacket( 0x17, 0x09, PluginMessage.class );
}
},
// 1
STATUS
{
{

{
TO_CLIENT.registerPacket( 0x00, StatusResponse.class );
TO_CLIENT.registerPacket( 0x01, PingPacket.class );
{
TO_CLIENT.registerPacket( 0x00, StatusResponse.class );
TO_CLIENT.registerPacket( 0x01, PingPacket.class );

TO_SERVER.registerPacket( 0x00, StatusRequest.class );
TO_SERVER.registerPacket( 0x01, PingPacket.class );
}
},
TO_SERVER.registerPacket( 0x00, StatusRequest.class );
TO_SERVER.registerPacket( 0x01, PingPacket.class );
}
},
//2
LOGIN
{
{

{
TO_CLIENT.registerPacket( 0x00, Kick.class );
TO_CLIENT.registerPacket( 0x01, EncryptionRequest.class );
TO_CLIENT.registerPacket( 0x02, LoginSuccess.class );
TO_CLIENT.registerPacket( 0x03, SetCompression.class );
{
TO_CLIENT.registerPacket( 0x00, Kick.class );
TO_CLIENT.registerPacket( 0x01, EncryptionRequest.class );
TO_CLIENT.registerPacket( 0x02, LoginSuccess.class );
TO_CLIENT.registerPacket( 0x03, SetCompression.class );

TO_SERVER.registerPacket( 0x00, LoginRequest.class );
TO_SERVER.registerPacket( 0x01, EncryptionResponse.class );
}
};
TO_SERVER.registerPacket( 0x00, LoginRequest.class );
TO_SERVER.registerPacket( 0x01, EncryptionResponse.class );
}
};
/*========================================================================*/
public static final int MAX_PACKET_ID = 0xFF;
public static List<Integer> supportedVersions = Arrays.asList(
Expand Down Expand Up @@ -132,7 +132,6 @@ public class DirectionData
private final TIntObjectMap<TIntIntMap> packetRemap = new TIntObjectHashMap<>();
private final TIntObjectMap<TIntIntMap> packetRemapInv = new TIntObjectHashMap<>();


{
packetRemap.put( ProtocolConstants.MINECRAFT_1_7_2, new TIntIntHashMap() );
packetRemapInv.put( ProtocolConstants.MINECRAFT_1_7_2, new TIntIntHashMap() );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public void write(ByteBuf buf, ProtocolConstants.Direction direction, int protoc
buf.writeByte( skinParts );
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_9 )
{
DefinedPacket.writeVarInt(mainHand, buf);
DefinedPacket.writeVarInt( mainHand, buf );
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,13 @@ public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protoco
String value = DefinedPacket.readString( buf );
if ( buf.readBoolean() )
{
item.properties[ j] = new String[]
item.properties[j] = new String[]
{
name, value, DefinedPacket.readString( buf )
};
} else
{
item.properties[ j ] = new String[]
item.properties[j] = new String[]
{
name, value
};
Expand Down
5 changes: 4 additions & 1 deletion proxy/src/main/java/net/md_5/bungee/BungeeCord.java
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,10 @@ public void start() throws Exception

pluginManager.enablePlugins();

connectionThrottle = new ConnectionThrottle( config.getThrottle() );
if ( config.getThrottle() > 0 )
{
connectionThrottle = new ConnectionThrottle( config.getThrottle() );
}
startListeners();

saveThread.scheduleAtFixedRate( new TimerTask()
Expand Down
20 changes: 12 additions & 8 deletions proxy/src/main/java/net/md_5/bungee/ConnectionThrottle.java
Original file line number Diff line number Diff line change
@@ -1,25 +1,29 @@
package net.md_5.bungee;

import com.google.common.cache.Cache;
import com.google.common.cache.CacheBuilder;
import java.net.InetAddress;
import java.util.HashMap;
import java.util.Map;
import lombok.RequiredArgsConstructor;
import java.util.concurrent.TimeUnit;

@RequiredArgsConstructor
public class ConnectionThrottle
{

private final Map<InetAddress, Long> throttle = new HashMap<>();
private final int throttleTime;
private final Cache<InetAddress, Long> throttle;

public void unthrottle(InetAddress address)
public ConnectionThrottle(int throttleTime)
{
throttle.remove( address );
this.throttleTime = throttleTime;
this.throttle = CacheBuilder.newBuilder()
.concurrencyLevel( Runtime.getRuntime().availableProcessors() )
.initialCapacity( 100 )
.expireAfterAccess( throttleTime, TimeUnit.MILLISECONDS )
.build();
}

public boolean throttle(InetAddress address)
{
Long value = throttle.get( address );
Long value = throttle.getIfPresent( address );
long currentTime = System.currentTimeMillis();

throttle.put( address, currentTime );
Expand Down
4 changes: 4 additions & 0 deletions proxy/src/main/java/net/md_5/bungee/PlayerInfoSerializer.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,17 @@

public class PlayerInfoSerializer implements JsonSerializer<ServerPing.PlayerInfo>, JsonDeserializer<ServerPing.PlayerInfo>
{
<<<<<<< HEAD
private final int protocol;

public PlayerInfoSerializer(int protocol)
{
this.protocol = protocol;
}

=======

>>>>>>> 80b3135a93f0e23489cc19086e31feb12ff51798
@Override
public ServerPing.PlayerInfo deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException
{
Expand Down
Loading

0 comments on commit 7ee40a0

Please sign in to comment.