コード例 #1
0
ファイル: ItemWorldMap.java プロジェクト: DaMarine/Alkazia
  @Override
  public void d(ItemStack itemstack, World world, EntityHuman entityhuman) {
    if (itemstack.hasTag() && itemstack.getTag().getBoolean("map_is_scaling")) {
      WorldMap worldmap = Items.MAP.getSavedMap(itemstack, world);

      world =
          world.getServer().getServer().worlds.get(0); // CraftBukkit - use primary world for maps

      itemstack.setData(world.b("map"));
      WorldMap worldmap1 = new WorldMap("map_" + itemstack.getData());

      worldmap1.scale = (byte) (worldmap.scale + 1);
      if (worldmap1.scale > 4) {
        worldmap1.scale = 4;
      }

      worldmap1.centerX = worldmap.centerX;
      worldmap1.centerZ = worldmap.centerZ;
      worldmap1.map = worldmap.map;
      worldmap1.c();
      world.a("map_" + itemstack.getData(), worldmap1);

      // CraftBukkit start
      MapInitializeEvent event = new MapInitializeEvent(worldmap1.mapView);
      Bukkit.getServer().getPluginManager().callEvent(event);
      // CraftBukkit end
    }
  }
コード例 #2
0
ファイル: ItemWorldMap.java プロジェクト: DaMarine/Alkazia
  public WorldMap getSavedMap(ItemStack itemstack, World world) {
    World worldMain =
        world
            .getServer()
            .getServer()
            .worlds
            .get(0); // CraftBukkit - store reference to primary world
    String s = "map_" + itemstack.getData();
    WorldMap worldmap =
        (WorldMap) worldMain.a(WorldMap.class, s); // CraftBukkit - use primary world for maps

    if (worldmap == null && !world.isStatic) {
      itemstack.setData(worldMain.b("map")); // CraftBukkit - use primary world for maps
      s = "map_" + itemstack.getData();
      worldmap = new WorldMap(s);
      worldmap.scale = 3;
      int i = 128 * (1 << worldmap.scale);

      worldmap.centerX = Math.round((float) world.getWorldData().c() / (float) i) * i;
      worldmap.centerZ = Math.round(world.getWorldData().e() / i) * i;
      worldmap.map =
          (byte) ((WorldServer) world).dimension; // CraftBukkit - fixes Bukkit multiworld maps
      worldmap.c();
      worldMain.a(s, worldmap); // CraftBukkit - use primary world for maps

      // CraftBukkit start
      MapInitializeEvent event = new MapInitializeEvent(worldmap.mapView);
      Bukkit.getServer().getPluginManager().callEvent(event);
      // CraftBukkit end
    }

    return worldmap;
  }