mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-22 13:16:45 +01:00
Command cleanup - Fishing. Added 2 new fishing permissions nodes.
This commit is contained in:
parent
def41af469
commit
3d2b881b0e
@ -10,6 +10,7 @@ Key:
|
||||
Version 1.3.07
|
||||
+ Added a permission node for Archery bonus damage
|
||||
+ Added a permission node for Greater Impact ability
|
||||
+ Added permission nodes for Treasure & Magic Hunter for Fishing
|
||||
= Fixed bug where the permission node for Impact didn't work
|
||||
! Changed MySQL to save player information 50ms apart from each other to reduce the load on the MySQL server
|
||||
- Removed some unused permission nodes
|
||||
|
@ -1,5 +1,7 @@
|
||||
package com.gmail.nossr50.commands.skills;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@ -11,9 +13,17 @@ import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.skills.Fishing;
|
||||
import com.gmail.nossr50.util.Page;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class FishingCommand implements CommandExecutor {
|
||||
private int lootTier;
|
||||
private String magicChance;
|
||||
|
||||
private boolean canTreasureHunt;
|
||||
private boolean canMagicHunt;
|
||||
private boolean canShake;
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (CommandHelper.noConsoleUsage(sender)) {
|
||||
@ -27,29 +37,68 @@ public class FishingCommand implements CommandExecutor {
|
||||
Player player = (Player) sender;
|
||||
PlayerProfile PP = Users.getProfile(player);
|
||||
|
||||
lootTier = Fishing.getFishingLootTier(PP);
|
||||
dataCalculations(lootTier);
|
||||
permissionsCheck(player);
|
||||
|
||||
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Fishing.SkillName") }));
|
||||
player.sendMessage(LocaleLoader.getString("Commands.XPGain", new Object[] { LocaleLoader.getString("Commands.XPGain.Fishing") }));
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Level", new Object[] { PP.getSkillLevel(SkillType.FISHING), PP.getSkillXpLevel(SkillType.FISHING), PP.getXpToLevel(SkillType.FISHING) }));
|
||||
|
||||
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Effects.Effects") }));
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Fishing.Effect.0"), LocaleLoader.getString("Fishing.Effect.1") }));
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Fishing.Effect.2"), LocaleLoader.getString("Fishing.Effect.3") }));
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Fishing.Effect.4"), LocaleLoader.getString("Fishing.Effect.5") }));
|
||||
|
||||
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Commands.Stats.Self") }));
|
||||
player.sendMessage(LocaleLoader.getString("Fishing.Ability.Rank", new Object[] { Fishing.getFishingLootTier(PP) }));
|
||||
player.sendMessage(LocaleLoader.getString("Fishing.Ability.Info"));
|
||||
|
||||
//TODO: Do we really need to display this twice? Not like there are any associated stats.
|
||||
if (PP.getSkillLevel(SkillType.FISHING) < 150) {
|
||||
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", new Object[] { LocaleLoader.getString("Fishing.Ability.Locked.0") }));
|
||||
if (canTreasureHunt || canMagicHunt || canShake) {
|
||||
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Effects.Effects") }));
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Fishing.Ability.Shake"));
|
||||
|
||||
if (canTreasureHunt) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Fishing.Effect.0"), LocaleLoader.getString("Fishing.Effect.1") }));
|
||||
}
|
||||
|
||||
if (canMagicHunt) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Fishing.Effect.2"), LocaleLoader.getString("Fishing.Effect.3") }));
|
||||
}
|
||||
|
||||
if (canShake) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Fishing.Effect.4"), LocaleLoader.getString("Fishing.Effect.5") }));
|
||||
}
|
||||
|
||||
if (canTreasureHunt || canMagicHunt || canShake) {
|
||||
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Commands.Stats.Self") }));
|
||||
}
|
||||
|
||||
if (canTreasureHunt) {
|
||||
player.sendMessage(LocaleLoader.getString("Fishing.Ability.Rank", new Object[] { lootTier }));
|
||||
}
|
||||
|
||||
if (canMagicHunt) {
|
||||
player.sendMessage(LocaleLoader.getString("Fishing.Enchant.Chance", new Object[] { magicChance }));
|
||||
}
|
||||
|
||||
if (canShake) {
|
||||
//TODO: Do we really need to display this twice? Not like there are any associated stats.
|
||||
if (PP.getSkillLevel(SkillType.FISHING) < 150) {
|
||||
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", new Object[] { LocaleLoader.getString("Fishing.Ability.Locked.0") }));
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Fishing.Ability.Shake"));
|
||||
}
|
||||
}
|
||||
|
||||
Page.grabGuidePageForSkill(SkillType.FISHING, player, args);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private void dataCalculations(int lootTier) {
|
||||
DecimalFormat percent = new DecimalFormat("##0.00%");
|
||||
|
||||
magicChance = percent.format((float) lootTier / 15);
|
||||
}
|
||||
|
||||
private void permissionsCheck(Player player) {
|
||||
Permissions permInstance = Permissions.getInstance();
|
||||
|
||||
canTreasureHunt = permInstance.fishingTreasures(player);
|
||||
canMagicHunt = permInstance.fishingMagic(player);
|
||||
canShake = permInstance.shakeMob(player);
|
||||
}
|
||||
}
|
||||
|
@ -26,6 +26,7 @@ import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.Combat;
|
||||
import com.gmail.nossr50.util.ItemChecks;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class Fishing {
|
||||
@ -97,7 +98,7 @@ public class Fishing {
|
||||
break;
|
||||
}
|
||||
|
||||
if (Config.getInstance().getFishingDropsEnabled() && rewards.size() > 0) {
|
||||
if (Config.getInstance().getFishingDropsEnabled() && rewards.size() > 0 && Permissions.getInstance().fishingTreasures(player)) {
|
||||
FishingTreasure treasure = rewards.get(random.nextInt(rewards.size()));
|
||||
|
||||
if (random.nextDouble() * 100 <= treasure.getDropChance()) {
|
||||
@ -129,7 +130,7 @@ public class Fishing {
|
||||
PlayerProfile PP = Users.getProfile(player);
|
||||
|
||||
getFishingResults(player, event);
|
||||
Item theCatch = (Item)event.getCaught();
|
||||
Item theCatch = (Item) event.getCaught();
|
||||
|
||||
if (theCatch.getItemStack().getType() != Material.RAW_FISH) {
|
||||
final int ENCHANTMENT_CHANCE = 10;
|
||||
@ -138,7 +139,7 @@ public class Fishing {
|
||||
|
||||
player.sendMessage(LocaleLoader.getString("Fishing.ItemFound"));
|
||||
if (ItemChecks.isArmor(fishingResults) || ItemChecks.isTool(fishingResults)) {
|
||||
if (random.nextInt(100) <= ENCHANTMENT_CHANCE) {
|
||||
if (random.nextInt(100) <= ENCHANTMENT_CHANCE && Permissions.getInstance().fishingMagic(player)) {
|
||||
for (Enchantment newEnchant : Enchantment.values()) {
|
||||
if (newEnchant.canEnchantItem(fishingResults)) {
|
||||
Map<Enchantment, Integer> resultEnchantments = fishingResults.getEnchantments();
|
||||
|
@ -204,9 +204,8 @@ public class Combat {
|
||||
dmgBonusPercent = 2;
|
||||
}
|
||||
|
||||
/* Every 100 skill levels Archery gains 20% damage bonus, set that here */
|
||||
/* Every 50 skill levels Archery gains 10% damage bonus, set that here */
|
||||
//TODO: Work in progress for balancing out Archery, will work on it more later...
|
||||
//TODO: Right now this is calculating a 10% bonus every 50 levels, not 20% every 100. Is this intended?
|
||||
int archeryBonus = (int)(event.getDamage() * dmgBonusPercent);
|
||||
event.setDamage(event.getDamage() + archeryBonus);
|
||||
}
|
||||
|
@ -108,6 +108,14 @@ public class Permissions {
|
||||
return player.hasPermission("mcmmo.ability.fishing.shakemob");
|
||||
}
|
||||
|
||||
public boolean fishingTreasures(Player player) {
|
||||
return player.hasPermission("mcmmo.ability.fishing.treasures");
|
||||
}
|
||||
|
||||
public boolean fishingMagic(Player player) {
|
||||
return player.hasPermission("mcmmo.ability.fishing.magic");
|
||||
}
|
||||
|
||||
/*
|
||||
* MCMMO.ABILITY.MINING.*
|
||||
*/
|
||||
|
@ -109,6 +109,7 @@ Fishing.Effect.2=Magic Hunter
|
||||
Fishing.Effect.3=Find Enchanted Items
|
||||
Fishing.Effect.4=Shake (vs. Entities)
|
||||
Fishing.Effect.5=Shake items off of mobs w/ fishing pole
|
||||
Fishing.Enchant.Chance=[[RED]]Magic Hunter Chance: [[YELLOW]]{0}
|
||||
Fishing.ItemFound=[[GRAY]]Treasure found!
|
||||
Fishing.Listener=Fishing:
|
||||
Fishing.MagicFound=[[GRAY]]You feel a touch of magic with this catch...
|
||||
@ -485,7 +486,7 @@ Guides.Unarmed=Guide coming soon...
|
||||
Guides.Woodcutting=Guide coming soon...
|
||||
|
||||
#INSPECT
|
||||
Inspect.Offline= [[RED]]That player is offline, inspecting offline players is limited to Ops!
|
||||
Inspect.Offline= [[RED]]You do not have permission to inspect offline players!
|
||||
Inspect.OfflineStats=mcMMO Stats for Offline Player [[YELLOW]]{0}
|
||||
Inspect.Stats=[[GREEN]]mcMMO Stats for [[YELLOW]]{0}
|
||||
Inspect.TooFar=[[RED]]You are too far away to inspect that player!
|
||||
|
@ -213,8 +213,14 @@ permissions:
|
||||
description: Allows access to all Fishing abilities
|
||||
children:
|
||||
mcmmo.ability.fishing.shakemob: true
|
||||
mcmmo.ability.fishing.treasures: true
|
||||
mcmmo.ability.fishing.magic: true
|
||||
mcmmo.ability.fishing.shakemob:
|
||||
description: Allows access to the Shake Mob ability
|
||||
mcmmo.ability.fishing.treasures:
|
||||
description: Allows treasure drops from Fishing
|
||||
mcmmo.ability.fishing.magic:
|
||||
description: Allows enchanted drops from Fishing
|
||||
mcmmo.ability.mining.*:
|
||||
description: Allows access to all Mining abilities
|
||||
children:
|
||||
|
Loading…
Reference in New Issue
Block a user