@@ -97,41 +97,40 @@ public void onPackStatus(PlayerResourcePackStatusEvent event) {
9797
9898 private boolean tryValidateHacks (Player player , PlayerResourcePackStatusEvent .Status status , VelocityConfig root , long now ) {
9999 final boolean tryPrevent = plugin .getConfig ().getBoolean ("try-to-stop-fake-accept-hacks" , true );
100- if (tryPrevent ) {
101- if (status == PlayerResourcePackStatusEvent .Status .ACCEPTED ) {
102- if (sentAccept .containsKey (player .getUniqueId ())) {
103- plugin .log ("Kicked player " + player .getUsername () + " because they are sending fake resource pack statuses (accepted sent twice)." );
104- final VelocityConfig actions = root .getConfig ("actions" ).getConfig ("DECLINED" );
105- final String text = actions .getString ("message" );
106- if (text == null ) return true ;
107- player .disconnect (plugin .getMiniMessage ().deserialize (text ));
108- return true ;
109- }
110- sentAccept .put (player .getUniqueId (), now );
111- } else if (status == PlayerResourcePackStatusEvent .Status .SUCCESSFUL ) {
112- if (!sentAccept .containsKey (player .getUniqueId ())) {
113- plugin .log ("Kicked player " + player .getUsername () + " because they are sending fake resource pack statuses (order not maintained)." );
114- final VelocityConfig actions = root .getConfig ("actions" ).getConfig ("FAILED_DOWNLOAD" );
115- final String text = actions .getString ("message" );
116- if (text == null ) return true ;
117- player .disconnect (plugin .getMiniMessage ().deserialize (text ));
118- return true ;
119- }
120-
121- long time = now - sentAccept .remove (player .getUniqueId ());
122- if (time <= 10 ) {
123- plugin .log ("Kicked player " + player .getUsername () + " because they are sending fake resource pack statuses (sent too fast)." );
124- final VelocityConfig actions = root .getConfig ("actions" ).getConfig ("FAILED_DOWNLOAD" );
125- final String text = actions .getString ("message" );
126- if (text == null ) return true ;
127- player .disconnect (plugin .getMiniMessage ().deserialize (text ));
128- return true ;
129- }
100+ if (!tryPrevent ) return false ;
101+
102+ final VelocityConfig actionsRoot = root .getConfig ("actions" );
103+ if (status == PlayerResourcePackStatusEvent .Status .ACCEPTED ) {
104+ if (sentAccept .containsKey (player .getUniqueId ())) {
105+ plugin .log ("Kicked player " + player .getUsername () + " because they are sending fake resource pack statuses (accepted sent twice)." );
106+ final VelocityConfig actions = actionsRoot .getConfig ("DECLINED" );
107+ return disconnectAction (player , actions );
108+ }
109+ sentAccept .put (player .getUniqueId (), now );
110+ } else if (status == PlayerResourcePackStatusEvent .Status .SUCCESSFUL ) {
111+ if (!sentAccept .containsKey (player .getUniqueId ())) {
112+ plugin .log ("Kicked player " + player .getUsername () + " because they are sending fake resource pack statuses (order not maintained)." );
113+ final VelocityConfig actions = actionsRoot .getConfig ("FAILED_DOWNLOAD" );
114+ return disconnectAction (player , actions );
115+ }
116+
117+ long time = now - sentAccept .remove (player .getUniqueId ());
118+ if (time <= 10 ) {
119+ plugin .log ("Kicked player " + player .getUsername () + " because they are sending fake resource pack statuses (sent too fast)." );
120+ final VelocityConfig actions = actionsRoot .getConfig ("FAILED_DOWNLOAD" );
121+ return disconnectAction (player , actions );
130122 }
131123 }
132124 return false ;
133125 }
134126
127+ private boolean disconnectAction (Player player , VelocityConfig actions ) {
128+ final String text = actions .getString ("message" );
129+ if (text == null ) return true ;
130+ player .disconnect (plugin .getMiniMessage ().deserialize (text ));
131+ return true ;
132+ }
133+
135134 @ Subscribe
136135 public void onQuit (DisconnectEvent event ) {
137136 final Player player = event .getPlayer ();
0 commit comments