本文整理汇总了Java中org.bukkit.event.inventory.InventoryOpenEvent.setCancelled方法的典型用法代码示例。如果您正苦于以下问题:Java InventoryOpenEvent.setCancelled方法的具体用法?Java InventoryOpenEvent.setCancelled怎么用?Java InventoryOpenEvent.setCancelled使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.event.inventory.InventoryOpenEvent
的用法示例。
在下文中一共展示了InventoryOpenEvent.setCancelled方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onAnvilOpen
import org.bukkit.event.inventory.InventoryOpenEvent; //导入方法依赖的package包/类
@EventHandler
public void onAnvilOpen(InventoryOpenEvent e) {
if (e.getPlayer().equals(null)) {
return;
}
if (e.getInventory().equals(null)) {
return;
}
Game bw = io.github.bedwarsrel.BedwarsRel.Main.getInstance()
.getGameManager().getGameOfPlayer((Player) e.getPlayer());
if (bw == null) {
return;
}
if (!Config.isGameEnabledXP(bw.getName())) {
return;
}
if (e.getInventory().getType().equals(InventoryType.ANVIL)) {
e.setCancelled(true);
}
}
示例2: onAnvilOpen
import org.bukkit.event.inventory.InventoryOpenEvent; //导入方法依赖的package包/类
@EventHandler
public void onAnvilOpen(InventoryOpenEvent e) {
if (e.getPlayer().equals(null)) {
return;
}
if (e.getInventory().equals(null)) {
return;
}
Game bw = io.github.yannici.bedwars.Main.getInstance().getGameManager()
.getGameOfPlayer((Player) e.getPlayer());
if (bw == null) {
return;
}
if (!Config.isGameEnabledXP(bw.getName())) {
return;
}
if (e.getInventory().getType().equals(InventoryType.ANVIL)) {
e.setCancelled(true);
}
}
示例3: onPetInventoryOpened
import org.bukkit.event.inventory.InventoryOpenEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.LOWEST)
public void onPetInventoryOpened(InventoryOpenEvent event) {
Player player = (Player) event.getPlayer();
if (!InventoryManager.playerIsLoaded(player)) {
return;
}
final PlayerWrapper playerWrapper = InventoryManager.get(player);
if (playerWrapper.hasPet() && event.getInventory().getHolder() == playerWrapper.getPet()) {
playerWrapper.openInventory();
event.setCancelled(true);
new BukkitRunnable() {
@Override
public void run() {
HorseInventory horseInv = ((Horse) playerWrapper.getPet()).getInventory();
horseInv.setSaddle(new ItemStack(Material.SADDLE));
}
}.runTaskLater(RPGInventory.getInstance(), 1);
}
}
示例4: callInventoryOpenEvent
import org.bukkit.event.inventory.InventoryOpenEvent; //导入方法依赖的package包/类
public static Container callInventoryOpenEvent(EntityPlayer player, Container container, boolean cancelled) {
if (player.activeContainer != player.defaultContainer) { // fire INVENTORY_CLOSE if one already open
player.playerConnection.a(new PacketPlayInCloseWindow(player.activeContainer.windowId));
}
CraftServer server = player.world.getServer();
CraftPlayer craftPlayer = player.getBukkitEntity();
player.activeContainer.transferTo(container, craftPlayer);
InventoryOpenEvent event = new InventoryOpenEvent(container.getBukkitView());
event.setCancelled(cancelled);
server.getPluginManager().callEvent(event);
if (event.isCancelled()) {
container.transferTo(player.activeContainer, craftPlayer);
return null;
}
return container;
}
示例5: onVillagerTrade
import org.bukkit.event.inventory.InventoryOpenEvent; //导入方法依赖的package包/类
@EventHandler
public void onVillagerTrade(InventoryOpenEvent event) {
if (!plugin.isSkyAssociatedWorld(event.getPlayer().getWorld())) {
return;
}
if (!(event.getPlayer() instanceof Player)) {
return;
}
if (villagerTradingEnabled
&& event.getPlayer() instanceof Player
&& !(hasPermission(event.getPlayer(), "usb.mod.bypassprotection"))
&& event.getInventory().getType() == InventoryType.MERCHANT
&& !plugin.playerIsOnIsland((Player)event.getPlayer())) {
event.setCancelled(true);
event.getPlayer().sendMessage(tr("\u00a7eTrading isn't allowed on other islands. Do it in spawn."));
return;
}
}
示例6: onInventoryOpenEvent
import org.bukkit.event.inventory.InventoryOpenEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.HIGHEST)
public void onInventoryOpenEvent(InventoryOpenEvent event) {
if (event.getInventory() instanceof DoubleChestInventory) {
DoubleChestInventory doubleInv = (DoubleChestInventory)event.getInventory();
Chest leftChest = (Chest)doubleInv.getHolder().getLeftSide();
/*Generate a new player 'switch' event for the left and right chests. */
PlayerInteractEvent interactLeft = new PlayerInteractEvent((Player)event.getPlayer(), Action.RIGHT_CLICK_BLOCK, null, leftChest.getBlock(), null);
BlockListener.OnPlayerSwitchEvent(interactLeft);
if (interactLeft.isCancelled()) {
event.setCancelled(true);
return;
}
Chest rightChest = (Chest)doubleInv.getHolder().getRightSide();
PlayerInteractEvent interactRight = new PlayerInteractEvent((Player)event.getPlayer(), Action.RIGHT_CLICK_BLOCK, null, rightChest.getBlock(), null);
BlockListener.OnPlayerSwitchEvent(interactRight);
if (interactRight.isCancelled()) {
event.setCancelled(true);
return;
}
}
}
示例7: PlayerInventoryOpen
import org.bukkit.event.inventory.InventoryOpenEvent; //导入方法依赖的package包/类
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOW)
public void PlayerInventoryOpen(final InventoryOpenEvent event)
{
if (!(event.getPlayer() instanceof Player))
return;
final Player player = (Player) event.getPlayer();
if (plugin.isLoggedIn(player))
{
final LoginPlayerData playerdata = plugin.getPlayerData(player);
if (playerdata != null)
playerdata.notifyAction();
return;
}
event.setCancelled(true);
player.closeInventory();
plugin.sendAuthReminderMessage(player);
}
示例8: onInventoryOpening
import org.bukkit.event.inventory.InventoryOpenEvent; //导入方法依赖的package包/类
/**
* Controls chest ownership for carts.
*
* @param e The {@link InventoryMoveItemEvent} associated with the chest.
*/
@EventHandler
public void onInventoryOpening(InventoryOpenEvent e) {
Inventory inv = e.getInventory();
if (e.getPlayer() instanceof Player) {
Player p = (Player) e.getPlayer();
if (inv.getHolder() instanceof Minecart) {
Minecart cart = (Minecart) inv.getHolder();
MinecartMember<?> toCheck = MinecartMemberStore.getAt(cart.getLocation());
if (toCheck != null && !toCheck.isDerailed()) {
CartProperties cp = toCheck.getProperties();
if (!cp.getOwners().contains(p.getName().toLowerCase())) {
p.sendMessage(ChatColor.RED + "You do not own this chest!");
e.setCancelled(true);
}
}
}
}
}
示例9: onInventoryOpenEvent
import org.bukkit.event.inventory.InventoryOpenEvent; //导入方法依赖的package包/类
/**
* Event handler to watch whenever a chest is opened.
* This will prevent the opening of the chest if necessary.
*
* @param event inventoryOpenEvent representing the inventory object that was just opened. We care about a Chest inventory being opened
*/
@EventHandler (ignoreCancelled=true)
public void onInventoryOpenEvent(InventoryOpenEvent event) {
//get the destination inventory
InventoryHolder holder = event.getInventory().getHolder();
//Make sure it is a chest
if (holder instanceof Chest) {
Location chestLocation = ((Chest) holder).getLocation();
//see if a filter is around the location
if (plugin.isChestNextToHopper(chestLocation)) {
Player player = (Player) event.getPlayer();
if (!player.hasPermission("hopperfiltersimplified.build.alter.chest")) {
plugin.sendMessageInfo(player, "You do not have rights to alter this hopper filter chest.");
event.setCancelled(true);
}
//debug if requested
if (plugin.debugLevel_get() > 0) plugin.getLogger().info("Chest next to hopper opened at (" + chestLocation.toString() + ")");
}
}
}
示例10: onInventoryOpen
import org.bukkit.event.inventory.InventoryOpenEvent; //导入方法依赖的package包/类
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
public void onInventoryOpen(final InventoryOpenEvent e) {
if (e.getView() instanceof LocaleInventory)
return;
if (e.getInventory().getType() != InventoryType.CHEST || !useLocaleInv) {
Inventory in = e.getInventory();
Iterator<ItemStack> it = in.iterator();
String locale = Locale.getPlayerLocale((Player) e.getPlayer());
try {
while (it.hasNext()) {
ItemStack item = it.next();
if (ItemManager.toRPGItem(item) != null)
RPGItem.updateItem(item, locale);
}
} catch (ArrayIndexOutOfBoundsException ex) {
// Fix for the bug with anvils in craftbukkit
}
} else if (useLocaleInv) {
LocaleInventory localeInv = new LocaleInventory((Player) e.getPlayer(), e.getView());
e.setCancelled(true);
e.getPlayer().openInventory(localeInv);
localeInventories.add(localeInv);
}
}
示例11: protectHorseInventory
import org.bukkit.event.inventory.InventoryOpenEvent; //导入方法依赖的package包/类
@EventHandler
public void protectHorseInventory(InventoryOpenEvent event){
if(event.getInventory().getHolder() instanceof Horse){
Horse h = (Horse)event.getInventory().getHolder();
Player p = (Player) event.getPlayer();
String playername = event.getPlayer().getName();
if(p.isOp() || p.hasPermission("echorse.override")){ //Op & permission check
return;
}
if(!(h.getOwner().getName() == playername)){ //Not the horse owner, cancel event
event.setCancelled(true);
p.sendMessage(ChatColor.AQUA + "[ECHorses]" + ChatColor.RED + " You dont have permission to open " + h.getOwner().getName() + "'s horse inventory!");
return;
}
return;
}
return;
}
示例12: onInventoryOpening
import org.bukkit.event.inventory.InventoryOpenEvent; //导入方法依赖的package包/类
/**
* This will facilitate the need to update the {@link TrainFactory#ownerStorage} list, because if the inventory changes, the instance changes.
*
* @param e The {@link InventoryMoveItemEvent} associated with the chest.
*/
@EventHandler
public void onInventoryOpening(InventoryOpenEvent e) {
Inventory inv = e.getInventory();
if(e.getPlayer() instanceof Player) {
Player p = (Player) e.getPlayer();
if(inv.getHolder() instanceof Minecart) {
Minecart cart = (Minecart) inv.getHolder();
MinecartMember<?> toCheck = MinecartMemberStore.getAt(cart.getLocation());
if(toCheck != null) {
CartProperties cp = toCheck.getProperties();
if(!cp.getOwners().contains(p.getName().toLowerCase())) {
p.sendMessage(ChatColor.RED + "You do not own this chest!");
e.setCancelled(true);
}
}
}
}
}
示例13: onChestClick
import org.bukkit.event.inventory.InventoryOpenEvent; //导入方法依赖的package包/类
/**
* This will be used to facilitate the permissions of chest minecarts.
*
* @param event The {@link InventoryOpenEvent} associated with the chest.
*/
public void onChestClick(InventoryOpenEvent event) {
event.setCancelled(true);
Player p = (Player) event.getPlayer();
Inventory i = event.getInventory();
if(TrainFactory.ownerStorage.containsKey(p)) {
for(MinecartMemberChest chest : TrainFactory.getInventoryList(p)) {
if(chest.getEntity().getInventory() == i) {
event.setCancelled(false);
break;
}
}
}
}
示例14: onInventoryOpenEvent
import org.bukkit.event.inventory.InventoryOpenEvent; //导入方法依赖的package包/类
@EventHandler
public void onInventoryOpenEvent(InventoryOpenEvent event) {
final Player player = (Player) event.getPlayer();
if (this.manager.carryingPet.contains(player)) {
event.setCancelled(true);
event.getPlayer().closeInventory();
}
}
示例15: onBlockInvOpen
import org.bukkit.event.inventory.InventoryOpenEvent; //导入方法依赖的package包/类
@EventHandler
public void onBlockInvOpen(InventoryOpenEvent e) {
if (GameStatus.isState(gameStatus))
if (e.getInventory().getType() != InventoryType.PLAYER
|| e.getInventory().getType() != InventoryType.CHEST)
e.setCancelled(!canOpenBlockInv);
}