public void Notify(Object world, int x, int y, int z) {
   if (world instanceof CraftWorld) {
     WorldServer server = (WorldServer) ((CraftWorld) world).getHandle();
     server.notify(x, y, z);
   } else {
     InternalAccessor.Instance.PrintError();
   }
 }
Example #2
0
  @Override
  public void changeBlockBiome(Location location) {
    int x = location.getBlockX();
    int z = location.getBlockZ();
    WorldServer world = ((CraftWorld) location.getWorld()).getHandle();
    if (world.isLoaded(new BlockPosition(x, 0, z))) {
      Chunk chunk = world.getChunkAtWorldCoords(new BlockPosition(x, 0, z));

      if (chunk != null) {
        byte[] biomevals = chunk.getBiomeIndex();
        biomevals[((z & 0xF) << 4) | (x & 0xF)] = (byte) BiomeBase.a(biomeBase);
      }
    }
  }
Example #3
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 Properties getGameProperties() throws RemoteException {
   Properties ret = new Properties(WorldServer.getInstance().getWorldProp());
   try {
     Connection con = DatabaseConnection.getConnection();
     PreparedStatement ps =
         con.prepareStatement("SELECT * FROM channelconfig WHERE channelid = ?");
     ps.setInt(1, dbId);
     ResultSet rs = ps.executeQuery();
     while (rs.next()) {
       ret.setProperty(rs.getString("name"), rs.getString("value"));
     }
     rs.close();
     ps.close();
   } catch (SQLException ex) {
     log.error("Could not retrieve channel configuration", ex);
   }
   return ret;
 }
  @Overwrite
  @SneakyThrows
  public void teleport(MC_Location loc) {
    if (loc != null) {
      plr.setVehicle(null);
      _SerializableLocation sloc =
          new _SerializableLocation(loc.x, loc.y, loc.z, loc.dimension, loc.yaw, loc.pitch);
      if (loc.dimension != this.plr.dimension) {
        int newDimen = loc.dimension;
        MC_EventInfo ei = new MC_EventInfo();
        PlayerWrapper pWrap = new PlayerWrapper(this.plr);

        for (Object var2 : _JoeUtils.plugins) {
          try {
            ((PluginInfo) var2).ref.onAttemptPlayerChangeDimension(pWrap, newDimen, ei);
          } catch (Throwable var8) {
            var8.printStackTrace();
          }
        }

        if (_JoeUtils.DebugMode) {
          String var21 =
              String.format(
                  "JKC DEBUG: --- DimensionChange (%s) to --- (%s) --- %s @ %s",
                  new Object[] {
                    _JoeUtils.GetDimensionName(plr.dimension),
                    _JoeUtils.GetDimensionName(newDimen),
                    plr.getName(),
                    _JoeUtils.GetEntityLocationDescription(plr)
                  });
          System.out.println(var21);
        }

        WorldServer localWorldFrom =
            MinecraftServer.getServer().getWorldServerByDimension(plr.dimension);
        localWorldFrom.getEntityTracker().removePlayer(plr);
        localWorldFrom.getPlayerChunkMap().removePlayer(plr);
        MinecraftServer.getServer().getThePlayerList().players.remove(plr);
        plr.worldEnt.removeEntity(plr);
        plr.dimension = newDimen;
        WorldServer localWorldTo =
            MinecraftServer.getServer().getWorldServerByDimension(plr.dimension);
        plr.setEntityWorld(localWorldTo);
        plr.dead = false;
        plr.setPositionRotation(loc.x, loc.y, loc.z, loc.yaw, loc.pitch);
        localWorldTo.cachedChunks.getOrCreateChunk((int) plr.xCoord >> 4, (int) plr.zCoord >> 4);
        while (!localWorldTo.getNearbyEntities(plr, plr.funcAppliesIfCanBePushed()).isEmpty()
            && plr.yCoord < 256.0D) {
          plr.setPositionRotation(plr.xCoord, plr.yCoord + 1.0D, plr.zCoord, plr.yaw, plr.pitch);
        }
        plr.dead = false;
        int packetDimen = plr.dimension;
        if (packetDimen > 1) {
          Environment i =
              PluginMultiWorld.getInstance()
                  .getStorageManager()
                  .getCustomConfig(packetDimen)
                  .getEnvironment();
          GenerationType generationType =
              PluginMultiWorld.getInstance()
                  .getStorageManager()
                  .getCustomConfig(packetDimen)
                  .getGenerationType();
          if (generationType == GenerationType.END) {
            packetDimen = 1;
          } else if (generationType == GenerationType.NETHER
              || i == codecrafter47.multiworld.api.Environment.NETHER) {
            packetDimen = -1;
          } else if (i == codecrafter47.multiworld.api.Environment.END) {
            packetDimen = 1;
          } else {
            packetDimen = 0;
          }
        }
        plr.plrConnection.sendPacket(
            new Packet_Respawn(
                packetDimen,
                plr.worldEnt.getDifficulty(),
                plr.worldEnt.getWorldData().getLevelType(),
                plr.playerInteractManager.getGameMode()));
        plr.plrConnection.sendPacket(new Packet_SetExperience(plr.m_exp, plr.xpTotal, plr.xpLevel));
        plr.setSneaking(false);
        MinecraftServer.getServer()
            .getThePlayerList()
            .sendPlayerPacketsAboutNewDimension(plr, localWorldTo);
        localWorldTo.getPlayerChunkMap().addPlayer(plr);
        localWorldTo.addEntity(plr);
        MinecraftServer.getServer().getThePlayerList().players.add(plr);
        plr.playerInteractManager.setInnerWorld(localWorldTo);
        plr.setHealth(plr.getHealth());
        plr.updateInventory(plr.defaultContainer);
        if (localWorldTo.S()) {
          plr.plrConnection.sendPacket(new Packet_ChangeGameState(2, 0.0F));
        } else {
          plr.plrConnection.sendPacket(new Packet_ChangeGameState(1, 0.0F));
        }
      } else {
        this.plr.TeleportSLoc(sloc);
      }
    }
  }
 public Properties getDatabaseProperties() throws RemoteException {
   return WorldServer.getInstance().getDbProp();
 }