本文整理汇总了Java中org.bukkit.event.inventory.InventoryCreativeEvent类的典型用法代码示例。如果您正苦于以下问题:Java InventoryCreativeEvent类的具体用法?Java InventoryCreativeEvent怎么用?Java InventoryCreativeEvent使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
InventoryCreativeEvent类属于org.bukkit.event.inventory包,在下文中一共展示了InventoryCreativeEvent类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onInventoryClick
import org.bukkit.event.inventory.InventoryCreativeEvent; //导入依赖的package包/类
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onInventoryClick(final InventoryClickEvent event) {
if(event instanceof InventoryCreativeEvent) return;;
// Ensure the player is clicking in their own inventory
// TODO: should we allow items to be locked into other types of inventories?
if(!Objects.equals(event.getWhoClicked(), event.getInventory().getHolder())) return;
// Break out of the switch if the action will move a locked item, otherwise return
switch(event.getAction()) {
case HOTBAR_SWAP:
case HOTBAR_MOVE_AND_READD:
// These actions can move up to two stacks. Check the hotbar stack,
// and then fall through to check the stack under the cursor.
if(isLocked(Slot.Hotbar.forPosition(event.getHotbarButton())
.getItem(event.getWhoClicked().getInventory()))) break;
// fall through
case PICKUP_ALL:
case PICKUP_HALF:
case PICKUP_SOME:
case PICKUP_ONE:
case SWAP_WITH_CURSOR:
case MOVE_TO_OTHER_INVENTORY:
case DROP_ONE_SLOT:
case DROP_ALL_SLOT:
case COLLECT_TO_CURSOR:
// All these actions move only a single stack, except COLLECT_TO_CURSOR,
// which can only move items that are stackable with the one under the cursor,
// and locked items are only stackable with other locked items.
if(isLocked(event.getCurrentItem())) break;
// fall through
default: return;
}
event.setCancelled(true);
sendLockWarning(event.getWhoClicked());
}
示例2: onInventoryCreative
import org.bukkit.event.inventory.InventoryCreativeEvent; //导入依赖的package包/类
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
public void onInventoryCreative(InventoryCreativeEvent event) {
HumanEntity humanEntity = event.getWhoClicked();
if (humanEntity instanceof Player && !humanEntity.hasPermission("base.command.gamemode")) {
event.setCancelled(true);
// humanEntity.sendMessage(ChatColor.RED + "You are not allowed to be in gamemode! Setting you to default gamemode!");
humanEntity.setGameMode(GameMode.SURVIVAL);
}
}
示例3: onInventoryCreative
import org.bukkit.event.inventory.InventoryCreativeEvent; //导入依赖的package包/类
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
public void onInventoryCreative(InventoryCreativeEvent event) {
HumanEntity humanEntity = event.getWhoClicked();
if (humanEntity instanceof Player && !humanEntity.hasPermission("base.command.gamemode")) {
event.setCancelled(true);
// humanEntity.sendMessage(ChatColor.RED + "You are not allowed to be in gamemode! Setting you to default gamemode!");
humanEntity.setGameMode(GameMode.SURVIVAL);
}
}
示例4: onCreativeSlotChange
import org.bukkit.event.inventory.InventoryCreativeEvent; //导入依赖的package包/类
@EventHandler(priority = EventPriority.LOWEST)
public void onCreativeSlotChange(InventoryCreativeEvent event) {
if (timeouts.isEmpty()) {
return; // Saves performance for most common case
}
InventoryHolder holder = event.getInventory().getHolder();
if (holder instanceof Player && timeouts.containsKey(((Player) holder).getUniqueId())) {
event.setResult(Event.Result.DENY);
}
}
示例5: onPick
import org.bukkit.event.inventory.InventoryCreativeEvent; //导入依赖的package包/类
@EventHandler
public void onPick(InventoryCreativeEvent event){
if(locked_players.containsKey(event.getWhoClicked())) {
if (event.getClick().equals(ClickType.CREATIVE)) {
if (event.getAction().equals(InventoryAction.PLACE_ALL)) {
if (event.getCursor() != null) {
if (!event.getCursor().getType().equals(Material.AIR)) {
event.setCancelled(true);
locked_players.get(event.getWhoClicked()).changeBlock(new VirtualBlock(event.getCursor().getType()), (Player) event.getWhoClicked());
}
}
}
}
}
}
示例6: creativeInventory
import org.bukkit.event.inventory.InventoryCreativeEvent; //导入依赖的package包/类
@EventHandler
public void creativeInventory(InventoryCreativeEvent e) {
if (e.getWhoClicked().hasPermission("commandspy.track")) {
Runnable task = new CommandSpyFile(((Player) e.getWhoClicked()).getName(), "Inventory", "Own Inventory" + e.getAction() + "|" + e.getCurrentItem());
new Thread(task, "CommandSpy").start();
}
}
示例7: onCreative
import org.bukkit.event.inventory.InventoryCreativeEvent; //导入依赖的package包/类
@EventHandler(priority = EventPriority.HIGH)
public void onCreative(InventoryCreativeEvent event) {
try {
Player p = (Player) event.getWhoClicked();
if (SGApi.getArenaManager().getArena(p).spectators.contains(p.getName()))
event.setCancelled(true);
} catch (ArenaNotFoundException ignored) {}
}
示例8: creativeInventory
import org.bukkit.event.inventory.InventoryCreativeEvent; //导入依赖的package包/类
@EventHandler
public void creativeInventory(InventoryCreativeEvent e) {
if (e.getWhoClicked().hasPermission("commandspy.track")) {
final String name = e.getWhoClicked().getName();
final InventoryAction invAction = e.getAction();
final ItemStack item = e.getCurrentItem();
BukkitScheduler scheduler = Bukkit.getServer().getScheduler();
scheduler.scheduleAsyncDelayedTask(SQDuties.getPluginMain(), new Runnable() {
@Override
public void run() {
(new CommandSpyFile(name, "Inventory", ("Own Inventory " + invAction + "|" + item))).run();
}
},1);
}
}
示例9: inventoryMenuPrevention
import org.bukkit.event.inventory.InventoryCreativeEvent; //导入依赖的package包/类
@EventHandler(priority = EventPriority.HIGHEST)
public void inventoryMenuPrevention(InventoryCreativeEvent event) {
if (event.getView().getTopInventory().getTitle().startsWith("CE"))
event.setCancelled(true);
}
示例10: onViewingInventoryClick
import org.bukkit.event.inventory.InventoryCreativeEvent; //导入依赖的package包/类
@EventHandler(priority = EventPriority.MONITOR)
public void onViewingInventoryClick(InventoryCreativeEvent event) {
updateNextTick(event.getActor());
}
示例11: onCreative
import org.bukkit.event.inventory.InventoryCreativeEvent; //导入依赖的package包/类
@EventHandler
public void onCreative(InventoryCreativeEvent evt) {
ItemStack itemStack = evt.getCurrentItem();
ItemStack newStack = new ItemStack(itemStack.getType(), itemStack.getAmount());
evt.setCurrentItem(newStack);
}
示例12: unregister
import org.bukkit.event.inventory.InventoryCreativeEvent; //导入依赖的package包/类
public void unregister() {
InventoryCreativeEvent.getHandlerList().unregister(this);
}
示例13: onCreativeInventory
import org.bukkit.event.inventory.InventoryCreativeEvent; //导入依赖的package包/类
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onCreativeInventory(InventoryCreativeEvent evt) {
plugin.getChecker().checkItem(evt.getCursor(), evt.getWhoClicked());
}
示例14: unregister
import org.bukkit.event.inventory.InventoryCreativeEvent; //导入依赖的package包/类
@Override
public void unregister() {
InventoryCreativeEvent.getHandlerList().unregister(this);
}