mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2026-02-18 17:53:00 +01:00
Compare commits
152 Commits
cs
...
dev-dblock
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4c4def2a23 | ||
|
|
2b9b5df1ee | ||
|
|
e7e62b8d40 | ||
|
|
3d242bbdb6 | ||
|
|
e796eae3c3 | ||
|
|
a257e83a62 | ||
|
|
d527584248 | ||
|
|
0a4de6e2fc | ||
|
|
4b20f12eff | ||
|
|
0de1187012 | ||
|
|
8e474170e4 | ||
|
|
2eeb9b1f35 | ||
|
|
3de6e2c3f1 | ||
|
|
98d166808f | ||
|
|
f75e15dfdc | ||
|
|
f2b892b7d5 | ||
|
|
883ada01f8 | ||
|
|
3a8f45a04d | ||
|
|
906609696b | ||
|
|
66ccde4310 | ||
|
|
4970cdc3f4 | ||
|
|
1becc874ba | ||
|
|
b107a8dc7c | ||
|
|
37aebc1716 | ||
|
|
836877ff93 | ||
|
|
28a846e0cb | ||
|
|
0185a30ec9 | ||
|
|
38e1947302 | ||
|
|
4fb4d6fc0c | ||
|
|
6d719988bf | ||
|
|
b1c1f0e21e | ||
|
|
3f34cc7365 | ||
|
|
3c6c2837bd | ||
|
|
4bcef76fd8 | ||
|
|
2fd5d7aa81 | ||
|
|
5080c68dce | ||
|
|
3403aef37d | ||
|
|
53a34c12d2 | ||
|
|
59417d6721 | ||
|
|
93d63dbca5 | ||
|
|
4643cf1070 | ||
|
|
91bf54019e | ||
|
|
ead716ef0d | ||
|
|
8fec1af257 | ||
|
|
99248caba3 | ||
|
|
af64bdf742 | ||
|
|
66a4925371 | ||
|
|
8eb6acd60f | ||
|
|
ce6892f2e6 | ||
|
|
c14a4e9305 | ||
|
|
5825eb1696 | ||
|
|
bfebbd0095 | ||
|
|
b204507a82 | ||
|
|
9f53426511 | ||
|
|
03c2282c3f | ||
|
|
20092d55fd | ||
|
|
69a2a5cfff | ||
|
|
618cfad100 | ||
|
|
56e625a9df | ||
|
|
79a1ef5d3e | ||
|
|
10dd7619bf | ||
|
|
f9dfec5bd0 | ||
|
|
a9488bc18b | ||
|
|
f0ee708710 | ||
|
|
3390a31cc6 | ||
|
|
0b4b272223 | ||
|
|
8d200ea653 | ||
|
|
eb359c5595 | ||
|
|
e1b8088c17 | ||
|
|
70a1eea231 | ||
|
|
c744974192 | ||
|
|
faa11a87a9 | ||
|
|
91da5c4ab1 | ||
|
|
da5e770e06 | ||
|
|
09557e378b | ||
|
|
72d26fed0f | ||
|
|
225de799e8 | ||
|
|
334c44760f | ||
|
|
ac7fc1020d | ||
|
|
461871327b | ||
|
|
60ddd799de | ||
|
|
80571fbe8f | ||
|
|
d407f85704 | ||
|
|
458dc7db42 | ||
|
|
beab794c0e | ||
|
|
8256f5461c | ||
|
|
0fe3ad7432 | ||
|
|
04e5dda127 | ||
|
|
f65adea2f9 | ||
|
|
cdfb0da5c9 | ||
|
|
cfa3d34dff | ||
|
|
01b7d4f742 | ||
|
|
9a359bf42c | ||
|
|
ebdf11300b | ||
|
|
e1a8f02bce | ||
|
|
862d38b587 | ||
|
|
2415767c06 | ||
|
|
aa59348a94 | ||
|
|
9c925d3327 | ||
|
|
30f7521a3a | ||
|
|
7b3869e385 | ||
|
|
0e641f7c5b | ||
|
|
733d16cf35 | ||
|
|
833bc1b251 | ||
|
|
840f3d9382 | ||
|
|
34d6d867f2 | ||
|
|
e56d5a0454 | ||
|
|
53fdf750f4 | ||
|
|
f096e915cf | ||
|
|
ce59488e8e | ||
|
|
47db522cc1 | ||
|
|
a2cac82cba | ||
|
|
2e74333eb7 | ||
|
|
0056be2d5f | ||
|
|
1d7e034d5e | ||
|
|
8deac175d1 | ||
|
|
d0b766a2d3 | ||
|
|
65692f2a83 | ||
|
|
d0b0786284 | ||
|
|
87ac1002de | ||
|
|
c51fde7f1f | ||
|
|
0a6735110f | ||
|
|
8a284c50a2 | ||
|
|
09431ef27c | ||
|
|
9f9de86d21 | ||
|
|
d9c04a09ba | ||
|
|
04a02cfdc8 | ||
|
|
b3a6c32ef6 | ||
|
|
254f3b5ac9 | ||
|
|
7f9ada14c8 | ||
|
|
f79a4741cc | ||
|
|
f3fd48d0c0 | ||
|
|
fbee3318bd | ||
|
|
813f807876 | ||
|
|
0060a86b20 | ||
|
|
15743c5f46 | ||
|
|
4b9d472f10 | ||
|
|
988006f913 | ||
|
|
2f05c472ce | ||
|
|
5c836cdaaf | ||
|
|
9e39c3495d | ||
|
|
b653aa57b7 | ||
|
|
2ffdd340af | ||
|
|
d63c3fc6d0 | ||
|
|
4486261413 | ||
|
|
a2e32179bb | ||
|
|
72b106e71f | ||
|
|
679f1ed629 | ||
|
|
734815c58d | ||
|
|
abfedf381d | ||
|
|
8e040ae8d9 | ||
|
|
0c9836eb03 |
@@ -7,7 +7,50 @@ Key:
|
|||||||
! Change
|
! Change
|
||||||
- Removal
|
- Removal
|
||||||
|
|
||||||
Version 1.4.08-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
|
||||||
|
+ Added option to config.yml for Alchemy. Skills.Alchemy.Prevent_Hopper_Transfer_Bottles
|
||||||
|
+ 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 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
|
+ Added SecondaryAbilityType enum, and new SecondaryAbilityWeightedActivationCheckEvent, fired when a secondary ability checkes its activation chances
|
||||||
+ Added the possibility to gain experience when using Fishing "Shake"
|
+ Added the possibility to gain experience when using Fishing "Shake"
|
||||||
@@ -20,6 +63,14 @@ Version 1.4.08-dev
|
|||||||
+ Added new experience bonus perk 'mcmmo.perks.xp.10percentboost.<skillname>' multiplies incoming XP by 1.1
|
+ Added new experience bonus perk 'mcmmo.perks.xp.10percentboost.<skillname>' multiplies incoming XP by 1.1
|
||||||
+ Added new experience bonus perk 'mcmmo.perks.xp.customboost.<skillname>' multiplies incoming XP by the boost amount defined in the experience config
|
+ Added new experience bonus perk 'mcmmo.perks.xp.customboost.<skillname>' multiplies incoming XP by the boost amount defined in the experience config
|
||||||
+ Added Ender Dragon, Wither, and Witch to combat experience multipliers - they do not give XP by default
|
+ Added Ender Dragon, Wither, and Witch to combat experience multipliers - they do not give XP by default
|
||||||
|
+ Added support for multiple mod config files, naming can be done as either armor.<modname>.yml or <modname>.armor.yml
|
||||||
|
+ Added config options to configure the items used in "Call of the Wild"
|
||||||
|
+ Added config option to configure the database command cooldown
|
||||||
|
= Fixed bug where healthbars wouldn't display if skills were disabled
|
||||||
|
= Fixed bug with "Call of the Wild" entities despawning
|
||||||
|
= Fixed bug with updating (very) old user data.
|
||||||
|
= Fixed bug with checking maximum durability of mod items.
|
||||||
|
= Fixed exploit involving Call of The Wild.
|
||||||
= Fixed bug where LeafBlower permissions were ignored
|
= Fixed bug where LeafBlower permissions were ignored
|
||||||
= Fixed bug with toggle commands not properly displaying the success message.
|
= Fixed bug with toggle commands not properly displaying the success message.
|
||||||
= Fixed IllegalArgumentException caused by an empty Fishing treasure category
|
= Fixed IllegalArgumentException caused by an empty Fishing treasure category
|
||||||
@@ -33,9 +84,12 @@ Version 1.4.08-dev
|
|||||||
= Fixed bug where party chat broke if the display name contained special characters
|
= Fixed bug where party chat broke if the display name contained special characters
|
||||||
= Fixed bug where `/addlevels all` and `/skillreset all` didn't work
|
= Fixed bug where `/addlevels all` and `/skillreset all` didn't work
|
||||||
= Fixed bug which made it possible to gain XP by taming the same horse multiple times, if a player "untamed" that horse
|
= Fixed bug which made it possible to gain XP by taming the same horse multiple times, if a player "untamed" that horse
|
||||||
|
= Fixed bug where some horses summoned with "Call of the Wild" were unable to jump
|
||||||
= Fixed bug where the /ptp request expiration time was checked wrongly - preventing players from using the command
|
= Fixed bug where the /ptp request expiration time was checked wrongly - preventing players from using the command
|
||||||
= Fixed bug where Hylian Luck was broken
|
= Fixed bug where Hylian Luck was broken
|
||||||
= Fixed bug where Snow would never drop treasures
|
= Fixed bug where Snow would never drop treasures
|
||||||
|
= Fixed issues with commands giving away vanished players.
|
||||||
|
= Fixed bug where the Repair lucky perk would increase the Arcane Forging downgrade chance, instead of decreasing it
|
||||||
! Changed party system. Parties now have XP and Levels. Party features such as party teleport and party chat have to be unlocked before they can be used by the party members
|
! Changed party system. Parties now have XP and Levels. Party features such as party teleport and party chat have to be unlocked before they can be used by the party members
|
||||||
! Changed appearance of party member list. Gold = party leader, White = online, Gray = offline, Italic = not nearby
|
! Changed appearance of party member list. Gold = party leader, White = online, Gray = offline, Italic = not nearby
|
||||||
! Updated localization files
|
! Updated localization files
|
||||||
@@ -45,6 +99,8 @@ Version 1.4.08-dev
|
|||||||
! Changed /ptp config setting, Commands.ptp.Confirm_Required is now Commands.ptp.Accept.Required
|
! Changed /ptp config setting, Commands.ptp.Confirm_Required is now Commands.ptp.Accept.Required
|
||||||
! Changed config validation for UnlockLevels, they can now also be 0
|
! Changed config validation for UnlockLevels, they can now also be 0
|
||||||
! Changed config validation for Rank_Levels, successive Ranks can now be less than or equal to each other
|
! Changed config validation for Rank_Levels, successive Ranks can now be less than or equal to each other
|
||||||
|
! Changed default amount of XP gained from mining Quartz Ore. From 250 to 100 XP.
|
||||||
|
! Changed Acrobatics config setting, Skills.Acrobatics.Prevent_XP_After_Teleport is now Skills.Acrobatics.XP_After_Teleport_Cooldown
|
||||||
- Removed /stats alias for /mcstats
|
- Removed /stats alias for /mcstats
|
||||||
|
|
||||||
Version 1.4.07
|
Version 1.4.07
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ mcMMO is currently developed by a team of individuals from all over the world.
|
|||||||
|
|
||||||
### Special thanks
|
### Special thanks
|
||||||
[]
|
[]
|
||||||
(https://github.com/EasyMFnE)
|
(https://github.com/EasyMFnE)
|
||||||
Added the Alchemy skill
|
Added the Alchemy skill
|
||||||
|
|
||||||
## Compiling
|
## Compiling
|
||||||
|
|||||||
4
pom.xml
4
pom.xml
@@ -2,7 +2,7 @@
|
|||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>com.gmail.nossr50.mcMMO</groupId>
|
<groupId>com.gmail.nossr50.mcMMO</groupId>
|
||||||
<artifactId>mcMMO</artifactId>
|
<artifactId>mcMMO</artifactId>
|
||||||
<version>1.4.08-SNAPSHOT</version>
|
<version>1.5.01-SNAPSHOT</version>
|
||||||
<name>mcMMO</name>
|
<name>mcMMO</name>
|
||||||
<url>https://github.com/mcMMO-Dev/mcMMO</url>
|
<url>https://github.com/mcMMO-Dev/mcMMO</url>
|
||||||
<issueManagement>
|
<issueManagement>
|
||||||
@@ -121,7 +121,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.bukkit</groupId>
|
<groupId>org.bukkit</groupId>
|
||||||
<artifactId>bukkit</artifactId>
|
<artifactId>bukkit</artifactId>
|
||||||
<version>RELEASE</version>
|
<version>LATEST</version>
|
||||||
<type>jar</type>
|
<type>jar</type>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|||||||
@@ -1,9 +1,11 @@
|
|||||||
package com.gmail.nossr50.api;
|
package com.gmail.nossr50.api;
|
||||||
|
|
||||||
|
import org.bukkit.entity.LivingEntity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||||
import com.gmail.nossr50.datatypes.skills.AbilityType;
|
import com.gmail.nossr50.datatypes.skills.AbilityType;
|
||||||
|
import com.gmail.nossr50.runnables.skills.BleedTimerTask;
|
||||||
import com.gmail.nossr50.util.player.UserManager;
|
import com.gmail.nossr50.util.player.UserManager;
|
||||||
|
|
||||||
public final class AbilityAPI {
|
public final class AbilityAPI {
|
||||||
@@ -80,4 +82,8 @@ public final class AbilityAPI {
|
|||||||
public static void setTreeFellerCooldown(Player player, long cooldown) {
|
public static void setTreeFellerCooldown(Player player, long cooldown) {
|
||||||
UserManager.getPlayer(player).setAbilityDATS(AbilityType.TREE_FELLER, cooldown);
|
UserManager.getPlayer(player).setAbilityDATS(AbilityType.TREE_FELLER, cooldown);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean isBleeding(LivingEntity entity) {
|
||||||
|
return BleedTimerTask.isBleeding(entity);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,10 +7,12 @@ import org.bukkit.entity.Player;
|
|||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.gmail.nossr50.api.exceptions.InvalidPlayerException;
|
import com.gmail.nossr50.api.exceptions.InvalidPlayerException;
|
||||||
import com.gmail.nossr50.api.exceptions.InvalidSkillException;
|
import com.gmail.nossr50.api.exceptions.InvalidSkillException;
|
||||||
|
import com.gmail.nossr50.api.exceptions.InvalidXPGainReasonException;
|
||||||
import com.gmail.nossr50.config.Config;
|
import com.gmail.nossr50.config.Config;
|
||||||
import com.gmail.nossr50.config.experience.ExperienceConfig;
|
import com.gmail.nossr50.config.experience.ExperienceConfig;
|
||||||
import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
||||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||||
|
import com.gmail.nossr50.datatypes.skills.XPGainReason;
|
||||||
import com.gmail.nossr50.skills.child.FamilyTree;
|
import com.gmail.nossr50.skills.child.FamilyTree;
|
||||||
import com.gmail.nossr50.util.player.UserManager;
|
import com.gmail.nossr50.util.player.UserManager;
|
||||||
|
|
||||||
@@ -43,9 +45,7 @@ public final class ExperienceAPI {
|
|||||||
public static boolean isNonChildSkill(String skillType) {
|
public static boolean isNonChildSkill(String skillType) {
|
||||||
SkillType skill = SkillType.getSkill(skillType);
|
SkillType skill = SkillType.getSkill(skillType);
|
||||||
|
|
||||||
if (skill == null) return false;
|
return skill != null && !skill.isChildSkill();
|
||||||
|
|
||||||
return !skill.isChildSkill();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
@@ -64,8 +64,26 @@ public final class ExperienceAPI {
|
|||||||
*
|
*
|
||||||
* @throws InvalidSkillException if the given skill is not valid
|
* @throws InvalidSkillException if the given skill is not valid
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
public static void addRawXP(Player player, String skillType, float XP) {
|
public static void addRawXP(Player player, String skillType, float XP) {
|
||||||
UserManager.getPlayer(player).applyXpGain(getSkillType(skillType), XP);
|
addRawXP(player, skillType, XP, "UNKNOWN");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds raw XP to the player.
|
||||||
|
* </br>
|
||||||
|
* This function is designed for API usage.
|
||||||
|
*
|
||||||
|
* @param player The player to add XP to
|
||||||
|
* @param skillType The skill to add XP to
|
||||||
|
* @param XP The amount of XP to add
|
||||||
|
* @param xpGainReason The reason to gain XP
|
||||||
|
*
|
||||||
|
* @throws InvalidSkillException if the given skill is not valid
|
||||||
|
* @throws InvalidXPGainReasonException if the given xpGainReason is not valid
|
||||||
|
*/
|
||||||
|
public static void addRawXP(Player player, String skillType, float XP, String xpGainReason) {
|
||||||
|
UserManager.getPlayer(player).applyXpGain(getSkillType(skillType), XP, getXPGainReason(xpGainReason));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
@@ -100,8 +118,26 @@ public final class ExperienceAPI {
|
|||||||
*
|
*
|
||||||
* @throws InvalidSkillException if the given skill is not valid
|
* @throws InvalidSkillException if the given skill is not valid
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
public static void addMultipliedXP(Player player, String skillType, int XP) {
|
public static void addMultipliedXP(Player player, String skillType, int XP) {
|
||||||
UserManager.getPlayer(player).applyXpGain(getSkillType(skillType), (int) (XP * ExperienceConfig.getInstance().getExperienceGainsGlobalMultiplier()));
|
addMultipliedXP(player, skillType, XP, "UNKNOWN");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds XP to the player, calculates for XP Rate only.
|
||||||
|
* </br>
|
||||||
|
* This function is designed for API usage.
|
||||||
|
*
|
||||||
|
* @param player The player to add XP to
|
||||||
|
* @param skillType The skill to add XP to
|
||||||
|
* @param XP The amount of XP to add
|
||||||
|
* @param xpGainReason The reason to gain XP
|
||||||
|
*
|
||||||
|
* @throws InvalidSkillException if the given skill is not valid
|
||||||
|
* @throws InvalidXPGainReasonException if the given xpGainReason is not valid
|
||||||
|
*/
|
||||||
|
public static void addMultipliedXP(Player player, String skillType, int XP, String xpGainReason) {
|
||||||
|
UserManager.getPlayer(player).applyXpGain(getSkillType(skillType), (int) (XP * ExperienceConfig.getInstance().getExperienceGainsGlobalMultiplier()), getXPGainReason(xpGainReason));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -131,10 +167,28 @@ public final class ExperienceAPI {
|
|||||||
*
|
*
|
||||||
* @throws InvalidSkillException if the given skill is not valid
|
* @throws InvalidSkillException if the given skill is not valid
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
public static void addModifiedXP(Player player, String skillType, int XP) {
|
public static void addModifiedXP(Player player, String skillType, int XP) {
|
||||||
|
addModifiedXP(player, skillType, XP, "UNKNOWN");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds XP to the player, calculates for XP Rate and skill modifier.
|
||||||
|
* </br>
|
||||||
|
* This function is designed for API usage.
|
||||||
|
*
|
||||||
|
* @param player The player to add XP to
|
||||||
|
* @param skillType The skill to add XP to
|
||||||
|
* @param XP The amount of XP to add
|
||||||
|
* @param xpGainReason The reason to gain XP
|
||||||
|
*
|
||||||
|
* @throws InvalidSkillException if the given skill is not valid
|
||||||
|
* @throws InvalidXPGainReasonException if the given xpGainReason is not valid
|
||||||
|
*/
|
||||||
|
public static void addModifiedXP(Player player, String skillType, int XP, String xpGainReason) {
|
||||||
SkillType skill = getSkillType(skillType);
|
SkillType skill = getSkillType(skillType);
|
||||||
|
|
||||||
UserManager.getPlayer(player).applyXpGain(skill, (int) (XP / skill.getXpModifier() * ExperienceConfig.getInstance().getExperienceGainsGlobalMultiplier()));
|
UserManager.getPlayer(player).applyXpGain(skill, (int) (XP / skill.getXpModifier() * ExperienceConfig.getInstance().getExperienceGainsGlobalMultiplier()), getXPGainReason(xpGainReason));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -167,8 +221,27 @@ public final class ExperienceAPI {
|
|||||||
*
|
*
|
||||||
* @throws InvalidSkillException if the given skill is not valid
|
* @throws InvalidSkillException if the given skill is not valid
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
public static void addXP(Player player, String skillType, int XP) {
|
public static void addXP(Player player, String skillType, int XP) {
|
||||||
UserManager.getPlayer(player).beginXpGain(getSkillType(skillType), XP);
|
addXP(player, skillType, XP, "UNKNOWN");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds XP to the player, calculates for XP Rate, skill modifiers, perks, child skills,
|
||||||
|
* and party sharing.
|
||||||
|
* </br>
|
||||||
|
* This function is designed for API usage.
|
||||||
|
*
|
||||||
|
* @param player The player to add XP to
|
||||||
|
* @param skillType The skill to add XP to
|
||||||
|
* @param XP The amount of XP to add
|
||||||
|
* @param xpGainReason The reason to gain XP
|
||||||
|
*
|
||||||
|
* @throws InvalidSkillException if the given skill is not valid
|
||||||
|
* @throws InvalidXPGainReasonException if the given xpGainReason is not valid
|
||||||
|
*/
|
||||||
|
public static void addXP(Player player, String skillType, int XP, String xpGainReason) {
|
||||||
|
UserManager.getPlayer(player).beginXpGain(getSkillType(skillType), XP, getXPGainReason(xpGainReason));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -349,12 +422,12 @@ public final class ExperienceAPI {
|
|||||||
profile.addLevels(parentSkill, (levels / parentSkills.size()));
|
profile.addLevels(parentSkill, (levels / parentSkills.size()));
|
||||||
}
|
}
|
||||||
|
|
||||||
profile.save();
|
profile.scheduleAsyncSave();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
profile.addLevels(skill, levels);
|
profile.addLevels(skill, levels);
|
||||||
profile.save();
|
profile.scheduleAsyncSave();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -583,7 +656,7 @@ public final class ExperienceAPI {
|
|||||||
PlayerProfile profile = getOfflineProfile(playerName);
|
PlayerProfile profile = getOfflineProfile(playerName);
|
||||||
|
|
||||||
profile.addXp(skill, XP);
|
profile.addXp(skill, XP);
|
||||||
profile.save();
|
profile.scheduleAsyncSave();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static PlayerProfile getOfflineProfile(String playerName) {
|
private static PlayerProfile getOfflineProfile(String playerName) {
|
||||||
@@ -615,4 +688,14 @@ public final class ExperienceAPI {
|
|||||||
|
|
||||||
return skill;
|
return skill;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static XPGainReason getXPGainReason(String reason) throws InvalidXPGainReasonException {
|
||||||
|
XPGainReason xpGainReason = XPGainReason.getXPGainReason(reason);
|
||||||
|
|
||||||
|
if (xpGainReason == null) {
|
||||||
|
throw new InvalidXPGainReasonException();
|
||||||
|
}
|
||||||
|
|
||||||
|
return xpGainReason;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -176,7 +176,7 @@ public final class PartyAPI {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static boolean hasAlly(String partyName) {
|
public static boolean hasAlly(String partyName) {
|
||||||
return PartyManager.getParty(partyName).getAlly() != null;
|
return getAllyName(partyName) != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getAllyName(String partyName) {
|
public static String getAllyName(String partyName) {
|
||||||
|
|||||||
@@ -0,0 +1,9 @@
|
|||||||
|
package com.gmail.nossr50.api.exceptions;
|
||||||
|
|
||||||
|
public class InvalidXPGainReasonException extends RuntimeException {
|
||||||
|
private static final long serialVersionUID = 4427052841957931157L;
|
||||||
|
|
||||||
|
public InvalidXPGainReasonException() {
|
||||||
|
super("That is not a valid XPGainReason.");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,7 +2,6 @@ package com.gmail.nossr50.commands;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
@@ -58,7 +57,7 @@ public class KrakenCommand implements TabExecutor {
|
|||||||
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
|
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
|
||||||
switch (args.length) {
|
switch (args.length) {
|
||||||
case 1:
|
case 1:
|
||||||
Set<String> playerNames = UserManager.getPlayerNames();
|
List<String> playerNames = CommandUtils.getOnlinePlayerNames(sender);
|
||||||
return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList<String>(playerNames.size()));
|
return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList<String>(playerNames.size()));
|
||||||
default:
|
default:
|
||||||
return ImmutableList.of();
|
return ImmutableList.of();
|
||||||
|
|||||||
@@ -30,7 +30,10 @@ public class McmmoCommand implements CommandExecutor {
|
|||||||
sender.sendMessage(ChatColor.GOLD + " - " + ChatColor.GREEN + "gjmcferrin@gmail.com" + ChatColor.GOLD + " Paypal");
|
sender.sendMessage(ChatColor.GOLD + " - " + ChatColor.GREEN + "gjmcferrin@gmail.com" + ChatColor.GOLD + " Paypal");
|
||||||
}
|
}
|
||||||
|
|
||||||
sender.sendMessage(LocaleLoader.getString("MOTD.Version", mcMMO.p.getDescription().getVersion()));
|
if (Permissions.showversion(sender)) {
|
||||||
|
sender.sendMessage(LocaleLoader.getString("MOTD.Version", mcMMO.p.getDescription().getVersion()));
|
||||||
|
}
|
||||||
|
|
||||||
mcMMO.getHolidayManager().anniversaryCheck(sender);
|
mcMMO.getHolidayManager().anniversaryCheck(sender);
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ package com.gmail.nossr50.commands;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
@@ -62,7 +61,7 @@ public abstract class ToggleCommand implements TabExecutor {
|
|||||||
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
|
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
|
||||||
switch (args.length) {
|
switch (args.length) {
|
||||||
case 1:
|
case 1:
|
||||||
Set<String> playerNames = UserManager.getPlayerNames();
|
List<String> playerNames = CommandUtils.getOnlinePlayerNames(sender);
|
||||||
return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList<String>(playerNames.size()));
|
return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList<String>(playerNames.size()));
|
||||||
default:
|
default:
|
||||||
return ImmutableList.of();
|
return ImmutableList.of();
|
||||||
|
|||||||
@@ -9,12 +9,12 @@ import org.bukkit.command.TabExecutor;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.util.StringUtil;
|
import org.bukkit.util.StringUtil;
|
||||||
|
|
||||||
import com.gmail.nossr50.config.Config;
|
|
||||||
import com.gmail.nossr50.datatypes.party.PartyFeature;
|
|
||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.gmail.nossr50.chat.ChatManager;
|
import com.gmail.nossr50.chat.ChatManager;
|
||||||
import com.gmail.nossr50.chat.ChatManagerFactory;
|
import com.gmail.nossr50.chat.ChatManagerFactory;
|
||||||
|
import com.gmail.nossr50.config.Config;
|
||||||
import com.gmail.nossr50.datatypes.chat.ChatMode;
|
import com.gmail.nossr50.datatypes.chat.ChatMode;
|
||||||
|
import com.gmail.nossr50.datatypes.party.PartyFeature;
|
||||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.util.commands.CommandUtils;
|
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||||
|
|||||||
@@ -4,8 +4,10 @@ import org.bukkit.command.CommandSender;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import com.gmail.nossr50.chat.PartyChatManager;
|
import com.gmail.nossr50.chat.PartyChatManager;
|
||||||
|
import com.gmail.nossr50.config.Config;
|
||||||
import com.gmail.nossr50.datatypes.chat.ChatMode;
|
import com.gmail.nossr50.datatypes.chat.ChatMode;
|
||||||
import com.gmail.nossr50.datatypes.party.Party;
|
import com.gmail.nossr50.datatypes.party.Party;
|
||||||
|
import com.gmail.nossr50.datatypes.party.PartyFeature;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.party.PartyManager;
|
import com.gmail.nossr50.party.PartyManager;
|
||||||
import com.gmail.nossr50.util.player.UserManager;
|
import com.gmail.nossr50.util.player.UserManager;
|
||||||
@@ -28,6 +30,11 @@ public class PartyChatCommand extends ChatCommand {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (party.getLevel() < Config.getInstance().getPartyFeatureUnlockLevel(PartyFeature.CHAT)) {
|
||||||
|
sender.sendMessage(LocaleLoader.getString("Party.Feature.Disabled.1"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
message = buildChatMessage(args, 0);
|
message = buildChatMessage(args, 0);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ package com.gmail.nossr50.commands.database;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
@@ -23,7 +22,7 @@ public class McremoveCommand implements TabExecutor {
|
|||||||
case 1:
|
case 1:
|
||||||
String playerName = CommandUtils.getMatchedPlayerName(args[0]);
|
String playerName = CommandUtils.getMatchedPlayerName(args[0]);
|
||||||
|
|
||||||
if (UserManager.getPlayer(playerName, true) == null && CommandUtils.unloadedProfile(sender, mcMMO.getDatabaseManager().loadPlayerProfile(playerName, false))) {
|
if (UserManager.getOfflinePlayer(playerName) == null && CommandUtils.unloadedProfile(sender, mcMMO.getDatabaseManager().loadPlayerProfile(playerName, false))) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -45,7 +44,7 @@ public class McremoveCommand implements TabExecutor {
|
|||||||
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
|
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
|
||||||
switch (args.length) {
|
switch (args.length) {
|
||||||
case 1:
|
case 1:
|
||||||
Set<String> playerNames = UserManager.getPlayerNames();
|
List<String> playerNames = CommandUtils.getOnlinePlayerNames(sender);
|
||||||
return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList<String>(playerNames.size()));
|
return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList<String>(playerNames.size()));
|
||||||
default:
|
default:
|
||||||
return ImmutableList.of();
|
return ImmutableList.of();
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import org.bukkit.entity.Player;
|
|||||||
|
|
||||||
import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
||||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||||
|
import com.gmail.nossr50.datatypes.skills.XPGainReason;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.util.EventUtils;
|
import com.gmail.nossr50.util.EventUtils;
|
||||||
import com.gmail.nossr50.util.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
@@ -26,11 +27,11 @@ public class AddlevelsCommand extends ExperienceCommand {
|
|||||||
profile.addLevels(skill, value);
|
profile.addLevels(skill, value);
|
||||||
|
|
||||||
if (player == null) {
|
if (player == null) {
|
||||||
profile.save();
|
profile.scheduleAsyncSave();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
EventUtils.handleLevelChangeEvent(player, skill, value, xpRemoved, true);
|
EventUtils.handleLevelChangeEvent(player, skill, value, xpRemoved, true, XPGainReason.COMMAND);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import org.bukkit.entity.Player;
|
|||||||
|
|
||||||
import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
||||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||||
|
import com.gmail.nossr50.datatypes.skills.XPGainReason;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.util.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
import com.gmail.nossr50.util.player.UserManager;
|
import com.gmail.nossr50.util.player.UserManager;
|
||||||
@@ -23,11 +24,11 @@ public class AddxpCommand extends ExperienceCommand {
|
|||||||
@Override
|
@Override
|
||||||
protected void handleCommand(Player player, PlayerProfile profile, SkillType skill, int value) {
|
protected void handleCommand(Player player, PlayerProfile profile, SkillType skill, int value) {
|
||||||
if (player != null) {
|
if (player != null) {
|
||||||
UserManager.getPlayer(player).applyXpGain(skill, value);
|
UserManager.getPlayer(player).applyXpGain(skill, value, XPGainReason.COMMAND);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
profile.addXp(skill, value);
|
profile.addXp(skill, value);
|
||||||
profile.save();
|
profile.scheduleAsyncSave();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ package com.gmail.nossr50.commands.experience;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
@@ -68,7 +67,7 @@ public abstract class ExperienceCommand implements TabExecutor {
|
|||||||
int value = Integer.parseInt(args[2]);
|
int value = Integer.parseInt(args[2]);
|
||||||
|
|
||||||
String playerName = CommandUtils.getMatchedPlayerName(args[0]);
|
String playerName = CommandUtils.getMatchedPlayerName(args[0]);
|
||||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(playerName, true);
|
McMMOPlayer mcMMOPlayer = UserManager.getOfflinePlayer(playerName);
|
||||||
|
|
||||||
// If the mcMMOPlayer doesn't exist, create a temporary profile and check if it's present in the database. If it's not, abort the process.
|
// If the mcMMOPlayer doesn't exist, create a temporary profile and check if it's present in the database. If it's not, abort the process.
|
||||||
if (mcMMOPlayer == null) {
|
if (mcMMOPlayer == null) {
|
||||||
@@ -96,7 +95,7 @@ public abstract class ExperienceCommand implements TabExecutor {
|
|||||||
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
|
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
|
||||||
switch (args.length) {
|
switch (args.length) {
|
||||||
case 1:
|
case 1:
|
||||||
Set<String> playerNames = UserManager.getPlayerNames();
|
List<String> playerNames = CommandUtils.getOnlinePlayerNames(sender);
|
||||||
return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList<String>(playerNames.size()));
|
return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList<String>(playerNames.size()));
|
||||||
case 2:
|
case 2:
|
||||||
return StringUtil.copyPartialMatches(args[1], SkillType.SKILL_NAMES, new ArrayList<String>(SkillType.SKILL_NAMES.size()));
|
return StringUtil.copyPartialMatches(args[1], SkillType.SKILL_NAMES, new ArrayList<String>(SkillType.SKILL_NAMES.size()));
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import org.bukkit.entity.Player;
|
|||||||
|
|
||||||
import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
||||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||||
|
import com.gmail.nossr50.datatypes.skills.XPGainReason;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.util.EventUtils;
|
import com.gmail.nossr50.util.EventUtils;
|
||||||
import com.gmail.nossr50.util.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
@@ -28,7 +29,7 @@ public class MmoeditCommand extends ExperienceCommand {
|
|||||||
profile.modifySkill(skill, value);
|
profile.modifySkill(skill, value);
|
||||||
|
|
||||||
if (player == null) {
|
if (player == null) {
|
||||||
profile.save();
|
profile.scheduleAsyncSave();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -36,7 +37,7 @@ public class MmoeditCommand extends ExperienceCommand {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
EventUtils.handleLevelChangeEvent(player, skill, value, xpRemoved, value > skillLevel);
|
EventUtils.handleLevelChangeEvent(player, skill, value, xpRemoved, value > skillLevel, XPGainReason.COMMAND);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ package com.gmail.nossr50.commands.experience;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
@@ -14,6 +13,7 @@ import com.gmail.nossr50.mcMMO;
|
|||||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||||
import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
||||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||||
|
import com.gmail.nossr50.datatypes.skills.XPGainReason;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.util.EventUtils;
|
import com.gmail.nossr50.util.EventUtils;
|
||||||
import com.gmail.nossr50.util.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
@@ -66,7 +66,7 @@ public class SkillresetCommand implements TabExecutor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
String playerName = CommandUtils.getMatchedPlayerName(args[0]);
|
String playerName = CommandUtils.getMatchedPlayerName(args[0]);
|
||||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(playerName, true);
|
McMMOPlayer mcMMOPlayer = UserManager.getOfflinePlayer(playerName);
|
||||||
|
|
||||||
// If the mcMMOPlayer doesn't exist, create a temporary profile and check if it's present in the database. If it's not, abort the process.
|
// If the mcMMOPlayer doesn't exist, create a temporary profile and check if it's present in the database. If it's not, abort the process.
|
||||||
if (mcMMOPlayer == null) {
|
if (mcMMOPlayer == null) {
|
||||||
@@ -94,7 +94,7 @@ public class SkillresetCommand implements TabExecutor {
|
|||||||
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
|
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
|
||||||
switch (args.length) {
|
switch (args.length) {
|
||||||
case 1:
|
case 1:
|
||||||
Set<String> playerNames = UserManager.getPlayerNames();
|
List<String> playerNames = CommandUtils.getOnlinePlayerNames(sender);
|
||||||
return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList<String>(playerNames.size()));
|
return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList<String>(playerNames.size()));
|
||||||
case 2:
|
case 2:
|
||||||
return StringUtil.copyPartialMatches(args[1], SkillType.SKILL_NAMES, new ArrayList<String>(SkillType.SKILL_NAMES.size()));
|
return StringUtil.copyPartialMatches(args[1], SkillType.SKILL_NAMES, new ArrayList<String>(SkillType.SKILL_NAMES.size()));
|
||||||
@@ -110,11 +110,11 @@ public class SkillresetCommand implements TabExecutor {
|
|||||||
profile.modifySkill(skill, 0);
|
profile.modifySkill(skill, 0);
|
||||||
|
|
||||||
if (player == null) {
|
if (player == null) {
|
||||||
profile.save();
|
profile.scheduleAsyncSave();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
EventUtils.handleLevelChangeEvent(player, skill, levelsRemoved, xpRemoved, false);
|
EventUtils.handleLevelChangeEvent(player, skill, levelsRemoved, xpRemoved, false, XPGainReason.COMMAND);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean permissionsCheckSelf(CommandSender sender) {
|
protected boolean permissionsCheckSelf(CommandSender sender) {
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
package com.gmail.nossr50.commands.party;
|
package com.gmail.nossr50.commands.party;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandExecutor;
|
import org.bukkit.command.CommandExecutor;
|
||||||
@@ -9,10 +12,10 @@ import org.bukkit.command.TabExecutor;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.util.StringUtil;
|
import org.bukkit.util.StringUtil;
|
||||||
|
|
||||||
import com.gmail.nossr50.mcMMO;
|
|
||||||
import com.gmail.nossr50.commands.chat.PartyChatCommand;
|
import com.gmail.nossr50.commands.chat.PartyChatCommand;
|
||||||
import com.gmail.nossr50.commands.party.alliance.PartyAllianceCommand;
|
import com.gmail.nossr50.commands.party.alliance.PartyAllianceCommand;
|
||||||
import com.gmail.nossr50.commands.party.teleport.PtpCommand;
|
import com.gmail.nossr50.commands.party.teleport.PtpCommand;
|
||||||
|
import com.gmail.nossr50.datatypes.party.Party;
|
||||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.util.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
@@ -52,7 +55,7 @@ public class PartyCommand implements TabExecutor {
|
|||||||
private CommandExecutor partyRenameCommand = new PartyRenameCommand();
|
private CommandExecutor partyRenameCommand = new PartyRenameCommand();
|
||||||
private CommandExecutor partyInfoCommand = new PartyInfoCommand();
|
private CommandExecutor partyInfoCommand = new PartyInfoCommand();
|
||||||
private CommandExecutor partyHelpCommand = new PartyHelpCommand();
|
private CommandExecutor partyHelpCommand = new PartyHelpCommand();
|
||||||
private CommandExecutor partyTeleportCommand = mcMMO.p.getCommand("ptp").getExecutor();
|
private CommandExecutor partyTeleportCommand = new PtpCommand();
|
||||||
private CommandExecutor partyChatCommand = new PartyChatCommand();
|
private CommandExecutor partyChatCommand = new PartyChatCommand();
|
||||||
private CommandExecutor partyAllianceCommand = new PartyAllianceCommand();
|
private CommandExecutor partyAllianceCommand = new PartyAllianceCommand();
|
||||||
|
|
||||||
@@ -175,7 +178,7 @@ public class PartyCommand implements TabExecutor {
|
|||||||
case INVITE:
|
case INVITE:
|
||||||
case KICK:
|
case KICK:
|
||||||
case OWNER:
|
case OWNER:
|
||||||
Set<String> playerNames = UserManager.getPlayerNames();
|
List<String> playerNames = CommandUtils.getOnlinePlayerNames(sender);
|
||||||
return StringUtil.copyPartialMatches(args[1], playerNames, new ArrayList<String>(playerNames.size()));
|
return StringUtil.copyPartialMatches(args[1], playerNames, new ArrayList<String>(playerNames.size()));
|
||||||
case XPSHARE:
|
case XPSHARE:
|
||||||
return StringUtil.copyPartialMatches(args[1], XPSHARE_COMPLETIONS, new ArrayList<String>(XPSHARE_COMPLETIONS.size()));
|
return StringUtil.copyPartialMatches(args[1], XPSHARE_COMPLETIONS, new ArrayList<String>(XPSHARE_COMPLETIONS.size()));
|
||||||
@@ -190,7 +193,10 @@ public class PartyCommand implements TabExecutor {
|
|||||||
List<String> matches = StringUtil.copyPartialMatches(args[1], PtpCommand.TELEPORT_SUBCOMMANDS, new ArrayList<String>(PtpCommand.TELEPORT_SUBCOMMANDS.size()));
|
List<String> matches = StringUtil.copyPartialMatches(args[1], PtpCommand.TELEPORT_SUBCOMMANDS, new ArrayList<String>(PtpCommand.TELEPORT_SUBCOMMANDS.size()));
|
||||||
|
|
||||||
if (matches.size() == 0) {
|
if (matches.size() == 0) {
|
||||||
playerNames = UserManager.getPlayerNames();
|
Player player = (Player) sender;
|
||||||
|
Party party = UserManager.getPlayer(player).getParty();
|
||||||
|
|
||||||
|
playerNames = party.getOnlinePlayerNames(player);
|
||||||
return StringUtil.copyPartialMatches(args[1], playerNames, new ArrayList<String>(playerNames.size()));
|
return StringUtil.copyPartialMatches(args[1], playerNames, new ArrayList<String>(playerNames.size()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -217,7 +223,7 @@ public class PartyCommand implements TabExecutor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private String[] extractArgs(String[] args) {
|
private String[] extractArgs(String[] args) {
|
||||||
return Arrays.copyOfRange(args, 1, args.length - 1);
|
return Arrays.copyOfRange(args, 1, args.length);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isItemShareCategory(String category) {
|
private boolean isItemShareCategory(String category) {
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ public class PartyHelpCommand implements CommandExecutor {
|
|||||||
sender.sendMessage(LocaleLoader.getString("Party.Help.7", "/party leader"));
|
sender.sendMessage(LocaleLoader.getString("Party.Help.7", "/party leader"));
|
||||||
sender.sendMessage(LocaleLoader.getString("Party.Help.8", "/party disband"));
|
sender.sendMessage(LocaleLoader.getString("Party.Help.8", "/party disband"));
|
||||||
sender.sendMessage(LocaleLoader.getString("Party.Help.9", "/party itemshare"));
|
sender.sendMessage(LocaleLoader.getString("Party.Help.9", "/party itemshare"));
|
||||||
sender.sendMessage(LocaleLoader.getString("Party.Help.10", "/party expshare"));
|
sender.sendMessage(LocaleLoader.getString("Party.Help.10", "/party xpshare"));
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ public class PartyInviteCommand implements CommandExecutor {
|
|||||||
switch (args.length) {
|
switch (args.length) {
|
||||||
case 2:
|
case 2:
|
||||||
String targetName = CommandUtils.getMatchedPlayerName(args[1]);
|
String targetName = CommandUtils.getMatchedPlayerName(args[1]);
|
||||||
McMMOPlayer mcMMOTarget = UserManager.getPlayer(targetName, true);
|
McMMOPlayer mcMMOTarget = UserManager.getOfflinePlayer(targetName);
|
||||||
|
|
||||||
if (!CommandUtils.checkPlayerExistence(sender, targetName, mcMMOTarget)) {
|
if (!CommandUtils.checkPlayerExistence(sender, targetName, mcMMOTarget)) {
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import com.gmail.nossr50.datatypes.party.Party;
|
|||||||
import com.gmail.nossr50.events.party.McMMOPartyChangeEvent.EventReason;
|
import com.gmail.nossr50.events.party.McMMOPartyChangeEvent.EventReason;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.party.PartyManager;
|
import com.gmail.nossr50.party.PartyManager;
|
||||||
|
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||||
import com.gmail.nossr50.util.player.UserManager;
|
import com.gmail.nossr50.util.player.UserManager;
|
||||||
|
|
||||||
public class PartyKickCommand implements CommandExecutor {
|
public class PartyKickCommand implements CommandExecutor {
|
||||||
@@ -19,13 +20,15 @@ public class PartyKickCommand implements CommandExecutor {
|
|||||||
switch (args.length) {
|
switch (args.length) {
|
||||||
case 2:
|
case 2:
|
||||||
Party playerParty = UserManager.getPlayer((Player) sender).getParty();
|
Party playerParty = UserManager.getPlayer((Player) sender).getParty();
|
||||||
OfflinePlayer target = mcMMO.p.getServer().getOfflinePlayer(args[1]);
|
String targetName = CommandUtils.getMatchedPlayerName(args[1]);
|
||||||
|
|
||||||
if (!playerParty.getMembers().contains(target.getName())) {
|
if (!playerParty.getMembers().contains(targetName)) {
|
||||||
sender.sendMessage(LocaleLoader.getString("Party.NotInYourParty", target.getName()));
|
sender.sendMessage(LocaleLoader.getString("Party.NotInYourParty", targetName));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
OfflinePlayer target = mcMMO.p.getServer().getOfflinePlayer(targetName);
|
||||||
|
|
||||||
if (target.isOnline()) {
|
if (target.isOnline()) {
|
||||||
Player onlineTarget = target.getPlayer();
|
Player onlineTarget = target.getPlayer();
|
||||||
String partyName = playerParty.getName();
|
String partyName = playerParty.getName();
|
||||||
|
|||||||
@@ -23,6 +23,11 @@ public class PartyAllianceAcceptCommand implements CommandExecutor {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (mcMMOPlayer.getParty().getAlly() != null) {
|
||||||
|
player.sendMessage(LocaleLoader.getString("Commands.Party.Alliance.AlreadyAllies"));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
PartyManager.acceptAllianceInvite(mcMMOPlayer);
|
PartyManager.acceptAllianceInvite(mcMMOPlayer);
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ package com.gmail.nossr50.commands.party.alliance;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
@@ -111,7 +110,7 @@ public class PartyAllianceCommand implements TabExecutor {
|
|||||||
List<String> matches = StringUtil.copyPartialMatches(args[0], ALLIANCE_SUBCOMMANDS, new ArrayList<String>(ALLIANCE_SUBCOMMANDS.size()));
|
List<String> matches = StringUtil.copyPartialMatches(args[0], ALLIANCE_SUBCOMMANDS, new ArrayList<String>(ALLIANCE_SUBCOMMANDS.size()));
|
||||||
|
|
||||||
if (matches.size() == 0) {
|
if (matches.size() == 0) {
|
||||||
Set<String> playerNames = UserManager.getPlayerNames();
|
List<String> playerNames = CommandUtils.getOnlinePlayerNames(commandSender);
|
||||||
return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList<String>(playerNames.size()));
|
return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList<String>(playerNames.size()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ public class PartyAllianceInviteCommand implements CommandExecutor {
|
|||||||
switch (args.length) {
|
switch (args.length) {
|
||||||
case 3:
|
case 3:
|
||||||
String targetName = CommandUtils.getMatchedPlayerName(args[2]);
|
String targetName = CommandUtils.getMatchedPlayerName(args[2]);
|
||||||
McMMOPlayer mcMMOTarget = UserManager.getPlayer(targetName, true);
|
McMMOPlayer mcMMOTarget = UserManager.getOfflinePlayer(targetName);
|
||||||
|
|
||||||
if (!CommandUtils.checkPlayerExistence(sender, targetName, mcMMOTarget)) {
|
if (!CommandUtils.checkPlayerExistence(sender, targetName, mcMMOTarget)) {
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ package com.gmail.nossr50.commands.party.teleport;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandExecutor;
|
import org.bukkit.command.CommandExecutor;
|
||||||
@@ -11,10 +10,10 @@ import org.bukkit.command.TabExecutor;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.util.StringUtil;
|
import org.bukkit.util.StringUtil;
|
||||||
|
|
||||||
import com.gmail.nossr50.datatypes.party.Party;
|
|
||||||
import com.gmail.nossr50.datatypes.party.PartyFeature;
|
|
||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.gmail.nossr50.config.Config;
|
import com.gmail.nossr50.config.Config;
|
||||||
|
import com.gmail.nossr50.datatypes.party.Party;
|
||||||
|
import com.gmail.nossr50.datatypes.party.PartyFeature;
|
||||||
import com.gmail.nossr50.datatypes.party.PartyTeleportRecord;
|
import com.gmail.nossr50.datatypes.party.PartyTeleportRecord;
|
||||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
@@ -44,6 +43,12 @@ public class PtpCommand implements TabExecutor {
|
|||||||
|
|
||||||
Player player = (Player) sender;
|
Player player = (Player) sender;
|
||||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
|
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
|
||||||
|
|
||||||
|
if (!mcMMOPlayer.inParty()) {
|
||||||
|
sender.sendMessage(LocaleLoader.getString("Commands.Party.None"));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
Party party = mcMMOPlayer.getParty();
|
Party party = mcMMOPlayer.getParty();
|
||||||
|
|
||||||
if (party.getLevel() < Config.getInstance().getPartyFeatureUnlockLevel(PartyFeature.TELEPORT)) {
|
if (party.getLevel() < Config.getInstance().getPartyFeatureUnlockLevel(PartyFeature.TELEPORT)) {
|
||||||
@@ -109,7 +114,14 @@ public class PtpCommand implements TabExecutor {
|
|||||||
List<String> matches = StringUtil.copyPartialMatches(args[0], TELEPORT_SUBCOMMANDS, new ArrayList<String>(TELEPORT_SUBCOMMANDS.size()));
|
List<String> matches = StringUtil.copyPartialMatches(args[0], TELEPORT_SUBCOMMANDS, new ArrayList<String>(TELEPORT_SUBCOMMANDS.size()));
|
||||||
|
|
||||||
if (matches.size() == 0) {
|
if (matches.size() == 0) {
|
||||||
Set<String> playerNames = UserManager.getPlayerNames();
|
Player player = (Player) sender;
|
||||||
|
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
|
||||||
|
|
||||||
|
if (!mcMMOPlayer.inParty()) {
|
||||||
|
return ImmutableList.of();
|
||||||
|
}
|
||||||
|
|
||||||
|
List<String> playerNames = mcMMOPlayer.getParty().getOnlinePlayerNames(player);
|
||||||
return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList<String>(playerNames.size()));
|
return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList<String>(playerNames.size()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ package com.gmail.nossr50.commands.player;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
@@ -29,7 +28,7 @@ public class InspectCommand implements TabExecutor {
|
|||||||
switch (args.length) {
|
switch (args.length) {
|
||||||
case 1:
|
case 1:
|
||||||
String playerName = CommandUtils.getMatchedPlayerName(args[0]);
|
String playerName = CommandUtils.getMatchedPlayerName(args[0]);
|
||||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(playerName, true);
|
McMMOPlayer mcMMOPlayer = UserManager.getOfflinePlayer(playerName);
|
||||||
|
|
||||||
// If the mcMMOPlayer doesn't exist, create a temporary profile and check if it's present in the database. If it's not, abort the process.
|
// If the mcMMOPlayer doesn't exist, create a temporary profile and check if it's present in the database. If it's not, abort the process.
|
||||||
if (mcMMOPlayer == null) {
|
if (mcMMOPlayer == null) {
|
||||||
@@ -104,7 +103,7 @@ public class InspectCommand implements TabExecutor {
|
|||||||
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
|
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
|
||||||
switch (args.length) {
|
switch (args.length) {
|
||||||
case 1:
|
case 1:
|
||||||
Set<String> playerNames = UserManager.getPlayerNames();
|
List<String> playerNames = CommandUtils.getOnlinePlayerNames(sender);
|
||||||
return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList<String>(playerNames.size()));
|
return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList<String>(playerNames.size()));
|
||||||
default:
|
default:
|
||||||
return ImmutableList.of();
|
return ImmutableList.of();
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ package com.gmail.nossr50.commands.player;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
@@ -15,7 +14,6 @@ import com.gmail.nossr50.config.Config;
|
|||||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.runnables.commands.McrankCommandAsyncTask;
|
import com.gmail.nossr50.runnables.commands.McrankCommandAsyncTask;
|
||||||
import com.gmail.nossr50.util.Misc;
|
|
||||||
import com.gmail.nossr50.util.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
import com.gmail.nossr50.util.commands.CommandUtils;
|
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||||
import com.gmail.nossr50.util.player.UserManager;
|
import com.gmail.nossr50.util.player.UserManager;
|
||||||
@@ -47,7 +45,7 @@ public class McrankCommand implements TabExecutor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
String playerName = CommandUtils.getMatchedPlayerName(args[0]);
|
String playerName = CommandUtils.getMatchedPlayerName(args[0]);
|
||||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(playerName, true);
|
McMMOPlayer mcMMOPlayer = UserManager.getOfflinePlayer(playerName);
|
||||||
|
|
||||||
if (mcMMOPlayer != null) {
|
if (mcMMOPlayer != null) {
|
||||||
Player player = mcMMOPlayer.getPlayer();
|
Player player = mcMMOPlayer.getPlayer();
|
||||||
@@ -73,7 +71,7 @@ public class McrankCommand implements TabExecutor {
|
|||||||
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
|
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
|
||||||
switch (args.length) {
|
switch (args.length) {
|
||||||
case 1:
|
case 1:
|
||||||
Set<String> playerNames = UserManager.getPlayerNames();
|
List<String> playerNames = CommandUtils.getOnlinePlayerNames(sender);
|
||||||
return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList<String>(playerNames.size()));
|
return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList<String>(playerNames.size()));
|
||||||
default:
|
default:
|
||||||
return ImmutableList.of();
|
return ImmutableList.of();
|
||||||
@@ -83,8 +81,9 @@ public class McrankCommand implements TabExecutor {
|
|||||||
private void display(CommandSender sender, String playerName) {
|
private void display(CommandSender sender, String playerName) {
|
||||||
if (sender instanceof Player) {
|
if (sender instanceof Player) {
|
||||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(sender.getName());
|
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(sender.getName());
|
||||||
|
long cooldownMillis = Math.max(Config.getInstance().getDatabasePlayerCooldown(), 1750);
|
||||||
|
|
||||||
if (mcMMOPlayer.getDatabaseATS() + Misc.PLAYER_DATABASE_COOLDOWN_MILLIS > System.currentTimeMillis()) {
|
if (mcMMOPlayer.getDatabaseATS() + cooldownMillis > System.currentTimeMillis()) {
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.Database.Cooldown"));
|
sender.sendMessage(LocaleLoader.getString("Commands.Database.Cooldown"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,7 +15,6 @@ import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
|||||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.runnables.commands.MctopCommandAsyncTask;
|
import com.gmail.nossr50.runnables.commands.MctopCommandAsyncTask;
|
||||||
import com.gmail.nossr50.util.Misc;
|
|
||||||
import com.gmail.nossr50.util.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
import com.gmail.nossr50.util.StringUtils;
|
import com.gmail.nossr50.util.StringUtils;
|
||||||
import com.gmail.nossr50.util.commands.CommandUtils;
|
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||||
@@ -85,8 +84,9 @@ public class MctopCommand implements TabExecutor {
|
|||||||
|
|
||||||
if (sender instanceof Player) {
|
if (sender instanceof Player) {
|
||||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(sender.getName());
|
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(sender.getName());
|
||||||
|
long cooldownMillis = Math.max(Config.getInstance().getDatabasePlayerCooldown(), 1750);
|
||||||
|
|
||||||
if (mcMMOPlayer.getDatabaseATS() + Misc.PLAYER_DATABASE_COOLDOWN_MILLIS > System.currentTimeMillis()) {
|
if (mcMMOPlayer.getDatabaseATS() + cooldownMillis > System.currentTimeMillis()) {
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.Database.Cooldown"));
|
sender.sendMessage(LocaleLoader.getString("Commands.Database.Cooldown"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,8 +33,8 @@ public class AlchemyCommand extends SkillCommand {
|
|||||||
AlchemyManager alchemyManager = UserManager.getPlayer(player).getAlchemyManager();
|
AlchemyManager alchemyManager = UserManager.getPlayer(player).getAlchemyManager();
|
||||||
String[] displayValues = new String[2];
|
String[] displayValues = new String[2];
|
||||||
|
|
||||||
displayValues[0] = decimal.format(alchemyManager.getBrewSpeed()) + "x";
|
displayValues[0] = decimal.format(alchemyManager.calculateBrewSpeed(false)) + "x";
|
||||||
displayValues[1] = isLucky ? decimal.format(alchemyManager.getBrewSpeedLucky()) + "x" : null;
|
displayValues[1] = isLucky ? decimal.format(alchemyManager.calculateBrewSpeed(true)) + "x" : null;
|
||||||
|
|
||||||
return displayValues;
|
return displayValues;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,205 @@
|
|||||||
|
package com.gmail.nossr50.commands.skills;
|
||||||
|
|
||||||
|
import java.text.DecimalFormat;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.command.TabExecutor;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
|
import com.gmail.nossr50.util.HolidayManager.FakeSkillType;
|
||||||
|
import com.gmail.nossr50.util.Misc;
|
||||||
|
import com.gmail.nossr50.util.StringUtils;
|
||||||
|
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableList;
|
||||||
|
|
||||||
|
public class AprilCommand implements TabExecutor {
|
||||||
|
private String skillName;
|
||||||
|
|
||||||
|
protected DecimalFormat percent = new DecimalFormat("##0.00%");
|
||||||
|
protected DecimalFormat decimal = new DecimalFormat("##0.00");
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
|
if (CommandUtils.noConsoleUsage(sender)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
skillName = StringUtils.getCapitalized(label);
|
||||||
|
|
||||||
|
switch (args.length) {
|
||||||
|
case 0:
|
||||||
|
Player player = (Player) sender;
|
||||||
|
FakeSkillType fakeSkillType = FakeSkillType.getByName(skillName);
|
||||||
|
|
||||||
|
float skillValue = Misc.getRandom().nextInt(99);
|
||||||
|
|
||||||
|
player.sendMessage(LocaleLoader.getString("Skills.Header", skillName));
|
||||||
|
player.sendMessage(LocaleLoader.getString("Commands.XPGain", getXPGainString(fakeSkillType)));
|
||||||
|
player.sendMessage(LocaleLoader.getString("Effects.Level", (int) skillValue, Misc.getRandom().nextInt(1000), 1000 + Misc.getRandom().nextInt(1000)));
|
||||||
|
|
||||||
|
|
||||||
|
List<String> effectMessages = effectsDisplay(fakeSkillType);
|
||||||
|
|
||||||
|
if (!effectMessages.isEmpty()) {
|
||||||
|
player.sendMessage(LocaleLoader.getString("Skills.Header", LocaleLoader.getString("Effects.Effects")));
|
||||||
|
|
||||||
|
for (String message : effectMessages) {
|
||||||
|
player.sendMessage(message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
List<String> statsMessages = statsDisplay(fakeSkillType);
|
||||||
|
|
||||||
|
if (!statsMessages.isEmpty()) {
|
||||||
|
player.sendMessage(LocaleLoader.getString("Skills.Header", LocaleLoader.getString("Commands.Stats.Self")));
|
||||||
|
|
||||||
|
for (String message : statsMessages) {
|
||||||
|
player.sendMessage(message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
player.sendMessage(LocaleLoader.formatString("[[DARK_AQUA]]Guide for {0} available - type /APRIL FOOLS ! :D", skillName));
|
||||||
|
return true;
|
||||||
|
|
||||||
|
default:
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getXPGainString(FakeSkillType fakeSkillType) {
|
||||||
|
switch (fakeSkillType) {
|
||||||
|
case MACHO:
|
||||||
|
return "Get beaten up";
|
||||||
|
case JUMPING:
|
||||||
|
return "Kris Kross will make ya Jump Jump";
|
||||||
|
case THROWING:
|
||||||
|
return "Chuck your items on the floor";
|
||||||
|
case WRECKING:
|
||||||
|
return "I'M GONNA WRECK IT!";
|
||||||
|
case CRAFTING:
|
||||||
|
return "Craft apple pies";
|
||||||
|
case WALKING:
|
||||||
|
return "Walk around the park";
|
||||||
|
case SWIMMING:
|
||||||
|
return "Like a fish on a bicycle";
|
||||||
|
case FALLING:
|
||||||
|
return "Faceplant the floor, headbutt the ground";
|
||||||
|
case CLIMBING:
|
||||||
|
return "Climb the highest mountain";
|
||||||
|
case FLYING:
|
||||||
|
return "I believe I can fly";
|
||||||
|
case DIVING:
|
||||||
|
return "Scuba club 4000";
|
||||||
|
case PIGGY:
|
||||||
|
return "OINK! OINK!";
|
||||||
|
default:
|
||||||
|
return "Sit and wait?";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
|
||||||
|
switch (args.length) {
|
||||||
|
case 1:
|
||||||
|
return ImmutableList.of("?");
|
||||||
|
default:
|
||||||
|
return ImmutableList.of();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<String> effectsDisplay(FakeSkillType fakeSkillType) {
|
||||||
|
List<String> messages = new ArrayList<String>();
|
||||||
|
|
||||||
|
switch (fakeSkillType) {
|
||||||
|
case MACHO:
|
||||||
|
messages.add(LocaleLoader.getString("Effects.Template", "Punching bag", "Absorb damage, like a bag of sand"));
|
||||||
|
break;
|
||||||
|
case JUMPING:
|
||||||
|
messages.add(LocaleLoader.getString("Effects.Template", "Jump", "PRESS SPACE TO JUMP"));
|
||||||
|
messages.add(LocaleLoader.getString("Effects.Template", "Jump Twice", "PRESS SPACE TWICE TO JUMP TWICE"));
|
||||||
|
break;
|
||||||
|
case THROWING:
|
||||||
|
messages.add(LocaleLoader.getString("Effects.Template", "Drop Item", "Randomly drop items, at random"));
|
||||||
|
break;
|
||||||
|
case WRECKING:
|
||||||
|
messages.add(LocaleLoader.getString("Effects.Template", "Ralphinator", "Smash windows with your fists"));
|
||||||
|
break;
|
||||||
|
case CRAFTING:
|
||||||
|
messages.add(LocaleLoader.getString("Effects.Template", "Crafting", "Chance of successful craft"));
|
||||||
|
break;
|
||||||
|
case WALKING:
|
||||||
|
messages.add(LocaleLoader.getString("Effects.Template", "Walk", "Traveling gracefully by foot"));
|
||||||
|
break;
|
||||||
|
case SWIMMING:
|
||||||
|
messages.add(LocaleLoader.getString("Effects.Template", "Swim", "Just keep swimming, swimming, swimming"));
|
||||||
|
break;
|
||||||
|
case FALLING:
|
||||||
|
messages.add(LocaleLoader.getString("Effects.Template", "Skydiving", "Go jump of a cliff. No, seriously."));
|
||||||
|
break;
|
||||||
|
case CLIMBING:
|
||||||
|
messages.add(LocaleLoader.getString("Effects.Template", "Rock Climber", "Use string to climb mountains faster"));
|
||||||
|
break;
|
||||||
|
case FLYING:
|
||||||
|
messages.add(LocaleLoader.getString("Effects.Template", "Fly", "Throw yourself at the ground and miss"));
|
||||||
|
break;
|
||||||
|
case DIVING:
|
||||||
|
messages.add(LocaleLoader.getString("Effects.Template", "Hold Breath", "Press shift to hold your breath longer"));
|
||||||
|
break;
|
||||||
|
case PIGGY:
|
||||||
|
messages.add(LocaleLoader.getString("Effects.Template", "Carrot Turbo", "Supercharge your pigs with carrots"));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return messages;
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<String> statsDisplay(FakeSkillType fakeSkillType) {
|
||||||
|
List<String> messages = new ArrayList<String>();
|
||||||
|
|
||||||
|
switch (fakeSkillType) {
|
||||||
|
case MACHO:
|
||||||
|
messages.add(LocaleLoader.formatString("[[RED]]Damage Taken: [[YELLOW]]{0}%", decimal.format(Misc.getRandom().nextInt(77))));
|
||||||
|
break;
|
||||||
|
case JUMPING:
|
||||||
|
messages.add(LocaleLoader.formatString("[[RED]]Double Jump Chance: [[YELLOW]]{0}%", decimal.format(Misc.getRandom().nextInt(27))));
|
||||||
|
break;
|
||||||
|
case THROWING:
|
||||||
|
messages.add(LocaleLoader.formatString("[[RED]]Drop Item Chance: [[YELLOW]]{0}%", decimal.format(Misc.getRandom().nextInt(87))));
|
||||||
|
break;
|
||||||
|
case WRECKING:
|
||||||
|
messages.add(LocaleLoader.formatString("[[RED]]Wrecking Chance: [[YELLOW]]{0}%", decimal.format(Misc.getRandom().nextInt(14))));
|
||||||
|
break;
|
||||||
|
case CRAFTING:
|
||||||
|
messages.add(LocaleLoader.formatString("[[RED]]Crafting Success: [[YELLOW]]{0}%", decimal.format(Misc.getRandom().nextInt(27))));
|
||||||
|
break;
|
||||||
|
case WALKING:
|
||||||
|
messages.add(LocaleLoader.formatString("[[RED]]Walk Chance: [[YELLOW]]{0}%", decimal.format(Misc.getRandom().nextInt(27))));
|
||||||
|
break;
|
||||||
|
case SWIMMING:
|
||||||
|
messages.add(LocaleLoader.formatString("[[RED]]Swim Chance: [[YELLOW]]{0}%", decimal.format(Misc.getRandom().nextInt(27))));
|
||||||
|
break;
|
||||||
|
case FALLING:
|
||||||
|
messages.add(LocaleLoader.formatString("[[RED]]Skydiving Success: [[YELLOW]]{0}%", decimal.format(Misc.getRandom().nextInt(37))));
|
||||||
|
break;
|
||||||
|
case CLIMBING:
|
||||||
|
messages.add(LocaleLoader.formatString("[[RED]]Rock Climber Chance: [[YELLOW]]{0}%", decimal.format(Misc.getRandom().nextInt(27))));
|
||||||
|
break;
|
||||||
|
case FLYING:
|
||||||
|
messages.add(LocaleLoader.formatString("[[RED]]Fly Chance: [[YELLOW]]{0}%", decimal.format(Misc.getRandom().nextInt(27))));
|
||||||
|
break;
|
||||||
|
case DIVING:
|
||||||
|
messages.add(LocaleLoader.formatString("[[RED]]Hold Breath Chance: [[YELLOW]]{0}%", decimal.format(Misc.getRandom().nextInt(27))));
|
||||||
|
break;
|
||||||
|
case PIGGY:
|
||||||
|
messages.add(LocaleLoader.formatString("[[RED]]Carrot Turbo Boost: [[YELLOW]]{0}%", decimal.format(Misc.getRandom().nextInt(80)) + 10));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return messages;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -65,7 +65,7 @@ public class ArcheryCommand extends SkillCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (canDaze) {
|
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) {
|
if (canRetrieve) {
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import java.util.ArrayList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.block.Biome;
|
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@@ -51,7 +50,6 @@ public class FishingCommand extends SkillCommand {
|
|||||||
@Override
|
@Override
|
||||||
protected void dataCalculations(Player player, float skillValue, boolean isLucky) {
|
protected void dataCalculations(Player player, float skillValue, boolean isLucky) {
|
||||||
FishingManager fishingManager = UserManager.getPlayer(player).getFishingManager();
|
FishingManager fishingManager = UserManager.getPlayer(player).getFishingManager();
|
||||||
boolean isStorming = player.getWorld().hasStorm();
|
|
||||||
|
|
||||||
// TREASURE HUNTER
|
// TREASURE HUNTER
|
||||||
if (canTreasureHunt) {
|
if (canTreasureHunt) {
|
||||||
@@ -70,7 +68,7 @@ public class FishingCommand extends SkillCommand {
|
|||||||
double totalEnchantChance = 0;
|
double totalEnchantChance = 0;
|
||||||
|
|
||||||
for (Rarity rarity : Rarity.values()) {
|
for (Rarity rarity : Rarity.values()) {
|
||||||
if (rarity != Rarity.TRAP || rarity != Rarity.RECORD) {
|
if (rarity != Rarity.TRAP && rarity != Rarity.RECORD) {
|
||||||
totalEnchantChance += TreasureConfig.getInstance().getEnchantmentDropRate(lootTier, rarity);
|
totalEnchantChance += TreasureConfig.getInstance().getEnchantmentDropRate(lootTier, rarity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -92,16 +90,14 @@ public class FishingCommand extends SkillCommand {
|
|||||||
|
|
||||||
// MASTER ANGLER
|
// MASTER ANGLER
|
||||||
if (canMasterAngler) {
|
if (canMasterAngler) {
|
||||||
double rawBiteChance = 1.0 / (isStorming ? 300 : 500);
|
double rawBiteChance = 1.0 / (player.getWorld().hasStorm() ? 300 : 500);
|
||||||
Location location = fishingManager.getHookLocation();
|
Location location = fishingManager.getHookLocation();
|
||||||
|
|
||||||
if (location == null) {
|
if (location == null) {
|
||||||
location = player.getLocation();
|
location = player.getLocation();
|
||||||
}
|
}
|
||||||
|
|
||||||
Biome biome = location.getBlock().getBiome();
|
if (Fishing.masterAnglerBiomes.contains(location.getBlock().getBiome())) {
|
||||||
|
|
||||||
if (biome == Biome.RIVER || biome == Biome.OCEAN) {
|
|
||||||
rawBiteChance = rawBiteChance * AdvancedConfig.getInstance().getMasterAnglerBiomeModifier();
|
rawBiteChance = rawBiteChance * AdvancedConfig.getInstance().getMasterAnglerBiomeModifier();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import org.bukkit.Material;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
|
import com.gmail.nossr50.datatypes.skills.MaterialType;
|
||||||
import com.gmail.nossr50.datatypes.skills.SecondaryAbility;
|
import com.gmail.nossr50.datatypes.skills.SecondaryAbility;
|
||||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
@@ -26,7 +27,6 @@ public class RepairCommand extends SkillCommand {
|
|||||||
private boolean canSuperRepair;
|
private boolean canSuperRepair;
|
||||||
private boolean canMasterRepair;
|
private boolean canMasterRepair;
|
||||||
private boolean canArcaneForge;
|
private boolean canArcaneForge;
|
||||||
private boolean canSalvage;
|
|
||||||
private boolean canRepairStone;
|
private boolean canRepairStone;
|
||||||
private boolean canRepairIron;
|
private boolean canRepairIron;
|
||||||
private boolean canRepairGold;
|
private boolean canRepairGold;
|
||||||
@@ -77,14 +77,13 @@ public class RepairCommand extends SkillCommand {
|
|||||||
canSuperRepair = Permissions.secondaryAbilityEnabled(player, SecondaryAbility.SUPER_REPAIR);
|
canSuperRepair = Permissions.secondaryAbilityEnabled(player, SecondaryAbility.SUPER_REPAIR);
|
||||||
canMasterRepair = Permissions.secondaryAbilityEnabled(player, SecondaryAbility.REPAIR_MASTERY);
|
canMasterRepair = Permissions.secondaryAbilityEnabled(player, SecondaryAbility.REPAIR_MASTERY);
|
||||||
canArcaneForge = Permissions.secondaryAbilityEnabled(player, SecondaryAbility.ARCANE_FORGING);
|
canArcaneForge = Permissions.secondaryAbilityEnabled(player, SecondaryAbility.ARCANE_FORGING);
|
||||||
canSalvage = Permissions.secondaryAbilityEnabled(player, SecondaryAbility.SALVAGE);
|
canRepairDiamond = Permissions.repairMaterialType(player, MaterialType.DIAMOND);
|
||||||
canRepairDiamond = Permissions.repairDiamond(player);
|
canRepairGold = Permissions.repairMaterialType(player, MaterialType.GOLD);
|
||||||
canRepairGold = Permissions.repairGold(player);
|
canRepairIron = Permissions.repairMaterialType(player, MaterialType.IRON);
|
||||||
canRepairIron = Permissions.repairIron(player);
|
canRepairStone = Permissions.repairMaterialType(player, MaterialType.STONE);
|
||||||
canRepairStone = Permissions.repairStone(player);
|
canRepairString = Permissions.repairMaterialType(player, MaterialType.STRING);
|
||||||
canRepairString = Permissions.repairString(player);
|
canRepairLeather = Permissions.repairMaterialType(player, MaterialType.LEATHER);
|
||||||
canRepairLeather = Permissions.repairLeather(player);
|
canRepairWood = Permissions.repairMaterialType(player, MaterialType.WOOD);
|
||||||
canRepairWood = Permissions.repairWood(player);
|
|
||||||
arcaneBypass = Permissions.arcaneBypass(player);
|
arcaneBypass = Permissions.arcaneBypass(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -122,10 +121,6 @@ public class RepairCommand extends SkillCommand {
|
|||||||
messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Repair.Effect.6", diamondLevel), LocaleLoader.getString("Repair.Effect.7")));
|
messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Repair.Effect.6", diamondLevel), LocaleLoader.getString("Repair.Effect.7")));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (canSalvage && Repair.salvageUnlockLevel > 0) {
|
|
||||||
messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Repair.Effect.16", Repair.salvageUnlockLevel), LocaleLoader.getString("Repair.Effect.17")));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (canArcaneForge) {
|
if (canArcaneForge) {
|
||||||
messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Repair.Effect.8"), LocaleLoader.getString("Repair.Effect.9")));
|
messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Repair.Effect.8"), LocaleLoader.getString("Repair.Effect.9")));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,79 @@
|
|||||||
|
package com.gmail.nossr50.commands.skills;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import com.gmail.nossr50.datatypes.skills.SecondaryAbility;
|
||||||
|
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||||
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
|
import com.gmail.nossr50.skills.salvage.Salvage;
|
||||||
|
import com.gmail.nossr50.skills.salvage.SalvageManager;
|
||||||
|
import com.gmail.nossr50.util.Permissions;
|
||||||
|
import com.gmail.nossr50.util.player.UserManager;
|
||||||
|
|
||||||
|
public class SalvageCommand extends SkillCommand {
|
||||||
|
private boolean canAdvancedSalvage;
|
||||||
|
private boolean canArcaneSalvage;
|
||||||
|
|
||||||
|
public SalvageCommand() {
|
||||||
|
super(SkillType.SALVAGE);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void dataCalculations(Player player, float skillValue, boolean isLucky) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void permissionsCheck(Player player) {
|
||||||
|
canAdvancedSalvage = Permissions.secondaryAbilityEnabled(player, SecondaryAbility.ADVANCED_SALVAGE);
|
||||||
|
canArcaneSalvage = Permissions.secondaryAbilityEnabled(player, SecondaryAbility.ARCANE_SALVAGE);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected List<String> effectsDisplay() {
|
||||||
|
List<String> messages = new ArrayList<String>();
|
||||||
|
|
||||||
|
if (canAdvancedSalvage) {
|
||||||
|
messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Salvage.Effect.0"), LocaleLoader.getString("Salvage.Effect.1")));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (canArcaneSalvage) {
|
||||||
|
messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Salvage.Effect.2"), LocaleLoader.getString("Salvage.Effect.3")));
|
||||||
|
}
|
||||||
|
|
||||||
|
return messages;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected List<String> statsDisplay(Player player, float skillValue, boolean hasEndurance, boolean isLucky) {
|
||||||
|
List<String> messages = new ArrayList<String>();
|
||||||
|
SalvageManager salvageManager = UserManager.getPlayer(player).getSalvageManager();
|
||||||
|
|
||||||
|
if (canAdvancedSalvage) {
|
||||||
|
if (skillValue < Salvage.advancedSalvageUnlockLevel) {
|
||||||
|
messages.add(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Salvage.Ability.Locked.0", Salvage.advancedSalvageUnlockLevel)));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
messages.add(LocaleLoader.getString("Ability.Generic.Template", LocaleLoader.getString("Salvage.Ability.Bonus.0"), LocaleLoader.getString("Salvage.Ability.Bonus.1", percent.format(salvageManager.getMaxSalvagePercentage()))));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (canArcaneSalvage) {
|
||||||
|
messages.add(LocaleLoader.getString("Salvage.Arcane.Rank", salvageManager.getArcaneSalvageRank(), Salvage.Tier.values().length));
|
||||||
|
|
||||||
|
if (Salvage.arcaneSalvageEnchantLoss) {
|
||||||
|
messages.add(LocaleLoader.getString("Ability.Generic.Template", LocaleLoader.getString("Salvage.Arcane.ExtractFull"), percent.format(salvageManager.getExtractFullEnchantChance() / 100)));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Salvage.arcaneSalvageDowngrades) {
|
||||||
|
messages.add(LocaleLoader.getString("Ability.Generic.Template", LocaleLoader.getString("Salvage.Arcane.ExtractPartial"), percent.format(salvageManager.getExtractPartialEnchantChance() / 100)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return messages;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -4,7 +4,6 @@ import java.text.DecimalFormat;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import com.gmail.nossr50.util.Motd;
|
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandExecutor;
|
import org.bukkit.command.CommandExecutor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
@@ -18,6 +17,7 @@ import com.gmail.nossr50.datatypes.skills.SecondaryAbility;
|
|||||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.skills.child.FamilyTree;
|
import com.gmail.nossr50.skills.child.FamilyTree;
|
||||||
|
import com.gmail.nossr50.util.Motd;
|
||||||
import com.gmail.nossr50.util.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
import com.gmail.nossr50.util.StringUtils;
|
import com.gmail.nossr50.util.StringUtils;
|
||||||
import com.gmail.nossr50.util.commands.CommandUtils;
|
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||||
|
|||||||
@@ -91,9 +91,9 @@ public class TamingCommand extends SkillCommand {
|
|||||||
|
|
||||||
if (canCallWild) {
|
if (canCallWild) {
|
||||||
messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Taming.Effect.12"), LocaleLoader.getString("Taming.Effect.13")));
|
messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Taming.Effect.12"), LocaleLoader.getString("Taming.Effect.13")));
|
||||||
messages.add(LocaleLoader.getString("Taming.Effect.14", Config.getInstance().getTamingCOTWOcelotCost()));
|
messages.add(LocaleLoader.getString("Taming.Effect.14", Config.getInstance().getTamingCOTWCost(EntityType.OCELOT)));
|
||||||
messages.add(LocaleLoader.getString("Taming.Effect.15", Config.getInstance().getTamingCOTWWolfCost()));
|
messages.add(LocaleLoader.getString("Taming.Effect.15", Config.getInstance().getTamingCOTWCost(EntityType.WOLF)));
|
||||||
messages.add(LocaleLoader.getString("Taming.Effect.20", Config.getInstance().getTamingCOTWHorseCost()));
|
messages.add(LocaleLoader.getString("Taming.Effect.20", Config.getInstance().getTamingCOTWCost(EntityType.HORSE)));
|
||||||
}
|
}
|
||||||
|
|
||||||
return messages;
|
return messages;
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ public class UnarmedCommand extends SkillCommand {
|
|||||||
|
|
||||||
// IRON ARM
|
// IRON ARM
|
||||||
if (canIronArm) {
|
if (canIronArm) {
|
||||||
ironArmBonus = Math.min(3 + ((int) skillValue / Unarmed.ironArmIncreaseLevel), Unarmed.ironArmMaxBonusDamage);
|
ironArmBonus = Math.min(Unarmed.ironArmMinBonusDamage + ((int) skillValue / Unarmed.ironArmIncreaseLevel), Unarmed.ironArmMaxBonusDamage);
|
||||||
}
|
}
|
||||||
|
|
||||||
// IRON GRIP
|
// IRON GRIP
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import com.gmail.nossr50.skills.alchemy.Alchemy;
|
|||||||
import com.gmail.nossr50.skills.fishing.Fishing;
|
import com.gmail.nossr50.skills.fishing.Fishing;
|
||||||
import com.gmail.nossr50.skills.mining.BlastMining;
|
import com.gmail.nossr50.skills.mining.BlastMining;
|
||||||
import com.gmail.nossr50.skills.repair.ArcaneForging;
|
import com.gmail.nossr50.skills.repair.ArcaneForging;
|
||||||
|
import com.gmail.nossr50.skills.salvage.Salvage;
|
||||||
import com.gmail.nossr50.skills.smelting.Smelting;
|
import com.gmail.nossr50.skills.smelting.Smelting;
|
||||||
import com.gmail.nossr50.util.StringUtils;
|
import com.gmail.nossr50.util.StringUtils;
|
||||||
|
|
||||||
@@ -133,7 +134,7 @@ public class AdvancedConfig extends AutoUpdateConfigLoader {
|
|||||||
reason.add("Skills.Acrobatics.Daze.MaxBonusLevel should be at least 1!");
|
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!");
|
reason.add("Skills.Acrobatics.Daze.BonusDamage should be at least 0!");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -378,10 +379,6 @@ public class AdvancedConfig extends AutoUpdateConfigLoader {
|
|||||||
reason.add("Skills.Repair.SuperRepair.MaxBonusLevel should be at least 1!");
|
reason.add("Skills.Repair.SuperRepair.MaxBonusLevel should be at least 1!");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getSalvageUnlockLevel() < 0) {
|
|
||||||
reason.add("Skills.Repair.Salvage.UnlockLevel should be at least 0!");
|
|
||||||
}
|
|
||||||
|
|
||||||
List<ArcaneForging.Tier> arcaneForgingTierList = Arrays.asList(ArcaneForging.Tier.values());
|
List<ArcaneForging.Tier> arcaneForgingTierList = Arrays.asList(ArcaneForging.Tier.values());
|
||||||
|
|
||||||
for (ArcaneForging.Tier tier : arcaneForgingTierList) {
|
for (ArcaneForging.Tier tier : arcaneForgingTierList) {
|
||||||
@@ -414,6 +411,51 @@ public class AdvancedConfig extends AutoUpdateConfigLoader {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* SALVAGE */
|
||||||
|
if (getSalvageMaxPercentage() < 1) {
|
||||||
|
reason.add("Skills.Salvage.MaxPercentage should be at least 1!");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (getSalvageMaxPercentageLevel() < 1) {
|
||||||
|
reason.add("Skills.Salvage.MaxPercentageLevel should be at least 1!");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (getAdvancedSalvageUnlockLevel() < 1) {
|
||||||
|
reason.add("Skills.Salvage.AdvancedSalvage.UnlockLevel should be at least 1!");
|
||||||
|
}
|
||||||
|
|
||||||
|
List<Salvage.Tier> salvageTierList = Arrays.asList(Salvage.Tier.values());
|
||||||
|
|
||||||
|
for (Salvage.Tier tier : salvageTierList) {
|
||||||
|
if (getArcaneSalvageRankLevel(tier) < 0) {
|
||||||
|
reason.add("Skills.Salvage.ArcaneSalvage.Rank_Levels.Rank_" + tier.toNumerical() + " should be at least 0!");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (getArcaneSalvageExtractFullEnchantsChance(tier) < 0 || getArcaneSalvageExtractFullEnchantsChance(tier) > 100) {
|
||||||
|
reason.add("Skills.Salvage.ArcaneSalvage.ExtractFullEnchant.Rank_" + tier.toNumerical() + " only accepts values from 0 to 100!");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (getArcaneSalvageExtractPartialEnchantsChance(tier) < 0 || getArcaneSalvageExtractPartialEnchantsChance(tier) > 100) {
|
||||||
|
reason.add("Skills.Salvage.ArcaneSalvage.ExtractPartialEnchant.Rank_" + tier.toNumerical() + " only accepts values from 0 to 100!");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tier != Salvage.Tier.EIGHT) {
|
||||||
|
Salvage.Tier nextTier = salvageTierList.get(salvageTierList.indexOf(tier) - 1);
|
||||||
|
|
||||||
|
if (getArcaneSalvageRankLevel(tier) >= getArcaneSalvageRankLevel(nextTier)) {
|
||||||
|
reason.add("Skills.Salvage.ArcaneSalvage.Rank_Levels.Rank_" + tier.toNumerical() + " should be less than Skills.Salvage.ArcaneSalvage.Rank_Levels.Rank_" + nextTier.toNumerical() + "!");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (getArcaneSalvageExtractFullEnchantsChance(tier) > getArcaneSalvageExtractFullEnchantsChance(nextTier)) {
|
||||||
|
reason.add("Skills.Salvage.ArcaneSalvage.ExtractFullEnchant.Rank_" + tier.toNumerical() + " should be less than or equal to Skills.Salvage.ArcaneSalvage.ExtractFullEnchant.Rank_" + nextTier.toNumerical() + "!");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (getArcaneSalvageExtractPartialEnchantsChance(tier) > getArcaneSalvageExtractPartialEnchantsChance(nextTier)) {
|
||||||
|
reason.add("Skills.Salvage.ArcaneSalvage.ExtractPartialEnchant.Rank_" + tier.toNumerical() + " should be less than or equal to Skills.Salvage.ArcaneSalvage.ExtractPartialEnchant.Rank_" + nextTier.toNumerical() + "!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* SMELTING */
|
/* SMELTING */
|
||||||
if (getBurnModifierMaxLevel() < 1) {
|
if (getBurnModifierMaxLevel() < 1) {
|
||||||
reason.add("Skills.Smelting.FuelEfficiency.MaxBonusLevel should be at least 1!");
|
reason.add("Skills.Smelting.FuelEfficiency.MaxBonusLevel should be at least 1!");
|
||||||
@@ -672,7 +714,7 @@ public class AdvancedConfig extends AutoUpdateConfigLoader {
|
|||||||
public double getSkillShotBonusMax() { return config.getDouble("Skills.Archery.SkillShot.MaxBonus", 2.0D); }
|
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 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); }
|
public double getForceMultiplier() { return config.getDouble("Skills.Archery.ForceMultiplier", 2.0D); }
|
||||||
|
|
||||||
@@ -725,7 +767,6 @@ public class AdvancedConfig extends AutoUpdateConfigLoader {
|
|||||||
/* REPAIR */
|
/* REPAIR */
|
||||||
public double getRepairMasteryMaxBonus() { return config.getDouble("Skills.Repair.RepairMastery.MaxBonusPercentage", 200.0D); }
|
public double getRepairMasteryMaxBonus() { return config.getDouble("Skills.Repair.RepairMastery.MaxBonusPercentage", 200.0D); }
|
||||||
public int getRepairMasteryMaxLevel() { return config.getInt("Skills.Repair.RepairMastery.MaxBonusLevel", 1000); }
|
public int getRepairMasteryMaxLevel() { return config.getInt("Skills.Repair.RepairMastery.MaxBonusLevel", 1000); }
|
||||||
public int getSalvageUnlockLevel() { return config.getInt("Skills.Repair.Salvage.UnlockLevel", 600); }
|
|
||||||
|
|
||||||
/* Arcane Forging */
|
/* Arcane Forging */
|
||||||
public int getArcaneForgingRankLevel(ArcaneForging.Tier tier) { return config.getInt("Skills.Repair.ArcaneForging.Rank_Levels.Rank_" + tier.toNumerical()); }
|
public int getArcaneForgingRankLevel(ArcaneForging.Tier tier) { return config.getInt("Skills.Repair.ArcaneForging.Rank_Levels.Rank_" + tier.toNumerical()); }
|
||||||
@@ -736,6 +777,19 @@ public class AdvancedConfig extends AutoUpdateConfigLoader {
|
|||||||
public boolean getArcaneForgingDowngradeEnabled() { return config.getBoolean("Skills.Repair.ArcaneForging.Downgrades_Enabled", true); }
|
public boolean getArcaneForgingDowngradeEnabled() { return config.getBoolean("Skills.Repair.ArcaneForging.Downgrades_Enabled", true); }
|
||||||
public double getArcaneForgingDowngradeChance(ArcaneForging.Tier tier) { return config.getDouble("Skills.Repair.ArcaneForging.Downgrades_Chance.Rank_" + tier.toNumerical()); }
|
public double getArcaneForgingDowngradeChance(ArcaneForging.Tier tier) { return config.getDouble("Skills.Repair.ArcaneForging.Downgrades_Chance.Rank_" + tier.toNumerical()); }
|
||||||
|
|
||||||
|
/* SALVAGE */
|
||||||
|
public double getSalvageMaxPercentage() { return config.getDouble("Skills.Salvage.MaxPercentage", 100.0D); }
|
||||||
|
public int getSalvageMaxPercentageLevel() { return config.getInt("Skills.Salvage.MaxPercentageLevel", 1000); }
|
||||||
|
|
||||||
|
public int getAdvancedSalvageUnlockLevel() { return config.getInt("Skills.Salvage.AdvancedSalvage.UnlockLevel", 350); }
|
||||||
|
|
||||||
|
public boolean getArcaneSalvageEnchantDowngradeEnabled() { return config.getBoolean("Skills.Salvage.ArcaneSalvage.EnchantDowngradeEnabled", true); }
|
||||||
|
public boolean getArcaneSalvageEnchantLossEnabled() { return config.getBoolean("Skills.Salvage.ArcaneSalvage.EnchantLossEnabled", true); }
|
||||||
|
|
||||||
|
public int getArcaneSalvageRankLevel(Salvage.Tier tier) { return config.getInt("Skills.Salvage.ArcaneSalvage.Rank_Levels.Rank_" + tier.toNumerical()); }
|
||||||
|
public double getArcaneSalvageExtractFullEnchantsChance(Salvage.Tier tier) { return config.getDouble("Skills.Salvage.ArcaneSalvage.ExtractFullEnchant.Rank_" + tier.toNumerical()); }
|
||||||
|
public double getArcaneSalvageExtractPartialEnchantsChance(Salvage.Tier tier) { return config.getDouble("Skills.Salvage.ArcaneSalvage.ExtractPartialEnchant.Rank_" + tier.toNumerical()); }
|
||||||
|
|
||||||
/* SMELTING */
|
/* SMELTING */
|
||||||
public int getBurnModifierMaxLevel() { return config.getInt("Skills.Smelting.FuelEfficiency.MaxBonusLevel", 1000); }
|
public int getBurnModifierMaxLevel() { return config.getInt("Skills.Smelting.FuelEfficiency.MaxBonusLevel", 1000); }
|
||||||
public double getBurnTimeMultiplier() { return config.getDouble("Skills.Smelting.FuelEfficiency.Multiplier", 3.0D); }
|
public double getBurnTimeMultiplier() { return config.getDouble("Skills.Smelting.FuelEfficiency.Multiplier", 3.0D); }
|
||||||
@@ -777,6 +831,7 @@ public class AdvancedConfig extends AutoUpdateConfigLoader {
|
|||||||
public int getSharpenedClawsUnlock() { return config.getInt("Skills.Taming.SharpenedClaws.UnlockLevel", 750); }
|
public int getSharpenedClawsUnlock() { return config.getInt("Skills.Taming.SharpenedClaws.UnlockLevel", 750); }
|
||||||
public double getSharpenedClawsBonus() { return config.getDouble("Skills.Taming.SharpenedClaws.Bonus", 2.0D); }
|
public double getSharpenedClawsBonus() { return config.getDouble("Skills.Taming.SharpenedClaws.Bonus", 2.0D); }
|
||||||
|
|
||||||
|
public double getMinHorseJumpStrength() { return config.getDouble("Skills.Taming.CallOfTheWild.MinHorseJumpStrength", 0.7D); }
|
||||||
public double getMaxHorseJumpStrength() { return config.getDouble("Skills.Taming.CallOfTheWild.MaxHorseJumpStrength", 2.0D); }
|
public double getMaxHorseJumpStrength() { return config.getDouble("Skills.Taming.CallOfTheWild.MaxHorseJumpStrength", 2.0D); }
|
||||||
|
|
||||||
/* UNARMED */
|
/* UNARMED */
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import java.util.List;
|
|||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.TreeSpecies;
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
|
|
||||||
@@ -182,20 +183,40 @@ public class Config extends AutoUpdateConfigLoader {
|
|||||||
reason.add("Cannot use the same item for Repair and Salvage anvils!");
|
reason.add("Cannot use the same item for Repair and Salvage anvils!");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getTamingCOTWWolfCost() < 1) {
|
if (getTamingCOTWMaterial(EntityType.WOLF) == null) {
|
||||||
reason.add("Skills.Taming.Call_Of_The_Wild.Bones_Required should be at least 1!");
|
reason.add("Skills.Taming.Call_Of_The_Wild.Wolf.Item_Material is invalid!!");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getTamingCOTWOcelotCost() < 1) {
|
if (getTamingCOTWMaterial(EntityType.OCELOT) == null) {
|
||||||
reason.add("Skills.Taming.Call_Of_The_Wild.Fish_Required should be at least 1!");
|
reason.add("Skills.Taming.Call_Of_The_Wild.Ocelot.Item_Material is invalid!!");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getTamingCOTWAmount(EntityType.OCELOT) <= 0) {
|
if (getTamingCOTWMaterial(EntityType.HORSE) == null) {
|
||||||
reason.add("Skills.Taming.Call_Of_The_Wild.Ocelot_Amount should be greater than 0!");
|
reason.add("Skills.Taming.Call_Of_The_Wild.Horse.Item_Material is invalid!!");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (getTamingCOTWCost(EntityType.WOLF) <= 0) {
|
||||||
|
reason.add("Skills.Taming.Call_Of_The_Wild.Wolf.Item_Amount should be greater than 0!");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (getTamingCOTWCost(EntityType.OCELOT) <= 0) {
|
||||||
|
reason.add("Skills.Taming.Call_Of_The_Wild.Ocelot.Item_Amount should be greater than 0!");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (getTamingCOTWCost(EntityType.HORSE) <= 0) {
|
||||||
|
reason.add("Skills.Taming.Call_Of_The_Wild.Horse.Item_Amount should be greater than 0!");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getTamingCOTWAmount(EntityType.WOLF) <= 0) {
|
if (getTamingCOTWAmount(EntityType.WOLF) <= 0) {
|
||||||
reason.add("Skills.Taming.Call_Of_The_Wild.Wolf_Amount should be greater than 0!");
|
reason.add("Skills.Taming.Call_Of_The_Wild.Wolf.Summon_Amount should be greater than 0!");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (getTamingCOTWAmount(EntityType.OCELOT) <= 0) {
|
||||||
|
reason.add("Skills.Taming.Call_Of_The_Wild.Ocelot.Summon_Amount should be greater than 0!");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (getTamingCOTWAmount(EntityType.HORSE) <= 0) {
|
||||||
|
reason.add("Skills.Taming.Call_Of_The_Wild.Horse.Summon_Amount should be greater than 0!");
|
||||||
}
|
}
|
||||||
|
|
||||||
return noErrorsInConfig(reason);
|
return noErrorsInConfig(reason);
|
||||||
@@ -216,9 +237,7 @@ public class Config extends AutoUpdateConfigLoader {
|
|||||||
public boolean getStatsTrackingEnabled() { return config.getBoolean("General.Stats_Tracking", true); }
|
public boolean getStatsTrackingEnabled() { return config.getBoolean("General.Stats_Tracking", true); }
|
||||||
public boolean getUpdateCheckEnabled() { return config.getBoolean("General.Update_Check", true); }
|
public boolean getUpdateCheckEnabled() { return config.getBoolean("General.Update_Check", true); }
|
||||||
public boolean getPreferBeta() { return config.getBoolean("General.Prefer_Beta", false); }
|
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 boolean getVerboseLoggingEnabled() { return config.getBoolean("General.Verbose_Logging", false); }
|
||||||
public boolean getConfigOverwriteEnabled() { return config.getBoolean("General.Config_Update_Overwrite", true); }
|
|
||||||
|
|
||||||
public String getPartyChatPrefix() { return config.getString("Commands.partychat.Chat_Prefix_Format", "[[GREEN]]([[WHITE]]{0}[[GREEN]])"); }
|
public String getPartyChatPrefix() { return config.getString("Commands.partychat.Chat_Prefix_Format", "[[GREEN]]([[WHITE]]{0}[[GREEN]])"); }
|
||||||
public boolean getPartyChatColorLeaderName() { return config.getBoolean("Commands.partychat.Gold_Leader_Name", true); }
|
public boolean getPartyChatColorLeaderName() { return config.getBoolean("Commands.partychat.Gold_Leader_Name", true); }
|
||||||
@@ -229,6 +248,7 @@ public class Config extends AutoUpdateConfigLoader {
|
|||||||
public boolean getAdminDisplayNames() { return config.getBoolean("Commands.adminchat.Use_Display_Names", true); }
|
public boolean getAdminDisplayNames() { return config.getBoolean("Commands.adminchat.Use_Display_Names", true); }
|
||||||
|
|
||||||
public boolean getMatchOfflinePlayers() { return config.getBoolean("Commands.Generic.Match_OfflinePlayers", false); }
|
public boolean getMatchOfflinePlayers() { return config.getBoolean("Commands.Generic.Match_OfflinePlayers", false); }
|
||||||
|
public long getDatabasePlayerCooldown() { return config.getLong("Commands.Database.Player_Cooldown", 1750); }
|
||||||
|
|
||||||
public boolean getLevelUpSoundsEnabled() { return config.getBoolean("General.LevelUp_Sounds", true); }
|
public boolean getLevelUpSoundsEnabled() { return config.getBoolean("General.LevelUp_Sounds", true); }
|
||||||
|
|
||||||
@@ -245,6 +265,11 @@ public class Config extends AutoUpdateConfigLoader {
|
|||||||
public int getMobHealthbarTime() { return config.getInt("Mob_Healthbar.Display_Time", 3); }
|
public int getMobHealthbarTime() { return config.getInt("Mob_Healthbar.Display_Time", 3); }
|
||||||
|
|
||||||
/* Scoreboards */
|
/* Scoreboards */
|
||||||
|
public boolean getPowerLevelTagsEnabled() { return config.getBoolean("Scoreboard.Power_Level_Tags", false); }
|
||||||
|
public boolean getAllowKeepBoard() { return config.getBoolean("Scoreboard.Allow_Keep", true); }
|
||||||
|
public boolean getShowStatsAfterLogin() { return config.getBoolean("Scoreboard.Show_Stats_After_Login", false); }
|
||||||
|
public boolean getScoreboardRainbows() { return config.getBoolean("Scoreboard.Rainbows", false); }
|
||||||
|
|
||||||
public boolean getRankUseChat() { return config.getBoolean("Scoreboard.Types.Rank.Print", false); }
|
public boolean getRankUseChat() { return config.getBoolean("Scoreboard.Types.Rank.Print", false); }
|
||||||
public boolean getRankUseBoard() { return config.getBoolean("Scoreboard.Types.Rank.Board", true); }
|
public boolean getRankUseBoard() { return config.getBoolean("Scoreboard.Types.Rank.Board", true); }
|
||||||
public int getRankScoreboardTime() { return config.getInt("Scoreboard.Types.Rank.Display_Time", 10); }
|
public int getRankScoreboardTime() { return config.getInt("Scoreboard.Types.Rank.Display_Time", 10); }
|
||||||
@@ -270,11 +295,6 @@ public class Config extends AutoUpdateConfigLoader {
|
|||||||
public boolean getSkillLevelUpBoard() { return config.getBoolean("Scoreboard.Types.Skill.LevelUp_Board", true); }
|
public boolean getSkillLevelUpBoard() { return config.getBoolean("Scoreboard.Types.Skill.LevelUp_Board", true); }
|
||||||
public int getSkillLevelUpTime() { return config.getInt("Scoreboard.Types.Skill.LevelUp_Time", 5); }
|
public int getSkillLevelUpTime() { return config.getInt("Scoreboard.Types.Skill.LevelUp_Time", 5); }
|
||||||
|
|
||||||
public boolean getPowerLevelTagsEnabled() { return config.getBoolean("Scoreboard.Power_Level_Tags", false); }
|
|
||||||
|
|
||||||
public boolean getAllowKeepBoard() { return config.getBoolean("Scoreboard.Allow_Keep", true); }
|
|
||||||
public boolean getScoreboardRainbows() { return config.getBoolean("Scoreboard.Rainbows", false); }
|
|
||||||
|
|
||||||
/* Database Purging */
|
/* Database Purging */
|
||||||
public int getPurgeInterval() { return config.getInt("Database_Purging.Purge_Interval", -1); }
|
public int getPurgeInterval() { return config.getInt("Database_Purging.Purge_Interval", -1); }
|
||||||
public int getOldUsersCutoff() { return config.getInt("Database_Purging.Old_User_Cutoff", 6); }
|
public int getOldUsersCutoff() { return config.getInt("Database_Purging.Old_User_Cutoff", 6); }
|
||||||
@@ -376,7 +396,7 @@ public class Config extends AutoUpdateConfigLoader {
|
|||||||
public int getPTPCommandWarmup() { return config.getInt("Commands.ptp.Warmup", 5); }
|
public int getPTPCommandWarmup() { return config.getInt("Commands.ptp.Warmup", 5); }
|
||||||
public int getPTPCommandRecentlyHurtCooldown() { return config.getInt("Commands.ptp.RecentlyHurt_Cooldown", 60); }
|
public int getPTPCommandRecentlyHurtCooldown() { return config.getInt("Commands.ptp.RecentlyHurt_Cooldown", 60); }
|
||||||
public int getPTPCommandTimeout() { return config.getInt("Commands.ptp.Request_Timeout", 300); }
|
public int getPTPCommandTimeout() { return config.getInt("Commands.ptp.Request_Timeout", 300); }
|
||||||
public boolean getPTPCommandConfirmRequired() { return config.getBoolean("Commands.ptp.Confirm_Required", true); }
|
public boolean getPTPCommandConfirmRequired() { return config.getBoolean("Commands.ptp.Accept_Required", true); }
|
||||||
public boolean getPTPCommandWorldPermissions() { return config.getBoolean("Commands.ptp.World_Based_Permissions", false); }
|
public boolean getPTPCommandWorldPermissions() { return config.getBoolean("Commands.ptp.World_Based_Permissions", false); }
|
||||||
|
|
||||||
/* Inspect command distance */
|
/* Inspect command distance */
|
||||||
@@ -423,14 +443,17 @@ public class Config extends AutoUpdateConfigLoader {
|
|||||||
|
|
||||||
/* Acrobatics */
|
/* Acrobatics */
|
||||||
public boolean getDodgeLightningDisabled() { return config.getBoolean("Skills.Acrobatics.Prevent_Dodge_Lightning", false); }
|
public boolean getDodgeLightningDisabled() { return config.getBoolean("Skills.Acrobatics.Prevent_Dodge_Lightning", false); }
|
||||||
public boolean getPreventXPAfterTeleport() { return config.getBoolean("Skills.Acrobatics.Prevent_XP_After_Teleport", true); }
|
public int getXPAfterTeleportCooldown() { return config.getInt("Skills.Acrobatics.XP_After_Teleport_Cooldown", 5); }
|
||||||
|
|
||||||
/* Alchemy */
|
/* Alchemy */
|
||||||
public boolean getEnabledForHoppers() { return config.getBoolean("Skills.Alchemy.Enabled_for_Hoppers", true); }
|
public boolean getEnabledForHoppers() { return config.getBoolean("Skills.Alchemy.Enabled_for_Hoppers", true); }
|
||||||
public boolean getPreventHopperTransfer() { return config.getBoolean("Skills.Alchemy.Prevent_Hopper_Transfer", false); }
|
public boolean getPreventHopperTransferIngredients() { return config.getBoolean("Skills.Alchemy.Prevent_Hopper_Transfer_Ingredients", false); }
|
||||||
|
public boolean getPreventHopperTransferBottles() { return config.getBoolean("Skills.Alchemy.Prevent_Hopper_Transfer_Bottles", false); }
|
||||||
|
|
||||||
/* Fishing */
|
/* Fishing */
|
||||||
public boolean getFishingDropsEnabled() { return config.getBoolean("Skills.Fishing.Drops_Enabled", true); }
|
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 */
|
/* Mining */
|
||||||
public Material getDetonatorItem() { return Material.matchMaterial(config.getString("Skills.Mining.Detonator_Name", "FLINT_AND_STEEL")); }
|
public Material getDetonatorItem() { return Material.matchMaterial(config.getString("Skills.Mining.Detonator_Name", "FLINT_AND_STEEL")); }
|
||||||
@@ -440,26 +463,26 @@ public class Config extends AutoUpdateConfigLoader {
|
|||||||
public boolean getRepairAnvilPlaceSoundsEnabled() { return config.getBoolean("Skills.Repair.Anvil_Placed_Sounds", true); }
|
public boolean getRepairAnvilPlaceSoundsEnabled() { return config.getBoolean("Skills.Repair.Anvil_Placed_Sounds", true); }
|
||||||
public boolean getRepairAnvilUseSoundsEnabled() { return config.getBoolean("Skills.Repair.Anvil_Use_Sounds", true); }
|
public boolean getRepairAnvilUseSoundsEnabled() { return config.getBoolean("Skills.Repair.Anvil_Use_Sounds", true); }
|
||||||
public Material getRepairAnvilMaterial() { return Material.matchMaterial(config.getString("Skills.Repair.Anvil_Material", "IRON_BLOCK")); }
|
public Material getRepairAnvilMaterial() { return Material.matchMaterial(config.getString("Skills.Repair.Anvil_Material", "IRON_BLOCK")); }
|
||||||
public Material getSalvageAnvilMaterial() { return Material.matchMaterial(config.getString("Skills.Repair.Salvage_Anvil_Material", "GOLD_BLOCK")); }
|
|
||||||
public boolean getSalvageTools() { return config.getBoolean("Skills.Repair.Salvage_tools", true); }
|
|
||||||
public boolean getSalvageArmor() { return config.getBoolean("Skills.Repair.Salvage_armor", true); }
|
|
||||||
public boolean getRepairConfirmRequired() { return config.getBoolean("Skills.Repair.Confirm_Required", true); }
|
public boolean getRepairConfirmRequired() { return config.getBoolean("Skills.Repair.Confirm_Required", true); }
|
||||||
|
|
||||||
|
/* Salvage */
|
||||||
|
public boolean getSalvageAnvilMessagesEnabled() { return config.getBoolean("Skills.Salvage.Anvil_Messages", true); }
|
||||||
|
public boolean getSalvageAnvilPlaceSoundsEnabled() { return config.getBoolean("Skills.Salvage.Anvil_Placed_Sounds", true); }
|
||||||
|
public boolean getSalvageAnvilUseSoundsEnabled() { return config.getBoolean("Skills.Salvage.Anvil_Use_Sounds", true); }
|
||||||
|
public Material getSalvageAnvilMaterial() { return Material.matchMaterial(config.getString("Skills.Salvage.Anvil_Material", "GOLD_BLOCK")); }
|
||||||
|
public boolean getSalvageConfirmRequired() { return config.getBoolean("Skills.Salvage.Confirm_Required", true); }
|
||||||
|
|
||||||
/* Unarmed */
|
/* Unarmed */
|
||||||
public boolean getUnarmedBlockCrackerSmoothbrickToCracked() { return config.getBoolean("Skills.Unarmed.Block_Cracker.SmoothBrick_To_CrackedBrick", true); }
|
public boolean getUnarmedBlockCrackerSmoothbrickToCracked() { return config.getBoolean("Skills.Unarmed.Block_Cracker.SmoothBrick_To_CrackedBrick", true); }
|
||||||
|
|
||||||
/* Taming */
|
/* Taming */
|
||||||
public int getTamingCOTWHorseCost() { return config.getInt("Skills.Taming.Call_Of_The_Wild.Apples_Required", 10); }
|
public Material getTamingCOTWMaterial(EntityType type) { return Material.matchMaterial(config.getString("Skills.Taming.Call_Of_The_Wild." + StringUtils.getPrettyEntityTypeString(type) + ".Item_Material")); }
|
||||||
public int getTamingCOTWWolfCost() { return config.getInt("Skills.Taming.Call_Of_The_Wild.Bones_Required", 10); }
|
public int getTamingCOTWCost(EntityType type) { return config.getInt("Skills.Taming.Call_Of_The_Wild." + StringUtils.getPrettyEntityTypeString(type) + ".Item_Amount"); }
|
||||||
public int getTamingCOTWOcelotCost() { return config.getInt("Skills.Taming.Call_Of_The_Wild.Fish_Required", 10); }
|
public int getTamingCOTWAmount(EntityType type) { return config.getInt("Skills.Taming.Call_Of_The_Wild." + StringUtils.getPrettyEntityTypeString(type) + ".Summon_Amount"); }
|
||||||
public double getTamingCOTWRange() { return config.getDouble("Skills.Taming.Call_Of_The_Wild.Range", 40.0D); }
|
public double getTamingCOTWRange() { return config.getDouble("Skills.Taming.Call_Of_The_Wild.Range", 40.0D); }
|
||||||
public int getTamingCOTWAmount(EntityType type) { return config.getInt("Skills.Taming.Call_Of_The_Wild." + StringUtils.getPrettyEntityTypeString(type)+ "_Amount"); }
|
|
||||||
|
|
||||||
/* Woodcutting */
|
/* Woodcutting */
|
||||||
public boolean getOakDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Woodcutting.Oak", true); }
|
public boolean getWoodcuttingDoubleDropsEnabled(TreeSpecies species) { return config.getBoolean("Double_Drops.Woodcutting." + StringUtils.getPrettyTreeSpeciesString(species).replace(" ", "_")); }
|
||||||
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 getTreeFellerSoundsEnabled() { return config.getBoolean("Skills.Woodcutting.Tree_Feller_Sounds", true); }
|
public boolean getTreeFellerSoundsEnabled() { return config.getBoolean("Skills.Woodcutting.Tree_Feller_Sounds", true); }
|
||||||
|
|
||||||
/* AFK Leveling */
|
/* AFK Leveling */
|
||||||
|
|||||||
@@ -3,13 +3,18 @@ package com.gmail.nossr50.config.experience;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.bukkit.GrassSpecies;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.TreeSpecies;
|
||||||
import org.bukkit.entity.EntityType;
|
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.config.AutoUpdateConfigLoader;
|
||||||
import com.gmail.nossr50.datatypes.experience.FormulaType;
|
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.SkillType;
|
||||||
import com.gmail.nossr50.skills.repair.repairables.RepairMaterialType;
|
import com.gmail.nossr50.datatypes.skills.alchemy.PotionStage;
|
||||||
import com.gmail.nossr50.util.StringUtils;
|
import com.gmail.nossr50.util.StringUtils;
|
||||||
|
|
||||||
public class ExperienceConfig extends AutoUpdateConfigLoader {
|
public class ExperienceConfig extends AutoUpdateConfigLoader {
|
||||||
@@ -77,8 +82,10 @@ public class ExperienceConfig extends AutoUpdateConfigLoader {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/* Alchemy */
|
/* Alchemy */
|
||||||
if (getPotionXP() <= 0) {
|
for (PotionStage potionStage : PotionStage.values()) {
|
||||||
reason.add("Experience.Alchemy.Potion should be greater than 0!");
|
if (getPotionXP(potionStage) < 0) {
|
||||||
|
reason.add("Experience.Alchemy.Potion_Stage_" + potionStage.toNumerical() + " should be at least 0!");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Combat XP Multipliers */
|
/* Combat XP Multipliers */
|
||||||
@@ -103,9 +110,7 @@ public class ExperienceConfig extends AutoUpdateConfigLoader {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Fishing */
|
/* Fishing */
|
||||||
if (getFishingBaseXP() <= 0) {
|
// TODO: Add validation for each fish type once enum is available.
|
||||||
reason.add("Experience.Fishing.Base should be greater than 0!");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (getFishingShakeXP() <= 0) {
|
if (getFishingShakeXP() <= 0) {
|
||||||
reason.add("Experience.Fishing.Shake should be greater than 0!");
|
reason.add("Experience.Fishing.Shake should be greater than 0!");
|
||||||
@@ -126,20 +131,12 @@ public class ExperienceConfig extends AutoUpdateConfigLoader {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Woodcutting */
|
/* Woodcutting */
|
||||||
if (getWoodcuttingXPOak() <= 0) {
|
for (TreeSpecies species : TreeSpecies.values()) {
|
||||||
reason.add("Experience.Woodcutting.Oak should be greater than 0!");
|
String key = "Experience.Woodcutting." + StringUtils.getPrettyTreeSpeciesString(species).replace(" ", "_");
|
||||||
}
|
|
||||||
|
|
||||||
if (getWoodcuttingXPBirch() <= 0) {
|
if (config.getInt(key) <= 0) {
|
||||||
reason.add("Experience.Woodcutting.Birch should be greater than 0!");
|
reason.add(key + " 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 (getWoodcuttingXPHugeBrownMushroom() <= 0) {
|
if (getWoodcuttingXPHugeBrownMushroom() <= 0) {
|
||||||
@@ -164,7 +161,7 @@ public class ExperienceConfig extends AutoUpdateConfigLoader {
|
|||||||
/* Curve values */
|
/* Curve values */
|
||||||
public double getMultiplier(FormulaType type) { return config.getDouble("Experience_Formula." + StringUtils.getCapitalized(type.toString()) + "_Values.multiplier"); }
|
public double getMultiplier(FormulaType type) { return config.getDouble("Experience_Formula." + StringUtils.getCapitalized(type.toString()) + "_Values.multiplier"); }
|
||||||
public int getBase(FormulaType type) { return config.getInt("Experience_Formula." + StringUtils.getCapitalized(type.toString()) + "_Values.base"); }
|
public int getBase(FormulaType type) { return config.getInt("Experience_Formula." + StringUtils.getCapitalized(type.toString()) + "_Values.base"); }
|
||||||
public double getExponent(FormulaType type) { return config.getDouble("Experience_Formula." + StringUtils.getCapitalized(type.toString()) +"_Values.exponent"); }
|
public double getExponent(FormulaType type) { return config.getDouble("Experience_Formula." + StringUtils.getCapitalized(type.toString()) + "_Values.exponent"); }
|
||||||
|
|
||||||
/* Global modifier */
|
/* Global modifier */
|
||||||
public double getExperienceGainsGlobalMultiplier() { return config.getDouble("Experience_Formula.Multiplier.Global", 1.0); }
|
public double getExperienceGainsGlobalMultiplier() { return config.getDouble("Experience_Formula.Multiplier.Global", 1.0); }
|
||||||
@@ -208,15 +205,119 @@ public class ExperienceConfig extends AutoUpdateConfigLoader {
|
|||||||
public double getFeatherFallXPModifier() { return config.getDouble("Experience.Acrobatics.FeatherFall_Multiplier", 2.0); }
|
public double getFeatherFallXPModifier() { return config.getDouble("Experience.Acrobatics.FeatherFall_Multiplier", 2.0); }
|
||||||
|
|
||||||
/* Alchemy */
|
/* 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 */
|
/* 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); }
|
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 */
|
/* Repair */
|
||||||
public double getRepairXPBase() { return config.getDouble("Experience.Repair.Base", 1000.0); }
|
public double getRepairXPBase() { return config.getDouble("Experience.Repair.Base", 1000.0); }
|
||||||
public double getRepairXP(RepairMaterialType repairMaterialType) { return config.getDouble("Experience.Repair." + StringUtils.getCapitalized(repairMaterialType.toString())); }
|
public double getRepairXP(MaterialType repairMaterialType) { return config.getDouble("Experience.Repair." + StringUtils.getCapitalized(repairMaterialType.toString())); }
|
||||||
|
|
||||||
/* Taming */
|
/* Taming */
|
||||||
public int getTamingXPHorse() { return config.getInt("Experience.Taming.Animal_Taming.Horse", 1000); }
|
public int getTamingXPHorse() { return config.getInt("Experience.Taming.Animal_Taming.Horse", 1000); }
|
||||||
@@ -224,10 +325,7 @@ public class ExperienceConfig extends AutoUpdateConfigLoader {
|
|||||||
public int getTamingXPOcelot() { return config.getInt("Experience.Taming.Animal_Taming.Ocelot", 500); }
|
public int getTamingXPOcelot() { return config.getInt("Experience.Taming.Animal_Taming.Ocelot", 500); }
|
||||||
|
|
||||||
/* Woodcutting */
|
/* Woodcutting */
|
||||||
public int getWoodcuttingXPOak() { return config.getInt("Experience.Woodcutting.Oak", 70); }
|
public int getWoodcuttingTreeXP(TreeSpecies species) { return config.getInt("Experience.Woodcutting." + StringUtils.getPrettyTreeSpeciesString(species).replace(" ", "_")); }
|
||||||
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 getWoodcuttingXPHugeBrownMushroom() { return config.getInt("Experience.Woodcutting.Huge_Mushroom_Brown", 70); }
|
public int getWoodcuttingXPHugeBrownMushroom() { return config.getInt("Experience.Woodcutting.Huge_Mushroom_Brown", 70); }
|
||||||
public int getWoodcuttingXPHugeRedMushroom() { return config.getInt("Experience.Woodcutting.Huge_Mushroom_Red", 70); }
|
public int getWoodcuttingXPHugeRedMushroom() { return config.getInt("Experience.Woodcutting.Huge_Mushroom_Red", 70); }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,35 @@
|
|||||||
|
package com.gmail.nossr50.config.mods;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
import com.gmail.nossr50.mcMMO;
|
||||||
|
import com.gmail.nossr50.util.ModManager;
|
||||||
|
|
||||||
|
public class ArmorConfigManager {
|
||||||
|
public ArmorConfigManager(mcMMO plugin) {
|
||||||
|
Pattern middlePattern = Pattern.compile("armor\\.(?:.+)\\.yml");
|
||||||
|
Pattern startPattern = Pattern.compile("(?:.+)\\.armor\\.yml");
|
||||||
|
File dataFolder = new File(mcMMO.getModDirectory());
|
||||||
|
File vanilla = new File(dataFolder, "armor.default.yml");
|
||||||
|
ModManager modManager = mcMMO.getModManager();
|
||||||
|
|
||||||
|
if (!vanilla.exists()) {
|
||||||
|
plugin.saveResource(vanilla.getParentFile().getName() + File.separator + "armor.default.yml", false);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (String fileName : dataFolder.list()) {
|
||||||
|
if (!middlePattern.matcher(fileName).matches() && !startPattern.matcher(fileName).matches()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
File file = new File(dataFolder, fileName);
|
||||||
|
|
||||||
|
if (file.isDirectory()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
modManager.registerCustomArmor(new CustomArmorConfig(fileName));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
package com.gmail.nossr50.config.mods;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
import com.gmail.nossr50.mcMMO;
|
||||||
|
import com.gmail.nossr50.util.ModManager;
|
||||||
|
|
||||||
|
public class BlockConfigManager {
|
||||||
|
public BlockConfigManager(mcMMO plugin) {
|
||||||
|
Pattern middlePattern = Pattern.compile("blocks\\.(?:.+)\\.yml");
|
||||||
|
Pattern startPattern = Pattern.compile("(?:.+)\\.blocks\\.yml");
|
||||||
|
File dataFolder = new File(mcMMO.getModDirectory());
|
||||||
|
File vanilla = new File(dataFolder, "blocks.default.yml");
|
||||||
|
ModManager modManager = mcMMO.getModManager();
|
||||||
|
|
||||||
|
if (!vanilla.exists()) {
|
||||||
|
plugin.saveResource(vanilla.getParentFile().getName() + File.separator + "blocks.default.yml", false);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (String fileName : dataFolder.list()) {
|
||||||
|
if (!middlePattern.matcher(fileName).matches() && !startPattern.matcher(fileName).matches()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
File file = new File(dataFolder, fileName);
|
||||||
|
|
||||||
|
if (file.isDirectory()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
modManager.registerCustomBlocks(new CustomBlockConfig(fileName));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -9,49 +9,29 @@ import org.bukkit.configuration.ConfigurationSection;
|
|||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
import com.gmail.nossr50.config.ConfigLoader;
|
import com.gmail.nossr50.config.ConfigLoader;
|
||||||
import com.gmail.nossr50.skills.repair.Repair;
|
import com.gmail.nossr50.datatypes.skills.ItemType;
|
||||||
import com.gmail.nossr50.skills.repair.repairables.RepairItemType;
|
import com.gmail.nossr50.datatypes.skills.MaterialType;
|
||||||
import com.gmail.nossr50.skills.repair.repairables.RepairMaterialType;
|
|
||||||
import com.gmail.nossr50.skills.repair.repairables.Repairable;
|
import com.gmail.nossr50.skills.repair.repairables.Repairable;
|
||||||
import com.gmail.nossr50.skills.repair.repairables.RepairableFactory;
|
import com.gmail.nossr50.skills.repair.repairables.RepairableFactory;
|
||||||
|
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||||
|
|
||||||
public class CustomArmorConfig extends ConfigLoader {
|
public class CustomArmorConfig extends ConfigLoader {
|
||||||
private static CustomArmorConfig instance;
|
|
||||||
|
|
||||||
private boolean needsUpdate = false;
|
private boolean needsUpdate = false;
|
||||||
|
|
||||||
private List<Repairable> repairables;
|
public List<Material> customBoots = new ArrayList<Material>();
|
||||||
|
public List<Material> customChestplates = new ArrayList<Material>();
|
||||||
|
public List<Material> customHelmets = new ArrayList<Material>();
|
||||||
|
public List<Material> customLeggings = new ArrayList<Material>();
|
||||||
|
|
||||||
private List<Material> customBoots = new ArrayList<Material>();
|
public List<Repairable> repairables = new ArrayList<Repairable>();
|
||||||
private List<Material> customChestplates = new ArrayList<Material>();
|
|
||||||
private List<Material> customHelmets = new ArrayList<Material>();
|
|
||||||
private List<Material> customLeggings = new ArrayList<Material>();
|
|
||||||
|
|
||||||
public CustomArmorConfig() {
|
protected CustomArmorConfig(String fileName) {
|
||||||
super("mods", "armor.yml");
|
super("mods", fileName);
|
||||||
loadKeys();
|
loadKeys();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static CustomArmorConfig getInstance() {
|
|
||||||
if (instance == null) {
|
|
||||||
instance = new CustomArmorConfig();
|
|
||||||
}
|
|
||||||
|
|
||||||
return instance;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<Repairable> getLoadedRepairables() {
|
|
||||||
if (repairables == null) {
|
|
||||||
return new ArrayList<Repairable>();
|
|
||||||
}
|
|
||||||
|
|
||||||
return repairables;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void loadKeys() {
|
protected void loadKeys() {
|
||||||
repairables = new ArrayList<Repairable>();
|
|
||||||
|
|
||||||
loadArmor("Boots", customBoots);
|
loadArmor("Boots", customBoots);
|
||||||
loadArmor("Chestplates", customChestplates);
|
loadArmor("Chestplates", customChestplates);
|
||||||
loadArmor("Helmets", customHelmets);
|
loadArmor("Helmets", customHelmets);
|
||||||
@@ -99,38 +79,26 @@ public class CustomArmorConfig extends ConfigLoader {
|
|||||||
|
|
||||||
if (repairable) {
|
if (repairable) {
|
||||||
byte repairData = (byte) config.getInt(armorType + "." + armorName + ".Repair_Material_Data_Value", -1);
|
byte repairData = (byte) config.getInt(armorType + "." + armorName + ".Repair_Material_Data_Value", -1);
|
||||||
int repairQuantity = Repair.getRepairAndSalvageQuantities(new ItemStack(armorMaterial), repairMaterial, repairData);
|
int repairQuantity = SkillUtils.getRepairAndSalvageQuantities(new ItemStack(armorMaterial), repairMaterial, repairData);
|
||||||
|
|
||||||
if (repairQuantity == 0) {
|
if (repairQuantity == 0) {
|
||||||
repairQuantity = config.getInt(armorType + "." + armorName + ".Repair_Material_Data_Quantity", 2);
|
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();
|
short durability = armorMaterial.getMaxDurability();
|
||||||
|
|
||||||
if (durability == 0) {
|
if (durability == 0) {
|
||||||
durability = (short) config.getInt(armorType + "." + armorName + ".Durability", 70);
|
durability = (short) config.getInt(armorType + "." + armorName + ".Durability", 70);
|
||||||
}
|
}
|
||||||
|
|
||||||
repairables.add(RepairableFactory.getRepairable(armorMaterial, repairMaterial, repairData, 0, repairQuantity, durability, RepairItemType.ARMOR, RepairMaterialType.OTHER, 1.0));
|
repairables.add(RepairableFactory.getRepairable(armorMaterial, repairMaterial, repairData, repairItemName, repairMinimumLevel, repairQuantity, durability, ItemType.ARMOR, MaterialType.OTHER, repairXpMultiplier));
|
||||||
}
|
}
|
||||||
|
|
||||||
materialList.add(armorMaterial);
|
materialList.add(armorMaterial);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isCustomBoots(Material material) {
|
|
||||||
return customBoots.contains(material);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isCustomChestplate(Material material) {
|
|
||||||
return customChestplates.contains(material);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isCustomHelmet(Material material) {
|
|
||||||
return customHelmets.contains(material);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isCustomLeggings(Material material) {
|
|
||||||
return customLeggings.contains(material);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,40 +13,29 @@ import com.gmail.nossr50.config.ConfigLoader;
|
|||||||
import com.gmail.nossr50.datatypes.mods.CustomBlock;
|
import com.gmail.nossr50.datatypes.mods.CustomBlock;
|
||||||
|
|
||||||
public class CustomBlockConfig extends ConfigLoader {
|
public class CustomBlockConfig extends ConfigLoader {
|
||||||
private static CustomBlockConfig instance;
|
|
||||||
|
|
||||||
private boolean needsUpdate = false;
|
private boolean needsUpdate = false;
|
||||||
|
|
||||||
private List<MaterialData> customExcavationBlocks = new ArrayList<MaterialData>();
|
public List<MaterialData> customExcavationBlocks = new ArrayList<MaterialData>();
|
||||||
private List<MaterialData> customHerbalismBlocks = new ArrayList<MaterialData>();
|
public List<MaterialData> customHerbalismBlocks = new ArrayList<MaterialData>();
|
||||||
private List<MaterialData> customMiningBlocks = new ArrayList<MaterialData>();
|
public List<MaterialData> customMiningBlocks = new ArrayList<MaterialData>();
|
||||||
private List<MaterialData> customWoodcuttingBlocks = new ArrayList<MaterialData>();
|
public List<MaterialData> customOres = new ArrayList<MaterialData>();
|
||||||
private List<MaterialData> customOres = new ArrayList<MaterialData>();
|
public List<MaterialData> customLogs = new ArrayList<MaterialData>();
|
||||||
private List<MaterialData> customLogs = new ArrayList<MaterialData>();
|
public List<MaterialData> customLeaves = new ArrayList<MaterialData>();
|
||||||
private List<MaterialData> customLeaves = new ArrayList<MaterialData>();
|
public List<MaterialData> customAbilityBlocks = new ArrayList<MaterialData>();
|
||||||
private List<MaterialData> customAbilityBlocks = new ArrayList<MaterialData>();
|
|
||||||
|
|
||||||
private HashMap<MaterialData, CustomBlock> customBlockMap = new HashMap<MaterialData, CustomBlock>();
|
public HashMap<MaterialData, CustomBlock> customBlockMap = new HashMap<MaterialData, CustomBlock>();
|
||||||
|
|
||||||
public CustomBlockConfig() {
|
protected CustomBlockConfig(String fileName) {
|
||||||
super("mods", "blocks.yml");
|
super("mods", fileName);
|
||||||
loadKeys();
|
loadKeys();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static CustomBlockConfig getInstance() {
|
|
||||||
if (instance == null) {
|
|
||||||
instance = new CustomBlockConfig();
|
|
||||||
}
|
|
||||||
|
|
||||||
return instance;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void loadKeys() {
|
protected void loadKeys() {
|
||||||
loadBlocks("Excavation", customExcavationBlocks);
|
loadBlocks("Excavation", customExcavationBlocks);
|
||||||
loadBlocks("Herbalism", customHerbalismBlocks);
|
loadBlocks("Herbalism", customHerbalismBlocks);
|
||||||
loadBlocks("Mining", customMiningBlocks);
|
loadBlocks("Mining", customMiningBlocks);
|
||||||
loadBlocks("Woodcutting", customWoodcuttingBlocks);
|
loadBlocks("Woodcutting", null);
|
||||||
loadBlocks("Ability_Blocks", customAbilityBlocks);
|
loadBlocks("Ability_Blocks", customAbilityBlocks);
|
||||||
|
|
||||||
if (needsUpdate) {
|
if (needsUpdate) {
|
||||||
@@ -85,7 +74,10 @@ public class CustomBlockConfig extends ConfigLoader {
|
|||||||
|
|
||||||
byte blockData = (blockInfo.length == 2) ? Byte.valueOf(blockInfo[1]) : 0;
|
byte blockData = (blockInfo.length == 2) ? Byte.valueOf(blockInfo[1]) : 0;
|
||||||
MaterialData blockMaterialData = new MaterialData(blockMaterial, blockData);
|
MaterialData blockMaterialData = new MaterialData(blockMaterial, blockData);
|
||||||
blockList.add(blockMaterialData);
|
|
||||||
|
if (blockList != null) {
|
||||||
|
blockList.add(blockMaterialData);
|
||||||
|
}
|
||||||
|
|
||||||
if (skillType.equals("Ability_Blocks")) {
|
if (skillType.equals("Ability_Blocks")) {
|
||||||
continue;
|
continue;
|
||||||
@@ -111,40 +103,4 @@ public class CustomBlockConfig extends ConfigLoader {
|
|||||||
customBlockMap.put(blockMaterialData, new CustomBlock(xp, config.getBoolean(skillType + "." + blockName + ".Double_Drops_Enabled"), smeltingXp));
|
customBlockMap.put(blockMaterialData, new CustomBlock(xp, config.getBoolean(skillType + "." + blockName + ".Double_Drops_Enabled"), smeltingXp));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public CustomBlock getCustomBlock(MaterialData data) {
|
|
||||||
return customBlockMap.get(data);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isCustomOre(MaterialData data) {
|
|
||||||
return customOres.contains(data);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isCustomLog(MaterialData data) {
|
|
||||||
return customLogs.contains(data);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isCustomLeaf(MaterialData data) {
|
|
||||||
return customLeaves.contains(data);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isCustomAbilityBlock(MaterialData data) {
|
|
||||||
return customAbilityBlocks.contains(data);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isCustomExcavationBlock(MaterialData data) {
|
|
||||||
return customExcavationBlocks.contains(data);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isCustomHerbalismBlock(MaterialData data) {
|
|
||||||
return customHerbalismBlocks.contains(data);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isCustomMiningBlock(MaterialData data) {
|
|
||||||
return customMiningBlocks.contains(data);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isCustomWoodcuttingBlock(MaterialData data) {
|
|
||||||
return customWoodcuttingBlocks.contains(data);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ package com.gmail.nossr50.config.mods;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.entity.Entity;
|
|
||||||
import org.bukkit.material.MaterialData;
|
import org.bukkit.material.MaterialData;
|
||||||
|
|
||||||
import com.gmail.nossr50.config.ConfigLoader;
|
import com.gmail.nossr50.config.ConfigLoader;
|
||||||
@@ -12,24 +11,14 @@ import com.gmail.nossr50.datatypes.mods.CustomEntity;
|
|||||||
import org.apache.commons.lang.ClassUtils;
|
import org.apache.commons.lang.ClassUtils;
|
||||||
|
|
||||||
public class CustomEntityConfig extends ConfigLoader {
|
public class CustomEntityConfig extends ConfigLoader {
|
||||||
private static CustomEntityConfig instance;
|
public HashMap<String, CustomEntity> customEntityClassMap = new HashMap<String, CustomEntity>();
|
||||||
|
public HashMap<String, CustomEntity> customEntityTypeMap = new HashMap<String, CustomEntity>();
|
||||||
|
|
||||||
private HashMap<String, CustomEntity> customEntityClassMap = new HashMap<String, CustomEntity>();
|
protected CustomEntityConfig(String fileName) {
|
||||||
private HashMap<String, CustomEntity> customEntityTypeMap = new HashMap<String, CustomEntity>();
|
super("mods", fileName);
|
||||||
|
|
||||||
public CustomEntityConfig() {
|
|
||||||
super("mods", "entities.yml");
|
|
||||||
loadKeys();
|
loadKeys();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static CustomEntityConfig getInstance() {
|
|
||||||
if (instance == null) {
|
|
||||||
instance = new CustomEntityConfig();
|
|
||||||
}
|
|
||||||
|
|
||||||
return instance;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void loadKeys() {
|
protected void loadKeys() {
|
||||||
if (config.getConfigurationSection("Hostile") != null) {
|
if (config.getConfigurationSection("Hostile") != null) {
|
||||||
@@ -71,47 +60,4 @@ public class CustomEntityConfig extends ConfigLoader {
|
|||||||
customEntityClassMap.put(clazz == null ? null : clazz.getName(), entity);
|
customEntityClassMap.put(clazz == null ? null : clazz.getName(), entity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isCustomEntity(Entity entity) {
|
|
||||||
if (customEntityTypeMap.containsKey(entity.getType().toString())) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
return customEntityClassMap.containsKey(((Class<?>) entity.getClass().getDeclaredField("entityClass").get(entity)).getName());
|
|
||||||
}
|
|
||||||
catch (Exception e) {
|
|
||||||
if (e instanceof NoSuchFieldException || e instanceof IllegalArgumentException || e instanceof IllegalAccessException) {
|
|
||||||
return customEntityClassMap.containsKey(entity.getClass().getName());
|
|
||||||
}
|
|
||||||
|
|
||||||
e.printStackTrace();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public CustomEntity getCustomEntity(Entity entity) {
|
|
||||||
CustomEntity customEntity = customEntityTypeMap.get(entity.getType().toString());
|
|
||||||
|
|
||||||
if (customEntity == null) {
|
|
||||||
try {
|
|
||||||
customEntity = customEntityClassMap.get(((Class<?>) entity.getClass().getDeclaredField("entityClass").get(entity)).getName());
|
|
||||||
}
|
|
||||||
catch (Exception e) {
|
|
||||||
if (e instanceof NoSuchFieldException || e instanceof IllegalArgumentException || e instanceof IllegalAccessException) {
|
|
||||||
customEntity = customEntityClassMap.get(entity.getClass().getName());
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return customEntity;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addEntity(CustomEntity customEntity, String className, String entityName) {
|
|
||||||
customEntityTypeMap.put(entityName, customEntity);
|
|
||||||
customEntityClassMap.put(className, customEntity);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,53 +11,33 @@ import org.bukkit.inventory.ItemStack;
|
|||||||
|
|
||||||
import com.gmail.nossr50.config.ConfigLoader;
|
import com.gmail.nossr50.config.ConfigLoader;
|
||||||
import com.gmail.nossr50.datatypes.mods.CustomTool;
|
import com.gmail.nossr50.datatypes.mods.CustomTool;
|
||||||
import com.gmail.nossr50.skills.repair.Repair;
|
import com.gmail.nossr50.datatypes.skills.ItemType;
|
||||||
import com.gmail.nossr50.skills.repair.repairables.RepairItemType;
|
import com.gmail.nossr50.datatypes.skills.MaterialType;
|
||||||
import com.gmail.nossr50.skills.repair.repairables.RepairMaterialType;
|
|
||||||
import com.gmail.nossr50.skills.repair.repairables.Repairable;
|
import com.gmail.nossr50.skills.repair.repairables.Repairable;
|
||||||
import com.gmail.nossr50.skills.repair.repairables.RepairableFactory;
|
import com.gmail.nossr50.skills.repair.repairables.RepairableFactory;
|
||||||
|
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||||
|
|
||||||
public class CustomToolConfig extends ConfigLoader {
|
public class CustomToolConfig extends ConfigLoader {
|
||||||
private static CustomToolConfig instance;
|
|
||||||
|
|
||||||
private boolean needsUpdate = false;
|
private boolean needsUpdate = false;
|
||||||
|
|
||||||
private List<Repairable> repairables;
|
public List<Material> customAxes = new ArrayList<Material>();
|
||||||
|
public List<Material> customBows = new ArrayList<Material>();
|
||||||
|
public List<Material> customHoes = new ArrayList<Material>();
|
||||||
|
public List<Material> customPickaxes = new ArrayList<Material>();
|
||||||
|
public List<Material> customShovels = new ArrayList<Material>();
|
||||||
|
public List<Material> customSwords = new ArrayList<Material>();
|
||||||
|
|
||||||
private List<Material> customAxes = new ArrayList<Material>();
|
public HashMap<Material, CustomTool> customToolMap = new HashMap<Material, CustomTool>();
|
||||||
private List<Material> customBows = new ArrayList<Material>();
|
|
||||||
private List<Material> customHoes = new ArrayList<Material>();
|
|
||||||
private List<Material> customPickaxes = new ArrayList<Material>();
|
|
||||||
private List<Material> customShovels = new ArrayList<Material>();
|
|
||||||
private List<Material> customSwords = new ArrayList<Material>();
|
|
||||||
|
|
||||||
private HashMap<Material, CustomTool> customToolMap = new HashMap<Material, CustomTool>();
|
public List<Repairable> repairables = new ArrayList<Repairable>();
|
||||||
|
|
||||||
private CustomToolConfig() {
|
protected CustomToolConfig(String fileName) {
|
||||||
super("mods", "tools.yml");
|
super("mods", fileName);
|
||||||
loadKeys();
|
loadKeys();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static CustomToolConfig getInstance() {
|
|
||||||
if (instance == null) {
|
|
||||||
instance = new CustomToolConfig();
|
|
||||||
}
|
|
||||||
|
|
||||||
return instance;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<Repairable> getLoadedRepairables() {
|
|
||||||
if (repairables == null) {
|
|
||||||
return new ArrayList<Repairable>();
|
|
||||||
}
|
|
||||||
|
|
||||||
return repairables;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void loadKeys() {
|
protected void loadKeys() {
|
||||||
repairables = new ArrayList<Repairable>();
|
|
||||||
|
|
||||||
loadTool("Axes", customAxes);
|
loadTool("Axes", customAxes);
|
||||||
loadTool("Bows", customBows);
|
loadTool("Bows", customBows);
|
||||||
loadTool("Hoes", customHoes);
|
loadTool("Hoes", customHoes);
|
||||||
@@ -107,19 +87,23 @@ public class CustomToolConfig extends ConfigLoader {
|
|||||||
|
|
||||||
if (repairable) {
|
if (repairable) {
|
||||||
byte repairData = (byte) config.getInt(toolType + "." + toolName + ".Repair_Material_Data_Value", -1);
|
byte repairData = (byte) config.getInt(toolType + "." + toolName + ".Repair_Material_Data_Value", -1);
|
||||||
int repairQuantity = Repair.getRepairAndSalvageQuantities(new ItemStack(toolMaterial), repairMaterial, repairData);
|
int repairQuantity = SkillUtils.getRepairAndSalvageQuantities(new ItemStack(toolMaterial), repairMaterial, repairData);
|
||||||
|
|
||||||
if (repairQuantity == 0) {
|
if (repairQuantity == 0) {
|
||||||
repairQuantity = config.getInt(toolType + "." + toolName + ".Repair_Material_Data_Quantity", 2);
|
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();
|
short durability = toolMaterial.getMaxDurability();
|
||||||
|
|
||||||
if (durability == 0) {
|
if (durability == 0) {
|
||||||
durability = (short) config.getInt(toolType + "." + toolName + ".Durability", 60);
|
durability = (short) config.getInt(toolType + "." + toolName + ".Durability", 60);
|
||||||
}
|
}
|
||||||
|
|
||||||
repairables.add(RepairableFactory.getRepairable(toolMaterial, repairMaterial, repairData, 0, repairQuantity, durability, RepairItemType.TOOL, RepairMaterialType.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);
|
double multiplier = config.getDouble(toolType + "." + toolName + ".XP_Modifier", 1.0);
|
||||||
@@ -132,36 +116,4 @@ public class CustomToolConfig extends ConfigLoader {
|
|||||||
customToolMap.put(toolMaterial, tool);
|
customToolMap.put(toolMaterial, tool);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isCustomAxe(Material material) {
|
|
||||||
return customAxes.contains(material);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isCustomBow(Material material) {
|
|
||||||
return customBows.contains(material);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isCustomHoe(Material material) {
|
|
||||||
return customHoes.contains(material);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isCustomPickaxe(Material material) {
|
|
||||||
return customPickaxes.contains(material);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isCustomShovel(Material material) {
|
|
||||||
return customShovels.contains(material);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isCustomSword(Material material) {
|
|
||||||
return customSwords.contains(material);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isCustomTool(Material material) {
|
|
||||||
return customToolMap.containsKey(material);
|
|
||||||
}
|
|
||||||
|
|
||||||
public CustomTool getCustomTool(Material material) {
|
|
||||||
return customToolMap.get(material);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,35 @@
|
|||||||
|
package com.gmail.nossr50.config.mods;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
import com.gmail.nossr50.mcMMO;
|
||||||
|
import com.gmail.nossr50.util.ModManager;
|
||||||
|
|
||||||
|
public class EntityConfigManager {
|
||||||
|
public EntityConfigManager(mcMMO plugin) {
|
||||||
|
Pattern middlePattern = Pattern.compile("entities\\.(?:.+)\\.yml");
|
||||||
|
Pattern startPattern = Pattern.compile("(?:.+)\\.entities\\.yml");
|
||||||
|
File dataFolder = new File(mcMMO.getModDirectory());
|
||||||
|
File vanilla = new File(dataFolder, "entities.default.yml");
|
||||||
|
ModManager modManager = mcMMO.getModManager();
|
||||||
|
|
||||||
|
if (!vanilla.exists()) {
|
||||||
|
plugin.saveResource(vanilla.getParentFile().getName() + File.separator + "entities.default.yml", false);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (String fileName : dataFolder.list()) {
|
||||||
|
if (!middlePattern.matcher(fileName).matches() && !startPattern.matcher(fileName).matches()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
File file = new File(dataFolder, fileName);
|
||||||
|
|
||||||
|
if (file.isDirectory()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
modManager.registerCustomEntities(new CustomEntityConfig(fileName));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
package com.gmail.nossr50.config.mods;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
import com.gmail.nossr50.mcMMO;
|
||||||
|
import com.gmail.nossr50.util.ModManager;
|
||||||
|
|
||||||
|
public class ToolConfigManager {
|
||||||
|
public ToolConfigManager(mcMMO plugin) {
|
||||||
|
Pattern middlePattern = Pattern.compile("tools\\.(?:.+)\\.yml");
|
||||||
|
Pattern startPattern = Pattern.compile("(?:.+)\\.tools\\.yml");
|
||||||
|
File dataFolder = new File(mcMMO.getModDirectory());
|
||||||
|
File vanilla = new File(dataFolder, "tools.default.yml");
|
||||||
|
ModManager modManager = mcMMO.getModManager();
|
||||||
|
|
||||||
|
if (!vanilla.exists()) {
|
||||||
|
plugin.saveResource(vanilla.getParentFile().getName() + File.separator + "tools.default.yml", false);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (String fileName : dataFolder.list()) {
|
||||||
|
if (!middlePattern.matcher(fileName).matches() && !startPattern.matcher(fileName).matches()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
File file = new File(dataFolder, fileName);
|
||||||
|
|
||||||
|
if (file.isDirectory()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
modManager.registerCustomTools(new CustomToolConfig(fileName));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package com.gmail.nossr50.config.potion;
|
package com.gmail.nossr50.config.skills.alchemy;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@@ -13,21 +13,21 @@ import org.bukkit.potion.PotionEffectType;
|
|||||||
|
|
||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.gmail.nossr50.config.ConfigLoader;
|
import com.gmail.nossr50.config.ConfigLoader;
|
||||||
import com.gmail.nossr50.datatypes.AlchemyPotion;
|
import com.gmail.nossr50.datatypes.skills.alchemy.AlchemyPotion;
|
||||||
|
|
||||||
public class PotionConfig extends ConfigLoader {
|
public class PotionConfig extends ConfigLoader {
|
||||||
private static PotionConfig instance;
|
private static PotionConfig instance;
|
||||||
|
|
||||||
public List<ItemStack> concoctionsIngredientsTierOne = new ArrayList<ItemStack>();
|
private List<ItemStack> concoctionsIngredientsTierOne = new ArrayList<ItemStack>();
|
||||||
public List<ItemStack> concoctionsIngredientsTierTwo = new ArrayList<ItemStack>();
|
private List<ItemStack> concoctionsIngredientsTierTwo = new ArrayList<ItemStack>();
|
||||||
public List<ItemStack> concoctionsIngredientsTierThree = new ArrayList<ItemStack>();
|
private List<ItemStack> concoctionsIngredientsTierThree = new ArrayList<ItemStack>();
|
||||||
public List<ItemStack> concoctionsIngredientsTierFour = new ArrayList<ItemStack>();
|
private List<ItemStack> concoctionsIngredientsTierFour = new ArrayList<ItemStack>();
|
||||||
public List<ItemStack> concoctionsIngredientsTierFive = new ArrayList<ItemStack>();
|
private List<ItemStack> concoctionsIngredientsTierFive = new ArrayList<ItemStack>();
|
||||||
public List<ItemStack> concoctionsIngredientsTierSix = new ArrayList<ItemStack>();
|
private List<ItemStack> concoctionsIngredientsTierSix = new ArrayList<ItemStack>();
|
||||||
public List<ItemStack> concoctionsIngredientsTierSeven = new ArrayList<ItemStack>();
|
private List<ItemStack> concoctionsIngredientsTierSeven = new ArrayList<ItemStack>();
|
||||||
public List<ItemStack> concoctionsIngredientsTierEight = new ArrayList<ItemStack>();
|
private List<ItemStack> concoctionsIngredientsTierEight = new ArrayList<ItemStack>();
|
||||||
|
|
||||||
public Map<Short, AlchemyPotion> potionMap = new HashMap<Short, AlchemyPotion>();
|
private Map<Short, AlchemyPotion> potionMap = new HashMap<Short, AlchemyPotion>();
|
||||||
|
|
||||||
private PotionConfig() {
|
private PotionConfig() {
|
||||||
super("potions.yml");
|
super("potions.yml");
|
||||||
@@ -189,4 +189,34 @@ public class PotionConfig extends ConfigLoader {
|
|||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<ItemStack> getIngredients(int tier) {
|
||||||
|
switch (tier) {
|
||||||
|
case 8:
|
||||||
|
return concoctionsIngredientsTierEight;
|
||||||
|
case 7:
|
||||||
|
return concoctionsIngredientsTierSeven;
|
||||||
|
case 6:
|
||||||
|
return concoctionsIngredientsTierSix;
|
||||||
|
case 5:
|
||||||
|
return concoctionsIngredientsTierFive;
|
||||||
|
case 4:
|
||||||
|
return concoctionsIngredientsTierFour;
|
||||||
|
case 3:
|
||||||
|
return concoctionsIngredientsTierThree;
|
||||||
|
case 2:
|
||||||
|
return concoctionsIngredientsTierTwo;
|
||||||
|
case 1:
|
||||||
|
default:
|
||||||
|
return concoctionsIngredientsTierOne;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isValidPotion(ItemStack item) {
|
||||||
|
return potionMap.containsKey(item.getDurability());
|
||||||
|
}
|
||||||
|
|
||||||
|
public AlchemyPotion getPotion(short durability) {
|
||||||
|
return potionMap.get(durability);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package com.gmail.nossr50.config.repair;
|
package com.gmail.nossr50.config.skills.repair;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -9,12 +9,12 @@ import org.bukkit.configuration.ConfigurationSection;
|
|||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
import com.gmail.nossr50.config.ConfigLoader;
|
import com.gmail.nossr50.config.ConfigLoader;
|
||||||
import com.gmail.nossr50.skills.repair.Repair;
|
import com.gmail.nossr50.datatypes.skills.ItemType;
|
||||||
import com.gmail.nossr50.skills.repair.repairables.RepairItemType;
|
import com.gmail.nossr50.datatypes.skills.MaterialType;
|
||||||
import com.gmail.nossr50.skills.repair.repairables.RepairMaterialType;
|
|
||||||
import com.gmail.nossr50.skills.repair.repairables.Repairable;
|
import com.gmail.nossr50.skills.repair.repairables.Repairable;
|
||||||
import com.gmail.nossr50.skills.repair.repairables.RepairableFactory;
|
import com.gmail.nossr50.skills.repair.repairables.RepairableFactory;
|
||||||
import com.gmail.nossr50.util.ItemUtils;
|
import com.gmail.nossr50.util.ItemUtils;
|
||||||
|
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||||
|
|
||||||
public class RepairConfig extends ConfigLoader {
|
public class RepairConfig extends ConfigLoader {
|
||||||
private List<Repairable> repairables;
|
private List<Repairable> repairables;
|
||||||
@@ -48,37 +48,37 @@ public class RepairConfig extends ConfigLoader {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Repair Material Type
|
// Repair Material Type
|
||||||
RepairMaterialType repairMaterialType = RepairMaterialType.OTHER;
|
MaterialType repairMaterialType = MaterialType.OTHER;
|
||||||
String repairMaterialTypeString = config.getString("Repairables." + key + ".MaterialType", "OTHER");
|
String repairMaterialTypeString = config.getString("Repairables." + key + ".MaterialType", "OTHER");
|
||||||
|
|
||||||
if (!config.contains("Repairables." + key + ".MaterialType") && itemMaterial != null) {
|
if (!config.contains("Repairables." + key + ".MaterialType") && itemMaterial != null) {
|
||||||
ItemStack repairItem = new ItemStack(itemMaterial);
|
ItemStack repairItem = new ItemStack(itemMaterial);
|
||||||
|
|
||||||
if (ItemUtils.isWoodTool(repairItem)) {
|
if (ItemUtils.isWoodTool(repairItem)) {
|
||||||
repairMaterialType = RepairMaterialType.WOOD;
|
repairMaterialType = MaterialType.WOOD;
|
||||||
}
|
}
|
||||||
else if (ItemUtils.isStoneTool(repairItem)) {
|
else if (ItemUtils.isStoneTool(repairItem)) {
|
||||||
repairMaterialType = RepairMaterialType.STONE;
|
repairMaterialType = MaterialType.STONE;
|
||||||
}
|
}
|
||||||
else if (ItemUtils.isStringTool(repairItem)) {
|
else if (ItemUtils.isStringTool(repairItem)) {
|
||||||
repairMaterialType = RepairMaterialType.STRING;
|
repairMaterialType = MaterialType.STRING;
|
||||||
}
|
}
|
||||||
else if (ItemUtils.isLeatherArmor(repairItem)) {
|
else if (ItemUtils.isLeatherArmor(repairItem)) {
|
||||||
repairMaterialType = RepairMaterialType.LEATHER;
|
repairMaterialType = MaterialType.LEATHER;
|
||||||
}
|
}
|
||||||
else if (ItemUtils.isIronArmor(repairItem) || ItemUtils.isIronTool(repairItem)) {
|
else if (ItemUtils.isIronArmor(repairItem) || ItemUtils.isIronTool(repairItem)) {
|
||||||
repairMaterialType = RepairMaterialType.IRON;
|
repairMaterialType = MaterialType.IRON;
|
||||||
}
|
}
|
||||||
else if (ItemUtils.isGoldArmor(repairItem) || ItemUtils.isGoldTool(repairItem)) {
|
else if (ItemUtils.isGoldArmor(repairItem) || ItemUtils.isGoldTool(repairItem)) {
|
||||||
repairMaterialType = RepairMaterialType.GOLD;
|
repairMaterialType = MaterialType.GOLD;
|
||||||
}
|
}
|
||||||
else if (ItemUtils.isDiamondArmor(repairItem) || ItemUtils.isDiamondTool(repairItem)) {
|
else if (ItemUtils.isDiamondArmor(repairItem) || ItemUtils.isDiamondTool(repairItem)) {
|
||||||
repairMaterialType = RepairMaterialType.DIAMOND;
|
repairMaterialType = MaterialType.DIAMOND;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
try {
|
try {
|
||||||
repairMaterialType = RepairMaterialType.valueOf(repairMaterialTypeString);
|
repairMaterialType = MaterialType.valueOf(repairMaterialTypeString);
|
||||||
}
|
}
|
||||||
catch (IllegalArgumentException ex) {
|
catch (IllegalArgumentException ex) {
|
||||||
reason.add(key + " has an invalid MaterialType of " + repairMaterialTypeString);
|
reason.add(key + " has an invalid MaterialType of " + repairMaterialTypeString);
|
||||||
@@ -87,7 +87,7 @@ public class RepairConfig extends ConfigLoader {
|
|||||||
|
|
||||||
// Repair Material
|
// Repair Material
|
||||||
String repairMaterialName = config.getString("Repairables." + key + ".RepairMaterial");
|
String repairMaterialName = config.getString("Repairables." + key + ".RepairMaterial");
|
||||||
Material repairMaterial = (repairMaterialName == null ? repairMaterialType.getDefaultRepairMaterial() : Material.matchMaterial(repairMaterialName));
|
Material repairMaterial = (repairMaterialName == null ? repairMaterialType.getDefaultMaterial() : Material.matchMaterial(repairMaterialName));
|
||||||
|
|
||||||
if (repairMaterial == null) {
|
if (repairMaterial == null) {
|
||||||
reason.add(key + " has an invalid repair material: " + repairMaterialName);
|
reason.add(key + " has an invalid repair material: " + repairMaterialName);
|
||||||
@@ -96,27 +96,31 @@ public class RepairConfig extends ConfigLoader {
|
|||||||
// Maximum Durability
|
// Maximum Durability
|
||||||
short maximumDurability = (itemMaterial != null ? itemMaterial.getMaxDurability() : (short) config.getInt("Repairables." + key + ".MaximumDurability"));
|
short maximumDurability = (itemMaterial != null ? itemMaterial.getMaxDurability() : (short) config.getInt("Repairables." + key + ".MaximumDurability"));
|
||||||
|
|
||||||
|
if (maximumDurability <= 0) {
|
||||||
|
maximumDurability = (short) config.getInt("Repairables." + key + ".MaximumDurability");
|
||||||
|
}
|
||||||
|
|
||||||
if (maximumDurability <= 0) {
|
if (maximumDurability <= 0) {
|
||||||
reason.add("Maximum durability of " + key + " must be greater than 0!");
|
reason.add("Maximum durability of " + key + " must be greater than 0!");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Item Type
|
// Item Type
|
||||||
RepairItemType repairItemType = RepairItemType.OTHER;
|
ItemType repairItemType = ItemType.OTHER;
|
||||||
String repairItemTypeString = config.getString("Repairables." + key + ".ItemType", "OTHER");
|
String repairItemTypeString = config.getString("Repairables." + key + ".ItemType", "OTHER");
|
||||||
|
|
||||||
if (!config.contains("Repairables." + key + ".ItemType") && itemMaterial != null) {
|
if (!config.contains("Repairables." + key + ".ItemType") && itemMaterial != null) {
|
||||||
ItemStack repairItem = new ItemStack(itemMaterial);
|
ItemStack repairItem = new ItemStack(itemMaterial);
|
||||||
|
|
||||||
if (ItemUtils.isMinecraftTool(repairItem)) {
|
if (ItemUtils.isMinecraftTool(repairItem)) {
|
||||||
repairItemType = RepairItemType.TOOL;
|
repairItemType = ItemType.TOOL;
|
||||||
}
|
}
|
||||||
else if (ItemUtils.isArmor(repairItem)) {
|
else if (ItemUtils.isArmor(repairItem)) {
|
||||||
repairItemType = RepairItemType.ARMOR;
|
repairItemType = ItemType.ARMOR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
try {
|
try {
|
||||||
repairItemType = RepairItemType.valueOf(repairItemTypeString);
|
repairItemType = ItemType.valueOf(repairItemTypeString);
|
||||||
}
|
}
|
||||||
catch (IllegalArgumentException ex) {
|
catch (IllegalArgumentException ex) {
|
||||||
reason.add(key + " has an invalid ItemType of " + repairItemTypeString);
|
reason.add(key + " has an invalid ItemType of " + repairItemTypeString);
|
||||||
@@ -132,7 +136,7 @@ public class RepairConfig extends ConfigLoader {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Minimum Quantity
|
// Minimum Quantity
|
||||||
int minimumQuantity = (itemMaterial != null ? Repair.getRepairAndSalvageQuantities(new ItemStack(itemMaterial), repairMaterial, repairMetadata) : config.getInt("Repairables." + key + ".MinimumQuantity", 2));
|
int minimumQuantity = (itemMaterial != null ? SkillUtils.getRepairAndSalvageQuantities(new ItemStack(itemMaterial), repairMaterial, repairMetadata) : config.getInt("Repairables." + key + ".MinimumQuantity", 2));
|
||||||
|
|
||||||
if (minimumQuantity <= 0 && itemMaterial != null) {
|
if (minimumQuantity <= 0 && itemMaterial != null) {
|
||||||
minimumQuantity = config.getInt("Repairables." + key + ".MinimumQuantity", 2);
|
minimumQuantity = config.getInt("Repairables." + key + ".MinimumQuantity", 2);
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package com.gmail.nossr50.config.repair;
|
package com.gmail.nossr50.config.skills.repair;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -9,11 +9,9 @@ import com.gmail.nossr50.mcMMO;
|
|||||||
import com.gmail.nossr50.skills.repair.repairables.Repairable;
|
import com.gmail.nossr50.skills.repair.repairables.Repairable;
|
||||||
|
|
||||||
public class RepairConfigManager {
|
public class RepairConfigManager {
|
||||||
private List<Repairable> repairables;
|
private final List<Repairable> repairables = new ArrayList<Repairable>();
|
||||||
|
|
||||||
public RepairConfigManager(mcMMO plugin) {
|
public RepairConfigManager(mcMMO plugin) {
|
||||||
repairables = new ArrayList<Repairable>();
|
|
||||||
|
|
||||||
Pattern pattern = Pattern.compile("repair\\.(?:.+)\\.yml");
|
Pattern pattern = Pattern.compile("repair\\.(?:.+)\\.yml");
|
||||||
File dataFolder = plugin.getDataFolder();
|
File dataFolder = plugin.getDataFolder();
|
||||||
File vanilla = new File(dataFolder, "repair.vanilla.yml");
|
File vanilla = new File(dataFolder, "repair.vanilla.yml");
|
||||||
@@ -34,19 +32,11 @@ public class RepairConfigManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
RepairConfig rConfig = new RepairConfig(fileName);
|
RepairConfig rConfig = new RepairConfig(fileName);
|
||||||
List<Repairable> rConfigRepairables = rConfig.getLoadedRepairables();
|
repairables.addAll(rConfig.getLoadedRepairables());
|
||||||
|
|
||||||
if (rConfigRepairables != null) {
|
|
||||||
repairables.addAll(rConfigRepairables);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Repairable> getLoadedRepairables() {
|
public List<Repairable> getLoadedRepairables() {
|
||||||
if (repairables == null) {
|
|
||||||
return new ArrayList<Repairable>();
|
|
||||||
}
|
|
||||||
|
|
||||||
return repairables;
|
return repairables;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,165 @@
|
|||||||
|
package com.gmail.nossr50.config.skills.salvage;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
import com.gmail.nossr50.config.ConfigLoader;
|
||||||
|
import com.gmail.nossr50.datatypes.skills.ItemType;
|
||||||
|
import com.gmail.nossr50.datatypes.skills.MaterialType;
|
||||||
|
import com.gmail.nossr50.skills.salvage.salvageables.Salvageable;
|
||||||
|
import com.gmail.nossr50.skills.salvage.salvageables.SalvageableFactory;
|
||||||
|
import com.gmail.nossr50.util.ItemUtils;
|
||||||
|
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||||
|
|
||||||
|
public class SalvageConfig extends ConfigLoader {
|
||||||
|
private List<Salvageable> salvageables;
|
||||||
|
|
||||||
|
public SalvageConfig(String fileName) {
|
||||||
|
super(fileName);
|
||||||
|
loadKeys();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void loadKeys() {
|
||||||
|
salvageables = new ArrayList<Salvageable>();
|
||||||
|
|
||||||
|
ConfigurationSection section = config.getConfigurationSection("Salvageables");
|
||||||
|
Set<String> keys = section.getKeys(false);
|
||||||
|
|
||||||
|
for (String key : keys) {
|
||||||
|
// Validate all the things!
|
||||||
|
List<String> reason = new ArrayList<String>();
|
||||||
|
|
||||||
|
// Item Material
|
||||||
|
Material itemMaterial = Material.matchMaterial(key);
|
||||||
|
|
||||||
|
if (itemMaterial == null) {
|
||||||
|
reason.add("Invalid material: " + key);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Salvage Material Type
|
||||||
|
MaterialType salvageMaterialType = MaterialType.OTHER;
|
||||||
|
String salvageMaterialTypeString = config.getString("Salvageables." + key + ".MaterialType", "OTHER");
|
||||||
|
|
||||||
|
if (!config.contains("Salvageables." + key + ".MaterialType") && itemMaterial != null) {
|
||||||
|
ItemStack salvageItem = new ItemStack(itemMaterial);
|
||||||
|
|
||||||
|
if (ItemUtils.isWoodTool(salvageItem)) {
|
||||||
|
salvageMaterialType = MaterialType.WOOD;
|
||||||
|
}
|
||||||
|
else if (ItemUtils.isStoneTool(salvageItem)) {
|
||||||
|
salvageMaterialType = MaterialType.STONE;
|
||||||
|
}
|
||||||
|
else if (ItemUtils.isStringTool(salvageItem)) {
|
||||||
|
salvageMaterialType = MaterialType.STRING;
|
||||||
|
}
|
||||||
|
else if (ItemUtils.isLeatherArmor(salvageItem)) {
|
||||||
|
salvageMaterialType = MaterialType.LEATHER;
|
||||||
|
}
|
||||||
|
else if (ItemUtils.isIronArmor(salvageItem) || ItemUtils.isIronTool(salvageItem)) {
|
||||||
|
salvageMaterialType = MaterialType.IRON;
|
||||||
|
}
|
||||||
|
else if (ItemUtils.isGoldArmor(salvageItem) || ItemUtils.isGoldTool(salvageItem)) {
|
||||||
|
salvageMaterialType = MaterialType.GOLD;
|
||||||
|
}
|
||||||
|
else if (ItemUtils.isDiamondArmor(salvageItem) || ItemUtils.isDiamondTool(salvageItem)) {
|
||||||
|
salvageMaterialType = MaterialType.DIAMOND;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
try {
|
||||||
|
salvageMaterialType = MaterialType.valueOf(salvageMaterialTypeString);
|
||||||
|
}
|
||||||
|
catch (IllegalArgumentException ex) {
|
||||||
|
reason.add(key + " has an invalid MaterialType of " + salvageMaterialTypeString);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Salvage Material
|
||||||
|
String salvageMaterialName = config.getString("Salvageables." + key + ".SalvageMaterial");
|
||||||
|
Material salvageMaterial = (salvageMaterialName == null ? salvageMaterialType.getDefaultMaterial() : Material.matchMaterial(salvageMaterialName));
|
||||||
|
|
||||||
|
if (salvageMaterial == null) {
|
||||||
|
reason.add(key + " has an invalid salvage material: " + salvageMaterialName);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Maximum Durability
|
||||||
|
short maximumDurability = (itemMaterial != null ? itemMaterial.getMaxDurability() : (short) config.getInt("Salvageables." + key + ".MaximumDurability"));
|
||||||
|
|
||||||
|
// Item Type
|
||||||
|
ItemType salvageItemType = ItemType.OTHER;
|
||||||
|
String salvageItemTypeString = config.getString("Salvageables." + key + ".ItemType", "OTHER");
|
||||||
|
|
||||||
|
if (!config.contains("Salvageables." + key + ".ItemType") && itemMaterial != null) {
|
||||||
|
ItemStack salvageItem = new ItemStack(itemMaterial);
|
||||||
|
|
||||||
|
if (ItemUtils.isMinecraftTool(salvageItem)) {
|
||||||
|
salvageItemType = ItemType.TOOL;
|
||||||
|
}
|
||||||
|
else if (ItemUtils.isArmor(salvageItem)) {
|
||||||
|
salvageItemType = ItemType.ARMOR;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
try {
|
||||||
|
salvageItemType = ItemType.valueOf(salvageItemTypeString);
|
||||||
|
}
|
||||||
|
catch (IllegalArgumentException ex) {
|
||||||
|
reason.add(key + " has an invalid ItemType of " + salvageItemTypeString);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
byte salvageMetadata = (byte) config.getInt("Salvageables." + key + ".SalvageMaterialMetadata", -1);
|
||||||
|
int minimumLevel = config.getInt("Salvageables." + key + ".MinimumLevel");
|
||||||
|
double xpMultiplier = config.getDouble("Salvageables." + key + ".XpMultiplier", 1);
|
||||||
|
|
||||||
|
if (minimumLevel < 0) {
|
||||||
|
reason.add(key + " has an invalid MinimumLevel of " + minimumLevel);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Maximum Quantity
|
||||||
|
int maximumQuantity = (itemMaterial != null ? SkillUtils.getRepairAndSalvageQuantities(new ItemStack(itemMaterial), salvageMaterial, salvageMetadata) : config.getInt("Salvageables." + key + ".MaximumQuantity", 2));
|
||||||
|
|
||||||
|
if (maximumQuantity <= 0 && itemMaterial != null) {
|
||||||
|
maximumQuantity = config.getInt("Salvageables." + key + ".MaximumQuantity", 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
int configMaximumQuantity = config.getInt("Salvageables." + key + ".MaximumQuantity", -1);
|
||||||
|
|
||||||
|
if (configMaximumQuantity > 0) {
|
||||||
|
maximumQuantity = configMaximumQuantity;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (maximumQuantity <= 0) {
|
||||||
|
reason.add("Maximum quantity of " + key + " must be greater than 0!");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (noErrorsInSalvageable(reason)) {
|
||||||
|
Salvageable salvageable = SalvageableFactory.getSalvageable(itemMaterial, salvageMaterial, salvageMetadata, minimumLevel, maximumQuantity, maximumDurability, salvageItemType, salvageMaterialType, xpMultiplier);
|
||||||
|
salvageables.add(salvageable);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected List<Salvageable> getLoadedSalvageables() {
|
||||||
|
return salvageables == null ? new ArrayList<Salvageable>() : salvageables;
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean noErrorsInSalvageable(List<String> issues) {
|
||||||
|
if (!issues.isEmpty()) {
|
||||||
|
plugin.getLogger().warning("Errors have been found in: " + fileName);
|
||||||
|
plugin.getLogger().warning("The following issues were found:");
|
||||||
|
}
|
||||||
|
|
||||||
|
for (String issue : issues) {
|
||||||
|
plugin.getLogger().warning(issue);
|
||||||
|
}
|
||||||
|
|
||||||
|
return issues.isEmpty();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,42 @@
|
|||||||
|
package com.gmail.nossr50.config.skills.salvage;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
import com.gmail.nossr50.mcMMO;
|
||||||
|
import com.gmail.nossr50.skills.salvage.salvageables.Salvageable;
|
||||||
|
|
||||||
|
public class SalvageConfigManager {
|
||||||
|
private final List<Salvageable> salvageables = new ArrayList<Salvageable>();
|
||||||
|
|
||||||
|
public SalvageConfigManager(mcMMO plugin) {
|
||||||
|
Pattern pattern = Pattern.compile("salvage\\.(?:.+)\\.yml");
|
||||||
|
File dataFolder = plugin.getDataFolder();
|
||||||
|
File vanilla = new File(dataFolder, "salvage.vanilla.yml");
|
||||||
|
|
||||||
|
if (!vanilla.exists()) {
|
||||||
|
plugin.saveResource("salvage.vanilla.yml", false);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (String fileName : dataFolder.list()) {
|
||||||
|
if (!pattern.matcher(fileName).matches()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
File file = new File(dataFolder, fileName);
|
||||||
|
|
||||||
|
if (file.isDirectory()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
SalvageConfig salvageConfig = new SalvageConfig(fileName);
|
||||||
|
salvageables.addAll(salvageConfig.getLoadedSalvageables());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Salvageable> getLoadedSalvageables() {
|
||||||
|
return salvageables;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -35,6 +35,8 @@ public class TreasureConfig extends ConfigLoader {
|
|||||||
public List<ExcavationTreasure> excavationFromMycel = new ArrayList<ExcavationTreasure>();
|
public List<ExcavationTreasure> excavationFromMycel = new ArrayList<ExcavationTreasure>();
|
||||||
public List<ExcavationTreasure> excavationFromSoulSand = new ArrayList<ExcavationTreasure>();
|
public List<ExcavationTreasure> excavationFromSoulSand = new ArrayList<ExcavationTreasure>();
|
||||||
public List<ExcavationTreasure> excavationFromSnow = 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> hylianFromBushes = new ArrayList<HylianTreasure>();
|
||||||
public List<HylianTreasure> hylianFromFlowers = new ArrayList<HylianTreasure>();
|
public List<HylianTreasure> hylianFromFlowers = new ArrayList<HylianTreasure>();
|
||||||
@@ -158,26 +160,29 @@ public class TreasureConfig extends ConfigLoader {
|
|||||||
// Validate all the things!
|
// Validate all the things!
|
||||||
List<String> reason = new ArrayList<String>();
|
List<String> reason = new ArrayList<String>();
|
||||||
|
|
||||||
|
String[] treasureInfo = treasureName.split("[|]");
|
||||||
|
String materialName = treasureInfo[0];
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Material, Amount, and Data
|
* Material, Amount, and Data
|
||||||
*/
|
*/
|
||||||
Material material;
|
Material material;
|
||||||
|
|
||||||
if (treasureName.contains("POTION")) {
|
if (materialName.contains("POTION")) {
|
||||||
material = Material.POTION;
|
material = Material.POTION;
|
||||||
}
|
}
|
||||||
else if (treasureName.contains("INK_SACK")) {
|
else if (materialName.contains("INK_SACK")) {
|
||||||
material = Material.INK_SACK;
|
material = Material.INK_SACK;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
material = Material.matchMaterial(treasureName);
|
material = Material.matchMaterial(materialName);
|
||||||
}
|
}
|
||||||
|
|
||||||
int amount = config.getInt(type + "." + treasureName + ".Amount");
|
int amount = config.getInt(type + "." + treasureName + ".Amount");
|
||||||
int data = config.getInt(type + "." + treasureName + ".Data");
|
short data = (treasureInfo.length == 2) ? Byte.valueOf(treasureInfo[1]) : (short) config.getInt(type + "." + treasureName + ".Data");
|
||||||
|
|
||||||
if (material == null) {
|
if (material == null) {
|
||||||
reason.add("Invalid material: " + treasureName);
|
reason.add("Invalid material: " + materialName);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (amount <= 0) {
|
if (amount <= 0) {
|
||||||
@@ -226,8 +231,8 @@ public class TreasureConfig extends ConfigLoader {
|
|||||||
*/
|
*/
|
||||||
ItemStack item = null;
|
ItemStack item = null;
|
||||||
|
|
||||||
if (treasureName.contains("POTION")) {
|
if (materialName.contains("POTION")) {
|
||||||
String potionType = treasureName.substring(7);
|
String potionType = materialName.substring(7);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
item = new Potion(PotionType.valueOf(potionType.toUpperCase().trim())).toItemStack(amount);
|
item = new Potion(PotionType.valueOf(potionType.toUpperCase().trim())).toItemStack(amount);
|
||||||
@@ -236,8 +241,8 @@ public class TreasureConfig extends ConfigLoader {
|
|||||||
reason.add("Invalid Potion_Type: " + potionType);
|
reason.add("Invalid Potion_Type: " + potionType);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (treasureName.contains("INK_SACK")) {
|
else if (materialName.contains("INK_SACK")) {
|
||||||
String color = treasureName.substring(9);
|
String color = materialName.substring(9);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Dye dye = new Dye();
|
Dye dye = new Dye();
|
||||||
@@ -250,17 +255,17 @@ public class TreasureConfig extends ConfigLoader {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (material != null) {
|
else if (material != null) {
|
||||||
item = new ItemStack(material, amount, (short) data);
|
item = new ItemStack(material, amount, data);
|
||||||
|
|
||||||
if (config.contains(type + "." + treasureName + ".Custom_Name")) {
|
if (config.contains(type + "." + treasureName + ".Custom_Name")) {
|
||||||
ItemMeta itemMeta = item.getItemMeta();
|
ItemMeta itemMeta = item.getItemMeta();
|
||||||
itemMeta.setDisplayName(config.getString(type + "." + treasureName + "Custom_Name"));
|
itemMeta.setDisplayName(config.getString(type + "." + treasureName + ".Custom_Name"));
|
||||||
item.setItemMeta(itemMeta);
|
item.setItemMeta(itemMeta);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (config.contains(type + "." + treasureName + ".Lore")) {
|
if (config.contains(type + "." + treasureName + ".Lore")) {
|
||||||
ItemMeta itemMeta = item.getItemMeta();
|
ItemMeta itemMeta = item.getItemMeta();
|
||||||
itemMeta.setLore(config.getStringList(type + "." + treasureName + "Custom_Name"));
|
itemMeta.setLore(config.getStringList(type + "." + treasureName + ".Lore"));
|
||||||
item.setItemMeta(itemMeta);
|
item.setItemMeta(itemMeta);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -371,6 +376,14 @@ public class TreasureConfig extends ConfigLoader {
|
|||||||
if (dropList.contains("Snow")) {
|
if (dropList.contains("Snow")) {
|
||||||
excavationFromSnow.add(excavationTreasure);
|
excavationFromSnow.add(excavationTreasure);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (dropList.contains("Red_Sand")) {
|
||||||
|
excavationFromRedSand.add(excavationTreasure);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (dropList.contains("Podzol")) {
|
||||||
|
excavationFromPodzol.add(excavationTreasure);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (isHylian) {
|
else if (isHylian) {
|
||||||
HylianTreasure hylianTreasure = new HylianTreasure(item, xp, dropChance, dropLevel);
|
HylianTreasure hylianTreasure = new HylianTreasure(item, xp, dropChance, dropLevel);
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ public interface DatabaseManager {
|
|||||||
/**
|
/**
|
||||||
* Retrieve leaderboard info.
|
* Retrieve leaderboard info.
|
||||||
*
|
*
|
||||||
* @param skillName The skill to retrieve info on
|
* @param skill The skill to retrieve info on
|
||||||
* @param pageNumber Which page in the leaderboards to retrieve
|
* @param pageNumber Which page in the leaderboards to retrieve
|
||||||
* @param statsPerPage The number of stats per page
|
* @param statsPerPage The number of stats per page
|
||||||
* @return the requested leaderboard information
|
* @return the requested leaderboard information
|
||||||
|
|||||||
@@ -26,6 +26,9 @@ import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
|||||||
import com.gmail.nossr50.datatypes.skills.AbilityType;
|
import com.gmail.nossr50.datatypes.skills.AbilityType;
|
||||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||||
import com.gmail.nossr50.util.Misc;
|
import com.gmail.nossr50.util.Misc;
|
||||||
|
import com.gmail.nossr50.util.StringUtils;
|
||||||
|
|
||||||
|
import org.apache.commons.lang.ArrayUtils;
|
||||||
|
|
||||||
public final class FlatfileDatabaseManager implements DatabaseManager {
|
public final class FlatfileDatabaseManager implements DatabaseManager {
|
||||||
private final HashMap<SkillType, List<PlayerStat>> playerStatHash = new HashMap<SkillType, List<PlayerStat>>();
|
private final HashMap<SkillType, List<PlayerStat>> playerStatHash = new HashMap<SkillType, List<PlayerStat>>();
|
||||||
@@ -604,7 +607,7 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
|
|||||||
|
|
||||||
// Length checks depend on last character being ':'
|
// Length checks depend on last character being ':'
|
||||||
if (line.charAt(line.length() - 1) != ':') {
|
if (line.charAt(line.length() - 1) != ':') {
|
||||||
line = line + ":";
|
line = line.concat(":");
|
||||||
}
|
}
|
||||||
String[] character = line.split(":");
|
String[] character = line.split(":");
|
||||||
|
|
||||||
@@ -621,29 +624,33 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
|
|||||||
|
|
||||||
String oldVersion = null;
|
String oldVersion = null;
|
||||||
|
|
||||||
|
if (character.length <= 33) {
|
||||||
|
// Introduction of HUDType
|
||||||
|
// Version 1.1.06
|
||||||
|
// commit 78f79213cdd7190cd11ae54526f3b4ea42078e8a
|
||||||
|
line = line.concat(" :");
|
||||||
|
character = line.split(":");
|
||||||
|
oldVersion = "1.1.06";
|
||||||
|
}
|
||||||
|
|
||||||
if (!character[33].isEmpty()) {
|
if (!character[33].isEmpty()) {
|
||||||
// Removal of Spout Support
|
// Removal of Spout Support
|
||||||
// Version 1.4.07-dev2
|
// Version 1.4.07-dev2
|
||||||
// commit 7bac0e2ca5143bce84dc160617fed97f0b1cb968
|
// commit 7bac0e2ca5143bce84dc160617fed97f0b1cb968
|
||||||
line = line.replace(character[33], "");
|
line = line.replace(character[33], "");
|
||||||
oldVersion = "1.4.07";
|
if (oldVersion == null) {
|
||||||
|
oldVersion = "1.4.07";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// If they're valid, rewrite them to the file.
|
// If they're valid, rewrite them to the file.
|
||||||
if (character.length > 40) {
|
if (character.length == 41) {
|
||||||
writer.append(line).append("\r\n");
|
writer.append(line).append("\r\n");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
StringBuilder newLine = new StringBuilder(line);
|
StringBuilder newLine = new StringBuilder(line);
|
||||||
|
|
||||||
if (character.length <= 33) {
|
|
||||||
// Introduction of HUDType
|
|
||||||
// Version 1.1.06
|
|
||||||
// commit 78f79213cdd7190cd11ae54526f3b4ea42078e8a
|
|
||||||
newLine.append(":");
|
|
||||||
oldVersion = "1.1.06";
|
|
||||||
}
|
|
||||||
if (character.length <= 35) {
|
if (character.length <= 35) {
|
||||||
// Introduction of Fishing
|
// Introduction of Fishing
|
||||||
// Version 1.2.00
|
// Version 1.2.00
|
||||||
@@ -682,7 +689,7 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
|
|||||||
oldVersion = "1.4.06";
|
oldVersion = "1.4.06";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (character.length <= 40) {
|
if (character.length <= 39) {
|
||||||
// Addition of Alchemy
|
// Addition of Alchemy
|
||||||
// Version 1.4.08
|
// Version 1.4.08
|
||||||
newLine.append("0").append(":");
|
newLine.append("0").append(":");
|
||||||
@@ -692,6 +699,46 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Remove any blanks that shouldn't be there, and validate the other fields
|
||||||
|
String[] newCharacter = newLine.toString().split(":");
|
||||||
|
boolean corrupted = false;
|
||||||
|
|
||||||
|
for (int i = 0; i < newCharacter.length; i++) {
|
||||||
|
if (newCharacter[i].isEmpty() && !(i == 2 || i == 3 || i == 23 || i == 33)) {
|
||||||
|
corrupted = true;
|
||||||
|
|
||||||
|
if (newCharacter.length != 41) {
|
||||||
|
newCharacter = (String[]) ArrayUtils.remove(newCharacter, i);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (i == 37) {
|
||||||
|
newCharacter[i] = String.valueOf(System.currentTimeMillis() / Misc.TIME_CONVERSION_FACTOR);
|
||||||
|
}
|
||||||
|
else if (i == 38) {
|
||||||
|
newCharacter[i] = Config.getInstance().getMobHealthbarDefault().toString();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
newCharacter[i] = "0";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (StringUtils.isInt(newCharacter[i]) && i == 38) {
|
||||||
|
corrupted = true;
|
||||||
|
newCharacter[i] = Config.getInstance().getMobHealthbarDefault().toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!StringUtils.isInt(newCharacter[i]) && !(i == 0 || i == 2 || i == 3 || i == 23 || i == 33 || i == 38)) {
|
||||||
|
corrupted = true;
|
||||||
|
newCharacter[i] = "0";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (corrupted) {
|
||||||
|
mcMMO.p.debug("Updating corrupted database line for player " + newCharacter[0]);
|
||||||
|
newLine = new StringBuilder(org.apache.commons.lang.StringUtils.join(newCharacter, ":"));
|
||||||
|
}
|
||||||
|
|
||||||
if (oldVersion != null) {
|
if (oldVersion != null) {
|
||||||
mcMMO.p.debug("Updating database line for player " + character[0] + " from before version " + oldVersion);
|
mcMMO.p.debug("Updating database line for player " + character[0] + " from before version " + oldVersion);
|
||||||
}
|
}
|
||||||
@@ -767,7 +814,7 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private PlayerProfile loadFromLine(String[] character) throws Exception {
|
private PlayerProfile loadFromLine(String[] character) {
|
||||||
Map<SkillType, Integer> skills = getSkillMapFromLine(character); // Skill levels
|
Map<SkillType, Integer> skills = getSkillMapFromLine(character); // Skill levels
|
||||||
Map<SkillType, Float> skillsXp = new HashMap<SkillType, Float>(); // Skill & XP
|
Map<SkillType, Float> skillsXp = new HashMap<SkillType, Float>(); // Skill & XP
|
||||||
Map<AbilityType, Integer> skillsDATS = new HashMap<AbilityType, Integer>(); // Ability & Cooldown
|
Map<AbilityType, Integer> skillsDATS = new HashMap<AbilityType, Integer>(); // Ability & Cooldown
|
||||||
|
|||||||
@@ -13,6 +13,8 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
|
||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.gmail.nossr50.config.Config;
|
import com.gmail.nossr50.config.Config;
|
||||||
import com.gmail.nossr50.datatypes.MobHealthbarType;
|
import com.gmail.nossr50.datatypes.MobHealthbarType;
|
||||||
@@ -29,7 +31,8 @@ import com.gmail.nossr50.util.Misc;
|
|||||||
public final class SQLDatabaseManager implements DatabaseManager {
|
public final class SQLDatabaseManager implements DatabaseManager {
|
||||||
private String connectionString;
|
private String connectionString;
|
||||||
private String tablePrefix = Config.getInstance().getMySQLTablePrefix();
|
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
|
// Scale waiting time by this much per failed attempt
|
||||||
private final double SCALING_FACTOR = 40.0;
|
private final double SCALING_FACTOR = 40.0;
|
||||||
@@ -199,7 +202,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
|||||||
PreparedStatement statement = null;
|
PreparedStatement statement = null;
|
||||||
|
|
||||||
try {
|
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(1, (pageNumber * statsPerPage) - statsPerPage);
|
||||||
statement.setInt(2, statsPerPage);
|
statement.setInt(2, statsPerPage);
|
||||||
resultSet = statement.executeQuery();
|
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 " +
|
"AND " + skillName + " > (SELECT " + skillName + " FROM " + tablePrefix + "users JOIN " + tablePrefix + "skills ON user_id = id " +
|
||||||
"WHERE user = ?)";
|
"WHERE user = ?)";
|
||||||
|
|
||||||
PreparedStatement statement = connection.prepareStatement(sql);
|
PreparedStatement statement = getConnection().prepareStatement(sql);
|
||||||
statement.setString(1, playerName);
|
statement.setString(1, playerName);
|
||||||
resultSet = statement.executeQuery();
|
resultSet = statement.executeQuery();
|
||||||
|
|
||||||
@@ -259,7 +262,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
|||||||
|
|
||||||
statement.close();
|
statement.close();
|
||||||
|
|
||||||
statement = connection.prepareStatement(sql);
|
statement = getConnection().prepareStatement(sql);
|
||||||
resultSet = statement.executeQuery();
|
resultSet = statement.executeQuery();
|
||||||
|
|
||||||
while (resultSet.next()) {
|
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 " +
|
"(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 = ?)";
|
"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);
|
statement.setString(1, playerName);
|
||||||
resultSet = statement.executeQuery();
|
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 " +
|
"(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";
|
"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);
|
statement.setString(1, playerName);
|
||||||
resultSet = statement.executeQuery();
|
resultSet = statement.executeQuery();
|
||||||
|
|
||||||
@@ -324,7 +327,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
|||||||
PreparedStatement statement = null;
|
PreparedStatement statement = null;
|
||||||
|
|
||||||
try {
|
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.setString(1, playerName);
|
||||||
statement.setLong(2, System.currentTimeMillis() / Misc.TIME_CONVERSION_FACTOR);
|
statement.setLong(2, System.currentTimeMillis() / Misc.TIME_CONVERSION_FACTOR);
|
||||||
statement.execute();
|
statement.execute();
|
||||||
@@ -359,7 +362,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
|||||||
PreparedStatement statement = null;
|
PreparedStatement statement = null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
statement = connection.prepareStatement(
|
statement = getConnection().prepareStatement(
|
||||||
"SELECT "
|
"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, "
|
+ "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, "
|
+ "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;
|
PreparedStatement statement = null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
statement = connection.prepareStatement(
|
statement = getConnection().prepareStatement(
|
||||||
"SELECT "
|
"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, "
|
+ "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, "
|
+ "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() {
|
public boolean checkConnected() {
|
||||||
boolean isClosed = true;
|
boolean isClosed = true;
|
||||||
boolean isValid = false;
|
boolean isValid = false;
|
||||||
|
Connection connection = getConnection();
|
||||||
boolean exists = (connection != null);
|
boolean exists = (connection != null);
|
||||||
|
|
||||||
// If we're waiting for server to recover then leave early
|
// 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
|
// Try to connect again
|
||||||
connect();
|
if (Bukkit.isPrimaryThread()) {
|
||||||
|
connectPrimary();
|
||||||
|
} else {
|
||||||
|
connectSecondary();
|
||||||
|
}
|
||||||
|
|
||||||
// Leave if connection is good
|
// Leave if connection is good
|
||||||
try {
|
try {
|
||||||
@@ -572,13 +580,47 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
|||||||
return false;
|
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() {
|
public List<String> getStoredUsers() {
|
||||||
ArrayList<String> users = new ArrayList<String>();
|
ArrayList<String> users = new ArrayList<String>();
|
||||||
|
|
||||||
if (checkConnected()) {
|
if (checkConnected()) {
|
||||||
Statement stmt = null;
|
Statement stmt = null;
|
||||||
try {
|
try {
|
||||||
stmt = connection.createStatement();
|
stmt = getConnection().createStatement();
|
||||||
ResultSet result = stmt.executeQuery("SELECT user FROM " + tablePrefix + "users");
|
ResultSet result = stmt.executeQuery("SELECT user FROM " + tablePrefix + "users");
|
||||||
while (result.next()) {
|
while (result.next()) {
|
||||||
users.add(result.getString("user"));
|
users.add(result.getString("user"));
|
||||||
@@ -603,10 +645,18 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
|||||||
return users;
|
return users;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Connection getConnection() {
|
||||||
|
if (Bukkit.isPrimaryThread()) {
|
||||||
|
return primaryConnection;
|
||||||
|
} else {
|
||||||
|
return secondaryConnection;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Attempt to connect to the mySQL database.
|
* 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();
|
connectionString = "jdbc:mysql://" + Config.getInstance().getMySQLServerName() + ":" + Config.getInstance().getMySQLServerPort() + "/" + Config.getInstance().getMySQLDatabaseName();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -619,12 +669,12 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
|||||||
connectionProperties.put("password", Config.getInstance().getMySQLUserPassword());
|
connectionProperties.put("password", Config.getInstance().getMySQLUserPassword());
|
||||||
connectionProperties.put("autoReconnect", "false");
|
connectionProperties.put("autoReconnect", "false");
|
||||||
connectionProperties.put("maxReconnects", "0");
|
connectionProperties.put("maxReconnects", "0");
|
||||||
connection = DriverManager.getConnection(connectionString, connectionProperties);
|
primaryConnection = DriverManager.getConnection(connectionString, connectionProperties);
|
||||||
|
|
||||||
mcMMO.p.getLogger().info("Connection to MySQL was a success!");
|
mcMMO.p.getLogger().info("Connection to MySQL was a success!");
|
||||||
}
|
}
|
||||||
catch (SQLException ex) {
|
catch (SQLException ex) {
|
||||||
connection = null;
|
primaryConnection = null;
|
||||||
|
|
||||||
if (reconnectAttempt == 0 || reconnectAttempt >= 11) {
|
if (reconnectAttempt == 0 || reconnectAttempt >= 11) {
|
||||||
mcMMO.p.getLogger().severe("Connection to MySQL failed!");
|
mcMMO.p.getLogger().severe("Connection to MySQL failed!");
|
||||||
@@ -632,7 +682,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (ClassNotFoundException ex) {
|
catch (ClassNotFoundException ex) {
|
||||||
connection = null;
|
primaryConnection = null;
|
||||||
|
|
||||||
if (reconnectAttempt == 0 || reconnectAttempt >= 11) {
|
if (reconnectAttempt == 0 || reconnectAttempt >= 11) {
|
||||||
mcMMO.p.getLogger().severe("MySQL database driver not found!");
|
mcMMO.p.getLogger().severe("MySQL database driver not found!");
|
||||||
@@ -799,7 +849,6 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ResultSet resultSet;
|
ResultSet resultSet;
|
||||||
HashMap<Integer, ArrayList<String>> rows = new HashMap<Integer, ArrayList<String>>();
|
|
||||||
PreparedStatement statement = null;
|
PreparedStatement statement = null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -807,17 +856,11 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
statement = connection.prepareStatement(sql);
|
statement = getConnection().prepareStatement(sql);
|
||||||
resultSet = statement.executeQuery();
|
resultSet = statement.executeQuery();
|
||||||
|
|
||||||
while (resultSet.next()) {
|
while (resultSet.next()) {
|
||||||
ArrayList<String> column = new ArrayList<String>();
|
// No reason to do anything here... we're just trying to catch exceptions
|
||||||
|
|
||||||
for (int i = 1; i <= resultSet.getMetaData().getColumnCount(); i++) {
|
|
||||||
column.add(resultSet.getString(i));
|
|
||||||
}
|
|
||||||
|
|
||||||
rows.put(resultSet.getRow(), column);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (SQLException ex) {
|
catch (SQLException ex) {
|
||||||
@@ -873,7 +916,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
|||||||
|
|
||||||
PreparedStatement statement = null;
|
PreparedStatement statement = null;
|
||||||
try {
|
try {
|
||||||
statement = connection.prepareStatement(sql);
|
statement = getConnection().prepareStatement(sql);
|
||||||
statement.executeUpdate();
|
statement.executeUpdate();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -908,7 +951,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
|||||||
PreparedStatement statement = null;
|
PreparedStatement statement = null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
statement = connection.prepareStatement(sql);
|
statement = getConnection().prepareStatement(sql);
|
||||||
rows = statement.executeUpdate();
|
rows = statement.executeUpdate();
|
||||||
}
|
}
|
||||||
catch (SQLException ex) {
|
catch (SQLException ex) {
|
||||||
@@ -943,7 +986,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
|||||||
ResultSet resultSet;
|
ResultSet resultSet;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
statement = connection.prepareStatement(sql);
|
statement = getConnection().prepareStatement(sql);
|
||||||
resultSet = statement.executeQuery();
|
resultSet = statement.executeQuery();
|
||||||
|
|
||||||
while (resultSet.next()) {
|
while (resultSet.next()) {
|
||||||
@@ -1015,22 +1058,22 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
|||||||
PreparedStatement statement = null;
|
PreparedStatement statement = null;
|
||||||
|
|
||||||
try {
|
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.setInt(1, id);
|
||||||
statement.execute();
|
statement.execute();
|
||||||
statement.close();
|
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.setInt(1, id);
|
||||||
statement.execute();
|
statement.execute();
|
||||||
statement.close();
|
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.setInt(1, id);
|
||||||
statement.execute();
|
statement.execute();
|
||||||
statement.close();
|
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.setInt(1, id);
|
||||||
statement.execute();
|
statement.execute();
|
||||||
statement.close();
|
statement.close();
|
||||||
@@ -1060,7 +1103,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
|||||||
PreparedStatement statement = null;
|
PreparedStatement statement = null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
statement = connection.prepareStatement(sql);
|
statement = getConnection().prepareStatement(sql);
|
||||||
int i = 1;
|
int i = 1;
|
||||||
|
|
||||||
for (int arg : args) {
|
for (int arg : args) {
|
||||||
@@ -1090,7 +1133,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
|||||||
PreparedStatement statement = null;
|
PreparedStatement statement = null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
statement = connection.prepareStatement(sql);
|
statement = getConnection().prepareStatement(sql);
|
||||||
int i = 1;
|
int i = 1;
|
||||||
|
|
||||||
for (long arg : args) {
|
for (long arg : args) {
|
||||||
@@ -1127,7 +1170,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
|||||||
int id = -1;
|
int id = -1;
|
||||||
|
|
||||||
try {
|
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);
|
statement.setString(1, playerName);
|
||||||
id = readInt(statement);
|
id = readInt(statement);
|
||||||
}
|
}
|
||||||
@@ -1142,7 +1185,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
|||||||
PreparedStatement statement = null;
|
PreparedStatement statement = null;
|
||||||
|
|
||||||
try {
|
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.setLong(1, login);
|
||||||
statement.setInt(2, id);
|
statement.setInt(2, id);
|
||||||
statement.execute();
|
statement.execute();
|
||||||
@@ -1168,7 +1211,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
|||||||
PreparedStatement statement = null;
|
PreparedStatement statement = null;
|
||||||
|
|
||||||
try {
|
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.setString(1, mobHealthBar);
|
||||||
statement.setInt(2, userId);
|
statement.setInt(2, userId);
|
||||||
statement.execute();
|
statement.execute();
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import java.util.List;
|
|||||||
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Sound;
|
import org.bukkit.Sound;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
@@ -83,6 +84,19 @@ public class Party {
|
|||||||
return onlineMembers;
|
return onlineMembers;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<String> getOnlinePlayerNames(CommandSender sender) {
|
||||||
|
Player player = sender instanceof Player ? (Player) sender : null;
|
||||||
|
List<String> onlinePlayerNames = new ArrayList<String>();
|
||||||
|
|
||||||
|
for (Player onlinePlayer : getOnlineMembers()) {
|
||||||
|
if (player != null && player.canSee(onlinePlayer)) {
|
||||||
|
onlinePlayerNames.add(onlinePlayer.getName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return onlinePlayerNames;
|
||||||
|
}
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
@@ -171,7 +185,7 @@ public class Party {
|
|||||||
|
|
||||||
public String getXpToLevelPercentage() {
|
public String getXpToLevelPercentage() {
|
||||||
DecimalFormat percent = new DecimalFormat("##0.00%");
|
DecimalFormat percent = new DecimalFormat("##0.00%");
|
||||||
return percent.format( this.getXp() / getXpToLevel());
|
return percent.format(this.getXp() / getXpToLevel());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -337,9 +351,4 @@ public class Party {
|
|||||||
|
|
||||||
return this.getName().equals(other.getName());
|
return this.getName().equals(other.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public int hashCode() {
|
|
||||||
return super.hashCode();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ import com.gmail.nossr50.datatypes.party.PartyTeleportRecord;
|
|||||||
import com.gmail.nossr50.datatypes.skills.AbilityType;
|
import com.gmail.nossr50.datatypes.skills.AbilityType;
|
||||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||||
import com.gmail.nossr50.datatypes.skills.ToolType;
|
import com.gmail.nossr50.datatypes.skills.ToolType;
|
||||||
|
import com.gmail.nossr50.datatypes.skills.XPGainReason;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.party.PartyManager;
|
import com.gmail.nossr50.party.PartyManager;
|
||||||
import com.gmail.nossr50.party.ShareHandler;
|
import com.gmail.nossr50.party.ShareHandler;
|
||||||
@@ -40,6 +41,7 @@ import com.gmail.nossr50.skills.fishing.FishingManager;
|
|||||||
import com.gmail.nossr50.skills.herbalism.HerbalismManager;
|
import com.gmail.nossr50.skills.herbalism.HerbalismManager;
|
||||||
import com.gmail.nossr50.skills.mining.MiningManager;
|
import com.gmail.nossr50.skills.mining.MiningManager;
|
||||||
import com.gmail.nossr50.skills.repair.RepairManager;
|
import com.gmail.nossr50.skills.repair.RepairManager;
|
||||||
|
import com.gmail.nossr50.skills.salvage.SalvageManager;
|
||||||
import com.gmail.nossr50.skills.smelting.SmeltingManager;
|
import com.gmail.nossr50.skills.smelting.SmeltingManager;
|
||||||
import com.gmail.nossr50.skills.swords.SwordsManager;
|
import com.gmail.nossr50.skills.swords.SwordsManager;
|
||||||
import com.gmail.nossr50.skills.taming.TamingManager;
|
import com.gmail.nossr50.skills.taming.TamingManager;
|
||||||
@@ -47,7 +49,6 @@ import com.gmail.nossr50.skills.unarmed.UnarmedManager;
|
|||||||
import com.gmail.nossr50.skills.woodcutting.WoodcuttingManager;
|
import com.gmail.nossr50.skills.woodcutting.WoodcuttingManager;
|
||||||
import com.gmail.nossr50.util.EventUtils;
|
import com.gmail.nossr50.util.EventUtils;
|
||||||
import com.gmail.nossr50.util.Misc;
|
import com.gmail.nossr50.util.Misc;
|
||||||
import com.gmail.nossr50.util.ModUtils;
|
|
||||||
import com.gmail.nossr50.util.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
import com.gmail.nossr50.util.StringUtils;
|
import com.gmail.nossr50.util.StringUtils;
|
||||||
import com.gmail.nossr50.util.skills.ParticleEffectUtils;
|
import com.gmail.nossr50.util.skills.ParticleEffectUtils;
|
||||||
@@ -80,7 +81,6 @@ public class McMMOPlayer {
|
|||||||
private final Map<AbilityType, Boolean> abilityInformed = new HashMap<AbilityType, Boolean>();
|
private final Map<AbilityType, Boolean> abilityInformed = new HashMap<AbilityType, Boolean>();
|
||||||
|
|
||||||
private final Map<ToolType, Boolean> toolMode = new HashMap<ToolType, Boolean>();
|
private final Map<ToolType, Boolean> toolMode = new HashMap<ToolType, Boolean>();
|
||||||
private final Map<ToolType, Integer> toolATS = new HashMap<ToolType, Integer>();
|
|
||||||
|
|
||||||
private int recentlyHurt;
|
private int recentlyHurt;
|
||||||
private int respawnATS;
|
private int respawnATS;
|
||||||
@@ -123,7 +123,6 @@ public class McMMOPlayer {
|
|||||||
|
|
||||||
for (ToolType toolType : ToolType.values()) {
|
for (ToolType toolType : ToolType.values()) {
|
||||||
toolMode.put(toolType, false);
|
toolMode.put(toolType, false);
|
||||||
toolATS.put(toolType, 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!profile.isLoaded()) {
|
if (!profile.isLoaded()) {
|
||||||
@@ -226,6 +225,10 @@ public class McMMOPlayer {
|
|||||||
return (RepairManager) skillManagers.get(SkillType.REPAIR);
|
return (RepairManager) skillManagers.get(SkillType.REPAIR);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public SalvageManager getSalvageManager() {
|
||||||
|
return (SalvageManager) skillManagers.get(SkillType.SALVAGE);
|
||||||
|
}
|
||||||
|
|
||||||
public SmeltingManager getSmeltingManager() {
|
public SmeltingManager getSmeltingManager() {
|
||||||
return (SmeltingManager) skillManagers.get(SkillType.SMELTING);
|
return (SmeltingManager) skillManagers.get(SkillType.SMELTING);
|
||||||
}
|
}
|
||||||
@@ -341,28 +344,6 @@ public class McMMOPlayer {
|
|||||||
toolMode.put(tool, isPrepared);
|
toolMode.put(tool, isPrepared);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the current prep ATS of a tool.
|
|
||||||
*
|
|
||||||
* @param tool Tool to get the ATS for
|
|
||||||
* @return the ATS for the tool
|
|
||||||
*/
|
|
||||||
public long getToolPreparationATS(ToolType tool) {
|
|
||||||
return toolATS.get(tool);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the current prep ATS of a tool.
|
|
||||||
*
|
|
||||||
* @param tool Tool to set the ATS for
|
|
||||||
* @param ATS the ATS of the tool
|
|
||||||
*/
|
|
||||||
public void setToolPreparationATS(ToolType tool, long ATS) {
|
|
||||||
int startTime = (int) (ATS / Misc.TIME_CONVERSION_FACTOR);
|
|
||||||
|
|
||||||
toolATS.put(tool, startTime);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Recently Hurt
|
* Recently Hurt
|
||||||
*/
|
*/
|
||||||
@@ -478,7 +459,7 @@ public class McMMOPlayer {
|
|||||||
* @param skill Skill being used
|
* @param skill Skill being used
|
||||||
* @param xp Experience amount to process
|
* @param xp Experience amount to process
|
||||||
*/
|
*/
|
||||||
public void beginXpGain(SkillType skill, float xp) {
|
public void beginXpGain(SkillType skill, float xp, XPGainReason xpGainReason) {
|
||||||
Validate.isTrue(xp >= 0.0, "XP gained should be greater than or equal to zero.");
|
Validate.isTrue(xp >= 0.0, "XP gained should be greater than or equal to zero.");
|
||||||
|
|
||||||
if (xp <= 0.0) {
|
if (xp <= 0.0) {
|
||||||
@@ -491,7 +472,7 @@ public class McMMOPlayer {
|
|||||||
|
|
||||||
for (SkillType parentSkill : parentSkills) {
|
for (SkillType parentSkill : parentSkills) {
|
||||||
if (parentSkill.getPermissions(player)) {
|
if (parentSkill.getPermissions(player)) {
|
||||||
beginXpGain(parentSkill, splitXp);
|
beginXpGain(parentSkill, splitXp, xpGainReason);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -499,11 +480,11 @@ public class McMMOPlayer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Return if the experience has been shared
|
// Return if the experience has been shared
|
||||||
if (party != null && ShareHandler.handleXpShare(xp, this, skill)) {
|
if (party != null && ShareHandler.handleXpShare(xp, this, skill, ShareHandler.getSharedXpGainReason(xpGainReason))) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
beginUnsharedXpGain(skill, xp);
|
beginUnsharedXpGain(skill, xp, xpGainReason);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -512,8 +493,8 @@ public class McMMOPlayer {
|
|||||||
* @param skill Skill being used
|
* @param skill Skill being used
|
||||||
* @param xp Experience amount to process
|
* @param xp Experience amount to process
|
||||||
*/
|
*/
|
||||||
public void beginUnsharedXpGain(SkillType skill, float xp) {
|
public void beginUnsharedXpGain(SkillType skill, float xp, XPGainReason xpGainReason) {
|
||||||
applyXpGain(skill, modifyXpGain(skill, xp));
|
applyXpGain(skill, modifyXpGain(skill, xp), xpGainReason);
|
||||||
|
|
||||||
if (party == null) {
|
if (party == null) {
|
||||||
return;
|
return;
|
||||||
@@ -530,7 +511,7 @@ public class McMMOPlayer {
|
|||||||
* @param skillType Skill being used
|
* @param skillType Skill being used
|
||||||
* @param xp Experience amount to add
|
* @param xp Experience amount to add
|
||||||
*/
|
*/
|
||||||
public void applyXpGain(SkillType skillType, float xp) {
|
public void applyXpGain(SkillType skillType, float xp, XPGainReason xpGainReason) {
|
||||||
if (!skillType.getPermissions(player)) {
|
if (!skillType.getPermissions(player)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -539,18 +520,18 @@ public class McMMOPlayer {
|
|||||||
Set<SkillType> parentSkills = FamilyTree.getParents(skillType);
|
Set<SkillType> parentSkills = FamilyTree.getParents(skillType);
|
||||||
|
|
||||||
for (SkillType parentSkill : parentSkills) {
|
for (SkillType parentSkill : parentSkills) {
|
||||||
applyXpGain(parentSkill, xp / parentSkills.size());
|
applyXpGain(parentSkill, xp / parentSkills.size(), xpGainReason);
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!EventUtils.handleXpGainEvent(player, skillType, xp)) {
|
if (!EventUtils.handleXpGainEvent(player, skillType, xp, xpGainReason)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
isUsingUnarmed = (skillType == SkillType.UNARMED);
|
isUsingUnarmed = (skillType == SkillType.UNARMED);
|
||||||
checkXp(skillType);
|
checkXp(skillType, xpGainReason);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -558,7 +539,7 @@ public class McMMOPlayer {
|
|||||||
*
|
*
|
||||||
* @param skillType The skill to check
|
* @param skillType The skill to check
|
||||||
*/
|
*/
|
||||||
private void checkXp(SkillType skillType) {
|
private void checkXp(SkillType skillType, XPGainReason xpGainReason) {
|
||||||
if (getSkillXpLevelRaw(skillType) < getXpToLevel(skillType)) {
|
if (getSkillXpLevelRaw(skillType) < getXpToLevel(skillType)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -576,7 +557,7 @@ public class McMMOPlayer {
|
|||||||
levelsGained++;
|
levelsGained++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!EventUtils.handleLevelChangeEvent(player, skillType, levelsGained, xpRemoved, true)) {
|
if (!EventUtils.handleLevelChangeEvent(player, skillType, levelsGained, xpRemoved, true, xpGainReason)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -595,10 +576,6 @@ public class McMMOPlayer {
|
|||||||
return player;
|
return player;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPlayer(Player player) {
|
|
||||||
this.player = player;
|
|
||||||
}
|
|
||||||
|
|
||||||
public PlayerProfile getProfile() {
|
public PlayerProfile getProfile() {
|
||||||
return profile;
|
return profile;
|
||||||
}
|
}
|
||||||
@@ -757,7 +734,7 @@ public class McMMOPlayer {
|
|||||||
xp = (float) (xp / skillType.getXpModifier() * ExperienceConfig.getInstance().getExperienceGainsGlobalMultiplier());
|
xp = (float) (xp / skillType.getXpModifier() * ExperienceConfig.getInstance().getExperienceGainsGlobalMultiplier());
|
||||||
|
|
||||||
if (Config.getInstance().getToolModsEnabled()) {
|
if (Config.getInstance().getToolModsEnabled()) {
|
||||||
CustomTool tool = ModUtils.getToolFromItemStack(player.getItemInHand());
|
CustomTool tool = mcMMO.getModManager().getTool(player.getItemInHand());
|
||||||
|
|
||||||
if (tool != null) {
|
if (tool != null) {
|
||||||
xp *= tool.getXpMultiplier();
|
xp *= tool.getXpMultiplier();
|
||||||
@@ -843,7 +820,7 @@ public class McMMOPlayer {
|
|||||||
|
|
||||||
ItemStack inHand = player.getItemInHand();
|
ItemStack inHand = player.getItemInHand();
|
||||||
|
|
||||||
if (ModUtils.isCustomTool(inHand) && !ModUtils.getToolFromItemStack(inHand).isAbilityEnabled()) {
|
if (mcMMO.getModManager().isCustomTool(inHand) && !mcMMO.getModManager().getTool(inHand).isAbilityEnabled()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -878,7 +855,6 @@ public class McMMOPlayer {
|
|||||||
player.sendMessage(tool.getRaiseTool());
|
player.sendMessage(tool.getRaiseTool());
|
||||||
}
|
}
|
||||||
|
|
||||||
setToolPreparationATS(tool, System.currentTimeMillis());
|
|
||||||
setToolPreparationMode(tool, true);
|
setToolPreparationMode(tool, true);
|
||||||
new ToolLowerTask(this, tool).runTaskLaterAsynchronously(mcMMO.p, 4 * Misc.TICK_CONVERSION_FACTOR);
|
new ToolLowerTask(this, tool).runTaskLaterAsynchronously(mcMMO.p, 4 * Misc.TICK_CONVERSION_FACTOR);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import com.gmail.nossr50.datatypes.MobHealthbarType;
|
|||||||
import com.gmail.nossr50.datatypes.experience.FormulaType;
|
import com.gmail.nossr50.datatypes.experience.FormulaType;
|
||||||
import com.gmail.nossr50.datatypes.skills.AbilityType;
|
import com.gmail.nossr50.datatypes.skills.AbilityType;
|
||||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||||
|
import com.gmail.nossr50.runnables.player.PlayerProfileSaveTask;
|
||||||
import com.gmail.nossr50.skills.child.FamilyTree;
|
import com.gmail.nossr50.skills.child.FamilyTree;
|
||||||
import com.gmail.nossr50.util.player.UserManager;
|
import com.gmail.nossr50.util.player.UserManager;
|
||||||
|
|
||||||
@@ -19,7 +20,7 @@ import com.google.common.collect.ImmutableMap;
|
|||||||
public class PlayerProfile {
|
public class PlayerProfile {
|
||||||
private final String playerName;
|
private final String playerName;
|
||||||
private boolean loaded;
|
private boolean loaded;
|
||||||
private boolean changed;
|
private volatile boolean changed;
|
||||||
|
|
||||||
/* HUDs */
|
/* HUDs */
|
||||||
private MobHealthbarType mobHealthbarType;
|
private MobHealthbarType mobHealthbarType;
|
||||||
@@ -60,12 +61,18 @@ public class PlayerProfile {
|
|||||||
loaded = true;
|
loaded = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void scheduleAsyncSave() {
|
||||||
|
new PlayerProfileSaveTask(this).runTaskAsynchronously(mcMMO.p);
|
||||||
|
}
|
||||||
|
|
||||||
public void save() {
|
public void save() {
|
||||||
if (!changed || !loaded) {
|
if (!changed || !loaded) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
changed = !mcMMO.getDatabaseManager().saveUser(new PlayerProfile(playerName, ImmutableMap.copyOf(skills), ImmutableMap.copyOf(skillsXp), ImmutableMap.copyOf(abilityDATS), mobHealthbarType));
|
// TODO should this part be synchronized?
|
||||||
|
PlayerProfile profileCopy = new PlayerProfile(playerName, ImmutableMap.copyOf(skills), ImmutableMap.copyOf(skillsXp), ImmutableMap.copyOf(abilityDATS), mobHealthbarType);
|
||||||
|
changed = !mcMMO.getDatabaseManager().saveUser(profileCopy);
|
||||||
|
|
||||||
if (changed) {
|
if (changed) {
|
||||||
mcMMO.p.getLogger().warning("PlayerProfile for " + playerName + " failed to save");
|
mcMMO.p.getLogger().warning("PlayerProfile for " + playerName + " failed to save");
|
||||||
|
|||||||
@@ -0,0 +1,7 @@
|
|||||||
|
package com.gmail.nossr50.datatypes.skills;
|
||||||
|
|
||||||
|
public enum ItemType {
|
||||||
|
ARMOR,
|
||||||
|
TOOL,
|
||||||
|
OTHER;
|
||||||
|
}
|
||||||
@@ -0,0 +1,43 @@
|
|||||||
|
package com.gmail.nossr50.datatypes.skills;
|
||||||
|
|
||||||
|
import org.bukkit.Material;
|
||||||
|
|
||||||
|
public enum MaterialType {
|
||||||
|
STRING,
|
||||||
|
LEATHER,
|
||||||
|
WOOD,
|
||||||
|
STONE,
|
||||||
|
IRON,
|
||||||
|
GOLD,
|
||||||
|
DIAMOND,
|
||||||
|
OTHER;
|
||||||
|
|
||||||
|
public Material getDefaultMaterial() {
|
||||||
|
switch (this) {
|
||||||
|
case STRING:
|
||||||
|
return Material.STRING;
|
||||||
|
|
||||||
|
case LEATHER:
|
||||||
|
return Material.LEATHER;
|
||||||
|
|
||||||
|
case WOOD:
|
||||||
|
return Material.WOOD;
|
||||||
|
|
||||||
|
case STONE:
|
||||||
|
return Material.COBBLESTONE;
|
||||||
|
|
||||||
|
case IRON:
|
||||||
|
return Material.IRON_INGOT;
|
||||||
|
|
||||||
|
case GOLD:
|
||||||
|
return Material.GOLD_INGOT;
|
||||||
|
|
||||||
|
case DIAMOND:
|
||||||
|
return Material.DIAMOND;
|
||||||
|
|
||||||
|
case OTHER:
|
||||||
|
default:
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -46,9 +46,12 @@ public enum SecondaryAbility {
|
|||||||
/* Repair */
|
/* Repair */
|
||||||
ARCANE_FORGING,
|
ARCANE_FORGING,
|
||||||
REPAIR_MASTERY,
|
REPAIR_MASTERY,
|
||||||
SALVAGE,
|
|
||||||
SUPER_REPAIR,
|
SUPER_REPAIR,
|
||||||
|
|
||||||
|
/* Salvage */
|
||||||
|
ADVANCED_SALVAGE,
|
||||||
|
ARCANE_SALVAGE,
|
||||||
|
|
||||||
/* Smelting */
|
/* Smelting */
|
||||||
FLUX_MINING,
|
FLUX_MINING,
|
||||||
FUEL_EFFICIENCY,
|
FUEL_EFFICIENCY,
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ import com.gmail.nossr50.skills.fishing.FishingManager;
|
|||||||
import com.gmail.nossr50.skills.herbalism.HerbalismManager;
|
import com.gmail.nossr50.skills.herbalism.HerbalismManager;
|
||||||
import com.gmail.nossr50.skills.mining.MiningManager;
|
import com.gmail.nossr50.skills.mining.MiningManager;
|
||||||
import com.gmail.nossr50.skills.repair.RepairManager;
|
import com.gmail.nossr50.skills.repair.RepairManager;
|
||||||
|
import com.gmail.nossr50.skills.salvage.SalvageManager;
|
||||||
import com.gmail.nossr50.skills.smelting.SmeltingManager;
|
import com.gmail.nossr50.skills.smelting.SmeltingManager;
|
||||||
import com.gmail.nossr50.skills.swords.SwordsManager;
|
import com.gmail.nossr50.skills.swords.SwordsManager;
|
||||||
import com.gmail.nossr50.skills.taming.TamingManager;
|
import com.gmail.nossr50.skills.taming.TamingManager;
|
||||||
@@ -43,7 +44,8 @@ public enum SkillType {
|
|||||||
FISHING(FishingManager.class, Color.NAVY, ImmutableList.of(SecondaryAbility.FISHERMANS_DIET, SecondaryAbility.FISHING_TREASURE_HUNTER, SecondaryAbility.ICE_FISHING, SecondaryAbility.MAGIC_HUNTER, SecondaryAbility.MASTER_ANGLER, SecondaryAbility.SHAKE)),
|
FISHING(FishingManager.class, Color.NAVY, ImmutableList.of(SecondaryAbility.FISHERMANS_DIET, SecondaryAbility.FISHING_TREASURE_HUNTER, SecondaryAbility.ICE_FISHING, SecondaryAbility.MAGIC_HUNTER, SecondaryAbility.MASTER_ANGLER, SecondaryAbility.SHAKE)),
|
||||||
HERBALISM(HerbalismManager.class, Color.GREEN, AbilityType.GREEN_TERRA, ToolType.HOE, ImmutableList.of(SecondaryAbility.FARMERS_DIET, SecondaryAbility.GREEN_THUMB_PLANT, SecondaryAbility.GREEN_THUMB_BLOCK, SecondaryAbility.HERBALISM_DOUBLE_DROPS, SecondaryAbility.HYLIAN_LUCK, SecondaryAbility.SHROOM_THUMB)),
|
HERBALISM(HerbalismManager.class, Color.GREEN, AbilityType.GREEN_TERRA, ToolType.HOE, ImmutableList.of(SecondaryAbility.FARMERS_DIET, SecondaryAbility.GREEN_THUMB_PLANT, SecondaryAbility.GREEN_THUMB_BLOCK, SecondaryAbility.HERBALISM_DOUBLE_DROPS, SecondaryAbility.HYLIAN_LUCK, SecondaryAbility.SHROOM_THUMB)),
|
||||||
MINING(MiningManager.class, Color.GRAY, AbilityType.SUPER_BREAKER, ToolType.PICKAXE, ImmutableList.of(SecondaryAbility.MINING_DOUBLE_DROPS)),
|
MINING(MiningManager.class, Color.GRAY, AbilityType.SUPER_BREAKER, ToolType.PICKAXE, ImmutableList.of(SecondaryAbility.MINING_DOUBLE_DROPS)),
|
||||||
REPAIR(RepairManager.class, Color.SILVER, ImmutableList.of(SecondaryAbility.ARCANE_FORGING, SecondaryAbility.REPAIR_MASTERY, SecondaryAbility.SALVAGE, SecondaryAbility.SUPER_REPAIR)),
|
REPAIR(RepairManager.class, Color.SILVER, ImmutableList.of(SecondaryAbility.ARCANE_FORGING, SecondaryAbility.REPAIR_MASTERY, SecondaryAbility.SUPER_REPAIR)),
|
||||||
|
SALVAGE(SalvageManager.class, Color.ORANGE, ImmutableList.of(SecondaryAbility.ADVANCED_SALVAGE, SecondaryAbility.ARCANE_SALVAGE)),
|
||||||
SMELTING(SmeltingManager.class, Color.YELLOW, ImmutableList.of(SecondaryAbility.FLUX_MINING, SecondaryAbility.FUEL_EFFICIENCY, SecondaryAbility.SECOND_SMELT)),
|
SMELTING(SmeltingManager.class, Color.YELLOW, ImmutableList.of(SecondaryAbility.FLUX_MINING, SecondaryAbility.FUEL_EFFICIENCY, SecondaryAbility.SECOND_SMELT)),
|
||||||
SWORDS(SwordsManager.class, Color.fromRGB(178, 34, 34), AbilityType.SERRATED_STRIKES, ToolType.SWORD, ImmutableList.of(SecondaryAbility.BLEED, SecondaryAbility.COUNTER)),
|
SWORDS(SwordsManager.class, Color.fromRGB(178, 34, 34), AbilityType.SERRATED_STRIKES, ToolType.SWORD, ImmutableList.of(SecondaryAbility.BLEED, SecondaryAbility.COUNTER)),
|
||||||
TAMING(TamingManager.class, Color.PURPLE, ImmutableList.of(SecondaryAbility.BEAST_LORE, SecondaryAbility.CALL_OF_THE_WILD, SecondaryAbility.ENVIROMENTALLY_AWARE, SecondaryAbility.FAST_FOOD, SecondaryAbility.GORE, SecondaryAbility.HOLY_HOUND, SecondaryAbility.SHARPENED_CLAWS, SecondaryAbility.SHOCK_PROOF, SecondaryAbility.THICK_FUR)),
|
TAMING(TamingManager.class, Color.PURPLE, ImmutableList.of(SecondaryAbility.BEAST_LORE, SecondaryAbility.CALL_OF_THE_WILD, SecondaryAbility.ENVIROMENTALLY_AWARE, SecondaryAbility.FAST_FOOD, SecondaryAbility.GORE, SecondaryAbility.HOLY_HOUND, SecondaryAbility.SHARPENED_CLAWS, SecondaryAbility.SHOCK_PROOF, SecondaryAbility.THICK_FUR)),
|
||||||
@@ -63,7 +65,7 @@ public enum SkillType {
|
|||||||
|
|
||||||
public static final List<SkillType> COMBAT_SKILLS = ImmutableList.of(ARCHERY, AXES, SWORDS, TAMING, UNARMED);
|
public static final List<SkillType> COMBAT_SKILLS = ImmutableList.of(ARCHERY, AXES, SWORDS, TAMING, UNARMED);
|
||||||
public static final List<SkillType> GATHERING_SKILLS = ImmutableList.of(EXCAVATION, FISHING, HERBALISM, MINING, WOODCUTTING);
|
public static final List<SkillType> GATHERING_SKILLS = ImmutableList.of(EXCAVATION, FISHING, HERBALISM, MINING, WOODCUTTING);
|
||||||
public static final List<SkillType> MISC_SKILLS = ImmutableList.of(ACROBATICS, ALCHEMY, REPAIR, SMELTING);
|
public static final List<SkillType> MISC_SKILLS = ImmutableList.of(ACROBATICS, ALCHEMY, REPAIR, SALVAGE, SMELTING);
|
||||||
|
|
||||||
static {
|
static {
|
||||||
List<SkillType> childSkills = new ArrayList<SkillType>();
|
List<SkillType> childSkills = new ArrayList<SkillType>();
|
||||||
@@ -182,6 +184,7 @@ public enum SkillType {
|
|||||||
// TODO: This is a little "hacky", we probably need to add something to distinguish child skills in the enum, or to use another enum for them
|
// TODO: This is a little "hacky", we probably need to add something to distinguish child skills in the enum, or to use another enum for them
|
||||||
public boolean isChildSkill() {
|
public boolean isChildSkill() {
|
||||||
switch (this) {
|
switch (this) {
|
||||||
|
case SALVAGE:
|
||||||
case SMELTING:
|
case SMELTING:
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,21 @@
|
|||||||
|
package com.gmail.nossr50.datatypes.skills;
|
||||||
|
|
||||||
|
public enum XPGainReason {
|
||||||
|
PVP,
|
||||||
|
PVE,
|
||||||
|
VAMPIRISM,
|
||||||
|
SHARED_PVP,
|
||||||
|
SHARED_PVE,
|
||||||
|
COMMAND,
|
||||||
|
UNKNOWN;
|
||||||
|
|
||||||
|
public static XPGainReason getXPGainReason(String reason) {
|
||||||
|
for (XPGainReason type : values()) {
|
||||||
|
if (type.name().equalsIgnoreCase(reason)) {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package com.gmail.nossr50.datatypes;
|
package com.gmail.nossr50.datatypes.skills.alchemy;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@@ -25,25 +25,27 @@ public class AlchemyPotion {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "AlchemyPotion{" + dataValue + "," + name + ",Effects[" + effects.size() + "], Children[" + children.size() + "]}";
|
return "AlchemyPotion{" + dataValue + ", " + name + ", Effects[" + effects.size() + "], Children[" + children.size() + "]}";
|
||||||
}
|
|
||||||
|
|
||||||
public ItemStack toItemStack() {
|
|
||||||
return toItemStack(1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ItemStack toItemStack(int amount) {
|
public ItemStack toItemStack(int amount) {
|
||||||
ItemStack potion = new ItemStack(Material.POTION, amount, this.getDataValue());
|
ItemStack potion = new ItemStack(Material.POTION, amount, this.getDataValue());
|
||||||
PotionMeta meta = (PotionMeta) potion.getItemMeta();
|
PotionMeta meta = (PotionMeta) potion.getItemMeta();
|
||||||
meta.setDisplayName(this.getName());
|
|
||||||
|
if (this.getName() != null) {
|
||||||
|
meta.setDisplayName(this.getName());
|
||||||
|
}
|
||||||
|
|
||||||
if (this.getLore() != null && !this.getLore().isEmpty()) {
|
if (this.getLore() != null && !this.getLore().isEmpty()) {
|
||||||
meta.setLore(this.getLore());
|
meta.setLore(this.getLore());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!this.getEffects().isEmpty()) {
|
if (!this.getEffects().isEmpty()) {
|
||||||
for (PotionEffect effect : this.getEffects()) {
|
for (PotionEffect effect : this.getEffects()) {
|
||||||
meta.addCustomEffect(effect, true);
|
meta.addCustomEffect(effect, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
potion.setItemMeta(meta);
|
potion.setItemMeta(meta);
|
||||||
return potion;
|
return potion;
|
||||||
}
|
}
|
||||||
@@ -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);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -6,6 +6,7 @@ import org.bukkit.event.HandlerList;
|
|||||||
import org.bukkit.event.player.PlayerEvent;
|
import org.bukkit.event.player.PlayerEvent;
|
||||||
|
|
||||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||||
|
import com.gmail.nossr50.datatypes.skills.XPGainReason;
|
||||||
import com.gmail.nossr50.util.player.UserManager;
|
import com.gmail.nossr50.util.player.UserManager;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -15,11 +16,21 @@ public abstract class McMMOPlayerExperienceEvent extends PlayerEvent implements
|
|||||||
private boolean cancelled;
|
private boolean cancelled;
|
||||||
protected SkillType skill;
|
protected SkillType skill;
|
||||||
protected int skillLevel;
|
protected int skillLevel;
|
||||||
|
protected XPGainReason xpGainReason;
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
protected McMMOPlayerExperienceEvent(Player player, SkillType skill) {
|
protected McMMOPlayerExperienceEvent(Player player, SkillType skill) {
|
||||||
super(player);
|
super(player);
|
||||||
this.skill = skill;
|
this.skill = skill;
|
||||||
this.skillLevel = UserManager.getPlayer(player).getSkillLevel(skill);
|
this.skillLevel = UserManager.getPlayer(player).getSkillLevel(skill);
|
||||||
|
this.xpGainReason = XPGainReason.UNKNOWN;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected McMMOPlayerExperienceEvent(Player player, SkillType skill, XPGainReason xpGainReason) {
|
||||||
|
super(player);
|
||||||
|
this.skill = skill;
|
||||||
|
this.skillLevel = UserManager.getPlayer(player).getSkillLevel(skill);
|
||||||
|
this.xpGainReason = xpGainReason;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -36,6 +47,13 @@ public abstract class McMMOPlayerExperienceEvent extends PlayerEvent implements
|
|||||||
return skillLevel;
|
return skillLevel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return The combat type involved in this event
|
||||||
|
*/
|
||||||
|
public XPGainReason getXpGainReason() {
|
||||||
|
return xpGainReason;
|
||||||
|
}
|
||||||
|
|
||||||
/** Following are required for Cancellable **/
|
/** Following are required for Cancellable **/
|
||||||
@Override
|
@Override
|
||||||
public boolean isCancelled() {
|
public boolean isCancelled() {
|
||||||
|
|||||||
@@ -3,12 +3,18 @@ package com.gmail.nossr50.events.experience;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||||
|
import com.gmail.nossr50.datatypes.skills.XPGainReason;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when a user levels change
|
* Called when a user levels change
|
||||||
*/
|
*/
|
||||||
public abstract class McMMOPlayerLevelChangeEvent extends McMMOPlayerExperienceEvent {
|
public abstract class McMMOPlayerLevelChangeEvent extends McMMOPlayerExperienceEvent {
|
||||||
|
@Deprecated
|
||||||
public McMMOPlayerLevelChangeEvent(Player player, SkillType skill) {
|
public McMMOPlayerLevelChangeEvent(Player player, SkillType skill) {
|
||||||
super(player, skill);
|
super(player, skill, XPGainReason.UNKNOWN);
|
||||||
|
}
|
||||||
|
|
||||||
|
public McMMOPlayerLevelChangeEvent(Player player, SkillType skill, XPGainReason xpGainReason) {
|
||||||
|
super(player, skill, xpGainReason);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package com.gmail.nossr50.events.experience;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||||
|
import com.gmail.nossr50.datatypes.skills.XPGainReason;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when a user loses levels in a skill
|
* Called when a user loses levels in a skill
|
||||||
@@ -10,13 +11,25 @@ import com.gmail.nossr50.datatypes.skills.SkillType;
|
|||||||
public class McMMOPlayerLevelDownEvent extends McMMOPlayerLevelChangeEvent {
|
public class McMMOPlayerLevelDownEvent extends McMMOPlayerLevelChangeEvent {
|
||||||
private int levelsLost;
|
private int levelsLost;
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public McMMOPlayerLevelDownEvent(Player player, SkillType skill) {
|
public McMMOPlayerLevelDownEvent(Player player, SkillType skill) {
|
||||||
super(player, skill);
|
super(player, skill, XPGainReason.UNKNOWN);
|
||||||
this.levelsLost = 1;
|
this.levelsLost = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public McMMOPlayerLevelDownEvent(Player player, SkillType skill, int levelsLost) {
|
public McMMOPlayerLevelDownEvent(Player player, SkillType skill, int levelsLost) {
|
||||||
super(player, skill);
|
super(player, skill, XPGainReason.UNKNOWN);
|
||||||
|
this.levelsLost = levelsLost;
|
||||||
|
}
|
||||||
|
|
||||||
|
public McMMOPlayerLevelDownEvent(Player player, SkillType skill, XPGainReason xpGainReason) {
|
||||||
|
super(player, skill, xpGainReason);
|
||||||
|
this.levelsLost = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public McMMOPlayerLevelDownEvent(Player player, SkillType skill, int levelsLost, XPGainReason xpGainReason) {
|
||||||
|
super(player, skill, xpGainReason);
|
||||||
this.levelsLost = levelsLost;
|
this.levelsLost = levelsLost;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package com.gmail.nossr50.events.experience;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||||
|
import com.gmail.nossr50.datatypes.skills.XPGainReason;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when a user levels up in a skill
|
* Called when a user levels up in a skill
|
||||||
@@ -10,13 +11,25 @@ import com.gmail.nossr50.datatypes.skills.SkillType;
|
|||||||
public class McMMOPlayerLevelUpEvent extends McMMOPlayerLevelChangeEvent {
|
public class McMMOPlayerLevelUpEvent extends McMMOPlayerLevelChangeEvent {
|
||||||
private int levelsGained;
|
private int levelsGained;
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public McMMOPlayerLevelUpEvent(Player player, SkillType skill) {
|
public McMMOPlayerLevelUpEvent(Player player, SkillType skill) {
|
||||||
super(player, skill);
|
super(player, skill, XPGainReason.UNKNOWN);
|
||||||
this.levelsGained = 1;
|
this.levelsGained = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public McMMOPlayerLevelUpEvent(Player player, SkillType skill, int levelsGained) {
|
public McMMOPlayerLevelUpEvent(Player player, SkillType skill, int levelsGained) {
|
||||||
super(player, skill);
|
super(player, skill, XPGainReason.UNKNOWN);
|
||||||
|
this.levelsGained = levelsGained;
|
||||||
|
}
|
||||||
|
|
||||||
|
public McMMOPlayerLevelUpEvent(Player player, SkillType skill, XPGainReason xpGainReason) {
|
||||||
|
super(player, skill, xpGainReason);
|
||||||
|
this.levelsGained = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public McMMOPlayerLevelUpEvent(Player player, SkillType skill, int levelsGained, XPGainReason xpGainReason) {
|
||||||
|
super(player, skill, xpGainReason);
|
||||||
this.levelsGained = levelsGained;
|
this.levelsGained = levelsGained;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package com.gmail.nossr50.events.experience;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||||
|
import com.gmail.nossr50.datatypes.skills.XPGainReason;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when a player gains XP in a skill
|
* Called when a player gains XP in a skill
|
||||||
@@ -10,8 +11,14 @@ import com.gmail.nossr50.datatypes.skills.SkillType;
|
|||||||
public class McMMOPlayerXpGainEvent extends McMMOPlayerExperienceEvent {
|
public class McMMOPlayerXpGainEvent extends McMMOPlayerExperienceEvent {
|
||||||
private float xpGained;
|
private float xpGained;
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public McMMOPlayerXpGainEvent(Player player, SkillType skill, float xpGained) {
|
public McMMOPlayerXpGainEvent(Player player, SkillType skill, float xpGained) {
|
||||||
super(player, skill);
|
super(player, skill, XPGainReason.UNKNOWN);
|
||||||
|
this.xpGained = xpGained;
|
||||||
|
}
|
||||||
|
|
||||||
|
public McMMOPlayerXpGainEvent(Player player, SkillType skill, float xpGained, XPGainReason xpGainReason) {
|
||||||
|
super(player, skill, xpGainReason);
|
||||||
this.xpGained = xpGained;
|
this.xpGained = xpGained;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,5 +1,7 @@
|
|||||||
package com.gmail.nossr50.events.fake;
|
package com.gmail.nossr50.events.fake;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
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.
|
* Called when mcMMO applies damage from an entity due to special abilities.
|
||||||
*/
|
*/
|
||||||
public class FakeEntityDamageByEntityEvent extends EntityDamageByEntityEvent {
|
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) {
|
public FakeEntityDamageByEntityEvent(Entity damager, Entity damagee, DamageCause cause, double damage) {
|
||||||
super(damager, damagee, cause, damage);
|
super(damager, damagee, cause, damage);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
package com.gmail.nossr50.events.fake;
|
package com.gmail.nossr50.events.fake;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.event.entity.EntityDamageEvent;
|
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.
|
* Called when mcMMO applies damage due to special abilities.
|
||||||
*/
|
*/
|
||||||
public class FakeEntityDamageEvent extends EntityDamageEvent {
|
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) {
|
public FakeEntityDamageEvent(Entity damagee, DamageCause cause, double damage) {
|
||||||
super(damagee, cause, damage);
|
super(damagee, cause, damage);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,14 @@
|
|||||||
|
package com.gmail.nossr50.events.fake;
|
||||||
|
|
||||||
|
import org.bukkit.entity.AnimalTamer;
|
||||||
|
import org.bukkit.entity.LivingEntity;
|
||||||
|
import org.bukkit.event.entity.EntityTameEvent;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when mcMMO tames an animal via Call of the Wild
|
||||||
|
*/
|
||||||
|
public class FakeEntityTameEvent extends EntityTameEvent {
|
||||||
|
public FakeEntityTameEvent(LivingEntity entity, AnimalTamer owner) {
|
||||||
|
super(entity, owner);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,18 +1,20 @@
|
|||||||
package com.gmail.nossr50.events.skills.secondaryabilities;
|
package com.gmail.nossr50.events.skills.secondaryabilities;
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.Cancellable;
|
||||||
|
|
||||||
import com.gmail.nossr50.datatypes.skills.SecondaryAbility;
|
import com.gmail.nossr50.datatypes.skills.SecondaryAbility;
|
||||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||||
import com.gmail.nossr50.events.skills.McMMOPlayerSkillEvent;
|
import com.gmail.nossr50.events.skills.McMMOPlayerSkillEvent;
|
||||||
|
|
||||||
public abstract class SecondaryAbilityEvent extends McMMOPlayerSkillEvent {
|
public class SecondaryAbilityEvent extends McMMOPlayerSkillEvent implements Cancellable {
|
||||||
|
|
||||||
private SecondaryAbility secondaryAbility;
|
private SecondaryAbility secondaryAbility;
|
||||||
|
private boolean cancelled;
|
||||||
|
|
||||||
public SecondaryAbilityEvent(Player player, SecondaryAbility secondaryAbility) {
|
public SecondaryAbilityEvent(Player player, SecondaryAbility secondaryAbility) {
|
||||||
super(player, SkillType.bySecondaryAbility(secondaryAbility));
|
super(player, SkillType.bySecondaryAbility(secondaryAbility));
|
||||||
this.secondaryAbility = secondaryAbility;
|
this.secondaryAbility = secondaryAbility;
|
||||||
|
cancelled = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -22,4 +24,12 @@ public abstract class SecondaryAbilityEvent extends McMMOPlayerSkillEvent {
|
|||||||
public SecondaryAbility getSecondaryAbility() {
|
public SecondaryAbility getSecondaryAbility() {
|
||||||
return secondaryAbility;
|
return secondaryAbility;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isCancelled() {
|
||||||
|
return cancelled;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCancelled(boolean newValue) {
|
||||||
|
this.cancelled = newValue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import org.bukkit.entity.Player;
|
|||||||
import com.gmail.nossr50.datatypes.skills.SecondaryAbility;
|
import com.gmail.nossr50.datatypes.skills.SecondaryAbility;
|
||||||
|
|
||||||
public class SecondaryAbilityWeightedActivationCheckEvent extends SecondaryAbilityEvent {
|
public class SecondaryAbilityWeightedActivationCheckEvent extends SecondaryAbilityEvent {
|
||||||
|
|
||||||
private double chance;
|
private double chance;
|
||||||
|
|
||||||
public SecondaryAbilityWeightedActivationCheckEvent(Player player, SecondaryAbility ability, double chance) {
|
public SecondaryAbilityWeightedActivationCheckEvent(Player player, SecondaryAbility ability, double chance) {
|
||||||
@@ -15,6 +14,7 @@ public class SecondaryAbilityWeightedActivationCheckEvent extends SecondaryAbili
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the activation chance of the ability 0D being no chance, 1.0D being 100% chance
|
* Gets the activation chance of the ability 0D being no chance, 1.0D being 100% chance
|
||||||
|
*
|
||||||
* @return The activation chance of the ability
|
* @return The activation chance of the ability
|
||||||
*/
|
*/
|
||||||
public double getChance() {
|
public double getChance() {
|
||||||
@@ -23,7 +23,8 @@ public class SecondaryAbilityWeightedActivationCheckEvent extends SecondaryAbili
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the activation chance of the ability [0D-1.0D]
|
* Sets the activation chance of the ability [0D-1.0D]
|
||||||
* @param The activation chance of the ability
|
*
|
||||||
|
* @param chance The activation chance of the ability
|
||||||
*/
|
*/
|
||||||
public void setChance(double chance) {
|
public void setChance(double chance) {
|
||||||
this.chance = chance;
|
this.chance = chance;
|
||||||
@@ -31,7 +32,8 @@ public class SecondaryAbilityWeightedActivationCheckEvent extends SecondaryAbili
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the activation chance of the ability to 100% or 0%
|
* Sets the activation chance of the ability to 100% or 0%
|
||||||
* @param whether it should be successful or not
|
*
|
||||||
|
* @param success whether it should be successful or not
|
||||||
*/
|
*/
|
||||||
public void setSuccessful(boolean success) {
|
public void setSuccessful(boolean success) {
|
||||||
this.chance = success ? 1.0D : 0D;
|
this.chance = success ? 1.0D : 0D;
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package com.gmail.nossr50.listeners;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.bukkit.GameMode;
|
import org.bukkit.GameMode;
|
||||||
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.Sound;
|
import org.bukkit.Sound;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
@@ -30,11 +31,15 @@ import com.gmail.nossr50.datatypes.skills.SkillType;
|
|||||||
import com.gmail.nossr50.datatypes.skills.ToolType;
|
import com.gmail.nossr50.datatypes.skills.ToolType;
|
||||||
import com.gmail.nossr50.events.fake.FakeBlockBreakEvent;
|
import com.gmail.nossr50.events.fake.FakeBlockBreakEvent;
|
||||||
import com.gmail.nossr50.events.fake.FakeBlockDamageEvent;
|
import com.gmail.nossr50.events.fake.FakeBlockDamageEvent;
|
||||||
|
import com.gmail.nossr50.runnables.PistonTrackerTask;
|
||||||
import com.gmail.nossr50.runnables.StickyPistonTrackerTask;
|
import com.gmail.nossr50.runnables.StickyPistonTrackerTask;
|
||||||
import com.gmail.nossr50.skills.alchemy.Alchemy;
|
import com.gmail.nossr50.skills.alchemy.Alchemy;
|
||||||
import com.gmail.nossr50.skills.excavation.ExcavationManager;
|
import com.gmail.nossr50.skills.excavation.ExcavationManager;
|
||||||
|
import com.gmail.nossr50.skills.herbalism.Herbalism;
|
||||||
import com.gmail.nossr50.skills.herbalism.HerbalismManager;
|
import com.gmail.nossr50.skills.herbalism.HerbalismManager;
|
||||||
import com.gmail.nossr50.skills.mining.MiningManager;
|
import com.gmail.nossr50.skills.mining.MiningManager;
|
||||||
|
import com.gmail.nossr50.skills.repair.Repair;
|
||||||
|
import com.gmail.nossr50.skills.salvage.Salvage;
|
||||||
import com.gmail.nossr50.skills.smelting.SmeltingManager;
|
import com.gmail.nossr50.skills.smelting.SmeltingManager;
|
||||||
import com.gmail.nossr50.skills.woodcutting.WoodcuttingManager;
|
import com.gmail.nossr50.skills.woodcutting.WoodcuttingManager;
|
||||||
import com.gmail.nossr50.util.BlockUtils;
|
import com.gmail.nossr50.util.BlockUtils;
|
||||||
@@ -59,27 +64,27 @@ public class BlockListener implements Listener {
|
|||||||
*/
|
*/
|
||||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||||
public void onBlockPistonExtend(BlockPistonExtendEvent event) {
|
public void onBlockPistonExtend(BlockPistonExtendEvent event) {
|
||||||
List<Block> blocks = event.getBlocks();
|
if (!EventUtils.shouldProcessEvent(event.getBlock(), true)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
BlockFace direction = event.getDirection();
|
BlockFace direction = event.getDirection();
|
||||||
Block futureEmptyBlock = event.getBlock().getRelative(direction); // Block that would be air after piston is finished
|
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) {
|
for (Block b : blocks) {
|
||||||
if (BlockUtils.shouldBeWatched(b.getState()) && mcMMO.getPlaceStore().isTrue(b)) {
|
if (BlockUtils.shouldBeWatched(b.getState()) && mcMMO.getPlaceStore().isTrue(b)) {
|
||||||
b.getRelative(direction).setMetadata(mcMMO.blockMetadataKey, mcMMO.metadataValue);
|
b.getRelative(direction).setMetadata(mcMMO.blockMetadataKey, mcMMO.metadataValue);
|
||||||
if (b.equals(futureEmptyBlock)) {
|
|
||||||
mcMMO.getPlaceStore().setFalse(b);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Block b : blocks) {
|
// Needed because blocks sometimes don't move when two pistons push towards each other
|
||||||
Block nextBlock = b.getRelative(direction);
|
new PistonTrackerTask(blocks, direction, futureEmptyBlock).runTaskLater(plugin, 2);
|
||||||
|
|
||||||
if (nextBlock.hasMetadata(mcMMO.blockMetadataKey)) {
|
|
||||||
mcMMO.getPlaceStore().setTrue(nextBlock);
|
|
||||||
nextBlock.removeMetadata(mcMMO.blockMetadataKey, plugin);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -89,10 +94,18 @@ public class BlockListener implements Listener {
|
|||||||
*/
|
*/
|
||||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||||
public void onBlockPistonRetract(BlockPistonRetractEvent event) {
|
public void onBlockPistonRetract(BlockPistonRetractEvent event) {
|
||||||
if (event.isSticky()) {
|
if (!EventUtils.shouldProcessEvent(event.getBlock(), false)) {
|
||||||
// Needed only because under some circumstances Minecraft doesn't move the block
|
return;
|
||||||
new StickyPistonTrackerTask(event.getDirection(), event.getBlock()).runTaskLater(plugin, 2);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!event.isSticky()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Block movedBlock = event.getRetractLocation().getBlock();
|
||||||
|
|
||||||
|
// Needed only because under some circumstances Minecraft doesn't move the block
|
||||||
|
new StickyPistonTrackerTask(event.getDirection(), event.getBlock(), movedBlock).runTaskLater(plugin, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -104,7 +117,7 @@ public class BlockListener implements Listener {
|
|||||||
public void onBlockPlace(BlockPlaceEvent event) {
|
public void onBlockPlace(BlockPlaceEvent event) {
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
|
|
||||||
if (Misc.isNPCEntity(player)) {
|
if (!UserManager.hasPlayerDataKey(player)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -115,8 +128,13 @@ public class BlockListener implements Listener {
|
|||||||
mcMMO.getPlaceStore().setTrue(blockState);
|
mcMMO.getPlaceStore().setTrue(blockState);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (BlockUtils.isMcMMOAnvil(blockState)) {
|
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
|
||||||
UserManager.getPlayer(player).getRepairManager().placedAnvilCheck(blockState.getType());
|
|
||||||
|
if (blockState.getType() == Repair.anvilMaterial && SkillType.REPAIR.getPermissions(player)) {
|
||||||
|
mcMMOPlayer.getRepairManager().placedAnvilCheck();
|
||||||
|
}
|
||||||
|
else if (blockState.getType() == Salvage.anvilMaterial && SkillType.SALVAGE.getPermissions(player)) {
|
||||||
|
mcMMOPlayer.getSalvageManager().placedAnvilCheck();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -132,19 +150,20 @@ public class BlockListener implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
BlockState blockState = event.getBlock().getState();
|
BlockState blockState = event.getBlock().getState();
|
||||||
|
Location location = blockState.getLocation();
|
||||||
|
|
||||||
if (!BlockUtils.shouldBeWatched(blockState)) {
|
if (!BlockUtils.shouldBeWatched(blockState)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ALCHEMY - Cancel any brew in progress for that BrewingStand */
|
/* ALCHEMY - Cancel any brew in progress for that BrewingStand */
|
||||||
if (blockState instanceof BrewingStand && Alchemy.brewingStandMap.containsKey(event.getBlock())) {
|
if (blockState instanceof BrewingStand && Alchemy.brewingStandMap.containsKey(location)) {
|
||||||
Alchemy.brewingStandMap.get(event.getBlock()).cancelBrew();
|
Alchemy.brewingStandMap.get(location).cancelBrew();
|
||||||
}
|
}
|
||||||
|
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
|
|
||||||
if (Misc.isNPCEntity(player) || player.getGameMode() == GameMode.CREATIVE) {
|
if (!UserManager.hasPlayerDataKey(player) || player.getGameMode() == GameMode.CREATIVE) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -176,7 +195,7 @@ public class BlockListener implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* WOOD CUTTING */
|
/* WOOD CUTTING */
|
||||||
else if (BlockUtils.isLog(blockState) && SkillType.WOODCUTTING.getPermissions(player) && !mcMMO.getPlaceStore().isTrue(blockState)) {
|
else if (BlockUtils.isLog(blockState) && ItemUtils.isAxe(heldItem) && SkillType.WOODCUTTING.getPermissions(player) && !mcMMO.getPlaceStore().isTrue(blockState)) {
|
||||||
WoodcuttingManager woodcuttingManager = mcMMOPlayer.getWoodcuttingManager();
|
WoodcuttingManager woodcuttingManager = mcMMOPlayer.getWoodcuttingManager();
|
||||||
|
|
||||||
if (woodcuttingManager.canUseTreeFeller(heldItem)) {
|
if (woodcuttingManager.canUseTreeFeller(heldItem)) {
|
||||||
@@ -214,13 +233,18 @@ public class BlockListener implements Listener {
|
|||||||
|
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
|
|
||||||
if (Misc.isNPCEntity(player) || player.getGameMode() == GameMode.CREATIVE) {
|
if (!UserManager.hasPlayerDataKey(player) || player.getGameMode() == GameMode.CREATIVE) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
BlockState blockState = event.getBlock().getState();
|
BlockState blockState = event.getBlock().getState();
|
||||||
ItemStack heldItem = player.getItemInHand();
|
ItemStack heldItem = player.getItemInHand();
|
||||||
|
|
||||||
|
if (Herbalism.isRecentlyRegrown(blockState)) {
|
||||||
|
event.setCancelled(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (ItemUtils.isSword(heldItem)) {
|
if (ItemUtils.isSword(heldItem)) {
|
||||||
HerbalismManager herbalismManager = UserManager.getPlayer(player).getHerbalismManager();
|
HerbalismManager herbalismManager = UserManager.getPlayer(player).getHerbalismManager();
|
||||||
|
|
||||||
@@ -261,7 +285,7 @@ public class BlockListener implements Listener {
|
|||||||
|
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
|
|
||||||
if (Misc.isNPCEntity(player)) {
|
if (!UserManager.hasPlayerDataKey(player)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -327,7 +351,7 @@ public class BlockListener implements Listener {
|
|||||||
|
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
|
|
||||||
if (Misc.isNPCEntity(player)) {
|
if (!UserManager.hasPlayerDataKey(player)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,12 @@
|
|||||||
package com.gmail.nossr50.listeners;
|
package com.gmail.nossr50.listeners;
|
||||||
|
|
||||||
|
import org.bukkit.Material;
|
||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.enchantments.Enchantment;
|
import org.bukkit.enchantments.Enchantment;
|
||||||
import org.bukkit.entity.AnimalTamer;
|
import org.bukkit.entity.AnimalTamer;
|
||||||
import org.bukkit.entity.Arrow;
|
import org.bukkit.entity.Arrow;
|
||||||
|
import org.bukkit.entity.Enderman;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.FallingBlock;
|
import org.bukkit.entity.FallingBlock;
|
||||||
import org.bukkit.entity.LivingEntity;
|
import org.bukkit.entity.LivingEntity;
|
||||||
@@ -34,6 +36,8 @@ import org.bukkit.inventory.ItemStack;
|
|||||||
import org.bukkit.inventory.meta.PotionMeta;
|
import org.bukkit.inventory.meta.PotionMeta;
|
||||||
import org.bukkit.metadata.FixedMetadataValue;
|
import org.bukkit.metadata.FixedMetadataValue;
|
||||||
import org.bukkit.potion.PotionEffect;
|
import org.bukkit.potion.PotionEffect;
|
||||||
|
import org.bukkit.potion.PotionEffectType;
|
||||||
|
import org.bukkit.projectiles.ProjectileSource;
|
||||||
|
|
||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.gmail.nossr50.config.AdvancedConfig;
|
import com.gmail.nossr50.config.AdvancedConfig;
|
||||||
@@ -42,6 +46,7 @@ import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
|||||||
import com.gmail.nossr50.datatypes.skills.SecondaryAbility;
|
import com.gmail.nossr50.datatypes.skills.SecondaryAbility;
|
||||||
import com.gmail.nossr50.events.fake.FakeEntityDamageByEntityEvent;
|
import com.gmail.nossr50.events.fake.FakeEntityDamageByEntityEvent;
|
||||||
import com.gmail.nossr50.events.fake.FakeEntityDamageEvent;
|
import com.gmail.nossr50.events.fake.FakeEntityDamageEvent;
|
||||||
|
import com.gmail.nossr50.events.fake.FakeEntityTameEvent;
|
||||||
import com.gmail.nossr50.party.PartyManager;
|
import com.gmail.nossr50.party.PartyManager;
|
||||||
import com.gmail.nossr50.runnables.skills.BleedTimerTask;
|
import com.gmail.nossr50.runnables.skills.BleedTimerTask;
|
||||||
import com.gmail.nossr50.skills.acrobatics.AcrobaticsManager;
|
import com.gmail.nossr50.skills.acrobatics.AcrobaticsManager;
|
||||||
@@ -51,6 +56,7 @@ import com.gmail.nossr50.skills.herbalism.Herbalism;
|
|||||||
import com.gmail.nossr50.skills.mining.MiningManager;
|
import com.gmail.nossr50.skills.mining.MiningManager;
|
||||||
import com.gmail.nossr50.skills.taming.Taming;
|
import com.gmail.nossr50.skills.taming.Taming;
|
||||||
import com.gmail.nossr50.skills.taming.TamingManager;
|
import com.gmail.nossr50.skills.taming.TamingManager;
|
||||||
|
import com.gmail.nossr50.util.BlockUtils;
|
||||||
import com.gmail.nossr50.util.Misc;
|
import com.gmail.nossr50.util.Misc;
|
||||||
import com.gmail.nossr50.util.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
import com.gmail.nossr50.util.player.UserManager;
|
import com.gmail.nossr50.util.player.UserManager;
|
||||||
@@ -79,7 +85,7 @@ public class EntityListener implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
projectile.setMetadata(mcMMO.bowForceKey, new FixedMetadataValue(plugin, Math.min(event.getForce() * AdvancedConfig.getInstance().getForceMultiplier(), 1.0)));
|
projectile.setMetadata(mcMMO.bowForceKey, new FixedMetadataValue(plugin, Math.min(event.getForce() * AdvancedConfig.getInstance().getForceMultiplier(), 1.0)));
|
||||||
projectile.setMetadata(mcMMO.arrowDistanceKey, new FixedMetadataValue(plugin, Archery.locationToString(projectile.getLocation())));
|
projectile.setMetadata(mcMMO.arrowDistanceKey, new FixedMetadataValue(plugin, projectile.getLocation()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||||
@@ -91,7 +97,7 @@ public class EntityListener implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
projectile.setMetadata(mcMMO.bowForceKey, new FixedMetadataValue(plugin, 1.0));
|
projectile.setMetadata(mcMMO.bowForceKey, new FixedMetadataValue(plugin, 1.0));
|
||||||
projectile.setMetadata(mcMMO.arrowDistanceKey, new FixedMetadataValue(plugin, Archery.locationToString(projectile.getLocation())));
|
projectile.setMetadata(mcMMO.arrowDistanceKey, new FixedMetadataValue(plugin, projectile.getLocation()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -101,21 +107,32 @@ public class EntityListener implements Listener {
|
|||||||
*/
|
*/
|
||||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||||
public void onEntityChangeBlock(EntityChangeBlockEvent event) {
|
public void onEntityChangeBlock(EntityChangeBlockEvent event) {
|
||||||
Entity entity = event.getEntity();
|
Block block = event.getBlock();
|
||||||
|
|
||||||
if (!(entity instanceof FallingBlock)) {
|
if (!BlockUtils.shouldBeWatched(block.getState())) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Block block = event.getBlock();
|
Entity entity = event.getEntity();
|
||||||
boolean isTracked = entity.hasMetadata(mcMMO.entityMetadataKey);
|
|
||||||
|
|
||||||
if (mcMMO.getPlaceStore().isTrue(block) && !isTracked) {
|
if (entity instanceof FallingBlock || entity instanceof Enderman) {
|
||||||
mcMMO.getPlaceStore().setFalse(block);
|
boolean isTracked = entity.hasMetadata(mcMMO.entityMetadataKey);
|
||||||
entity.setMetadata(mcMMO.entityMetadataKey, mcMMO.metadataValue);
|
|
||||||
|
if (mcMMO.getPlaceStore().isTrue(block) && !isTracked) {
|
||||||
|
mcMMO.getPlaceStore().setFalse(block);
|
||||||
|
entity.setMetadata(mcMMO.entityMetadataKey, mcMMO.metadataValue);
|
||||||
|
}
|
||||||
|
else if (isTracked) {
|
||||||
|
mcMMO.getPlaceStore().setTrue(block);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (isTracked) {
|
else if ((block.getType() == Material.REDSTONE_ORE || block.getType() == Material.GLOWING_REDSTONE_ORE) && (event.getTo() == Material.REDSTONE_ORE || event.getTo() == Material.GLOWING_REDSTONE_ORE)) {
|
||||||
mcMMO.getPlaceStore().setTrue(block);
|
return;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (mcMMO.getPlaceStore().isTrue(block)) {
|
||||||
|
mcMMO.getPlaceStore().setFalse(block);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -130,7 +147,7 @@ public class EntityListener implements Listener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
double damage = event.getDamage();
|
double damage = event.getFinalDamage();
|
||||||
|
|
||||||
if (damage <= 0) {
|
if (damage <= 0) {
|
||||||
return;
|
return;
|
||||||
@@ -160,7 +177,11 @@ public class EntityListener implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (attacker instanceof Projectile) {
|
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) {
|
else if (attacker instanceof Tameable) {
|
||||||
AnimalTamer animalTamer = ((Tameable) attacker).getOwner();
|
AnimalTamer animalTamer = ((Tameable) attacker).getOwner();
|
||||||
@@ -174,6 +195,10 @@ public class EntityListener implements Listener {
|
|||||||
Player defendingPlayer = (Player) defender;
|
Player defendingPlayer = (Player) defender;
|
||||||
Player attackingPlayer = (Player) attacker;
|
Player attackingPlayer = (Player) attacker;
|
||||||
|
|
||||||
|
if (!UserManager.hasPlayerDataKey(defendingPlayer) || !UserManager.hasPlayerDataKey(attackingPlayer)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// We want to make sure we're not gaining XP or applying abilities when we hit ourselves
|
// We want to make sure we're not gaining XP or applying abilities when we hit ourselves
|
||||||
if (defendingPlayer.equals(attackingPlayer)) {
|
if (defendingPlayer.equals(attackingPlayer)) {
|
||||||
return;
|
return;
|
||||||
@@ -186,6 +211,7 @@ public class EntityListener implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
CombatUtils.processCombatAttack(event, attacker, target);
|
CombatUtils.processCombatAttack(event, attacker, target);
|
||||||
|
CombatUtils.handleHealthbars(attacker, target, event.getFinalDamage());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -199,7 +225,7 @@ public class EntityListener implements Listener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
double damage = event.getDamage();
|
double damage = event.getFinalDamage();
|
||||||
|
|
||||||
if (damage <= 0) {
|
if (damage <= 0) {
|
||||||
return;
|
return;
|
||||||
@@ -226,6 +252,11 @@ public class EntityListener implements Listener {
|
|||||||
|
|
||||||
if (livingEntity instanceof Player) {
|
if (livingEntity instanceof Player) {
|
||||||
Player player = (Player) entity;
|
Player player = (Player) entity;
|
||||||
|
|
||||||
|
if (!UserManager.hasPlayerDataKey(player)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
|
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
|
||||||
|
|
||||||
/* Check for invincibility */
|
/* Check for invincibility */
|
||||||
@@ -236,7 +267,7 @@ public class EntityListener implements Listener {
|
|||||||
|
|
||||||
switch (cause) {
|
switch (cause) {
|
||||||
case FALL:
|
case FALL:
|
||||||
if (Config.getInstance().getPreventXPAfterTeleport() && SkillUtils.calculateTimeLeft((long) mcMMOPlayer.getTeleportATS() * Misc.TIME_CONVERSION_FACTOR, 5, player) > 0) {
|
if (!SkillUtils.cooldownExpired((long) mcMMOPlayer.getTeleportATS(), Config.getInstance().getXPAfterTeleportCooldown())) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -245,7 +276,7 @@ public class EntityListener implements Listener {
|
|||||||
if (acrobaticsManager.canRoll()) {
|
if (acrobaticsManager.canRoll()) {
|
||||||
event.setDamage(acrobaticsManager.rollCheck(event.getDamage()));
|
event.setDamage(acrobaticsManager.rollCheck(event.getDamage()));
|
||||||
|
|
||||||
if (event.getDamage() == 0) {
|
if (event.getFinalDamage() == 0) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -258,7 +289,7 @@ public class EntityListener implements Listener {
|
|||||||
if (miningManager.canUseDemolitionsExpertise()) {
|
if (miningManager.canUseDemolitionsExpertise()) {
|
||||||
event.setDamage(miningManager.processDemolitionsExpertise(event.getDamage()));
|
event.setDamage(miningManager.processDemolitionsExpertise(event.getDamage()));
|
||||||
|
|
||||||
if (event.getDamage() == 0) {
|
if (event.getFinalDamage() == 0) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -269,7 +300,7 @@ public class EntityListener implements Listener {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event.getDamage() >= 1) {
|
if (event.getFinalDamage() >= 1) {
|
||||||
mcMMOPlayer.actualizeRecentlyHurt();
|
mcMMOPlayer.actualizeRecentlyHurt();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -303,7 +334,7 @@ public class EntityListener implements Listener {
|
|||||||
if (tamingManager.canUseThickFur()) {
|
if (tamingManager.canUseThickFur()) {
|
||||||
event.setDamage(Taming.processThickFur(wolf, event.getDamage()));
|
event.setDamage(Taming.processThickFur(wolf, event.getDamage()));
|
||||||
|
|
||||||
if (event.getDamage() == 0) {
|
if (event.getFinalDamage() == 0) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -329,7 +360,7 @@ public class EntityListener implements Listener {
|
|||||||
if (tamingManager.canUseShockProof()) {
|
if (tamingManager.canUseShockProof()) {
|
||||||
event.setDamage(Taming.processShockProof(wolf, event.getDamage()));
|
event.setDamage(Taming.processShockProof(wolf, event.getDamage()));
|
||||||
|
|
||||||
if (event.getDamage() == 0) {
|
if (event.getFinalDamage() == 0) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -424,7 +455,7 @@ public class EntityListener implements Listener {
|
|||||||
// We can make this assumption because we (should) be the only ones using this exact metadata
|
// We can make this assumption because we (should) be the only ones using this exact metadata
|
||||||
Player player = plugin.getServer().getPlayerExact(entity.getMetadata(mcMMO.tntMetadataKey).get(0).asString());
|
Player player = plugin.getServer().getPlayerExact(entity.getMetadata(mcMMO.tntMetadataKey).get(0).asString());
|
||||||
|
|
||||||
if (Misc.isNPCEntity(player)) {
|
if (!UserManager.hasPlayerDataKey(player)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -451,7 +482,7 @@ public class EntityListener implements Listener {
|
|||||||
// We can make this assumption because we (should) be the only ones using this exact metadata
|
// We can make this assumption because we (should) be the only ones using this exact metadata
|
||||||
Player player = plugin.getServer().getPlayerExact(entity.getMetadata(mcMMO.tntMetadataKey).get(0).asString());
|
Player player = plugin.getServer().getPlayerExact(entity.getMetadata(mcMMO.tntMetadataKey).get(0).asString());
|
||||||
|
|
||||||
if (Misc.isNPCEntity(player)) {
|
if (!UserManager.hasPlayerDataKey(player)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -494,7 +525,7 @@ public class EntityListener implements Listener {
|
|||||||
|
|
||||||
Player player = (Player) entity;
|
Player player = (Player) entity;
|
||||||
|
|
||||||
if (Misc.isNPCEntity(player)) {
|
if (!UserManager.hasPlayerDataKey(player)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -557,10 +588,14 @@ public class EntityListener implements Listener {
|
|||||||
*/
|
*/
|
||||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||||
public void onEntityTame(EntityTameEvent event) {
|
public void onEntityTame(EntityTameEvent event) {
|
||||||
|
if (event instanceof FakeEntityTameEvent) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
Player player = (Player) event.getOwner();
|
Player player = (Player) event.getOwner();
|
||||||
LivingEntity entity = event.getEntity();
|
LivingEntity entity = event.getEntity();
|
||||||
|
|
||||||
if (Misc.isNPCEntity(player) || Misc.isNPCEntity(entity) || entity.hasMetadata(mcMMO.entityMetadataKey)) {
|
if (!UserManager.hasPlayerDataKey(player) || Misc.isNPCEntity(entity) || entity.hasMetadata(mcMMO.entityMetadataKey)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -603,9 +638,8 @@ public class EntityListener implements Listener {
|
|||||||
*/
|
*/
|
||||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||||
public void onPotionSplash(PotionSplashEvent event) {
|
public void onPotionSplash(PotionSplashEvent event) {
|
||||||
for (PotionEffect effect : ((PotionMeta) event.getEntity().getItem().getItemMeta()).getCustomEffects()) {
|
for (PotionEffect effect : ((PotionMeta) event.getPotion().getItem().getItemMeta()).getCustomEffects()) {
|
||||||
// (effect.getType() != PotionEffectType.SATURATION) is seemingly broken, so we use deprecated method for now.
|
if (!effect.getType().equals(PotionEffectType.SATURATION)) {
|
||||||
if (effect.getType().getId() != 23) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import org.bukkit.entity.Player;
|
|||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.event.inventory.ClickType;
|
||||||
import org.bukkit.event.inventory.CraftItemEvent;
|
import org.bukkit.event.inventory.CraftItemEvent;
|
||||||
import org.bukkit.event.inventory.FurnaceBurnEvent;
|
import org.bukkit.event.inventory.FurnaceBurnEvent;
|
||||||
import org.bukkit.event.inventory.FurnaceExtractEvent;
|
import org.bukkit.event.inventory.FurnaceExtractEvent;
|
||||||
@@ -22,8 +23,10 @@ import org.bukkit.event.inventory.InventoryDragEvent;
|
|||||||
import org.bukkit.event.inventory.InventoryMoveItemEvent;
|
import org.bukkit.event.inventory.InventoryMoveItemEvent;
|
||||||
import org.bukkit.event.inventory.InventoryOpenEvent;
|
import org.bukkit.event.inventory.InventoryOpenEvent;
|
||||||
import org.bukkit.event.inventory.InventoryType;
|
import org.bukkit.event.inventory.InventoryType;
|
||||||
|
import org.bukkit.inventory.BrewerInventory;
|
||||||
import org.bukkit.inventory.FurnaceInventory;
|
import org.bukkit.inventory.FurnaceInventory;
|
||||||
import org.bukkit.inventory.Inventory;
|
import org.bukkit.inventory.Inventory;
|
||||||
|
import org.bukkit.inventory.InventoryHolder;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.metadata.MetadataValue;
|
import org.bukkit.metadata.MetadataValue;
|
||||||
|
|
||||||
@@ -31,10 +34,10 @@ import com.gmail.nossr50.mcMMO;
|
|||||||
import com.gmail.nossr50.config.Config;
|
import com.gmail.nossr50.config.Config;
|
||||||
import com.gmail.nossr50.datatypes.skills.SecondaryAbility;
|
import com.gmail.nossr50.datatypes.skills.SecondaryAbility;
|
||||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||||
import com.gmail.nossr50.runnables.PlayerUpdateInventoryTask;
|
import com.gmail.nossr50.runnables.player.PlayerUpdateInventoryTask;
|
||||||
|
import com.gmail.nossr50.skills.alchemy.Alchemy;
|
||||||
import com.gmail.nossr50.skills.alchemy.AlchemyPotionBrewer;
|
import com.gmail.nossr50.skills.alchemy.AlchemyPotionBrewer;
|
||||||
import com.gmail.nossr50.util.ItemUtils;
|
import com.gmail.nossr50.util.ItemUtils;
|
||||||
import com.gmail.nossr50.util.Misc;
|
|
||||||
import com.gmail.nossr50.util.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
import com.gmail.nossr50.util.player.UserManager;
|
import com.gmail.nossr50.util.player.UserManager;
|
||||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||||
@@ -48,7 +51,7 @@ public class InventoryListener implements Listener {
|
|||||||
|
|
||||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||||
public void onInventoryOpen(InventoryOpenEvent event) {
|
public void onInventoryOpen(InventoryOpenEvent event) {
|
||||||
Block furnaceBlock = processInventoryOpenorCloseEvent(event.getInventory());
|
Block furnaceBlock = processInventoryOpenOrCloseEvent(event.getInventory());
|
||||||
|
|
||||||
if (furnaceBlock == null || furnaceBlock.hasMetadata(mcMMO.furnaceMetadataKey)) {
|
if (furnaceBlock == null || furnaceBlock.hasMetadata(mcMMO.furnaceMetadataKey)) {
|
||||||
return;
|
return;
|
||||||
@@ -56,7 +59,7 @@ public class InventoryListener implements Listener {
|
|||||||
|
|
||||||
HumanEntity player = event.getPlayer();
|
HumanEntity player = event.getPlayer();
|
||||||
|
|
||||||
if (Misc.isNPCEntity(player)) {
|
if (!UserManager.hasPlayerDataKey(player)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -65,7 +68,7 @@ public class InventoryListener implements Listener {
|
|||||||
|
|
||||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||||
public void onInventoryClose(InventoryCloseEvent event) {
|
public void onInventoryClose(InventoryCloseEvent event) {
|
||||||
Block furnaceBlock = processInventoryOpenorCloseEvent(event.getInventory());
|
Block furnaceBlock = processInventoryOpenOrCloseEvent(event.getInventory());
|
||||||
|
|
||||||
if (furnaceBlock == null || furnaceBlock.hasMetadata(mcMMO.furnaceMetadataKey)) {
|
if (furnaceBlock == null || furnaceBlock.hasMetadata(mcMMO.furnaceMetadataKey)) {
|
||||||
return;
|
return;
|
||||||
@@ -73,7 +76,7 @@ public class InventoryListener implements Listener {
|
|||||||
|
|
||||||
HumanEntity player = event.getPlayer();
|
HumanEntity player = event.getPlayer();
|
||||||
|
|
||||||
if (Misc.isNPCEntity(player)) {
|
if (!UserManager.hasPlayerDataKey(player)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -92,7 +95,7 @@ public class InventoryListener implements Listener {
|
|||||||
|
|
||||||
Player player = getPlayerFromFurnace(furnaceBlock);
|
Player player = getPlayerFromFurnace(furnaceBlock);
|
||||||
|
|
||||||
if (Misc.isNPCEntity(player) || !Permissions.secondaryAbilityEnabled(player, SecondaryAbility.FUEL_EFFICIENCY)) {
|
if (!UserManager.hasPlayerDataKey(player) || !Permissions.secondaryAbilityEnabled(player, SecondaryAbility.FUEL_EFFICIENCY)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -110,7 +113,7 @@ public class InventoryListener implements Listener {
|
|||||||
|
|
||||||
Player player = getPlayerFromFurnace(furnaceBlock);
|
Player player = getPlayerFromFurnace(furnaceBlock);
|
||||||
|
|
||||||
if (Misc.isNPCEntity(player) || !SkillType.SMELTING.getPermissions(player)) {
|
if (!UserManager.hasPlayerDataKey(player) || !SkillType.SMELTING.getPermissions(player)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -129,7 +132,7 @@ public class InventoryListener implements Listener {
|
|||||||
|
|
||||||
Player player = getPlayerFromFurnace(furnaceBlock);
|
Player player = getPlayerFromFurnace(furnaceBlock);
|
||||||
|
|
||||||
if (Misc.isNPCEntity(player) || !Permissions.vanillaXpBoost(player, SkillType.SMELTING)) {
|
if (!UserManager.hasPlayerDataKey(player) || !Permissions.vanillaXpBoost(player, SkillType.SMELTING)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -138,43 +141,172 @@ public class InventoryListener implements Listener {
|
|||||||
|
|
||||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||||
public void onInventoryClickEventNormal(InventoryClickEvent event) {
|
public void onInventoryClickEventNormal(InventoryClickEvent event) {
|
||||||
if (event.getInventory().getType() != InventoryType.BREWING || !(event.getInventory().getHolder() instanceof BrewingStand)) {
|
Inventory inventory = event.getInventory();
|
||||||
|
|
||||||
|
if (!(inventory instanceof BrewerInventory)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(event.getWhoClicked() instanceof Player) || Misc.isNPCEntity(event.getWhoClicked()) || !Permissions.concoctions(event.getWhoClicked())) {
|
InventoryHolder holder = inventory.getHolder();
|
||||||
|
|
||||||
|
if (!(holder instanceof BrewingStand)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
AlchemyPotionBrewer.handleInventoryClick(event);
|
HumanEntity whoClicked = event.getWhoClicked();
|
||||||
|
|
||||||
|
if (!UserManager.hasPlayerDataKey(event.getWhoClicked()) || !Permissions.secondaryAbilityEnabled(whoClicked, SecondaryAbility.CONCOCTIONS)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Player player = (Player) whoClicked;
|
||||||
|
BrewingStand stand = (BrewingStand) holder;
|
||||||
|
ItemStack clicked = event.getCurrentItem();
|
||||||
|
ItemStack cursor = event.getCursor();
|
||||||
|
|
||||||
|
if ((clicked != null && clicked.getType() == Material.POTION) || (cursor != null && cursor.getType() == Material.POTION)) {
|
||||||
|
AlchemyPotionBrewer.scheduleCheck(player, stand);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ClickType click = event.getClick();
|
||||||
|
InventoryType.SlotType slot = event.getSlotType();
|
||||||
|
|
||||||
|
if (click.isShiftClick()) {
|
||||||
|
switch (slot) {
|
||||||
|
case FUEL:
|
||||||
|
AlchemyPotionBrewer.scheduleCheck(player, stand);
|
||||||
|
return;
|
||||||
|
case CONTAINER:
|
||||||
|
case QUICKBAR:
|
||||||
|
if (!AlchemyPotionBrewer.isValidIngredient(player, clicked)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!AlchemyPotionBrewer.transferItems(event.getView(), event.getRawSlot(), click)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
event.setCancelled(true);
|
||||||
|
AlchemyPotionBrewer.scheduleUpdate(inventory);
|
||||||
|
AlchemyPotionBrewer.scheduleCheck(player, stand);
|
||||||
|
return;
|
||||||
|
default:
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (slot == InventoryType.SlotType.FUEL) {
|
||||||
|
boolean emptyClicked = AlchemyPotionBrewer.isEmpty(clicked);
|
||||||
|
|
||||||
|
if (AlchemyPotionBrewer.isEmpty(cursor)) {
|
||||||
|
if (emptyClicked && click == ClickType.NUMBER_KEY) {
|
||||||
|
AlchemyPotionBrewer.scheduleCheck(player, stand);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
AlchemyPotionBrewer.scheduleCheck(player, stand);
|
||||||
|
}
|
||||||
|
else if (emptyClicked) {
|
||||||
|
if (AlchemyPotionBrewer.isValidIngredient(player, cursor)) {
|
||||||
|
int amount = cursor.getAmount();
|
||||||
|
|
||||||
|
if (click == ClickType.LEFT || (click == ClickType.RIGHT && amount == 1)) {
|
||||||
|
event.setCancelled(true);
|
||||||
|
event.setCurrentItem(cursor.clone());
|
||||||
|
event.setCursor(null);
|
||||||
|
|
||||||
|
AlchemyPotionBrewer.scheduleUpdate(inventory);
|
||||||
|
AlchemyPotionBrewer.scheduleCheck(player, stand);
|
||||||
|
}
|
||||||
|
else if (click == ClickType.RIGHT) {
|
||||||
|
event.setCancelled(true);
|
||||||
|
|
||||||
|
ItemStack one = cursor.clone();
|
||||||
|
one.setAmount(1);
|
||||||
|
|
||||||
|
ItemStack rest = cursor.clone();
|
||||||
|
rest.setAmount(amount - 1);
|
||||||
|
|
||||||
|
event.setCurrentItem(one);
|
||||||
|
event.setCursor(rest);
|
||||||
|
|
||||||
|
AlchemyPotionBrewer.scheduleUpdate(inventory);
|
||||||
|
AlchemyPotionBrewer.scheduleCheck(player, stand);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||||
public void onInventoryDragEvent(InventoryDragEvent event) {
|
public void onInventoryDragEvent(InventoryDragEvent event) {
|
||||||
if (event.getInventory().getType() != InventoryType.BREWING || !(event.getInventory().getHolder() instanceof BrewingStand)) {
|
Inventory inventory = event.getInventory();
|
||||||
|
|
||||||
|
if (!(inventory instanceof BrewerInventory)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(event.getWhoClicked() instanceof Player) || Misc.isNPCEntity(event.getWhoClicked()) || !Permissions.concoctions(event.getWhoClicked())) {
|
InventoryHolder holder = inventory.getHolder();
|
||||||
|
|
||||||
|
if (!(holder instanceof BrewingStand)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
AlchemyPotionBrewer.handleInventoryDrag(event);
|
HumanEntity whoClicked = event.getWhoClicked();
|
||||||
|
|
||||||
|
if (!UserManager.hasPlayerDataKey(event.getWhoClicked()) || !Permissions.secondaryAbilityEnabled(whoClicked, SecondaryAbility.CONCOCTIONS)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!event.getInventorySlots().contains(Alchemy.INGREDIENT_SLOT)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ItemStack cursor = event.getCursor();
|
||||||
|
ItemStack ingredient = ((BrewerInventory) inventory).getIngredient();
|
||||||
|
|
||||||
|
if (AlchemyPotionBrewer.isEmpty(ingredient) || ingredient.isSimilar(cursor)) {
|
||||||
|
Player player = (Player) whoClicked;
|
||||||
|
|
||||||
|
if (AlchemyPotionBrewer.isValidIngredient(player, cursor)) {
|
||||||
|
// Not handled: dragging custom ingredients over ingredient slot (does not trigger any event)
|
||||||
|
AlchemyPotionBrewer.scheduleCheck(player, (BrewingStand) holder);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
event.setCancelled(true);
|
||||||
|
AlchemyPotionBrewer.scheduleUpdate(inventory);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||||
public void onInventoryMoveItemEvent(InventoryMoveItemEvent event) {
|
public void onInventoryMoveItemEvent(InventoryMoveItemEvent event) {
|
||||||
if (event.getDestination().getType() != InventoryType.BREWING || !(event.getDestination().getHolder() instanceof BrewingStand)) {
|
Inventory inventory = event.getDestination();
|
||||||
|
|
||||||
|
if (!(inventory instanceof BrewerInventory)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Config.getInstance().getPreventHopperTransfer() && event.getItem() != null && event.getItem().getType() != Material.POTION) {
|
InventoryHolder holder = inventory.getHolder();
|
||||||
|
|
||||||
|
if (!(holder instanceof BrewingStand)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ItemStack item = event.getItem();
|
||||||
|
|
||||||
|
if (Config.getInstance().getPreventHopperTransferIngredients() && item.getType() != Material.POTION) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Config.getInstance().getEnabledForHoppers()) {
|
if (Config.getInstance().getPreventHopperTransferBottles() && item.getType() == Material.POTION) {
|
||||||
AlchemyPotionBrewer.handleInventoryMoveItem(event);
|
event.setCancelled(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Config.getInstance().getEnabledForHoppers() && AlchemyPotionBrewer.isValidIngredient(null, item)) {
|
||||||
|
AlchemyPotionBrewer.scheduleCheck(null, (BrewingStand) holder);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -187,7 +319,7 @@ public class InventoryListener implements Listener {
|
|||||||
public void onCraftItem(CraftItemEvent event) {
|
public void onCraftItem(CraftItemEvent event) {
|
||||||
final HumanEntity whoClicked = event.getWhoClicked();
|
final HumanEntity whoClicked = event.getWhoClicked();
|
||||||
|
|
||||||
if (Misc.isNPCEntity(whoClicked) || !(whoClicked instanceof Player)) {
|
if (!whoClicked.hasMetadata(mcMMO.playerDataKey)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -200,7 +332,7 @@ public class InventoryListener implements Listener {
|
|||||||
new PlayerUpdateInventoryTask((Player) whoClicked).runTaskLater(plugin, 0);
|
new PlayerUpdateInventoryTask((Player) whoClicked).runTaskLater(plugin, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Block processInventoryOpenorCloseEvent(Inventory inventory) {
|
private Block processInventoryOpenOrCloseEvent(Inventory inventory) {
|
||||||
if (!(inventory instanceof FurnaceInventory)) {
|
if (!(inventory instanceof FurnaceInventory)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import org.bukkit.Sound;
|
|||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.block.BlockState;
|
import org.bukkit.block.BlockState;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
|
import org.bukkit.entity.EntityType;
|
||||||
import org.bukkit.entity.Item;
|
import org.bukkit.entity.Item;
|
||||||
import org.bukkit.entity.LivingEntity;
|
import org.bukkit.entity.LivingEntity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@@ -23,6 +24,7 @@ import org.bukkit.event.player.PlayerJoinEvent;
|
|||||||
import org.bukkit.event.player.PlayerPickupItemEvent;
|
import org.bukkit.event.player.PlayerPickupItemEvent;
|
||||||
import org.bukkit.event.player.PlayerQuitEvent;
|
import org.bukkit.event.player.PlayerQuitEvent;
|
||||||
import org.bukkit.event.player.PlayerRespawnEvent;
|
import org.bukkit.event.player.PlayerRespawnEvent;
|
||||||
|
import org.bukkit.event.player.PlayerStatisticIncrementEvent;
|
||||||
import org.bukkit.event.player.PlayerTeleportEvent;
|
import org.bukkit.event.player.PlayerTeleportEvent;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
@@ -36,16 +38,18 @@ import com.gmail.nossr50.datatypes.chat.ChatMode;
|
|||||||
import com.gmail.nossr50.datatypes.party.Party;
|
import com.gmail.nossr50.datatypes.party.Party;
|
||||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||||
import com.gmail.nossr50.datatypes.skills.AbilityType;
|
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.SkillType;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.party.ShareHandler;
|
import com.gmail.nossr50.party.ShareHandler;
|
||||||
|
import com.gmail.nossr50.runnables.commands.McScoreboardKeepTask;
|
||||||
import com.gmail.nossr50.runnables.skills.BleedTimerTask;
|
import com.gmail.nossr50.runnables.skills.BleedTimerTask;
|
||||||
import com.gmail.nossr50.skills.fishing.FishingManager;
|
import com.gmail.nossr50.skills.fishing.FishingManager;
|
||||||
import com.gmail.nossr50.skills.herbalism.HerbalismManager;
|
import com.gmail.nossr50.skills.herbalism.HerbalismManager;
|
||||||
import com.gmail.nossr50.skills.mining.MiningManager;
|
import com.gmail.nossr50.skills.mining.MiningManager;
|
||||||
import com.gmail.nossr50.skills.repair.Repair;
|
import com.gmail.nossr50.skills.repair.Repair;
|
||||||
import com.gmail.nossr50.skills.repair.RepairManager;
|
import com.gmail.nossr50.skills.repair.RepairManager;
|
||||||
|
import com.gmail.nossr50.skills.salvage.Salvage;
|
||||||
|
import com.gmail.nossr50.skills.salvage.SalvageManager;
|
||||||
import com.gmail.nossr50.skills.taming.TamingManager;
|
import com.gmail.nossr50.skills.taming.TamingManager;
|
||||||
import com.gmail.nossr50.skills.unarmed.Unarmed;
|
import com.gmail.nossr50.skills.unarmed.Unarmed;
|
||||||
import com.gmail.nossr50.util.BlockUtils;
|
import com.gmail.nossr50.util.BlockUtils;
|
||||||
@@ -58,6 +62,7 @@ import com.gmail.nossr50.util.MobHealthbarUtils;
|
|||||||
import com.gmail.nossr50.util.Motd;
|
import com.gmail.nossr50.util.Motd;
|
||||||
import com.gmail.nossr50.util.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
import com.gmail.nossr50.util.player.UserManager;
|
import com.gmail.nossr50.util.player.UserManager;
|
||||||
|
import com.gmail.nossr50.util.scoreboards.ScoreboardManager;
|
||||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||||
|
|
||||||
public class PlayerListener implements Listener {
|
public class PlayerListener implements Listener {
|
||||||
@@ -80,7 +85,7 @@ public class PlayerListener implements Listener {
|
|||||||
public void onPlayerTeleport(PlayerTeleportEvent event) {
|
public void onPlayerTeleport(PlayerTeleportEvent event) {
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
|
|
||||||
if (Misc.isNPCEntity(player) || !Config.getInstance().getPreventXPAfterTeleport() || event.getFrom().equals(event.getTo())) {
|
if (!UserManager.hasPlayerDataKey(player) || Config.getInstance().getXPAfterTeleportCooldown() <= 0 || event.getFrom().equals(event.getTo())) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -129,7 +134,7 @@ public class PlayerListener implements Listener {
|
|||||||
|
|
||||||
Player killedPlayer = event.getEntity();
|
Player killedPlayer = event.getEntity();
|
||||||
|
|
||||||
if (Misc.isNPCEntity(killedPlayer) || Permissions.hardcoreBypass(killedPlayer)) {
|
if (!killedPlayer.hasMetadata(mcMMO.playerDataKey) || Permissions.hardcoreBypass(killedPlayer)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -164,7 +169,7 @@ public class PlayerListener implements Listener {
|
|||||||
public void onPlayerWorldChange(PlayerChangedWorldEvent event) {
|
public void onPlayerWorldChange(PlayerChangedWorldEvent event) {
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
|
|
||||||
if (Misc.isNPCEntity(player)) {
|
if (!UserManager.hasPlayerDataKey(player)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -207,7 +212,7 @@ public class PlayerListener implements Listener {
|
|||||||
public void onPlayerFishHighest(PlayerFishEvent event) {
|
public void onPlayerFishHighest(PlayerFishEvent event) {
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
|
|
||||||
if (Misc.isNPCEntity(player) || !SkillType.FISHING.getPermissions(player)) {
|
if (!UserManager.hasPlayerDataKey(player) || !SkillType.FISHING.getPermissions(player)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -221,6 +226,13 @@ public class PlayerListener implements Listener {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
case CAUGHT_FISH:
|
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)) {
|
if (Permissions.vanillaXpBoost(player, SkillType.FISHING)) {
|
||||||
event.setExpToDrop(fishingManager.handleVanillaXpBoost(event.getExpToDrop()));
|
event.setExpToDrop(fishingManager.handleVanillaXpBoost(event.getExpToDrop()));
|
||||||
}
|
}
|
||||||
@@ -252,7 +264,7 @@ public class PlayerListener implements Listener {
|
|||||||
public void onPlayerFishMonitor(PlayerFishEvent event) {
|
public void onPlayerFishMonitor(PlayerFishEvent event) {
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
|
|
||||||
if (Misc.isNPCEntity(player) || !SkillType.FISHING.getPermissions(player)) {
|
if (!UserManager.hasPlayerDataKey(player) || !SkillType.FISHING.getPermissions(player)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -293,7 +305,7 @@ public class PlayerListener implements Listener {
|
|||||||
public void onPlayerPickupItem(PlayerPickupItemEvent event) {
|
public void onPlayerPickupItem(PlayerPickupItemEvent event) {
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
|
|
||||||
if (Misc.isNPCEntity(player)) {
|
if (!UserManager.hasPlayerDataKey(player)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -303,7 +315,7 @@ public class PlayerListener implements Listener {
|
|||||||
ItemStack dropStack = drop.getItemStack();
|
ItemStack dropStack = drop.getItemStack();
|
||||||
|
|
||||||
if (drop.hasMetadata(mcMMO.disarmedItemKey)) {
|
if (drop.hasMetadata(mcMMO.disarmedItemKey)) {
|
||||||
if (!player.getName().equals(drop.getMetadata(mcMMO.disarmedItemKey).get(0).value())) {
|
if (!player.getName().equals(drop.getMetadata(mcMMO.disarmedItemKey).get(0).asString())) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -343,7 +355,7 @@ public class PlayerListener implements Listener {
|
|||||||
public void onPlayerQuit(PlayerQuitEvent event) {
|
public void onPlayerQuit(PlayerQuitEvent event) {
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
|
|
||||||
if (Misc.isNPCEntity(player)) {
|
if (!UserManager.hasPlayerDataKey(player)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -351,8 +363,9 @@ public class PlayerListener implements Listener {
|
|||||||
|
|
||||||
mcMMOPlayer.resetAbilityMode();
|
mcMMOPlayer.resetAbilityMode();
|
||||||
BleedTimerTask.bleedOut(player);
|
BleedTimerTask.bleedOut(player);
|
||||||
mcMMOPlayer.getProfile().save();
|
mcMMOPlayer.getProfile().scheduleAsyncSave();
|
||||||
UserManager.remove(player.getName());
|
UserManager.remove(player);
|
||||||
|
ScoreboardManager.teardownPlayer(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -372,7 +385,9 @@ public class PlayerListener implements Listener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
UserManager.addUser(player).actualizeRespawnATS();
|
McMMOPlayer mcMMOPlayer = UserManager.addUser(player);
|
||||||
|
mcMMOPlayer.actualizeRespawnATS();
|
||||||
|
ScoreboardManager.setupPlayer(player);
|
||||||
|
|
||||||
if (Config.getInstance().getMOTDEnabled() && Permissions.motd(player)) {
|
if (Config.getInstance().getMOTDEnabled() && Permissions.motd(player)) {
|
||||||
Motd.displayAll(player);
|
Motd.displayAll(player);
|
||||||
@@ -386,6 +401,11 @@ public class PlayerListener implements Listener {
|
|||||||
player.sendMessage(LocaleLoader.getString("UpdateChecker.Outdated"));
|
player.sendMessage(LocaleLoader.getString("UpdateChecker.Outdated"));
|
||||||
player.sendMessage(LocaleLoader.getString("UpdateChecker.NewAvailable"));
|
player.sendMessage(LocaleLoader.getString("UpdateChecker.NewAvailable"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (Config.getInstance().getShowStatsAfterLogin()) {
|
||||||
|
ScoreboardManager.enablePlayerStatsScoreboard(player);
|
||||||
|
new McScoreboardKeepTask(player).runTaskLater(mcMMO.p, 1 * Misc.TICK_CONVERSION_FACTOR);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -401,7 +421,7 @@ public class PlayerListener implements Listener {
|
|||||||
public void onPlayerRespawn(PlayerRespawnEvent event) {
|
public void onPlayerRespawn(PlayerRespawnEvent event) {
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
|
|
||||||
if (Misc.isNPCEntity(player)) {
|
if (!UserManager.hasPlayerDataKey(player)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -417,7 +437,7 @@ public class PlayerListener implements Listener {
|
|||||||
public void onPlayerInteractLowest(PlayerInteractEvent event) {
|
public void onPlayerInteractLowest(PlayerInteractEvent event) {
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
|
|
||||||
if (Misc.isNPCEntity(player) || player.getGameMode() == GameMode.CREATIVE) {
|
if (!UserManager.hasPlayerDataKey(player) || player.getGameMode() == GameMode.CREATIVE) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -432,24 +452,24 @@ public class PlayerListener implements Listener {
|
|||||||
|
|
||||||
if (!Config.getInstance().getAbilitiesOnlyActivateWhenSneaking() || player.isSneaking()) {
|
if (!Config.getInstance().getAbilitiesOnlyActivateWhenSneaking() || player.isSneaking()) {
|
||||||
/* REPAIR CHECKS */
|
/* REPAIR CHECKS */
|
||||||
if (type == Repair.repairAnvilMaterial && SkillType.REPAIR.getPermissions(player) && mcMMO.getRepairableManager().isRepairable(heldItem)) {
|
if (type == Repair.anvilMaterial && SkillType.REPAIR.getPermissions(player) && mcMMO.getRepairableManager().isRepairable(heldItem)) {
|
||||||
RepairManager repairManager = mcMMOPlayer.getRepairManager();
|
RepairManager repairManager = mcMMOPlayer.getRepairManager();
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
|
|
||||||
// Make sure the player knows what he's doing when trying to repair an enchanted item
|
// Make sure the player knows what he's doing when trying to repair an enchanted item
|
||||||
if (!(heldItem.getEnchantments().size() > 0) || repairManager.checkConfirmation(type, true)) {
|
if (!(heldItem.getEnchantments().size() > 0) || repairManager.checkConfirmation(true)) {
|
||||||
repairManager.handleRepair(heldItem);
|
repairManager.handleRepair(heldItem);
|
||||||
player.updateInventory();
|
player.updateInventory();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* SALVAGE CHECKS */
|
/* SALVAGE CHECKS */
|
||||||
else if (type == Repair.salvageAnvilMaterial && Permissions.secondaryAbilityEnabled(player, SecondaryAbility.SALVAGE) && Repair.isSalvageable(heldItem)) {
|
else if (type == Salvage.anvilMaterial && SkillType.SALVAGE.getPermissions(player) && mcMMO.getSalvageableManager().isSalvageable(heldItem)) {
|
||||||
RepairManager repairManager = mcMMOPlayer.getRepairManager();
|
SalvageManager salvageManager = UserManager.getPlayer(player).getSalvageManager();
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
|
|
||||||
// Make sure the player knows what he's doing when trying to salvage an enchanted item
|
// Make sure the player knows what he's doing when trying to salvage an enchanted item
|
||||||
if (!(heldItem.getEnchantments().size() > 0) || repairManager.checkConfirmation(type, true)) {
|
if (!(heldItem.getEnchantments().size() > 0) || salvageManager.checkConfirmation(true)) {
|
||||||
repairManager.handleSalvage(block.getLocation(), heldItem);
|
salvageManager.handleSalvage(block.getLocation(), heldItem);
|
||||||
player.updateInventory();
|
player.updateInventory();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -471,22 +491,22 @@ public class PlayerListener implements Listener {
|
|||||||
|
|
||||||
if ((Config.getInstance().getAbilitiesOnlyActivateWhenSneaking() && player.isSneaking()) || !Config.getInstance().getAbilitiesOnlyActivateWhenSneaking()) {
|
if ((Config.getInstance().getAbilitiesOnlyActivateWhenSneaking() && player.isSneaking()) || !Config.getInstance().getAbilitiesOnlyActivateWhenSneaking()) {
|
||||||
/* REPAIR CHECKS */
|
/* REPAIR CHECKS */
|
||||||
if (type == Repair.repairAnvilMaterial && SkillType.REPAIR.getPermissions(player) && mcMMO.getRepairableManager().isRepairable(heldItem)) {
|
if (type == Repair.anvilMaterial && SkillType.REPAIR.getPermissions(player) && mcMMO.getRepairableManager().isRepairable(heldItem)) {
|
||||||
RepairManager repairManager = mcMMOPlayer.getRepairManager();
|
RepairManager repairManager = mcMMOPlayer.getRepairManager();
|
||||||
|
|
||||||
// Cancel repairing an enchanted item
|
// Cancel repairing an enchanted item
|
||||||
if (repairManager.checkConfirmation(type, false) && Config.getInstance().getRepairConfirmRequired()) {
|
if (repairManager.checkConfirmation(false)) {
|
||||||
repairManager.setLastAnvilUse(Repair.repairAnvilMaterial, 0);
|
repairManager.setLastAnvilUse(0);
|
||||||
player.sendMessage(LocaleLoader.getString("Skills.Cancelled", LocaleLoader.getString("Repair.Pretty.Name")));
|
player.sendMessage(LocaleLoader.getString("Skills.Cancelled", LocaleLoader.getString("Repair.Pretty.Name")));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* SALVAGE CHECKS */
|
/* SALVAGE CHECKS */
|
||||||
else if (type == Repair.salvageAnvilMaterial && Permissions.secondaryAbilityEnabled(player, SecondaryAbility.SALVAGE) && Repair.isSalvageable(heldItem)) {
|
else if (type == Salvage.anvilMaterial && SkillType.SALVAGE.getPermissions(player) && mcMMO.getSalvageableManager().isSalvageable(heldItem)) {
|
||||||
RepairManager repairManager = mcMMOPlayer.getRepairManager();
|
SalvageManager salvageManager = mcMMOPlayer.getSalvageManager();
|
||||||
|
|
||||||
// Cancel salvaging an enchanted item
|
// Cancel salvaging an enchanted item
|
||||||
if (repairManager.checkConfirmation(type, false) && Config.getInstance().getRepairConfirmRequired()) {
|
if (salvageManager.checkConfirmation(false)) {
|
||||||
repairManager.setLastAnvilUse(Repair.salvageAnvilMaterial, 0);
|
salvageManager.setLastAnvilUse(0);
|
||||||
player.sendMessage(LocaleLoader.getString("Skills.Cancelled", LocaleLoader.getString("Salvage.Pretty.Name")));
|
player.sendMessage(LocaleLoader.getString("Skills.Cancelled", LocaleLoader.getString("Salvage.Pretty.Name")));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -508,7 +528,7 @@ public class PlayerListener implements Listener {
|
|||||||
public void onPlayerInteractMonitor(PlayerInteractEvent event) {
|
public void onPlayerInteractMonitor(PlayerInteractEvent event) {
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
|
|
||||||
if (Misc.isNPCEntity(player) || player.getGameMode() == GameMode.CREATIVE) {
|
if (!UserManager.hasPlayerDataKey(player) || player.getGameMode() == GameMode.CREATIVE) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -592,21 +612,14 @@ public class PlayerListener implements Listener {
|
|||||||
Material type = heldItem.getType();
|
Material type = heldItem.getType();
|
||||||
TamingManager tamingManager = mcMMOPlayer.getTamingManager();
|
TamingManager tamingManager = mcMMOPlayer.getTamingManager();
|
||||||
|
|
||||||
switch (type) {
|
if (type == Config.getInstance().getTamingCOTWMaterial(EntityType.WOLF)) {
|
||||||
case APPLE:
|
tamingManager.summonWolf();
|
||||||
tamingManager.summonHorse();
|
}
|
||||||
break;
|
else if (type == Config.getInstance().getTamingCOTWMaterial(EntityType.OCELOT)) {
|
||||||
|
tamingManager.summonOcelot();
|
||||||
case BONE:
|
}
|
||||||
tamingManager.summonWolf();
|
else if (type == Config.getInstance().getTamingCOTWMaterial(EntityType.HORSE)) {
|
||||||
break;
|
tamingManager.summonHorse();
|
||||||
|
|
||||||
case RAW_FISH:
|
|
||||||
tamingManager.summonOcelot();
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@@ -625,11 +638,11 @@ public class PlayerListener implements Listener {
|
|||||||
public void onPlayerChat(AsyncPlayerChatEvent event) {
|
public void onPlayerChat(AsyncPlayerChatEvent event) {
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
|
|
||||||
if (Misc.isNPCEntity(player)) {
|
if (Misc.isNPCEntity(player) || !UserManager.hasPlayerDataKey(player)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player, true);
|
McMMOPlayer mcMMOPlayer = UserManager.getOfflinePlayer(player);
|
||||||
|
|
||||||
if (mcMMOPlayer == null) {
|
if (mcMMOPlayer == null) {
|
||||||
mcMMO.p.debug(player.getName() + "is chatting, but is currently not logged in to the server.");
|
mcMMO.p.debug(player.getName() + "is chatting, but is currently not logged in to the server.");
|
||||||
@@ -689,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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,39 +0,0 @@
|
|||||||
package com.gmail.nossr50.listeners;
|
|
||||||
|
|
||||||
import org.bukkit.event.EventHandler;
|
|
||||||
import org.bukkit.event.EventPriority;
|
|
||||||
import org.bukkit.event.Listener;
|
|
||||||
import org.bukkit.event.player.PlayerJoinEvent;
|
|
||||||
import org.bukkit.event.player.PlayerQuitEvent;
|
|
||||||
|
|
||||||
import com.gmail.nossr50.events.experience.McMMOPlayerLevelUpEvent;
|
|
||||||
import com.gmail.nossr50.events.experience.McMMOPlayerXpGainEvent;
|
|
||||||
import com.gmail.nossr50.events.skills.abilities.McMMOPlayerAbilityActivateEvent;
|
|
||||||
import com.gmail.nossr50.util.scoreboards.ScoreboardManager;
|
|
||||||
|
|
||||||
public class ScoreboardsListener implements Listener {
|
|
||||||
@EventHandler(priority = EventPriority.MONITOR)
|
|
||||||
public void onPlayerJoin(PlayerJoinEvent event) {
|
|
||||||
ScoreboardManager.setupPlayer(event.getPlayer());
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.MONITOR)
|
|
||||||
public void onPlayerQuit(PlayerQuitEvent event) {
|
|
||||||
ScoreboardManager.teardownPlayer(event.getPlayer());
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.MONITOR)
|
|
||||||
public void onPlayerLevelUp(McMMOPlayerLevelUpEvent event) {
|
|
||||||
ScoreboardManager.handleLevelUp(event.getPlayer(), event.getSkill());
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.MONITOR)
|
|
||||||
public void onPlayerXp(McMMOPlayerXpGainEvent event) {
|
|
||||||
ScoreboardManager.handleXp(event.getPlayer(), event.getSkill());
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.MONITOR)
|
|
||||||
public void onAbility(McMMOPlayerAbilityActivateEvent event) {
|
|
||||||
ScoreboardManager.cooldownUpdate(event.getPlayer(), event.getSkill());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,21 +1,41 @@
|
|||||||
package com.gmail.nossr50.listeners;
|
package com.gmail.nossr50.listeners;
|
||||||
|
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
|
|
||||||
import com.gmail.nossr50.config.Config;
|
import com.gmail.nossr50.config.Config;
|
||||||
|
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||||
import com.gmail.nossr50.events.experience.McMMOPlayerLevelUpEvent;
|
import com.gmail.nossr50.events.experience.McMMOPlayerLevelUpEvent;
|
||||||
|
import com.gmail.nossr50.events.experience.McMMOPlayerXpGainEvent;
|
||||||
|
import com.gmail.nossr50.events.skills.abilities.McMMOPlayerAbilityActivateEvent;
|
||||||
|
import com.gmail.nossr50.util.scoreboards.ScoreboardManager;
|
||||||
|
|
||||||
public class SelfListener implements Listener {
|
public class SelfListener implements Listener {
|
||||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||||
public void onPlayerLevelUp(McMMOPlayerLevelUpEvent event) {
|
public void onPlayerLevelUp(McMMOPlayerLevelUpEvent event) {
|
||||||
|
Player player = event.getPlayer();
|
||||||
|
SkillType skill = event.getSkill();
|
||||||
|
|
||||||
|
ScoreboardManager.handleLevelUp(player, skill);
|
||||||
|
|
||||||
if (!Config.getInstance().getLevelUpEffectsEnabled()) {
|
if (!Config.getInstance().getLevelUpEffectsEnabled()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((event.getSkillLevel() % Config.getInstance().getLevelUpEffectsTier()) == 0) {
|
if ((event.getSkillLevel() % Config.getInstance().getLevelUpEffectsTier()) == 0) {
|
||||||
event.getSkill().celebrateLevelUp(event.getPlayer());
|
skill.celebrateLevelUp(player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||||
|
public void onPlayerXp(McMMOPlayerXpGainEvent event) {
|
||||||
|
ScoreboardManager.handleXp(event.getPlayer(), event.getSkill());
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||||
|
public void onAbility(McMMOPlayerAbilityActivateEvent event) {
|
||||||
|
ScoreboardManager.cooldownUpdate(event.getPlayer(), event.getSkill());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
package com.gmail.nossr50.listeners;
|
package com.gmail.nossr50.listeners;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.ArrayList;
|
|
||||||
|
|
||||||
import org.bukkit.Chunk;
|
import org.bukkit.Chunk;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
@@ -18,7 +17,6 @@ import com.gmail.nossr50.mcMMO;
|
|||||||
import com.gmail.nossr50.util.blockmeta.conversion.BlockStoreConversionMain;
|
import com.gmail.nossr50.util.blockmeta.conversion.BlockStoreConversionMain;
|
||||||
|
|
||||||
public class WorldListener implements Listener {
|
public class WorldListener implements Listener {
|
||||||
private final ArrayList<BlockStoreConversionMain> converters = new ArrayList<BlockStoreConversionMain>();
|
|
||||||
private final mcMMO plugin;
|
private final mcMMO plugin;
|
||||||
|
|
||||||
public WorldListener(final mcMMO plugin) {
|
public WorldListener(final mcMMO plugin) {
|
||||||
@@ -56,9 +54,7 @@ public class WorldListener implements Listener {
|
|||||||
|
|
||||||
plugin.getLogger().info("Converting block storage for " + world.getName() + " to a new format.");
|
plugin.getLogger().info("Converting block storage for " + world.getName() + " to a new format.");
|
||||||
|
|
||||||
BlockStoreConversionMain converter = new BlockStoreConversionMain(world);
|
new BlockStoreConversionMain(world).run();
|
||||||
converter.run();
|
|
||||||
converters.add(converter);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -14,12 +14,13 @@ import org.bukkit.plugin.java.JavaPlugin;
|
|||||||
import com.gmail.nossr50.config.AdvancedConfig;
|
import com.gmail.nossr50.config.AdvancedConfig;
|
||||||
import com.gmail.nossr50.config.Config;
|
import com.gmail.nossr50.config.Config;
|
||||||
import com.gmail.nossr50.config.HiddenConfig;
|
import com.gmail.nossr50.config.HiddenConfig;
|
||||||
import com.gmail.nossr50.config.mods.CustomArmorConfig;
|
import com.gmail.nossr50.config.mods.ArmorConfigManager;
|
||||||
import com.gmail.nossr50.config.mods.CustomBlockConfig;
|
import com.gmail.nossr50.config.mods.BlockConfigManager;
|
||||||
import com.gmail.nossr50.config.mods.CustomEntityConfig;
|
import com.gmail.nossr50.config.mods.EntityConfigManager;
|
||||||
import com.gmail.nossr50.config.mods.CustomToolConfig;
|
import com.gmail.nossr50.config.mods.ToolConfigManager;
|
||||||
import com.gmail.nossr50.config.potion.PotionConfig;
|
import com.gmail.nossr50.config.skills.alchemy.PotionConfig;
|
||||||
import com.gmail.nossr50.config.repair.RepairConfigManager;
|
import com.gmail.nossr50.config.skills.repair.RepairConfigManager;
|
||||||
|
import com.gmail.nossr50.config.skills.salvage.SalvageConfigManager;
|
||||||
import com.gmail.nossr50.config.treasure.TreasureConfig;
|
import com.gmail.nossr50.config.treasure.TreasureConfig;
|
||||||
import com.gmail.nossr50.database.DatabaseManager;
|
import com.gmail.nossr50.database.DatabaseManager;
|
||||||
import com.gmail.nossr50.database.DatabaseManagerFactory;
|
import com.gmail.nossr50.database.DatabaseManagerFactory;
|
||||||
@@ -27,13 +28,13 @@ import com.gmail.nossr50.listeners.BlockListener;
|
|||||||
import com.gmail.nossr50.listeners.EntityListener;
|
import com.gmail.nossr50.listeners.EntityListener;
|
||||||
import com.gmail.nossr50.listeners.InventoryListener;
|
import com.gmail.nossr50.listeners.InventoryListener;
|
||||||
import com.gmail.nossr50.listeners.PlayerListener;
|
import com.gmail.nossr50.listeners.PlayerListener;
|
||||||
import com.gmail.nossr50.listeners.ScoreboardsListener;
|
|
||||||
import com.gmail.nossr50.listeners.SelfListener;
|
import com.gmail.nossr50.listeners.SelfListener;
|
||||||
import com.gmail.nossr50.listeners.WorldListener;
|
import com.gmail.nossr50.listeners.WorldListener;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
|
||||||
import com.gmail.nossr50.metrics.MetricsManager;
|
import com.gmail.nossr50.metrics.MetricsManager;
|
||||||
import com.gmail.nossr50.party.PartyManager;
|
import com.gmail.nossr50.party.PartyManager;
|
||||||
|
import com.gmail.nossr50.runnables.CheckDateTask;
|
||||||
import com.gmail.nossr50.runnables.SaveTimerTask;
|
import com.gmail.nossr50.runnables.SaveTimerTask;
|
||||||
|
import com.gmail.nossr50.runnables.UpdaterResultAsyncTask;
|
||||||
import com.gmail.nossr50.runnables.backups.CleanBackupsTask;
|
import com.gmail.nossr50.runnables.backups.CleanBackupsTask;
|
||||||
import com.gmail.nossr50.runnables.database.UserPurgeTask;
|
import com.gmail.nossr50.runnables.database.UserPurgeTask;
|
||||||
import com.gmail.nossr50.runnables.party.PartyAutoKickTask;
|
import com.gmail.nossr50.runnables.party.PartyAutoKickTask;
|
||||||
@@ -44,10 +45,14 @@ import com.gmail.nossr50.skills.child.ChildConfig;
|
|||||||
import com.gmail.nossr50.skills.repair.repairables.Repairable;
|
import com.gmail.nossr50.skills.repair.repairables.Repairable;
|
||||||
import com.gmail.nossr50.skills.repair.repairables.RepairableManager;
|
import com.gmail.nossr50.skills.repair.repairables.RepairableManager;
|
||||||
import com.gmail.nossr50.skills.repair.repairables.SimpleRepairableManager;
|
import com.gmail.nossr50.skills.repair.repairables.SimpleRepairableManager;
|
||||||
|
import com.gmail.nossr50.skills.salvage.salvageables.Salvageable;
|
||||||
|
import com.gmail.nossr50.skills.salvage.salvageables.SalvageableManager;
|
||||||
|
import com.gmail.nossr50.skills.salvage.salvageables.SimpleSalvageableManager;
|
||||||
import com.gmail.nossr50.util.ChimaeraWing;
|
import com.gmail.nossr50.util.ChimaeraWing;
|
||||||
import com.gmail.nossr50.util.HolidayManager;
|
import com.gmail.nossr50.util.HolidayManager;
|
||||||
import com.gmail.nossr50.util.LogFilter;
|
import com.gmail.nossr50.util.LogFilter;
|
||||||
import com.gmail.nossr50.util.Misc;
|
import com.gmail.nossr50.util.Misc;
|
||||||
|
import com.gmail.nossr50.util.ModManager;
|
||||||
import com.gmail.nossr50.util.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
import com.gmail.nossr50.util.blockmeta.chunkmeta.ChunkManager;
|
import com.gmail.nossr50.util.blockmeta.chunkmeta.ChunkManager;
|
||||||
import com.gmail.nossr50.util.blockmeta.chunkmeta.ChunkManagerFactory;
|
import com.gmail.nossr50.util.blockmeta.chunkmeta.ChunkManagerFactory;
|
||||||
@@ -56,18 +61,17 @@ import com.gmail.nossr50.util.experience.FormulaManager;
|
|||||||
import com.gmail.nossr50.util.player.UserManager;
|
import com.gmail.nossr50.util.player.UserManager;
|
||||||
import com.gmail.nossr50.util.scoreboards.ScoreboardManager;
|
import com.gmail.nossr50.util.scoreboards.ScoreboardManager;
|
||||||
|
|
||||||
import net.gravitydevelopment.updater.mcmmo.Updater;
|
|
||||||
import net.gravitydevelopment.updater.mcmmo.Updater.UpdateResult;
|
|
||||||
import net.gravitydevelopment.updater.mcmmo.Updater.UpdateType;
|
|
||||||
import net.shatteredlands.shatt.backup.ZipLibrary;
|
import net.shatteredlands.shatt.backup.ZipLibrary;
|
||||||
|
|
||||||
public class mcMMO extends JavaPlugin {
|
public class mcMMO extends JavaPlugin {
|
||||||
/* Managers */
|
/* Managers */
|
||||||
private static ChunkManager placeStore;
|
private static ChunkManager placeStore;
|
||||||
private static RepairableManager repairableManager;
|
private static RepairableManager repairableManager;
|
||||||
private static DatabaseManager databaseManager;
|
private static SalvageableManager salvageableManager;
|
||||||
private static FormulaManager formulaManager;
|
private static ModManager modManager;
|
||||||
private static HolidayManager holidayManager;
|
private static DatabaseManager databaseManager;
|
||||||
|
private static FormulaManager formulaManager;
|
||||||
|
private static HolidayManager holidayManager;
|
||||||
|
|
||||||
/* File Paths */
|
/* File Paths */
|
||||||
private static String mainDirectory;
|
private static String mainDirectory;
|
||||||
@@ -84,11 +88,7 @@ public class mcMMO extends JavaPlugin {
|
|||||||
private boolean updateAvailable;
|
private boolean updateAvailable;
|
||||||
|
|
||||||
/* Plugin Checks */
|
/* Plugin Checks */
|
||||||
private static boolean combatTagEnabled;
|
|
||||||
private static boolean healthBarPluginEnabled;
|
private static boolean healthBarPluginEnabled;
|
||||||
private static boolean noCheatPlusPluginEnabled;
|
|
||||||
private static boolean compatNoCheatPlusPluginEnabled;
|
|
||||||
private static boolean mcpcEnabled;
|
|
||||||
|
|
||||||
// Config Validation Check
|
// Config Validation Check
|
||||||
public boolean noErrorsInConfigFiles = true;
|
public boolean noErrorsInConfigFiles = true;
|
||||||
@@ -110,6 +110,9 @@ public class mcMMO extends JavaPlugin {
|
|||||||
public final static String arrowDistanceKey = "mcMMO: Arrow Distance";
|
public final static String arrowDistanceKey = "mcMMO: Arrow Distance";
|
||||||
public final static String customDamageKey = "mcMMO: Custom Damage";
|
public final static String customDamageKey = "mcMMO: Custom Damage";
|
||||||
public final static String disarmedItemKey = "mcMMO: Disarmed Item";
|
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;
|
public static FixedMetadataValue metadataValue;
|
||||||
|
|
||||||
@@ -123,21 +126,20 @@ public class mcMMO extends JavaPlugin {
|
|||||||
getLogger().setFilter(new LogFilter(this));
|
getLogger().setFilter(new LogFilter(this));
|
||||||
metadataValue = new FixedMetadataValue(this, true);
|
metadataValue = new FixedMetadataValue(this, true);
|
||||||
|
|
||||||
mcpcEnabled = getServer().getName().equals("MCPC+");
|
PluginManager pluginManager = getServer().getPluginManager();
|
||||||
combatTagEnabled = getServer().getPluginManager().getPlugin("CombatTag") != null;
|
healthBarPluginEnabled = pluginManager.getPlugin("HealthBar") != null;
|
||||||
healthBarPluginEnabled = getServer().getPluginManager().getPlugin("HealthBar") != null;
|
|
||||||
noCheatPlusPluginEnabled = getServer().getPluginManager().getPlugin("NoCheatPlus") != null;
|
|
||||||
compatNoCheatPlusPluginEnabled = getServer().getPluginManager().getPlugin("CompatNoCheatPlus") != null;
|
|
||||||
|
|
||||||
setupFilePaths();
|
setupFilePaths();
|
||||||
|
|
||||||
|
modManager = new ModManager();
|
||||||
|
|
||||||
loadConfigFiles();
|
loadConfigFiles();
|
||||||
|
|
||||||
if (!noErrorsInConfigFiles) {
|
if (!noErrorsInConfigFiles) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mcpcEnabled) {
|
if (getServer().getName().equals("Cauldron") || getServer().getName().equals("MCPC+")) {
|
||||||
checkModConfigs();
|
checkModConfigs();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -145,7 +147,7 @@ public class mcMMO extends JavaPlugin {
|
|||||||
getLogger().info("HealthBar plugin found, mcMMO's healthbars are automatically disabled.");
|
getLogger().info("HealthBar plugin found, mcMMO's healthbars are automatically disabled.");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (noCheatPlusPluginEnabled && !compatNoCheatPlusPluginEnabled) {
|
if (pluginManager.getPlugin("NoCheatPlus") != null && pluginManager.getPlugin("CompatNoCheatPlus") == null) {
|
||||||
getLogger().warning("NoCheatPlus plugin found, but CompatNoCheatPlus was not found!");
|
getLogger().warning("NoCheatPlus plugin found, but CompatNoCheatPlus was not found!");
|
||||||
getLogger().warning("mcMMO will not work properly alongside NoCheatPlus without CompatNoCheatPlus");
|
getLogger().warning("mcMMO will not work properly alongside NoCheatPlus without CompatNoCheatPlus");
|
||||||
}
|
}
|
||||||
@@ -202,6 +204,7 @@ public class mcMMO extends JavaPlugin {
|
|||||||
try {
|
try {
|
||||||
Alchemy.finishAllBrews(); // Finish all partially complete AlchemyBrewTasks to prevent vanilla brewing continuation on restart
|
Alchemy.finishAllBrews(); // Finish all partially complete AlchemyBrewTasks to prevent vanilla brewing continuation on restart
|
||||||
UserManager.saveAll(); // Make sure to save player information if the server shuts down
|
UserManager.saveAll(); // Make sure to save player information if the server shuts down
|
||||||
|
UserManager.clearAll();
|
||||||
PartyManager.saveParties(); // Save our parties
|
PartyManager.saveParties(); // Save our parties
|
||||||
ScoreboardManager.teardownAll();
|
ScoreboardManager.teardownAll();
|
||||||
formulaManager.saveFormula();
|
formulaManager.saveFormula();
|
||||||
@@ -258,6 +261,10 @@ public class mcMMO extends JavaPlugin {
|
|||||||
return updateAvailable;
|
return updateAvailable;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setUpdateAvailable(boolean available) {
|
||||||
|
this.updateAvailable = available;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isXPEventEnabled() {
|
public boolean isXPEventEnabled() {
|
||||||
return xpEventEnabled;
|
return xpEventEnabled;
|
||||||
}
|
}
|
||||||
@@ -290,27 +297,27 @@ public class mcMMO extends JavaPlugin {
|
|||||||
return repairableManager;
|
return repairableManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static SalvageableManager getSalvageableManager() {
|
||||||
|
return salvageableManager;
|
||||||
|
}
|
||||||
|
|
||||||
public static DatabaseManager getDatabaseManager() {
|
public static DatabaseManager getDatabaseManager() {
|
||||||
return databaseManager;
|
return databaseManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static ModManager getModManager() {
|
||||||
|
return modManager;
|
||||||
|
}
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public static void setDatabaseManager(DatabaseManager databaseManager) {
|
public static void setDatabaseManager(DatabaseManager databaseManager) {
|
||||||
mcMMO.databaseManager = databaseManager;
|
mcMMO.databaseManager = databaseManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isCombatTagEnabled() {
|
|
||||||
return combatTagEnabled;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean isHealthBarPluginEnabled() {
|
public static boolean isHealthBarPluginEnabled() {
|
||||||
return healthBarPluginEnabled;
|
return healthBarPluginEnabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isMCPCEnabled() {
|
|
||||||
return mcpcEnabled;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Setup the various storage file paths
|
* Setup the various storage file paths
|
||||||
*/
|
*/
|
||||||
@@ -329,15 +336,47 @@ public class mcMMO extends JavaPlugin {
|
|||||||
|
|
||||||
if (oldFlatfilePath.exists()) {
|
if (oldFlatfilePath.exists()) {
|
||||||
if (!oldFlatfilePath.renameTo(new File(flatFileDirectory))) {
|
if (!oldFlatfilePath.renameTo(new File(flatFileDirectory))) {
|
||||||
getLogger().warning("Failed to rename FlatFileStuff to flatfile !");
|
getLogger().warning("Failed to rename FlatFileStuff to flatfile!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (oldModPath.exists()) {
|
if (oldModPath.exists()) {
|
||||||
if (!oldModPath.renameTo(new File(modDirectory))) {
|
if (!oldModPath.renameTo(new File(modDirectory))) {
|
||||||
getLogger().warning("Failed to rename ModConfigs to mods !");
|
getLogger().warning("Failed to rename ModConfigs to mods!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
File oldArmorFile = new File(modDirectory + "armor.yml");
|
||||||
|
File oldBlocksFile = new File(modDirectory + "blocks.yml");
|
||||||
|
File oldEntitiesFile = new File(modDirectory + "entities.yml");
|
||||||
|
File oldToolsFile = new File(modDirectory + "tools.yml");
|
||||||
|
|
||||||
|
if (oldArmorFile.exists()) {
|
||||||
|
if (!oldArmorFile.renameTo(new File(modDirectory + "armor.default.yml"))) {
|
||||||
|
getLogger().warning("Failed to rename armor.yml to armor.default.yml!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (oldBlocksFile.exists()) {
|
||||||
|
if (!oldBlocksFile.renameTo(new File(modDirectory + "blocks.default.yml"))) {
|
||||||
|
getLogger().warning("Failed to rename blocks.yml to blocks.default.yml!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (oldEntitiesFile.exists()) {
|
||||||
|
if (!oldEntitiesFile.renameTo(new File(modDirectory + "entities.default.yml"))) {
|
||||||
|
getLogger().warning("Failed to rename entities.yml to entities.default.yml!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (oldToolsFile.exists()) {
|
||||||
|
if (!oldToolsFile.renameTo(new File(modDirectory + "tools.default.yml"))) {
|
||||||
|
getLogger().warning("Failed to rename tools.yml to tools.default.yml!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
File currentFlatfilePath = new File(flatFileDirectory);
|
||||||
|
currentFlatfilePath.mkdirs();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkForUpdates() {
|
private void checkForUpdates() {
|
||||||
@@ -345,21 +384,7 @@ public class mcMMO extends JavaPlugin {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Updater updater = new Updater(this, 31030, mcmmo, UpdateType.NO_DOWNLOAD, false);
|
new UpdaterResultAsyncTask(this).runTaskAsynchronously(mcMMO.p);
|
||||||
|
|
||||||
if (updater.getResult() != UpdateResult.UPDATE_AVAILABLE) {
|
|
||||||
this.updateAvailable = false;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (updater.getLatestType().equals("beta") && !Config.getInstance().getPreferBeta()) {
|
|
||||||
this.updateAvailable = false;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.updateAvailable = true;
|
|
||||||
getLogger().info(LocaleLoader.getString("UpdateChecker.Outdated"));
|
|
||||||
getLogger().info(LocaleLoader.getString("UpdateChecker.NewAvailable"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void loadConfigFiles() {
|
private void loadConfigFiles() {
|
||||||
@@ -371,28 +396,35 @@ public class mcMMO extends JavaPlugin {
|
|||||||
new ChildConfig();
|
new ChildConfig();
|
||||||
|
|
||||||
List<Repairable> repairables = new ArrayList<Repairable>();
|
List<Repairable> repairables = new ArrayList<Repairable>();
|
||||||
|
List<Salvageable> salvageables = new ArrayList<Salvageable>();
|
||||||
|
|
||||||
if (Config.getInstance().getToolModsEnabled()) {
|
if (Config.getInstance().getToolModsEnabled()) {
|
||||||
repairables.addAll(CustomToolConfig.getInstance().getLoadedRepairables());
|
new ToolConfigManager(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Config.getInstance().getArmorModsEnabled()) {
|
if (Config.getInstance().getArmorModsEnabled()) {
|
||||||
repairables.addAll(CustomArmorConfig.getInstance().getLoadedRepairables());
|
new ArmorConfigManager(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Config.getInstance().getBlockModsEnabled()) {
|
if (Config.getInstance().getBlockModsEnabled()) {
|
||||||
CustomBlockConfig.getInstance();
|
new BlockConfigManager(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Config.getInstance().getEntityModsEnabled()) {
|
if (Config.getInstance().getEntityModsEnabled()) {
|
||||||
CustomEntityConfig.getInstance();
|
new EntityConfigManager(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load repair configs, make manager, and register them at this time
|
// Load repair configs, make manager, and register them at this time
|
||||||
RepairConfigManager rManager = new RepairConfigManager(this);
|
repairables.addAll(new RepairConfigManager(this).getLoadedRepairables());
|
||||||
repairables.addAll(rManager.getLoadedRepairables());
|
repairables.addAll(modManager.getLoadedRepairables());
|
||||||
repairableManager = new SimpleRepairableManager(repairables.size());
|
repairableManager = new SimpleRepairableManager(repairables.size());
|
||||||
repairableManager.registerRepairables(repairables);
|
repairableManager.registerRepairables(repairables);
|
||||||
|
|
||||||
|
// Load salvage configs, make manager and register them at this time
|
||||||
|
SalvageConfigManager sManager = new SalvageConfigManager(this);
|
||||||
|
salvageables.addAll(sManager.getLoadedSalvageables());
|
||||||
|
salvageableManager = new SimpleSalvageableManager(salvageables.size());
|
||||||
|
salvageableManager.registerSalvageables(salvageables);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void registerEvents() {
|
private void registerEvents() {
|
||||||
@@ -404,7 +436,6 @@ public class mcMMO extends JavaPlugin {
|
|||||||
pluginManager.registerEvents(new EntityListener(this), this);
|
pluginManager.registerEvents(new EntityListener(this), this);
|
||||||
pluginManager.registerEvents(new InventoryListener(this), this);
|
pluginManager.registerEvents(new InventoryListener(this), this);
|
||||||
pluginManager.registerEvents(new SelfListener(), this);
|
pluginManager.registerEvents(new SelfListener(), this);
|
||||||
pluginManager.registerEvents(new ScoreboardsListener(), this);
|
|
||||||
pluginManager.registerEvents(new WorldListener(this), this);
|
pluginManager.registerEvents(new WorldListener(this), this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -447,26 +478,30 @@ public class mcMMO extends JavaPlugin {
|
|||||||
|
|
||||||
// Update power level tag scoreboards
|
// Update power level tag scoreboards
|
||||||
new PowerLevelUpdatingTask().runTaskTimer(this, 2 * Misc.TICK_CONVERSION_FACTOR, 2 * Misc.TICK_CONVERSION_FACTOR);
|
new PowerLevelUpdatingTask().runTaskTimer(this, 2 * Misc.TICK_CONVERSION_FACTOR, 2 * Misc.TICK_CONVERSION_FACTOR);
|
||||||
|
|
||||||
|
if (getHolidayManager().nearingAprilFirst()) {
|
||||||
|
new CheckDateTask().runTaskTimer(this, 10L * Misc.TICK_CONVERSION_FACTOR, 1L * 60L * 60L * Misc.TICK_CONVERSION_FACTOR);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkModConfigs() {
|
private void checkModConfigs() {
|
||||||
if (!Config.getInstance().getToolModsEnabled()) {
|
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.");
|
getLogger().info("To enable, set Mods.Tool_Mods_Enabled to TRUE in config.yml.");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Config.getInstance().getArmorModsEnabled()) {
|
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.");
|
getLogger().info("To enable, set Mods.Armor_Mods_Enabled to TRUE in config.yml.");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Config.getInstance().getBlockModsEnabled()) {
|
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.");
|
getLogger().info("To enable, set Mods.Block_Mods_Enabled to TRUE in config.yml.");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Config.getInstance().getEntityModsEnabled()) {
|
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.");
|
getLogger().info("To enable, set Mods.Entity_Mods_Enabled to TRUE in config.yml.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -170,7 +170,7 @@ public final class PartyManager {
|
|||||||
*/
|
*/
|
||||||
public static Party getParty(String partyName) {
|
public static Party getParty(String partyName) {
|
||||||
for (Party party : parties) {
|
for (Party party : parties) {
|
||||||
if (party.getName().equals(partyName)) {
|
if (party.getName().equalsIgnoreCase(partyName)) {
|
||||||
return party;
|
return party;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -260,6 +260,11 @@ public final class PartyManager {
|
|||||||
processPartyLeaving(UserManager.getPlayer(member));
|
processPartyLeaving(UserManager.getPlayer(member));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Disband the alliance between the disbanded party and it's ally
|
||||||
|
if (party.getAlly() != null) {
|
||||||
|
party.getAlly().setAlly(null);
|
||||||
|
}
|
||||||
|
|
||||||
parties.remove(party);
|
parties.remove(party);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -459,16 +464,6 @@ public final class PartyManager {
|
|||||||
return !party.isLocked() || party.getLeader().equalsIgnoreCase(mcMMOPlayer.getPlayer().getName());
|
return !party.isLocked() || party.getLeader().equalsIgnoreCase(mcMMOPlayer.getPlayer().getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Check if a string is a valid party name.
|
|
||||||
*
|
|
||||||
* @param partyName The party name to check
|
|
||||||
* @return true if this is a valid party, false otherwise
|
|
||||||
*/
|
|
||||||
public static boolean isParty(String partyName) {
|
|
||||||
return getParty(partyName) != null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load party file.
|
* Load party file.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import com.gmail.nossr50.datatypes.party.Party;
|
|||||||
import com.gmail.nossr50.datatypes.party.ShareMode;
|
import com.gmail.nossr50.datatypes.party.ShareMode;
|
||||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||||
|
import com.gmail.nossr50.datatypes.skills.XPGainReason;
|
||||||
import com.gmail.nossr50.util.Misc;
|
import com.gmail.nossr50.util.Misc;
|
||||||
import com.gmail.nossr50.util.player.UserManager;
|
import com.gmail.nossr50.util.player.UserManager;
|
||||||
|
|
||||||
@@ -27,7 +28,7 @@ public final class ShareHandler {
|
|||||||
* @param skillType Skill being used
|
* @param skillType Skill being used
|
||||||
* @return True is the xp has been shared
|
* @return True is the xp has been shared
|
||||||
*/
|
*/
|
||||||
public static boolean handleXpShare(float xp, McMMOPlayer mcMMOPlayer, SkillType skillType) {
|
public static boolean handleXpShare(float xp, McMMOPlayer mcMMOPlayer, SkillType skillType, XPGainReason xpGainReason) {
|
||||||
Party party = mcMMOPlayer.getParty();
|
Party party = mcMMOPlayer.getParty();
|
||||||
|
|
||||||
if (party.getXpShareMode() != ShareMode.EQUAL) {
|
if (party.getXpShareMode() != ShareMode.EQUAL) {
|
||||||
@@ -47,7 +48,7 @@ public final class ShareHandler {
|
|||||||
float splitXp = (float) (xp / partySize * shareBonus);
|
float splitXp = (float) (xp / partySize * shareBonus);
|
||||||
|
|
||||||
for (Player member : nearMembers) {
|
for (Player member : nearMembers) {
|
||||||
UserManager.getPlayer(member).beginUnsharedXpGain(skillType, splitXp);
|
UserManager.getPlayer(member).beginUnsharedXpGain(skillType, splitXp, xpGainReason);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@@ -142,6 +143,18 @@ public final class ShareHandler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static XPGainReason getSharedXpGainReason(XPGainReason xpGainReason) {
|
||||||
|
if (xpGainReason == XPGainReason.PVE) {
|
||||||
|
return XPGainReason.SHARED_PVE;
|
||||||
|
}
|
||||||
|
else if (xpGainReason == XPGainReason.PVP) {
|
||||||
|
return XPGainReason.SHARED_PVP;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return xpGainReason;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static void awardDrop(Player winningPlayer, ItemStack drop) {
|
private static void awardDrop(Player winningPlayer, ItemStack drop) {
|
||||||
if (winningPlayer.getInventory().addItem(drop).size() != 0) {
|
if (winningPlayer.getInventory().addItem(drop).size() != 0) {
|
||||||
winningPlayer.getWorld().dropItemNaturally(winningPlayer.getLocation(), drop);
|
winningPlayer.getWorld().dropItemNaturally(winningPlayer.getLocation(), drop);
|
||||||
|
|||||||
24
src/main/java/com/gmail/nossr50/runnables/CheckDateTask.java
Normal file
24
src/main/java/com/gmail/nossr50/runnables/CheckDateTask.java
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
package com.gmail.nossr50.runnables;
|
||||||
|
|
||||||
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
|
||||||
|
import com.gmail.nossr50.mcMMO;
|
||||||
|
import com.gmail.nossr50.runnables.skills.AprilTask;
|
||||||
|
import com.gmail.nossr50.util.Misc;
|
||||||
|
|
||||||
|
public class CheckDateTask extends BukkitRunnable {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
if (!mcMMO.getHolidayManager().isAprilFirst()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set up jokes
|
||||||
|
new AprilTask().runTaskTimer(mcMMO.p, 1L * 60L * Misc.TICK_CONVERSION_FACTOR, 10L * 60L * Misc.TICK_CONVERSION_FACTOR);
|
||||||
|
mcMMO.getHolidayManager().registerAprilCommand();
|
||||||
|
|
||||||
|
// Jokes deployed.
|
||||||
|
this.cancel();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,31 +1,36 @@
|
|||||||
package com.gmail.nossr50.runnables;
|
package com.gmail.nossr50.runnables;
|
||||||
|
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.block.BlockFace;
|
import org.bukkit.block.BlockFace;
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
|
||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
|
import com.gmail.nossr50.util.BlockUtils;
|
||||||
|
|
||||||
public class StickyPistonTrackerTask extends BukkitRunnable {
|
public class StickyPistonTrackerTask extends BukkitRunnable {
|
||||||
private BlockFace direction;
|
private BlockFace direction;
|
||||||
private Block block;
|
private Block block;
|
||||||
|
private Block movedBlock;
|
||||||
|
|
||||||
public StickyPistonTrackerTask(BlockFace direction, Block block) {
|
public StickyPistonTrackerTask(BlockFace direction, Block block, Block movedBlock) {
|
||||||
this.direction = direction;
|
this.direction = direction;
|
||||||
this.block = block;
|
this.block = block;
|
||||||
|
this.movedBlock = movedBlock;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
Block newBlock = block.getRelative(direction);
|
if (!mcMMO.getPlaceStore().isTrue(movedBlock)) {
|
||||||
Block originalBlock = newBlock.getRelative(direction);
|
|
||||||
|
|
||||||
if (originalBlock.getType() != Material.AIR || !mcMMO.getPlaceStore().isTrue(originalBlock)) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
mcMMO.getPlaceStore().setFalse(originalBlock);
|
if (!BlockUtils.isPistonPiece(movedBlock.getState())) {
|
||||||
mcMMO.getPlaceStore().setTrue(newBlock);
|
// 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));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,36 @@
|
|||||||
|
package com.gmail.nossr50.runnables;
|
||||||
|
|
||||||
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
|
||||||
|
import com.gmail.nossr50.mcMMO;
|
||||||
|
import com.gmail.nossr50.config.Config;
|
||||||
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
|
|
||||||
|
import net.gravitydevelopment.updater.mcmmo.Updater;
|
||||||
|
|
||||||
|
public class UpdaterResultAsyncTask extends BukkitRunnable {
|
||||||
|
private mcMMO plugin;
|
||||||
|
|
||||||
|
public UpdaterResultAsyncTask(mcMMO plugin) {
|
||||||
|
this.plugin = plugin;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
Updater updater = new Updater(plugin, 31030, plugin.mcmmo, Updater.UpdateType.NO_DOWNLOAD, false);
|
||||||
|
|
||||||
|
if (updater.getResult() != Updater.UpdateResult.UPDATE_AVAILABLE) {
|
||||||
|
plugin.setUpdateAvailable(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (updater.getLatestType().equals("beta") && !Config.getInstance().getPreferBeta()) {
|
||||||
|
plugin.setUpdateAvailable(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
plugin.setUpdateAvailable(true);
|
||||||
|
plugin.getLogger().info(LocaleLoader.getString("UpdateChecker.Outdated"));
|
||||||
|
plugin.getLogger().info(LocaleLoader.getString("UpdateChecker.NewAvailable"));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
package com.gmail.nossr50.runnables.commands;
|
||||||
|
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
|
||||||
|
import com.gmail.nossr50.util.scoreboards.ScoreboardManager;
|
||||||
|
|
||||||
|
public class McScoreboardKeepTask extends BukkitRunnable {
|
||||||
|
private Player player;
|
||||||
|
|
||||||
|
public McScoreboardKeepTask(Player player) {
|
||||||
|
this.player = player;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
if (player.isValid() && ScoreboardManager.isBoardShown(player.getName())) {
|
||||||
|
ScoreboardManager.keepBoard(player.getName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -34,7 +34,7 @@ public class McrankCommandDisplayTask extends BukkitRunnable {
|
|||||||
displayBoard();
|
displayBoard();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (useChat){
|
if (useChat) {
|
||||||
displayChat();
|
displayChat();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,5 +28,5 @@ public class DatabaseConversionTask extends BukkitRunnable {
|
|||||||
sender.sendMessage(message);
|
sender.sendMessage(message);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ public class FormulaConversionTask extends BukkitRunnable {
|
|||||||
int convertedUsers = 0;
|
int convertedUsers = 0;
|
||||||
long startMillis = System.currentTimeMillis();
|
long startMillis = System.currentTimeMillis();
|
||||||
for (String playerName : mcMMO.getDatabaseManager().getStoredUsers()) {
|
for (String playerName : mcMMO.getDatabaseManager().getStoredUsers()) {
|
||||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(playerName, true);
|
McMMOPlayer mcMMOPlayer = UserManager.getOfflinePlayer(playerName);
|
||||||
PlayerProfile profile;
|
PlayerProfile profile;
|
||||||
|
|
||||||
// If the mcMMOPlayer doesn't exist, create a temporary profile and check if it's present in the database. If it's not, abort the process.
|
// If the mcMMOPlayer doesn't exist, create a temporary profile and check if it's present in the database. If it's not, abort the process.
|
||||||
@@ -41,7 +41,8 @@ public class FormulaConversionTask extends BukkitRunnable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
editValues(profile);
|
editValues(profile);
|
||||||
profile.save(); // Since this is a temporary profile, we save it here.
|
// Since this is a temporary profile, we save it here.
|
||||||
|
profile.scheduleAsyncSave();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
profile = mcMMOPlayer.getProfile();
|
profile = mcMMOPlayer.getProfile();
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
package com.gmail.nossr50.runnables;
|
package com.gmail.nossr50.runnables.player;
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
@@ -2,7 +2,7 @@ package com.gmail.nossr50.runnables.skills;
|
|||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.block.BrewingStand;
|
import org.bukkit.block.BrewingStand;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
@@ -12,8 +12,6 @@ import com.gmail.nossr50.skills.alchemy.Alchemy;
|
|||||||
import com.gmail.nossr50.skills.alchemy.AlchemyPotionBrewer;
|
import com.gmail.nossr50.skills.alchemy.AlchemyPotionBrewer;
|
||||||
|
|
||||||
public class AlchemyBrewCheckTask extends BukkitRunnable {
|
public class AlchemyBrewCheckTask extends BukkitRunnable {
|
||||||
private final static int INGREDIENT_SLOT = 3;
|
|
||||||
|
|
||||||
private Player player;
|
private Player player;
|
||||||
private BrewingStand brewingStand;
|
private BrewingStand brewingStand;
|
||||||
private ItemStack[] oldInventory;
|
private ItemStack[] oldInventory;
|
||||||
@@ -26,18 +24,17 @@ public class AlchemyBrewCheckTask extends BukkitRunnable {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
Block block = brewingStand.getBlock();
|
Location location = brewingStand.getLocation();
|
||||||
ItemStack[] newInventory = Arrays.copyOfRange(((BrewingStand) block.getState()).getInventory().getContents(), 0, 4);
|
ItemStack[] newInventory = Arrays.copyOfRange(brewingStand.getInventory().getContents(), 0, 4);
|
||||||
|
boolean validBrew = AlchemyPotionBrewer.isValidBrew(player, newInventory);
|
||||||
|
|
||||||
if (Alchemy.brewingStandMap.containsKey(brewingStand)) {
|
if (Alchemy.brewingStandMap.containsKey(location)) {
|
||||||
if (oldInventory[INGREDIENT_SLOT] == null || newInventory[INGREDIENT_SLOT] == null || !oldInventory[INGREDIENT_SLOT].isSimilar(newInventory[INGREDIENT_SLOT]) || !AlchemyPotionBrewer.isValidBrew(player, newInventory)) {
|
if (oldInventory[Alchemy.INGREDIENT_SLOT] == null || newInventory[Alchemy.INGREDIENT_SLOT] == null || !oldInventory[Alchemy.INGREDIENT_SLOT].isSimilar(newInventory[Alchemy.INGREDIENT_SLOT]) || !validBrew) {
|
||||||
Alchemy.brewingStandMap.get(brewingStand).cancelBrew();
|
Alchemy.brewingStandMap.get(location).cancelBrew();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (validBrew) {
|
||||||
if (!Alchemy.brewingStandMap.containsKey(brewingStand) && AlchemyPotionBrewer.isValidBrew(player, newInventory)) {
|
Alchemy.brewingStandMap.put(location, new AlchemyBrewTask(brewingStand, player));
|
||||||
Alchemy.brewingStandMap.put(brewingStand, new AlchemyBrewTask(brewingStand, player));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.gmail.nossr50.runnables.skills;
|
package com.gmail.nossr50.runnables.skills;
|
||||||
|
|
||||||
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.BlockState;
|
import org.bukkit.block.BlockState;
|
||||||
import org.bukkit.block.BrewingStand;
|
import org.bukkit.block.BrewingStand;
|
||||||
@@ -22,44 +23,43 @@ public class AlchemyBrewTask extends BukkitRunnable {
|
|||||||
private static int DEFAULT_BREW_TICKS = 400;
|
private static int DEFAULT_BREW_TICKS = 400;
|
||||||
|
|
||||||
private BlockState brewingStand;
|
private BlockState brewingStand;
|
||||||
|
private Location location;
|
||||||
private double brewSpeed;
|
private double brewSpeed;
|
||||||
private double brewTimer;
|
private double brewTimer;
|
||||||
private Player player;
|
private Player player;
|
||||||
|
|
||||||
public AlchemyBrewTask(BlockState brewingStand, Player player) {
|
public AlchemyBrewTask(BlockState brewingStand, Player player) {
|
||||||
this.brewingStand = brewingStand;
|
this.brewingStand = brewingStand;
|
||||||
|
this.location = brewingStand.getLocation();
|
||||||
this.player = player;
|
this.player = player;
|
||||||
|
|
||||||
brewSpeed = DEFAULT_BREW_SPEED;
|
brewSpeed = DEFAULT_BREW_SPEED;
|
||||||
brewTimer = DEFAULT_BREW_TICKS;
|
brewTimer = DEFAULT_BREW_TICKS;
|
||||||
|
|
||||||
if (player != null && !Misc.isNPCEntity(player) && Permissions.secondaryAbilityEnabled(player, SecondaryAbility.CATALYSIS)) {
|
if (player != null && !Misc.isNPCEntity(player) && Permissions.secondaryAbilityEnabled(player, SecondaryAbility.CATALYSIS)) {
|
||||||
double catalysis = UserManager.getPlayer(player).getAlchemyManager().getBrewSpeed();
|
double catalysis = UserManager.getPlayer(player).getAlchemyManager().calculateBrewSpeed(Permissions.lucky(player, SkillType.ALCHEMY));
|
||||||
|
|
||||||
if (Permissions.lucky(player, SkillType.ALCHEMY)) {
|
|
||||||
catalysis = UserManager.getPlayer(player).getAlchemyManager().getBrewSpeedLucky();
|
|
||||||
}
|
|
||||||
|
|
||||||
McMMOPlayerCatalysisEvent event = new McMMOPlayerCatalysisEvent(player, catalysis);
|
McMMOPlayerCatalysisEvent event = new McMMOPlayerCatalysisEvent(player, catalysis);
|
||||||
mcMMO.p.getServer().getPluginManager().callEvent(event);
|
mcMMO.p.getServer().getPluginManager().callEvent(event);
|
||||||
|
|
||||||
if (!event.isCancelled()) {
|
if (!event.isCancelled()) {
|
||||||
brewSpeed = catalysis;
|
brewSpeed = catalysis;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Alchemy.brewingStandMap.containsKey(brewingStand)) {
|
if (Alchemy.brewingStandMap.containsKey(location)) {
|
||||||
Alchemy.brewingStandMap.get(brewingStand).cancel();
|
Alchemy.brewingStandMap.get(location).cancel();
|
||||||
}
|
}
|
||||||
|
|
||||||
Alchemy.brewingStandMap.put(brewingStand, this);
|
Alchemy.brewingStandMap.put(location, this);
|
||||||
this.runTaskTimer(mcMMO.p, 1, 1);
|
this.runTaskTimer(mcMMO.p, 1, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if (player == null || !player.isValid() || brewingStand == null || brewingStand.getType() != Material.BREWING_STAND) {
|
if (player == null || !player.isValid() || brewingStand == null || brewingStand.getType() != Material.BREWING_STAND) {
|
||||||
if (Alchemy.brewingStandMap.containsKey(brewingStand)) {
|
if (Alchemy.brewingStandMap.containsKey(location)) {
|
||||||
Alchemy.brewingStandMap.remove(brewingStand);
|
Alchemy.brewingStandMap.remove(location);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.cancel();
|
this.cancel();
|
||||||
@@ -87,20 +87,20 @@ public class AlchemyBrewTask extends BukkitRunnable {
|
|||||||
AlchemyPotionBrewer.finishBrewing(brewingStand, player, false);
|
AlchemyPotionBrewer.finishBrewing(brewingStand, player, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
Alchemy.brewingStandMap.remove(brewingStand);
|
Alchemy.brewingStandMap.remove(location);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void finishImmediately() {
|
public void finishImmediately() {
|
||||||
this.cancel();
|
this.cancel();
|
||||||
|
|
||||||
AlchemyPotionBrewer.finishBrewing(brewingStand, player, true);
|
AlchemyPotionBrewer.finishBrewing(brewingStand, player, true);
|
||||||
Alchemy.brewingStandMap.remove(brewingStand);
|
Alchemy.brewingStandMap.remove(location);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void cancelBrew() {
|
public void cancelBrew() {
|
||||||
this.cancel();
|
this.cancel();
|
||||||
|
|
||||||
((BrewingStand) brewingStand).setBrewingTime(-1);
|
((BrewingStand) brewingStand).setBrewingTime(-1);
|
||||||
Alchemy.brewingStandMap.remove(brewingStand);
|
Alchemy.brewingStandMap.remove(location);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user