/**
* Handle interaction with armor stands V1.8
* Note - some armor stand protection is done in IslandGuard.java, e.g. against projectiles.
*
* @param e
*/
@EventHandler(priority = EventPriority.LOW, ignoreCancelled=true)
public void onPlayerInteract(final PlayerInteractAtEntityEvent e) {
if (DEBUG) {
plugin.getLogger().info("1.8 " + e.getEventName());
}
if (!Util.inWorld(e.getPlayer())) {
return;
}
if (e.getRightClicked() != null && e.getRightClicked().getType().equals(EntityType.ARMOR_STAND)) {
if (actionAllowed(e.getPlayer(), e.getRightClicked().getLocation(), SettingsFlag.ARMOR_STAND)) {
return;
}
e.setCancelled(true);
Util.sendMessage(e.getPlayer(), plugin.getLocale(e.getPlayer().getUniqueId()).get("island.protected"));
}
}
java类org.bukkit.event.player.PlayerInteractAtEntityEvent的实例源码
IslandGuard1_8.java 文件源码
项目:bskyblock
阅读 20
收藏 0
点赞 0
评论 0
EntityClick_Listener.java 文件源码
项目:Achtbaan
阅读 22
收藏 0
点赞 0
评论 0
@EventHandler
public void EntityClick(PlayerInteractAtEntityEvent e)
{
Player p = e.getPlayer();
if(e.getRightClicked() instanceof ArmorStand){
ArmorStand clickedA = (ArmorStand) e.getRightClicked();
if(clickedA.getPassenger() == null){
for(Rollercoaster att : Main.r.Attracties.values()){
if(att.getSeats().contains(clickedA)){
if(att.allowSit != false){
e.setCancelled(true);
p.teleport(clickedA);
clickedA.setPassenger(p);
att.addPassagier(p, clickedA);
}
return;
}
}
}
}
}
EntityClick_Listener.java 文件源码
项目:Achtbaan
阅读 21
收藏 0
点赞 0
评论 0
@EventHandler
public void EntityClick(PlayerInteractAtEntityEvent e)
{
Player p = e.getPlayer();
if(e.getRightClicked() instanceof ArmorStand){
ArmorStand clickedA = (ArmorStand) e.getRightClicked();
if(clickedA.getPassenger() == null){
for(attractie att : Main.r.Attracties.values()){
if(att.getSeats().contains(clickedA)){
if(att.allowSit == true){
e.setCancelled(true);
p.teleport(clickedA);
clickedA.setPassenger(p);
att.addPassagier(p, clickedA);
}
return;
}
}
}
}
}
PlayerInteract.java 文件源码
项目:MCDeathSwap
阅读 18
收藏 0
点赞 0
评论 0
@EventHandler
public void onPlayerInteractAtEntity(PlayerInteractAtEntityEvent event) {
Player player = event.getPlayer();
Entity entity = event.getRightClicked();
if (entity.getCustomName() != null && entity.getCustomName().toLowerCase().contains("join deathswap")) {
if (GameState.isGameState(GameState.LOBBY)) {
if (DeathSwap.getInstance().isInQueue(player)) {
player.sendMessage(ChatUtil.formatWithPrefix("You're already in the DeathSwap queue!"));
return;
}
player.sendMessage(ChatUtil.formatWithPrefix("You're in the DeathSwap queue."));
DeathSwap.getInstance().joinQueue(player);
player.closeInventory();
event.setCancelled(true);
}
}
}
IslandGuard1_8.java 文件源码
项目:acidisland
阅读 20
收藏 0
点赞 0
评论 0
/**
* Handle interaction with armor stands V1.8
* Note - some armor stand protection is done in IslandGuard.java, e.g. against projectiles.
*
* @param e
*/
@EventHandler(priority = EventPriority.LOW, ignoreCancelled=true)
public void onPlayerInteract(final PlayerInteractAtEntityEvent e) {
if (DEBUG) {
plugin.getLogger().info("1.8 " + e.getEventName());
}
if (!IslandGuard.inWorld(e.getPlayer())) {
return;
}
if (e.getRightClicked() != null && e.getRightClicked().getType().equals(EntityType.ARMOR_STAND)) {
if (actionAllowed(e.getPlayer(), e.getRightClicked().getLocation(), SettingsFlag.ARMOR_STAND)) {
return;
}
e.setCancelled(true);
Util.sendMessage(e.getPlayer(), ChatColor.RED + plugin.myLocale(e.getPlayer().getUniqueId()).islandProtected);
}
}
IslandGuard1_8.java 文件源码
项目:askyblock
阅读 21
收藏 0
点赞 0
评论 0
/**
* Handle interaction with armor stands V1.8
* Note - some armor stand protection is done in IslandGuard.java, e.g. against projectiles.
*
* @param e
*/
@EventHandler(priority = EventPriority.LOW, ignoreCancelled=true)
public void onPlayerInteract(final PlayerInteractAtEntityEvent e) {
if (DEBUG) {
plugin.getLogger().info("1.8 " + e.getEventName());
}
if (!IslandGuard.inWorld(e.getPlayer())) {
return;
}
if (e.getRightClicked() != null && e.getRightClicked().getType().equals(EntityType.ARMOR_STAND)) {
if (actionAllowed(e.getPlayer(), e.getRightClicked().getLocation(), SettingsFlag.ARMOR_STAND)) {
return;
}
e.setCancelled(true);
Util.sendMessage(e.getPlayer(), ChatColor.RED + plugin.myLocale(e.getPlayer().getUniqueId()).islandProtected);
}
}
ContextModule.java 文件源码
项目:CraftoPlugin
阅读 22
收藏 0
点赞 0
评论 0
@EventHandler
public void onPlayerInteractAtEntity(final PlayerInteractAtEntityEvent event) { // TEST
try {
if (event.getPlayer() == null || event.getRightClicked() == null) { return; }
if (!this.entityHandlers.isEmpty() && !event.isCancelled()) {
final Menu menu = new Menu("Kontextmen�: " + event.getRightClicked().getType());
for (final BiConsumer<PlayerInteractEntityEvent, Menu> consumer : this.entityHandlers) {
try { consumer.accept(event, menu); }
catch (final Exception e) { CraftoMessenger.report(this.getClass(), "A playerinteractATentityevent consumer ("+consumer+") got an exception!", e); }
}
if (!menu.isEmpty()) {
menu.show(event.getPlayer());
event.setCancelled(true);
event.getPlayer().playSound(event.getPlayer().getLocation(), Sound.BLOCK_WOODEN_DOOR_OPEN, 1.0f, 2.0f);
}
}
}
catch (Exception outsideException) { CraftoMessenger.report(getClass(), "Failed to handle PlayerInteractEntityEvent!", outsideException); }
}
IslandGuard1_9.java 文件源码
项目:bskyblock
阅读 29
收藏 0
点赞 0
评论 0
/**
* Handle interaction with end crystals 1.9
*
* @param e
*/
@EventHandler(priority = EventPriority.LOW, ignoreCancelled=true)
public void onHitEndCrystal(final PlayerInteractAtEntityEvent e) {
if (DEBUG) {
plugin.getLogger().info("1.9 " +e.getEventName());
}
if (!Util.inWorld(e.getPlayer())) {
return;
}
if (e.getPlayer().isOp()) {
return;
}
// This permission bypasses protection
if (VaultHelper.hasPerm(e.getPlayer(), Settings.PERMPREFIX + "mod.bypassprotect")) {
return;
}
if (e.getRightClicked() != null && e.getRightClicked().getType().equals(EntityType.ENDER_CRYSTAL)) {
// Check island
Island island = plugin.getIslands().getIslandAt(e.getRightClicked().getLocation());
if (island == null && Settings.defaultWorldSettings.get(SettingsFlag.BREAK_BLOCKS)) {
return;
}
if (island !=null) {
if (island.getMembers().contains(e.getPlayer().getUniqueId()) || island.getFlag(SettingsFlag.BREAK_BLOCKS)) {
return;
}
}
e.setCancelled(true);
Util.sendMessage(e.getPlayer(), plugin.getLocale(e.getPlayer().getUniqueId()).get("island.protected"));
}
}
LobbyModule.java 文件源码
项目:OpenUHC
阅读 24
收藏 0
点赞 0
评论 0
/**
* Prevents lobby players from interacting in the world.
*
* @param event The event
*/
@EventHandler
public void onPlayerInteractEntity(final PlayerInteractAtEntityEvent event) {
if (event.getPlayer().getLocation().getWorld().equals(world)) {
event.setCancelled(true);
}
}
BallListener.java 文件源码
项目:BlockBall
阅读 22
收藏 0
点赞 0
评论 0
@EventHandler
public void entityRightClickEvent(final PlayerInteractAtEntityEvent event) {
if (this.isBall(event.getRightClicked())) {
if (Config.getInstance().isUseEngineV2()) {
final Ball ball = this.getBall(event.getRightClicked());
ball.pass(event.getPlayer());
}
event.setCancelled(true);
} else if (this.isDeadBall(event.getRightClicked())) {
event.setCancelled(true);
}
}
EntityClick_Listener.java 文件源码
项目:Achtbaan
阅读 29
收藏 0
点赞 0
评论 0
@EventHandler
public void EntityClick(PlayerInteractAtEntityEvent e)
{
Player p = e.getPlayer();
if(e.getRightClicked() instanceof ArmorStand){
ArmorStand clickedA = (ArmorStand) e.getRightClicked();
if(clickedA.getPassenger() == null){
for(attractie att : Main.r.Attracties.values()){
for(ArmorStand a : att.getSeats())
{
if(a.getLocation().getX() == clickedA.getLocation().getX() &&
a.getLocation().getY() == clickedA.getLocation().getY() &&
a.getLocation().getZ() == clickedA.getLocation().getZ())
{
if(att.allowSit == true){
e.setCancelled(true);
p.teleport(clickedA);
clickedA.setPassenger(p);
att.addPassagier(p, clickedA);
}
return;
}
}
}
}
}
}
InteractModule.java 文件源码
项目:Cardinal
阅读 24
收藏 0
点赞 0
评论 0
/**
* Prevents a player that can't interact from interacting with an entity.
*
* @param event The event.
*/
@EventHandler(ignoreCancelled = true)
public void onPlayerInteractAtEntity(PlayerInteractAtEntityEvent event) {
if (!canInteract(event.getActor())) {
event.setCancelled(true);
}
}
NPC.java 文件源码
项目:QuestManager
阅读 20
收藏 0
点赞 0
评论 0
@EventHandler(priority = EventPriority.HIGH)
public void onPlayerInteract(PlayerInteractAtEntityEvent e) {
if (!e.isCancelled())
if (e.getHand().equals(EquipmentSlot.HAND))
if (e.getRightClicked().getUniqueId().equals(id)) {
e.setCancelled(true);
this.interact(e.getPlayer());
}
}
TalkRequirement.java 文件源码
项目:QuestManager
阅读 18
收藏 0
点赞 0
评论 0
/**
* Catches a player's interaction and sees if it's the one we've been waiting for
*/
@EventHandler
public void onInteract(PlayerInteractAtEntityEvent e) {
if (state) {
HandlerList.unregisterAll(this);
return;
}
if (QuestManagerPlugin.questManagerPlugin.getPluginConfiguration().getWorlds()
.contains(e.getPlayer().getPlayer().getWorld().getName())) {
for (QuestPlayer qp : participants.getParticipants()) {
if (qp.getPlayer().isOnline() && qp.getPlayer().getPlayer().getUniqueId()
.equals(e.getPlayer().getUniqueId())) {
//one of our participants
//actually check interaction now
if (e.getRightClicked().equals(npc.getEntity())) {
//cancel and interact
e.setCancelled(true);
this.state = true;
HandlerList.unregisterAll(this);
updateQuest();
menu.show(e.getPlayer(), getGoal().getQuest());
}
}
}
}
}
RPMine18.java 文件源码
项目:RedProtect
阅读 21
收藏 0
点赞 0
评论 0
@EventHandler
public void onAttemptInteractAS(PlayerInteractAtEntityEvent e) {
if (e.isCancelled()) {
return;
}
Entity ent = e.getRightClicked();
Location l = ent.getLocation();
Region r = RedProtect.get().rm.getTopRegion(l);
Player p = e.getPlayer();
if (r == null){
//global flags
if (ent instanceof ArmorStand) {
if (!RPConfig.getGlobalFlagBool(l.getWorld().getName()+".build")) {
e.setCancelled(true);
return;
}
}
return;
}
if (ent instanceof ArmorStand) {
if (r != null && !r.canBuild(p)) {
RPLang.sendMessage(p, "playerlistener.region.cantedit");
e.setCancelled(true);
}
}
}
ArmorStandGui.java 文件源码
项目:EditArmorStands
阅读 23
收藏 0
点赞 0
评论 0
@EventHandler
public void onArmorStandInteract(PlayerInteractAtEntityEvent event) {
if (event.getRightClicked().getUniqueId().equals(armorStand.getUniqueId())) {
event.setCancelled(true);
event.getPlayer().sendMessage(ChatColor.RED + "Can't manipulate this Armor Stand! " + ChatColor.GOLD + player.getName() + ChatColor.RED + " is currently editing it!");
}
}
PlayerEvents_1_8.java 文件源码
项目:PlotSquared-Chinese
阅读 22
收藏 0
点赞 0
评论 0
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onInteract(final PlayerInteractAtEntityEvent e) {
Entity entity = e.getRightClicked();
if (!(entity instanceof ArmorStand)) {
return;
}
final Location l = BukkitUtil.getLocation(e.getRightClicked().getLocation());
String world = l.getWorld();
if (!PlotSquared.isPlotWorld(world)) {
return;
}
Plot plot = MainUtil.getPlot(l);
PlotPlayer pp = BukkitUtil.getPlayer(e.getPlayer());
if (plot == null) {
if (!MainUtil.isPlotArea(l)) {
return;
}
if (!Permissions.hasPermission(pp, "plots.admin.interact.road")) {
MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.interact.road");
e.setCancelled(true);
}
}
else {
if (!plot.hasOwner()) {
if (!Permissions.hasPermission(pp, "plots.admin.interact.unowned")) {
MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.interact.unowned");
e.setCancelled(true);
}
}
else {
final UUID uuid = pp.getUUID();
if (!plot.isAdded(uuid)) {
if (!Permissions.hasPermission(pp, "plots.admin.interact.other")) {
MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.interact.other");
e.setCancelled(true);
}
}
}
}
}
WorldGuardListener.java 文件源码
项目:ShopChest
阅读 21
收藏 0
点赞 0
评论 0
@EventHandler(priority = EventPriority.LOW)
public void onUseEntity(UseEntityEvent event) {
if (plugin.getShopChestConfig().enable_worldguard_integration) {
Player player = event.getCause().getFirstPlayer();
if (player == null) return;
if (event.getOriginalEvent() instanceof PlayerInteractAtEntityEvent) {
PlayerInteractAtEntityEvent orig = (PlayerInteractAtEntityEvent) event.getOriginalEvent();
Entity e = orig.getRightClicked();
if (e.getType() == EntityType.ARMOR_STAND) {
if (!Hologram.isPartOfHologram((ArmorStand) e))
return;
for (Shop shop : plugin.getShopUtils().getShops()) {
if (shop.getHologram() != null && shop.getHologram().contains((ArmorStand) e)) {
if (isAllowed(player, shop.getLocation(), Action.RIGHT_CLICK_BLOCK)) {
event.setAllowed(true);
orig.setCancelled(false);
}
return;
}
}
}
}
}
}
ShopInteractListener.java 文件源码
项目:ShopChest
阅读 25
收藏 0
点赞 0
评论 0
@EventHandler
public void onPlayerInteractAtEntity(PlayerInteractAtEntityEvent e) {
if (!plugin.getShopChestConfig().enable_hologram_interaction) return;
Entity entity = e.getRightClicked();
Player p = e.getPlayer();
if (config.enable_authme_integration && plugin.hasAuthMe() && !AuthMe.getApi().isAuthenticated(p)) return;
if (Utils.getMajorVersion() == 8 || e.getHand() == EquipmentSlot.HAND) {
if (entity instanceof ArmorStand) {
ArmorStand armorStand = (ArmorStand) entity;
if (Hologram.isPartOfHologram(armorStand)) {
Hologram hologram = Hologram.getHologram(armorStand);
if (hologram != null) {
Block b = null;
for (Shop shop : plugin.getShopUtils().getShops()) {
if (shop.getHologram() != null && shop.getHologram().equals(hologram)) {
b = shop.getLocation().getBlock();
}
}
if (b != null) {
PlayerInteractEvent interactEvent = new PlayerInteractEvent(p, Action.RIGHT_CLICK_BLOCK, Utils.getPreferredItemInHand(p), b, null);
handleInteractEvent(interactEvent);
}
}
}
}
}
}
IslandGuard1_9.java 文件源码
项目:acidisland
阅读 24
收藏 0
点赞 0
评论 0
/**
* Handle interaction with end crystals 1.9
*
* @param e
*/
@EventHandler(priority = EventPriority.LOW, ignoreCancelled=true)
public void onHitEndCrystal(final PlayerInteractAtEntityEvent e) {
if (DEBUG) {
plugin.getLogger().info("1.9 " +e.getEventName());
}
if (!IslandGuard.inWorld(e.getPlayer())) {
return;
}
if (e.getPlayer().isOp()) {
return;
}
// This permission bypasses protection
if (VaultHelper.checkPerm(e.getPlayer(), Settings.PERMPREFIX + "mod.bypassprotect")) {
return;
}
if (e.getRightClicked() != null && e.getRightClicked().getType().equals(EntityType.ENDER_CRYSTAL)) {
// Check island
Island island = plugin.getGrid().getIslandAt(e.getRightClicked().getLocation());
if (island == null && Settings.defaultWorldSettings.get(SettingsFlag.BREAK_BLOCKS)) {
return;
}
if (island !=null) {
if (island.getMembers().contains(e.getPlayer().getUniqueId()) || island.getIgsFlag(SettingsFlag.BREAK_BLOCKS)) {
return;
}
}
e.setCancelled(true);
Util.sendMessage(e.getPlayer(), ChatColor.RED + plugin.myLocale(e.getPlayer().getUniqueId()).islandProtected);
}
}
PlayerListener18.java 文件源码
项目:Factoid
阅读 17
收藏 0
点赞 0
评论 0
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onPlayerInteractAtEntity(PlayerInteractAtEntityEvent event) {
IDummyLand land;
EntityType et = event.getRightClicked().getType();
Player player = event.getPlayer();
Material mat = player.getItemInHand().getType();
PlayerConfEntry entry;
Location loc = event.getRightClicked().getLocation();
Factoid.getThisPlugin().iLog().write(
"PlayerInteractAtEntity player name: " + event.getPlayer().getName()
+ ", Entity: " + et.name());
// Citizen bug, check if entry exist before
if ((entry = playerConf.get(player)) != null
&& !entry.isAdminMod()) {
land = Factoid.getThisPlugin().iLands().getLandOrOutsideArea(loc);
// Remove and add an item from an armor stand
if(BKVersion.isArmorStand(et)) {
if (((!checkPermission(land, event.getPlayer(), PermissionList.BUILD.getPermissionType())
|| !checkPermission(land, event.getPlayer(), PermissionList.BUILD_DESTROY.getPermissionType()))
&& mat == Material.AIR)
|| ((!checkPermission(land, event.getPlayer(), PermissionList.BUILD.getPermissionType())
|| !checkPermission(land, event.getPlayer(), PermissionList.BUILD_PLACE.getPermissionType()))
&& mat != Material.AIR)) {
messagePermission(player);
event.setCancelled(true);
}
}
}
}
IslandGuard1_9.java 文件源码
项目:askyblock
阅读 20
收藏 0
点赞 0
评论 0
/**
* Handle interaction with end crystals 1.9
*
* @param e
*/
@EventHandler(priority = EventPriority.LOW, ignoreCancelled=true)
public void onHitEndCrystal(final PlayerInteractAtEntityEvent e) {
if (DEBUG) {
plugin.getLogger().info("1.9 " +e.getEventName());
}
if (!IslandGuard.inWorld(e.getPlayer())) {
return;
}
if (e.getPlayer().isOp()) {
return;
}
// This permission bypasses protection
if (VaultHelper.checkPerm(e.getPlayer(), Settings.PERMPREFIX + "mod.bypassprotect")) {
return;
}
if (e.getRightClicked() != null && e.getRightClicked().getType().equals(EntityType.ENDER_CRYSTAL)) {
// Check island
Island island = plugin.getGrid().getIslandAt(e.getRightClicked().getLocation());
if (island == null && Settings.defaultWorldSettings.get(SettingsFlag.BREAK_BLOCKS)) {
return;
}
if (island !=null) {
if (island.getMembers().contains(e.getPlayer().getUniqueId()) || island.getIgsFlag(SettingsFlag.BREAK_BLOCKS)) {
return;
}
}
e.setCancelled(true);
Util.sendMessage(e.getPlayer(), ChatColor.RED + plugin.myLocale(e.getPlayer().getUniqueId()).islandProtected);
}
}
PlayerEvents_1_8.java 文件源码
项目:PlotSquared
阅读 19
收藏 0
点赞 0
评论 0
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onInteract(PlayerInteractAtEntityEvent e) {
Entity entity = e.getRightClicked();
if (!(entity instanceof ArmorStand)) {
return;
}
Location l = BukkitUtil.getLocation(e.getRightClicked().getLocation());
PlotArea area = l.getPlotArea();
if (area == null) {
return;
}
Plot plot = area.getPlotAbs(l);
PlotPlayer pp = BukkitUtil.getPlayer(e.getPlayer());
if (plot == null) {
if (!Permissions.hasPermission(pp, "plots.admin.interact.road")) {
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, "plots.admin.interact.road");
e.setCancelled(true);
}
} else if (!plot.hasOwner()) {
if (!Permissions.hasPermission(pp, "plots.admin.interact.unowned")) {
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, "plots.admin.interact.unowned");
e.setCancelled(true);
}
} else {
UUID uuid = pp.getUUID();
if (!plot.isAdded(uuid)) {
if (Flags.MISC_INTERACT.isTrue(plot)) {
return;
}
if (!Permissions.hasPermission(pp, "plots.admin.interact.other")) {
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, "plots.admin.interact.other");
e.setCancelled(true);
}
}
}
}
BookOfSoulsEmptyCI.java 文件源码
项目:NBTEditor
阅读 73
收藏 0
点赞 0
评论 0
@Override
public void onInteractAtEntity(final PlayerInteractAtEntityEvent event, PlayerDetails details) {
if (EntityNBT.isValidType(event.getRightClicked().getType())) {
details.consumeItem();
Bukkit.getScheduler().runTask(getPlugin(), new Runnable() {
@Override
public void run() {
event.getPlayer().getInventory().addItem((new BookOfSouls(EntityNBT.fromEntity(event.getRightClicked()))).getBook());
}
});
event.setCancelled(true);
}
}
CustomItemListener.java 文件源码
项目:NBTEditor
阅读 24
收藏 0
点赞 0
评论 0
@EventHandler
private void playerInteractAtEntity(PlayerInteractAtEntityEvent event) {
Player player = event.getPlayer();
ItemStack item = player.getInventory().getItemInMainHand();
CustomItem customItem = CustomItemManager.getCustomItem(item);
if (customItem != null) {
if (verifyCustomItem(customItem, event.getPlayer(), false)) {
event.setCancelled(true);
customItem.onInteractAtEntity(event, new PlayerDetails(item, event.getPlayer()));
}
}
}
SpectatorsInteractionsListener.java 文件源码
项目:SpectatorPlus
阅读 24
收藏 0
点赞 0
评论 0
/**
* Used to prevent the following whilst spectating:
* <ul>
* <li>Modifying <tt>ArmorStand</tt>s</li>
* <li>other cases where interaction occurs AT an entity</li>
* </ul>
*/
@EventHandler (priority = EventPriority.HIGHEST)
public void onPlayerInteractAtEntity(final PlayerInteractAtEntityEvent ev)
{
if (p.getPlayerData(ev.getPlayer()).isSpectating() && !Toggles.SKRIPT_INTEGRATION.get())
{
ev.setCancelled(true);
}
}
EventFilterMatchModule.java 文件源码
项目:ProjectAres
阅读 25
收藏 0
点赞 0
评论 0
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onArmorStandInteract(final PlayerInteractAtEntityEvent event) {
cancelUnlessInteracting(event, event.getPlayer());
}
EnvironmentControlListener.java 文件源码
项目:ProjectAres
阅读 22
收藏 0
点赞 0
评论 0
@EventHandler(priority = EventPriority.HIGH)
public void interactAtEntity(PlayerInteractAtEntityEvent event) {
event.setCancelled(true);
}
Callbacks.java 文件源码
项目:Kineticraft
阅读 19
收藏 0
点赞 0
评论 0
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
public void onInteract(PlayerInteractAtEntityEvent evt) {
evt.setCancelled(accept(evt.getPlayer(), ListenerType.ENTITY, evt.getRightClicked())); // Handles entity click callbacks.
}
EntityListener.java 文件源码
项目:BedwarsRel
阅读 21
收藏 0
点赞 0
评论 0
@EventHandler(priority = EventPriority.HIGH)
public void onInteractEntity(PlayerInteractAtEntityEvent event) {
if (event.getRightClicked() == null) {
return;
}
Entity entity = event.getRightClicked();
Player player = event.getPlayer();
if (!player.hasMetadata("bw-addteamjoin")) {
if (!(entity instanceof LivingEntity)) {
return;
}
LivingEntity livEntity = (LivingEntity) entity;
Game game = BedwarsRel.getInstance().getGameManager().getGameOfPlayer(player);
if (game == null) {
return;
}
if (game.getState() != GameState.WAITING) {
return;
}
Team team = game.getTeam(ChatColor.stripColor(livEntity.getCustomName()));
if (team == null) {
return;
}
game.playerJoinTeam(player, team);
event.setCancelled(true);
return;
}
List<MetadataValue> values = player.getMetadata("bw-addteamjoin");
if (values == null || values.size() == 0) {
return;
}
event.setCancelled(true);
TeamJoinMetaDataValue value = (TeamJoinMetaDataValue) values.get(0);
if (!((boolean) value.value())) {
return;
}
if (!(entity instanceof LivingEntity)) {
player.sendMessage(
ChatWriter.pluginMessage(ChatColor.RED + BedwarsRel
._l(player, "errors.entitynotcompatible")));
return;
}
LivingEntity living = (LivingEntity) entity;
living.setRemoveWhenFarAway(false);
living.setCanPickupItems(false);
living.setCustomName(value.getTeam().getChatColor() + value.getTeam().getDisplayName());
living.setCustomNameVisible(
BedwarsRel.getInstance().getBooleanConfig("jointeam-entity.show-name", true));
if (living.getType().equals(EntityType.valueOf("ARMOR_STAND"))) {
Utils.equipArmorStand(living, value.getTeam());
}
player.removeMetadata("bw-addteamjoin", BedwarsRel.getInstance());
player.sendMessage(ChatWriter
.pluginMessage(
ChatColor.GREEN + BedwarsRel._l(player, "success.teamjoinadded", ImmutableMap.of("team",
value.getTeam().getChatColor() + value.getTeam().getDisplayName()
+ ChatColor.GREEN))));
}