本文整理汇总了Java中org.spongepowered.api.event.entity.InteractEntityEvent类的典型用法代码示例。如果您正苦于以下问题:Java InteractEntityEvent类的具体用法?Java InteractEntityEvent怎么用?Java InteractEntityEvent使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
InteractEntityEvent类属于org.spongepowered.api.event.entity包,在下文中一共展示了InteractEntityEvent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onInteractEntity
import org.spongepowered.api.event.entity.InteractEntityEvent; //导入依赖的package包/类
@Listener
public void onInteractEntity(final InteractEntityEvent event) {
if (event.getTargetEntity() instanceof Hanging || event.getTargetEntity() instanceof Minecart || event.getTargetEntity() instanceof Boat) {
Optional<Player> player = event.getCause().first(Player.class);
if (player.isPresent()) {
// Staff
if (player.get().hasPermission("safeguard.mod")) {
return;
}
if (!SafeGuard.getZoneManager().allows(player.get(), blockLikeEntityFlag, event.getTargetEntity().getLocation())) {
player.get().sendMessage(Format.error("Sorry, this zone doesn't allow you to do that."));
event.setCancelled(true);
}
} else {
if (!SafeGuard.getZoneManager().allows(blockLikeEntityFlag, event.getTargetEntity().getLocation())) {
event.setCancelled(true);
}
}
}
}
示例2: onInteractEntity
import org.spongepowered.api.event.entity.InteractEntityEvent; //导入依赖的package包/类
@Listener(order=Order.FIRST)
@IsCancelled(Tristate.UNDEFINED)
public void onInteractEntity(InteractEntityEvent.Primary event) {
Optional<Player> optPlayer = event.getCause().get(NamedCause.SOURCE, Player.class);
if (!optPlayer.isPresent()) return;
Player player = optPlayer.get();
if (!this.players.contains(player.getUniqueId())) return;
event.setCancelled(true);
player.sendMessage(Text.of(TextColors.GRAY, TextStyles.BOLD, "============================================"));
player.sendMessage(Text.of(TextColors.DARK_GREEN, TextStyles.BOLD, "Entity Type: ", TextColors.BLUE, TextStyles.RESET, event.getTargetEntity().getType().getId()));
player.sendMessage(Text.of(TextColors.DARK_GREEN, TextStyles.BOLD, "Entity Owner: ", TextColors.BLUE, TextStyles.RESET, event.getTargetEntity().getCreator()));
player.sendMessage(Text.of(TextColors.DARK_GREEN, TextStyles.BOLD, "Entity Notifier: ", TextColors.BLUE, TextStyles.RESET, event.getTargetEntity().getNotifier()));
}
示例3: 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);
}
}
示例4: 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!"));
}
}
}
示例5: onInteractEntityPrimaryMain
import org.spongepowered.api.event.entity.InteractEntityEvent; //导入依赖的package包/类
@Listener
public void onInteractEntityPrimaryMain(InteractEntityEvent.Primary 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 primary use " + itemType.getName() + " on " + entityType.getName() + "s!"));
}
}
}
示例6: 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");
}
}
示例7: onPlayerInteract
import org.spongepowered.api.event.entity.InteractEntityEvent; //导入依赖的package包/类
@Listener(order = Order.FIRST, beforeModifications = true)
public void onPlayerInteract(InteractEntityEvent e, @First Player p) {
Entity ent = e.getTargetEntity();
Location<World> l = ent.getLocation();
Region r = RedProtect.get().rm.getTopRegion(l);
if (!canInteract(p, r)){
e.setCancelled(true);
}
if (r != null){
return;
}
if (ent.getType().getName().contains("minecart") || ent.getType().getName().contains("boat")){
if (!RedProtect.get().cfgs.getGlobalFlag(ent.getWorld().getName(),"use-minecart") && !p.hasPermission("RedProtect.get().bypass.world")) {
e.setCancelled(true);
}
} else {
if (!RedProtect.get().cfgs.getGlobalFlag(ent.getWorld().getName(),"interact") && !p.hasPermission("RedProtect.get().bypass.world") && (!(ent instanceof Player))) {
e.setCancelled(true);
}
}
}
示例8: onEntityDamageByEntityEvent
import org.spongepowered.api.event.entity.InteractEntityEvent; //导入依赖的package包/类
@Listener(order = Order.FIRST, beforeModifications = true)
public void onEntityDamageByEntityEvent(InteractEntityEvent.Primary e, @First Player p) {
Entity e1 = e.getTargetEntity();
RedProtect.get().logger.debug("player","RPLayerListener: Is EntityDamageByEntityEvent event. Victim: "+e.getTargetEntity().getType().getName());
Location<World> l = e1.getLocation();
Region r = RedProtect.get().rm.getTopRegion(l);
if (r == null || p == null){
return;
}
if (e1 instanceof Player && r.flagExists("pvp") && !r.canPVP(p)){
RPLang.sendMessage(p, "entitylistener.region.cantpvp");
e.setCancelled(true);
}
}
示例9: 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);
}
}
}
示例10: onEntityInteract
import org.spongepowered.api.event.entity.InteractEntityEvent; //导入依赖的package包/类
@Listener
public void onEntityInteract(InteractEntityEvent.Primary event, @First Player player, @Getter("getTargetEntity") Player targetPlayer) {
Optional<org.spongepowered.api.item.inventory.ItemStack> optItemStack = player.getItemInHand(HandTypes.MAIN_HAND);
if (!optItemStack.isPresent()) {
return;
}
org.spongepowered.api.item.inventory.ItemStack itemStack = optItemStack.get();
if (this.equals(itemStack.getItem()) && isAttuned(itemStack)) {
if (playerAlreadyHasInvite(itemStack, targetPlayer)) {
player.sendMessage(
Text.of(TextColors.RED, targetPlayer.getName() + " already has an invite.")
);
} else {
org.spongepowered.api.item.inventory.ItemStack newStack = createForMaster(itemStack, player);
tf(targetPlayer).inventory.addItemStackToInventory(tf(newStack));
targetPlayer.sendMessage(
Text.of(TextColors.GOLD, player.getName() + " has invited you to " + getZone(itemStack).get() + ".")
);
player.sendMessage(
Text.of(TextColors.GOLD, targetPlayer.getName() + " has been given invite.")
);
}
event.setCancelled(true);
}
}
示例11: 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);
}
}
示例12: onPlayerInteractEntity
import org.spongepowered.api.event.entity.InteractEntityEvent; //导入依赖的package包/类
@Listener
public void onPlayerInteractEntity(InteractEntityEvent event, @First Player player)
{
if (!this.module.getConfig().protectEntityFromRClick) return;
Entity entity = event.getTargetEntity();
if (!player.hasPermission(module.perms().ALLOW_ENTITY.getId()))
{
i18n.send(player, NEGATIVE, "Strong magic prevents you from reaching this entity!");
event.setCancelled(true);
return;
}
Lock lock = this.manager.getLockForEntityUID(entity.getUniqueId());
if (lock == null) return;
if (entity instanceof Carrier || (entity.getType() == HORSE && player.get(Keys.IS_SNEAKING).get()))
{
// Handled by InteractInventoryEvent.Open
lock.handleInventoryOpen(event, ((Carrier) entity).getInventory(), null, player);
}
else
{
lock.handleEntityInteract(event, player);
}
}
示例13: onLeftClickEntity
import org.spongepowered.api.event.entity.InteractEntityEvent; //导入依赖的package包/类
@Listener
public void onLeftClickEntity(InteractEntityEvent.Primary evt, @Root Player player) {
PlayerLeftClicksEntityScriptEvent event = (PlayerLeftClicksEntityScriptEvent) clone();
event.internal = evt;
event.player = new PlayerTag(player);
event.entity = new EntityTag(evt.getTargetEntity());
event.cancelled = evt.isCancelled();
event.run();
evt.setCancelled(event.cancelled);
}
示例14: 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);
}
示例15: onInteract
import org.spongepowered.api.event.entity.InteractEntityEvent; //导入依赖的package包/类
@Listener(order=Order.FIRST, beforeModifications = true)
public void onInteract(InteractEntityEvent event, @First Player player)
{
if (!ConfigHandler.getNode("worlds").getNode(player.getWorld().getName()).getNode("enabled").getBoolean())
{
return;
}
if (player.hasPermission("nations.admin.bypass.perm.interact"))
{
return;
}
Entity target = event.getTargetEntity();
if (target instanceof Player || target instanceof Monster)
{
return;
}
if (target instanceof ItemFrame || target instanceof ArmorStand)
{
if (player.hasPermission("nations.admin.bypass.perm.build"))
{
return;
}
if (!DataHandler.getPerm("build", player.getUniqueId(), event.getTargetEntity().getLocation()))
{
event.setCancelled(true);
player.sendMessage(Text.of(TextColors.RED, LanguageHandler.ERROR_PERM_BUILD));
}
return;
}
if (!DataHandler.getPerm("interact", player.getUniqueId(), event.getTargetEntity().getLocation()))
{
event.setCancelled(true);
player.sendMessage(Text.of(TextColors.RED, LanguageHandler.ERROR_PERM_INTERACT));
}
}