当前位置: 首页>>代码示例>>Java>>正文


Java PlayerFishEvent.getState方法代码示例

本文整理汇总了Java中org.bukkit.event.player.PlayerFishEvent.getState方法的典型用法代码示例。如果您正苦于以下问题:Java PlayerFishEvent.getState方法的具体用法?Java PlayerFishEvent.getState怎么用?Java PlayerFishEvent.getState使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.bukkit.event.player.PlayerFishEvent的用法示例。


在下文中一共展示了PlayerFishEvent.getState方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: Grappler

import org.bukkit.event.player.PlayerFishEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.NORMAL)
	public void Grappler(PlayerFishEvent event)
	{
		Player player = event.getPlayer();
		if(event.getState() == State.IN_GROUND)
		{
			AnniPlayer p = AnniPlayer.getPlayer(player.getUniqueId());
			if(p != null && p.getKit().equals(this))
			{
				if(isGrappleItem(player.getItemInHand()))
				{
					//event.getHook().
					Location playerloc = player.getLocation();
					Location loc = event.getHook().getLocation();
					if (playerloc.distance(loc) < 3.0D) 
				        pullPlayerSlightly(player, loc);
				    else 
				        pullEntityToLocation(player, loc);
//					Vector vec = playerloc.toVector();
//					Vector vec2 = loc.toVector();
//					player.setVelocity(vec2.subtract(vec).normalize().multiply(1));
					player.getItemInHand().setDurability((short)0);
				}
			}
		}
	}
 
开发者ID:MrLittleKitty,项目名称:AnnihilationPro,代码行数:27,代码来源:Scout.java

示例2: onFish

import org.bukkit.event.player.PlayerFishEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onFish(PlayerFishEvent event) {
    if (event.getState() == PlayerFishEvent.State.CAUGHT_FISH && event.getCaught() instanceof Item) {
        if (!contest.hasStarted() && plugin.getConfig().getBoolean("general.no-fishing-unless-contest")) {
            event.setCancelled(true);

            String msg = plugin.getLocale().getString("no-fishing-allowed");
            event.getPlayer().sendMessage(msg);
            return;
        }
        if (!isFishingEnabled(event)) {
            return;
        }

        executeFishingActions(event.getPlayer(), event);
    }
}
 
开发者ID:elsiff,项目名称:MoreFish,代码行数:18,代码来源:FishingListener.java

示例3: onPlayerFish

import org.bukkit.event.player.PlayerFishEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPlayerFish(PlayerFishEvent event) {
	if (event.getState() != PlayerFishEvent.State.CAUGHT_FISH) {
		return;
	}

	Player player = event.getPlayer();
	NormalAchievements category;
	Item caughtItem = (Item) event.getCaught();
	if (caughtItem.getItemStack().getType() == Material.RAW_FISH) {
		category = NormalAchievements.FISH;
	} else {
		category = NormalAchievements.TREASURES;
	}

	if (plugin.getDisabledCategorySet().contains(category.toString())) {
		return;
	}

	if (!shouldIncreaseBeTakenIntoAccount(player, category)) {
		return;
	}

	updateStatisticAndAwardAchievementsIfAvailable(player, category, 1);
}
 
开发者ID:PyvesB,项目名称:AdvancedAchievements,代码行数:26,代码来源:AchieveFishListener.java

示例4: onPlayerFishEvent

import org.bukkit.event.player.PlayerFishEvent; //导入方法依赖的package包/类
@EventHandler
public void onPlayerFishEvent(PlayerFishEvent event) {
    Fish hook = event.getHook();
    if (event.getState() != PlayerFishEvent.State.FISHING) {
        boolean isBlock = false;
        for (int dx = -1; dx <= 1; dx++) {
            for (int dy = -1; dy <= 1; dy++) {
                for (int dz = -1; dz <= 1; dz++) {
                    if (!RParticles.isAirlike(hook.getWorld().getBlockAt(hook.getLocation().getBlockX() + dx, hook.getLocation().getBlockY() + dy, hook.getLocation().getBlockZ() + dz))) {
                        isBlock = true;
                        break;
                    }
                }
            }
        }
        try {
            event.getPlayer().getEquipment().getItemInMainHand().setDurability((short) 0);
        } catch (Exception e) {

        }
        if (isBlock) {
            pullEntityToLocation(event.getPlayer(), hook.getLocation());
        } else {
            event.getPlayer().sendMessage(ChatColor.RED + "Your grapple wasn't hooked on anything.");
        }
    }
}
 
开发者ID:edasaki,项目名称:ZentrelaRPG,代码行数:28,代码来源:GrappleManager.java

示例5: onReelIn

import org.bukkit.event.player.PlayerFishEvent; //导入方法依赖的package包/类
/**
 * This is to cancel dragging the player closer when you reel in
 */
@EventHandler(priority = EventPriority.HIGHEST)
private void onReelIn(PlayerFishEvent e){
	if(!isSettingEnabled("cancelDraggingIn") || e.getState() != PlayerFishEvent.State.CAUGHT_ENTITY) return;
	e.getHook().remove(); //Nuke the bobber and don't do anything else
	e.setCancelled(true);
}
 
开发者ID:gvlfm78,项目名称:BukkitOldCombatMechanics,代码行数:10,代码来源:ModuleFishingKnockback.java

示例6: onPlayerFishMonitor

import org.bukkit.event.player.PlayerFishEvent; //导入方法依赖的package包/类
/**
 * Monitor PlayerFishEvents.
 * <p>
 * These events are monitored for the purpose of handling the various
 * Fishing skills and abilities.
 *
 * @param event The event to monitor
 */
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPlayerFishMonitor(PlayerFishEvent event) {
    Player player = event.getPlayer();

    if (!UserManager.hasPlayerDataKey(player) || !SkillType.FISHING.getPermissions(player)) {
        return;
    }

    FishingManager fishingManager = UserManager.getPlayer(player).getFishingManager();
    Entity caught = event.getCaught();

    switch (event.getState()) {
        case FISHING:
            if (fishingManager.canMasterAngler()) {
                fishingManager.masterAngler(event.getHook());
            }
            return;

        case CAUGHT_FISH:
            fishingManager.handleFishing((Item) caught);
            return;

        case CAUGHT_ENTITY:
            if (fishingManager.canShake(caught)) {
                fishingManager.shakeCheck((LivingEntity) caught);
            }
            return;

        default:
            return;
    }
}
 
开发者ID:Pershonkey,项目名称:McMMOPlus,代码行数:41,代码来源:PlayerListener.java

示例7: onPlayerFish

import org.bukkit.event.player.PlayerFishEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.LOW)
public void onPlayerFish(PlayerFishEvent event) {
    if (event.getState() == PlayerFishEvent.State.CAUGHT_FISH) {
        event.getCaught().remove();
        int roll = random.nextInt(101);
        if (roll > (100 - (getFishingConfig().getInt("chance") + 1))) {
            event.getPlayer().sendMessage(ChatColor.YELLOW + "The caught fish looks a bit off...");
        } else {
            roll = random.nextInt(fish.size() + 1);
            event.getPlayer().getWorld().dropItemNaturally(event.getHook().getLocation(), fish.get(roll)).setVelocity(reelVelocity(event.getPlayer(), event.getHook()));
        }
    }
}
 
开发者ID:WaywardRealms,项目名称:Wayward,代码行数:14,代码来源:PlayerFishListener.java

示例8: onPlayerFish

import org.bukkit.event.player.PlayerFishEvent; //导入方法依赖的package包/类
@EventHandler
public void onPlayerFish(PlayerFishEvent e) {
	if (e.getState() != PlayerFishEvent.State.CAUGHT_FISH) {
		return;
	}
	
	if (!QuestManagerPlugin.questManagerPlugin.getPluginConfiguration().getWorlds()
			.contains(e.getPlayer().getWorld().getName())) {
		return;
	}
	

	//e.setCancelled(true);
	e.getCaught().remove();
	
	QuestPlayer qp = QuestManagerPlugin.questManagerPlugin.getPlayerManager().getPlayer(e.getPlayer());
	int level = qp.getSkillLevel(this);
	
	FishRecord record = getFish(level, e.getHook().getLocation());
	if (record == null) {
		e.getPlayer().sendMessage(BAD_RANGE_MESSAGE);
		return;
	}
	
	FishEvent event = new FishEvent(qp, new QualityItem(record.icon), record.difficulty);
	Bukkit.getPluginManager().callEvent(event);
	
	if (event.isCancelled()) {
		return;
	}
	
	int deltaDifficulty = Math.max(0, record.difficulty - level);
	double obstacleTime, obstacleDeviation, completionTime;
	int rows, amount;
	float reelDifficulty, reelDeviation;
	
	
	obstacleTime = baseObstacleDifficulty + (deltaDifficulty * obstacleDifficultyRate);
	obstacleDeviation = baseObstacleDeviation;
	completionTime = baseTimePerDifficulty * record.difficulty;
	rows = (int) Math.min(5, Math.max(1, 1 + ((int) record.difficulty / (int) difficultyPerRow)));
	amount = 1 + (int) Math.floor(extraFishPerLevel * Math.max(level - record.difficulty, 0));
	reelDifficulty = baseReelDifficulty + (reelDifficultyRate * deltaDifficulty);
	reelDeviation = baseReelDeviation;
	
	////////Modifer Code - Move to eventhandler if mechs moved out of skill/////////
	
	event.setObstacleDifficultyModifier(event.getObstacleDifficultyModifier()
			- (obstacleDifficultyDiscount * level));
	event.setReelDifficultyModifier(event.getReelDifficultyModifier()
			- (reelDifficultyDiscount * level));
	event.setTimeModifier(event.getTimeModifier() - (timeDiscount * level));
	event.setQualityModifier(event.getQualityModifier() + (level * qualityRate));
	
	////////////////////////////////////////////////////////////////////////////////
	
	//apply modifiers
	obstacleTime *= event.getObstacleDifficultyModifier();
	obstacleDeviation *= event.getObstacleDeviationModifier();
	completionTime *= event.getTimeModifier();
	reelDifficulty *= event.getReelDifficultyModifier();
	reelDeviation *= event.getReelDeviationModifier();
	
	QualityItem reward = new QualityItem(record.icon.clone());
	reward.getUnderlyingItem().setAmount(amount);
	reward.setQuality(reward.getQuality() * event.getQualityModifier());
	
	FishingGui gui = new FishingGui(e.getPlayer(), reward, record.difficulty, rows,
			reelDifficulty, reelDeviation, letRate, obstacleTime, obstacleDeviation, completionTime);
	InventoryMenu menu = new InventoryMenu(qp, gui);
	QuestManagerPlugin.questManagerPlugin.getInventoryGuiHandler().showMenu(e.getPlayer(), menu);
	gui.start();
	
}
 
开发者ID:Dove-Bren,项目名称:QuestManager,代码行数:75,代码来源:FishingSkill.java

示例9: onPlayerFishHighest

import org.bukkit.event.player.PlayerFishEvent; //导入方法依赖的package包/类
/**
 * Handle PlayerFishEvents at the highest priority.
 * <p>
 * These events are used for the purpose of handling our anti-exploit
 * code, as well as dealing with ice fishing.
 *
 * @param event The event to modify
 */
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onPlayerFishHighest(PlayerFishEvent event) {
    Player player = event.getPlayer();

    if (!UserManager.hasPlayerDataKey(player) || !SkillType.FISHING.getPermissions(player)) {
        return;
    }

    FishingManager fishingManager = UserManager.getPlayer(player).getFishingManager();

    switch (event.getState()) {
        case FISHING:
            if (!Permissions.krakenBypass(player)) {
                event.setCancelled(fishingManager.exploitPrevention());
            }
            return;

        case CAUGHT_FISH:
            //TODO Update to new API once available! Waiting for case CAUGHT_TREASURE:
            Item fishingCatch = (Item) event.getCaught();

            if (Config.getInstance().getFishingOverrideTreasures() && fishingCatch.getItemStack().getType() != Material.RAW_FISH) {
                fishingCatch.setItemStack(new ItemStack(Material.RAW_FISH, 1));
            }

            if (Permissions.vanillaXpBoost(player, SkillType.FISHING)) {
                event.setExpToDrop(fishingManager.handleVanillaXpBoost(event.getExpToDrop()));
            }
            return;

        case IN_GROUND:
            Block block = player.getTargetBlock(null, 100);

            if (fishingManager.canIceFish(block)) {
                event.setCancelled(true);
                fishingManager.iceFishing(event.getHook(), block);
            }
            return;

        default:
            return;
    }
}
 
开发者ID:Pershonkey,项目名称:McMMOPlus,代码行数:52,代码来源:PlayerListener.java


注:本文中的org.bukkit.event.player.PlayerFishEvent.getState方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。