goauth

Fabric plugin for enhanced whitelists
git clone git://git.bain.cz/goauth.git
Log | Files | Refs | README | LICENSE

OnWhitelistAddListener.java (1101B)


      1 package cz.bain.plugins.goauth.events.listeners;
      2 
      3 import com.mojang.authlib.GameProfile;
      4 import cz.bain.plugins.goauth.Goauth;
      5 import cz.bain.plugins.goauth.StringRepository;
      6 import cz.bain.plugins.goauth.events.callbacks.OnWhitelistAddCallback;
      7 import net.minecraft.server.command.ServerCommandSource;
      8 import net.minecraft.server.network.ServerPlayerEntity;
      9 import net.minecraft.text.Text;
     10 import net.minecraft.util.ActionResult;
     11 
     12 import java.util.Collection;
     13 
     14 public class OnWhitelistAddListener implements OnWhitelistAddCallback {
     15 
     16     private final Goauth plugin;
     17 
     18     public OnWhitelistAddListener(Goauth plugin) {
     19         this.plugin = plugin;
     20     }
     21 
     22     @Override
     23     public ActionResult interact(ServerCommandSource source, Collection<GameProfile> targets) {
     24 
     25         for (GameProfile target : targets) {
     26             ServerPlayerEntity player = this.plugin.playersLimbo.get(target.getName());
     27             if (player != null) {
     28                 player.networkHandler.disconnect(Text.of(StringRepository.limboRemoveDisconnect));
     29             }
     30         }
     31 
     32         return ActionResult.PASS;
     33     }
     34 }