當前位置: 首頁>>代碼示例>>Java>>正文


Java Chest.getLocation方法代碼示例

本文整理匯總了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));
    }
}
 
開發者ID:EpicEricEE,項目名稱:ShopChest,代碼行數:23,代碼來源:ChestProtectListener.java

示例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());
}
 
開發者ID:netizen539,項目名稱:civcraft,代碼行數:25,代碼來源:InventoryHolderStorage.java

示例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;
}
 
開發者ID:xize,項目名稱:xEssentials_old_Source,代碼行數:18,代碼來源:ManCoHook.java

示例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);
}
 
開發者ID:RoyalDev,項目名稱:RoyalSurvivors,代碼行數:21,代碼來源:SurvivorsListener.java

示例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;
	}
 
開發者ID:Esaych,項目名稱:DDCustomPlugin,代碼行數:47,代碼來源:AutoConfiscate.java

示例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();
}
 
開發者ID:Craftolution,項目名稱:CraftoPlugin,代碼行數:44,代碼來源:Treasure.java


注:本文中的org.bukkit.block.Chest.getLocation方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。