本文整理汇总了Java中org.bukkit.event.player.PlayerFishEvent.getPlayer方法的典型用法代码示例。如果您正苦于以下问题:Java PlayerFishEvent.getPlayer方法的具体用法?Java PlayerFishEvent.getPlayer怎么用?Java PlayerFishEvent.getPlayer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.event.player.PlayerFishEvent
的用法示例。
在下文中一共展示了PlayerFishEvent.getPlayer方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
}
}
}
示例2: 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);
}
示例3: disableFishingRodPull
import org.bukkit.event.player.PlayerFishEvent; //导入方法依赖的package包/类
@EventHandler(ignoreCancelled = true)
public void disableFishingRodPull(PlayerFishEvent e) {
if (e.getCaught() instanceof Player
&& config.checkEnabled(Config.Node.FISHING_HOOK, e.getCaught().getLocation())) {
final Player shooter = e.getPlayer();
Player caught = (Player) e.getCaught();
if (!shooter.equals(caught) && !helper.isPvPAllowed(shooter, caught)) {
final int heldSlot = shooter.getInventory().getHeldItemSlot();
shooter.getInventory().setHeldItemSlot((heldSlot + 1) % 9);
Bukkit.getScheduler().runTaskLater(WorldGuardFix.getInstance(), new Runnable() {
@Override
public void run() {
shooter.getInventory().setHeldItemSlot(heldSlot);
}
}, 2L);
e.setCancelled(true);
shooter.sendMessage(ChatColor.RED.toString() + ChatColor.BOLD
+ "Hey!" + ChatColor.GRAY + " Sorry, but you can't PvP here.");
}
}
}
示例4: cancelSameTeam
import org.bukkit.event.player.PlayerFishEvent; //导入方法依赖的package包/类
public void cancelSameTeam(PlayerFishEvent e) {
if (e.getCaught() instanceof Player) {
Player damager = e.getPlayer();
Player player = (Player) e.getCaught();
TeamId playerTeam = plugin.pm.getTeamId(player);
TeamId damagerTeam = plugin.pm.getTeamId(damager);
if (playerTeam == damagerTeam) {
e.setCancelled(true);
}
}
}
示例5: 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;
}
}
示例6: onPlayerFish
import org.bukkit.event.player.PlayerFishEvent; //导入方法依赖的package包/类
@EventHandler
public void onPlayerFish(PlayerFishEvent event) {
Player p = event.getPlayer();
ArenaManager am = SimpleSurvivalGames.instance.getArenaManager();
// Is the current player playing
if(am.isInArena(p)) {
ArenaPlayer ap = am.getPlayer(p);
// Is the player in the lobby of the arena
if(ap.isInLobby()) {
// Has the player a arena spawn assigned
if(ap.hasAssignedAreanSpawn()) {
// Cancel the event and send a status message
event.setCancelled(true);
p.sendMessage(ChatColor.DARK_RED + "You can't fish inside the lobby of an arena!");
}
}
// Is the player an spectators
if(ap.isSpectator()) {
event.setCancelled(true);
ap.sendMessage(ChatColor.DARK_RED + "You can't fish while spectating!");
}
}
}
示例7: onFish
import org.bukkit.event.player.PlayerFishEvent; //导入方法依赖的package包/类
@EventHandler
public void onFish(PlayerFishEvent e) {
Player p = e.getPlayer();
if (!RUtils.isInInfectedWorld(p)) return;
e.setExpToDrop(0);
PConfManager pcm = PConfManager.getPConfManager(p);
float thirst = pcm.getFloat("thirst");
if (!pcm.isSet("thirst")) {
thirst = 1F;
pcm.set("thirst", thirst);
}
p.setExp(thirst);
}
示例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();
}
示例9: onFishCaught
import org.bukkit.event.player.PlayerFishEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onFishCaught(final PlayerFishEvent event) {
final PlayerStat stat = PlayerStat.ITEMS_CAUGHT;
// Get player
final Player player = event.getPlayer();
// Do general check
if (!plugin.doGeneralCheck(player, stat))
return;
Entity entity;
ItemStack item;
String materialName = null;
if (event.getCaught() != null) {
entity = event.getCaught();
if (!(entity instanceof Item)) {
return; // Did not catch an item
}
item = ((Item) entity).getItemStack();
if (event.getState().equals(State.CAUGHT_FISH)) {
materialName = StatzUtil.getFoodName(item);
if (materialName == null) {
materialName = item.getType().toString();
}
} else {
materialName = item.getType().toString();
}
} else {
// Did not catch anything.
return;
}
final String material = materialName;
// Update value to new stat.
plugin.getDataManager().setPlayerInfo(player.getUniqueId(), stat, StatzUtil.makeQuery("uuid",
player.getUniqueId().toString(), "value", 1, "caught", material, "world", player.getWorld().getName()));
}
示例10: onScoutGrapple
import org.bukkit.event.player.PlayerFishEvent; //导入方法依赖的package包/类
@EventHandler
public void onScoutGrapple(PlayerFishEvent e) {
Player player = e.getPlayer();
player.getItemInHand().setDurability((short) -10);
// if (e.getState() != State.FISHING && e.getState() != State.IN_GROUND)
// return;
if (PlayerMeta.getMeta(player).getKit() != Kit.SCOUT)
return;
if (!player.getItemInHand().getItemMeta().getDisplayName()
.contains("Grapple"))
return;
Location hookLoc = e.getHook().getLocation();
Location playerLoc = player.getLocation();
double hookX = (int) hookLoc.getX();
double hookY = (int) hookLoc.getY();
double hookZ = (int) hookLoc.getZ();
Material inType = hookLoc.getWorld().getBlockAt(hookLoc).getType();
if (inType == Material.AIR || inType == Material.WATER
|| inType == Material.LAVA) {
Material belowType = hookLoc.getWorld()
.getBlockAt((int) hookX, (int) (hookY - 0.1), (int) hookZ)
.getType();
if (belowType == Material.AIR || inType == Material.WATER
|| inType == Material.LAVA)
return;
}
playerLoc.setY(playerLoc.getY() + 0.5);
player.teleport(playerLoc);
Vector diff = hookLoc.toVector().subtract(playerLoc.toVector());
Vector vel = new Vector();
double d = hookLoc.distance(playerLoc);
vel.setX((1.0 + 0.07 * d) * diff.getX() / d);
vel.setY((1.0 + 0.03 * d) * diff.getY() / d + 0.04 * d);
vel.setZ((1.0 + 0.07 * d) * diff.getZ() / d);
player.setVelocity(vel);
}
示例11: 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;
}
}