Esempio n. 1
0
  public static void setGamemode(EntityPlayerMP player, int mode) {
    if (mode < 0
        || mode >= NEIActions.gameModes.length
        || NEIActions.nameActionMap.containsKey(NEIActions.gameModes[mode])
            && !NEIServerConfig.canPlayerPerformAction(
                player.getName(), NEIActions.gameModes[mode])) {
      return;
    }

    // creative+
    NEIServerConfig.forPlayer(player.getName()).enableAction("creative+", mode == 2);
    if (mode == 2
        && !(player.openContainer
            instanceof ContainerCreativeInv)) // open the container immediately for the client
    {
      NEISPH.processCreativeInv(player, true);
    }

    // change it on the server
    player.theItemInWorldManager.setGameType(getGameType(mode));

    // tell the client to change it
    new PacketCustom(NEISPH.channel, 14).writeByte(mode).sendToPlayer(player);
    player.addChatMessage(new ChatComponentTranslation("nei.chat.gamemode." + mode));
  }
Esempio n. 2
0
  public static void sendNotice(ICommandSender sender, IChatComponent msg, String permission) {
    ChatComponentTranslation notice =
        new ChatComponentTranslation("chat.type.admin", sender.getName(), msg.createCopy());
    notice.getChatStyle().setColor(EnumChatFormatting.GRAY).setItalic(true);

    if (NEIServerConfig.canPlayerPerformAction("CONSOLE", permission)) {
      MinecraftServer.getServer().addChatMessage(notice);
    }

    for (EntityPlayer p : ServerUtils.getPlayers()) {
      if (p == sender) {
        p.addChatComponentMessage(msg);
      } else if (NEIServerConfig.canPlayerPerformAction(p.getName(), permission)) {
        p.addChatComponentMessage(notice);
      }
    }
  }
Esempio n. 3
0
 public static int getCreativeMode(EntityPlayerMP player) {
   if (NEIServerConfig.forPlayer(player.getName()).isActionEnabled("creative+")) {
     return 2;
   } else if (player.theItemInWorldManager.isCreative()) {
     return 1;
   } else if (player.theItemInWorldManager.getGameType().isAdventure()) {
     return 3;
   } else {
     return 0;
   }
 }
Esempio n. 4
0
  public static void advanceDisabledTimes(World world) {
    int dim = world.provider.getDimensionId();
    int hour = (int) (getTime(world) % 24000) / 1000;
    int newhour = hour;
    while (NEIServerConfig.isActionDisabled(dim, NEIActions.timeZones[newhour / 6])) {
      newhour = ((newhour / 6 + 1) % 4) * 6;
    }

    if (newhour != hour) {
      setHourForward(world, newhour, false);
    }
  }
Esempio n. 5
0
  public static void cycleCreativeInv(EntityPlayerMP player, int steps) {
    InventoryPlayer inventory = player.inventory;

    // top down [row][col]
    ItemStack[][] slots = new ItemStack[10][9];
    PlayerSave playerSave = NEIServerConfig.forPlayer(player.getName());

    // get
    System.arraycopy(inventory.mainInventory, 0, slots[9], 0, 9);

    for (int row = 0; row < 3; row++) {
      System.arraycopy(inventory.mainInventory, (row + 1) * 9, slots[row + 6], 0, 9);
    }

    for (int row = 0; row < 6; row++) {
      System.arraycopy(playerSave.creativeInv, row * 9, slots[row], 0, 9);
    }

    ItemStack[][] newslots = new ItemStack[10][];

    // put back
    for (int row = 0; row < 10; row++) {
      newslots[(row + steps + 10) % 10] = slots[row];
    }

    System.arraycopy(newslots[9], 0, inventory.mainInventory, 0, 9);

    for (int row = 0; row < 3; row++) {
      System.arraycopy(newslots[row + 6], 0, inventory.mainInventory, (row + 1) * 9, 9);
    }

    for (int row = 0; row < 6; row++) {
      System.arraycopy(newslots[row], 0, playerSave.creativeInv, row * 9, 9);
    }

    playerSave.setDirty();
  }
Esempio n. 6
0
 public static void toggleMagnetMode(EntityPlayerMP player) {
   PlayerSave playerSave = NEIServerConfig.forPlayer(player.getName());
   playerSave.enableAction("magnet", !playerSave.isActionEnabled("magnet"));
 }