示例#1
0
  public static Wolf spawn(Location location) {

    MinecraftServer server = MinecraftServer.getServer();
    WorldServer world = server.getWorldServer(0);
    for (WorldServer ws : server.worlds) {
      if (ws.getWorld().getName().equals(location.getWorld().getName())) {
        world = ws;
        break;
      }
    }
    World mcWorld = (World) ((CraftWorld) location.getWorld()).getHandle();
    final WolfNPC customEntity = new WolfNPC(world);
    customEntity.setLocation(
        location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch());
    ((CraftLivingEntity) customEntity.getBukkitEntity()).setRemoveWhenFarAway(false);
    mcWorld.addEntity(customEntity, CreatureSpawnEvent.SpawnReason.CUSTOM);
    return (CraftWolf) customEntity.getBukkitEntity();
  }
  public void remove(Long mcsId, String nickname) {
    MinecraftServer mcs = MinecraftServer.findById(mcsId);

    try {
      System.out.println(
          MinecraftRcon.send(mcs.hostIp, mcs.port, mcs.password, "whitelist remove " + nickname));

    } catch (Exception e) {
    }
  }
示例#3
0
  public static boolean a(
      World world, EntityHuman entityhuman, BlockPosition blockposition, ItemStack itemstack) {
    MinecraftServer minecraftserver = MinecraftServer.getServer();

    if (minecraftserver == null) {
      return false;
    } else {
      if (itemstack.hasTag() && itemstack.getTag().hasKeyOfType("BlockEntityTag", 10)) {
        TileEntity tileentity = world.getTileEntity(blockposition);

        if (tileentity != null) {
          if (!world.isClientSide
              && tileentity.F()
              && !minecraftserver.getPlayerList().isOp(entityhuman.getProfile())) {
            return false;
          }

          NBTTagCompound nbttagcompound = new NBTTagCompound();
          NBTTagCompound nbttagcompound1 = (NBTTagCompound) nbttagcompound.clone();

          tileentity.b(nbttagcompound);
          NBTTagCompound nbttagcompound2 =
              (NBTTagCompound) itemstack.getTag().get("BlockEntityTag");

          nbttagcompound.a(nbttagcompound2);
          nbttagcompound.setInt("x", blockposition.getX());
          nbttagcompound.setInt("y", blockposition.getY());
          nbttagcompound.setInt("z", blockposition.getZ());
          if (!nbttagcompound.equals(nbttagcompound1)) {
            tileentity.a(nbttagcompound);
            tileentity.update();
            return true;
          }
        }
      }

      return false;
    }
  }