本文整理汇总了Java中org.spongepowered.api.item.ItemTypes.NONE属性的典型用法代码示例。如果您正苦于以下问题:Java ItemTypes.NONE属性的具体用法?Java ItemTypes.NONE怎么用?Java ItemTypes.NONE使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.spongepowered.api.item.ItemTypes
的用法示例。
在下文中一共展示了ItemTypes.NONE属性的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onClickInventory
@Listener
public void onClickInventory(final ClickInventoryEvent event, @First Player player) {
//Make sure we have a transaction to validate
if (event.getTransactions().size() <= 0) {
return;
}
//Get the first transaction of this event
final SlotTransaction slotTransaction = event.getTransactions().get(0);
final Slot slot = slotTransaction.getSlot();
//If the player is interacting with a TileEntityCarrier
if (slot.parent() instanceof TileEntityCarrier) {
//If the final item is NONE (or amount is less) person is trying to withdraw (so we care about it)
if (slotTransaction.getFinal().getType() == ItemTypes.NONE || slotTransaction.getFinal().getCount() < slotTransaction.getOriginal().getCount()) {
//Then check to see if there's a lock
final Optional<Lock> lock = Latch.getLockManager().getLock(((TileEntityCarrier) slot.parent()).getLocation());
//If there's a donation lock the player CANNOT access
if (lock.isPresent() && lock.get().getLockType() == LockType.DONATION && !lock.get().canAccess(player.getUniqueId())) {
event.setCancelled(true);
}
}
}
}
示例2: canInteract
private boolean canInteract(Player p, Region r){
boolean claimRps = RedProtect.get().cfgs.getGlobalFlag(p.getWorld().getName(),"deny-item-usage","allow-on-claimed-rps");
boolean wilderness = RedProtect.get().cfgs.getGlobalFlag(p.getWorld().getName(),"deny-item-usage","allow-on-wilderness");
ItemType item = ItemTypes.NONE;
if (p.getItemInHand(HandTypes.MAIN_HAND).isPresent()){
item = p.getItemInHand(HandTypes.MAIN_HAND).get().getItem();
} else if (p.getItemInHand(HandTypes.OFF_HAND).isPresent()){
item = p.getItemInHand(HandTypes.OFF_HAND).get().getItem();
}
//deny item usage
if (!RedProtect.get().ph.hasPerm(p, "RedProtect.get().bypass") && !item.equals(ItemTypes.NONE) && RedProtect.get().cfgs.getGlobalFlagList(p.getWorld().getName(),"deny-item-usage","items").contains(item.getType().getName())){
if (r != null && ((!claimRps && r.canBuild(p)) || (claimRps && !r.canBuild(p)))){
RPLang.sendMessage(p, "playerlistener.region.cantuse");
return false;
}
if (r == null && !wilderness){
RPLang.sendMessage(p, "playerlistener.region.cantuse");
return false;
}
}
return true;
}
示例3: getConsumedItemStacks
private Set<ItemStack> getConsumedItemStacks(List<SlotTransaction> transactions) {
Set<ItemStack> consumed = Sets.newHashSet();
for (SlotTransaction transaction : transactions) {
if (transaction.getOriginal().getType() == ItemTypes.NONE) {
continue;
}
int newCount = transaction.getFinal().getType() != ItemTypes.NONE ? transaction.getFinal().getCount() : 0;
if (newCount >= transaction.getOriginal().getCount()) {
continue;
}
int stackSize = transaction.getOriginal().getCount() - newCount;
consumed.add(createStackWithCustomQuantity(transaction.getOriginal().createStack(), stackSize));
}
return consumed;
}
示例4: getResult
private Entry<ItemStack, Integer> getResult(List<SlotTransaction> transactions) {
ItemStack result = null;
int created = 0;
for (SlotTransaction transaction : transactions) {
if (transaction.getFinal().getType() == ItemTypes.NONE) {
continue;
}
int oldCount = transaction.getOriginal().getType() != ItemTypes.NONE
? transaction.getOriginal().getCount() : 0;
int newCount = transaction.getFinal().getCount();
if (newCount <= oldCount) {
continue;
}
if (result == null) {
result = createStackWithCustomQuantity(transaction.getFinal().createStack(), 1);
}
created += newCount - oldCount;
}
return Maps.immutableEntry(result, created);
}
示例5: freeSlots
public static int freeSlots(Iterable<Inventory> slots) {
int count = 0;
for (Inventory i : slots) {
Optional<ItemStack> ois = i.peek();
if (!ois.isPresent() || ois.get().getItem() == ItemTypes.NONE) {
count++;
}
}
return count;
}
示例6: usedSlots
public static int usedSlots(Iterable<Inventory> slots) {
int count = 0;
for (Inventory i : slots) {
Optional<ItemStack> ois = i.peek();
if (ois.isPresent() && ois.get().getItem() != ItemTypes.NONE) {
count++;
}
}
return count;
}
示例7: getItemHand
public static ItemType getItemHand(Player p){
ItemType itemInHand = ItemTypes.NONE;
if (p.getItemInHand(HandTypes.MAIN_HAND).isPresent()){
itemInHand = p.getItemInHand(HandTypes.MAIN_HAND).get().getItem();
} else if (p.getItemInHand(HandTypes.OFF_HAND).isPresent()){
itemInHand = p.getItemInHand(HandTypes.OFF_HAND).get().getItem();
}
return itemInHand;
}
示例8: onBlockPlace
@Listener(order = Order.FIRST, beforeModifications = true)
public void onBlockPlace(ChangeBlockEvent.Place e, @First Player p) {
RedProtect.get().logger.debug("default","RPGlobalListener - Is ChangeBlockEvent event! Cancelled? " + e.isCancelled());
BlockSnapshot b = e.getTransactions().get(0).getFinal();
ItemType item = ItemTypes.NONE;
if (p.getItemInHand(HandTypes.MAIN_HAND).isPresent()){
item = p.getItemInHand(HandTypes.MAIN_HAND).get().getItem();
} else if (p.getItemInHand(HandTypes.OFF_HAND).isPresent()){
item = p.getItemInHand(HandTypes.OFF_HAND).get().getItem();
}
Region r = RedProtect.get().rm.getTopRegion(e.getTransactions().get(0).getOriginal().getLocation().get());
if (r != null){
return;
}
if (!RPUtil.canBuildNear(p, b.getLocation().get())){
e.setCancelled(true);
return;
}
if (item.getName().contains("minecart") || item.getName().contains("boat")){
if (!RedProtect.get().cfgs.getGlobalFlag(p.getWorld().getName(), "use-minecart") && !p.hasPermission("RedProtect.get().bypass")){
e.setCancelled(true);
RedProtect.get().logger.debug("default","RPGlobalListener - Can't place minecart/boat!");
}
} else {
if (!bypassBuild(p, b, 1)){
e.setCancelled(true);
RedProtect.get().logger.debug("default", "RPGlobalListener - Can't Build!");
}
}
}
示例9: onInteractBlock
@Listener(order = Order.FIRST, beforeModifications = true)
public void onInteractBlock(InteractBlockEvent event, @First Player p) {
BlockSnapshot b = event.getTargetBlock();
Location<World> l = null;
RedProtect.get().logger.debug("player","RPBlockListener - Is InteractBlockEvent event");
if (!b.getState().getType().equals(BlockTypes.AIR)){
l = b.getLocation().get();
RedProtect.get().logger.debug("player","RPBlockListener - Is InteractBlockEvent event. The block is " + b.getState().getType().getName());
} else {
l = p.getLocation();
}
Region r = RedProtect.get().rm.getTopRegion(l);
if (r != null){
ItemType itemInHand = ItemTypes.NONE;
if (p.getItemInHand(HandTypes.MAIN_HAND).isPresent()){
itemInHand = p.getItemInHand(HandTypes.MAIN_HAND).get().getItem();
} else if (p.getItemInHand(HandTypes.OFF_HAND).isPresent()){
itemInHand = p.getItemInHand(HandTypes.OFF_HAND).get().getItem();
}
if (itemInHand.equals(ItemTypes.ARMOR_STAND) && !r.canBuild(p)){
RPLang.sendMessage(p, "blocklistener.region.cantbuild");
event.setCancelled(true);
}
}
}
示例10: onInteractLeft
@Listener(order = Order.FIRST)
public void onInteractLeft(InteractBlockEvent.Primary event, @First Player p) {
BlockSnapshot b = event.getTargetBlock();
Location<World> l = null;
RedProtect.get().logger.debug("player","RPPlayerListener - Is InteractBlockEvent.Primary event");
if (!b.getState().getType().equals(BlockTypes.AIR)){
l = b.getLocation().get();
RedProtect.get().logger.debug("player","RPPlayerListener - Is InteractBlockEvent.Primary event. The block is " + b.getState().getType().getName());
} else {
l = p.getLocation();
}
ItemType itemInHand = ItemTypes.NONE;
if (p.getItemInHand(HandTypes.MAIN_HAND).isPresent()){
itemInHand = p.getItemInHand(HandTypes.MAIN_HAND).get().getItem();
} else if (p.getItemInHand(HandTypes.OFF_HAND).isPresent()){
itemInHand = p.getItemInHand(HandTypes.OFF_HAND).get().getItem();
}
String claimmode = RedProtect.get().cfgs.getWorldClaimType(p.getWorld().getName());
if (itemInHand.getId().equalsIgnoreCase(RedProtect.get().cfgs.getString("wands.adminWandID")) && ((claimmode.equalsIgnoreCase("WAND") || claimmode.equalsIgnoreCase("BOTH")) || RedProtect.get().ph.hasPerm(p, "redprotect.admin.claim"))) {
if (!RPUtil.canBuildNear(p, l)){
event.setCancelled(true);
return;
}
RedProtect.get().firstLocationSelections.put(p, l);
p.sendMessage(RPUtil.toText(RPLang.get("playerlistener.wand1") + RPLang.get("general.color") + " (&e" + l.getBlockX() + RPLang.get("general.color") + ", &e" + l.getBlockY() + RPLang.get("general.color") + ", &e" + l.getBlockZ() + RPLang.get("general.color") + ")."));
event.setCancelled(true);
//show preview border
if (RedProtect.get().firstLocationSelections.containsKey(p) && RedProtect.get().secondLocationSelections.containsKey(p)){
RPUtil.addBorder(p, get4Points(RedProtect.get().firstLocationSelections.get(p),RedProtect.get().secondLocationSelections.get(p),p.getLocation().getBlockY()));
}
}
}
示例11: isEmpty
@Override
public boolean isEmpty() {
return this.itemType == ItemTypes.NONE || this.quantity <= 0;
}
示例12: getCurrentItem
@Override
public ItemType getCurrentItem() {
return this.itemTypeSet ? itemStack(null).getType() : ItemTypes.NONE;
}
示例13: onAttemptInteractAS
@Listener(order = Order.FIRST, beforeModifications = true)
public void onAttemptInteractAS(InteractEntityEvent e, @First Player p) {
Entity ent = e.getTargetEntity();
Location<World> l = ent.getLocation();
Region r = RedProtect.get().rm.getTopRegion(l);
if (r == null){
//global flags
if (ent.getType().equals(EntityTypes.ARMOR_STAND)) {
if (!RedProtect.get().cfgs.getGlobalFlag(l.getExtent().getName(),"build")) {
e.setCancelled(true);
return;
}
}
return;
}
ItemType itemInHand = ItemTypes.NONE;
if (p.getItemInHand(HandTypes.MAIN_HAND).isPresent()){
itemInHand = p.getItemInHand(HandTypes.MAIN_HAND).get().getItem();
} else if (p.getItemInHand(HandTypes.OFF_HAND).isPresent()){
itemInHand = p.getItemInHand(HandTypes.OFF_HAND).get().getItem();
}
if (!itemInHand.equals(ItemTypes.NONE) && itemInHand.getType().equals(ItemTypes.ARMOR_STAND)){
if (r != null && !r.canBuild(p)){
e.setCancelled(true);
RPLang.sendMessage(p, "blocklistener.region.cantbuild");
return;
}
}
//TODO Not working!
if (ent.getType().equals(EntityTypes.ARMOR_STAND)) {
if (r != null && !r.canBuild(p)) {
if (!RedProtect.get().ph.hasPerm(p, "redprotect.bypass")) {
RPLang.sendMessage(p, "playerlistener.region.cantedit");
e.setCancelled(true);
}
}
}
}
示例14: onBlockPlace
@Listener(order = Order.FIRST, beforeModifications = true)
public void onBlockPlace(ChangeBlockEvent.Place e, @First Player p) {
RedProtect.get().logger.debug("blocks","BlockListener - Is BlockPlaceEvent event! Cancelled? " + e.isCancelled());
BlockSnapshot b = e.getTransactions().get(0).getOriginal();
Location<World> bloc = b.getLocation().get();
World w = bloc.getExtent();
ItemType m = ItemTypes.NONE;
if (p.getItemInHand(HandTypes.MAIN_HAND).isPresent()){
m = p.getItemInHand(HandTypes.MAIN_HAND).get().getItem();
} else if (p.getItemInHand(HandTypes.OFF_HAND).isPresent()){
m = p.getItemInHand(HandTypes.OFF_HAND).get().getItem();
}
Boolean antih = RedProtect.get().cfgs.getBool("region-settings.anti-hopper");
Region r = RedProtect.get().rm.getTopRegion(b.getLocation().get());
if (r == null && RedProtect.get().cfgs.getGlobalFlagList(w.getName(),"if-build-false","place-blocks").contains(b.getState().getType().getName())){
return;
}
if (r != null){
if (!r.canMinecart(p) && m.getName().contains("minecart")){
RPLang.sendMessage(p, "blocklistener.region.cantplace");
e.setCancelled(true);
return;
}
if (b.getState().getType().equals(BlockTypes.MOB_SPAWNER) && r.allowSpawner(p)){
return;
}
try {
if (!r.canBuild(p) && !r.canPlace(b)) {
RPLang.sendMessage(p, "blocklistener.region.cantbuild");
e.setCancelled(true);
} else {
if (!RedProtect.get().ph.hasPerm(p, "redprotect.bypass") && antih &&
(m.equals(ItemTypes.HOPPER) || m.getName().contains("rail"))){
int x = bloc.getBlockX();
int y = bloc.getBlockY();
int z = bloc.getBlockZ();
BlockSnapshot ib = w.createSnapshot(x, y+1, z);
if (!cont.canBreak(p, ib) || !cont.canBreak(p, b)){
RPLang.sendMessage(p, "blocklistener.container.chestinside");
e.setCancelled(true);
}
}
}
} catch (Throwable t) {
t.printStackTrace();
}
}
}