1
0
mirror of https://github.com/mcMMO-Dev/mcMMO.git synced 2026-02-18 17:53:00 +01:00

Compare commits

..

82 Commits

Author SHA1 Message Date
t00thpick1
4c4def2a23 This entirely untested and made on a whim patch may or may not fix database lockups due to seperate threads accessing the db connection at the same time 2014-07-03 00:46:09 -04:00
TfT_02
2b9b5df1ee Alter original event and stop firing FakeDamageEvents
Fixes #2105
2014-07-02 11:28:21 +02:00
TfT_02
e7e62b8d40 SecondaryAbilityEvent now implements Cancellable
Fire SecondaryAbilityEvent for abilities with static chances

Also cleanup some of the event handling for Armor Impact, Greater
Impact and Fast Food
2014-07-02 11:25:13 +02:00
TfT_02
3d242bbdb6 Always call back events 2014-07-02 11:25:13 +02:00
TfT_02
e796eae3c3 Update for new damage API 2014-07-02 11:25:08 +02:00
TfT_02
a257e83a62 Update for new getOnlinePlayers behavior 2014-06-29 14:04:36 +02:00
Kane York
d527584248 A private method cannot be abstract >.> 2014-06-28 23:49:46 -07:00
Kane York
0a4de6e2fc Reword statement in standards.md 2014-06-28 23:48:12 -07:00
TfT_02
4b20f12eff Fix a NPE with getFlowerAndGrassXp()
Fixes #1975
2014-06-23 22:52:34 +02:00
TfT_02
0de1187012 Fixed setting custom names and lore with treasures 2014-06-22 20:42:48 +02:00
TfT_02
8e474170e4 Fix crafting with items received from Salvage
Only set metadata on Salvage items when it’s not set to -1
Fixes #2078

And cleanup some javadocs in Salvageable
2014-06-18 11:44:21 +02:00
TfT_02
2eeb9b1f35 Set a pretty repair material name in armor.yml
Adds #1863
2014-06-15 17:46:16 +02:00
TfT_02
3de6e2c3f1 Add full Repairable support in armor config files
You can now fully configure armor to be repairable from the armor.yml
config files.

Adds Repair_MinimumLevel and Repair_XpMultiplier to armor.yml
2014-06-15 17:46:16 +02:00
TfT_02
98d166808f Finish the tools.yml header 2014-06-15 17:45:52 +02:00
TfT_02
f75e15dfdc Set a pretty repair material name in tools.yml
Adds #1863
2014-06-15 17:31:50 +02:00
TfT_02
f2b892b7d5 Add full Repairable support in tools config files
You can now fully configure a tool to be repairable from the tools.yml
config files.

Adds Repair_MinimumLevel and Repair_XpMultiplier to tools.yml
2014-06-15 17:28:54 +02:00
TfT_02
883ada01f8 Fix typo with XP_Modifier in tools.default.yml 2014-06-15 17:18:49 +02:00
TfT_02
3a8f45a04d Fix bugs with pistons
This commit improves piston tracking and fixes a couple of bugs with
block tracking.

Fixes #2043
2014-06-15 14:26:02 +02:00
TfT_02
906609696b Workaround a CB bug by tracking piston events
There is a bug in Craftbukkit that causes piston events to fire
multiple times. We need to keep track of the extend and retract events
to see which piston events should be processed.
2014-06-15 14:26:02 +02:00
riking
66ccde4310 MCPC+ is now known as Cauldron 2014-06-14 11:34:35 -07:00
TfT_02
4970cdc3f4 Add mcmmo.skills.salvage permission to plugin.yml
Fixes issue where players would have access to the Salvage child skill
by default.

Mentioned in #2075
2014-06-12 13:42:42 +02:00
TfT_02
1becc874ba Check if input is a water bottle first 2014-06-09 22:55:03 +02:00
TfT_02
b107a8dc7c Fire brew event after outputs have changed
and before experience is granted.
Part 2 of fixing #2041
2014-06-09 02:04:59 +02:00
TfT_02
37aebc1716 Calculate Alchemy XP based on potion stage
Adds #1926
2014-06-09 01:56:07 +02:00
TfT_02
836877ff93 Alchemy should fire BrewEvents
Fixes #2041
2014-06-09 01:43:50 +02:00
TfT_02
28a846e0cb Update changelog 2014-06-08 18:23:07 +02:00
TfT_02
0185a30ec9 Fix an IndexOutOfBoundsException: Index: 0
In SaveTimerTask.java

Fixes #2039
2014-06-08 18:21:13 +02:00
TfT_02
38e1947302 Remove PvpLogger checks
No longer needed when testing with Combat Tag v6.1.4, the NPCs have
metadata „NPC”.

Fixes #2017
2014-06-08 18:11:18 +02:00
riking
4fb4d6fc0c Save users asynchronously 2014-06-08 14:12:25 +02:00
TfT_02
6d719988bf Remove this check here, allows Salvage in Adv mode
We’re already checking if the players game mode isn’t CREATIVE, so we
can safely remove this check.

Fixes #2059
2014-06-03 12:23:42 +02:00
TfT_02
b1c1f0e21e Added missing Salvage permissions to plugin.yml 2014-05-25 23:45:20 +02:00
TfT_02
3f34cc7365 Actually fix maximumQuantity reading from config
Now we try to automatically detect the maximum quantity if possible and
fall back to the config if the user has set a value there.

Also fixed the feedback message which said „Minimum quantity” instead
of „Maximum quantity”
2014-05-25 23:20:19 +02:00
TfT_02
3c6c2837bd Check permission before sending anvil messages 2014-05-25 22:46:35 +02:00
TfT_02
4bcef76fd8 Let config key take priority here 2014-05-24 15:42:15 +02:00
TfT_02
2fd5d7aa81 Cleanup RepairConfig leftovers in SalvageConfig
Some copy/pasta I forgot to remove
2014-05-24 15:24:25 +02:00
TfT_02
5080c68dce Fix Maximum Quantity in Salvage configs 2014-05-24 15:23:50 +02:00
TfT_02
3403aef37d Don't display child skills on scoreboards
This fixes an issue where the scoreboard would not display properly
when using /mcstats or /inspect.

Fixes #2037
2014-05-23 17:03:02 +02:00
TfT_02
53a34c12d2 Add SALVAGE to MISC_SKILLS List 2014-05-23 14:23:05 +02:00
TfT_02
59417d6721 Add changelog entry for Salvage child skill
Closes #561
2014-05-19 16:59:28 +02:00
TfT_02
93d63dbca5 Minor cleanup of imports 2014-05-18 17:06:50 +02:00
TfT_02
4643cf1070 A whole bunch of more work to convert Salvage to a child skill 2014-05-18 17:04:39 +02:00
GJ
91bf54019e Convert Salvage to a child skill. 2014-05-18 17:04:38 +02:00
TfT_02
ead716ef0d Fix a NPE when tab completing with /ptp
Fixes #2013
2014-05-11 18:33:50 +02:00
TfT_02
8fec1af257 Fix a bunch of small formatting issues 2014-05-11 15:15:44 +02:00
Sean Porter
99248caba3 Redstone ore now throws events when it flips on or off.
Fixes issue #2021
2014-05-11 01:30:11 -07:00
TfT_02
af64bdf742 Added API to check if an entity is bleeding 2014-05-02 19:41:44 +02:00
TfT_02
66a4925371 Use getAllyName() here instead 2014-05-02 00:53:05 +02:00
TfT_02
8eb6acd60f Add option to prevent hopper transfers of bottles 2014-04-27 15:03:07 +02:00
TfT_02
ce6892f2e6 Update README.md 2014-04-24 16:00:02 +02:00
TfT_02
c14a4e9305 Fix /party teleport command
Why did we use getCommand("ptp").getExecutor() again?

Fixes #1995
2014-04-21 14:54:09 +02:00
TfT_02
5825eb1696 Make sure to shorten long ability and skill names
(cherry picked from commit 236ccd6ebdd0834f87b373794e1597ef36fb2ff6)
2014-04-21 14:09:52 +02:00
TfT_02
bfebbd0095 Fix formatting
(cherry picked from commit 4e36073e6e2dc3aeba087d605cef79fc4a8a9779)
2014-04-21 14:09:41 +02:00
GJ
b204507a82 Use strings instead of OfflinePlayers for scoreboards.
(cherry picked from commit 89b596591ec1974e0201395dc6e76353e4709572)
2014-04-21 14:09:09 +02:00
TfT_02
9f53426511 Added API to XP events to get XP gain reason 2014-04-18 22:32:32 +02:00
Sean Porter
03c2282c3f Fix the calculations for Iron Arm Style in the Unarmed command. 2014-04-18 02:16:35 -07:00
TfT_02
20092d55fd Fix bug where dodge would check the wrong player 2014-04-18 00:49:40 +02:00
TfT_02
69a2a5cfff Check if player has a mcMMOPlayer object
Fixes #1976
2014-04-12 17:06:14 +02:00
TfT_02
618cfad100 Prevent accidentally breaking regrown crops
Adds #828
2014-04-06 14:41:40 +02:00
TfT_02
56e625a9df Added option to open /mcstats after logging in
Added #1033
2014-04-06 13:27:38 +02:00
TfT_02
79a1ef5d3e Players need to be in a party to use /ptp
Fixes #1967
2014-04-06 12:43:42 +02:00
TfT_02
10dd7619bf Support MATERIAL|data format in treasures.yml
Allows users to use the same material type for multiple treasures in
treasures.yml

Fixes #1965
2014-04-05 18:31:01 +02:00
TfT_02
f9dfec5bd0 Check event.getBow() != null
Fixes #1933
2014-04-05 13:55:10 +02:00
TfT_02
a9488bc18b Vanished players no longer get hit by AoE effects
Fixes #1964
2014-04-05 13:12:20 +02:00
TfT_02
f0ee708710 Updater should not be running on the main thread
Fixes #1957
2014-04-05 12:10:02 +02:00
TfT_02
3390a31cc6 Move PlayerUpdateInventoryTask to runnables.player 2014-04-05 11:59:36 +02:00
t00thpick1
0b4b272223 Account for level 0 2014-04-01 14:58:24 -04:00
TfT_02
8d200ea653 Back to active development 2014-03-29 18:28:26 +01:00
TfT_02
eb359c5595 Update pom.xml and changelog.txt for 1.5.00 release 2014-03-29 17:52:08 +01:00
TfT_02
e1b8088c17 Improve holiday manager with 1.7 changes 2014-03-29 17:50:29 +01:00
TfT_02
70a1eea231 Nerf Herbalism XP from Tall Grass 2014-03-29 17:12:55 +01:00
TfT_02
c744974192 Added option to config.yml to override vanilla Minecraft treasures 2014-03-29 17:12:55 +01:00
TfT_02
faa11a87a9 Removed "Treasure found!" message
Because when treasures are found in vanilla Minecraft, there isn’t a
message either
2014-03-29 17:12:55 +01:00
TfT_02
91da5c4ab1 Add option to drop extra fish
Allows enabling of old fishing mechanic where fish was always caught,
even when a treasure was found
2014-03-29 17:12:54 +01:00
GJ
da5e770e06 Add Podzol & Red Sand to Excavation 2014-03-29 17:12:54 +01:00
TfT_02
09557e378b Update to the new ProjectileSource API 2014-03-29 17:12:54 +01:00
TfT_02
72d26fed0f Update version number to 1.5.00 2014-03-29 17:12:54 +01:00
TfT_02
225de799e8 Increase TreasureHunter chances for Luck enchantment
When the player is using a fishing rod with the ”Luck of the Sea”
enchantment, the drop chances will increase with 1% for each level of
the enchantment.
2014-03-29 17:12:36 +01:00
TfT_02
334c44760f Workaround for ClassCastException: MaterialData cannot be cast to Tree 2014-03-29 17:12:36 +01:00
TfT_02
ac7fc1020d Use tree species for Woodcutting double drops in config.yml
Oak is now Generic, and Spruce is now Redwood.
2014-03-29 17:12:36 +01:00
riking
461871327b Include new 1.7 biomes in fishing biome XP boost and Ice Fishing check 2014-03-29 17:12:36 +01:00
GJ
60ddd799de Update mcMMO for Minecraft 1.7.2 2014-03-29 17:12:35 +01:00
GJ
80571fbe8f Remove deprecated permission nodes 2014-03-29 17:12:35 +01:00
83 changed files with 1334 additions and 728 deletions

View File

@@ -7,7 +7,7 @@ Key:
! Change
- Removal
Version 1.4.09-dev
Version 1.5.01-dev
+ Added new child skill; Salvage
+ Added new feature to Herbalism. Instantly-regrown crops are protected from being broken for 1 second
+ Added option to config.yml to show the /mcstats scoreboard automatically after logging in
@@ -15,17 +15,41 @@ Version 1.4.09-dev
+ Added support for `MATERIAL|data` format in treasures.yml
+ Added API to experience events to get XP gain reason
+ Added API to check if an entity is bleeding
+ Added options to tools.yml and armor.yml config files to set a pretty repair material name
+ Added full support for repairables in tools.yml and armor.yml config files
= Fixed bug where pistons would mess with the block tracking
= Fixed bug where the Updater was running on the main thread.
= Fixed bug when players would use /ptp without being in a party
= Fixed bug where player didn't have a mcMMOPlayer object in AsyncPlayerChatEvent
= Fixed bug where dodge would check the wrong player skill level
= Fixed bug which causes /party teleport to stop working
= Fixed bug where SaveTimerTask would produce an IndexOutOfBoundsException
= Fixed bug where Alchemy would not fire BrewEvents
= Fixed bug with setting custom names and lore in treasures config
= Fixed bug which would cause a NullPointerException with getFlowerAndGrassXp()
! Changed SecondaryAbilityEvent to implement Cancellable and it now gets fired for damage related secondary abilities
! Changed the way mcMMO handles bonus damage, updated for the new damage event API
! Changed player data saving. Save tasks are now asynchronous
! Vanished players no longer get hit by AoE effects
! Changed Alchemy config option 'Prevent_Hopper_Transfer' renamed to 'Prevent_Hopper_Transfer_Ingredients'
! Changed Alchemy XP distribution. XP is granted based on the stage of the potion.
! Updated for new getOnlinePlayers() behavior
- Removed salvage ability from Repair, salvage has it's own (child) skill now
Version 1.5.00
+ Added Podzol & Red Sand to Excavation
+ Added Hardened Clay, Stained Clay, and Packed Ice to Mining blocks
+ Added Acacia and Dark Oak to Woodcutting blocks
+ Added Salmon, Clownfish, and Pufferfish to Fishing XP
+ Added new flowers and grasses to Herbalism XP
+ Added option to config.yml which allows players to always catch fish, even when a treasure is found
+ Added option to config.yml to override vanilla Minecraft treasures
! Fishing XP now depends on the type of fish.
! Woodcutting XP in experience.yml and Woodcutting double drops in config.yml now use the tree species names. Oak is now Generic, and Spruce is now Redwood.
! Red_Rose was replaced by Poppy, and so the key in experience.yml has been updated accordingly.
- Removed deprecated permission nodes
- Removed "Treasure found!" message
Version 1.4.08
+ Added a new skill; Alchemy. Special thanks to EasyMFnE for creating this!
+ Added SecondaryAbilityType enum, and new SecondaryAbilityWeightedActivationCheckEvent, fired when a secondary ability checkes its activation chances

View File

@@ -2,7 +2,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.gmail.nossr50.mcMMO</groupId>
<artifactId>mcMMO</artifactId>
<version>1.4.09-SNAPSHOT</version>
<version>1.5.01-SNAPSHOT</version>
<name>mcMMO</name>
<url>https://github.com/mcMMO-Dev/mcMMO</url>
<issueManagement>
@@ -121,7 +121,7 @@
<dependency>
<groupId>org.bukkit</groupId>
<artifactId>bukkit</artifactId>
<version>1.6.4-R2.0</version>
<version>LATEST</version>
<type>jar</type>
<scope>compile</scope>
</dependency>

View File

@@ -65,7 +65,7 @@ public class ArcheryCommand extends SkillCommand {
}
if (canDaze) {
messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Archery.Effect.2"), LocaleLoader.getString("Archery.Effect.3", Archery.dazeModifier)));
messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Archery.Effect.2"), LocaleLoader.getString("Archery.Effect.3", Archery.dazeBonusDamage)));
}
if (canRetrieve) {

View File

@@ -4,7 +4,6 @@ import java.util.ArrayList;
import java.util.List;
import org.bukkit.Location;
import org.bukkit.block.Biome;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
@@ -98,9 +97,7 @@ public class FishingCommand extends SkillCommand {
location = player.getLocation();
}
Biome biome = location.getBlock().getBiome();
if (biome == Biome.RIVER || biome == Biome.OCEAN) {
if (Fishing.masterAnglerBiomes.contains(location.getBlock().getBiome())) {
rawBiteChance = rawBiteChance * AdvancedConfig.getInstance().getMasterAnglerBiomeModifier();
}

View File

@@ -134,7 +134,7 @@ public class AdvancedConfig extends AutoUpdateConfigLoader {
reason.add("Skills.Acrobatics.Daze.MaxBonusLevel should be at least 1!");
}
if (getDazeModifier() < 0) {
if (getDazeBonusDamage() < 0) {
reason.add("Skills.Acrobatics.Daze.BonusDamage should be at least 0!");
}
@@ -714,7 +714,7 @@ public class AdvancedConfig extends AutoUpdateConfigLoader {
public double getSkillShotBonusMax() { return config.getDouble("Skills.Archery.SkillShot.MaxBonus", 2.0D); }
public double getSkillShotDamageMax() { return config.getDouble("Skills.Archery.SkillShot.MaxDamage", 9.0D); }
public double getDazeModifier() { return config.getDouble("Skills.Archery.Daze.BonusDamage", 4.0D); }
public double getDazeBonusDamage() { return config.getDouble("Skills.Archery.Daze.BonusDamage", 4.0D); }
public double getForceMultiplier() { return config.getDouble("Skills.Archery.ForceMultiplier", 2.0D); }

View File

@@ -5,6 +5,7 @@ import java.util.List;
import java.util.Set;
import org.bukkit.Material;
import org.bukkit.TreeSpecies;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.entity.EntityType;
@@ -236,7 +237,6 @@ public class Config extends AutoUpdateConfigLoader {
public boolean getStatsTrackingEnabled() { return config.getBoolean("General.Stats_Tracking", true); }
public boolean getUpdateCheckEnabled() { return config.getBoolean("General.Update_Check", true); }
public boolean getPreferBeta() { return config.getBoolean("General.Prefer_Beta", false); }
public boolean getEventCallbackEnabled() { return config.getBoolean("General.Event_Callback", true); }
public boolean getVerboseLoggingEnabled() { return config.getBoolean("General.Verbose_Logging", false); }
public String getPartyChatPrefix() { return config.getString("Commands.partychat.Chat_Prefix_Format", "[[GREEN]]([[WHITE]]{0}[[GREEN]])"); }
@@ -452,6 +452,7 @@ public class Config extends AutoUpdateConfigLoader {
/* Fishing */
public boolean getFishingDropsEnabled() { return config.getBoolean("Skills.Fishing.Drops_Enabled", true); }
public boolean getFishingOverrideTreasures() { return config.getBoolean("Skills.Fishing.Override_Vanilla_Treasures", true); }
public boolean getFishingExtraFish() { return config.getBoolean("Skills.Fishing.Extra_Fish", true); }
/* Mining */
@@ -481,10 +482,7 @@ public class Config extends AutoUpdateConfigLoader {
public double getTamingCOTWRange() { return config.getDouble("Skills.Taming.Call_Of_The_Wild.Range", 40.0D); }
/* Woodcutting */
public boolean getOakDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Woodcutting.Oak", true); }
public boolean getBirchDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Woodcutting.Birch", true); }
public boolean getSpruceDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Woodcutting.Spruce", true); }
public boolean getJungleDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Woodcutting.Jungle", true); }
public boolean getWoodcuttingDoubleDropsEnabled(TreeSpecies species) { return config.getBoolean("Double_Drops.Woodcutting." + StringUtils.getPrettyTreeSpeciesString(species).replace(" ", "_")); }
public boolean getTreeFellerSoundsEnabled() { return config.getBoolean("Skills.Woodcutting.Tree_Feller_Sounds", true); }
/* AFK Leveling */

View File

@@ -3,13 +3,18 @@ package com.gmail.nossr50.config.experience;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.GrassSpecies;
import org.bukkit.Material;
import org.bukkit.TreeSpecies;
import org.bukkit.entity.EntityType;
import org.bukkit.material.LongGrass;
import org.bukkit.material.MaterialData;
import com.gmail.nossr50.config.AutoUpdateConfigLoader;
import com.gmail.nossr50.datatypes.experience.FormulaType;
import com.gmail.nossr50.datatypes.skills.MaterialType;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.datatypes.skills.alchemy.PotionStage;
import com.gmail.nossr50.util.StringUtils;
public class ExperienceConfig extends AutoUpdateConfigLoader {
@@ -77,8 +82,10 @@ public class ExperienceConfig extends AutoUpdateConfigLoader {
*/
/* Alchemy */
if (getPotionXP() <= 0) {
reason.add("Experience.Alchemy.Potion should be greater than 0!");
for (PotionStage potionStage : PotionStage.values()) {
if (getPotionXP(potionStage) < 0) {
reason.add("Experience.Alchemy.Potion_Stage_" + potionStage.toNumerical() + " should be at least 0!");
}
}
/* Combat XP Multipliers */
@@ -103,9 +110,7 @@ public class ExperienceConfig extends AutoUpdateConfigLoader {
}
/* Fishing */
if (getFishingBaseXP() <= 0) {
reason.add("Experience.Fishing.Base should be greater than 0!");
}
// TODO: Add validation for each fish type once enum is available.
if (getFishingShakeXP() <= 0) {
reason.add("Experience.Fishing.Shake should be greater than 0!");
@@ -126,20 +131,12 @@ public class ExperienceConfig extends AutoUpdateConfigLoader {
}
/* Woodcutting */
if (getWoodcuttingXPOak() <= 0) {
reason.add("Experience.Woodcutting.Oak should be greater than 0!");
}
for (TreeSpecies species : TreeSpecies.values()) {
String key = "Experience.Woodcutting." + StringUtils.getPrettyTreeSpeciesString(species).replace(" ", "_");
if (getWoodcuttingXPBirch() <= 0) {
reason.add("Experience.Woodcutting.Birch should be greater than 0!");
}
if (getWoodcuttingXPSpruce() <= 0) {
reason.add("Experience.Woodcutting.Spruce should be greater than 0!");
}
if (getWoodcuttingXPJungle() <= 0) {
reason.add("Experience.Woodcutting.Jungle should be greater than 0!");
if (config.getInt(key) <= 0) {
reason.add(key + " should be greater than 0!");
}
}
if (getWoodcuttingXPHugeBrownMushroom() <= 0) {
@@ -208,12 +205,116 @@ public class ExperienceConfig extends AutoUpdateConfigLoader {
public double getFeatherFallXPModifier() { return config.getDouble("Experience.Acrobatics.FeatherFall_Multiplier", 2.0); }
/* Alchemy */
public double getPotionXP() { return config.getDouble("Experience.Alchemy.Potion", 150D); }
public double getPotionXP(PotionStage stage) { return config.getDouble("Experience.Alchemy.Potion_Stage_" + stage.toNumerical(), 10D); }
/* Fishing */
public int getFishingBaseXP() { return config.getInt("Experience.Fishing.Base", 800); }
public int getFishXp(MaterialData data) {
switch (data.getData()) {
case 0x0:
return config.getInt("Experience.Fishing.Raw_Fish", 800);
case 0x1:
return config.getInt("Experience.Fishing.Raw_Salmon", 800);
case 0x2:
return config.getInt("Experience.Fishing.Clownfish", 800);
case 0x3:
return config.getInt("Experience.Fishing.Pufferfish", 800);
default:
return 0;
}
}
public int getFishingShakeXP() { return config.getInt("Experience.Fishing.Shake", 50); }
/* Herbalism */
public int getFlowerAndGrassXp(MaterialData data) {
Material type = data.getItemType();
if (type == Material.RED_ROSE) {
switch (data.getData()) {
case 0x0:
return config.getInt("Experience.Herbalism.Poppy", 100);
case 0x1:
return config.getInt("Experience.Herbalism.Blue_Orchid", 150);
case 0x2:
return config.getInt("Experience.Herbalism.Allium", 300);
case 0x3:
return config.getInt("Experience.Herbalism.Azure_Bluet", 150);
case 0x4:
return config.getInt("Experience.Herbalism.Red_Tulip", 150);
case 0x5:
return config.getInt("Experience.Herbalism.Orange_Tulip", 150);
case 0x6:
return config.getInt("Experience.Herbalism.White_Tulip", 150);
case 0x7:
return config.getInt("Experience.Herbalism.Pink_Tulip", 150);
case 0x8:
return config.getInt("Experience.Herbalism.Oxeye_Daisy", 150);
default:
return 0;
}
}
else if (type == Material.LONG_GRASS) {
GrassSpecies species = ((LongGrass) data).getSpecies();
if (species == null) {
return 0;
}
switch (species) {
case DEAD:
return config.getInt("Experience.Herbalism.Dead_Bush", 30);
case FERN_LIKE:
return config.getInt("Experience.Herbalism.Small_Fern", 10);
case NORMAL:
return config.getInt("Experience.Herbalism.Small_Grass", 10);
default:
return 0;
}
}
else if (type == Material.DOUBLE_PLANT) {
switch (data.getData()) {
case 0x0:
return config.getInt("Experience.Herbalism.Sunflower", 50);
case 0x1:
return config.getInt("Experience.Herbalism.Lilac", 50);
case 0x2:
return config.getInt("Experience.Herbalism.Tall_Grass", 50);
case 0x3:
return config.getInt("Experience.Herbalism.Tall_Fern", 50);
case 0x4:
return config.getInt("Experience.Herbalism.Rose_Bush", 50);
case 0x5:
return config.getInt("Experience.Herbalism.Peony", 50);
default:
return 0;
}
}
return 0;
}
/* Repair */
public double getRepairXPBase() { return config.getDouble("Experience.Repair.Base", 1000.0); }
public double getRepairXP(MaterialType repairMaterialType) { return config.getDouble("Experience.Repair." + StringUtils.getCapitalized(repairMaterialType.toString())); }
@@ -224,10 +325,7 @@ public class ExperienceConfig extends AutoUpdateConfigLoader {
public int getTamingXPOcelot() { return config.getInt("Experience.Taming.Animal_Taming.Ocelot", 500); }
/* Woodcutting */
public int getWoodcuttingXPOak() { return config.getInt("Experience.Woodcutting.Oak", 70); }
public int getWoodcuttingXPBirch() { return config.getInt("Experience.Woodcutting.Birch", 90); }
public int getWoodcuttingXPSpruce() { return config.getInt("Experience.Woodcutting.Spruce", 80); }
public int getWoodcuttingXPJungle() { return config.getInt("Experience.Woodcutting.Jungle", 100); }
public int getWoodcuttingTreeXP(TreeSpecies species) { return config.getInt("Experience.Woodcutting." + StringUtils.getPrettyTreeSpeciesString(species).replace(" ", "_")); }
public int getWoodcuttingXPHugeBrownMushroom() { return config.getInt("Experience.Woodcutting.Huge_Mushroom_Brown", 70); }
public int getWoodcuttingXPHugeRedMushroom() { return config.getInt("Experience.Woodcutting.Huge_Mushroom_Red", 70); }
}

View File

@@ -85,13 +85,17 @@ public class CustomArmorConfig extends ConfigLoader {
repairQuantity = config.getInt(armorType + "." + armorName + ".Repair_Material_Data_Quantity", 2);
}
String repairItemName = config.getString(armorType + "." + armorName + ".Repair_Material_Pretty_Name");
int repairMinimumLevel = config.getInt(armorType + "." + armorName + ".Repair_MinimumLevel", 0);
double repairXpMultiplier = config.getDouble(armorType + "." + armorName + ".Repair_XpMultiplier", 1);
short durability = armorMaterial.getMaxDurability();
if (durability == 0) {
durability = (short) config.getInt(armorType + "." + armorName + ".Durability", 70);
}
repairables.add(RepairableFactory.getRepairable(armorMaterial, repairMaterial, repairData, 0, repairQuantity, durability, ItemType.ARMOR, MaterialType.OTHER, 1.0));
repairables.add(RepairableFactory.getRepairable(armorMaterial, repairMaterial, repairData, repairItemName, repairMinimumLevel, repairQuantity, durability, ItemType.ARMOR, MaterialType.OTHER, repairXpMultiplier));
}
materialList.add(armorMaterial);

View File

@@ -68,61 +68,39 @@ public class CustomBlockConfig extends ConfigLoader {
Material blockMaterial = Material.matchMaterial(blockInfo[0]);
if (blockMaterial == null) {
plugin.getLogger().warning("Invalid material name. [" + blockInfo[0] + "] This item will be skipped. - " + blockName);
plugin.getLogger().warning("Invalid material name. This item will be skipped. - " + blockInfo[0]);
continue;
}
if (blockInfo.length == 2) {
String[] dataInfo = blockInfo[1].split("[-]");
byte blockData = (blockInfo.length == 2) ? Byte.valueOf(blockInfo[1]) : 0;
MaterialData blockMaterialData = new MaterialData(blockMaterial, blockData);
if (dataInfo.length == 2) {
byte startData = Byte.valueOf(dataInfo[0]);
byte endData = Byte.valueOf(dataInfo[1]);
System.out.println(blockName + " Data range; [" + startData + " - " + endData + "]");
if (blockList != null) {
blockList.add(blockMaterialData);
}
for (byte blockData = startData; blockData <= endData; blockData++) {
MaterialData blockMaterialData = new MaterialData(blockMaterial, blockData);
loadBlock(skillType, blockList, blockName, blockMaterialData);
}
if (skillType.equals("Ability_Blocks")) {
continue;
}
return;
int xp = config.getInt(skillType + "." + blockName + ".XP_Gain");
int smeltingXp = 0;
if (skillType.equals("Mining") && config.getBoolean(skillType + "." + blockName + ".Is_Ore")) {
customOres.add(blockMaterialData);
smeltingXp = config.getInt(skillType + "." + blockName + ".Smelting_XP_Gain", xp / 10);
}
else if (skillType.equals("Woodcutting")) {
if (config.getBoolean(skillType + "." + blockName + ".Is_Log")) {
customLogs.add(blockMaterialData);
}
else {
customLeaves.add(blockMaterialData);
xp = 0; // Leaves don't grant XP
}
}
byte blockData = (blockInfo.length == 2) ? Byte.valueOf(blockInfo[1]) : 0;
MaterialData blockMaterialData = new MaterialData(blockMaterial, blockData);
loadBlock(skillType, blockList, blockName, blockMaterialData);
customBlockMap.put(blockMaterialData, new CustomBlock(xp, config.getBoolean(skillType + "." + blockName + ".Double_Drops_Enabled"), smeltingXp));
}
}
private void loadBlock(String skillType, List<MaterialData> blockList, String blockName, MaterialData blockMaterialData) {
System.out.println("Loading block: " + blockMaterialData.getItemType() + " " + blockMaterialData.getData());
if (blockList != null) {
blockList.add(blockMaterialData);
}
if (skillType.equals("Ability_Blocks")) {
return;
}
int xp = config.getInt(skillType + "." + blockName + ".XP_Gain");
int smeltingXp = 0;
if (skillType.equals("Mining") && config.getBoolean(skillType + "." + blockName + ".Is_Ore")) {
customOres.add(blockMaterialData);
smeltingXp = config.getInt(skillType + "." + blockName + ".Smelting_XP_Gain", xp / 10);
}
else if (skillType.equals("Woodcutting")) {
if (config.getBoolean(skillType + "." + blockName + ".Is_Log")) {
customLogs.add(blockMaterialData);
}
else {
customLeaves.add(blockMaterialData);
xp = 0; // Leaves don't grant XP
}
}
customBlockMap.put(blockMaterialData, new CustomBlock(xp, config.getBoolean(skillType + "." + blockName + ".Double_Drops_Enabled"), smeltingXp));
}
}

View File

@@ -93,13 +93,17 @@ public class CustomToolConfig extends ConfigLoader {
repairQuantity = config.getInt(toolType + "." + toolName + ".Repair_Material_Data_Quantity", 2);
}
String repairItemName = config.getString(toolType + "." + toolName + ".Repair_Material_Pretty_Name");
int repairMinimumLevel = config.getInt(toolType + "." + toolName + ".Repair_MinimumLevel", 0);
double repairXpMultiplier = config.getDouble(toolType + "." + toolName + ".Repair_XpMultiplier", 1);
short durability = toolMaterial.getMaxDurability();
if (durability == 0) {
durability = (short) config.getInt(toolType + "." + toolName + ".Durability", 60);
}
repairables.add(RepairableFactory.getRepairable(toolMaterial, repairMaterial, repairData, 0, repairQuantity, durability, ItemType.TOOL, MaterialType.OTHER, 1.0));
repairables.add(RepairableFactory.getRepairable(toolMaterial, repairMaterial, repairData, repairItemName, repairMinimumLevel, repairQuantity, durability, ItemType.TOOL, MaterialType.OTHER, repairXpMultiplier));
}
double multiplier = config.getDouble(toolType + "." + toolName + ".XP_Modifier", 1.0);

View File

@@ -35,6 +35,8 @@ public class TreasureConfig extends ConfigLoader {
public List<ExcavationTreasure> excavationFromMycel = new ArrayList<ExcavationTreasure>();
public List<ExcavationTreasure> excavationFromSoulSand = new ArrayList<ExcavationTreasure>();
public List<ExcavationTreasure> excavationFromSnow = new ArrayList<ExcavationTreasure>();
public List<ExcavationTreasure> excavationFromRedSand = new ArrayList<ExcavationTreasure>();
public List<ExcavationTreasure> excavationFromPodzol = new ArrayList<ExcavationTreasure>();
public List<HylianTreasure> hylianFromBushes = new ArrayList<HylianTreasure>();
public List<HylianTreasure> hylianFromFlowers = new ArrayList<HylianTreasure>();
@@ -257,13 +259,13 @@ public class TreasureConfig extends ConfigLoader {
if (config.contains(type + "." + treasureName + ".Custom_Name")) {
ItemMeta itemMeta = item.getItemMeta();
itemMeta.setDisplayName(config.getString(type + "." + treasureName + "Custom_Name"));
itemMeta.setDisplayName(config.getString(type + "." + treasureName + ".Custom_Name"));
item.setItemMeta(itemMeta);
}
if (config.contains(type + "." + treasureName + ".Lore")) {
ItemMeta itemMeta = item.getItemMeta();
itemMeta.setLore(config.getStringList(type + "." + treasureName + "Custom_Name"));
itemMeta.setLore(config.getStringList(type + "." + treasureName + ".Lore"));
item.setItemMeta(itemMeta);
}
}
@@ -374,6 +376,14 @@ public class TreasureConfig extends ConfigLoader {
if (dropList.contains("Snow")) {
excavationFromSnow.add(excavationTreasure);
}
if (dropList.contains("Red_Sand")) {
excavationFromRedSand.add(excavationTreasure);
}
if (dropList.contains("Podzol")) {
excavationFromPodzol.add(excavationTreasure);
}
}
else if (isHylian) {
HylianTreasure hylianTreasure = new HylianTreasure(item, xp, dropChance, dropLevel);

View File

@@ -13,6 +13,8 @@ import java.util.List;
import java.util.Map;
import java.util.Properties;
import org.bukkit.Bukkit;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.MobHealthbarType;
@@ -29,7 +31,8 @@ import com.gmail.nossr50.util.Misc;
public final class SQLDatabaseManager implements DatabaseManager {
private String connectionString;
private String tablePrefix = Config.getInstance().getMySQLTablePrefix();
private Connection connection = null;
private Connection primaryConnection = null;
private Connection secondaryConnection = null;
// Scale waiting time by this much per failed attempt
private final double SCALING_FACTOR = 40.0;
@@ -199,7 +202,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
PreparedStatement statement = null;
try {
statement = connection.prepareStatement("SELECT " + query + ", user, NOW() FROM " + tablePrefix + "users JOIN " + tablePrefix + "skills ON (user_id = id) WHERE " + query + " > 0 ORDER BY " + query + " DESC, user LIMIT ?, ?");
statement = getConnection().prepareStatement("SELECT " + query + ", user, NOW() FROM " + tablePrefix + "users JOIN " + tablePrefix + "skills ON (user_id = id) WHERE " + query + " > 0 ORDER BY " + query + " DESC, user LIMIT ?, ?");
statement.setInt(1, (pageNumber * statsPerPage) - statsPerPage);
statement.setInt(2, statsPerPage);
resultSet = statement.executeQuery();
@@ -245,7 +248,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
"AND " + skillName + " > (SELECT " + skillName + " FROM " + tablePrefix + "users JOIN " + tablePrefix + "skills ON user_id = id " +
"WHERE user = ?)";
PreparedStatement statement = connection.prepareStatement(sql);
PreparedStatement statement = getConnection().prepareStatement(sql);
statement.setString(1, playerName);
resultSet = statement.executeQuery();
@@ -259,7 +262,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
statement.close();
statement = connection.prepareStatement(sql);
statement = getConnection().prepareStatement(sql);
resultSet = statement.executeQuery();
while (resultSet.next()) {
@@ -278,7 +281,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
"(SELECT taming+mining+woodcutting+repair+unarmed+herbalism+excavation+archery+swords+axes+acrobatics+fishing+alchemy " +
"FROM " + tablePrefix + "users JOIN " + tablePrefix + "skills ON user_id = id WHERE user = ?)";
PreparedStatement statement = connection.prepareStatement(sql);
PreparedStatement statement = getConnection().prepareStatement(sql);
statement.setString(1, playerName);
resultSet = statement.executeQuery();
@@ -295,7 +298,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
"(SELECT taming+mining+woodcutting+repair+unarmed+herbalism+excavation+archery+swords+axes+acrobatics+fishing+alchemy " +
"FROM " + tablePrefix + "users JOIN " + tablePrefix + "skills ON user_id = id WHERE user = ?) ORDER BY user";
statement = connection.prepareStatement(sql);
statement = getConnection().prepareStatement(sql);
statement.setString(1, playerName);
resultSet = statement.executeQuery();
@@ -324,7 +327,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
PreparedStatement statement = null;
try {
statement = connection.prepareStatement("INSERT INTO " + tablePrefix + "users (user, lastlogin) VALUES (?, ?)", Statement.RETURN_GENERATED_KEYS);
statement = getConnection().prepareStatement("INSERT INTO " + tablePrefix + "users (user, lastlogin) VALUES (?, ?)", Statement.RETURN_GENERATED_KEYS);
statement.setString(1, playerName);
statement.setLong(2, System.currentTimeMillis() / Misc.TIME_CONVERSION_FACTOR);
statement.execute();
@@ -359,7 +362,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
PreparedStatement statement = null;
try {
statement = connection.prepareStatement(
statement = getConnection().prepareStatement(
"SELECT "
+ "s.taming, s.mining, s.repair, s.woodcutting, s.unarmed, s.herbalism, s.excavation, s.archery, s.swords, s.axes, s.acrobatics, s.fishing, s.alchemy, "
+ "e.taming, e.mining, e.repair, e.woodcutting, e.unarmed, e.herbalism, e.excavation, e.archery, e.swords, e.axes, e.acrobatics, e.fishing, e.alchemy, "
@@ -435,7 +438,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
PreparedStatement statement = null;
try {
statement = connection.prepareStatement(
statement = getConnection().prepareStatement(
"SELECT "
+ "s.taming, s.mining, s.repair, s.woodcutting, s.unarmed, s.herbalism, s.excavation, s.archery, s.swords, s.axes, s.acrobatics, s.fishing, s.alchemy, "
+ "e.taming, e.mining, e.repair, e.woodcutting, e.unarmed, e.herbalism, e.excavation, e.archery, e.swords, e.axes, e.acrobatics, e.fishing, e.alchemy, "
@@ -500,6 +503,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
public boolean checkConnected() {
boolean isClosed = true;
boolean isValid = false;
Connection connection = getConnection();
boolean exists = (connection != null);
// If we're waiting for server to recover then leave early
@@ -547,7 +551,11 @@ public final class SQLDatabaseManager implements DatabaseManager {
}
// Try to connect again
connect();
if (Bukkit.isPrimaryThread()) {
connectPrimary();
} else {
connectSecondary();
}
// Leave if connection is good
try {
@@ -572,13 +580,47 @@ public final class SQLDatabaseManager implements DatabaseManager {
return false;
}
private void connectSecondary() {
connectionString = "jdbc:mysql://" + Config.getInstance().getMySQLServerName() + ":" + Config.getInstance().getMySQLServerPort() + "/" + Config.getInstance().getMySQLDatabaseName();
try {
mcMMO.p.getLogger().info("Attempting connection to MySQL...");
// Force driver to load if not yet loaded
Class.forName("com.mysql.jdbc.Driver");
Properties connectionProperties = new Properties();
connectionProperties.put("user", Config.getInstance().getMySQLUserName());
connectionProperties.put("password", Config.getInstance().getMySQLUserPassword());
connectionProperties.put("autoReconnect", "false");
connectionProperties.put("maxReconnects", "0");
secondaryConnection = DriverManager.getConnection(connectionString, connectionProperties);
mcMMO.p.getLogger().info("Connection to MySQL was a success!");
}
catch (SQLException ex) {
secondaryConnection = null;
if (reconnectAttempt == 0 || reconnectAttempt >= 11) {
mcMMO.p.getLogger().severe("Connection to MySQL failed!");
printErrors(ex);
}
}
catch (ClassNotFoundException ex) {
secondaryConnection = null;
if (reconnectAttempt == 0 || reconnectAttempt >= 11) {
mcMMO.p.getLogger().severe("MySQL database driver not found!");
}
}
}
public List<String> getStoredUsers() {
ArrayList<String> users = new ArrayList<String>();
if (checkConnected()) {
Statement stmt = null;
try {
stmt = connection.createStatement();
stmt = getConnection().createStatement();
ResultSet result = stmt.executeQuery("SELECT user FROM " + tablePrefix + "users");
while (result.next()) {
users.add(result.getString("user"));
@@ -603,10 +645,18 @@ public final class SQLDatabaseManager implements DatabaseManager {
return users;
}
private Connection getConnection() {
if (Bukkit.isPrimaryThread()) {
return primaryConnection;
} else {
return secondaryConnection;
}
}
/**
* Attempt to connect to the mySQL database.
*/
private void connect() {
private void connectPrimary() {
connectionString = "jdbc:mysql://" + Config.getInstance().getMySQLServerName() + ":" + Config.getInstance().getMySQLServerPort() + "/" + Config.getInstance().getMySQLDatabaseName();
try {
@@ -619,12 +669,12 @@ public final class SQLDatabaseManager implements DatabaseManager {
connectionProperties.put("password", Config.getInstance().getMySQLUserPassword());
connectionProperties.put("autoReconnect", "false");
connectionProperties.put("maxReconnects", "0");
connection = DriverManager.getConnection(connectionString, connectionProperties);
primaryConnection = DriverManager.getConnection(connectionString, connectionProperties);
mcMMO.p.getLogger().info("Connection to MySQL was a success!");
}
catch (SQLException ex) {
connection = null;
primaryConnection = null;
if (reconnectAttempt == 0 || reconnectAttempt >= 11) {
mcMMO.p.getLogger().severe("Connection to MySQL failed!");
@@ -632,7 +682,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
}
}
catch (ClassNotFoundException ex) {
connection = null;
primaryConnection = null;
if (reconnectAttempt == 0 || reconnectAttempt >= 11) {
mcMMO.p.getLogger().severe("MySQL database driver not found!");
@@ -806,7 +856,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
return;
}
statement = connection.prepareStatement(sql);
statement = getConnection().prepareStatement(sql);
resultSet = statement.executeQuery();
while (resultSet.next()) {
@@ -866,7 +916,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
PreparedStatement statement = null;
try {
statement = connection.prepareStatement(sql);
statement = getConnection().prepareStatement(sql);
statement.executeUpdate();
return true;
}
@@ -901,7 +951,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
PreparedStatement statement = null;
try {
statement = connection.prepareStatement(sql);
statement = getConnection().prepareStatement(sql);
rows = statement.executeUpdate();
}
catch (SQLException ex) {
@@ -936,7 +986,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
ResultSet resultSet;
try {
statement = connection.prepareStatement(sql);
statement = getConnection().prepareStatement(sql);
resultSet = statement.executeQuery();
while (resultSet.next()) {
@@ -1008,22 +1058,22 @@ public final class SQLDatabaseManager implements DatabaseManager {
PreparedStatement statement = null;
try {
statement = connection.prepareStatement("INSERT IGNORE INTO " + tablePrefix + "experience (user_id) VALUES (?)");
statement = getConnection().prepareStatement("INSERT IGNORE INTO " + tablePrefix + "experience (user_id) VALUES (?)");
statement.setInt(1, id);
statement.execute();
statement.close();
statement = connection.prepareStatement("INSERT IGNORE INTO " + tablePrefix + "skills (user_id) VALUES (?)");
statement = getConnection().prepareStatement("INSERT IGNORE INTO " + tablePrefix + "skills (user_id) VALUES (?)");
statement.setInt(1, id);
statement.execute();
statement.close();
statement = connection.prepareStatement("INSERT IGNORE INTO " + tablePrefix + "cooldowns (user_id) VALUES (?)");
statement = getConnection().prepareStatement("INSERT IGNORE INTO " + tablePrefix + "cooldowns (user_id) VALUES (?)");
statement.setInt(1, id);
statement.execute();
statement.close();
statement = connection.prepareStatement("INSERT IGNORE INTO " + tablePrefix + "huds (user_id, mobhealthbar) VALUES (? ,'" + Config.getInstance().getMobHealthbarDefault().name() + "')");
statement = getConnection().prepareStatement("INSERT IGNORE INTO " + tablePrefix + "huds (user_id, mobhealthbar) VALUES (? ,'" + Config.getInstance().getMobHealthbarDefault().name() + "')");
statement.setInt(1, id);
statement.execute();
statement.close();
@@ -1053,7 +1103,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
PreparedStatement statement = null;
try {
statement = connection.prepareStatement(sql);
statement = getConnection().prepareStatement(sql);
int i = 1;
for (int arg : args) {
@@ -1083,7 +1133,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
PreparedStatement statement = null;
try {
statement = connection.prepareStatement(sql);
statement = getConnection().prepareStatement(sql);
int i = 1;
for (long arg : args) {
@@ -1120,7 +1170,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
int id = -1;
try {
PreparedStatement statement = connection.prepareStatement("SELECT id FROM " + tablePrefix + "users WHERE user = ?");
PreparedStatement statement = getConnection().prepareStatement("SELECT id FROM " + tablePrefix + "users WHERE user = ?");
statement.setString(1, playerName);
id = readInt(statement);
}
@@ -1135,7 +1185,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
PreparedStatement statement = null;
try {
statement = connection.prepareStatement("UPDATE " + tablePrefix + "users SET lastlogin = ? WHERE id = ?");
statement = getConnection().prepareStatement("UPDATE " + tablePrefix + "users SET lastlogin = ? WHERE id = ?");
statement.setLong(1, login);
statement.setInt(2, id);
statement.execute();
@@ -1161,7 +1211,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
PreparedStatement statement = null;
try {
statement = connection.prepareStatement("UPDATE " + tablePrefix + "huds SET mobhealthbar = ? WHERE user_id = ?");
statement = getConnection().prepareStatement("UPDATE " + tablePrefix + "huds SET mobhealthbar = ? WHERE user_id = ?");
statement.setString(1, mobHealthBar);
statement.setInt(2, userId);
statement.execute();

View File

@@ -0,0 +1,74 @@
package com.gmail.nossr50.datatypes.skills.alchemy;
import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;
import org.bukkit.potion.Potion;
public enum PotionStage {
FIVE(5),
FOUR(4),
THREE(3),
TWO(2),
ONE(1);
int numerical;
private PotionStage(int numerical) {
this.numerical = numerical;
}
public int toNumerical() {
return numerical;
}
private static PotionStage getPotionStageNumerical(int numerical) {
for (PotionStage potionStage : values()) {
if (numerical >= potionStage.toNumerical()) {
return potionStage;
}
}
return ONE;
}
public static PotionStage getPotionStage(AlchemyPotion input, AlchemyPotion output) {
PotionStage potionStage = getPotionStage(output);
if (!isWaterBottle(input) && getPotionStage(input) == potionStage) {
potionStage = PotionStage.FIVE;
}
return potionStage;
}
private static boolean isWaterBottle(AlchemyPotion input) {
return input.getEffects().isEmpty();
}
public static PotionStage getPotionStage(AlchemyPotion alchemyPotion) {
Potion potion = Potion.fromItemStack(new ItemStack(Material.POTION, 1, alchemyPotion.getDataValue()));
int stage = 1;
// Check if potion isn't awkward or mundane
if (potion.getType() != null) {
stage++;
}
// Check if potion has a glowstone dust amplifier
if (potion.getLevel() > 1) {
stage++;
}
// Check if potion has a redstone dust amplifier
if (potion.hasExtendedDuration()) {
stage++;
}
// Check if potion has a gunpowder amplifier
if (potion.isSplash()) {
stage++;
}
return PotionStage.getPotionStageNumerical(stage);
}
}

View File

@@ -0,0 +1,11 @@
package com.gmail.nossr50.events.fake;
import org.bukkit.block.Block;
import org.bukkit.event.inventory.BrewEvent;
import org.bukkit.inventory.BrewerInventory;
public class FakeBrewEvent extends BrewEvent {
public FakeBrewEvent(Block brewer, BrewerInventory contents) {
super(brewer, contents);
}
}

View File

@@ -1,5 +1,7 @@
package com.gmail.nossr50.events.fake;
import java.util.Map;
import org.bukkit.entity.Entity;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
@@ -7,6 +9,11 @@ import org.bukkit.event.entity.EntityDamageByEntityEvent;
* Called when mcMMO applies damage from an entity due to special abilities.
*/
public class FakeEntityDamageByEntityEvent extends EntityDamageByEntityEvent {
public FakeEntityDamageByEntityEvent(Entity damager, Entity damagee, DamageCause cause, final Map<DamageModifier, Double> modifiers) {
super(damager, damagee, cause, modifiers);
}
@Deprecated
public FakeEntityDamageByEntityEvent(Entity damager, Entity damagee, DamageCause cause, double damage) {
super(damager, damagee, cause, damage);
}

View File

@@ -1,5 +1,7 @@
package com.gmail.nossr50.events.fake;
import java.util.Map;
import org.bukkit.entity.Entity;
import org.bukkit.event.entity.EntityDamageEvent;
@@ -7,6 +9,11 @@ import org.bukkit.event.entity.EntityDamageEvent;
* Called when mcMMO applies damage due to special abilities.
*/
public class FakeEntityDamageEvent extends EntityDamageEvent {
public FakeEntityDamageEvent(Entity damagee, DamageCause cause, final Map<DamageModifier, Double> modifiers) {
super(damagee, cause, modifiers);
}
@Deprecated
public FakeEntityDamageEvent(Entity damagee, DamageCause cause, double damage) {
super(damagee, cause, damage);
}

View File

@@ -1,18 +1,20 @@
package com.gmail.nossr50.events.skills.secondaryabilities;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import com.gmail.nossr50.datatypes.skills.SecondaryAbility;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.events.skills.McMMOPlayerSkillEvent;
public abstract class SecondaryAbilityEvent extends McMMOPlayerSkillEvent {
public class SecondaryAbilityEvent extends McMMOPlayerSkillEvent implements Cancellable {
private SecondaryAbility secondaryAbility;
private boolean cancelled;
public SecondaryAbilityEvent(Player player, SecondaryAbility secondaryAbility) {
super(player, SkillType.bySecondaryAbility(secondaryAbility));
this.secondaryAbility = secondaryAbility;
cancelled = false;
}
/**
@@ -22,4 +24,12 @@ public abstract class SecondaryAbilityEvent extends McMMOPlayerSkillEvent {
public SecondaryAbility getSecondaryAbility() {
return secondaryAbility;
}
public boolean isCancelled() {
return cancelled;
}
public void setCancelled(boolean newValue) {
this.cancelled = newValue;
}
}

View File

@@ -5,7 +5,6 @@ import org.bukkit.entity.Player;
import com.gmail.nossr50.datatypes.skills.SecondaryAbility;
public class SecondaryAbilityWeightedActivationCheckEvent extends SecondaryAbilityEvent {
private double chance;
public SecondaryAbilityWeightedActivationCheckEvent(Player player, SecondaryAbility ability, double chance) {

View File

@@ -31,6 +31,7 @@ import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.datatypes.skills.ToolType;
import com.gmail.nossr50.events.fake.FakeBlockBreakEvent;
import com.gmail.nossr50.events.fake.FakeBlockDamageEvent;
import com.gmail.nossr50.runnables.PistonTrackerTask;
import com.gmail.nossr50.runnables.StickyPistonTrackerTask;
import com.gmail.nossr50.skills.alchemy.Alchemy;
import com.gmail.nossr50.skills.excavation.ExcavationManager;
@@ -63,27 +64,27 @@ public class BlockListener implements Listener {
*/
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onBlockPistonExtend(BlockPistonExtendEvent event) {
List<Block> blocks = event.getBlocks();
if (!EventUtils.shouldProcessEvent(event.getBlock(), true)) {
return;
}
BlockFace direction = event.getDirection();
Block futureEmptyBlock = event.getBlock().getRelative(direction); // Block that would be air after piston is finished
if (futureEmptyBlock.getType() == Material.AIR) {
return;
}
List<Block> blocks = event.getBlocks();
for (Block b : blocks) {
if (BlockUtils.shouldBeWatched(b.getState()) && mcMMO.getPlaceStore().isTrue(b)) {
b.getRelative(direction).setMetadata(mcMMO.blockMetadataKey, mcMMO.metadataValue);
if (b.equals(futureEmptyBlock) && futureEmptyBlock.getType() == Material.AIR) {
mcMMO.getPlaceStore().setFalse(b);
}
}
}
for (Block b : blocks) {
Block nextBlock = b.getRelative(direction);
if (nextBlock.hasMetadata(mcMMO.blockMetadataKey)) {
mcMMO.getPlaceStore().setTrue(nextBlock);
nextBlock.removeMetadata(mcMMO.blockMetadataKey, plugin);
}
}
// Needed because blocks sometimes don't move when two pistons push towards each other
new PistonTrackerTask(blocks, direction, futureEmptyBlock).runTaskLater(plugin, 2);
}
/**
@@ -93,6 +94,10 @@ public class BlockListener implements Listener {
*/
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onBlockPistonRetract(BlockPistonRetractEvent event) {
if (!EventUtils.shouldProcessEvent(event.getBlock(), false)) {
return;
}
if (!event.isSticky()) {
return;
}

View File

@@ -37,6 +37,7 @@ import org.bukkit.inventory.meta.PotionMeta;
import org.bukkit.metadata.FixedMetadataValue;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import org.bukkit.projectiles.ProjectileSource;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.AdvancedConfig;
@@ -146,7 +147,7 @@ public class EntityListener implements Listener {
return;
}
double damage = event.getDamage();
double damage = event.getFinalDamage();
if (damage <= 0) {
return;
@@ -176,7 +177,11 @@ public class EntityListener implements Listener {
}
if (attacker instanceof Projectile) {
attacker = ((Projectile) attacker).getShooter();
ProjectileSource projectileSource = ((Projectile) attacker).getShooter();
if (projectileSource instanceof LivingEntity) {
attacker = (LivingEntity) projectileSource;
}
}
else if (attacker instanceof Tameable) {
AnimalTamer animalTamer = ((Tameable) attacker).getOwner();
@@ -206,7 +211,7 @@ public class EntityListener implements Listener {
}
CombatUtils.processCombatAttack(event, attacker, target);
CombatUtils.handleHealthbars(attacker, target, event.getDamage());
CombatUtils.handleHealthbars(attacker, target, event.getFinalDamage());
}
/**
@@ -220,7 +225,7 @@ public class EntityListener implements Listener {
return;
}
double damage = event.getDamage();
double damage = event.getFinalDamage();
if (damage <= 0) {
return;
@@ -271,7 +276,7 @@ public class EntityListener implements Listener {
if (acrobaticsManager.canRoll()) {
event.setDamage(acrobaticsManager.rollCheck(event.getDamage()));
if (event.getDamage() == 0) {
if (event.getFinalDamage() == 0) {
event.setCancelled(true);
return;
}
@@ -284,7 +289,7 @@ public class EntityListener implements Listener {
if (miningManager.canUseDemolitionsExpertise()) {
event.setDamage(miningManager.processDemolitionsExpertise(event.getDamage()));
if (event.getDamage() == 0) {
if (event.getFinalDamage() == 0) {
event.setCancelled(true);
return;
}
@@ -295,7 +300,7 @@ public class EntityListener implements Listener {
break;
}
if (event.getDamage() >= 1) {
if (event.getFinalDamage() >= 1) {
mcMMOPlayer.actualizeRecentlyHurt();
}
}
@@ -329,7 +334,7 @@ public class EntityListener implements Listener {
if (tamingManager.canUseThickFur()) {
event.setDamage(Taming.processThickFur(wolf, event.getDamage()));
if (event.getDamage() == 0) {
if (event.getFinalDamage() == 0) {
event.setCancelled(true);
}
}
@@ -355,7 +360,7 @@ public class EntityListener implements Listener {
if (tamingManager.canUseShockProof()) {
event.setDamage(Taming.processShockProof(wolf, event.getDamage()));
if (event.getDamage() == 0) {
if (event.getFinalDamage() == 0) {
event.setCancelled(true);
}
}

View File

@@ -24,6 +24,7 @@ import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerPickupItemEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.event.player.PlayerRespawnEvent;
import org.bukkit.event.player.PlayerStatisticIncrementEvent;
import org.bukkit.event.player.PlayerTeleportEvent;
import org.bukkit.inventory.ItemStack;
@@ -225,6 +226,13 @@ public class PlayerListener implements Listener {
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()));
}
@@ -694,4 +702,13 @@ public class PlayerListener implements Listener {
}
}
}
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPlayerStatisticIncrementEvent(PlayerStatisticIncrementEvent event) {
if (!mcMMO.getHolidayManager().isAprilFirst()) {
return;
}
mcMMO.getHolidayManager().handleStatisticEvent(event);
}
}

View File

@@ -112,6 +112,7 @@ public class mcMMO extends JavaPlugin {
public final static String disarmedItemKey = "mcMMO: Disarmed Item";
public final static String playerDataKey = "mcMMO: Player Data";
public final static String greenThumbDataKey = "mcMMO: Green Thumb";
public final static String pistonDataKey = "mcMMO: Piston State";
public static FixedMetadataValue metadataValue;
@@ -138,7 +139,7 @@ public class mcMMO extends JavaPlugin {
return;
}
if (getServer().getName().equals("MCPC+")) {
if (getServer().getName().equals("Cauldron") || getServer().getName().equals("MCPC+")) {
checkModConfigs();
}
@@ -485,22 +486,22 @@ public class mcMMO extends JavaPlugin {
private void checkModConfigs() {
if (!Config.getInstance().getToolModsEnabled()) {
getLogger().info("MCPC+ implementation found, but the custom tool config for mcMMO is disabled!");
getLogger().warning("Cauldron implementation found, but the custom tool config for mcMMO is disabled!");
getLogger().info("To enable, set Mods.Tool_Mods_Enabled to TRUE in config.yml.");
}
if (!Config.getInstance().getArmorModsEnabled()) {
getLogger().info("MCPC+ implementation found, but the custom armor config for mcMMO is disabled!");
getLogger().warning("Cauldron implementation found, but the custom armor config for mcMMO is disabled!");
getLogger().info("To enable, set Mods.Armor_Mods_Enabled to TRUE in config.yml.");
}
if (!Config.getInstance().getBlockModsEnabled()) {
getLogger().info("MCPC+ implementation found, but the custom block config for mcMMO is disabled!");
getLogger().warning("Cauldron implementation found, but the custom block config for mcMMO is disabled!");
getLogger().info("To enable, set Mods.Block_Mods_Enabled to TRUE in config.yml.");
}
if (!Config.getInstance().getEntityModsEnabled()) {
getLogger().info("MCPC+ implementation found, but the custom entity config for mcMMO is disabled!");
getLogger().warning("Cauldron implementation found, but the custom entity config for mcMMO is disabled!");
getLogger().info("To enable, set Mods.Entity_Mods_Enabled to TRUE in config.yml.");
}
}

View File

@@ -0,0 +1,47 @@
package com.gmail.nossr50.runnables;
import java.util.List;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.scheduler.BukkitRunnable;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.BlockUtils;
public class PistonTrackerTask extends BukkitRunnable {
private List<Block> blocks;
private BlockFace direction;
private Block futureEmptyBlock;
public PistonTrackerTask(List<Block> blocks, BlockFace direction, Block futureEmptyBlock) {
this.blocks = blocks;
this.direction = direction;
this.futureEmptyBlock = futureEmptyBlock;
}
@Override
public void run() {
// Check to see if futureEmptyBlock is empty - if it isn't; the blocks didn't move
if (!BlockUtils.isPistonPiece(futureEmptyBlock.getState())) {
return;
}
if (mcMMO.getPlaceStore().isTrue(futureEmptyBlock)) {
mcMMO.getPlaceStore().setFalse(futureEmptyBlock);
}
for (Block b : blocks) {
Block nextBlock = b.getRelative(direction);
if (nextBlock.hasMetadata(mcMMO.blockMetadataKey)) {
mcMMO.getPlaceStore().setTrue(nextBlock);
nextBlock.removeMetadata(mcMMO.blockMetadataKey, mcMMO.p);
}
else if (mcMMO.getPlaceStore().isTrue(nextBlock)) {
// Block doesn't have metadatakey but isTrue - set it to false
mcMMO.getPlaceStore().setFalse(nextBlock);
}
}
}
}

View File

@@ -2,7 +2,6 @@ package com.gmail.nossr50.runnables;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.block.PistonMoveReaction;
import org.bukkit.scheduler.BukkitRunnable;
import com.gmail.nossr50.mcMMO;
@@ -21,10 +20,16 @@ public class StickyPistonTrackerTask extends BukkitRunnable {
@Override
public void run() {
if (!BlockUtils.shouldBeWatched(movedBlock.getState()) || movedBlock.getPistonMoveReaction() != PistonMoveReaction.MOVE || !mcMMO.getPlaceStore().isTrue(movedBlock)) {
if (!mcMMO.getPlaceStore().isTrue(movedBlock)) {
return;
}
if (!BlockUtils.isPistonPiece(movedBlock.getState())) {
// The block didn't move
return;
}
// The sticky piston actually pulled the block so move the PlaceStore data
mcMMO.getPlaceStore().setFalse(movedBlock);
mcMMO.getPlaceStore().setTrue(block.getRelative(direction));
}

View File

@@ -2,6 +2,7 @@ package com.gmail.nossr50.runnables.skills;
import org.bukkit.ChatColor;
import org.bukkit.Sound;
import org.bukkit.Statistic;
import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable;
@@ -19,6 +20,7 @@ public class AprilTask extends BukkitRunnable {
}
for (Player player : mcMMO.p.getServer().getOnlinePlayers()) {
int random = Misc.getRandom().nextInt(40) + 11;
int betterRandom = Misc.getRandom().nextInt(2000);
if (betterRandom == 0) {
player.playSound(player.getLocation(), Sound.LEVEL_UP, Misc.LEVELUP_VOLUME, Misc.LEVELUP_PITCH);
@@ -26,10 +28,9 @@ public class AprilTask extends BukkitRunnable {
fireworksShow(player);
}
for (HolidayManager.FakeSkillType fakeSkillType : HolidayManager.FakeSkillType.values()) {
int random = Misc.getRandom().nextInt(250);
if (random == 0) {
mcMMO.getHolidayManager().levelUpApril(player, fakeSkillType);
for (Statistic statistic : mcMMO.getHolidayManager().movementStatistics) {
if (player.getStatistic(statistic) > 0 && player.getStatistic(statistic) % random == 0) {
mcMMO.getHolidayManager().levelUpApril(player, HolidayManager.FakeSkillType.getByStatistic(statistic));
break;
}
}

View File

@@ -9,6 +9,7 @@ import com.gmail.nossr50.config.skills.alchemy.PotionConfig;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.datatypes.skills.XPGainReason;
import com.gmail.nossr50.datatypes.skills.alchemy.PotionStage;
import com.gmail.nossr50.skills.SkillManager;
import com.gmail.nossr50.util.StringUtils;
@@ -64,7 +65,7 @@ public class AlchemyManager extends SkillManager {
return Math.min(Alchemy.catalysisMaxSpeed, Alchemy.catalysisMinSpeed + (Alchemy.catalysisMaxSpeed - Alchemy.catalysisMinSpeed) * (skillLevel - Alchemy.catalysisUnlockLevel) / (Alchemy.catalysisMaxBonusLevel - Alchemy.catalysisUnlockLevel)) * (isLucky ? LUCKY_MODIFIER : 1.0);
}
public void handlePotionBrewSuccesses(int amount) {
applyXpGain((float) (ExperienceConfig.getInstance().getPotionXP() * amount), XPGainReason.PVE);
public void handlePotionBrewSuccesses(PotionStage potionStage, int amount) {
applyXpGain((float) (ExperienceConfig.getInstance().getPotionXP(potionStage) * amount), XPGainReason.PVE);
}
}

View File

@@ -1,5 +1,6 @@
package com.gmail.nossr50.skills.alchemy;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.Material;
@@ -17,6 +18,8 @@ import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.skills.alchemy.PotionConfig;
import com.gmail.nossr50.datatypes.skills.SecondaryAbility;
import com.gmail.nossr50.datatypes.skills.alchemy.AlchemyPotion;
import com.gmail.nossr50.datatypes.skills.alchemy.PotionStage;
import com.gmail.nossr50.events.fake.FakeBrewEvent;
import com.gmail.nossr50.runnables.player.PlayerUpdateInventoryTask;
import com.gmail.nossr50.runnables.skills.AlchemyBrewCheckTask;
import com.gmail.nossr50.util.Permissions;
@@ -100,6 +103,8 @@ public final class AlchemyPotionBrewer {
return;
}
List<AlchemyPotion> inputList = new ArrayList<AlchemyPotion>();
for (int i = 0; i < 3; i++) {
ItemStack item = inventory.getItem(i);
@@ -110,12 +115,26 @@ public final class AlchemyPotionBrewer {
AlchemyPotion input = PotionConfig.getInstance().getPotion(item.getDurability());
AlchemyPotion output = PotionConfig.getInstance().getPotion(input.getChildDataValue(ingredient));
inputList.add(input);
if (output != null) {
inventory.setItem(i, output.toItemStack(item.getAmount()).clone());
}
}
if (player != null) {
UserManager.getPlayer(player).getAlchemyManager().handlePotionBrewSuccesses(1);
}
FakeBrewEvent event = new FakeBrewEvent(brewingStand.getBlock(), inventory);
mcMMO.p.getServer().getPluginManager().callEvent(event);
if (event.isCancelled() || inputList.isEmpty()) {
return;
}
for (AlchemyPotion input : inputList) {
AlchemyPotion output = PotionConfig.getInstance().getPotion(input.getChildDataValue(ingredient));
if (output != null && player != null) {
PotionStage potionStage = PotionStage.getPotionStage(input, output);
UserManager.getPlayer(player).getAlchemyManager().handlePotionBrewSuccesses(potionStage, 1);
}
}

View File

@@ -19,7 +19,7 @@ public class Archery {
public static double skillShotMaxBonusPercentage = AdvancedConfig.getInstance().getSkillShotBonusMax();
public static double skillShotMaxBonusDamage = AdvancedConfig.getInstance().getSkillShotDamageMax();
public static double dazeModifier = AdvancedConfig.getInstance().getDazeModifier();
public static double dazeBonusDamage = AdvancedConfig.getInstance().getDazeBonusDamage();
public static final double DISTANCE_XP_MULTIPLIER = 0.025;

View File

@@ -1,11 +1,9 @@
package com.gmail.nossr50.skills.archery;
import org.bukkit.Location;
import org.bukkit.entity.Arrow;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
@@ -18,7 +16,6 @@ import com.gmail.nossr50.skills.SkillManager;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.skills.CombatUtils;
import com.gmail.nossr50.util.skills.SkillUtils;
public class ArcheryManager extends SkillManager {
@@ -70,9 +67,8 @@ public class ArcheryManager extends SkillManager {
* Handle the effects of the Daze ability
*
* @param defender The {@link Player} being affected by the ability
* @param arrow The {@link Arrow} that was fired
*/
public double daze(Player defender, Arrow arrow) {
public double daze(Player defender) {
if (!SkillUtils.activationSuccessful(SecondaryAbility.DAZE, getPlayer(), getSkillLevel(), activationChance)) {
return 0;
}
@@ -91,20 +87,21 @@ public class ArcheryManager extends SkillManager {
getPlayer().sendMessage(LocaleLoader.getString("Combat.TargetDazed"));
}
return CombatUtils.callFakeDamageEvent(arrow, defender, DamageCause.PROJECTILE, Archery.dazeModifier);
return Archery.dazeBonusDamage;
}
/**
* Handle the effects of the Skill Shot ability
*
* @param target The {@link LivingEntity} being affected by the ability
* @param damage The amount of damage initially dealt by the event
* @param arrow The {@link Arrow} that was fired
*/
public double skillShot(LivingEntity target, double damage, Arrow arrow) {
double damageBonusPercent = Math.min(((getSkillLevel() / Archery.skillShotIncreaseLevel) * Archery.skillShotIncreasePercentage), Archery.skillShotMaxBonusPercentage);
double archeryBonus = Math.min(damage * damageBonusPercent, Archery.skillShotMaxBonusDamage);
public double skillShot(double damage) {
if (!SkillUtils.activationSuccessful(SecondaryAbility.SKILL_SHOT, getPlayer())) {
return damage;
}
return CombatUtils.callFakeDamageEvent(arrow, target, DamageCause.PROJECTILE, archeryBonus);
double damageBonusPercent = Math.min(((getSkillLevel() / Archery.skillShotIncreaseLevel) * Archery.skillShotIncreasePercentage), Archery.skillShotMaxBonusPercentage);
return Math.min(damage * damageBonusPercent, Archery.skillShotMaxBonusDamage);
}
}

View File

@@ -1,20 +1,20 @@
package com.gmail.nossr50.skills.axes;
import java.util.Map;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.event.entity.EntityDamageEvent.DamageModifier;
import org.bukkit.inventory.ItemStack;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.skills.AbilityType;
import com.gmail.nossr50.datatypes.skills.SecondaryAbility;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.datatypes.skills.ToolType;
import com.gmail.nossr50.events.skills.secondaryabilities.SecondaryAbilityWeightedActivationCheckEvent;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.skills.SkillManager;
import com.gmail.nossr50.util.ItemUtils;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.skills.CombatUtils;
@@ -52,13 +52,13 @@ public class AxesManager extends SkillManager {
/**
* Handle the effects of the Axe Mastery ability
*
* @param target The {@link LivingEntity} being affected by the ability
*/
public double axeMastery(LivingEntity target) {
double axeBonus = Math.min(getSkillLevel() / (Axes.axeMasteryMaxBonusLevel / Axes.axeMasteryMaxBonus), Axes.axeMasteryMaxBonus);
public double axeMastery() {
if (!SkillUtils.activationSuccessful(SecondaryAbility.AXE_MASTERY, getPlayer())) {
return 0;
}
return CombatUtils.callFakeDamageEvent(getPlayer(), target, axeBonus);
return Math.min(getSkillLevel() / (Axes.axeMasteryMaxBonusLevel / Axes.axeMasteryMaxBonus), Axes.axeMasteryMaxBonus);
}
/**
@@ -85,7 +85,7 @@ public class AxesManager extends SkillManager {
damage = (damage * Axes.criticalHitPVEModifier) - damage;
}
return CombatUtils.callFakeDamageEvent(player, target, damage);
return damage;
}
/**
@@ -98,10 +98,7 @@ public class AxesManager extends SkillManager {
for (ItemStack armor : target.getEquipment().getArmorContents()) {
if (ItemUtils.isArmor(armor)) {
double chance = Axes.impactChance / activationChance;
SecondaryAbilityWeightedActivationCheckEvent event = new SecondaryAbilityWeightedActivationCheckEvent(getPlayer(), SecondaryAbility.ARMOR_IMPACT, chance);
mcMMO.p.getServer().getPluginManager().callEvent(event);
if ((event.getChance() * activationChance) > Misc.getRandom().nextInt(activationChance)) {
if (SkillUtils.activationSuccessful(SecondaryAbility.ARMOR_IMPACT, getPlayer(), Axes.impactChance, activationChance)) {
SkillUtils.handleDurabilityChange(armor, durabilityDamage, Axes.impactMaxDurabilityModifier);
}
}
@@ -114,10 +111,7 @@ public class AxesManager extends SkillManager {
* @param target The {@link LivingEntity} being affected by the ability
*/
public double greaterImpact(LivingEntity target) {
double chance = Axes.greaterImpactChance / activationChance;
SecondaryAbilityWeightedActivationCheckEvent event = new SecondaryAbilityWeightedActivationCheckEvent(getPlayer(), SecondaryAbility.GREATER_IMPACT, chance);
mcMMO.p.getServer().getPluginManager().callEvent(event);
if ((event.getChance() * activationChance) <= Misc.getRandom().nextInt(activationChance)) {
if (!SkillUtils.activationSuccessful(SecondaryAbility.GREATER_IMPACT, getPlayer(), Axes.greaterImpactChance, activationChance)) {
return 0;
}
@@ -138,7 +132,7 @@ public class AxesManager extends SkillManager {
}
}
return CombatUtils.callFakeDamageEvent(player, target, Axes.greaterImpactBonusDamage);
return Axes.greaterImpactBonusDamage;
}
/**
@@ -147,7 +141,7 @@ public class AxesManager extends SkillManager {
* @param target The {@link LivingEntity} being affected by the ability
* @param damage The amount of damage initially dealt by the event
*/
public void skullSplitterCheck(LivingEntity target, double damage) {
CombatUtils.applyAbilityAoE(getPlayer(), target, damage / Axes.skullSplitterModifier, skill);
public void skullSplitterCheck(LivingEntity target, double damage, Map<DamageModifier, Double> modifiers) {
CombatUtils.applyAbilityAoE(getPlayer(), target, damage / Axes.skullSplitterModifier, modifiers, skill);
}
}

View File

@@ -21,13 +21,13 @@ public class Excavation {
protected static List<ExcavationTreasure> getTreasures(BlockState blockState) {
switch (blockState.getType()) {
case DIRT:
return TreasureConfig.getInstance().excavationFromDirt;
return blockState.getRawData() == 0x2 ? TreasureConfig.getInstance().excavationFromPodzol : TreasureConfig.getInstance().excavationFromDirt;
case GRASS:
return TreasureConfig.getInstance().excavationFromGrass;
case SAND:
return TreasureConfig.getInstance().excavationFromSand;
return blockState.getRawData() == 0x1 ? TreasureConfig.getInstance().excavationFromRedSand : TreasureConfig.getInstance().excavationFromSand;
case GRAVEL:
return TreasureConfig.getInstance().excavationFromGravel;

View File

@@ -1,9 +1,12 @@
package com.gmail.nossr50.skills.fishing;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.List;
import java.util.Set;
import org.bukkit.Material;
import org.bukkit.block.Biome;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.LivingEntity;
import org.bukkit.inventory.ItemStack;
@@ -54,6 +57,13 @@ public final class Fishing {
public static int fishermansDietRankLevel2 = fishermansDietRankLevel1 * 2;
public static int fishermansDietMaxLevel = fishermansDietRankLevel1 * 5;
public static Set<Biome> masterAnglerBiomes = EnumSet.of(Biome.RIVER, Biome.OCEAN, Biome.DEEP_OCEAN);
public static Set<Biome> iceFishingBiomes = EnumSet.of(
Biome.FROZEN_OCEAN, Biome.FROZEN_RIVER,
Biome.TAIGA, Biome.TAIGA_HILLS, Biome.TAIGA_MOUNTAINS,
Biome.ICE_PLAINS, Biome.ICE_MOUNTAINS, Biome.ICE_PLAINS_SPIKES,
Biome.COLD_TAIGA, Biome.COLD_TAIGA_HILLS, Biome.COLD_TAIGA_MOUNTAINS);
private Fishing() {}
/**

View File

@@ -12,7 +12,6 @@ import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.WeatherType;
import org.bukkit.World;
import org.bukkit.block.Biome;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.enchantments.Enchantment;
@@ -199,10 +198,7 @@ public class FishingManager extends SkillManager {
}
// 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 || biome == Biome.TAIGA || biome == Biome.TAIGA_HILLS || biome == Biome.ICE_PLAINS || biome == Biome.ICE_MOUNTAINS);
if (!isFrozenBiome && (block.getRelative(BlockFace.DOWN, 3).getType() != Material.STATIONARY_WATER)) {
if (!Fishing.iceFishingBiomes.contains(block.getBiome()) && (block.getRelative(BlockFace.DOWN, 3).getType() != Material.STATIONARY_WATER)) {
return false;
}
@@ -282,12 +278,11 @@ public class FishingManager extends SkillManager {
public void masterAngler(Fish hook) {
Player player = getPlayer();
Location location = hook.getLocation();
Biome biome = location.getBlock().getBiome();
double biteChance = hook.getBiteChance();
hookLocation = location;
if (biome == Biome.RIVER || biome == Biome.OCEAN) {
if (Fishing.masterAnglerBiomes.contains(location.getBlock().getBiome())) {
biteChance = biteChance * AdvancedConfig.getInstance().getMasterAnglerBiomeModifier();
}
@@ -305,6 +300,7 @@ public class FishingManager extends SkillManager {
*/
public void handleFishing(Item fishingCatch) {
this.fishingCatch = fishingCatch;
int fishXp = ExperienceConfig.getInstance().getFishXp(fishingCatch.getItemStack().getData());
int treasureXp = 0;
Player player = getPlayer();
FishingTreasure treasure = null;
@@ -315,8 +311,6 @@ public class FishingManager extends SkillManager {
}
if (treasure != null) {
player.sendMessage(LocaleLoader.getString("Fishing.Ability.TH.ItemFound"));
ItemStack treasureDrop = treasure.getDrop().clone(); // Not cloning is bad, m'kay?
Map<Enchantment, Integer> enchants = new HashMap<Enchantment, Integer>();
@@ -356,7 +350,7 @@ public class FishingManager extends SkillManager {
}
}
applyXpGain(ExperienceConfig.getInstance().getFishingBaseXP() + treasureXp, XPGainReason.PVE);
applyXpGain(fishXp + treasureXp, XPGainReason.PVE);
}
/**
@@ -455,6 +449,8 @@ public class FishingManager extends SkillManager {
*/
private FishingTreasure getFishingTreasure() {
double diceRoll = Misc.getRandom().nextDouble() * 100;
diceRoll -= getPlayer().getItemInHand().getEnchantmentLevel(Enchantment.LUCK);
FishingTreasure treasure = null;
for (Rarity rarity : Rarity.values()) {

View File

@@ -148,7 +148,12 @@ public class HerbalismManager extends SkillManager {
processGreenThumbPlants(blockState, greenTerra);
}
xp = ExperienceConfig.getInstance().getXp(skill, material);
if (material == Material.DOUBLE_PLANT || material == Material.RED_ROSE || material == Material.LONG_GRASS) {
xp = ExperienceConfig.getInstance().getFlowerAndGrassXp(blockState.getData());
}
else {
xp = ExperienceConfig.getInstance().getXp(skill, material);
}
if (Config.getInstance().getDoubleDropsEnabled(skill, material) && Permissions.secondaryAbilityEnabled(player, SecondaryAbility.HERBALISM_DOUBLE_DROPS)) {
drops = blockState.getBlock().getDrops();

View File

@@ -39,11 +39,13 @@ public class Mining {
switch (blockType) {
case ENDER_STONE:
case GOLD_ORE:
case HARD_CLAY:
case IRON_ORE:
case MOSSY_COBBLESTONE:
case NETHERRACK:
case OBSIDIAN:
case SANDSTONE:
case STAINED_CLAY:
handleMiningDrops(blockState);
return;
@@ -55,12 +57,13 @@ public class Mining {
case COAL_ORE:
case DIAMOND_ORE:
case REDSTONE_ORE:
case EMERALD_ORE:
case GLOWSTONE:
case LAPIS_ORE:
case STONE:
case EMERALD_ORE:
case PACKED_ICE:
case QUARTZ_ORE:
case REDSTONE_ORE:
case STONE:
Misc.dropItem(blockState.getLocation(), new ItemStack(blockType));
return;
@@ -82,17 +85,20 @@ public class Mining {
case COAL_ORE:
case DIAMOND_ORE:
case EMERALD_ORE:
case GLOWSTONE:
case LAPIS_ORE:
case STONE:
case ENDER_STONE:
case GLOWSTONE:
case GOLD_ORE:
case HARD_CLAY:
case IRON_ORE:
case LAPIS_ORE:
case MOSSY_COBBLESTONE:
case NETHERRACK:
case OBSIDIAN:
case PACKED_ICE:
case REDSTONE_ORE:
case SANDSTONE:
case STAINED_CLAY:
case STONE:
case QUARTZ_ORE:
Misc.dropItems(blockState.getLocation(), blockState.getBlock().getDrops());
return;

View File

@@ -97,7 +97,8 @@ public class RepairManager extends SkillManager {
// Check if they have the proper material to repair with
if (!inventory.contains(repairMaterial)) {
String message = LocaleLoader.getString("Skills.NeedMore", StringUtils.getPrettyItemString(repairMaterial));
String prettyName = repairable.getRepairMaterialPrettyName() == null ? StringUtils.getPrettyItemString(repairMaterial) : repairable.getRepairMaterialPrettyName();
String message = LocaleLoader.getString("Skills.NeedMore", prettyName);
if (repairMaterialMetadata != (byte) -1 && !inventory.containsAtLeast(toRemove, 1)) {
message += ":" + repairMaterialMetadata;

View File

@@ -28,6 +28,13 @@ public interface Repairable {
*/
public byte getRepairMaterialMetadata();
/**
* Gets the pretty name of the material used to repair this item
*
* @return the pretty name of the repair material
*/
public String getRepairMaterialPrettyName();
/**
* Gets the RepairItemType value for this repairable item
*

View File

@@ -8,11 +8,15 @@ import com.gmail.nossr50.datatypes.skills.MaterialType;
public class RepairableFactory {
public static Repairable getRepairable(Material itemMaterial, Material repairMaterial, byte repairMetadata, int minimumQuantity, short maximumDurability) {
return getRepairable(itemMaterial, repairMaterial, repairMetadata, 0, minimumQuantity, maximumDurability, ItemType.OTHER, MaterialType.OTHER, 1);
return getRepairable(itemMaterial, repairMaterial, repairMetadata, null, 0, minimumQuantity, maximumDurability, ItemType.OTHER, MaterialType.OTHER, 1);
}
public static Repairable getRepairable(Material itemMaterial, Material repairMaterial, byte repairMetadata, int minimumLevel, int minimumQuantity, short maximumDurability, ItemType repairItemType, MaterialType repairMaterialType, double xpMultiplier) {
return getRepairable(itemMaterial, repairMaterial, repairMetadata, null, minimumLevel, minimumQuantity, maximumDurability, repairItemType, repairMaterialType, xpMultiplier);
}
public static Repairable getRepairable(Material itemMaterial, Material repairMaterial, byte repairMetadata, String repairMaterialPrettyName, int minimumLevel, int minimumQuantity, short maximumDurability, ItemType repairItemType, MaterialType repairMaterialType, double xpMultiplier) {
// TODO: Add in loading from config what type of repairable we want.
return new SimpleRepairable(itemMaterial, repairMaterial, repairMetadata, minimumLevel, minimumQuantity, maximumDurability, repairItemType, repairMaterialType, xpMultiplier);
return new SimpleRepairable(itemMaterial, repairMaterial, repairMetadata, repairMaterialPrettyName, minimumLevel, minimumQuantity, maximumDurability, repairItemType, repairMaterialType, xpMultiplier);
}
}

View File

@@ -11,14 +11,16 @@ public class SimpleRepairable implements Repairable {
private final int minimumQuantity, minimumLevel;
private final short maximumDurability, baseRepairDurability;
private final byte repairMetadata;
private String repairMaterialPrettyName;
private final ItemType repairItemType;
private final MaterialType repairMaterialType;
private final double xpMultiplier;
protected SimpleRepairable(Material type, Material repairMaterial, byte repairMetadata, int minimumLevel, int minimumQuantity, short maximumDurability, ItemType repairItemType, MaterialType repairMaterialType, double xpMultiplier) {
protected SimpleRepairable(Material type, Material repairMaterial, byte repairMetadata, String repairMaterialPrettyName, int minimumLevel, int minimumQuantity, short maximumDurability, ItemType repairItemType, MaterialType repairMaterialType, double xpMultiplier) {
this.itemMaterial = type;
this.repairMaterial = repairMaterial;
this.repairMetadata = repairMetadata;
this.repairMaterialPrettyName = repairMaterialPrettyName;
this.repairItemType = repairItemType;
this.repairMaterialType = repairMaterialType;
this.minimumLevel = minimumLevel;
@@ -43,6 +45,11 @@ public class SimpleRepairable implements Repairable {
return repairMetadata;
}
@Override
public String getRepairMaterialPrettyName() {
return repairMaterialPrettyName;
}
@Override
public ItemType getRepairItemType() {
return repairItemType;

View File

@@ -84,8 +84,6 @@ public class SalvageManager extends SkillManager {
return;
}
byte salvageMaterialMetadata = salvageable.getSalvageMaterialMetadata();
int salvageableAmount = Salvage.calculateSalvageableAmount(item.getDurability(), salvageable.getMaximumDurability(), salvageable.getMaximumQuantity());
if (salvageableAmount == 0) {
@@ -108,6 +106,8 @@ public class SalvageManager extends SkillManager {
}
}
byte salvageMaterialMetadata = (salvageable.getSalvageMaterialMetadata() != (byte) -1) ? salvageable.getSalvageMaterialMetadata() : 0;
Misc.dropItems(location, new MaterialData(salvageable.getSalvageMaterial(), salvageMaterialMetadata).toItemStack(salvageableAmount), 1);
// BWONG BWONG BWONG - CLUNK!

View File

@@ -7,37 +7,37 @@ import com.gmail.nossr50.datatypes.skills.MaterialType;
public interface Salvageable {
/**
* Gets the type of this repairable item
* Gets the type of this salvageable item
*
* @return the type of this repairable
* @return the type of this salvageable
*/
public Material getItemMaterial();
/**
* Gets the id of the material used to repair this item
* Gets the material of the items dropped when salvaging this item
*
* @return the id of the repair material
* @return the material of the salvage drop
*/
public Material getSalvageMaterial();
/**
* Gets the metadata byte value of the material used to repair this item
* Gets the metadata byte value of the items dropped when salvaging this item
*
* @return the byte metadata of the repair material
* @return the byte metadata of the salvage drop
*/
public byte getSalvageMaterialMetadata();
/**
* Gets the RepairItemType value for this repairable item
* Gets the ItemType value for this salvageable item
*
* @return the RepairItemType for this repairable
* @return the ItemType for this salvageable
*/
public ItemType getSalvageItemType();
/**
* Gets the RepairMaterialType value for this repairable item
* Gets the MaterialType value for this salvageable item
*
* @return the RepairMaterialType for this repairable
* @return the MaterialType for this salvageable
*/
public MaterialType getSalvageMaterialType();
@@ -58,25 +58,25 @@ public interface Salvageable {
public short getMaximumDurability();
/**
* Gets the base repair durability on which to calculate bonuses.
* Gets the base salvage durability on which to calculate bonuses.
*
* This is actually the maximum durability divided by the minimum quantity
*
* @return the base repair durability
* @return the base salvage durability
*/
public short getBaseSalvageDurability();
/**
* Gets the minimum repair level needed to repair this item
* Gets the minimum salvage level needed to salvage this item
*
* @return the minimum level to repair this item, or 0 for no minimum
* @return the minimum level to salvage this item, or 0 for no minimum
*/
public int getMinimumLevel();
/**
* Gets the xpMultiplier for this repairable
* Gets the xpMultiplier for this salvageable
*
* @return the xpMultiplier of this repairable
* @return the xpMultiplier of this salvageable
*/
public double getXpMultiplier();
}

View File

@@ -1,8 +1,11 @@
package com.gmail.nossr50.skills.swords;
import java.util.Map;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.event.entity.EntityDamageEvent.DamageModifier;
import com.gmail.nossr50.config.AdvancedConfig;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
@@ -96,8 +99,8 @@ public class SwordsManager extends SkillManager {
* @param target The {@link LivingEntity} being affected by the ability
* @param damage The amount of damage initially dealt by the event
*/
public void serratedStrikes(LivingEntity target, double damage) {
CombatUtils.applyAbilityAoE(getPlayer(), target, damage / Swords.serratedStrikesModifier, skill);
public void serratedStrikes(LivingEntity target, double damage, Map<DamageModifier, Double> modifiers) {
CombatUtils.applyAbilityAoE(getPlayer(), target, damage / Swords.serratedStrikesModifier, modifiers, skill);
BleedTimerTask.add(target, Swords.serratedStrikesBleedTicks);
}
}

View File

@@ -18,14 +18,12 @@ import com.gmail.nossr50.datatypes.skills.SecondaryAbility;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.datatypes.skills.XPGainReason;
import com.gmail.nossr50.events.fake.FakeEntityTameEvent;
import com.gmail.nossr50.events.skills.secondaryabilities.SecondaryAbilityWeightedActivationCheckEvent;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.runnables.skills.BleedTimerTask;
import com.gmail.nossr50.skills.SkillManager;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.StringUtils;
import com.gmail.nossr50.util.skills.CombatUtils;
import com.gmail.nossr50.util.skills.SkillUtils;
public class TamingManager extends SkillManager {
@@ -96,18 +94,16 @@ public class TamingManager extends SkillManager {
* @param damage The damage being absorbed by the wolf
*/
public void fastFoodService(Wolf wolf, double damage) {
double chance = Taming.fastFoodServiceActivationChance / activationChance;
SecondaryAbilityWeightedActivationCheckEvent event = new SecondaryAbilityWeightedActivationCheckEvent(getPlayer(), SecondaryAbility.FAST_FOOD, chance);
mcMMO.p.getServer().getPluginManager().callEvent(event);
if ((event.getChance() * activationChance) > Misc.getRandom().nextInt(activationChance)) {
if (!SkillUtils.activationSuccessful(SecondaryAbility.FAST_FOOD, getPlayer(), Taming.fastFoodServiceActivationChance, activationChance)) {
return;
}
double health = wolf.getHealth();
double maxHealth = wolf.getMaxHealth();
double health = wolf.getHealth();
double maxHealth = wolf.getMaxHealth();
if (health < maxHealth) {
double newHealth = health + damage;
wolf.setHealth(Math.min(newHealth, maxHealth));
}
if (health < maxHealth) {
double newHealth = health + damage;
wolf.setHealth(Math.min(newHealth, maxHealth));
}
}
@@ -116,9 +112,8 @@ public class TamingManager extends SkillManager {
*
* @param target The LivingEntity to apply Gore on
* @param damage The initial damage
* @param wolf The wolf using the ability
*/
public double gore(LivingEntity target, double damage, Wolf wolf) {
public double gore(LivingEntity target, double damage) {
if (!SkillUtils.activationSuccessful(SecondaryAbility.GORE, getPlayer(), getSkillLevel(), activationChance)) {
return 0;
}
@@ -132,11 +127,11 @@ public class TamingManager extends SkillManager {
getPlayer().sendMessage(LocaleLoader.getString("Combat.Gore"));
damage = (damage * Taming.goreModifier) - damage;
return CombatUtils.callFakeDamageEvent(wolf, target, damage);
return damage;
}
public double sharpenedClaws(LivingEntity target, Wolf wolf) {
return CombatUtils.callFakeDamageEvent(wolf, target, Taming.sharpenedClawsBonusDamage);
public double sharpenedClaws() {
return Taming.sharpenedClawsBonusDamage;
}
/**

View File

@@ -22,7 +22,6 @@ import com.gmail.nossr50.util.EventUtils;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.skills.CombatUtils;
import com.gmail.nossr50.util.skills.SkillUtils;
public class UnarmedManager extends SkillManager {
@@ -57,6 +56,10 @@ public class UnarmedManager extends SkillManager {
}
public boolean blockCrackerCheck(BlockState blockState) {
if (!SkillUtils.activationSuccessful(SecondaryAbility.BLOCK_CRACKER, getPlayer())) {
return false;
}
MaterialData data = blockState.getData();
switch (blockState.getType()) {
@@ -117,24 +120,23 @@ public class UnarmedManager extends SkillManager {
/**
* Handle the effects of the Berserk ability
*
* @param target The {@link LivingEntity} being affected by the ability
* @param damage The amount of damage initially dealt by the event
*/
public double berserkDamage(LivingEntity target, double damage) {
public double berserkDamage(double damage) {
damage = (damage * Unarmed.berserkDamageModifier) - damage;
return CombatUtils.callFakeDamageEvent(getPlayer(), target, damage);
return damage;
}
/**
* Handle the effects of the Iron Arm ability
*
* @param target The {@link LivingEntity} being affected by the ability
*/
public double ironArm(LivingEntity target) {
double unarmedBonus = Math.min(Unarmed.ironArmMinBonusDamage + (getSkillLevel() / Unarmed.ironArmIncreaseLevel), Unarmed.ironArmMaxBonusDamage);
public double ironArm() {
if (!SkillUtils.activationSuccessful(SecondaryAbility.IRON_ARM, getPlayer())) {
return 0;
}
return CombatUtils.callFakeDamageEvent(getPlayer(), target, unarmedBonus);
return Math.min(Unarmed.ironArmMinBonusDamage + (getSkillLevel() / Unarmed.ironArmIncreaseLevel), Unarmed.ironArmMaxBonusDamage);
}
/**

View File

@@ -5,6 +5,7 @@ import java.util.List;
import java.util.Set;
import org.bukkit.Material;
import org.bukkit.TreeSpecies;
import org.bukkit.block.BlockFace;
import org.bukkit.block.BlockState;
import org.bukkit.inventory.ItemStack;
@@ -55,28 +56,19 @@ public final class Woodcutting {
return mcMMO.getModManager().getBlock(blockState).getXpGain();
}
switch (((Tree) blockState.getData()).getSpecies()) {
case GENERIC:
return ExperienceConfig.getInstance().getWoodcuttingXPOak();
case REDWOOD:
return ExperienceConfig.getInstance().getWoodcuttingXPSpruce();
case BIRCH:
return ExperienceConfig.getInstance().getWoodcuttingXPBirch();
case JUNGLE:
int xp = ExperienceConfig.getInstance().getWoodcuttingXPJungle();
if (experienceGainMethod == ExperienceGainMethod.TREE_FELLER) {
xp *= 0.5;
}
return xp;
default:
return 0;
//TODO Remove this workaround when casting to Tree works again
TreeSpecies species = TreeSpecies.GENERIC;
if (blockState.getData() instanceof Tree) {
species = ((Tree) blockState.getData()).getSpecies();
}
int xp = ExperienceConfig.getInstance().getWoodcuttingTreeXP(species);
if (species == TreeSpecies.JUNGLE && experienceGainMethod == ExperienceGainMethod.TREE_FELLER) {
xp *= 0.5;
}
return xp;
}
/**
@@ -89,33 +81,14 @@ public final class Woodcutting {
Misc.dropItems(blockState.getLocation(), blockState.getBlock().getDrops());
}
else {
switch (((Tree) blockState.getData()).getSpecies()) {
case GENERIC:
if (Config.getInstance().getOakDoubleDropsEnabled()) {
Misc.dropItems(blockState.getLocation(), blockState.getBlock().getDrops());
}
return;
//TODO Remove this workaround when casting to Tree works again
TreeSpecies species = TreeSpecies.GENERIC;
if (blockState.getData() instanceof Tree) {
species = ((Tree) blockState.getData()).getSpecies();
}
case REDWOOD:
if (Config.getInstance().getSpruceDoubleDropsEnabled()) {
Misc.dropItems(blockState.getLocation(), blockState.getBlock().getDrops());
}
return;
case BIRCH:
if (Config.getInstance().getBirchDoubleDropsEnabled()) {
Misc.dropItems(blockState.getLocation(), blockState.getBlock().getDrops());
}
return;
case JUNGLE:
if (Config.getInstance().getJungleDoubleDropsEnabled()) {
Misc.dropItems(blockState.getLocation(), blockState.getBlock().getDrops());
}
return;
default:
return;
if (Config.getInstance().getWoodcuttingDoubleDropsEnabled(species)) {
Misc.dropItems(blockState.getLocation(), blockState.getBlock().getDrops());
}
}
}

View File

@@ -141,11 +141,15 @@ public class WoodcuttingManager extends SkillManager {
Misc.dropItems(blockState.getLocation(), block.getDrops());
}
else {
Tree tree = (Tree) blockState.getData();
tree.setDirection(BlockFace.UP);
//TODO Remove this workaround when casting to Tree works again
if (blockState.getData() instanceof Tree) {
Tree tree = (Tree) blockState.getData();
tree.setDirection(BlockFace.UP);
}
switch (material) {
case LOG:
case LOG_2:
if (canGetDoubleDrops()) {
Woodcutting.checkForDoubleDrop(blockState);
}
@@ -154,6 +158,7 @@ public class WoodcuttingManager extends SkillManager {
break;
case LEAVES:
case LEAVES_2:
Misc.dropItems(blockState.getLocation(), block.getDrops());
break;
@@ -168,5 +173,4 @@ public class WoodcuttingManager extends SkillManager {
applyXpGain(xp, XPGainReason.PVE);
}
}

View File

@@ -113,7 +113,9 @@ public final class BlockUtils {
switch (blockState.getType()) {
case BROWN_MUSHROOM:
case CACTUS:
case DOUBLE_PLANT:
case MELON_BLOCK:
case LONG_GRASS:
case PUMPKIN:
case RED_MUSHROOM:
case RED_ROSE:
@@ -151,10 +153,13 @@ public final class BlockUtils {
switch (blockState.getType()) {
case ENDER_STONE:
case GLOWSTONE:
case HARD_CLAY:
case MOSSY_COBBLESTONE:
case NETHERRACK:
case OBSIDIAN:
case PACKED_ICE:
case SANDSTONE:
case STAINED_CLAY:
case STONE:
return true;
@@ -196,6 +201,7 @@ public final class BlockUtils {
public static boolean isLog(BlockState blockState) {
switch (blockState.getType()) {
case LOG:
case LOG_2:
case HUGE_MUSHROOM_1:
case HUGE_MUSHROOM_2:
return true;
@@ -214,6 +220,7 @@ public final class BlockUtils {
public static boolean isLeaves(BlockState blockState) {
switch (blockState.getType()) {
case LEAVES:
case LEAVES_2:
return true;
default:
@@ -276,7 +283,7 @@ public final class BlockUtils {
* Determine if a given block can be made into Mycelium
*
* @param blockState The {@link BlockState} of the block to check
* @return true if the block can be made in Mycelium, false otherwise
* @return true if the block can be made into Mycelium, false otherwise
*/
public static boolean canMakeShroomy(BlockState blockState) {
switch (blockState.getType()) {
@@ -301,6 +308,12 @@ public final class BlockUtils {
return type == Repair.anvilMaterial || type == Salvage.anvilMaterial;
}
public static boolean isPistonPiece(BlockState blockState) {
Material type = blockState.getType();
return type == Material.PISTON_MOVING_PIECE || type == Material.AIR;
}
/**
* Get a HashSet containing every transparent block
*

View File

@@ -8,6 +8,7 @@ import org.bukkit.entity.Fish;
import org.bukkit.entity.Player;
import org.bukkit.event.player.PlayerFishEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.metadata.FixedMetadataValue;
import org.bukkit.plugin.PluginManager;
import com.gmail.nossr50.mcMMO;
@@ -15,6 +16,7 @@ import com.gmail.nossr50.datatypes.party.Party;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.player.PlayerProfile;
import com.gmail.nossr50.datatypes.skills.AbilityType;
import com.gmail.nossr50.datatypes.skills.SecondaryAbility;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.datatypes.skills.XPGainReason;
import com.gmail.nossr50.events.experience.McMMOPlayerLevelChangeEvent;
@@ -34,6 +36,7 @@ import com.gmail.nossr50.events.skills.abilities.McMMOPlayerAbilityDeactivateEve
import com.gmail.nossr50.events.skills.fishing.McMMOPlayerFishingTreasureEvent;
import com.gmail.nossr50.events.skills.fishing.McMMOPlayerMagicHunterEvent;
import com.gmail.nossr50.events.skills.repair.McMMOPlayerRepairCheckEvent;
import com.gmail.nossr50.events.skills.secondaryabilities.SecondaryAbilityEvent;
import com.gmail.nossr50.events.skills.unarmed.McMMOPlayerDisarmEvent;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.player.UserManager;
@@ -46,6 +49,13 @@ public class EventUtils {
return event;
}
public static SecondaryAbilityEvent callSecondaryAbilityEvent(Player player, SecondaryAbility secondaryAbility) {
SecondaryAbilityEvent event = new SecondaryAbilityEvent(player, secondaryAbility);
mcMMO.p.getServer().getPluginManager().callEvent(event);
return event;
}
public static FakePlayerAnimationEvent callFakeArmSwingEvent(Player player) {
FakePlayerAnimationEvent event = new FakePlayerAnimationEvent(player);
mcMMO.p.getServer().getPluginManager().callEvent(event);
@@ -194,4 +204,26 @@ public class EventUtils {
return event;
}
/**
* There is a bug in CraftBukkit that causes piston events to
* fire multiple times. Check this method to see if the piston event
* should be processed.
*
* @param block Block object of the piston block
* @param isExtendEvent should be true when called from BlockPistonExtendEvent
*
* @return true if the PistonEvent should be processed, false otherwise
*/
public static boolean shouldProcessEvent(Block block, boolean isExtendEvent) {
String pistonAction = isExtendEvent ? "EXTEND" : "RETRACT";
String lastAction = block.hasMetadata(mcMMO.pistonDataKey) ? block.getMetadata(mcMMO.pistonDataKey).get(0).asString() : "";
if (!lastAction.equals(pistonAction)) {
block.setMetadata(mcMMO.pistonDataKey, new FixedMetadataValue(mcMMO.p, pistonAction));
return true;
}
return false;
}
}

View File

@@ -10,8 +10,10 @@ import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collections;
import java.util.Date;
import java.util.EnumSet;
import java.util.GregorianCalendar;
import java.util.List;
import java.util.Set;
import java.util.regex.Pattern;
import org.bukkit.ChatColor;
@@ -20,11 +22,13 @@ import org.bukkit.DyeColor;
import org.bukkit.FireworkEffect;
import org.bukkit.FireworkEffect.Type;
import org.bukkit.Sound;
import org.bukkit.Statistic;
import org.bukkit.command.CommandSender;
import org.bukkit.command.PluginCommand;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Firework;
import org.bukkit.entity.Player;
import org.bukkit.event.player.PlayerStatisticIncrementEvent;
import org.bukkit.inventory.meta.FireworkMeta;
import com.gmail.nossr50.mcMMO;
@@ -67,8 +71,45 @@ public final class HolidayManager {
}
return null;
}
public static FakeSkillType getByStatistic(Statistic statistic) {
switch (statistic) {
case DAMAGE_TAKEN:
return FakeSkillType.MACHO;
case JUMP:
return FakeSkillType.JUMPING;
case DROP:
return FakeSkillType.THROWING;
case MINE_BLOCK:
case BREAK_ITEM:
return FakeSkillType.WRECKING;
case CRAFT_ITEM:
return FakeSkillType.CRAFTING;
case WALK_ONE_CM:
return FakeSkillType.WALKING;
case SWIM_ONE_CM:
return FakeSkillType.SWIMMING;
case FALL_ONE_CM:
return FakeSkillType.FALLING;
case CLIMB_ONE_CM:
return FakeSkillType.CLIMBING;
case FLY_ONE_CM:
return FakeSkillType.FLYING;
case DIVE_ONE_CM:
return FakeSkillType.DIVING;
case PIG_ONE_CM:
return FakeSkillType.PIGGY;
default:
return FakeSkillType.UNKNOWN;
}
}
}
public final Set<Statistic> movementStatistics = EnumSet.of(
Statistic.WALK_ONE_CM, Statistic.SWIM_ONE_CM, Statistic.FALL_ONE_CM,
Statistic.CLIMB_ONE_CM, Statistic.FLY_ONE_CM, Statistic.DIVE_ONE_CM,
Statistic.PIG_ONE_CM);
static {
List<Color> colors = new ArrayList<Color>();
List<ChatColor> chatColors = new ArrayList<ChatColor>();
@@ -301,8 +342,40 @@ public final class HolidayManager {
return mcMMO.getHolidayManager().getDateRange(day.getTime(), start.getTime(), end.getTime());
}
public void handleStatisticEvent(PlayerStatisticIncrementEvent event) {
Player player = event.getPlayer();
Statistic statistic = event.getStatistic();
int newValue = event.getNewValue();
int modifier;
switch (statistic) {
case DAMAGE_TAKEN:
modifier = 500;
break;
case JUMP:
modifier = 500;
break;
case DROP:
modifier = 200;
break;
case MINE_BLOCK:
case BREAK_ITEM:
modifier = 500;
break;
case CRAFT_ITEM:
modifier = 100;
break;
default:
return;
}
if (newValue % modifier == 0) {
mcMMO.getHolidayManager().levelUpApril(player, FakeSkillType.getByStatistic(statistic));
}
}
public void levelUpApril(Player player, FakeSkillType fakeSkillType) {
int levelTotal = Misc.getRandom().nextInt(UserManager.getPlayer(player).getSkillLevel(SkillType.MINING)) + 1;
int levelTotal = Misc.getRandom().nextInt(1 + UserManager.getPlayer(player).getSkillLevel(SkillType.MINING)) + 1;
player.playSound(player.getLocation(), Sound.LEVEL_UP, Misc.LEVELUP_VOLUME, Misc.LEVELUP_PITCH);
player.sendMessage(ChatColor.YELLOW + StringUtils.getCapitalized(fakeSkillType.toString()) + " skill increased by 1. Total (" + levelTotal + ")");
ParticleEffectUtils.fireworkParticleShower(player, ALL_COLORS.get(Misc.getRandom().nextInt(ALL_COLORS.size())));

View File

@@ -1,12 +1,14 @@
package com.gmail.nossr50.util;
import org.bukkit.ChatColor;
import org.bukkit.CoalType;
import org.bukkit.DyeColor;
import org.bukkit.Material;
import org.bukkit.inventory.FurnaceRecipe;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.Recipe;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.material.Coal;
import org.bukkit.material.Dye;
import com.gmail.nossr50.mcMMO;
@@ -586,6 +588,8 @@ public final class ItemUtils {
case PUMPKIN_SEEDS:
case WATER_LILY:
case VINE:
case LONG_GRASS:
case DOUBLE_PLANT:
return true;
case INK_SACK:
@@ -614,7 +618,6 @@ public final class ItemUtils {
case PORK:
case GRILLED_PORK:
case WOOL:
case RED_ROSE: // Not sure we should include this, as it will also trigger from herbalism
case IRON_INGOT:
case SNOW_BALL:
case BLAZE_ROD:
@@ -627,12 +630,17 @@ public final class ItemUtils {
case ARROW:
case SLIME_BALL:
case NETHER_STAR:
case COAL: // Not sure we should include this, as it will also trigger when mining
case ROTTEN_FLESH:
case GOLD_NUGGET:
case EGG:
return true;
case COAL: // Not sure we should include this, as it will also trigger when mining
return (((Coal) item.getData()).getType() == CoalType.COAL);
case RED_ROSE: // Not sure we should include this, as it will also trigger from herbalism
return (item.getData().getData() == 0x0);
default:
return false;
}
@@ -647,7 +655,9 @@ public final class ItemUtils {
public static boolean isWoodcuttingDrop(ItemStack item) {
switch (item.getType()) {
case LOG:
case LOG_2:
case LEAVES:
case LEAVES_2:
case SAPLING:
case APPLE:
return true;

View File

@@ -1,6 +1,7 @@
package com.gmail.nossr50.util;
import org.bukkit.Material;
import org.bukkit.TreeSpecies;
import org.bukkit.entity.EntityType;
import com.gmail.nossr50.datatypes.party.PartyFeature;
@@ -30,6 +31,10 @@ public class StringUtils {
return createPrettyEnumString(ability.toString());
}
public static String getPrettyTreeSpeciesString(TreeSpecies species) {
return createPrettyEnumString(species.toString());
}
public static String getPrettySecondaryAbilityString(SecondaryAbility secondaryAbility) {
switch (secondaryAbility) {
case HERBALISM_DOUBLE_DROPS:

View File

@@ -11,6 +11,8 @@ import org.bukkit.metadata.FixedMetadataValue;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.google.common.collect.ImmutableList;
public final class UserManager {
private UserManager() {}
@@ -50,8 +52,8 @@ public final class UserManager {
* Save all users ON THIS THREAD.
*/
public static void saveAll() {
Player[] onlinePlayers = mcMMO.p.getServer().getOnlinePlayers();
mcMMO.p.debug("Saving mcMMOPlayers... (" + onlinePlayers.length + ")");
ImmutableList<Player> onlinePlayers = ImmutableList.copyOf(mcMMO.p.getServer().getOnlinePlayers());
mcMMO.p.debug("Saving mcMMOPlayers... (" + onlinePlayers.size() + ")");
for (Player player : onlinePlayers) {
getPlayer(player).getProfile().save();

View File

@@ -7,7 +7,6 @@ import java.util.List;
import java.util.Map;
import org.bukkit.ChatColor;
import org.bukkit.OfflinePlayer;
import org.bukkit.entity.Player;
import org.bukkit.scoreboard.DisplaySlot;
import org.bukkit.scoreboard.Objective;
@@ -23,6 +22,7 @@ import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.player.UserManager;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Lists;
@@ -40,21 +40,21 @@ public class ScoreboardManager {
static final String POWER_LEVEL = LocaleLoader.getString("Scoreboard.Misc.PowerLevel");
static final OfflinePlayer LABEL_POWER_LEVEL = getOfflinePlayer(POWER_LEVEL);
static final OfflinePlayer LABEL_LEVEL = getOfflinePlayer(LocaleLoader.getString("Scoreboard.Misc.Level"));
static final OfflinePlayer LABEL_CURRENT_XP = getOfflinePlayer(LocaleLoader.getString("Scoreboard.Misc.CurrentXP"));
static final OfflinePlayer LABEL_REMAINING_XP = getOfflinePlayer(LocaleLoader.getString("Scoreboard.Misc.RemainingXP"));
static final OfflinePlayer LABEL_ABILITY_COOLDOWN = getOfflinePlayer(LocaleLoader.getString("Scoreboard.Misc.Cooldown"));
static final OfflinePlayer LABEL_OVERALL = getOfflinePlayer(LocaleLoader.getString("Scoreboard.Misc.Overall"));
static final String LABEL_POWER_LEVEL = POWER_LEVEL;
static final String LABEL_LEVEL = LocaleLoader.getString("Scoreboard.Misc.Level");
static final String LABEL_CURRENT_XP = LocaleLoader.getString("Scoreboard.Misc.CurrentXP");
static final String LABEL_REMAINING_XP = LocaleLoader.getString("Scoreboard.Misc.RemainingXP");
static final String LABEL_ABILITY_COOLDOWN = LocaleLoader.getString("Scoreboard.Misc.Cooldown");
static final String LABEL_OVERALL = LocaleLoader.getString("Scoreboard.Misc.Overall");
static final Map<SkillType, OfflinePlayer> skillLabels;
static final Map<AbilityType, OfflinePlayer> abilityLabelsColored;
static final Map<AbilityType, OfflinePlayer> abilityLabelsSkill;
static final Map<SkillType, String> skillLabels;
static final Map<AbilityType, String> abilityLabelsColored;
static final Map<AbilityType, String> abilityLabelsSkill;
static {
ImmutableMap.Builder<SkillType, OfflinePlayer> skillLabelBuilder = ImmutableMap.builder();
ImmutableMap.Builder<AbilityType, OfflinePlayer> abilityLabelBuilder = ImmutableMap.builder();
ImmutableMap.Builder<AbilityType, OfflinePlayer> abilityLabelSkillBuilder = ImmutableMap.builder();
ImmutableMap.Builder<SkillType, String> skillLabelBuilder = ImmutableMap.builder();
ImmutableMap.Builder<AbilityType, String> abilityLabelBuilder = ImmutableMap.builder();
ImmutableMap.Builder<AbilityType, String> abilityLabelSkillBuilder = ImmutableMap.builder();
if (Config.getInstance().getScoreboardRainbows()) {
// Everything but black, gray, gold
@@ -78,36 +78,38 @@ public class ScoreboardManager {
int i = 0;
for (SkillType type : SkillType.values()) {
// Include child skills
skillLabelBuilder.put(type, getOfflinePlayer(colors.get(i) + type.getName()));
skillLabelBuilder.put(type, getShortenedName(colors.get(i) + type.getName(), false));
if (type.getAbility() != null) {
abilityLabelBuilder.put(type.getAbility(), getOfflinePlayer(colors.get(i) + type.getAbility().getName()));
abilityLabelBuilder.put(type.getAbility(), getShortenedName(colors.get(i) + type.getAbility().getName()));
if (type == SkillType.MINING) {
abilityLabelBuilder.put(AbilityType.BLAST_MINING, getOfflinePlayer(colors.get(i) + AbilityType.BLAST_MINING.getName()));
abilityLabelBuilder.put(AbilityType.BLAST_MINING, getShortenedName(colors.get(i) + AbilityType.BLAST_MINING.getName()));
}
}
if (++i == colors.size()) i = 0;
if (++i == colors.size()) {
i = 0;
}
}
}
else {
for (SkillType type : SkillType.values()) {
// Include child skills
skillLabelBuilder.put(type, getOfflinePlayer(ChatColor.GREEN + type.getName()));
skillLabelBuilder.put(type, getShortenedName(ChatColor.GREEN + type.getName()));
if (type.getAbility() != null) {
abilityLabelBuilder.put(type.getAbility(), getOfflinePlayerDots(ChatColor.AQUA + type.getAbility().getName()));
abilityLabelBuilder.put(type.getAbility(), getShortenedName(ChatColor.AQUA + type.getAbility().getName()));
if (type == SkillType.MINING) {
abilityLabelBuilder.put(AbilityType.BLAST_MINING, getOfflinePlayerDots(ChatColor.AQUA + AbilityType.BLAST_MINING.getName()));
abilityLabelBuilder.put(AbilityType.BLAST_MINING, getShortenedName(ChatColor.AQUA + AbilityType.BLAST_MINING.getName()));
}
}
}
}
for (AbilityType type : AbilityType.values()) {
abilityLabelSkillBuilder.put(type, getOfflinePlayerDots((type == AbilityType.BLAST_MINING ? ChatColor.BLUE : ChatColor.AQUA) + type.getName()));
abilityLabelSkillBuilder.put(type, getShortenedName((type == AbilityType.BLAST_MINING ? ChatColor.BLUE : ChatColor.AQUA) + type.getName()));
}
skillLabels = skillLabelBuilder.build();
@@ -117,22 +119,6 @@ public class ScoreboardManager {
private static List<String> dirtyPowerLevels = new ArrayList<String>();
private static OfflinePlayer getOfflinePlayer(String name) {
return getOfflinePlayer(name, false);
}
private static OfflinePlayer getOfflinePlayerDots(String name) {
return getOfflinePlayer(name, true);
}
private static OfflinePlayer getOfflinePlayer(String name, boolean useDots) {
if (name.length() > 16) {
name = useDots ? name.substring(0, 14) + ".." : name.substring(0, 16);
}
return mcMMO.p.getServer().getOfflinePlayer(name);
}
public enum SidebarType {
NONE,
SKILL_BOARD,
@@ -142,6 +128,18 @@ public class ScoreboardManager {
TOP_BOARD;
}
private static String getShortenedName(String name) {
return getShortenedName(name, true);
}
private static String getShortenedName(String name, boolean useDots) {
if (name.length() > 16) {
name = useDots ? name.substring(0, 14) + ".." : name.substring(0, 16);
}
return name;
}
// **** Listener call-ins **** //
// Called by PlayerJoinEvent listener
@@ -161,8 +159,8 @@ public class ScoreboardManager {
// Called in onDisable()
public static void teardownAll() {
Player[] onlinePlayers = mcMMO.p.getServer().getOnlinePlayers();
mcMMO.p.debug("Tearing down scoreboards... (" + onlinePlayers.length + ")");
ImmutableList<Player> onlinePlayers = ImmutableList.copyOf(mcMMO.p.getServer().getOnlinePlayers());
mcMMO.p.debug("Tearing down scoreboards... (" + onlinePlayers.size() + ")");
for (Player player : onlinePlayers) {
teardownPlayer(player);
}
@@ -338,7 +336,7 @@ public class ScoreboardManager {
Player player = mcMMOPlayer.getPlayer();
int power = mcMMOPlayer.getPowerLevel();
mainObjective.getScore(player).setScore(power);
mainObjective.getScore(playerName).setScore(power);
for (ScoreboardWrapper wrapper : PLAYER_SCOREBOARDS.values()) {
wrapper.updatePowerLevel(player, power);
@@ -351,7 +349,7 @@ public class ScoreboardManager {
/**
* Gets or creates the power level objective on the main scoreboard.
* <p>
* <p/>
* If power levels are disabled, the objective is deleted and null is
* returned.
*

View File

@@ -28,7 +28,6 @@ import com.gmail.nossr50.util.scoreboards.ScoreboardManager.SidebarType;
import org.apache.commons.lang.Validate;
public class ScoreboardWrapper {
// Initialization variables
public final String playerName;
private final Scoreboard scoreboard;
@@ -59,7 +58,7 @@ public class ScoreboardWrapper {
powerObjective.setDisplaySlot(DisplaySlot.BELOW_NAME);
for (McMMOPlayer mcMMOPlayer : UserManager.getPlayers()) {
powerObjective.getScore(mcMMOPlayer.getPlayer()).setScore(mcMMOPlayer.getPowerLevel());
powerObjective.getScore(mcMMOPlayer.getProfile().getPlayerName()).setScore(mcMMOPlayer.getPowerLevel());
}
}
}
@@ -69,6 +68,7 @@ public class ScoreboardWrapper {
}
public BukkitTask updateTask = null;
private class ScoreboardQuickUpdate extends BukkitRunnable {
@Override
public void run() {
@@ -78,6 +78,7 @@ public class ScoreboardWrapper {
}
public BukkitTask revertTask = null;
private class ScoreboardChangeTask extends BukkitRunnable {
@Override
public void run() {
@@ -87,6 +88,7 @@ public class ScoreboardWrapper {
}
public BukkitTask cooldownTask = null;
private class ScoreboardCooldownTask extends BukkitRunnable {
@Override
public void run() {
@@ -121,7 +123,8 @@ public class ScoreboardWrapper {
try {
cooldownTask.cancel();
}
catch (Throwable ignored) {}
catch (Throwable ignored) {
}
cooldownTask = null;
}
@@ -274,7 +277,7 @@ public class ScoreboardWrapper {
targetProfile = null;
leaderboardPage = -1;
loadObjective(ScoreboardManager.skillLabels.get(skill).getName());
loadObjective(ScoreboardManager.skillLabels.get(skill));
}
public void setTypeSelfStats() {
@@ -355,7 +358,7 @@ public class ScoreboardWrapper {
int endPosition = page * 15;
int startPosition = endPosition - 14;
loadObjective(String.format("%s (%2d - %2d)", ScoreboardManager.skillLabels.get(skill).getName(), startPosition, endPosition));
loadObjective(String.format("%s (%2d - %2d)", ScoreboardManager.skillLabels.get(skill), startPosition, endPosition));
}
// Setup for after a board type change
@@ -381,7 +384,8 @@ public class ScoreboardWrapper {
try {
updateTask.cancel();
}
catch (Throwable ignored) {} // catch NullPointerException and IllegalStateException and any Error; don't care
catch (Throwable ignored) {
} // catch NullPointerException and IllegalStateException and any Error; don't care
updateTask = null;
@@ -399,123 +403,123 @@ public class ScoreboardWrapper {
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
switch (sidebarType) {
case NONE:
break;
case NONE:
break;
case SKILL_BOARD:
Validate.notNull(targetSkill);
case SKILL_BOARD:
Validate.notNull(targetSkill);
if (!targetSkill.isChildSkill()) {
int currentXP = mcMMOPlayer.getSkillXpLevel(targetSkill);
if (!targetSkill.isChildSkill()) {
int currentXP = mcMMOPlayer.getSkillXpLevel(targetSkill);
sidebarObjective.getScore(ScoreboardManager.LABEL_CURRENT_XP).setScore(currentXP);
sidebarObjective.getScore(ScoreboardManager.LABEL_REMAINING_XP).setScore(mcMMOPlayer.getXpToLevel(targetSkill) - currentXP);
}
else {
for (SkillType parentSkill : FamilyTree.getParents(targetSkill)) {
sidebarObjective.getScore(ScoreboardManager.skillLabels.get(parentSkill)).setScore(mcMMOPlayer.getSkillLevel(parentSkill));
}
}
sidebarObjective.getScore(ScoreboardManager.LABEL_LEVEL).setScore(mcMMOPlayer.getSkillLevel(targetSkill));
if (targetSkill.getAbility() != null) {
boolean stopUpdating;
if (targetSkill == SkillType.MINING) {
// Special-Case: Mining has two abilities, both with cooldowns
Score cooldownSB = sidebarObjective.getScore(ScoreboardManager.abilityLabelsSkill.get(AbilityType.SUPER_BREAKER));
Score cooldownBM = sidebarObjective.getScore(ScoreboardManager.abilityLabelsSkill.get(AbilityType.BLAST_MINING));
int secondsSB = Math.max(mcMMOPlayer.calculateTimeRemaining(AbilityType.SUPER_BREAKER), 0);
int secondsBM = Math.max(mcMMOPlayer.calculateTimeRemaining(AbilityType.BLAST_MINING), 0);
cooldownSB.setScore(secondsSB);
cooldownBM.setScore(secondsBM);
stopUpdating = (secondsSB == 0 && secondsBM == 0);
sidebarObjective.getScore(ScoreboardManager.LABEL_CURRENT_XP).setScore(currentXP);
sidebarObjective.getScore(ScoreboardManager.LABEL_REMAINING_XP).setScore(mcMMOPlayer.getXpToLevel(targetSkill) - currentXP);
}
else {
AbilityType ability = targetSkill.getAbility();
Score cooldown = sidebarObjective.getScore(ScoreboardManager.abilityLabelsSkill.get(ability));
for (SkillType parentSkill : FamilyTree.getParents(targetSkill)) {
sidebarObjective.getScore(ScoreboardManager.skillLabels.get(parentSkill)).setScore(mcMMOPlayer.getSkillLevel(parentSkill));
}
}
sidebarObjective.getScore(ScoreboardManager.LABEL_LEVEL).setScore(mcMMOPlayer.getSkillLevel(targetSkill));
if (targetSkill.getAbility() != null) {
boolean stopUpdating;
if (targetSkill == SkillType.MINING) {
// Special-Case: Mining has two abilities, both with cooldowns
Score cooldownSB = sidebarObjective.getScore(ScoreboardManager.abilityLabelsSkill.get(AbilityType.SUPER_BREAKER));
Score cooldownBM = sidebarObjective.getScore(ScoreboardManager.abilityLabelsSkill.get(AbilityType.BLAST_MINING));
int secondsSB = Math.max(mcMMOPlayer.calculateTimeRemaining(AbilityType.SUPER_BREAKER), 0);
int secondsBM = Math.max(mcMMOPlayer.calculateTimeRemaining(AbilityType.BLAST_MINING), 0);
cooldownSB.setScore(secondsSB);
cooldownBM.setScore(secondsBM);
stopUpdating = (secondsSB == 0 && secondsBM == 0);
}
else {
AbilityType ability = targetSkill.getAbility();
Score cooldown = sidebarObjective.getScore(ScoreboardManager.abilityLabelsSkill.get(ability));
int seconds = Math.max(mcMMOPlayer.calculateTimeRemaining(ability), 0);
cooldown.setScore(seconds);
stopUpdating = seconds == 0;
}
if (stopUpdating) {
stopCooldownUpdating();
}
else {
startCooldownUpdating();
}
}
break;
case COOLDOWNS_BOARD:
boolean anyCooldownsActive = false;
for (AbilityType ability : AbilityType.values()) {
int seconds = Math.max(mcMMOPlayer.calculateTimeRemaining(ability), 0);
cooldown.setScore(seconds);
if (seconds != 0) {
anyCooldownsActive = true;
}
stopUpdating = seconds == 0;
sidebarObjective.getScore(ScoreboardManager.abilityLabelsColored.get(ability)).setScore(seconds);
}
if (stopUpdating) {
stopCooldownUpdating();
}
else {
if (anyCooldownsActive) {
startCooldownUpdating();
}
}
break;
else {
stopCooldownUpdating();
}
break;
case COOLDOWNS_BOARD:
boolean anyCooldownsActive = false;
case STATS_BOARD:
// Select the profile to read from
PlayerProfile newProfile;
for (AbilityType ability : AbilityType.values()) {
int seconds = Math.max(mcMMOPlayer.calculateTimeRemaining(ability), 0);
if (seconds != 0) {
anyCooldownsActive = true;
if (targetProfile != null) {
newProfile = targetProfile; // offline
}
else if (targetPlayer == null) {
newProfile = mcMMOPlayer.getProfile(); // self
}
else {
newProfile = UserManager.getPlayer(targetPlayer).getProfile(); // online
}
sidebarObjective.getScore(ScoreboardManager.abilityLabelsColored.get(ability)).setScore(seconds);
}
// Calculate power level here
int powerLevel = 0;
for (SkillType skill : SkillType.NON_CHILD_SKILLS) { // Don't include child skills, makes the list too long
int level = newProfile.getSkillLevel(skill);
if (anyCooldownsActive) {
startCooldownUpdating();
}
else {
stopCooldownUpdating();
}
break;
powerLevel += level;
case STATS_BOARD:
// Select the profile to read from
PlayerProfile newProfile;
// TODO: Verify that this is what we want - calculated in power level but not displayed
if (!skill.getPermissions(player)) {
continue;
}
if (targetProfile != null) {
newProfile = targetProfile; // offline
}
else if (targetPlayer == null) {
newProfile = mcMMOPlayer.getProfile(); // self
}
else {
newProfile = UserManager.getPlayer(targetPlayer).getProfile(); // online
}
// Calculate power level here
int powerLevel = 0;
for (SkillType skill : SkillType.NON_CHILD_SKILLS) { // Don't include child skills, makes the list too long
int level = newProfile.getSkillLevel(skill);
powerLevel += level;
// TODO: Verify that this is what we want - calculated in power level but not displayed
if (!skill.getPermissions(player)) {
continue;
sidebarObjective.getScore(ScoreboardManager.skillLabels.get(skill)).setScore(level);
}
sidebarObjective.getScore(ScoreboardManager.skillLabels.get(skill)).setScore(level);
}
sidebarObjective.getScore(ScoreboardManager.LABEL_POWER_LEVEL).setScore(powerLevel);
break;
sidebarObjective.getScore(ScoreboardManager.LABEL_POWER_LEVEL).setScore(powerLevel);
break;
case RANK_BOARD:
case TOP_BOARD:
case RANK_BOARD:
case TOP_BOARD:
/*
* @see #acceptRankData(Map<SkillType, Integer> rank)
* @see #acceptLeaderboardData(List<PlayerStat> stats)
*/
break;
break;
default:
break;
default:
break;
}
}
@@ -550,11 +554,11 @@ public class ScoreboardWrapper {
name = ChatColor.GOLD + "--You--";
}
sidebarObjective.getScore(mcMMO.p.getServer().getOfflinePlayer(name)).setScore(stat.statVal);
sidebarObjective.getScore(name).setScore(stat.statVal);
}
}
public void updatePowerLevel(Player player, int newPowerLevel) {
powerObjective.getScore(player).setScore(newPowerLevel);
powerObjective.getScore(player.getName()).setScore(newPowerLevel);
}
}

View File

@@ -1,5 +1,9 @@
package com.gmail.nossr50.util.skills;
import java.util.EnumMap;
import java.util.HashMap;
import java.util.Map;
import org.bukkit.Material;
import org.bukkit.entity.AnimalTamer;
import org.bukkit.entity.Animals;
@@ -15,10 +19,11 @@ import org.bukkit.entity.Wolf;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.event.entity.EntityDamageEvent.DamageModifier;
import org.bukkit.inventory.ItemStack;
import org.bukkit.projectiles.ProjectileSource;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.config.experience.ExperienceConfig;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.skills.SkillType;
@@ -43,12 +48,16 @@ import com.gmail.nossr50.util.MobHealthbarUtils;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.player.UserManager;
import com.google.common.collect.ImmutableMap;
public final class CombatUtils {
private CombatUtils() {}
private static void processSwordCombat(LivingEntity target, Player player, double damage) {
private static void processSwordCombat(LivingEntity target, Player player, EntityDamageByEntityEvent event) {
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
SwordsManager swordsManager = mcMMOPlayer.getSwordsManager();
double initialDamage = event.getDamage();
Map<DamageModifier, Double> modifiers = getModifiers(event);
if (swordsManager.canActivateAbility()) {
mcMMOPlayer.checkAbilityActivation(SkillType.SWORDS);
@@ -59,7 +68,7 @@ public final class CombatUtils {
}
if (swordsManager.canUseSerratedStrike()) {
swordsManager.serratedStrikes(target, damage);
swordsManager.serratedStrikes(target, initialDamage, modifiers);
}
startGainXp(mcMMOPlayer, target, SkillType.SWORDS);
@@ -68,6 +77,7 @@ public final class CombatUtils {
private static void processAxeCombat(LivingEntity target, Player player, EntityDamageByEntityEvent event) {
double initialDamage = event.getDamage();
double finalDamage = initialDamage;
Map<DamageModifier, Double> modifiers = getModifiers(event);
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
AxesManager axesManager = mcMMOPlayer.getAxesManager();
@@ -77,7 +87,7 @@ public final class CombatUtils {
}
if (axesManager.canUseAxeMastery()) {
finalDamage += axesManager.axeMastery(target);
finalDamage += axesManager.axeMastery();
}
if (axesManager.canCriticalHit(target)) {
@@ -92,10 +102,10 @@ public final class CombatUtils {
}
if (axesManager.canUseSkullSplitter(target)) {
axesManager.skullSplitterCheck(target, initialDamage);
axesManager.skullSplitterCheck(target, initialDamage, modifiers);
}
event.setDamage(finalDamage);
applyScaledModifiers(initialDamage, finalDamage, event);
startGainXp(mcMMOPlayer, target, SkillType.AXES);
}
@@ -111,18 +121,18 @@ public final class CombatUtils {
}
if (unarmedManager.canUseIronArm()) {
finalDamage += unarmedManager.ironArm(target);
finalDamage += unarmedManager.ironArm();
}
if (unarmedManager.canUseBerserk()) {
finalDamage += unarmedManager.berserkDamage(target, initialDamage);
finalDamage += unarmedManager.berserkDamage(initialDamage);
}
if (unarmedManager.canDisarm(target)) {
unarmedManager.disarmCheck((Player) target);
}
event.setDamage(finalDamage);
applyScaledModifiers(initialDamage, finalDamage, event);
startGainXp(mcMMOPlayer, target, SkillType.UNARMED);
}
@@ -138,14 +148,14 @@ public final class CombatUtils {
}
if (tamingManager.canUseSharpenedClaws()) {
finalDamage += tamingManager.sharpenedClaws(target, wolf);
finalDamage += tamingManager.sharpenedClaws();
}
if (tamingManager.canUseGore()) {
finalDamage += tamingManager.gore(target, initialDamage, wolf);
finalDamage += tamingManager.gore(target, initialDamage);
}
event.setDamage(finalDamage);
applyScaledModifiers(initialDamage, finalDamage, event);
startGainXp(mcMMOPlayer, target, SkillType.TAMING);
}
@@ -169,11 +179,11 @@ public final class CombatUtils {
}
if (archeryManager.canSkillShot()) {
finalDamage += archeryManager.skillShot(target, initialDamage, arrow);
finalDamage += archeryManager.skillShot(initialDamage);
}
if (archeryManager.canDaze(target)) {
finalDamage += archeryManager.daze((Player) target, arrow);
finalDamage += archeryManager.daze((Player) target);
}
if (!arrow.hasMetadata(mcMMO.infiniteArrowKey) && archeryManager.canRetrieveArrows()) {
@@ -182,7 +192,7 @@ public final class CombatUtils {
archeryManager.distanceXpBonus(target, arrow);
event.setDamage(finalDamage);
applyScaledModifiers(initialDamage, finalDamage, event);
startGainXp(mcMMOPlayer, target, SkillType.ARCHERY, arrow.getMetadata(mcMMO.bowForceKey).get(0).asDouble());
}
@@ -226,7 +236,7 @@ public final class CombatUtils {
}
if (SkillType.SWORDS.getPermissions(player)) {
processSwordCombat(target, player, event.getDamage());
processSwordCombat(target, player, event);
}
}
else if (ItemUtils.isAxe(heldItem)) {
@@ -263,10 +273,10 @@ public final class CombatUtils {
}
else if (entityType == EntityType.ARROW) {
Arrow arrow = (Arrow) damager;
LivingEntity shooter = arrow.getShooter();
ProjectileSource projectileSource = arrow.getShooter();
if (shooter != null && shooter instanceof Player && SkillType.ARCHERY.shouldProcess(target)) {
Player player = (Player) shooter;
if (projectileSource != null && projectileSource instanceof Player && SkillType.ARCHERY.shouldProcess(target)) {
Player player = (Player) projectileSource;
if (!Misc.isNPCEntity(player) && SkillType.ARCHERY.getPermissions(player)) {
processArcheryCombat(target, player, event, arrow);
@@ -307,6 +317,7 @@ public final class CombatUtils {
* @param target LivingEntity which to attempt to damage
* @param damage Amount of damage to attempt to do
*/
@Deprecated
public static void dealDamage(LivingEntity target, double damage) {
dealDamage(target, damage, DamageCause.CUSTOM, null);
}
@@ -318,6 +329,7 @@ public final class CombatUtils {
* @param damage Amount of damage to attempt to do
* @param attacker Player to pass to event as damager
*/
@Deprecated
public static void dealDamage(LivingEntity target, double damage, LivingEntity attacker) {
dealDamage(target, damage, DamageCause.ENTITY_ATTACK, attacker);
}
@@ -329,6 +341,23 @@ public final class CombatUtils {
* @param damage Amount of damage to attempt to do
* @param attacker Player to pass to event as damager
*/
public static void dealDamage(LivingEntity target, double damage, Map<DamageModifier, Double> modifiers, LivingEntity attacker) {
if (target.isDead()) {
return;
}
// Aren't we applying the damage twice????
target.damage(callFakeDamageEvent(attacker, target, damage, modifiers));
}
/**
* Attempt to damage target for value dmg with reason ENTITY_ATTACK with damager attacker
*
* @param target LivingEntity which to attempt to damage
* @param damage Amount of damage to attempt to do
* @param attacker Player to pass to event as damager
*/
@Deprecated
public static void dealDamage(LivingEntity target, double damage, DamageCause cause, Entity attacker) {
if (target.isDead()) {
return;
@@ -345,7 +374,7 @@ public final class CombatUtils {
* @param damage The initial damage amount
* @param type The type of skill being used
*/
public static void applyAbilityAoE(Player attacker, LivingEntity target, double damage, SkillType type) {
public static void applyAbilityAoE(Player attacker, LivingEntity target, double damage, Map<DamageModifier, Double> modifiers, SkillType type) {
int numberOfTargets = getTier(attacker.getItemInHand()); // The higher the weapon tier, the more targets you hit
double damageAmount = Math.max(damage, 1);
@@ -381,7 +410,7 @@ public final class CombatUtils {
break;
}
dealDamage(livingEntity, damageAmount, attacker);
dealDamage(livingEntity, damageAmount, modifiers, attacker);
numberOfTargets--;
}
}
@@ -566,23 +595,79 @@ public final class CombatUtils {
return false;
}
@Deprecated
public static double callFakeDamageEvent(Entity attacker, Entity target, double damage) {
return callFakeDamageEvent(attacker, target, DamageCause.ENTITY_ATTACK, damage);
return callFakeDamageEvent(attacker, target, DamageCause.ENTITY_ATTACK, new EnumMap<DamageModifier, Double>(ImmutableMap.of(DamageModifier.BASE, damage)));
}
public static double callFakeDamageEvent(Entity attacker, Entity target, DamageCause cause, double damage) {
if (Config.getInstance().getEventCallbackEnabled()) {
EntityDamageEvent damageEvent = attacker == null ? new FakeEntityDamageEvent(target, cause, damage) : new FakeEntityDamageByEntityEvent(attacker, target, cause, damage);
mcMMO.p.getServer().getPluginManager().callEvent(damageEvent);
@Deprecated
public static double callFakeDamageEvent(Entity attacker, Entity target, DamageCause damageCause, double damage) {
return callFakeDamageEvent(attacker, target, damageCause, new EnumMap<DamageModifier, Double>(ImmutableMap.of(DamageModifier.BASE, damage)));
}
if (damageEvent.isCancelled()) {
return 0;
}
public static double callFakeDamageEvent(Entity attacker, Entity target, Map<DamageModifier, Double> modifiers) {
return callFakeDamageEvent(attacker, target, DamageCause.ENTITY_ATTACK, modifiers);
}
damage = damageEvent.getDamage();
public static double callFakeDamageEvent(Entity attacker, Entity target, double damage, Map<DamageModifier, Double> modifiers) {
return callFakeDamageEvent(attacker, target, DamageCause.ENTITY_ATTACK, getScaledModifiers(damage, modifiers));
}
public static double callFakeDamageEvent(Entity attacker, Entity target, DamageCause cause, Map<DamageModifier, Double> modifiers) {
EntityDamageEvent damageEvent = attacker == null ? new FakeEntityDamageEvent(target, cause, modifiers) : new FakeEntityDamageByEntityEvent(attacker, target, cause, modifiers);
mcMMO.p.getServer().getPluginManager().callEvent(damageEvent);
if (damageEvent.isCancelled()) {
return 0;
}
return damage;
return damageEvent.getFinalDamage();
}
private static Map<DamageModifier, Double> getModifiers(EntityDamageEvent event) {
Map<DamageModifier, Double> modifiers = new HashMap<DamageModifier, Double>();
for (DamageModifier modifier : DamageModifier.values()) {
modifiers.put(modifier, event.getDamage(modifier));
}
return modifiers;
}
private static Map<DamageModifier, Double> getScaledModifiers(double damage, Map<DamageModifier, Double> modifiers) {
Map<DamageModifier, Double> scaledModifiers = new HashMap<DamageModifier, Double>();
for (DamageModifier modifier : DamageModifier.values()) {
if (modifier == DamageModifier.BASE) {
modifiers.put(modifier, damage);
continue;
}
scaledModifiers.put(modifier, damage * modifiers.get(modifier));
}
return scaledModifiers;
}
public static EntityDamageByEntityEvent applyScaledModifiers(double initialDamage, double finalDamage, EntityDamageByEntityEvent event) {
// No additional damage
if (initialDamage == finalDamage) {
return event;
}
for (DamageModifier modifier : DamageModifier.values()) {
if (!event.isApplicable(modifier)) {
continue;
}
if (modifier == DamageModifier.BASE) {
event.setDamage(modifier, finalDamage);
continue;
}
event.setDamage(modifier, finalDamage / initialDamage * event.getDamage(modifier));
}
return event;
}
/**

View File

@@ -24,8 +24,10 @@ import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.skills.AbilityType;
import com.gmail.nossr50.datatypes.skills.SecondaryAbility;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.events.skills.secondaryabilities.SecondaryAbilityEvent;
import com.gmail.nossr50.events.skills.secondaryabilities.SecondaryAbilityWeightedActivationCheckEvent;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.EventUtils;
import com.gmail.nossr50.util.ItemUtils;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.StringUtils;
@@ -205,13 +207,25 @@ public class SkillUtils {
double chance = (maxChance / maxLevel) * Math.min(skillLevel, maxLevel) / activationChance;
SecondaryAbilityWeightedActivationCheckEvent event = new SecondaryAbilityWeightedActivationCheckEvent(player, skillAbility, chance);
mcMMO.p.getServer().getPluginManager().callEvent(event);
return (event.getChance() * activationChance) > Misc.getRandom().nextInt(activationChance);
return (event.getChance() * activationChance) > Misc.getRandom().nextInt(activationChance) && !event.isCancelled();
}
public static boolean activationSuccessful(SecondaryAbility skillAbility, Player player, double staticChance, int activationChance) {
double chance = staticChance / activationChance;
SecondaryAbilityWeightedActivationCheckEvent event = new SecondaryAbilityWeightedActivationCheckEvent(player, skillAbility, chance);
mcMMO.p.getServer().getPluginManager().callEvent(event);
return (event.getChance() * activationChance) > Misc.getRandom().nextInt(activationChance) && !event.isCancelled();
}
public static boolean activationSuccessful(SecondaryAbility skillAbility, Player player) {
SecondaryAbilityEvent event = EventUtils.callSecondaryAbilityEvent(player, skillAbility);
return !event.isCancelled();
}
public static boolean treasureDropSuccessful(Player player, double dropChance, int activationChance) {
SecondaryAbilityWeightedActivationCheckEvent event = new SecondaryAbilityWeightedActivationCheckEvent(player, SecondaryAbility.EXCAVATION_TREASURE_HUNTER, dropChance / activationChance);
mcMMO.p.getServer().getPluginManager().callEvent(event);
return (event.getChance() * activationChance) > (Misc.getRandom().nextDouble() * activationChance);
return (event.getChance() * activationChance) > (Misc.getRandom().nextDouble() * activationChance) && !event.isCancelled();
}
private static boolean isLocalizedSkill(String skillName) {

View File

@@ -17,8 +17,6 @@ General:
# Allow mcMMO to check if a new version is available
Update_Check: true
Prefer_Beta: false
# Allow mcMMO to inform other plugins of damage being dealt
Event_Callback: true
Power_Level_Cap: 0
# Should mcMMO print out debug messages?
Verbose_Logging: false
@@ -294,6 +292,7 @@ Skills:
Fishing:
Level_Cap: 0
Drops_Enabled: true
Override_Vanilla_Treasures: true
# Always catch fish, even when treasure is found
Extra_Fish: false
Herbalism:
@@ -394,10 +393,12 @@ Double_Drops:
Sandstone: true
Stone: true
Woodcutting:
Oak: true
Acacia: true
Birch: true
Spruce: true
Dark_Oak: true
Generic: true
Jungle: true
Redwood: true
#
# Settings for commands

View File

@@ -80,9 +80,22 @@ Experience:
# FeatherFall_Multiplier: Multiply Acrobatics XP by this value when wearing boots with the Feather Fall enchant
FeatherFall_Multiplier: 2.0
Alchemy:
Potion: 120
# Alchemy potion stages are based on the number of ingredients added
# Potion_Stage_1 represents a base potion
# Potion_Stage_2 represents a base potion with one ingredient
# Potion_Stage_3 represents a base potion with one ingredient and one amplifier
# Potion_Stage_4 represents a base potion with one ingredient and two amplifiers
# Potion_Stage_5 represents a base potion with one ingredient where the amplifiers are swapped
Potion_Stage_1: 15
Potion_Stage_2: 30
Potion_Stage_3: 60
Potion_Stage_4: 120
Potion_Stage_5: 0
Fishing:
Base: 800
Raw_Fish: 800
Raw_Salmon: 800
Clownfish: 800
Pufferfish: 800
Shake: 50
Excavation:
Clay: 40
@@ -95,27 +108,46 @@ Experience:
Snow_Block: 40
Soul_Sand: 40
Woodcutting:
Oak: 70
Spruce: 80
Acacia: 90
Birch: 90
Dark_Oak: 90
Generic: 70
Jungle: 100
Redwood: 80
Huge_Mushroom_Red: 70
Huge_Mushroom_Brown: 70
Herbalism:
Allium: 300
Azure_Bluet: 150
Blue_Orchid: 150
Brown_Mushroom: 150
Cactus: 30
Carrot: 50
Cocoa: 30
Crops: 50
Dead_Bush: 30
Lilac: 50
Melon_Block: 20
Nether_Warts: 50
Orange_Tulip: 150
Oxeye_Daisy: 150
Peony: 50
Pink_Tulip: 150
Poppy: 100
Potato: 50
Pumpkin: 20
Red_Mushroom: 150
Red_Rose: 100
Red_Tulip: 150
Rose_Bush: 50
Small_Fern: 10
Small_Grass: 10
Sugar_Cane_Block: 30
Sunflower: 50
Tall_Grass: 50
Tall_Fern: 50
Vine: 10
Water_Lily: 100
White_Tulip: 150
Yellow_Flower: 100
Mining:
Coal_Ore: 100
@@ -124,14 +156,17 @@ Experience:
Ender_Stone: 150
Glowstone: 30
Gold_Ore: 350
Hard_Clay: 30
Iron_Ore: 250
Lapis_Ore: 400
Mossy_Cobblestone: 30
Netherrack: 30
Obsidian: 150
Packed_Ice: 50
Quartz_Ore: 100
Redstone_Ore: 150
Sandstone: 30
Stained_Clay: 50
Stone: 30
Repair:
Base: 1000.0

View File

@@ -95,7 +95,6 @@ Fishing.Effect.10=Ryba\u0159en\u00ed v ledu
Fishing.Effect.11=Umo\u017e\u0148uje v\u00e1m ryba\u0159it v ledov\u00fdch prost\u0159ed\u00edch
Fishing.Chance.Raining=[[BLUE]] De\u0161\u0165ov\u00fd bonus
Fishing.Listener=Rybareni:
Fishing.Ability.TH.ItemFound=[[GRAY]]Nasel si poklad!
Fishing.Ability.TH.MagicFound=[[GRAY]]C\u00edt\u00edte dotek magie s t\u00edmto \u00falovkem...
Fishing.SkillName=RYBARENI
Fishing.Skillup=[[YELLOW]]Dovednost v rybareni byla navysena o {0}. Celkem ({1})

View File

@@ -87,7 +87,6 @@ Fishing.Effect.6=Fisherman\'s Diet
Fishing.Effect.7=Improves hunger restored from fished foods
Fishing.Chance.Raining=[[BLUE]] Rain Bonus
Fishing.Listener=Fishing:
Fishing.Ability.TH.ItemFound=[[GRAY]]Treasure found!
Fishing.Ability.TH.MagicFound=[[GRAY]]You feel a touch of magic with this catch...
Fishing.SkillName=FISHING
Fishing.Skillup=[[YELLOW]]Fishing skill increased by {0}. Total ({1})

View File

@@ -87,7 +87,6 @@ Fishing.Effect.6=Fiskers Diet
Fishing.Effect.7=Forbedrer Sult genoprettet af Fisked mad
Fishing.Chance.Raining=[[BLUE]] Regn Bonus
Fishing.Listener=Fiskeri:
Fishing.Ability.TH.ItemFound=[[GRAY]Du har fundet en skat!
Fishing.Ability.TH.MagicFound=[[GRAY]]Du f\u00f8ler et strejf a magi med denne fangst...
Fishing.SkillName=FISKER
Fishing.Skillup=[[YELLOW]]Fisker evne for\u00f8get med {0}. Total ({1})

View File

@@ -87,7 +87,6 @@ Fishing.Effect.6=Fischer-Mahlzeit
Fishing.Effect.7=Verbessert Effizienz von geangelter Nahrung
Fishing.Chance.Raining=[[BLUE]] Rain Bonus
Fishing.Listener=Angeln:
Fishing.Ability.TH.ItemFound=[[AQUA]]Du hast einen Schatz gefunden!
Fishing.Ability.TH.MagicFound=[[AQUA]]Dich ber\u00fchrt ein leichter Zauber bei diesem Fang...
Fishing.SkillName=ANGELN
Fishing.Skillup=[[YELLOW]]Angel Skill um {0} gestiegen. Gesamt ({1})

View File

@@ -137,7 +137,6 @@ Fishing.Effect.10=Ice Fishing
Fishing.Effect.11=Allows you to fish in icy biomes
Fishing.Chance.Raining=[[BLUE]] Rain Bonus
Fishing.Listener=Fishing:
Fishing.Ability.TH.ItemFound=[[GRAY]]Treasure found!
Fishing.Ability.TH.MagicFound=[[GRAY]]You feel a touch of magic with this catch...
Fishing.Ability.TH.Boom=[[GRAY]]BOOM TIME!!!
Fishing.Ability.TH.Poison=[[GRAY]]Something doesn't smell quite right...

View File

@@ -96,7 +96,6 @@ Fishing.Effect.10=Pesca de hielo
Fishing.Effect.11=Te permite pescar en biomas de hielo
Fishing.Chance.Raining=[[BLUE]] Lluvia de Bonus
Fishing.Listener=Pescador:
Fishing.Ability.TH.ItemFound=[[GRAY]]\u00a1Tesoro encontrado!
Fishing.Ability.TH.MagicFound=[[GRAY]]Sientes un toque de magia con esta pesca...
Fishing.SkillName=PESCADOR
Fishing.Skillup=[[YELLOW]]Habilidad de Pescador incrementada en {0}. Total ({1})

View File

@@ -2,7 +2,6 @@ Acrobatics.Listener=Akrobaatika:
Acrobatics.SkillName=AKROBAATIKA
Acrobatics.Skillup=[[YELLOW]]Akrobaatika oskus kasvanud {0} v\u00f5rra. Kokku ({1})
Archery.Skillup=[[YELLOW]]Vibunduse oskus kasvanud {0} v\u00f5rra. Kokku ({1})
Fishing.Ability.TH.ItemFound=[[GRAY]]Varandus leitud!
Mining.Ability.Lower=[[GRAY]]**TE LANGETASITE OMA KIRKA**
Mining.Ability.Ready=[[GREEN]]**TE PANITE OMA KIRKA VALMIS**
Mining.Listener=Kaevandamine:

View File

@@ -36,7 +36,6 @@ Excavation.Skills.GigaDrillBreaker.On=[[GREEN]]**TEHO PORA HAJOITUS AKTIVOITU**
Excavation.Skillup=[[YELLOW]]Kaivuu taito nousi {0} tasolla. Kokonaism\u00e4\u00e4r\u00e4 ({1})
Fishing.Effect.0=Aarteenmets\u00e4st\u00e4j\u00e4 (Passiivinen)
Fishing.Listener=Kalastus:
Fishing.Ability.TH.ItemFound=[[GRAY]]Treasure found!
Fishing.Ability.TH.MagicFound=[[GRAY]]You feel a touch of magic with this catch...
Fishing.SkillName=KALASTUS
Fishing.Skillup=[[YELLOW]]Kalastustaito nousi {0} tasolla. Kokonaism\u00e4\u00e4r\u00e4 ({1})

View File

@@ -87,7 +87,6 @@ Fishing.Effect.6=R\u00e9gime de fermier
Fishing.Effect.7=Am\u00e9liore la nutrition des produits de la ferme
Fishing.Chance.Raining=[[BLUE]] Bonus de pluie
Fishing.Listener=P\u00eache :
Fishing.Ability.TH.ItemFound=[[GRAY]]Tr\u00e9sor d\u00e9couvert !
Fishing.Ability.TH.MagicFound=[[GRAY]]Vous ressentez quelque chose de magique dans cette prise...
Fishing.SkillName=P\u00caCHE
Fishing.Skillup=[[YELLOW]]Le talent p\u00eache augmente de {0}. Total ({1})

View File

@@ -25,7 +25,6 @@ Excavation.Skills.GigaDrillBreaker.Other.On=[[GREEN]]{0}[[DARK_GREEN]] haszn\u00
Excavation.Skillup=[[YELLOW]]\u00c1s\u00e1s fejl\u0151d\u00f6tt {0} szinttel. \u00d6sszesen: ({1})
Fishing.Effect.10=J\u00e9g Horg\u00e1szat
Fishing.Listener=Horg\u00e1szat:
Fishing.Ability.TH.ItemFound=[[GRAY]]Kincs megtal\u00e1lva!
Fishing.SkillName=HORG\u00c1SZAT
Herbalism.Ability.Lower=[[GRAY]]**LETETTED A KAP\u00c1DAT**
Herbalism.Ability.Ready=[[GREEN]]**EL\u0150K\u00c9SZ\u00cdTETTED A KAP\u00c1DAT**

View File

@@ -98,7 +98,6 @@ Fishing.Effect.10=\uc5bc\uc74c \ub09a\uc2dc
Fishing.Effect.11=\uc5bc\uc74c\uc774 \ub36e\ud600\uc788\ub294 \ud658\uacbd\uc5d0\uc11c \ub09a\uc2dc \uac00\ub2a5
Fishing.Chance.Raining=[[BLUE]] \ube44 \ubcf4\ub108\uc2a4
Fishing.Listener=\ub09a\uc2dc(FISHING):
Fishing.Ability.TH.ItemFound=[[GRAY]]\ubcf4\ubb3c \ubc1c\uacac!
Fishing.Ability.TH.MagicFound=[[GRAY]]\uc774 \uc785\uc9c8\uc5d0\uc11c \ub9c8\ubc95\uc774 \ub290\uaef4\uc9d1\ub2c8\ub2e4...
Fishing.Ability.TH.Boom=[[GRAY]]\ud3ed\ubc1c \uc2dc\uac04!!!
Fishing.Ability.TH.Poison=[[GRAY]]\ubb54\uac00 \uaf64 \uad1c\ucc2e\uc740 \ub0c4\uc0c8\uac00 \ub098\uc9c0 \uc54a\uc2b5\ub2c8\ub2e4...

View File

@@ -76,7 +76,6 @@ Fishing.Effect.10=Ijs Vissen
Fishing.Effect.11=Stelt je in staat om te vissen in de ijzige biomen
Fishing.Chance.Raining=[[BLUE]] Regen Bonus
Fishing.Listener=Vissen:
Fishing.Ability.TH.ItemFound=[[GRAY]]Schat gevonden!
Fishing.Ability.TH.MagicFound=[[GRAY]]Jij voelt een vleugje magie met deze vangst...
Fishing.SkillName=VISSEN
Herbalism.Ability.FD=[[RED]]Boeren Dieet: [[YELLOW]]Rank {0}

View File

@@ -94,7 +94,6 @@ Fishing.Effect.10=Lodowe lowienie ryb
Fishing.Effect.11=Pozwala na lowienie ryb w zimowych biomach
Fishing.Chance.Raining=[[BLUE]] Bonus od Deszczu
Fishing.Listener=Rybactwo
Fishing.Ability.TH.ItemFound=[[GRAY]]Treasure found!
Fishing.Ability.TH.MagicFound=[[GRAY]]Wyczuwasz w pobli\u017cu \u017ar\u00f3d\u0142o magii...
Fishing.SkillName=RYBACTWO
Fishing.Skillup=[[YELLOW]]Umiej\u0119tno\u015b\u0107 \u0142owienia wzros\u0142a o {0}. Razem ({1})

View File

@@ -30,7 +30,6 @@ Excavation.Listener=Escavacao:
Excavation.SkillName=Escava\u00e7\u00e3o
Excavation.Skillup=[[YELLOW]]Habilidade de Escavacao aumentada em {0}. Total ({1})
Fishing.Listener=Pescaria:
Fishing.Ability.TH.ItemFound=[[GRAY]]Tesouro encontrado!
Fishing.Ability.TH.MagicFound=[[GRAY]]You feel a touch of magic with this catch...
Fishing.SkillName=PESCARIA
Fishing.Skillup=[[YELLOW]]Habilidade em Pescaria aumentada em {0}. Total ({1})

View File

@@ -98,7 +98,6 @@ Fishing.Effect.10=\u041f\u043e\u0434\u043b\u0435\u0434\u043d\u0430\u044f \u0420\
Fishing.Effect.11=\u041f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0432\u0430\u043c \u0440\u044b\u0431\u0430\u0447\u0438\u0442\u044c \u0432 \u0441\u043d\u0435\u0436\u043d\u044b\u0445 \u0431\u0438\u043e\u043c\u0430\u0445
Fishing.Chance.Raining=[[BLUE]] \u0411\u043e\u043d\u0443\u0441 \u0414\u043e\u0436\u0434\u044f
Fishing.Listener=\u0420\u044b\u0431\u043e\u043b\u043e\u0432\u0441\u0442\u0432\u043e:
Fishing.Ability.TH.ItemFound=[[GRAY]]Treasure found!
Fishing.Ability.TH.MagicFound=[[GRAY]]You feel a touch of magic with this catch...
Fishing.Ability.TH.Boom=[[GRAY]]\u0412\u0420\u0415\u041c\u042f \u0412\u0417\u0420\u042b\u0412\u0410\u0422\u042c!!!
Fishing.Ability.TH.Poison=[[GRAY]]\u0427\u0442\u043e-\u0442\u043e \u0441\u0434\u0435\u0441\u044c \u043d\u0435 \u0442\u0430\u043a...

View File

@@ -25,7 +25,6 @@ Excavation.Listener=Gr\u00e4vning:
Excavation.SkillName=Gr\u00e4vning
Excavation.Skills.GigaDrillBreaker.On=[[GREEN]]**GIGA BORR KROSSAREN AKTIVERAD**
Excavation.Skillup=[[YELLOW]]Gr\u00e4vningsf\u00e4rdigheten har \u00f6kat med {0}. Totalt ({1})
Fishing.Ability.TH.ItemFound=[[GRAY]]Skatt hittad!
Fishing.Ability.TH.MagicFound=[[GRAY]] Du f\u00e5r en k\u00e4nsla av magi med denna f\u00e5ngst....
Herbalism.Ability.GTh=[[GREEN]]**GR\u00d6NA FINGRAR**
Herbalism.Ability.Ready=[[GREEN]]**DU H\u00d6JER DIN SKYFFEL**

View File

@@ -95,7 +95,6 @@ Fishing.Effect.10=Ice Fishing
Fishing.Effect.11=\u0e2d\u0e19\u0e38\u0e0d\u0e32\u0e15\u0e34\u0e43\u0e2b\u0e49\u0e15\u0e01\u0e1b\u0e25\u0e32\u0e43\u0e19\u0e19\u0e49\u0e33\u0e41\u0e02\u0e47\u0e07
Fishing.Chance.Raining=[[BLUE]] Rain Bonus
Fishing.Listener=\u0e17\u0e31\u0e01\u0e29\u0e30 Fishing:
Fishing.Ability.TH.ItemFound=[[GRAY]]\u0e44\u0e14\u0e49\u0e1e\u0e1a\u0e2a\u0e21\u0e1a\u0e31\u0e15\u0e34!
Fishing.Ability.TH.MagicFound=[[GRAY]]\u0e04\u0e38\u0e13\u0e23\u0e39\u0e49\u0e2a\u0e36\u0e01\u0e44\u0e14\u0e49\u0e16\u0e36\u0e07\u0e2a\u0e31\u0e21\u0e1c\u0e31\u0e2a\u0e02\u0e2d\u0e07\u0e40\u0e27\u0e17\u0e21\u0e19\u0e15\u0e23\u0e4c\u0e14\u0e49\u0e27\u0e22\u0e01\u0e32\u0e23\u0e08\u0e31\u0e1a\u0e2a\u0e34\u0e48\u0e07\u0e19\u0e35\u0e49 ...
Fishing.SkillName=FISHING
Fishing.Skillup=[[YELLOW]]\u0e17\u0e31\u0e01\u0e29\u0e30 Fishing \u0e40\u0e1e\u0e34\u0e48\u0e21\u0e02\u0e36\u0e49\u0e19 {0}. \u0e21\u0e35\u0e17\u0e31\u0e49\u0e07\u0e2b\u0e21\u0e14 ({1})

View File

@@ -10,7 +10,6 @@ Axes.Effect.2=Kritik Vuruslar
Axes.SkillName=BALTALAR
Excavation.Ability.Lower=[[GRAY]]**K\u00dcREGINI INDIRIYORSUN**
Excavation.SkillName=KAZMA
Fishing.Ability.TH.ItemFound=[[GRAY]]Hazine bulundu!
Fishing.SkillName=BALIK TUTMA
Herbalism.Ability.Lower=[[GRAY]]**\u00c7APANI INDIRIYORSUN**
Herbalism.Ability.Ready=[[GREEN]]**\u00c7APANI HAZIRLIYORSUN**

View File

@@ -98,7 +98,6 @@ Fishing.Effect.10=\u51b0\u9493
Fishing.Effect.11=\u5141\u8bb8\u4f60\u5728\u51b0\u51b7\u7684\u73af\u5883\u4e0b\u9493\u9c7c
Fishing.Chance.Raining=[[BLUE]] \u5927\u91cf\u5956\u52b1
Fishing.Listener=\u9493\u9c7c(Fishing):
Fishing.Ability.TH.ItemFound=[[GRAY]]\u53d1\u73b0\u5b9d\u7269\u4e86\uff01
Fishing.Ability.TH.MagicFound=[[GRAY]]\u4f60\u611f\u5230\u4e00\u80a1\u9b54\u529b\u7684\u6ce2\u52a8...
Fishing.Ability.TH.Boom=[[GRAY]]\u7e41\u8363\u65f6\u671f!!!
Fishing.Ability.TH.Poison=[[GRAY]]\u4ec0\u4e48\u4e1c\u897f,\u95fb\u8d77\u6765\u597d\u81ed\u554a...

View File

@@ -98,7 +98,6 @@ Fishing.Effect.10=\u51b0\u91e3
Fishing.Effect.11=\u5141\u8a31\u4f60\u5728\u51b0\u5929\u96ea\u5730\u88e1\u91e3\u9b5a
Fishing.Chance.Raining=[[BLUE]] \u5927\u91cf\u734e\u52f5
Fishing.Listener=\u91e3\u9b5a:
Fishing.Ability.TH.ItemFound=[[GRAY]]\u767c\u73fe\u5bf6\u7269\u4e86\uff01
Fishing.Ability.TH.MagicFound=[[GRAY]]\u4f60\u611f\u53d7\u5230\u9b54\u529b\u7684\u6ce2\u52d5...
Fishing.Ability.TH.Boom=[[GRAY]]\u6536\u7a6b\u6642\u9593!!!
Fishing.Ability.TH.Poison=[[GRAY]]\u4ec0\u9ebc\u6771\u897f,\u805e\u8d77\u4f86\u597d\u81ed\u554a...

View File

@@ -1,4 +1,47 @@
#
# Armor example configuration
# Last updated on ${project.version}-b${BUILD_NUMBER}
#
# Any file named armor.*.yml in the mod folder will be loaded as a armor config
# For every armor type there is a separate section.
# The names of each subitem should be the exact material name.
# The bare minimum of an Armor piece is that it has a Repair_Material
#
#
# Repairable: Whether or not the item is repairable
## This defaults to true
#
# Repair_Material: This is the material name of the item used to repair this armor.
## This is required to be set if you want to be able to repair the item.
#
# Repair_Material_Data_Value: This is the metadata of the item used to repair this armor.
## A value of -1 means to ignore all metadata when repairing.
## This defaults to -1
#
# Repair_Material_Quantity: This is the minimum number of items needed to repair this item ignoring all other repair bonuses.
## This is typically the number of the repair material needed to create a new item, for example for a sword it is 2, for an axe it is 3
## This defaults to 9
#
# Repair_Material_Pretty_Name: The pretty name of the repair material.
## Used in the feedback message when not enough repair materials are found.
## This defaults to the Repair_Material converted to string.
#
# Repair_Material_Pretty_Name: The pretty name of the repair material.
## Used in the feedback message when not enough repair materials are found.
## This defaults to the Repair_Material converted to string.
#
# Repair_MinimumLevel: This is the minimum repair level needed to repair this item.
## Valid values are => 0
## This defaults to 0
#
# Repair_XpMultiplier: This is the amount to multiply the xp bonus by.
## This defaults to 1
#
# Durability: This is the maximum durability of the armor.
## Valid values are >= 1
#
###
#
# Settings for Boots
###
Boots:
@@ -7,12 +50,18 @@ Boots:
Repair_Material: REPAIR_MATERIAL_NAME
Repair_Material_Data_Value: 0
Repair_Material_Quantity: 9
Repair_Material_Pretty_Name: Repair Item Name
Repair_MinimumLevel: 0
Repair_XpMultiplier: 1.0
Durability: 999
Boot_2:
Repairable: true
Repair_Material: REPAIR_MATERIAL_NAME
Repair_Material_Data_Value: 0
Repair_Material_Quantity: 9
Repair_Material_Pretty_Name: Repair Item Name
Repair_MinimumLevel: 0
Repair_XpMultiplier: 1.0
Durability: 999
#
# Settings for Chestplates
@@ -23,12 +72,18 @@ Chestplates:
Repair_Material: REPAIR_MATERIAL_NAME
Repair_Material_Data_Value: 0
Repair_Material_Quantity: 9
Repair_Material_Pretty_Name: Repair Item Name
Repair_MinimumLevel: 0
Repair_XpMultiplier: 1.0
Durability: 999
Chestplate_2:
Repairable: true
Repair_Material: REPAIR_MATERIAL_NAME
Repair_Material_Data_Value: 0
Repair_Material_Quantity: 9
Repair_Material_Pretty_Name: Repair Item Name
Repair_MinimumLevel: 0
Repair_XpMultiplier: 1.0
Durability: 999
#
# Settings for Helmets
@@ -39,12 +94,18 @@ Helmets:
Repair_Material: REPAIR_MATERIAL_NAME
Repair_Material_Data_Value: 0
Repair_Material_Quantity: 9
Repair_Material_Pretty_Name: Repair Item Name
Repair_MinimumLevel: 0
Repair_XpMultiplier: 1.0
Durability: 999
Helmet_2:
Repairable: true
Repair_Material: REPAIR_MATERIAL_NAME
Repair_Material_Data_Value: 0
Repair_Material_Quantity: 9
Repair_Material_Pretty_Name: Repair Item Name
Repair_MinimumLevel: 0
Repair_XpMultiplier: 1.0
Durability: 999
#
# Settings for Leggings
@@ -55,10 +116,16 @@ Leggings:
Repair_Material: REPAIR_MATERIAL_NAME
Repair_Material_Data_Value: 0
Repair_Material_Quantity: 9
Repair_Material_Pretty_Name: Repair Item Name
Repair_MinimumLevel: 0
Repair_XpMultiplier: 1.0
Durability: 999
Legging_2:
Repairable: true
Repair_Material: REPAIR_MATERIAL_NAME
Repair_Material_Data_Value: 0
Repair_Material_Quantity: 9
Repair_Material_Pretty_Name: Repair Item Name
Repair_MinimumLevel: 0
Repair_XpMultiplier: 1.0
Durability: 999

View File

@@ -1,132 +1,220 @@
#
# Tools example configuration
# Last updated on ${project.version}-b${BUILD_NUMBER}
#
# Any file named tools.*.yml in the mod folder will be loaded as a tools config
# For every tool type there is a separate section.
# The names of each subitem should be the exact material name.
# The bare minimum of a Tool is that it has a Repair_Material
#
#
#
# XP_Modifier: This is the xp modifier of the tool, xp is multiplied by this modifier.
## Valid values are > 0
## This defaults to 1.0.
#
# Tier: The tier of the tool
## Used to determine the capabilities of AoE abilities with certain skills
## Valid values range from 1 to 4
## This defaults to 1
#
# Ability_Enabled: Whether or not abilities are enabled with this tool
## This defaults to true
#
# Repairable: Whether or not the item is repairable
## This defaults to true
#
# Repair_Material: This is the material name of the item used to repair this tool.
## This is required to be set if you want to be able to repair the item.
#
# Repair_Material_Data_Value: This is the metadata of the item used to repair this tool.
## A value of -1 means to ignore all metadata when repairing.
## This defaults to -1
#
# Repair_Material_Quantity: This is the minimum number of items needed to repair this item ignoring all other repair bonuses.
## This is typically the number of the repair material needed to create a new item, for example for a sword it is 2, for an axe it is 3
## This defaults to 9
#
# Repair_Material_Pretty_Name: The pretty name of the repair material.
## Used in the feedback message when not enough repair materials are found.
## This defaults to the Repair_Material converted to string.
#
# Repair_MinimumLevel: This is the minimum repair level needed to repair this item.
## Valid values are => 0
## This defaults to 0
#
# Repair_XpMultiplier: This is the amount to multiply the xp bonus by.
## This defaults to 1
#
# Durability: This is the maximum durability of the tool.
## Valid values are >= 1
#
###
#
# Settings for Axes
###
Axes:
Axe_1:
XP_Modifer: 1.0
XP_Modifier: 1.0
Ability_Enabled: true
Tier: 1
Repairable: true
Repair_Material: REPAIR_MATERIAL_NAME
Repair_Material_Data_Value: 0
Repair_Material_Quantity: 9
Repair_Material_Pretty_Name: Repair Item Name
Repair_MinimumLevel: 0
Repair_XpMultiplier: 1.0
Durability: 9999
Axe_2:
XP_Modifer: 1.0
XP_Modifier: 1.0
Ability_Enabled: true
Tier: 1
Repairable: true
Repair_Material: REPAIR_MATERIAL_NAME
Repair_Material_Data_Value: 0
Repair_Material_Quantity: 9
Repair_Material_Pretty_Name: Repair Item Name
Repair_MinimumLevel: 0
Repair_XpMultiplier: 1.0
Durability: 9999
#
# Settings for Bows
###
Bows:
Bow_1:
XP_Modifer: 1.0
XP_Modifier: 1.0
Ability_Enabled: true
Tier: 1
Repairable: true
Repair_Material: REPAIR_MATERIAL_NAME
Repair_Material_Data_Value: 0
Repair_Material_Quantity: 9
Repair_Material_Pretty_Name: Repair Item Name
Repair_MinimumLevel: 0
Repair_XpMultiplier: 1.0
Durability: 9999
Bow_2:
XP_Modifer: 1.0
XP_Modifier: 1.0
Ability_Enabled: true
Tier: 1
Repairable: true
Repair_Material: REPAIR_MATERIAL_NAME
Repair_Material_Data_Value: 0
Repair_Material_Quantity: 9
Repair_Material_Pretty_Name: Repair Item Name
Repair_MinimumLevel: 0
Repair_XpMultiplier: 1.0
Durability: 9999
#
# Settings for Hoes
###
Hoes:
Hoe_1:
XP_Modifer: 1.0
XP_Modifier: 1.0
Ability_Enabled: true
Tier: 1
Repairable: true
Repair_Material: REPAIR_MATERIAL_NAME
Repair_Material_Data_Value: 0
Repair_Material_Quantity: 9
Repair_Material_Pretty_Name: Repair Item Name
Repair_MinimumLevel: 0
Repair_XpMultiplier: 1.0
Durability: 9999
Hoe_2:
XP_Modifer: 1.0
XP_Modifier: 1.0
Ability_Enabled: true
Tier: 1
Repairable: true
Repair_Material: REPAIR_MATERIAL_NAME
Repair_Material_Data_Value: 0
Repair_Material_Quantity: 9
Repair_Material_Pretty_Name: Repair Item Name
Repair_MinimumLevel: 0
Repair_XpMultiplier: 1.0
Durability: 9999
#
# Settings for Pickaxes
###
Pickaxes:
Pickaxe_1:
XP_Modifer: 1.0
XP_Modifier: 1.0
Ability_Enabled: true
Tier: 1
Repairable: true
Repair_Material: REPAIR_MATERIAL_NAME
Repair_Material_Data_Value: 0
Repair_Material_Quantity: 9
Repair_Material_Pretty_Name: Repair Item Name
Repair_MinimumLevel: 0
Repair_XpMultiplier: 1.0
Durability: 9999
Pickaxe_2:
XP_Modifer: 1.0
XP_Modifier: 1.0
Ability_Enabled: true
Tier: 1
Repairable: true
Repair_Material: REPAIR_MATERIAL_NAME
Repair_Material_Data_Value: 0
Repair_Material_Quantity: 9
Repair_Material_Pretty_Name: Repair Item Name
Repair_MinimumLevel: 0
Repair_XpMultiplier: 1.0
Durability: 9999
#
# Settings for Shovels
###
Shovels:
Shovel_1:
XP_Modifer: 1.0
XP_Modifier: 1.0
Ability_Enabled: true
Tier: 1
Repairable: true
Repair_Material: REPAIR_MATERIAL_NAME
Repair_Material_Data_Value: 0
Repair_Material_Quantity: 9
Repair_Material_Pretty_Name: Repair Item Name
Repair_MinimumLevel: 0
Repair_XpMultiplier: 1.0
Durability: 9999
Shovel_2:
XP_Modifer: 1.0
XP_Modifier: 1.0
Ability_Enabled: true
Tier: 1
Repairable: true
Repair_Material: REPAIR_MATERIAL_NAME
Repair_Material_Data_Value: 0
Repair_Material_Quantity: 9
Repair_Material_Pretty_Name: Repair Item Name
Repair_MinimumLevel: 0
Repair_XpMultiplier: 1.0
Durability: 9999
#
# Settings for Swords
###
Swords:
Sword_1:
XP_Modifer: 1.0
XP_Modifier: 1.0
Ability_Enabled: true
Tier: 1
Repairable: true
Repair_Material: REPAIR_MATERIAL_NAME
Repair_Material_Data_Value: 0
Repair_Material_Quantity: 9
Repair_Material_Pretty_Name: Repair Item Name
Repair_MinimumLevel: 0
Repair_XpMultiplier: 1.0
Durability: 9999
Sword_2:
XP_Modifer: 1.0
XP_Modifier: 1.0
Ability_Enabled: true
Tier: 1
Repairable: true
Repair_Material: REPAIR_MATERIAL_NAME
Repair_Material_Data_Value: 0
Repair_Material_Quantity: 9
Repair_Material_Pretty_Name: Repair Item Name
Repair_MinimumLevel: 0
Repair_XpMultiplier: 1.0
Durability: 9999

View File

@@ -652,16 +652,6 @@ permissions:
mcmmo.bypass.fishingtraps:
default: false
description: Allows user to bypass finding traps when Fishing
mcmmo.bypass.inspect.distance:
default: false
description: Allows user to bypass Inspect's distance requirements
children:
mcmmo.commands.inspect.far: true
mcmmo.bypass.inspect.offline:
default: false
description: Allows user to bypass Inspect's offline player requirements
children:
mcmmo.commands.inspect.offline: true
mcmmo.chat.*:
default: false
description: Implies all mcmmo.chat permissions. (Warning, contains adminchat)
@@ -749,11 +739,6 @@ permissions:
mcmmo.commands.skillreset.all: true
mcmmo.commands.vampirism.all: true
mcmmo.commands.xprate.all: true
mcmmo.commands.ability:
default: false
description: Allows access to the mcability command
children:
mcmmo.commands.mcability: true
mcmmo.commands.acrobatics:
description: Allows access to the acrobatics command
mcmmo.commands.addlevels:
@@ -822,11 +807,6 @@ permissions:
description: Allows access to the mcability command
mcmmo.commands.mcability.others:
description: Allows access to the mcability command for other players
mcmmo.commands.mcc:
default: false
description: Allows access to the mcmmo help command
children:
mcmmo.commands.mcmmo.help: true
mcmmo.commands.mcconvert.*:
default: false
description: Allows access to the mcconvert commands
@@ -956,11 +936,6 @@ permissions:
description: Allows access to the mmoedit command
mcmmo.commands.mmoedit.others:
description: Allows access to the mmoedit command for other players
mcmmo.commands.mmoupdate:
default: false
description: Allows access to the mcconvert database command
children:
mcmmo.commands.mcconvert.database: true
mcmmo.commands.mmoshowdb:
description: Allows access to the mmoshowdb command
mcmmo.commands.mobhealth:
@@ -1246,7 +1221,7 @@ permissions:
mcmmo.chat.adminchat: true
mcmmo.commands.defaultsop: true
mcmmo.item.all: true
mcmmo.tools.updatecheck: true
mcmmo.tools.all: true
mcmmo.item.*:
default: false
description: Implies all mcmmo.item permissions
@@ -1979,6 +1954,11 @@ permissions:
children:
mcmmo.ability.repair.all: true
mcmmo.commands.repair: true
mcmmo.skills.salvage:
description: Allows access to the Salvage skill
children:
mcmmo.ability.salvage.all: true
mcmmo.commands.salvage: true
mcmmo.skills.smelting:
description: Allows access to the Smelting skill
children:
@@ -2016,163 +1996,7 @@ permissions:
default: false
description: Implies all mcmmo.tools permissions.
children:
mcmmo.tools.mcgod: true
mcmmo.tools.mcrefresh: true
mcmmo.tools.mcremove: true
mcmmo.tools.mmoedit: true
mcmmo.tools.updatecheck: true
mcmmo.tools.mcgod:
default: false
description: Allows access to mcgod command
children:
mcmmo.commands.mcgod: true
mcmmo.tools.mcrefresh:
default: false
description: Allows access to mcrefresh command
children:
mcmmo.commands.mcrefresh: true
mcmmo.commands.mcrefresh.others: true
mcmmo.tools.mcremove:
default: false
decription: Allows access to mcremove and mcpurge command
children:
mcmmo.commands.mcremove: true
mcmmo.tools.mmoedit:
default: false
description: Allows access to mmoedit command
children:
mcmmo.commands.addlevels: true
mcmmo.commands.addlevels.others: true
mcmmo.commands.addxp: true
mcmmo.commands.addxp.others: true
mcmmo.commands.mcpurge: true
mcmmo.commands.mmoedit: true
mcmmo.commands.mmoedit.others: true
mcmmo.tools.updatecheck:
default: false
description: Notifies admins if there is a new version of mcMMO available
mcmmo.ability.fishing.shakemob:
default: false
description: deprecated
children:
mcmmo.ability.fishing.shake: true
mcmmo.ability.axes.impact:
default: false
description: deprecated
children:
mcmmo.ability.axes.armorimpact: true
mcmmo.ability.taming.fastfoodservice:
default: false
description: deprecated
children:
mcmmo.ability.taming.fastfood: true
mcmmo.ability.archery.trackarrows:
default: false
description: deprecated
children:
mcmmo.ability.archery.retrieve: true
mcmmo.ability.repair.repairbonus:
default: false
description: deprecated
children:
mcmmo.ability.repair.superrepair: true
mcmmo.ability.swords.counterattack:
default: false
description: deprecated
children:
mcmmo.ability.swords.counter: true
mcmmo.ability.archery.bonusdamage:
default: false
description: deprecated
children:
mcmmo.ability.archery.skillshot: true
mcmmo.ability.excavation.treasures:
default: false
description: deprecated
children:
mcmmo.ability.excavation.treasurehunter: true
mcmmo.ability.fishing.treasures:
default: false
description: deprecated
children:
mcmmo.ability.fishing.treasurehunter: true
mcmmo.ability.fishing.magic:
default: false
description: deprecated
children:
mcmmo.ability.fishing.magichunter: true
mcmmo.ability.unarmed.bonusdamage:
default: false
description: deprecated
children:
mcmmo.ability.unarmed.ironarm: true
mcmmo.ability.axes.bonusdamage:
default: false
description: deprecated
children:
mcmmo.ability.axes.axemastery: true
mcmmo.ability.smelting.doubledrops:
default: false
description: deprecated
children:
mcmmo.ability.smelting.secondsmelt: true
mcmmo.ability.taming.callofthewild_renamepets:
default: false
description: deprecated
children:
mcmmo.ability.taming.callofthewild.renamepets: true
mcmmo.ability.blastmining.*:
default: false
description: deprecated
children:
mcmmo.ability.mining.blastmining.*: true
mcmmo.ability.blastmining.all:
default: false
description: deprecated
children:
mcmmo.ability.mining.blastmining.all: true
mcmmo.ability.blastmining.biggerbombs:
default: false
description: deprecated
children:
mcmmo.ability.mining.blastmining.biggerbombs: true
mcmmo.ability.blastmining.demolitionsexpertise:
default: false
description: deprecated
children:
mcmmo.ability.mining.blastmining.demolitionsexpertise: true
mcmmo.ability.blastmining.detonate:
default: false
description: deprecated
children:
mcmmo.ability.mining.blastmining.detonate: true
mcmmo.ability.herbalism.greenthumbblocks:
default: false
description: deprecated
children:
mcmmo.ability.herbalism.greenthumb.blocks.all: true
mcmmo.ability.herbalism.greenthumbcarrots:
default: false
description: deprecated
children:
mcmmo.ability.herbalism.greenthumb.plants.carrot: true
mcmmo.ability.herbalism.greenthumbcocoa:
default: false
description: deprecated
children:
mcmmo.ability.herbalism.greenthumb.plants.cocoa: true
mcmmo.ability.herbalism.greenthumbnetherwart:
default: false
description: deprecated
children:
mcmmo.ability.herbalism.greenthumb.plants.netherwarts: true
mcmmo.ability.herbalism.greenthumbpotatoes:
default: false
description: deprecated
children:
mcmmo.ability.herbalism.greenthumb.plants.potato: true
mcmmo.ability.herbalism.greenthumbwheat:
default: false
description: deprecated
children:
mcmmo.ability.herbalism.greenthumb.plants.crops: true

View File

@@ -446,7 +446,7 @@ Excavation:
XP: 3000
Drop_Chance: 0.05
Drop_Level: 750
Drops_From: [Dirt, Grass, Sand, Gravel, Clay, Mycelium, Soul_Sand]
Drops_From: [Dirt, Podzol, Grass, Sand, Red_Sand, Gravel, Clay, Mycelium, Soul_Sand]
SULPHUR:
Amount: 1
XP: 30
@@ -488,13 +488,13 @@ Excavation:
XP: 80
Drop_Chance: 0.5
Drop_Level: 500
Drops_From: [Dirt, Grass, Mycelium]
Drops_From: [Dirt, Podzol, Grass, Mycelium]
BROWN_MUSHROOM:
Amount: 1
XP: 80
Drop_Chance: 0.5
Drop_Level: 500
Drops_From: [Dirt, Grass, Mycelium]
Drops_From: [Dirt, Podzol, Grass, Mycelium]
EGG:
Amount: 1
XP: 100
@@ -506,7 +506,7 @@ Excavation:
XP: 80
Drop_Chance: 0.5
Drop_Level: 650
Drops_From: [Sand]
Drops_From: [Sand, Red_Sand]
WATCH:
Amount: 1
XP: 100
@@ -530,43 +530,43 @@ Excavation:
XP: 80
Drop_Chance: 5.0
Drop_Level: 25
Drops_From: [Dirt, Grass, Sand, Mycelium]
Drops_From: [Dirt, Podzol, Grass, Sand, Red_Sand, Mycelium]
GOLD_RECORD:
Amount: 1
XP: 3000
Drop_Chance: 0.05
Drop_Level: 250
Drops_From: [Dirt, Grass, Sand, Gravel, Clay, Mycelium, Soul_Sand]
Drops_From: [Dirt, Podzol, Grass, Sand, Red_Sand, Gravel, Clay, Mycelium, Soul_Sand]
GREEN_RECORD:
Amount: 1
XP: 3000
Drop_Chance: 0.05
Drop_Level: 250
Drops_From: [Dirt, Grass, Sand, Gravel, Clay, Mycelium, Soul_Sand]
Drops_From: [Dirt, Podzol, Grass, Sand, Red_Sand, Gravel, Clay, Mycelium, Soul_Sand]
DIAMOND:
Amount: 1
XP: 1000
Drop_Chance: 0.13
Drop_Level: 350
Drops_From: [Dirt, Grass, Sand, Gravel, Clay, Mycelium, Soul_Sand]
Drops_From: [Dirt, Podzol, Grass, Sand, Red_Sand, Gravel, Clay, Mycelium, Soul_Sand]
INK_SACK_BROWN:
Amount: 1
XP: 100
Drop_Chance: 1.33
Drop_Level: 350
Drops_From: [Dirt, Grass, Mycelium]
Drops_From: [Dirt, Podzol, Grass, Mycelium]
QUARTZ:
Amount: 1
XP: 100
Drop_Chance: 0.5
Drop_Level: 850
Drops_From: [Dirt, Sand, Gravel, Mycelium, Soul_Sand]
Drops_From: [Dirt, Podzol, Sand, Red_Sand, Gravel, Mycelium, Soul_Sand]
NAME_TAG:
Amount: 1
XP: 3000
Drop_Chance: 0.05
Drop_Level: 250
Drops_From: [Dirt, Grass, Sand, Gravel, Clay, Mycelium, Soul_Sand]
Drops_From: [Dirt, Podzol, Grass, Sand, Red_Sand, Gravel, Clay, Mycelium, Soul_Sand]
#
# Settings for Hylian Luck
###

View File

@@ -58,12 +58,13 @@ finally () {</pre>
break;
case 2:</pre>
* Whenever possible, check for a negative, rather than a positive
* <pre>if (!something) {
// Do things
* Prefer early returns over method indentation. Example:
* <pre>if (!precondition) {
// Possibly cleanup
return;
}
// Do other things</pre>
// Continue with task</pre>
* Java standard class and method naming, with exception to McMMO in a class name
* <pre>thisIsAMethod()</pre>
* <pre>ThisIsAClass</pre>
@@ -88,8 +89,6 @@ finally () {</pre>
* protected
* static protected
* abstract protected
* override private
* private
* static private
* abstract private
* No one-line if statements, they should all have brackets
* No one-line if statements, they should all have brackets