@Override
 public void onPlayerLogin(EntityPlayer player) {
   if (FMLCommonHandler.instance().getEffectiveSide().isServer()) {
     if (SimpleModsConfiguration.server.isDedicatedServer()) {
       if (!Permissions.playerData.getCompoundTag(player.username).hasKey("Rank")) {
         NBTTagCompound data = new NBTTagCompound();
         data.setString("Rank", Permissions.defaultRank);
         Permissions.playerData.setCompoundTag(player.username, data);
         player.addChatMessage(
             SimpleModsTranslation.welcomeMessageCoreDefaultRank.replaceAll(
                 "%d", Permissions.defaultRank));
         player.addChatMessage(SimpleModsTranslation.welcomeMessageCore);
         if (Permissions.rankData.getCompoundTag(Permissions.getRank(player)).hasKey("Spawn")) {
           data =
               Permissions.rankData
                   .getCompoundTag(Permissions.getRank(player))
                   .getCompoundTag("Spawn");
           Double X = data.getDouble("X");
           Double Y = data.getDouble("Y");
           Double Z = data.getDouble("Z");
           Float yaw = data.getFloat("yaw");
           Float pitch = data.getFloat("pitch");
           Integer dim = data.getInteger("Dim");
           if (player.dimension != dim)
             ModLoader.getMinecraftServerInstance()
                 .getConfigurationManager()
                 .transferPlayerToDimension(((EntityPlayerMP) player), dim);
           ((EntityPlayerMP) player).playerNetServerHandler.setPlayerLocation(X, Y, Z, yaw, pitch);
           player.sendChatToPlayer("Welcome to " + data.getString("name"));
         }
       }
     } else {
       if (!Permissions.playerData.getCompoundTag(player.username).hasKey("Rank")) {
         NBTTagCompound data = new NBTTagCompound();
         data.setString("Rank", Permissions.opRank);
         Permissions.playerData.setCompoundTag(player.username, data);
         if (Permissions.rankData.getCompoundTag(Permissions.getRank(player)).hasKey("Spawn")) {
           data =
               Permissions.rankData
                   .getCompoundTag(Permissions.getRank(player))
                   .getCompoundTag("Spawn");
           Double X = data.getDouble("X");
           Double Y = data.getDouble("Y");
           Double Z = data.getDouble("Z");
           Float yaw = data.getFloat("yaw");
           Float pitch = data.getFloat("pitch");
           Integer dim = data.getInteger("Dim");
           if (player.dimension != dim)
             ModLoader.getMinecraftServerInstance()
                 .getConfigurationManager()
                 .transferPlayerToDimension(((EntityPlayerMP) player), dim);
           ((EntityPlayerMP) player).playerNetServerHandler.setPlayerLocation(X, Y, Z, yaw, pitch);
           player.sendChatToPlayer("Welcome to " + data.getString("name"));
         }
       }
     }
   }
 }
Exemple #2
0
 @ServerStarting
 public void serverStarting(FMLServerStartingEvent event) {
   MinecraftServer server = ModLoader.getMinecraftServerInstance();
   ICommandManager commandManager = server.getCommandManager();
   ServerCommandManager serverCommandManager = (ServerCommandManager) commandManager;
   serverCommandManager.registerCommand(new CommanduPerm());
 }
  public static void tick() {
    if (ModLoader.getMinecraftServerInstance() == null) {
      possibleClose();
      return;
    }

    if (watchers.length != ModLoader.getMinecraftServerInstance().worldServers.length) {
      createNewWatchers();
      return;
    }

    watchers[index++].tick();

    if (index >= watchers.length) {
      index = 0;
    }
  }
 private static void createNewWatchers() {
   World[] worlds = ModLoader.getMinecraftServerInstance().worldServers;
   if (worlds.length > 0) {
     for (DaytimeWatcher dw : watchers) {
       dw.close();
     }
     watchers = new DaytimeWatcher[worlds.length];
     for (int i = 0; i < worlds.length; i++) {
       watchers[i] = new DaytimeWatcher(worlds[i]);
     }
     index = 0;
   }
 }
  @Override
  public void processCommand(ICommandSender sender, String[] par2ArrayOfStr) {
    MinecraftServer server = ModLoader.getMinecraftServerInstance();
    EntityPlayer player = getCommandSenderAsPlayer(sender);
    EntityPlayerMP playerMP = (EntityPlayerMP) sender;
    String ho = "";

    if (par2ArrayOfStr.length == 0) {
      ho = "[Default]";
    } else {
      ho = par2ArrayOfStr[0];
    }

    setBackLocation(player);

    NBTTagCompound playerdata =
        NecessitiesMain.instance.necessities_data.getCompoundTag(player.username);
    NecessitiesMain.instance.necessities_data.setCompoundTag(player.username, playerdata);
    NBTTagCompound homes = playerdata.getCompoundTag("Homes");
    playerdata.setCompoundTag("Homes", homes);

    // Go to the specified home
    if (!homes.hasKey(ho)) {
      sender.sendChatToPlayer("Unknown home.");
      return;
    }

    NBTTagCompound h = homes.getCompoundTag(ho);
    double posX = h.getDouble("PosX");
    double posY = h.getDouble("PosY");
    double posZ = h.getDouble("PosZ");
    float yaw = h.getFloat("Yaw");
    float pitch = h.getFloat("Pitch");
    int dim = h.getInteger("Dim");

    if (player.dimension != dim)
      server.getConfigurationManager().transferPlayerToDimension(((EntityPlayerMP) player), dim);

    playerMP.playerNetServerHandler.setPlayerLocation(posX, posY, posZ, yaw, pitch);
  } // public voice processCommand(...)
 @Override
 public void onPlayerRespawn(EntityPlayer player) {
   MinecraftServer server = ModLoader.getMinecraftServerInstance();
   ChunkCoordinates var4 = ((EntityPlayerMP) player).getSpawnChunk();
   if (var4 == null) {
     if (Permissions.rankData.getCompoundTag(Permissions.getRank(player)).hasKey("Spawn")) {
       NBTTagCompound data =
           Permissions.rankData
               .getCompoundTag(Permissions.getRank(player))
               .getCompoundTag("Spawn");
       Double X = data.getDouble("X");
       Double Y = data.getDouble("Y");
       Double Z = data.getDouble("Z");
       Float yaw = data.getFloat("yaw");
       Float pitch = data.getFloat("pitch");
       Integer dim = data.getInteger("Dim");
       if (player.dimension != dim)
         server
             .getConfigurationManager()
             .transferPlayerToDimension(((EntityPlayerMP) player), dim);
       ((EntityPlayerMP) player).playerNetServerHandler.setPlayerLocation(X, Y, Z, yaw, pitch);
       player.sendChatToPlayer("Welcome to " + data.getString("name"));
     } else if (SimpleModsConfiguration.spawnOverride) {
       ChunkCoordinates coords = player.worldObj.getSpawnPoint();
       player.setPosition(coords.posX, coords.posY, coords.posZ);
       while (!server
           .worldServerForDimension(player.dimension)
           .getCollidingBoundingBoxes(player, player.boundingBox)
           .isEmpty()) {
         player.setPosition(player.posX, player.posY + 0.5D, player.posZ);
       }
       ((EntityPlayerMP) player)
           .playerNetServerHandler.setPlayerLocation(coords.posX, coords.posY, coords.posZ, 0, 0);
     }
   }
 }