Examples of MinecraftServer


Examples of net.minecraft.server.MinecraftServer

  @Override
  public List<EntityPlayer> getPlayers()
  {
    if ( !Platform.isClient() )
    {
      MinecraftServer server = FMLCommonHandler.instance().getMinecraftServerInstance();

      if ( server != null )
        return server.getConfigurationManager().playerEntityList;
    }

    return new ArrayList<EntityPlayer>();
  }
View Full Code Here

Examples of net.minecraft.server.MinecraftServer

    ct = ForgeChunkManager.requestTicket( AppEng.instance, worldObj, Type.NORMAL );

    if ( ct == null )
    {
      MinecraftServer server = FMLCommonHandler.instance().getMinecraftServerInstance();
      if ( server != null )
      {
        List<EntityPlayerMP> pl = server.getConfigurationManager().playerEntityList;
        for (EntityPlayerMP p : pl)
        {
          p.addChatMessage( new ChatComponentText( "Can't chunk load.." ) );
        }
      }
View Full Code Here

Examples of net.minecraft.server.MinecraftServer

        int var2;

        if (!this.worldObj.isRemote && this.worldObj instanceof WorldServer)
        {
            this.worldObj.theProfiler.startSection("portal");
            MinecraftServer var1 = ((WorldServer) this.worldObj).func_73046_m();
            var2 = this.getMaxInPortalTime();

            if (this.inPortal)
            {
                if (var1.getAllowNether())
                {
                    /*
                     * if (this.ridingEntity == null && this.timeInPortal++ >=
                     * var2) { this.timeInPortal = var2; this.timeUntilPortal =
                     * this.getPortalCooldown(); byte var3;
View Full Code Here

Examples of net.minecraft.server.MinecraftServer

    boolean unloaded = world.unloaded;
    return (unloaded ? "un" : "") + "loaded world " + name(world) + '@' + System.identityHashCode(world) + ", dimension: " + world.getDimension() + ", provider dimension: " + (unloaded ? "unknown" : world.provider.dimensionId) + ", original dimension: " + world.originalDimension;
  }

  public static void checkWorlds() {
    MinecraftServer minecraftServer = MinecraftServer.getServer();
    List<WorldServer> bukkitWorldList = minecraftServer.worlds;
    int a = bukkitWorldList == null ? -1 : bukkitWorldList.size();
    int b = minecraftServer.worldServers.length;
    int c = DimensionManager.getWorlds().length;
    if ((a != -1 && a != b) || b != c) {
View Full Code Here

Examples of net.minecraft.server.MinecraftServer

  }

  public static String dumpWorlds() {
    StringBuilder sb = new StringBuilder();
    List<World> dimensionManagerWorlds = new ArrayList<World>(Arrays.asList(DimensionManager.getWorlds()));
    MinecraftServer minecraftServer = MinecraftServer.getServer();
    List<World> minecraftServerWorlds = new ArrayList<World>(Arrays.asList(minecraftServer.worldServers));
    List<WorldServer> bukkitWorldList = minecraftServer.worlds;
    List<World> bukkitWorlds = bukkitWorldList == null ? null : new ArrayList<World>(bukkitWorldList);
    if (bukkitWorlds != null) {
      sb.append("Worlds in bukkitWorlds: \n").append(dumpWorlds(bukkitWorlds));
View Full Code Here

Examples of net.minecraft.server.MinecraftServer

      }
    }
    if (deadTime < (TickThreading.instance.deadLockTime * 1000000000l)) {
      return true;
    }
    final MinecraftServer minecraftServer = MinecraftServer.getServer();
    if (!minecraftServer.isServerRunning() || minecraftServer.isServerStopped()) {
      return false;
    }
    if (!spikeDetector && minecraftServer.currentlySaving.get() != 0) {
      Log.severe("The server seems to have frozen while saving - Waiting for two minutes to give it time to complete.");
      InsecurityManager.flushLogs();
      trySleep(180000);
      if (minecraftServer.currentlySaving.get() != 0) {
        Log.info("Server still seems to be saving, must've deadlocked.");
        minecraftServer.currentlySaving.set(0);
      } else {
        return true;
      }
    }
    TreeMap<String, String> sortedThreads = new TreeMap<String, String>();
    ThreadMXBean threadMXBean = ManagementFactory.getThreadMXBean();
    if (!attemptedToRecoverDeadlock) {
      StringBuilder sb = new StringBuilder();
      sb
          .append("The server appears to have ").append(spikeDetector ? "lag spiked." : "deadlocked.")
          .append("\nLast tick ").append(deadTime / 1000000000).append("s ago.");
      String prefix = "\nWaiting ThreadManagers: ";
      Set<String> threadManagerSet = new HashSet<String>();
      for (ThreadManager threadManager : DeadLockDetector.threadManagers) {
        if (threadManager.isWaiting()) {
          threadManagerSet.add(threadManager.getName());
        }
      }
      for (ThreadManager threadManager : DeadLockDetector.threadManagers) {
        if (threadManager.isWaiting()) {
          threadManagerSet.remove(threadManager.getParentName());
        }
      }
      for (String threadManager : threadManagerSet) {
        sb.append(prefix).append(threadManager);
        prefix = ", ";
      }
      sb.append("\n\n");
      long[] deadlockedThreads = threadMXBean.findDeadlockedThreads();
      if (deadlockedThreads == null) {
        LoadingCache<String, List<ThreadInfo>> threads = CacheBuilder.newBuilder().build(new CacheLoader<String, List<ThreadInfo>>() {
          @Override
          public List<ThreadInfo> load(final String key) throws Exception {
            return new ArrayList<ThreadInfo>();
          }
        });
        ThreadInfo[] t = threadMXBean.dumpAllThreads(true, true);
        for (ThreadInfo thread : t) {
          String info = toString(thread, false);
          if (info != null) {
            threads.getUnchecked(info).add(thread);
          }
        }
        for (Map.Entry<String, List<ThreadInfo>> entry : threads.asMap().entrySet()) {
          List<ThreadInfo> threadInfoList = entry.getValue();
          ThreadInfo lowest = null;
          for (ThreadInfo threadInfo : threadInfoList) {
            if (lowest == null || threadInfo.getThreadName().toLowerCase().compareTo(lowest.getThreadName().toLowerCase()) < 0) {
              lowest = threadInfo;
            }
          }
          List threadNameList = CollectionsUtil.newList(threadInfoList, new Function<Object, Object>() {
            @Override
            public Object apply(final Object input) {
              return ((ThreadInfo) input).getThreadName();
            }
          });
          Collections.sort(threadNameList);
          sortedThreads.put(lowest.getThreadName(), '"' + CollectionsUtil.join(threadNameList, "\", \"") + "\" " + entry.getKey());
        }
        sb.append(CollectionsUtil.join(sortedThreads.values(), "\n"));
      } else {
        ThreadInfo[] infos = threadMXBean.getThreadInfo(deadlockedThreads, true, true);
        sb.append("Definitely deadlocked: \n");
        for (ThreadInfo threadInfo : infos) {
          sb.append(toString(threadInfo, true)).append('\n');
        }
      }
      if (!spikeDetector) {
        sb.append("\nAttempting to recover without restarting.");
        for (String threadManager : threadManagerSet) {
          tryFixDeadlocks(threadManager);
        }
      }
      Log.severe(sb.toString());
      attemptedToRecoverDeadlock = true;
      trySleep(15000);
      return true;
    }
    if (spikeDetector) {
      return true;
    }
    if (TickThreading.instance.exitOnDeadlock) {
      sendChatSafely(ChatFormat.RED + TickThreading.instance.messageDeadlockSavingExiting);
    }
    Log.severe("Failed to recover from the deadlock.");
    InsecurityManager.flushLogs();
    if (!TickThreading.instance.exitOnDeadlock) {
      Log.severe("Now attempting to save the world. The server will not stop, you must do this yourself. If you want the server to stop automatically on deadlock, enable exitOnDeadlock in TT's config.");
      minecraftServer.saveEverything();
      return false;
    }
    // Yes, we save multiple times - handleServerStopping may freeze on the same thing we deadlocked on, but if it doesn't might change stuff
    // which needs to be saved.
    minecraftServer.getNetworkThread().stopListening();
    trySleep(500);
    new Thread() {
      @Override
      public void run() {
        // We can't lock here, deadlock may be due to the playerEntityList lock.
        int attempts = 5;
        while (attempts-- > 0) {
          try {
            for (EntityPlayerMP entityPlayerMP : new ArrayList<EntityPlayerMP>(minecraftServer.getConfigurationManager().playerEntityList)) {
              entityPlayerMP.playerNetServerHandler.kickPlayerFromServer("Restarting");
            }
            attempts = 0;
          } catch (ConcurrentModificationException ignored) {
          }
        }
      }
    }.start();
    trySleep(1000);
    Log.info("Attempting to save");
    InsecurityManager.flushLogs();
    new Thread() {
      @Override
      public void run() {
        trySleep(300000);
        Log.severe("Froze while attempting to stop - halting server.");
        InsecurityManager.flushLogs();
        new Thread() {
          @Override
          public void run() {
            trySleep(150000);
            Log.severe("Something really broke... Runtime.exit() failed to stop the server. Crashing the JVM now.");
            InsecurityManager.flushLogs();
            UnsafeUtil.crashMe();
          }
        }.start();
        Runtime.getRuntime().exit(1);
      }
    }.start();
    minecraftServer.saveEverything(); // Save first
    Log.info("Saved, now attempting to stop the server and disconnect players cleanly");
    try {
      minecraftServer.getConfigurationManager().disconnectAllPlayers("The server has frozen and must now restart.");
      minecraftServer.stopServer();
      FMLCommonHandler.instance().handleServerStopping(); // Try to get mods to save data - this may lock up, as we deadlocked.
    } catch (Throwable throwable) {
      Log.severe("Error stopping server", throwable);
    }
    minecraftServer.saveEverything(); // Save again, in case they changed anything.
    minecraftServer.initiateShutdown();
    InsecurityManager.flushLogs();
    trySleep(1000);
    Runtime.getRuntime().exit(1);
    return false;
  }
View Full Code Here

Examples of net.minecraft.server.MinecraftServer

    }

    public void handleServerStopped()
    {
        sidedDelegate.serverStopped();
        MinecraftServer server = getMinecraftServerInstance();
        Loader.instance().serverStopped();
        // FORCE the internal server to stop: hello optifine workaround!
        if (server!=null) ObfuscationReflectionHelper.setPrivateValue(MinecraftServer.class, server, false, "field_71316"+"_v", "u", "serverStopped");

        // allow any pending exit to continue, clear exitLatch
View Full Code Here

Examples of net.minecraft.server.MinecraftServer

    @Override
    public void serverStopped()
    {
        // If the server crashes during startup, it might hang the client- reset the client so it can abend properly.
        MinecraftServer server = getServer();

        if (server != null && !server.serverIsInRunLoop())
        {
            ObfuscationReflectionHelper.setPrivateValue(MinecraftServer.class, server, true, "field_71296"+"_Q","serverIs"+"Running");
        }
    }
View Full Code Here

Examples of net.minecraft.server.MinecraftServer

        query.execute();
    }

    public static void abort()
    {
        MinecraftServer server = FMLCommonHandler.instance().getMinecraftServerInstance();
        if (server != null) server.initiateShutdown();

        aborted = true; // to abort loading and go back to the main menu
        throw new AbortedException(); // to halt the server
    }
View Full Code Here

Examples of net.minecraft.server.MinecraftServer

        return 40;
    }

    @Override
    public int getRedstoneValue(World world, int x, int y, int z, int sensorRange, String textBoxText){
        MinecraftServer server = FMLCommonHandler.instance().getMinecraftServerInstance();
        double worldTickTime = mean(server.worldTickTimes.get(world.provider.dimensionId)) * 1.0E-6D;
        try {
            int redstoneStrength = (int)(worldTickTime * Double.parseDouble(textBoxText));
            return Math.min(15, redstoneStrength);
        } catch(Exception e) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.