本文整理匯總了Java中org.bukkit.block.Chest.getLocation方法的典型用法代碼示例。如果您正苦於以下問題:Java Chest.getLocation方法的具體用法?Java Chest.getLocation怎麽用?Java Chest.getLocation使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.bukkit.block.Chest
的用法示例。
在下文中一共展示了Chest.getLocation方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: remove
import org.bukkit.block.Chest; //導入方法依賴的package包/類
private void remove(final Shop shop, final Block b, final Player p) {
if (shop.getInventoryHolder() instanceof DoubleChest) {
DoubleChest dc = (DoubleChest) shop.getInventoryHolder();
final Chest l = (Chest) dc.getLeftSide();
final Chest r = (Chest) dc.getRightSide();
Location loc = (b.getLocation().equals(l.getLocation()) ? r.getLocation() : l.getLocation());
final Shop newShop = new Shop(shop.getID(), plugin, shop.getVendor(), shop.getProduct(), loc, shop.getBuyPrice(), shop.getSellPrice(), shop.getShopType());
shopUtils.removeShop(shop, true, new Callback<Void>(plugin) {
@Override
public void onResult(Void result) {
newShop.create(true);
shopUtils.addShop(newShop, true);
}
});
} else {
shopUtils.removeShop(shop, true);
plugin.debug(String.format("%s broke %s's shop (#%d)", p.getName(), shop.getVendor().getName(), shop.getID()));
p.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.SHOP_REMOVED));
}
}
示例2: setHolder
import org.bukkit.block.Chest; //導入方法依賴的package包/類
public void setHolder(InventoryHolder holder) throws CivException {
if (holder instanceof Player) {
Player player = (Player)holder;
playerName = player.getName();
blockLocation = null;
return;
}
if (holder instanceof Chest) {
Chest chest = (Chest)holder;
playerName = null;
blockLocation = chest.getLocation();
return;
}
if (holder instanceof DoubleChest) {
DoubleChest dchest = (DoubleChest)holder;
playerName = null;
blockLocation = dchest.getLocation();
return;
}
throw new CivException("Invalid holder passed to set holder:"+holder.toString());
}
示例3: getCrateLocation
import org.bukkit.block.Chest; //導入方法依賴的package包/類
public static Location getCrateLocation(Player p) {
ManCo manco = (ManCo) Bukkit.getPluginManager().getPlugin("ManCo");
if(manco.getApi().hasCrate(p)) {
if(manco.getApi().isFalling(p)) {
Location loc = manco.getApi().getFallingCrateLocation(p);
return loc;
} else {
try {
Chest chest = manco.getApi().getCrate(p);
return chest.getLocation();
} catch (ChestHasNoOwnerException e) {
// TODO Auto-generated catch block
}
}
}
return null;
}
示例4: placeRepairChest
import org.bukkit.block.Chest; //導入方法依賴的package包/類
@EventHandler
public void placeRepairChest(BlockPlaceEvent e) {
Player p = e.getPlayer();
if (!RUtils.isInInfectedWorld(p)) return;
ItemStack hand = e.getItemInHand();
if (hand == null || hand.getType() != Material.CHEST) return;
ItemMeta him = hand.getItemMeta();
ItemMeta fim = plugin.repairChest.getItemMeta();
String hdn = him.getDisplayName();
if (hdn == null || !hdn.equals(fim.getDisplayName())) return;
List<String> hl = him.getLore();
if (hl == null || !hl.containsAll(fim.getLore())) return;
Block b = e.getBlockPlaced();
if (!(b.getState() instanceof Chest)) return;
Chest c = (Chest) b.getState();
ConfManager cm = ConfManager.getConfManager("otherdata.yml");
Location l = c.getLocation();
String path = "repairchests." + l.getWorld().getName() + "," + l.getBlockX() + "," + l.getBlockY() + "," + l.getBlockZ();
cm.set(path + ".enabled", true);
}
示例5: isChestLogged
import org.bukkit.block.Chest; //導入方法依賴的package包/類
public boolean isChestLogged(Chest chest) {
reloadChestData();
Location chestLoc = chest.getLocation();
if (!chestLoc.getWorld().getName().equals(getChestData().getString("first_chest.location.world")))
return false;
int y = chestLoc.getBlockY();
int minY = getChestData().getInt("first_chest.location.y");
int maxY = minY + (yLayerNum() * 4);
int x = chestLoc.getBlockX();
int minX = getChestData().getInt("first_chest.location.x");
int maxX = getChestData().getInt("players_confiscated") * 3 + minX - 2;
int z = chestLoc.getBlockZ();
int minZ = getChestData().getInt("first_chest.location.z");
int maxZ = getChestData().getInt("chest_range") * 2 + minZ - 2;
// plugin.getLogger().info("Found chest_range: " + getChestData().getInt("chest_range"));
// plugin.getLogger().info("Found players_confiscated: " + getChestData().getInt("players_confiscated"));
// plugin.getLogger().info("Found layer number: " + yLayerNum());
//
// plugin.getLogger().info("minX = " + minX + " x = " + x + " maxX = " + maxX);
// plugin.getLogger().info("minZ = " + minZ + " z = " + z + " maxZ = " + maxZ);
// plugin.getLogger().info("minY = " + minY + " y = " + y + " maxY = " + maxY);
if (y < minY)
return false;
if (y > maxY)
return false;
if (z < minZ)
return false;
if (z > maxZ)
return false;
if (x < minX)
return false;
if (x > maxX)
return false;
// plugin.getLogger().info("Chest Logged");
return true;
}
示例6: Treasure
import org.bukkit.block.Chest; //導入方法依賴的package包/類
Treasure(TreasureModule module, String name, Chest chest) throws IOException, IllegalStateException {
Check.nonNulls("the module/name/chest must not be null!", module, name, chest);
debug("Treasure instantiated with name: " + name);
this.module = module;
this.filePath = module.storage.treasureDirectory.resolve(name + ".yml");
debug("this.filePath = " + this.filePath.toString());
// Check if file already exists, if it does -> throw exception, if not -> create it
if (Files.exists(filePath)) { throw new IllegalStateException("Treasure file: " + filePath + " already exists!"); }
else if (Files.notExists(this.filePath)) { Files.createFile(this.filePath); debug("Created file!"); }
this.enabled = true;
this.name = name;
debug("this.name = " + this.name);
// Try to find pair block (if this treasure is a doublechest)
Pair<Block, Block> pairBlocks = Utility.getPairBlocks(chest.getBlock().getState()).orElse(null);
if (pairBlocks != null && pairBlocks.allPresent()) {
// Both blocks are present in pairBlocks, so we have a doublechest in this case
this.location = pairBlocks.getFirst().getLocation();
this.secondLocation = Optional.of(pairBlocks.getSecond().getLocation());
}
else {
// No doublechest found
this.location = chest.getLocation();
this.secondLocation = Optional.empty();
}
this.playerList = Lists.newArrayList();
this.itemList = Lists.newArrayList();
this.sessionMap = Maps.newHashMap();
// Fill this.itemList with every item contained in the chest
for (ItemStack item : chest.getInventory().getContents()) {
this.itemList.add(item);
}
// Save this new treasure to disk
this.save();
}