Skip to content

Commit

Permalink
add option to disable transfers
Browse files Browse the repository at this point in the history
  • Loading branch information
Outfluencer committed Jan 20, 2024
1 parent f984c90 commit 0e51f06
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
3 changes: 3 additions & 0 deletions proxy/src/main/java/net/md_5/bungee/conf/Configuration.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ public class Configuration implements ProxyConfig
private int compressionThreshold = 256;
private boolean preventProxyConnections;
private boolean forgeSupport;
private boolean rejectTransfers;


public void load()
{
Expand Down Expand Up @@ -103,6 +105,7 @@ public void load()
compressionThreshold = adapter.getInt( "network_compression_threshold", compressionThreshold );
preventProxyConnections = adapter.getBoolean( "prevent_proxy_connections", preventProxyConnections );
forgeSupport = adapter.getBoolean( "forge_support", forgeSupport );
rejectTransfers = adapter.getBoolean( "reject_transfers", rejectTransfers );

disabledCommands = new CaseInsensitiveSet( (Collection<String>) adapter.getList( "disabled_commands", Arrays.asList( "disabledcommandhere" ) ) );

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -351,8 +351,8 @@ public void handle(Handshake handshake) throws Exception
ch.setProtocol( Protocol.STATUS );
break;
case 2:
case 3: // transferred
this.transferred = handshake.getRequestedProtocol() == 3;
case 3:
transferred = handshake.getRequestedProtocol() == 3;
// Login
bungee.getLogger().log( Level.INFO, "{0} has connected", this );
thisState = State.USERNAME;
Expand All @@ -369,6 +369,12 @@ public void handle(Handshake handshake) throws Exception
}
return;
}

if ( transferred && bungee.config.isRejectTransfers() )
{
disconnect( bungee.getTranslation( "reject_transfer" ) );
return;
}
break;
default:
throw new QuietException( "Cannot request protocol " + handshake.getRequestedProtocol() );
Expand Down
1 change: 1 addition & 0 deletions proxy/src/main/resources/messages.properties
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,4 @@ command_perms_permission=\u00a79- {0}
command_ip=\u00a79IP of {0} is {1}
illegal_chat_characters=\u00a7cIllegal characters in chat ({0})
kick_message=\u00a7cYou have been kicked off the proxy.
reject_transfer=\u00a7cYour transfer was rejected.

0 comments on commit 0e51f06

Please sign in to comment.