Package org.bukkit

Examples of org.bukkit.Chunk


            if (resident == null) break;
            if (currentTime > resident.getTeleportRequestTime() + (TownySettings.getTeleportWarmupTime() * 1000)) {
                resident.clearTeleportRequest();
                try {
                  // Make sure the chunk we teleport to is loaded.
                    Chunk chunk = resident.getTeleportDestination().getSpawn().getWorld().getChunkAt(resident.getTeleportDestination().getSpawn().getBlock());
                  if (!chunk.isLoaded()) chunk.load();
                    TownyUniverse.getPlayer(resident).teleport(resident.getTeleportDestination().getSpawn());
                } catch (TownyException ignore) { }
                teleportQueue.poll();
            } else {
                break;
View Full Code Here


  public static void regenUndo (ChunkSnapshot snapshot, Resident resident) {
     
      byte data;
      int typeId;
      World world = Bukkit.getWorld(snapshot.getWorldName());
      Chunk chunk = world.getChunkAt(MinecraftTools.calcChunk(snapshot.getX()), MinecraftTools.calcChunk(snapshot.getZ()));

      for (int x = 0 ; x < 16 ; x++) {
        for (int z = 0 ; z < 16 ; z++) {
          for (int y = 0 ; y < world.getMaxHeight() ; y++) {
            data = (byte) snapshot.getBlockData(x, y, z);
            typeId = snapshot.getBlockTypeId(x, y, z);
            chunk.getBlock(x, y, z).setTypeIdAndData(typeId, data, false);
          }
        }
       
      }
     
View Full Code Here

                // Check if need/can pay
                if (travelCost > 0 && TownySettings.isUsingEconomy() && (resident.getHoldingBalance() < travelCost))
                  throw new TownyException(notAffordMSG);
               
                // Used later to make sure the chunk we teleport to is loaded.
                Chunk chunk = town.getSpawn().getWorld().getChunkAt(town.getSpawn().getBlock());
               
                // Essentials tests
                boolean UsingESS = plugin.isEssentials();
               
                if (UsingESS && !isTownyAdmin) {
                        try {
                            User user = plugin.getEssentials().getUser(player);
                           
                            if (!user.isJailed()) {
                             
                                Teleport teleport = user.getTeleport();
                                if (!chunk.isLoaded()) chunk.load();
                                // Cause an essentials exception if in cooldown.
                                teleport.cooldown(true);
                                teleport.teleport(town.getSpawn(),null);
                            }
                        } catch (Exception e) {
                            TownyMessaging.sendErrorMsg(player, "Error: " + e.getMessage());
                            // cooldown?
                            return;
                        }
                }
               
                // Show message if we are using iConomy and are charging for spawn travel.
                if (travelCost > 0 && TownySettings.isUsingEconomy() && resident.payTo(travelCost, town, String.format("Town Spawn (%s)", townSpawnPermission))) {
                  TownyMessaging.sendMsg(player, String.format(TownySettings.getLangString("msg_cost_spawn"),
                        TownyEconomyObject.getFormattedBalance(travelCost))); // + TownyEconomyObject.getEconomyCurrency()));
                }
               
               
                // If an Admin or Essentials teleport isn't being used, use our own.
                if(isTownyAdmin) {
                  if (player.getVehicle() != null)
                    player.getVehicle().eject();
                  if (!chunk.isLoaded()) chunk.load();
                    player.teleport(town.getSpawn());
                    return;
                }
               
                if (!UsingESS) {
                    if (plugin.getTownyUniverse().isTeleportWarmupRunning()) {
                      // Use teleport warmup
                        player.sendMessage(String.format(TownySettings.getLangString("msg_town_spawn_warmup"),
                                TownySettings.getTeleportWarmupTime()));
                        plugin.getTownyUniverse().requestTeleport(player, town, travelCost);
                    } else {
                      // Don't use teleport warmup
                      if (player.getVehicle() != null)
                        player.getVehicle().eject();
                      if (!chunk.isLoaded()) chunk.load();
                        player.teleport(town.getSpawn());
                    }
                }
            } catch (TownyException e) {
                TownyMessaging.sendErrorMsg(player, e.getMessage());
View Full Code Here

TOP

Related Classes of org.bukkit.Chunk

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.