mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-22 13:16:45 +01:00
Added "Ice Fishing" ability to Fishing
This commit is contained in:
parent
76cf0ebb01
commit
3322677d32
@ -8,6 +8,7 @@ Key:
|
|||||||
- Removal
|
- Removal
|
||||||
|
|
||||||
Version 1.4.06-dev
|
Version 1.4.06-dev
|
||||||
|
+ Added "Ice Fishing" ability to Fishing
|
||||||
+ Added global scoreboards to track skill rankings (display using /mctop)
|
+ Added global scoreboards to track skill rankings (display using /mctop)
|
||||||
+ Added per-player scoreboard displays for the /inspect, /mcrank, /mcstats, and /<skillname> commands
|
+ Added per-player scoreboard displays for the /inspect, /mcrank, /mcstats, and /<skillname> commands
|
||||||
+ Added tab-complete support for all commands
|
+ Added tab-complete support for all commands
|
||||||
|
@ -22,6 +22,7 @@ public class FishingCommand extends SkillCommand {
|
|||||||
private boolean canShake;
|
private boolean canShake;
|
||||||
private boolean canFishermansDiet;
|
private boolean canFishermansDiet;
|
||||||
private boolean canMasterAngler;
|
private boolean canMasterAngler;
|
||||||
|
private boolean canIceFish;
|
||||||
|
|
||||||
public FishingCommand() {
|
public FishingCommand() {
|
||||||
super(SkillType.FISHING);
|
super(SkillType.FISHING);
|
||||||
@ -71,11 +72,12 @@ public class FishingCommand extends SkillCommand {
|
|||||||
canShake = Permissions.shake(player);
|
canShake = Permissions.shake(player);
|
||||||
canFishermansDiet = Permissions.fishermansDiet(player);
|
canFishermansDiet = Permissions.fishermansDiet(player);
|
||||||
canMasterAngler = Permissions.masterAngler(player);
|
canMasterAngler = Permissions.masterAngler(player);
|
||||||
|
canIceFish = Permissions.iceFishing(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean effectsHeaderPermissions() {
|
protected boolean effectsHeaderPermissions() {
|
||||||
return canTreasureHunt || canMagicHunt || canShake || canMasterAngler || canFishermansDiet;
|
return canTreasureHunt || canMagicHunt || canShake || canMasterAngler || canFishermansDiet || canIceFish;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -101,11 +103,15 @@ public class FishingCommand extends SkillCommand {
|
|||||||
if (canMasterAngler) {
|
if (canMasterAngler) {
|
||||||
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Fishing.Effect.8"), LocaleLoader.getString("Fishing.Effect.9")));
|
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Fishing.Effect.8"), LocaleLoader.getString("Fishing.Effect.9")));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (canIceFish) {
|
||||||
|
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Fishing.Effect.10"), LocaleLoader.getString("Fishing.Effect.11")));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean statsHeaderPermissions() {
|
protected boolean statsHeaderPermissions() {
|
||||||
return canTreasureHunt || canMagicHunt || canShake || canMasterAngler || canFishermansDiet;
|
return canTreasureHunt || canMagicHunt || canShake || canMasterAngler || canFishermansDiet || canIceFish;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -136,5 +142,16 @@ public class FishingCommand extends SkillCommand {
|
|||||||
if (canFishermansDiet) {
|
if (canFishermansDiet) {
|
||||||
player.sendMessage(LocaleLoader.getString("Fishing.Ability.FD", fishermansDietRank));
|
player.sendMessage(LocaleLoader.getString("Fishing.Ability.FD", fishermansDietRank));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (canIceFish) {
|
||||||
|
int unlockLevel = AdvancedConfig.getInstance().getIceFishingUnlockLevel();
|
||||||
|
|
||||||
|
if (skillValue < unlockLevel) {
|
||||||
|
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Fishing.Ability.Locked.1", unlockLevel)));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
player.sendMessage(LocaleLoader.getString("Fishing.Ability.IceFishing"));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -85,6 +85,8 @@ public class AdvancedConfig extends AutoUpdateConfigLoader {
|
|||||||
|
|
||||||
public int getFishermanDietRankChange() { return config.getInt("Skills.Fishing.Fisherman_Diet_RankChange", 200); }
|
public int getFishermanDietRankChange() { return config.getInt("Skills.Fishing.Fisherman_Diet_RankChange", 200); }
|
||||||
|
|
||||||
|
public int getIceFishingUnlockLevel() { return config.getInt("Skills.Fishing.Ice_Fishing_UnlockLevel", 50); }
|
||||||
|
|
||||||
/* Shake */
|
/* Shake */
|
||||||
public int getShakeUnlockLevel() { return config.getInt("Skills.Fishing.Shake_UnlockLevel", 150); }
|
public int getShakeUnlockLevel() { return config.getInt("Skills.Fishing.Shake_UnlockLevel", 150); }
|
||||||
public int getShakeChanceRank1() { return config.getInt("Skills.Fishing.Shake_Chance.Rank_1", 25); }
|
public int getShakeChanceRank1() { return config.getInt("Skills.Fishing.Shake_Chance.Rank_1", 25); }
|
||||||
|
@ -0,0 +1,12 @@
|
|||||||
|
package com.gmail.nossr50.events.fake;
|
||||||
|
|
||||||
|
import org.bukkit.entity.Entity;
|
||||||
|
import org.bukkit.entity.Fish;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.player.PlayerFishEvent;
|
||||||
|
|
||||||
|
public class FakePlayerFishEvent extends PlayerFishEvent {
|
||||||
|
public FakePlayerFishEvent(Player player, Entity entity, Fish hookEntity, State state) {
|
||||||
|
super(player, entity, hookEntity, state);
|
||||||
|
}
|
||||||
|
}
|
@ -7,6 +7,7 @@ import org.bukkit.Sound;
|
|||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.block.BlockState;
|
import org.bukkit.block.BlockState;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
|
import org.bukkit.entity.Fish;
|
||||||
import org.bukkit.entity.Item;
|
import org.bukkit.entity.Item;
|
||||||
import org.bukkit.entity.LivingEntity;
|
import org.bukkit.entity.LivingEntity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -191,11 +192,22 @@ public class PlayerListener implements Listener {
|
|||||||
|
|
||||||
case CAUGHT_ENTITY:
|
case CAUGHT_ENTITY:
|
||||||
Entity entity = event.getCaught();
|
Entity entity = event.getCaught();
|
||||||
|
|
||||||
if (fishingManager.canShake(entity)) {
|
if (fishingManager.canShake(entity)) {
|
||||||
fishingManager.shakeCheck((LivingEntity) entity);
|
fishingManager.shakeCheck((LivingEntity) entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case IN_GROUND:
|
||||||
|
Fish hook = event.getHook();
|
||||||
|
Block block = hook.getLocation().getBlock();
|
||||||
|
|
||||||
|
if (fishingManager.canIceFish(block)) {
|
||||||
|
event.setCancelled(true);
|
||||||
|
fishingManager.iceFishing(hook, block);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,9 @@ import java.util.Collections;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.block.Biome;
|
||||||
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.block.BlockFace;
|
||||||
import org.bukkit.enchantments.Enchantment;
|
import org.bukkit.enchantments.Enchantment;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.Fish;
|
import org.bukkit.entity.Fish;
|
||||||
@ -14,8 +17,10 @@ import org.bukkit.entity.Player;
|
|||||||
import org.bukkit.entity.Sheep;
|
import org.bukkit.entity.Sheep;
|
||||||
import org.bukkit.entity.Skeleton;
|
import org.bukkit.entity.Skeleton;
|
||||||
import org.bukkit.entity.Skeleton.SkeletonType;
|
import org.bukkit.entity.Skeleton.SkeletonType;
|
||||||
|
import org.bukkit.event.player.PlayerFishEvent;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.gmail.nossr50.config.AdvancedConfig;
|
import com.gmail.nossr50.config.AdvancedConfig;
|
||||||
import com.gmail.nossr50.config.Config;
|
import com.gmail.nossr50.config.Config;
|
||||||
import com.gmail.nossr50.config.treasure.TreasureConfig;
|
import com.gmail.nossr50.config.treasure.TreasureConfig;
|
||||||
@ -23,6 +28,7 @@ import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
|||||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||||
import com.gmail.nossr50.datatypes.treasure.FishingTreasure;
|
import com.gmail.nossr50.datatypes.treasure.FishingTreasure;
|
||||||
import com.gmail.nossr50.datatypes.treasure.ShakeTreasure;
|
import com.gmail.nossr50.datatypes.treasure.ShakeTreasure;
|
||||||
|
import com.gmail.nossr50.events.fake.FakePlayerFishEvent;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.skills.SkillManager;
|
import com.gmail.nossr50.skills.SkillManager;
|
||||||
import com.gmail.nossr50.skills.fishing.Fishing.Tier;
|
import com.gmail.nossr50.skills.fishing.Fishing.Tier;
|
||||||
@ -45,6 +51,26 @@ public class FishingManager extends SkillManager {
|
|||||||
return Permissions.masterAngler(getPlayer());
|
return Permissions.masterAngler(getPlayer());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean canIceFish(Block block) {
|
||||||
|
if (getSkillLevel() < AdvancedConfig.getInstance().getIceFishingUnlockLevel()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (block.getType() != Material.ICE) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Make sure this is a body of water, not just a block of ice.
|
||||||
|
Biome biome = block.getBiome();
|
||||||
|
boolean isFrozenBiome = (biome == Biome.FROZEN_OCEAN || biome == Biome.FROZEN_RIVER);
|
||||||
|
|
||||||
|
if (!isFrozenBiome && block.getRelative(BlockFace.DOWN, 3).getType() == (Material.STATIONARY_WATER)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Permissions.iceFishing(getPlayer());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the loot tier
|
* Gets the loot tier
|
||||||
*
|
*
|
||||||
@ -90,6 +116,24 @@ public class FishingManager extends SkillManager {
|
|||||||
return SkillUtils.handleFoodSkills(getPlayer(), skill, eventFoodLevel, Fishing.fishermansDietRankLevel1, Fishing.fishermansDietMaxLevel, rankChange);
|
return SkillUtils.handleFoodSkills(getPlayer(), skill, eventFoodLevel, Fishing.fishermansDietRankLevel1, Fishing.fishermansDietMaxLevel, rankChange);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void iceFishing(Fish hook, Block block) {
|
||||||
|
// Make a hole
|
||||||
|
block.setType(Material.STATIONARY_WATER);
|
||||||
|
|
||||||
|
for (int x = -1; x <= 1; x++) {
|
||||||
|
for (int z = -1; z <= 1; z++) {
|
||||||
|
Block relative = block.getRelative(x, 0, z);
|
||||||
|
|
||||||
|
if (relative.getType() == Material.ICE) {
|
||||||
|
relative.setType(Material.STATIONARY_WATER);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Recast in the new spot
|
||||||
|
mcMMO.p.getServer().getPluginManager().callEvent(new FakePlayerFishEvent(getPlayer(), null, hook, PlayerFishEvent.State.FISHING));
|
||||||
|
}
|
||||||
|
|
||||||
public void masterAngler(Fish hook) {
|
public void masterAngler(Fish hook) {
|
||||||
hook.setBiteChance(Math.min(hook.getBiteChance() * Math.max((getSkillLevel() / 200.0), 1.0), 1.0));
|
hook.setBiteChance(Math.min(hook.getBiteChance() * Math.max((getSkillLevel() / 200.0), 1.0), 1.0));
|
||||||
}
|
}
|
||||||
|
@ -142,6 +142,7 @@ public final class Permissions {
|
|||||||
/* FISHING */
|
/* FISHING */
|
||||||
public static boolean fishermansDiet(Permissible permissible) { return permissible.hasPermission("mcmmo.ability.fishing.fishermansdiet"); }
|
public static boolean fishermansDiet(Permissible permissible) { return permissible.hasPermission("mcmmo.ability.fishing.fishermansdiet"); }
|
||||||
public static boolean fishingTreasureHunter(Permissible permissible) { return permissible.hasPermission("mcmmo.ability.fishing.treasures"); }
|
public static boolean fishingTreasureHunter(Permissible permissible) { return permissible.hasPermission("mcmmo.ability.fishing.treasures"); }
|
||||||
|
public static boolean iceFishing(Permissible permissible) { return permissible.hasPermission("mcmmo.ability.fishing.icefishing"); }
|
||||||
public static boolean magicHunter(Permissible permissible) { return permissible.hasPermission("mcmmo.ability.fishing.magic"); }
|
public static boolean magicHunter(Permissible permissible) { return permissible.hasPermission("mcmmo.ability.fishing.magic"); }
|
||||||
public static boolean masterAngler(Permissible permissible) { return permissible.hasPermission("mcmmo.ability.fishing.masterangler"); }
|
public static boolean masterAngler(Permissible permissible) { return permissible.hasPermission("mcmmo.ability.fishing.masterangler"); }
|
||||||
public static boolean shake(Permissible permissible) { return permissible.hasPermission("mcmmo.ability.fishing.shakemob"); }
|
public static boolean shake(Permissible permissible) { return permissible.hasPermission("mcmmo.ability.fishing.shakemob"); }
|
||||||
|
@ -139,6 +139,9 @@ Skills:
|
|||||||
|
|
||||||
# This determines when Fisherman's Diet adds extra hunger recovery to food
|
# This determines when Fisherman's Diet adds extra hunger recovery to food
|
||||||
Fisherman_Diet_RankChange: 200
|
Fisherman_Diet_RankChange: 200
|
||||||
|
|
||||||
|
# Ice_Fishing_UnlockLevel: Fishing level when the Ice Fishing ability unlocks
|
||||||
|
Ice_Fishing_UnlockLevel: 50
|
||||||
#
|
#
|
||||||
# Settings for Herbalism
|
# Settings for Herbalism
|
||||||
###
|
###
|
||||||
|
@ -101,8 +101,10 @@ Excavation.Skillup=[[YELLOW]]Excavation skill increased by {0}. Total ({1})
|
|||||||
Fishing.Ability.Chance=[[RED]]Bite Chance: [[YELLOW]]{0}
|
Fishing.Ability.Chance=[[RED]]Bite Chance: [[YELLOW]]{0}
|
||||||
Fishing.Ability.Info=[[RED]]Magic Hunter: [[GRAY]] **Improves With Treasure Hunter Rank**
|
Fishing.Ability.Info=[[RED]]Magic Hunter: [[GRAY]] **Improves With Treasure Hunter Rank**
|
||||||
Fishing.Ability.Locked.0=LOCKED UNTIL {0}+ SKILL (SHAKE)
|
Fishing.Ability.Locked.0=LOCKED UNTIL {0}+ SKILL (SHAKE)
|
||||||
|
Fishing.Ability.Locked.1=LOCKED UNTIL {0}+ SKILL (ICE FISHING)
|
||||||
Fishing.Ability.Rank=[[RED]]Treasure Hunter Rank: [[YELLOW]]{0}/5
|
Fishing.Ability.Rank=[[RED]]Treasure Hunter Rank: [[YELLOW]]{0}/5
|
||||||
Fishing.Ability.Shake=[[RED]]Shake Chance: [[YELLOW]]{0}
|
Fishing.Ability.Shake=[[RED]]Shake Chance: [[YELLOW]]{0}
|
||||||
|
Fishing.Ability.IceFishing=[[RED]]Ice Fishing: Go fishing in ice
|
||||||
Fishing.Ability.FD=[[RED]]Fisherman''s Diet: [[YELLOW]]Rank {0}
|
Fishing.Ability.FD=[[RED]]Fisherman''s Diet: [[YELLOW]]Rank {0}
|
||||||
Fishing.Effect.0=Treasure Hunter (Passive)
|
Fishing.Effect.0=Treasure Hunter (Passive)
|
||||||
Fishing.Effect.1=Fish up misc. objects
|
Fishing.Effect.1=Fish up misc. objects
|
||||||
@ -114,6 +116,8 @@ Fishing.Effect.6=Fisherman's Diet
|
|||||||
Fishing.Effect.7=Improves hunger restored from fished foods
|
Fishing.Effect.7=Improves hunger restored from fished foods
|
||||||
Fishing.Effect.8=Master Angler
|
Fishing.Effect.8=Master Angler
|
||||||
Fishing.Effect.9=Improves chance of getting a bite while fishing
|
Fishing.Effect.9=Improves chance of getting a bite while fishing
|
||||||
|
Fishing.Effect.10=Ice Fishing
|
||||||
|
Fishing.Effect.11=Allows you to fish in icy biomes
|
||||||
Fishing.Enchant.Chance=[[RED]]Magic Hunter Chance: [[YELLOW]]{0}
|
Fishing.Enchant.Chance=[[RED]]Magic Hunter Chance: [[YELLOW]]{0}
|
||||||
Fishing.Chance.Raining=[[BLUE]] Rain Bonus
|
Fishing.Chance.Raining=[[BLUE]] Rain Bonus
|
||||||
Fishing.ItemFound=[[GRAY]]Treasure found!
|
Fishing.ItemFound=[[GRAY]]Treasure found!
|
||||||
|
@ -255,6 +255,7 @@ permissions:
|
|||||||
description: Allows access to all Fishing abilities
|
description: Allows access to all Fishing abilities
|
||||||
children:
|
children:
|
||||||
mcmmo.ability.fishing.fishermansdiet: true
|
mcmmo.ability.fishing.fishermansdiet: true
|
||||||
|
mcmmo.ability.fishing.icefishing: true
|
||||||
mcmmo.ability.fishing.magic: true
|
mcmmo.ability.fishing.magic: true
|
||||||
mcmmo.ability.fishing.masterangler: true
|
mcmmo.ability.fishing.masterangler: true
|
||||||
mcmmo.ability.fishing.shakemob: true
|
mcmmo.ability.fishing.shakemob: true
|
||||||
@ -262,6 +263,8 @@ permissions:
|
|||||||
mcmmo.ability.fishing.vanillaxpboost: true
|
mcmmo.ability.fishing.vanillaxpboost: true
|
||||||
mcmmo.ability.fishing.fishermansdiet:
|
mcmmo.ability.fishing.fishermansdiet:
|
||||||
description: Allows access to the Fishermans's Diet ability
|
description: Allows access to the Fishermans's Diet ability
|
||||||
|
mcmmo.ability.fishing.icefishing:
|
||||||
|
description: Allows access to the Ice Fishing ability
|
||||||
mcmmo.ability.fishing.magic:
|
mcmmo.ability.fishing.magic:
|
||||||
description: Allows enchanted drops from Fishing
|
description: Allows enchanted drops from Fishing
|
||||||
mcmmo.ability.fishing.masterangler:
|
mcmmo.ability.fishing.masterangler:
|
||||||
|
Loading…
Reference in New Issue
Block a user