當前位置: 首頁>>代碼示例>>Java>>正文


Java Event類代碼示例

本文整理匯總了Java中org.bukkit.event.Event的典型用法代碼示例。如果您正苦於以下問題:Java Event類的具體用法?Java Event怎麽用?Java Event使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Event類屬於org.bukkit.event包,在下文中一共展示了Event類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: call

import org.bukkit.event.Event; //導入依賴的package包/類
@Override
public void call(Event event) {
	final Player player = profile.getPlayer();

	if (event instanceof PlayerMoveEvent) {
		if ((player.isSprinting() || player.isBlocking() || player.isConversing()) && player.isSneaking()) {
			callback(true);
			return;
		}
		callback(false);
	} else if (event instanceof AsyncPlayerChatEvent) {
		if ((player.isBlocking() || player.isSprinting() || player.isSneaking())) {
			callback(true);
			return;
		}
		callback(false);
	}
}
 
開發者ID:davidm98,項目名稱:Crescent,代碼行數:19,代碼來源:ImpossibleA.java

示例2: call

import org.bukkit.event.Event; //導入依賴的package包/類
@Override
public void call(Event event) {
	if (event instanceof EntityDamageEvent) {
		final EntityDamageEvent ede = (EntityDamageEvent) event;
		final DamageCause cause = ede.getCause();

		if (cause == DamageCause.FIRE || cause == DamageCause.CONTACT) {
			final Player player = profile.getPlayer();

			if (cause == DamageCause.FIRE && player.getFoodLevel() < 20) {
				// The AntiFire cheat only works when the hunger bar is
				// full.
				return;
			}

			final double previousHealth = player.getHealth();

			// Check a little later.
			Bukkit.getScheduler().runTaskLater(Crescent.getInstance(), () -> {
				if (player.getHealth() > previousHealth - ede.getDamage()) {
					callback(true);
				}
			}, 2L);
		}
	}
}
 
開發者ID:davidm98,項目名稱:Crescent,代碼行數:27,代碼來源:AntiDamageA.java

示例3: check

import org.bukkit.event.Event; //導入依賴的package包/類
@Override
public boolean check(Event arg0) {
	@SuppressWarnings("unused")
	Boolean goodip = IpTools.validIP(ip.getSingle(arg0));
	if (!goodip) {
		Skript.error("\"" + ip + "\" is not a valid IPv4 address!");
		return false;
	}
	JSONObject jsonparsed = null;
	try {
		jsonparsed = JsonReader.readJsonFromUrl("http://proxycheck.io/v1/" + ip.getSingle(arg0) + "&vpn=1&asn=0&node=1&time=1&tag=skLib");
	} catch (JSONException | IOException e) {
		e.printStackTrace();
	}
	String jsonvalue = (String) jsonparsed.get("proxy");
	if (jsonvalue.equalsIgnoreCase("yes")) {
		return true;
	}
	return false;
}
 
開發者ID:WheezyGold7931,項目名稱:skLib,代碼行數:21,代碼來源:CondVpnCheck.java

示例4: execute

import org.bukkit.event.Event; //導入依賴的package包/類
@Override
// 計算調用次數和花費總時間以及花費最多的時間
public void execute(Listener listener, Event e) throws EventException {
	if (e.isAsynchronous()) {
		this.eventExecutor.execute(listener, e);
	} else {
		long startTime = System.nanoTime();
		try {
			this.eventExecutor.execute(listener, e);
		} finally {
			long endTime = System.nanoTime();
			long executeTime = endTime - startTime;
			this.record(e.getEventName(), executeTime);
		}
	}
}
 
開發者ID:jiongjionger,項目名稱:NeverLag,代碼行數:17,代碼來源:EventExecutorInjector.java

示例5: healWithPotion

import org.bukkit.event.Event; //導入依賴的package包/類
public static void healWithPotion(int amount, String name, Event event, Player p) {
    if (!(event instanceof PlayerInteractEvent))
        return;
    PlayerInteractEvent e = (PlayerInteractEvent) event;
    if (!(e.getAction() == Action.RIGHT_CLICK_AIR || e.getAction() == Action.RIGHT_CLICK_BLOCK))
        return;
    if (lastHealItem.containsKey(p.getName()) && System.currentTimeMillis() - lastHealItem.get(p.getName()) < 500) {
        return;
    }
    lastHealItem.put(p.getName(), System.currentTimeMillis());
    p.getEquipment().setItemInMainHand(new ItemStack(Material.AIR));
    PlayerDataRPG pd = plugin.getPD(p);
    pd.heal(amount, HealType.POTION);
    for (int k = 0; k < p.getInventory().getContents().length; k++) {
        if (ItemManager.isItem(p.getInventory().getItem(k), name)) {
            p.getEquipment().setItemInMainHand(p.getInventory().getItem(k));
            p.getInventory().setItem(k, new ItemStack(Material.AIR));
            break;
        }
    }
    RSound.playSound(p, Sound.ENTITY_GENERIC_DRINK);
}
 
開發者ID:edasaki,項目名稱:ZentrelaRPG,代碼行數:23,代碼來源:EtcItem.java

示例6: change

import org.bukkit.event.Event; //導入依賴的package包/類
@Override
public void change(Event e, Object[] delta, Changer.ChangeMode mode) {
  Object target = targetArg.getSingle(e);
  if (target == null) {
    return;
  }

  Object[] args = new Object[1];

  switch (mode) {
    case SET:
      args[0] = delta[0];
      break;
    case DELETE:
      args[0] = null;
      break;
  }

  invoke(target, args, getDescriptor(e));
}
 
開發者ID:btk5h,項目名稱:skript-mirror,代碼行數:21,代碼來源:ExprJavaCall.java

示例7: execute

import org.bukkit.event.Event; //導入依賴的package包/類
@Override
protected void execute(Event event) {
    String[] commands = this.commands.getAll(event);
    Object[] senders = this.senders.getAll(event);
    if (commands == null || senders == null) {
        return;
    }
    Arrays.stream(getBungeeMaster().convertObjectsToNamesAndUUIDs(senders))
            .forEach(sender ->
                    Arrays.stream(commands)
                    .filter(Objects::nonNull)
                    .forEach(command -> {
                        if (command.startsWith("/")) {
                            command = command.substring(1);
                        }
                        send(new SendMessageAsPlayerPacket(sender, "/" + command));
                    })
            );
}
 
開發者ID:TonyMaster21,項目名稱:BungeeMaster,代碼行數:20,代碼來源:EffPerformCommandAsPlayer.java

示例8: change

import org.bukkit.event.Event; //導入依賴的package包/類
@Override
public void change(Event e, Object[] delta, Changer.ChangeMode mode) {
  Trigger trigger = changerHandlers.get(which);
  ExpressionChangeEvent expressionEvent =
      new ExpressionChangeEvent(e, exprs, parseResult, delta, mode);

  if (trigger == null) {
    Skript.error(
        String.format("The custom expression '%s' no longer has a change handler.",
            which.getPattern())
    );
  } else {
    trigger.execute(expressionEvent);
  }
}
 
開發者ID:btk5h,項目名稱:skript-mirror,代碼行數:16,代碼來源:CustomExpression.java

示例9: execute

import org.bukkit.event.Event; //導入依賴的package包/類
protected void execute(final Event arg0) {
    final Jedis jedis = Main.pool.getResource();
    new BukkitRunnable(){

        public void run() {
            try {
                jedis.set((String)EffectSetVariable.this.key.getSingle(arg0), (String)EffectSetVariable.this.value.getSingle(arg0));
            }
            catch (Exception e) {
                e.printStackTrace();
            }
            jedis.close();
        }
    }.runTaskAsynchronously(Main.plugin);
}
 
開發者ID:WheezyGold7931,項目名稱:skLib,代碼行數:16,代碼來源:EffectSetVariable.java

示例10: call

import org.bukkit.event.Event; //導入依賴的package包/類
@Override
public void call(Event event) {
	if (event instanceof PlayerMoveEvent) {
		final PlayerMoveEvent pme = (PlayerMoveEvent) event;

		final Behaviour behaviour = profile.getBehaviour();

		if (!behaviour.isOnGround() && !behaviour.isInLiquid() && !behaviour.isInWeb()) {
			if (behaviour.getMotion().isDescending()) {
				final double difference = Math.abs((behaviour.getMotion()
						.calculateGravityEffect() /*
													 * Expected y difference
													 */)
						- (pme.getTo().getY() - pme.getFrom()
								.getY()) /* Actual y difference */);
				if (difference > ALLOWED_MAX_GRAVITY_DIFFERENCE && behaviour
						.getBlocksBelowGround() > 2 /*
													 * The player being too
													 * close to the ground
													 * causes false
													 * positives.
													 */) {
					callback(true);
				}
			}
		}
	}
}
 
開發者ID:davidm98,項目名稱:Crescent,代碼行數:29,代碼來源:AntiGravityA.java

示例11: get

import org.bukkit.event.Event; //導入依賴的package包/類
@Override
@Nullable
protected Number[] get(Event e) {
	InventoryType container = ((InventoryClickEvent)e).getClickedInventory().getType();
	if (container != InventoryType.CHEST || container != InventoryType.DISPENSER || container != InventoryType.DROPPER || container != InventoryType.WORKBENCH || container != InventoryType.ENDER_CHEST || container != InventoryType.PLAYER) {
		for (int i = 1; i < ((InventoryClickEvent)e).getClickedInventory().getSize() + 1; i++) {
			if (rowType(i, ((InventoryClickEvent)e).getSlot(), ((InventoryClickEvent)e).getInventory())) {
				return new Number[]{i};
			}
		}
	}
	return null;
}
 
開發者ID:WheezyGold7931,項目名稱:skLib,代碼行數:14,代碼來源:ExprClickedRow.java

示例12: change

import org.bukkit.event.Event; //導入依賴的package包/類
@Override
public void change(Event e, Object[] delta, Changer.ChangeMode mode) {
  Number num = numbers.getSingle(e);
  Number f = from.getSingle(e);
  Number t = to.getSingle(e);

  if (num == null || f == null || t == null) {
    return;
  }

  long mask = getRangeMaskIndexed(f.intValue(), t.intValue());

  long number = num.longValue();

  switch (mode) {
    case SET:
      if (delta[0] instanceof Number) {
        number &= ~mask;
        mask &= (((Number) delta[0]).longValue()) << f.intValue();
      } else if (delta[0] instanceof Boolean) {
        if (!((Boolean) delta[0])) {
          mask = ~mask;
        }
      } else {
        throw new IllegalStateException();
      }

      number |= mask;
      break;
    case DELETE:
      number &= ~mask;
      break;
    default:
      throw new IllegalStateException();
  }

  numbers.change(e, new Object[]{number}, Changer.ChangeMode.SET);
}
 
開發者ID:btk5h,項目名稱:skript-mirror,代碼行數:39,代碼來源:ExprBits.java

示例13: destroy

import org.bukkit.event.Event; //導入依賴的package包/類
@Override
public void destroy() {
    if (!this.dead) {
        Bukkit.getPluginManager().callEvent((Event)new LoggerRemovedEvent(this));
        this.dead = true;
        this.cancelTask();
    }
}
 
開發者ID:funkemunky,項目名稱:HCFCore,代碼行數:9,代碼來源:LoggerEntityHuman.java

示例14: get

import org.bukkit.event.Event; //導入依賴的package包/類
@Nullable
@Override
protected Pattern[] get(Event e) {
	Color c = color.getSingle(e);
	PatternType p = pattern.getSingle(e);
	if (c == null || p == null) {
		return null;
	}
	return new Pattern[]{new Pattern(c.getWoolColor(), p)};
}
 
開發者ID:Syst3ms,項目名稱:QuarSK,代碼行數:11,代碼來源:ExprCustomBannerLayer.java

示例15: PlayerItemTransferEvent

import org.bukkit.event.Event; //導入依賴的package包/類
public PlayerItemTransferEvent(Event cause,
                               Type type,
                               Player player,
                               Optional<InventorySlot<?>> from,
                               Optional<InventorySlot<?>> to,
                               ItemStack itemStack,
                               @Nullable Item itemEntity,
                               int quantity,
                               @Nullable ItemStack cursorItems) {

    super(cause, type, from, to, itemStack, itemEntity, quantity);
    this.player = checkNotNull(player);
    this.cursorItems = cursorItems;
}
 
開發者ID:OvercastNetwork,項目名稱:ProjectAres,代碼行數:15,代碼來源:PlayerItemTransferEvent.java


注:本文中的org.bukkit.event.Event類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。