本文整理了Java中org.bukkit.event.EventHandler
类的一些代码示例,展示了EventHandler
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。EventHandler
类的具体详情如下:
包路径:org.bukkit.event.EventHandler
类名称:EventHandler
暂无
代码示例来源:origin: webbukkit/dynmap
@EventHandler(priority=EventPriority.MONITOR, ignoreCancelled=true)
public void onBlockBreak(BlockBreakEvent event) {
Block b = event.getBlock();
if(b == null) return; /* Stupid mod workaround */
Location loc = b.getLocation();
String wn = getWorld(loc.getWorld()).getName();
sscache.invalidateSnapshot(wn, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
mapManager.touch(wn, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), "blockbreak");
}
};
代码示例来源:origin: Bukkit/Bukkit
eventSet.add(new TimedRegisteredListener(listener, executor, eh.priority(), plugin, eh.ignoreCancelled()));
} else {
eventSet.add(new RegisteredListener(listener, executor, eh.priority(), plugin, eh.ignoreCancelled()));
代码示例来源:origin: EngineHub/WorldGuard
@EventHandler(ignoreCancelled = true)
public void onPlayerBucketFill(PlayerBucketFillEvent event) {
Player player = event.getPlayer();
Block blockAffected = event.getBlockClicked().getRelative(event.getBlockFace());
boolean allowed = false;
// Milk buckets can't be emptied as of writing
if (event.getItemStack().getType() == Material.MILK_BUCKET) {
allowed = true;
}
ItemStack item = new ItemStack(event.getBucket(), 1);
Events.fireToCancel(event, new BreakBlockEvent(event, create(player), blockAffected).setAllowed(allowed));
Events.fireToCancel(event, new UseItemEvent(event, create(player), player.getWorld(), item).setAllowed(allowed));
if (event.isCancelled()) {
playDenyEffect(event.getPlayer(), blockAffected.getLocation().add(0.5, 0.5, 0.5));
}
}
代码示例来源:origin: webbukkit/dynmap
@EventHandler(priority=EventPriority.MONITOR, ignoreCancelled=true)
public void onPlayerMove(PlayerMoveEvent event) {
Location loc = event.getPlayer().getLocation();
mapManager.touch(getWorld(loc.getWorld()).getName(), loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), "playermove");
}
};
代码示例来源:origin: EngineHub/WorldGuard
@EventHandler(priority = EventPriority.HIGH)
public void onItemHeldChange(PlayerItemHeldEvent event) {
Player player = event.getPlayer();
ConfigurationManager cfg = WorldGuard.getInstance().getPlatform().getGlobalStateManager();
WorldConfiguration wcfg = cfg.get(BukkitAdapter.adapt(player.getWorld()));
if (wcfg.removeInfiniteStacks
&& !plugin.hasPermission(player, "worldguard.override.infinite-stack")) {
int newSlot = event.getNewSlot();
ItemStack heldItem = player.getInventory().getItem(newSlot);
if (heldItem != null && heldItem.getAmount() < 0) {
player.getInventory().setItem(newSlot, null);
player.sendMessage(ChatColor.RED + "Infinite stack removed.");
}
}
}
代码示例来源:origin: BentoBoxWorld/BentoBox
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onTropicalFishScooping(final PlayerInteractEntityEvent e) {
if (e.getRightClicked() instanceof TropicalFish && e.getPlayer().getInventory().getItemInMainHand().getType().equals(Material.WATER_BUCKET)) {
checkIsland(e, e.getRightClicked().getLocation(), Flags.FISH_SCOOPING);
}
}
}
代码示例来源:origin: dzikoysk/WildSkript
@SuppressWarnings("deprecation")
@EventHandler
public void onPlayerMove(PlayerMoveEvent event) {
Block block, control;
if (event.getTo().getY() > event.getFrom().getY()) {
block = event.getPlayer().getWorld().getBlockAt(new Location(event.getPlayer().getWorld(), event.getTo().getX(), event.getTo().getY() + 2, event.getTo().getZ()));
control = event.getPlayer().getWorld().getBlockAt(new Location(event.getPlayer().getWorld(), event.getTo().getX(), event.getTo().getY() - 2, event.getTo().getZ()));
if (!(block.getTypeId() != 0 || control.getTypeId() == 0)) {
EvtJump custom = new EvtJump(event.getPlayer());
Bukkit.getServer().getPluginManager().callEvent(custom);
if (custom.isCancelled()) {
event.setCancelled(true);
}
}
}
}
代码示例来源:origin: gvlfm78/BukkitOldCombatMechanics
@EventHandler(priority = EventPriority.HIGHEST)
public void onWorldChange(PlayerChangedWorldEvent e){
Player p = e.getPlayer();
World w = p.getWorld();
if(!isEnabled(w)) return;
PlayerInventory inv = p.getInventory();
ItemStack chestplate = inv.getChestplate();
if(chestplate == null || chestplate.getType() != Material.ELYTRA) return;
inv.setChestplate(new ItemStack(Material.AIR));
if(inv.firstEmpty() != -1)
inv.addItem(chestplate);
else
w.dropItem(p.getLocation(), chestplate);
}
}
代码示例来源:origin: eccentricdevotion/TARDIS
@EventHandler
public void onPlayerInteract(PlayerInteractEvent event) {
if (event.getHand() == null || event.getHand().equals(EquipmentSlot.OFF_HAND)) {
return;
}
Player p = event.getPlayer();
ItemStack inhand = p.getInventory().getItemInMainHand();
if (event.getAction().equals(Action.RIGHT_CLICK_AIR) && inhand.getType().equals(Material.CLOCK) && p.hasPermission("tardis.temporal")) {
if (inhand.hasItemMeta() && inhand.getItemMeta().hasDisplayName() && notthese.contains(inhand.getItemMeta().getDisplayName())) {
return;
}
p.resetPlayerTime();
plugin.getTrackerKeeper().getSetTime().remove(p.getUniqueId());
TARDISMessage.send(p, "TEMPORAL_RESET");
}
}
}
代码示例来源:origin: FunnyGuilds/FunnyGuilds
@EventHandler
public void onPlace(BlockPlaceEvent e) {
if (ProtectionSystem.build(e.getPlayer(), e.getBlock().getLocation(), true)) {
if (config.buggedBlocks && !config.buggedBlocksExclude.contains(e.getBlock().getType())) {
ItemStack returnItem = e.getItemInHand().clone();
returnItem.setAmount(1);
Bukkit.getScheduler().runTaskLater(FunnyGuilds.getInstance(), () -> {
e.getBlockReplacedState().update(true);
if (config.buggedBlockReturn) {
e.getPlayer().getInventory().addItem(returnItem);
}
}, config.buggedBlocksTimer);
return;
}
e.setCancelled(true);
}
}
代码示例来源:origin: TotalFreedom/TotalFreedomMod
@EventHandler(priority = EventPriority.HIGH)
public void onPlayerLogin(PlayerLoginEvent event)
{
final Player player = event.getPlayer();
// Validate position
if (Math.abs(player.getLocation().getX()) >= MAX_XZ_COORD || Math.abs(player.getLocation().getZ()) >= MAX_XZ_COORD)
{
player.teleport(player.getWorld().getSpawnLocation()); // Illegal position, teleport to spawn
}
}
代码示例来源:origin: BentoBoxWorld/BentoBox
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onPlayerDeathEvent(PlayerDeathEvent e) {
if (plugin.getIWM().inWorld(e.getEntity().getLocation()) && plugin.getIWM().getWorldSettings(e.getEntity().getLocation().getWorld()).isDeathsCounted()) {
plugin.getPlayers().addDeath(e.getEntity().getWorld(), e.getEntity().getUniqueId());
}
}
}
代码示例来源:origin: Bkm016/TabooLib
@EventHandler
public void onJoin(PlayerJoinEvent e) {
if (UpdateTask.isHaveUpdate() && e.getPlayer().hasPermission("taboolib.update.notify")) {
TLocale.Logger.sendTo(e.getPlayer(), "UPDATETASK.VERSION-OUTDATED", String.valueOf(TabooLib.getPluginVersion()), String.valueOf(UpdateTask.getNewVersion()));
}
if (TranslateUUID.isEnabled()) {
Bukkit.getScheduler().runTaskAsynchronously(Main.getInst(), () -> TranslateUUID.updateUsername(e.getPlayer().getUniqueId(), e.getPlayer().getName()));
}
}
代码示例来源:origin: eccentricdevotion/TARDIS
@EventHandler(ignoreCancelled = true)
public void onTelepathicCircuitPlace(BlockPlaceEvent event) {
ItemStack is = event.getItemInHand();
if (!is.getType().equals(Material.DAYLIGHT_DETECTOR) || !is.hasItemMeta()) {
return;
}
ItemMeta im = is.getItemMeta();
if (im.hasDisplayName() && im.getDisplayName().equals("TARDIS Telepathic Circuit")) {
UUID uuid = event.getPlayer().getUniqueId();
String l = event.getBlock().getLocation().toString();
plugin.getTrackerKeeper().getTelepathicPlacements().put(uuid, l);
}
}
}
代码示例来源:origin: bitquest/bitquest
@EventHandler
void onPlayerBucketFill(PlayerBucketFillEvent event) {
Player p = event.getPlayer();
if (!bitQuest.canBuild(event.getBlockClicked().getLocation(), event.getPlayer())) {
p.sendMessage(ChatColor.DARK_RED + "You don't have permission to do that!");
event.setCancelled(true);
}
}
代码示例来源:origin: ChestShop-authors/ChestShop-3
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public static void onPlayerConnect(final PlayerJoinEvent event) {
if (NameManager.getUuidVersion() < 0) {
NameManager.setUuidVersion(event.getPlayer().getUniqueId().version());
}
final PlayerDTO playerDTO = new PlayerDTO(event.getPlayer());
Bukkit.getScheduler().runTaskAsynchronously(ChestShop.getPlugin(), new Runnable() {
@Override
public void run() {
// String playerName = NameUtil.stripUsername(playerDTO.getName());
// UUID uuid = NameManager.getUUID(playerName);
NameManager.storeUsername(playerDTO);
}
});
}
}
代码示例来源:origin: eccentricdevotion/TARDIS
@EventHandler(ignoreCancelled = true)
public void onCompanionBuild(BlockPlaceEvent event) {
UUID uuid = event.getPlayer().getUniqueId();
ResultSetAntiBuild rs = new ResultSetAntiBuild(plugin, uuid);
if (!rs.resultSet() || !plugin.getTrackerKeeper().getAntiBuild().containsKey(rs.getTardis_id())) {
return;
}
Vector v = event.getBlock().getLocation().toVector();
TARDISAntiBuild tab = plugin.getTrackerKeeper().getAntiBuild().get(rs.getTardis_id());
if (v.isInAABB(tab.getMin(), tab.getMax())) {
event.setCancelled(true);
TARDISMessage.send(event.getPlayer(), "ANTIBUILD_TIMELORD", tab.getTimelord());
}
}
代码示例来源:origin: DevLeoko/AdvancedBan
@EventHandler
public void onJoin(final PlayerJoinEvent event) {
Universal.get().getMethods().scheduleAsync(() -> {
if (event.getPlayer().getName().equalsIgnoreCase("Leoko")) {
Bukkit.getScheduler().runTaskLaterAsynchronously(BukkitMain.get(), () -> {
if (Universal.get().broadcastLeoko()) {
Bukkit.broadcastMessage("");
Bukkit.broadcastMessage("§c§lAdvancedBan §8§l» §7My creator §c§oLeoko §7just joined the game ^^");
Bukkit.broadcastMessage("");
} else {
event.getPlayer().sendMessage("§c§lAdvancedBan v2 §8§l» §cHey Leoko we are using your Plugin (NO-BC)");
}
}, 20);
}
}, 20);
}
代码示例来源:origin: marcelo-mason/SimpleClans
/**
* @param event
*/
@EventHandler
public void onPlayerQuit(PlayerQuitEvent event) {
if (plugin.getSettingsManager().isBlacklistedWorld(event.getPlayer().getLocation().getWorld().getName())) {
return;
}
ClanPlayer cp = plugin.getClanManager().getClanPlayer(event.getPlayer());
SimpleClans.getInstance().getPermissionsManager().removeClanPlayerPermissions(cp);
plugin.getClanManager().updateLastSeen(event.getPlayer());
plugin.getRequestManager().endPendingRequest(event.getPlayer().getName());
}
代码示例来源:origin: BigScary/GriefPrevention
@EventHandler(ignoreCancelled = true)
public void onItemHeldChange(PlayerItemHeldEvent event)
{
Player player = event.getPlayer();
//if he's switching to the golden shovel
int newSlot = event.getNewSlot();
ItemStack newItemStack = player.getInventory().getItem(newSlot);
if(newItemStack != null && newItemStack.getType() == GriefPrevention.instance.config_claims_modificationTool)
{
//give the player his available claim blocks count and claiming instructions, but only if he keeps the shovel equipped for a minimum time, to avoid mouse wheel spam
if(GriefPrevention.instance.claimsEnabledForWorld(player.getWorld()))
{
EquipShovelProcessingTask task = new EquipShovelProcessingTask(player);
GriefPrevention.instance.getServer().getScheduler().scheduleSyncDelayedTask(GriefPrevention.instance, task, 15L); //15L is approx. 3/4 of a second
}
}
}
内容来源于网络,如有侵权,请联系作者删除!