本文整理汇总了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;
}
}
示例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;
}
}