当前位置: 首页>>代码示例>>Java>>正文


Java Location.equals方法代码示例

本文整理汇总了Java中org.spongepowered.api.world.Location.equals方法的典型用法代码示例。如果您正苦于以下问题:Java Location.equals方法的具体用法?Java Location.equals怎么用?Java Location.equals使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.spongepowered.api.world.Location的用法示例。


在下文中一共展示了Location.equals方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: openBlockCase

import org.spongepowered.api.world.Location; //导入方法依赖的package包/类
@Listener(order = Order.LATE)
public void openBlockCase(InteractBlockEvent.Secondary.MainHand event) {
    Optional<Player> optional_player = event.getCause().first(Player.class);
    if (!optional_player.isPresent()) return;
    Player player = optional_player.get();
    Optional<Location<World>> optional_location = event.getTargetBlock().getLocation();
    if (!optional_location.isPresent()) return;
    Location<World> location = optional_location.get();
    for (Manager manager : GWMCrates.getInstance().getCreatedManagers()) {
        Case caze = manager.getCase();
        if (!(caze instanceof BlockCase)) continue;
        Location<World> block_case_location = ((BlockCase) caze).getLocation();
        if (!block_case_location.equals(location)) continue;
        event.setCancelled(true);
        OpenManager open_manager = manager.getOpenManager();
        if (!open_manager.canOpen(player, manager)) {
            player.sendMessage(LanguageUtils.getText("CAN_NOT_OPEN_CASE"));
            return;
        }
        Key key = manager.getKey();
        if (key.get(player) < 1) {
            player.sendMessage(LanguageUtils.getText("HAVE_NOT_KEY"));
            return;
        }
        key.add(player, -1);
        manager.getOpenManager().open(player, manager);
        break;
    }
}
 
开发者ID:GreWeMa,项目名称:gwm_Crates,代码行数:30,代码来源:BlockCaseListener.java

示例2: startBlockCasePreview

import org.spongepowered.api.world.Location; //导入方法依赖的package包/类
@Listener(order = Order.LATE)
public void startBlockCasePreview(InteractBlockEvent.Primary.MainHand event) {
    Optional<Player> optional_player = event.getCause().first(Player.class);
    if (!optional_player.isPresent()) return;
    Player player = optional_player.get();
    Optional<Location<World>> optional_location = event.getTargetBlock().getLocation();
    if (!optional_location.isPresent()) return;
    Location<World> location = optional_location.get();
    for (Manager manager : GWMCrates.getInstance().getCreatedManagers()) {
        String manager_id = manager.getId();
        Case caze = manager.getCase();
        if (!(caze instanceof BlockCase)) continue;
        Location<World> block_case_location = ((BlockCase) caze).getLocation();
        if (!block_case_location.equals(location)) continue;
        event.setCancelled(true);
        if (!((BlockCase) caze).isStartPreviewOnLeftClick()) return;
        Optional<Preview> optional_preview = manager.getPreview();
        if (!optional_preview.isPresent()) {
            player.sendMessage(LanguageUtils.getText("PREVIEW_NOT_AVAILABLE",
                    new Pair<String, String>("%MANAGER%", manager.getName())));
            return;
        }
        Preview preview = optional_preview.get();
        if (!player.hasPermission("gwm_crates.preview." + manager_id)) {
            player.sendMessage(LanguageUtils.getText("HAVE_NOT_PERMISSION"));
            return;
        }
        preview.preview(player, manager);
        player.sendMessage(LanguageUtils.getText("PREVIEW_STARTED",
                new Pair<String, String>("%MANAGER%", manager.getName())));
        break;
    }
}
 
开发者ID:GreWeMa,项目名称:gwm_Crates,代码行数:34,代码来源:BlockCaseListener.java


注:本文中的org.spongepowered.api.world.Location.equals方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。