Hooks.java 867 B

1234567891011121314151617181920212223242526272829303132333435
  1. package me.kcm;
  2. import java.util.function.Consumer;
  3. import net.minecraft.server.dedicated.DedicatedPlayerList;
  4. import net.minecraft.server.dedicated.DedicatedServer;
  5. public class Hooks
  6. {
  7. private static Consumer<DedicatedServer> playerListFunction = null;
  8. public static void setPlayerListFunction(Consumer<DedicatedServer> c)
  9. {
  10. playerListFunction = c;
  11. }
  12. public static void setPlayerList(DedicatedServer server)
  13. {
  14. if(playerListFunction != null)
  15. {
  16. playerListFunction.accept(server);
  17. }
  18. else
  19. {
  20. try
  21. {
  22. server.setPlayerList(new DedicatedPlayerList(server));
  23. }
  24. catch(Exception ex)
  25. {
  26. // this is stupid and should not be needed
  27. ex.printStackTrace();
  28. }
  29. }
  30. }
  31. }