LANDiscoveryPlugin class

Пакет: com.hypixel.hytale.builtin.landiscovery

Файл: com/hypixel/hytale/builtin/landiscovery/LANDiscoveryPlugin.java

extends: JavaPlugin

Поля (1)

МодификаторыТипИмя
instance

Методы (8)

МодификаторыВозвратСигнатура
abstract throw new IllegalArgumentExceptionthrow new IllegalArgumentException("Listener thread already exists!")
static LANDiscoveryPlugin getLANDiscoveryPlugin get()
if if(this.lanDiscoveryThread != null)
if if(this.lanDiscoveryThread != null)
if if(!var1 && this.lanDiscoveryThread != null)
public boolean isLANDiscoveryEnabledboolean isLANDiscoveryEnabled()
public void setLANDiscoveryEnabledvoid setLANDiscoveryEnabled(boolean var1)
abstract super super(var1)

Исходный код

Показать/скрыть
class="kw">package com.hypixel.hytale.builtin.landiscovery;

class="kw">import com.hypixel.hytale.protocol.packets.serveraccess.Access;
class="kw">import com.hypixel.hytale.server.core.modules.singleplayer.SingleplayerRequestAccessEvent;
class="kw">import com.hypixel.hytale.server.core.plugin.JavaPlugin;
class="kw">import com.hypixel.hytale.server.core.plugin.JavaPluginInit;
class="kw">import javax.annotation.Nonnull;
class="kw">import javax.annotation.Nullable;

class="kw">public class LANDiscoveryPlugin class="kw">extends JavaPlugin {
   @Nullable
   class="kw">private LANDiscoveryThread lanDiscoveryThread;
   class="kw">private class="kw">static LANDiscoveryPlugin instance;

   class="kw">public class="kw">static LANDiscoveryPlugin get() {
      class="kw">return instance;
   }

   class="kw">public LANDiscoveryPlugin(@Nonnull JavaPluginInit var1) {
      super(var1);
   }

   @Override
   class="kw">protected void setup() {
      instance = this;
      this.getCommandRegistry().registerCommand(new LANDiscoveryCommand());
      this.getEventRegistry().registerGlobal(SingleplayerRequestAccessEvent.class, var1 -> this.setLANDiscoveryEnabled(var1.getAccess() != Access.Private));
   }

   @Override
   class="kw">protected void start() {
      if (this.lanDiscoveryThread != null) {
         throw new IllegalArgumentException("Listener thread already exists!");
      }
   }

   @Override
   class="kw">protected void shutdown() {
      if (this.lanDiscoveryThread != null) {
         this.setLANDiscoveryEnabled(false);
      }
   }

   class="kw">public void setLANDiscoveryEnabled(boolean var1) {
      if (!var1 && this.lanDiscoveryThread != null) {
         this.lanDiscoveryThread.interrupt();
         this.lanDiscoveryThread.getSocket().close();
         this.lanDiscoveryThread = null;
      } else if (var1 && this.lanDiscoveryThread == null) {
         this.lanDiscoveryThread = new LANDiscoveryThread();
         this.lanDiscoveryThread.start();
      }
   }

   class="kw">public boolean isLANDiscoveryEnabled() {
      class="kw">return this.lanDiscoveryThread != null;
   }

   @Nullable
   class="kw">public LANDiscoveryThread getLanDiscoveryThread() {
      class="kw">return this.lanDiscoveryThread;
   }
}