当前位置: 首页>>代码示例>>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;未经允许,请勿转载。