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


Java DoubleChest.getRightSide方法代碼示例

本文整理匯總了Java中org.bukkit.block.DoubleChest.getRightSide方法的典型用法代碼示例。如果您正苦於以下問題:Java DoubleChest.getRightSide方法的具體用法?Java DoubleChest.getRightSide怎麽用?Java DoubleChest.getRightSide使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.bukkit.block.DoubleChest的用法示例。


在下文中一共展示了DoubleChest.getRightSide方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: removeShop

import org.bukkit.block.DoubleChest; //導入方法依賴的package包/類
/** Remove a shop
 * @param shop Shop to remove
 * @param removeFromDatabase Whether the shop should also be removed from the database
 * @param callback Callback that - if succeeded - returns null
 */
public void removeShop(Shop shop, boolean removeFromDatabase, Callback<Void> callback) {
    plugin.debug("Removing shop (#" + shop.getID() + ")");

    InventoryHolder ih = shop.getInventoryHolder();

    if (ih instanceof DoubleChest) {
        DoubleChest dc = (DoubleChest) ih;
        Chest r = (Chest) dc.getRightSide();
        Chest l = (Chest) dc.getLeftSide();

        shopLocation.remove(r.getLocation());
        shopLocation.remove(l.getLocation());
    } else {
        shopLocation.remove(shop.getLocation());
    }

    shop.removeItem();
    shop.removeHologram();

    if (removeFromDatabase) {
        plugin.getShopDatabase().removeShop(shop, callback);
    } else {
        if (callback != null) callback.callSyncResult(null);
    }
}
 
開發者ID:EpicEricEE,項目名稱:ShopChest,代碼行數:31,代碼來源:ShopUtils.java

示例2: remove

import org.bukkit.block.DoubleChest; //導入方法依賴的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

示例3: onItemMove

import org.bukkit.block.DoubleChest; //導入方法依賴的package包/類
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void onItemMove(InventoryMoveItemEvent e) {
    if (config.hopper_protection) {
        if ((e.getSource().getType().equals(InventoryType.CHEST)) && (!e.getInitiator().getType().equals(InventoryType.PLAYER))) {

            if (e.getSource().getHolder() instanceof DoubleChest) {
                DoubleChest dc = (DoubleChest) e.getSource().getHolder();
                Chest r = (Chest) dc.getRightSide();
                Chest l = (Chest) dc.getLeftSide();

                if (shopUtils.isShop(r.getLocation()) || shopUtils.isShop(l.getLocation())) e.setCancelled(true);

            } else if (e.getSource().getHolder() instanceof Chest) {
                Chest c = (Chest) e.getSource().getHolder();

                if (shopUtils.isShop(c.getLocation())) e.setCancelled(true);
            }

        }
    }
}
 
開發者ID:EpicEricEE,項目名稱:ShopChest,代碼行數:22,代碼來源:ChestProtectListener.java

示例4: addShop

import org.bukkit.block.DoubleChest; //導入方法依賴的package包/類
/**
 * Add a shop
 * @param shop Shop to add
 * @param addToDatabase Whether the shop should also be added to the database
 * @param callback Callback that - if succeeded - returns the ID the shop had or was given (as {@code int})
 */
public void addShop(Shop shop, boolean addToDatabase, Callback<Integer> callback) {
    InventoryHolder ih = shop.getInventoryHolder();
    plugin.debug("Adding shop... (#" + shop.getID() + ")");

    if (ih instanceof DoubleChest) {
        DoubleChest dc = (DoubleChest) ih;
        Chest r = (Chest) dc.getRightSide();
        Chest l = (Chest) dc.getLeftSide();

        plugin.debug("Added shop as double chest. (#" + shop.getID() + ")");

        shopLocation.put(r.getLocation(), shop);
        shopLocation.put(l.getLocation(), shop);
    } else {
        plugin.debug("Added shop as single chest. (#" + shop.getID() + ")");

        shopLocation.put(shop.getLocation(), shop);
    }

    if (addToDatabase) {
        plugin.getShopDatabase().addShop(shop, callback);
    } else {
        if (callback != null) callback.callSyncResult(shop.getID());
    }

}
 
開發者ID:EpicEricEE,項目名稱:ShopChest,代碼行數:33,代碼來源:ShopUtils.java

示例5: createHologram

import org.bukkit.block.DoubleChest; //導入方法依賴的package包/類
/**
 * Creates the hologram of the shop
 */
private void createHologram() {
    plugin.debug("Creating hologram (#" + id + ")");

    InventoryHolder ih = getInventoryHolder();

    if (ih == null) return;

    Chest[] chests = new Chest[2];
    boolean doubleChest;

    if (ih instanceof DoubleChest) {
        DoubleChest dc = (DoubleChest) ih;
        Chest r = (Chest) dc.getRightSide();
        Chest l = (Chest) dc.getLeftSide();

        chests[0] = r;
        chests[1] = l;
        doubleChest = true;
    } else {
        chests[0] = (Chest) ih;
        doubleChest = false;
    }

    String[] holoText = getHologramText();
    Location holoLocation = getHologramLocation(doubleChest, chests);

    hologram = new Hologram(plugin, holoText, holoLocation);
}
 
開發者ID:EpicEricEE,項目名稱:ShopChest,代碼行數:32,代碼來源:Shop.java


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