本文整理汇总了Java中org.spongepowered.api.event.entity.InteractEntityEvent.Secondary方法的典型用法代码示例。如果您正苦于以下问题:Java InteractEntityEvent.Secondary方法的具体用法?Java InteractEntityEvent.Secondary怎么用?Java InteractEntityEvent.Secondary使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.spongepowered.api.event.entity.InteractEntityEvent
的用法示例。
在下文中一共展示了InteractEntityEvent.Secondary方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onPlayerInteractEntity
import org.spongepowered.api.event.entity.InteractEntityEvent; //导入方法依赖的package包/类
@Listener(order=Order.LAST)
public void onPlayerInteractEntity(InteractEntityEvent event, @First Player player_sponge) {
EPlayer player = this.plugin.getEServer().getEPlayer(player_sponge);
// GameMode : Painting
if (event instanceof InteractEntityEvent.Secondary && event.getTargetEntity() instanceof Painting) {
if (this.plugin.getConfigs().isGameModePaint() && player.isSneaking() && player.isCreative()) {
Painting paint = (Painting) event.getTargetEntity();
if (paint.get(Keys.ART).isPresent()) {
Art art = paint.get(Keys.ART).get();
Art next = UtilsPainting.next(art);
while (!paint.offer(Keys.ART, next).isSuccessful() && !art.equals(next)){
next = UtilsPainting.next(next);
}
}
}
}
// AFK
player.updateLastActivated();
// Freeze
if(player.isFreeze()) {
event.setCancelled(true);
}
}
示例2: onInteractEntitySecondaryMain
import org.spongepowered.api.event.entity.InteractEntityEvent; //导入方法依赖的package包/类
@Listener
public void onInteractEntitySecondaryMain(InteractEntityEvent.Secondary event, @Root Player player) {
Optional<ItemStack> itemStackOptional = player.getItemInHand(event.getHandType());
if(itemStackOptional.isPresent()) {
EntityType entityType = event.getTargetEntity().getType();
String entityId = entityType.getId();
ItemType itemType = itemStackOptional.get().getType();
String itemId = itemType.getId();
PermHandler ph = PermHandler.getInstance();
if (!ph.checkPerm(player, "protectionperms.item.use." + itemId + ".on." + entityId + ".primary")) {
event.setCancelled(true);
player.sendMessage(ChatTypes.ACTION_BAR,
Text.of(TextColors.RED, "You don't have permission to secondary use " + itemType.getName() + " on " + entityType.getName() + "s!"));
}
}
}
示例3: onInteractEvent
import org.spongepowered.api.event.entity.InteractEntityEvent; //导入方法依赖的package包/类
@Listener(order = Order.FIRST, beforeModifications = true)
public void onInteractEvent(InteractEntityEvent.Secondary e, @First Player p){
Entity et = e.getTargetEntity();
Location<World> l = et.getLocation();
Region r = RedProtect.get().rm.getTopRegion(l);
RedProtect.get().logger.debug("entity","RPEntityListener - InteractEntityEvent.Secondary entity "+et.getType().getName());
if (r != null && !r.canInteractPassives(p) && (et instanceof Animal || et instanceof Villager || et instanceof Golem || et instanceof Ambient)) {
if (RedProtect.get().getPVHelper().checkHorseOwner(et, p)){
return;
}
e.setCancelled(true);
RPLang.sendMessage(p, "entitylistener.region.cantinteract");
}
}
示例4: onRightClick
import org.spongepowered.api.event.entity.InteractEntityEvent; //导入方法依赖的package包/类
@Listener
public void onRightClick(InteractEntityEvent.Secondary event, @First(typeFilter = Player.class) Player pl) {
Optional<ItemStack> itemInHand = pl.getItemInHand(HandTypes.MAIN_HAND);
if (itemInHand.isPresent()) {
ItemStack itemStack = itemInHand.get();
if (ItemStackUtils.any_armor.contains(itemStack.getItem())) {
event.setCancelled(true); //restrict armor equip on rightclick
return;
} else {
IActiveCharacter character = characterService.getCharacter(pl.getUniqueId());
if (character.isStub())
return;
inventoryService.onRightClick(character, 0);
}
}
}
示例5: onRightClickEntity
import org.spongepowered.api.event.entity.InteractEntityEvent; //导入方法依赖的package包/类
@Listener
public void onRightClickEntity(InteractEntityEvent.Secondary event, @First Player player)
{
if (isPlayerInteract(player))
{
return;
}
LockAction lockAction = lockActions.get(player.getUniqueId());
if (lockAction != null)
{
Entity target = event.getTargetEntity();
Location<World> location = target.getLocation();
Lock lock = this.manager.getLockForEntityUID(target.getUniqueId());
lockAction.apply(lock, location, target);
cmdUsed(player);
event.setCancelled(true);
}
}
示例6: onRightClickEntity
import org.spongepowered.api.event.entity.InteractEntityEvent; //导入方法依赖的package包/类
@Listener
public void onRightClickEntity(InteractEntityEvent.Secondary evt, @Root Player player) {
PlayerRightClicksEntityScriptEvent event = (PlayerRightClicksEntityScriptEvent) clone();
event.internal = evt;
event.player = new PlayerTag(player);
event.entity = new EntityTag(evt.getTargetEntity());
event.hInternal = evt.getHandType();
event.hand = new TextTag(Utilities.getIdWithoutDefaultPrefix(evt.getHandType().getId()));
event.cancelled = evt.isCancelled();
event.run();
evt.setCancelled(event.cancelled);
}
示例7: onInteractEntitySecondary
import org.spongepowered.api.event.entity.InteractEntityEvent; //导入方法依赖的package包/类
@Listener
public void onInteractEntitySecondary(InteractEntityEvent.Secondary event, @Root Player player) {
EntityType entityType = event.getTargetEntity().getType();
String entityId = entityType.getId();
PermHandler ph = PermHandler.getInstance();
if (!ph.checkPerm(player, "protectionperms.entity.interact." + entityId + ".secondary")) {
event.setCancelled(true);
player.sendMessage(ChatTypes.ACTION_BAR,
Text.of(TextColors.RED, "You don't have permission to secondary interact with " + entityType.getName() + "s!"));
}
}
示例8: onPlayerInteractEntity
import org.spongepowered.api.event.entity.InteractEntityEvent; //导入方法依赖的package包/类
@Listener
public void onPlayerInteractEntity(InteractEntityEvent.Secondary event) {
Optional<Player> cause = event.getCause().first(Player.class);
Entity target = event.getTargetEntity();
if (cause.isPresent())
if (InteractionHandler.clickEntity(cause.get(), target, InteractionHandler.Button.right))
event.setCancelled(true);
}
示例9: onEntityInteract
import org.spongepowered.api.event.entity.InteractEntityEvent; //导入方法依赖的package包/类
@Listener
public void onEntityInteract(InteractEntityEvent event, @First Player player) {
HandType hand = Utils.getEventHand(event);
CustomWorld world = WorldManager.toCustomWorld(event.getTargetEntity().getWorld());
EntityTracker tracker = world.getEntityTracker(event.getTargetEntity());
if (tracker == null) {
return;
}
if (event instanceof InteractEntityEvent.Primary) {
tracker.onEntityHit(event.getTargetEntity(), player, hand);
} else if (event instanceof InteractEntityEvent.Secondary) {
tracker.onEntityActivated(event.getTargetEntity(), player, hand);
}
}
示例10: onRMBClick
import org.spongepowered.api.event.entity.InteractEntityEvent; //导入方法依赖的package包/类
@Listener
@Include({
InteractBlockEvent.Secondary.class,
InteractEntityEvent.Secondary.class,
InteractItemEvent.Secondary.class
})
public void onRMBClick(InteractEvent e, @Root Player player) {
IActiveCharacter character = characterService.getCharacter(player);
e.setCancelled(characterService.processUserAction(character, UserActionType.R));
}