mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2026-02-18 09:43:00 +01:00
Compare commits
196 Commits
1.4.07-bet
...
1.4.07
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5da66f05d4 | ||
|
|
134e0db2e9 | ||
|
|
b3415ee2f4 | ||
|
|
14175a6dfd | ||
|
|
7b3fb46a9a | ||
|
|
0aea165a8f | ||
|
|
17b7a9bf10 | ||
|
|
bd611ee11c | ||
|
|
c6ca65f5c9 | ||
|
|
95f15e68fe | ||
|
|
89dabaeb43 | ||
|
|
c2e100b1e3 | ||
|
|
9f33c6cef1 | ||
|
|
7e241e3993 | ||
|
|
bc51505150 | ||
|
|
e0599a0dea | ||
|
|
d410251595 | ||
|
|
810c74dc2a | ||
|
|
100f2c7e56 | ||
|
|
e13e5295e8 | ||
|
|
b100b7bcc7 | ||
|
|
f4ff8518c2 | ||
|
|
dbd27b641e | ||
|
|
4a428a47af | ||
|
|
3252137ed7 | ||
|
|
68c4b99d1b | ||
|
|
f282891d0a | ||
|
|
7f4e3fedb3 | ||
|
|
2042e0cdbd | ||
|
|
2662fee9fb | ||
|
|
e8e2dcff46 | ||
|
|
3b09012b35 | ||
|
|
a774733af4 | ||
|
|
4a7e1e2b94 | ||
|
|
b8c1f868f5 | ||
|
|
3f56a8fbcf | ||
|
|
d8e86d0fc7 | ||
|
|
e125700b43 | ||
|
|
819a1c62ed | ||
|
|
4bc446e306 | ||
|
|
7f2f15d88e | ||
|
|
be4736fffd | ||
|
|
b4f4de4628 | ||
|
|
b9c652ef2b | ||
|
|
bf4e8d43ea | ||
|
|
468fbdab56 | ||
|
|
309dfd50cd | ||
|
|
44e3e4d1e1 | ||
|
|
476f426590 | ||
|
|
766f1f4127 | ||
|
|
b3cf9bf839 | ||
|
|
056f7cc93b | ||
|
|
741f629ab8 | ||
|
|
dd64c4008b | ||
|
|
3a5de8e2ce | ||
|
|
2d78c0738d | ||
|
|
77617ebee2 | ||
|
|
67e9d9c535 | ||
|
|
800786111c | ||
|
|
ed8197bd50 | ||
|
|
82f8c4ce36 | ||
|
|
b1cf7d0348 | ||
|
|
ae77313007 | ||
|
|
49cbaad47f | ||
|
|
1d96ed72dc | ||
|
|
ec378d046f | ||
|
|
a25dc24c6c | ||
|
|
68eb51a3d0 | ||
|
|
2eda3a9c83 | ||
|
|
ad8e200a84 | ||
|
|
0c83bf2a80 | ||
|
|
6eaec5ffab | ||
|
|
8a2c5fb051 | ||
|
|
9485869014 | ||
|
|
e1bf55b077 | ||
|
|
81140824e4 | ||
|
|
d5545de81f | ||
|
|
8632baed27 | ||
|
|
9aaea7e44f | ||
|
|
c2f8f4d016 | ||
|
|
5131e74349 | ||
|
|
3927427b5b | ||
|
|
4aef4c63fc | ||
|
|
fb4777e7f0 | ||
|
|
d8f3a54f9b | ||
|
|
de964a3a60 | ||
|
|
ce3bc07aa8 | ||
|
|
5a6bb363cf | ||
|
|
3f9c98d72e | ||
|
|
96b54387fe | ||
|
|
70eb67dd6a | ||
|
|
77f9f40065 | ||
|
|
14ae1a69c4 | ||
|
|
c9858dfd49 | ||
|
|
f75fe3cc89 | ||
|
|
c19ccbccac | ||
|
|
2f90e533a5 | ||
|
|
0cd0919447 | ||
|
|
e8b886fcc6 | ||
|
|
b8e937a234 | ||
|
|
eb2e0d3abf | ||
|
|
3365da7f8d | ||
|
|
a0e37a4a09 | ||
|
|
5541c15753 | ||
|
|
f87110749e | ||
|
|
a0ef0d5708 | ||
|
|
2e2abcd645 | ||
|
|
6baf820afa | ||
|
|
288287badf | ||
|
|
ca4feca073 | ||
|
|
7c9356955e | ||
|
|
57541ec233 | ||
|
|
9c6d1ce020 | ||
|
|
c72ead9d0a | ||
|
|
4262a1b2a5 | ||
|
|
eb589b6e78 | ||
|
|
98e5e53fda | ||
|
|
00918fbdc1 | ||
|
|
5ad0f2c624 | ||
|
|
babb9baa2b | ||
|
|
45143836e5 | ||
|
|
ceacd7dc52 | ||
|
|
6eb255632f | ||
|
|
3a37d0e092 | ||
|
|
4c7fb1854d | ||
|
|
763cff6898 | ||
|
|
fa34d06341 | ||
|
|
1ca53da0e2 | ||
|
|
57dfa00541 | ||
|
|
36ae84eada | ||
|
|
7f290504ad | ||
|
|
92b4be9a01 | ||
|
|
8cb8dea642 | ||
|
|
a63f745c73 | ||
|
|
4a0fee5796 | ||
|
|
cf90236e57 | ||
|
|
fc6c7bb1de | ||
|
|
1b92131ce9 | ||
|
|
792ecd6aad | ||
|
|
933b6f278b | ||
|
|
45dfc13ebd | ||
|
|
1254ab232a | ||
|
|
b49e56c857 | ||
|
|
d5bd9a1693 | ||
|
|
9b60cd96f9 | ||
|
|
0a05ed98d0 | ||
|
|
6a3a564bd4 | ||
|
|
3828f78480 | ||
|
|
239d7e33cb | ||
|
|
b8c479549c | ||
|
|
0a9fd4a92e | ||
|
|
4c96161acb | ||
|
|
ce7a7a31a7 | ||
|
|
834e26b44e | ||
|
|
f71b302f6f | ||
|
|
566a381e95 | ||
|
|
5d7d779a49 | ||
|
|
59a35b170c | ||
|
|
14eb473355 | ||
|
|
a8e23e08ee | ||
|
|
15f5dcf860 | ||
|
|
9be9908a22 | ||
|
|
446b6c107b | ||
|
|
5a3f8ad15f | ||
|
|
3a2c6a0827 | ||
|
|
e865acd871 | ||
|
|
4a0e1ba444 | ||
|
|
1a88b0b944 | ||
|
|
e0592b3f62 | ||
|
|
1ec55c2d7e | ||
|
|
6427a7dcdf | ||
|
|
7bac0e2ca5 | ||
|
|
e8bc2475c3 | ||
|
|
816b08b14a | ||
|
|
64e1448782 | ||
|
|
ae0a27991b | ||
|
|
f1b82dcbe6 | ||
|
|
bfbd50d8f4 | ||
|
|
de07316261 | ||
|
|
eae196c6a1 | ||
|
|
8af41975ff | ||
|
|
957bbbc9b2 | ||
|
|
17faf1561f | ||
|
|
ec6419f0ff | ||
|
|
f6e60bebcc | ||
|
|
797ac20567 | ||
|
|
3bc029a0de | ||
|
|
4eba33a1c6 | ||
|
|
800a452d62 | ||
|
|
177604e94a | ||
|
|
088015dd4d | ||
|
|
0f2d0aee5f | ||
|
|
1004e2a32b | ||
|
|
5c2b523f7a | ||
|
|
de42063171 | ||
|
|
a49d373af0 |
@@ -7,7 +7,12 @@ Key:
|
||||
! Change
|
||||
- Removal
|
||||
|
||||
Version 1.4.07-dev
|
||||
Version 1.4.07
|
||||
+ Added XP boost to Acrobatics when wearing Boots of Feather Falling
|
||||
+ Added SQL Database can now recover from a dropped connection without losing data. (Thanks Riking!)
|
||||
+ Added more tiers to Fishing, Repair and Smelting!
|
||||
+ Added Carrot on a Stick and Flint & Steel to repair.vanilla.yml
|
||||
+ Added horses to the "Shake" ability
|
||||
+ Added ability to summon horses via "Call of the Wild" using apples
|
||||
+ Added XP gain to Taming for horses
|
||||
+ Added new permission nodes to allow more control over Taming and "Call of the Wild"
|
||||
@@ -22,6 +27,16 @@ Version 1.4.07-dev
|
||||
+ Added new McMMOPlayerDeathPenaltyEvent, fired when a player dies and would lose levels
|
||||
+ Added new McMMOPlayerLevelChangeEvent, fired when a players level changes
|
||||
+ Added new McMMOPlayerLevelDownEvent, fired when a player loses levels
|
||||
+ Added ability to give custom names to items in treasures.yml - use the key "Custom_Name" to set, expects a string.
|
||||
+ Added ability to give lore to items in treasures.yml - use the key "Lore" to set, expects a list of strings.
|
||||
+ Added Quartz and Name Tags to the default Excavation treasures
|
||||
+ Added a warning message if the server is running NoCheatPlus without CompatNoCheatPlus
|
||||
+ Added cooldown to commands with heavy database access to prevent denial of service
|
||||
+ Added /mcscoreboard keep, to keep the scoreboard up forever
|
||||
+ Added Rainbow Mode to scoreboards
|
||||
+ Added new /mccooldowns command to show all ability cooldowns
|
||||
+ Commands may now both print text and display a scoreboard
|
||||
+ Killing a custom entity will automatically add it to the custom entity config file with default values.
|
||||
= Fixed bug which allowed players to bypass fishing's exploit prevention
|
||||
= Fixed bug where FakeEntityDamageByEntityEvent wasn't being fired
|
||||
= Fixed bug with "Skull Splitter" not finding the locale string
|
||||
@@ -32,22 +47,42 @@ Version 1.4.07-dev
|
||||
= Fixed a bug where teleport location was never reset if warmup was set to 0 for "Chimaera Wing".
|
||||
= Fixed a bug where the "Dodge" DamageModifier wasn't being read from advanced.yml
|
||||
= Fixed a bug where squid were not awarding XP.
|
||||
= Fixed a bug where Combat XP was granted within 5 seconds for respawned players
|
||||
= Fixed a bug where wrong feedback messages were being send when using a command on an offline player
|
||||
= Fixed a bug where players were able to gain Herbalism XP in mine carts, even though Prevent_AFK_Leveling was enabled
|
||||
= Fixed a bug where players would get hit by fireworks if they leveled up while in a boat
|
||||
! Changed Fishing "Treasure Hunter" and "Magic Hunter" drop percentages
|
||||
! Changed format of mod config files. (blocks.yml, tools.yml, armor.yml and entities.yml) **YOU WILL NEED TO UPDATE YOUR FILE TO THE NEW FORMAT**
|
||||
! Changed format of treasures.yml. **YOU WILL NEED TO UPDATE YOUR FILE TO THE NEW FORMAT**
|
||||
! Changed format of repair.vanilla.yml. **YOU WILL NEED TO UPDATE YOUR FILE TO THE NEW FORMAT**
|
||||
! Changed default XP multiplier for repairing shears
|
||||
! Changed "Shake" drops for Witches. They no longer drop water bottles, since they no longer drop them in Vanilla.
|
||||
! Changed fishing exploit prevention, by default it will no longer send global sounds, effects and messages.
|
||||
! Changed Hardcore modes, they will also subtract experience
|
||||
! Changed various values to double in advanced.yml for the sake of consistency.
|
||||
! Nerfed Fishing "Master Angler" (removed skill level based bonus) and also made the modifiers configurable
|
||||
! Nerfed Archery damage to eliminate constant one-hit kills.
|
||||
! Changed the way Repair hands out XP, also added config options to control Repair XP
|
||||
! Changed Swords "Counter Attack" ability from passive to active. Blocking is required to activate.
|
||||
! Hardcore mode can now be toggled for each skill individually
|
||||
! Hardcore modes can now be toggled for each skill individually
|
||||
! Vampirism can now be enabled without having Skill Death Penalty enabled
|
||||
! Admin and Party chat prefixes are now customizable
|
||||
! Changed the color of party leader names in Party chat
|
||||
! Improved "Tree Feller" algorithm (Thanks Riking!)
|
||||
! Improved AFK Acrobatics prevention mechanism
|
||||
! Improved profile saving
|
||||
! Improved partial name matcher
|
||||
! Slightly improved update checker feedback
|
||||
! Improved update checker
|
||||
! Updated localization files
|
||||
! Party item share category states are now saved when the server shuts down.
|
||||
! When using "Super Breaker" or "Giga Driller" abilities extra tool durability is used (again)
|
||||
! Mob healthbars are automatically disabled when the plugin "HealthBar" is found
|
||||
! Massively improved scoreboard handling
|
||||
! Reworked scoreboard configuration (config.yml) - **you will need to update**
|
||||
- The /mmoupdate command has been removed. It is replaced by /mcconvert database
|
||||
- Removed Abilities.Tools.Durability_Loss_Enabled, set Abilities.Tools.Durability_Loss to 0 to disable instead.
|
||||
- Removed Skills.Fishing.Shake_UnlockLevel from advanced.yml, now using Skills.Fishing.Rank_Levels.Rank_1 instead.
|
||||
- Removed SpoutPlugin support
|
||||
|
||||
Version 1.4.06
|
||||
+ Added "Ice Fishing" ability to Fishing
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
## The RPG lovers mod
|
||||
|
||||
### Dev builds
|
||||
Our latest development builds are available [here](http://ci.mcmmo.info).
|
||||
Our latest development builds are available ~~[here](http://ci.mcmmo.info)~~. Unfortunately, the mcMMO site is down; a temporary dev build location is hosted [here](http://ci.ecocitycraft.com/job/mcMMO/).
|
||||
|
||||
### Brief Description
|
||||
The goal of mcMMO is to take core Minecraft game mechanics and expand them into add an extensive and quality RPG experience. Everything in mcMMO has been carefully thought out and is constantly being improved upon. Currently, mcMMO adds thirteen unique skills to train and level in. Each of these skills is highly customizable through our configuration files, allowing server admins to tweak mcMMO to best suit the needs of his or her server. Additionally, when run in conjuction with SpoutPlugin, mcMMO also has a custom XP bar to allow for easy tracking of progress towards leveling up. Know that the mcMMO team is dedicated to providing an ever-evolving experience, and that we carefully read all feedback and bug reports in order to evaluate and balance the mechanics of mcMMO in every update.
|
||||
The goal of mcMMO is to take core Minecraft game mechanics and expand them into add an extensive and quality RPG experience. Everything in mcMMO has been carefully thought out and is constantly being improved upon. Currently, mcMMO adds thirteen unique skills to train and level in. Each of these skills is highly customizable through our configuration files, allowing server admins to tweak mcMMO to best suit the needs of his or her server. Know that the mcMMO team is dedicated to providing an ever-evolving experience, and that we carefully read all feedback and bug reports in order to evaluate and balance the mechanics of mcMMO in every update.
|
||||
|
||||
## About the Team
|
||||
|
||||
@@ -29,15 +29,16 @@ mcMMO is currently developed by a team of individuals from all over the world.
|
||||
(https://github.com/TfT-02)
|
||||
[]
|
||||
(https://github.com/t00thpick1)
|
||||
[]
|
||||
(https://github.com/riking)
|
||||
|
||||
## Compiling
|
||||
|
||||
mcMMO uses Maven 3 to manage dependancies, packaging, and shading of necessary classes; Maven 3 is required to compile mcMMO.
|
||||
|
||||
The typical command used to build mcMMO is: mvn clean package install
|
||||
The typical command used to build mcMMO is: `mvn clean package install`
|
||||
|
||||
Required Libraries:
|
||||
* Spout API
|
||||
* JUnit
|
||||
* EMetrics
|
||||
* Bukkit
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
#
|
||||
# Repair configuration
|
||||
# Last updated on ${project.version}-b${BUILD_NUMBER}
|
||||
#
|
||||
# Any file named repair.*.yml in the mcmmmo folder will be loaded as a repair config
|
||||
# All repair configs have a main section titled "Repairables"
|
||||
# Afterwards, all sub-items are considered a Repairable to be loaded
|
||||
# The bare minimum of a Repairable is that it have an ItemId, a RepairMaterialId, and a MaximumDurability
|
||||
#
|
||||
# ItemId: This is the id of the item to be repairable.
|
||||
## This is required to be set.
|
||||
# Afterwards, all sub-items are considered a Repairable to be loaded. The names of each subitem should be the exact material name.
|
||||
# The bare minimum of a Repairable is that it have a RepairMaterial and a MaximumDurability
|
||||
#
|
||||
# ItemType: This is the type of item to be repaired, this is only important to permissions.
|
||||
## Valid values are ARMOR, TOOL, and OTHER.
|
||||
@@ -15,7 +15,7 @@
|
||||
## Valid values are STRING, LEATHER, WOOD, STONE, IRON, GOLD, DIAMOND, and OTHER
|
||||
## This defaults to OTHER.
|
||||
#
|
||||
# RepairMaterialId: This is the id of the item used to repair this repairable.
|
||||
# RepairMaterial: This is the material name of the item used to repair this repairable.
|
||||
## This is required to be set.
|
||||
#
|
||||
# RepairMaterialMetadata: This is the metadata of the item used to repair this repairable.
|
||||
@@ -26,7 +26,7 @@
|
||||
## This is required to be set.
|
||||
#
|
||||
# MinimumLevel: This is the minimum repair level needed to repair this item.
|
||||
## Valid values are > 0
|
||||
## Valid values are => 0
|
||||
## This defaults to 0
|
||||
#
|
||||
# MinimumQuantity: This is the minimum number of items needed to repair this item ignoring all other repair bonuses.
|
||||
@@ -42,32 +42,19 @@
|
||||
#
|
||||
###
|
||||
Repairables:
|
||||
ChainHelmet:
|
||||
ItemId: 302
|
||||
ItemType: ARMOR
|
||||
RepairMaterialId: 51
|
||||
MaximumDurability: 165
|
||||
MinimumQuantity: 5
|
||||
#
|
||||
# Chainmail repairables
|
||||
###
|
||||
# Armor
|
||||
CHAINMAIL_HELMET:
|
||||
RepairMaterial: FIRE
|
||||
XpMultiplier: 2
|
||||
ChainChest:
|
||||
ItemId: 303
|
||||
ItemType: ARMOR
|
||||
RepairMaterialId: 51
|
||||
MaximumDurability: 240
|
||||
MinimumQuantity: 8
|
||||
CHAINMAIL_CHESTPLATE:
|
||||
RepairMaterial: FIRE
|
||||
XpMultiplier: 2
|
||||
ChainLegs:
|
||||
ItemId: 304
|
||||
ItemType: ARMOR
|
||||
RepairMaterialId: 51
|
||||
MaximumDurability: 225
|
||||
MinimumQuantity: 7
|
||||
CHAINMAIL_LEGGINGS:
|
||||
RepairMaterial: FIRE
|
||||
XpMultiplier: 2
|
||||
ChainBoots:
|
||||
ItemId: 305
|
||||
ItemType: ARMOR
|
||||
RepairMaterialId: 51
|
||||
RepairMaterialMetadata: -1
|
||||
MaximumDurability: 195
|
||||
MinimumQuantity: 4
|
||||
CHAINMAIL_BOOTS:
|
||||
RepairMaterial: FIRE
|
||||
XpMultiplier: 2
|
||||
|
||||
57
pom.xml
57
pom.xml
@@ -2,7 +2,7 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.gmail.nossr50.mcMMO</groupId>
|
||||
<artifactId>mcMMO</artifactId>
|
||||
<version>1.4.07-beta1</version>
|
||||
<version>1.4.07</version>
|
||||
<name>mcMMO</name>
|
||||
<url>https://github.com/mcMMO-Dev/mcMMO</url>
|
||||
<issueManagement>
|
||||
@@ -22,38 +22,6 @@
|
||||
<include>.jenkins</include>
|
||||
</includes>
|
||||
</resource>
|
||||
<resource>
|
||||
<targetPath>resources</targetPath>
|
||||
<filtering>false</filtering>
|
||||
<directory>${basedir}/src/main/resources/xpbar/</directory>
|
||||
<includes>
|
||||
<include>xpbar*.png</include>
|
||||
</includes>
|
||||
</resource>
|
||||
<resource>
|
||||
<targetPath>resources</targetPath>
|
||||
<filtering>false</filtering>
|
||||
<directory>${basedir}/src/main/resources/healthbar/</directory>
|
||||
<includes>
|
||||
<include>health*.png</include>
|
||||
</includes>
|
||||
</resource>
|
||||
<resource>
|
||||
<targetPath>resources</targetPath>
|
||||
<filtering>false</filtering>
|
||||
<directory>${basedir}/src/main/resources/skillicon/</directory>
|
||||
<includes>
|
||||
<include>*.png</include>
|
||||
</includes>
|
||||
</resource>
|
||||
<resource>
|
||||
<targetPath>resources</targetPath>
|
||||
<filtering>false</filtering>
|
||||
<directory>${basedir}/src/main/resources/sound/</directory>
|
||||
<includes>
|
||||
<include>*.wav</include>
|
||||
</includes>
|
||||
</resource>
|
||||
<resource>
|
||||
<targetPath>com/gmail/nossr50/locale</targetPath>
|
||||
<filtering>true</filtering>
|
||||
@@ -62,6 +30,14 @@
|
||||
<include>locale*.properties</include>
|
||||
</includes>
|
||||
</resource>
|
||||
<resource>
|
||||
<targetPath>mods</targetPath>
|
||||
<filtering>true</filtering>
|
||||
<directory>${basedir}/src/main/resources/mods</directory>
|
||||
<includes>
|
||||
<include>*.yml</include>
|
||||
</includes>
|
||||
</resource>
|
||||
</resources>
|
||||
<plugins>
|
||||
<plugin>
|
||||
@@ -132,10 +108,6 @@
|
||||
<id>bukkit-repo</id>
|
||||
<url>http://repo.bukkit.org/content/groups/public/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>spout-repo</id>
|
||||
<url>http://nexus.spout.org/content/groups/public/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>Plugin MetricsExtension</id>
|
||||
<url>http://repo.turt2live.com</url>
|
||||
@@ -149,13 +121,6 @@
|
||||
<type>jar</type>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.getspout</groupId>
|
||||
<artifactId>spoutplugin</artifactId>
|
||||
<version>LATEST</version>
|
||||
<type>jar</type>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit-dep</artifactId>
|
||||
@@ -178,7 +143,7 @@
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
<ciManagement>
|
||||
<system>Jenkins</system>
|
||||
<url>ci.mcmmo.org</url>
|
||||
<system>Jenkins</system>
|
||||
<url>http://ci.ecocitycraft.com/job/mcMMO</url>
|
||||
</ciManagement>
|
||||
</project>
|
||||
|
||||
@@ -48,6 +48,11 @@ public final class ExperienceAPI {
|
||||
return !skill.isChildSkill();
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static void addRawXP(Player player, String skillType, int XP) {
|
||||
addRawXP(player, skillType, (float) XP);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds raw XP to the player.
|
||||
* </br>
|
||||
@@ -59,10 +64,15 @@ public final class ExperienceAPI {
|
||||
*
|
||||
* @throws InvalidSkillException if the given skill is not valid
|
||||
*/
|
||||
public static void addRawXP(Player player, String skillType, int XP) {
|
||||
public static void addRawXP(Player player, String skillType, float XP) {
|
||||
UserManager.getPlayer(player).applyXpGain(getSkillType(skillType), XP);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static void addRawXPOffline(String playerName, String skillType, int XP) {
|
||||
addRawXPOffline(playerName, skillType, (float) XP);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds raw XP to an offline player.
|
||||
* </br>
|
||||
@@ -75,8 +85,8 @@ public final class ExperienceAPI {
|
||||
* @throws InvalidSkillException if the given skill is not valid
|
||||
* @throws InvalidPlayerException if the given player does not exist in the database
|
||||
*/
|
||||
public static void addRawXPOffline(String playerName, String skillType, int XP) {
|
||||
addOfflineXP(playerName, getSkillType(skillType), XP);
|
||||
public static void addRawXPOffline(String playerName, String skillType, float XP) {
|
||||
addOfflineXP(playerName, getSkillType(skillType), (int) Math.floor(XP));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -404,7 +414,7 @@ public final class ExperienceAPI {
|
||||
int powerLevel = 0;
|
||||
PlayerProfile profile = getOfflineProfile(playerName);
|
||||
|
||||
for (SkillType type : SkillType.nonChildSkills()) {
|
||||
for (SkillType type : SkillType.NON_CHILD_SKILLS) {
|
||||
powerLevel += profile.getSkillLevel(type);
|
||||
}
|
||||
|
||||
@@ -451,7 +461,7 @@ public final class ExperienceAPI {
|
||||
* @return the position on the leaderboard
|
||||
*/
|
||||
public static int getPlayerRankSkill(String playerName, String skillType) {
|
||||
return mcMMO.getDatabaseManager().readRank(getOfflineProfile(playerName).getPlayerName()).get(getNonChildSkillType(skillType).toString());
|
||||
return mcMMO.getDatabaseManager().readRank(getOfflineProfile(playerName).getPlayerName()).get(getNonChildSkillType(skillType));
|
||||
}
|
||||
|
||||
|
||||
@@ -467,7 +477,7 @@ public final class ExperienceAPI {
|
||||
* @return the position on the power level leaderboard
|
||||
*/
|
||||
public static int getPlayerRankOverall(String playerName) {
|
||||
return mcMMO.getDatabaseManager().readRank(getOfflineProfile(playerName).getPlayerName()).get("ALL");
|
||||
return mcMMO.getDatabaseManager().readRank(getOfflineProfile(playerName).getPlayerName()).get(null);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,29 +0,0 @@
|
||||
package com.gmail.nossr50.api;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.config.spout.SpoutConfig;
|
||||
import com.gmail.nossr50.datatypes.spout.huds.HudType;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
|
||||
public class SpoutHudAPI {
|
||||
private SpoutHudAPI() {}
|
||||
|
||||
/**
|
||||
* Disable the mcMMO XP bar for a player.
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*/
|
||||
public static void disableXpBar(Player player) {
|
||||
UserManager.getPlayer(player).getProfile().setHudType(HudType.DISABLED);
|
||||
}
|
||||
|
||||
/**
|
||||
* Disable the mcMMO XP bar for the server.
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*/
|
||||
public static void disableXpBar() {
|
||||
SpoutConfig.getInstance().setXPBarEnabled(false);
|
||||
}
|
||||
}
|
||||
@@ -1,53 +0,0 @@
|
||||
package com.gmail.nossr50.api;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import com.gmail.nossr50.datatypes.skills.ToolType;
|
||||
|
||||
public final class SpoutToolsAPI {
|
||||
public static final List<ItemStack> spoutSwords = new ArrayList<ItemStack>();
|
||||
public static final List<ItemStack> spoutAxes = new ArrayList<ItemStack>();
|
||||
public static final List<ItemStack> spoutPickaxes = new ArrayList<ItemStack>();
|
||||
public static final List<ItemStack> spoutHoes = new ArrayList<ItemStack>();
|
||||
public static final List<ItemStack> spoutShovels = new ArrayList<ItemStack>();
|
||||
|
||||
private SpoutToolsAPI() {}
|
||||
|
||||
/**
|
||||
* Add a custom Spout tool to mcMMO for XP gain & ability use.
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param spoutTool The tool to add
|
||||
* @param type The type of tool to add
|
||||
*/
|
||||
public static void addCustomTool(ItemStack spoutTool, ToolType type) {
|
||||
switch (type) {
|
||||
case AXE:
|
||||
spoutAxes.add(spoutTool);
|
||||
break;
|
||||
|
||||
case HOE:
|
||||
spoutHoes.add(spoutTool);
|
||||
break;
|
||||
|
||||
case PICKAXE:
|
||||
spoutPickaxes.add(spoutTool);
|
||||
break;
|
||||
|
||||
case SHOVEL:
|
||||
spoutShovels.add(spoutTool);
|
||||
break;
|
||||
|
||||
case SWORD:
|
||||
spoutSwords.add(spoutTool);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -27,7 +27,7 @@ public class PartyChatManager extends ChatManager {
|
||||
@Override
|
||||
protected void sendMessage() {
|
||||
if (Config.getInstance().getPartyChatColorLeaderName() && senderName.equalsIgnoreCase(party.getLeader())) {
|
||||
message = message.replaceAll(displayName, ChatColor.GOLD + displayName + ChatColor.RESET);
|
||||
message = message.replaceFirst(displayName, ChatColor.GOLD + displayName + ChatColor.RESET);
|
||||
}
|
||||
|
||||
for (Player member : party.getOnlineMembers()) {
|
||||
|
||||
@@ -24,6 +24,6 @@ public class McabilityCommand extends ToggleCommand {
|
||||
|
||||
@Override
|
||||
protected void sendSuccessMessage(CommandSender sender) {
|
||||
sender.sendMessage("Ability use has been toggled for " + player.getName()); // TODO: Localize
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Ability.Toggle"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,6 +24,6 @@ public class McgodCommand extends ToggleCommand {
|
||||
|
||||
@Override
|
||||
protected void sendSuccessMessage(CommandSender sender) {
|
||||
sender.sendMessage("God mode has been toggled for " + player.getName()); // TODO: Localize
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.GodMode.Success"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,14 +4,13 @@ import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.commands.party.PartySubcommandType;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.HolidayManager;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.spout.SpoutUtils;
|
||||
|
||||
public class McmmoCommand implements CommandExecutor {
|
||||
@Override
|
||||
@@ -28,16 +27,12 @@ public class McmmoCommand implements CommandExecutor {
|
||||
sender.sendMessage(mcSplit);
|
||||
|
||||
if (Config.getInstance().getDonateMessageEnabled()) {
|
||||
if (mcMMO.isSpoutEnabled() && sender instanceof Player) {
|
||||
SpoutUtils.sendDonationNotification((Player) sender);
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(LocaleLoader.getString("MOTD.Donate"));
|
||||
sender.sendMessage(ChatColor.GOLD + " - " + ChatColor.GREEN + "gjmcferrin@gmail.com" + ChatColor.GOLD + " Paypal");
|
||||
}
|
||||
sender.sendMessage(LocaleLoader.getString("MOTD.Donate"));
|
||||
sender.sendMessage(ChatColor.GOLD + " - " + ChatColor.GREEN + "gjmcferrin@gmail.com" + ChatColor.GOLD + " Paypal");
|
||||
}
|
||||
|
||||
sender.sendMessage(LocaleLoader.getString("MOTD.Version", mcMMO.p.getDescription().getVersion()));
|
||||
HolidayManager.anniversaryCheck(sender);
|
||||
return true;
|
||||
|
||||
case 1:
|
||||
|
||||
@@ -2,141 +2,79 @@ package com.gmail.nossr50.commands;
|
||||
|
||||
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 org.bukkit.util.StringUtil;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.util.StringUtils;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
import com.gmail.nossr50.util.scoreboards.ScoreboardManager;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
public class McscoreboardCommand implements TabExecutor {
|
||||
private static final List<String> SCOREBOARD_TYPES = ImmutableList.of("clear", "rank", "stats", "top");
|
||||
private static final List<String> FIRST_ARGS = ImmutableList.of("keep", "time", "clear", "reset");
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (CommandUtils.noConsoleUsage(sender)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
Player player = (Player) sender;
|
||||
|
||||
switch (args.length) {
|
||||
case 0:
|
||||
clearScoreboard(player);
|
||||
return true;
|
||||
|
||||
case 1:
|
||||
if (args[0].equalsIgnoreCase("clear")) {
|
||||
clearScoreboard(player);
|
||||
}
|
||||
else if (args[0].equalsIgnoreCase("rank")) {
|
||||
if (!Config.getInstance().getMcrankScoreboardEnabled()) {
|
||||
sender.sendMessage("This scoreboard is not enabled."); //TODO: Localize
|
||||
return true;
|
||||
}
|
||||
|
||||
ScoreboardManager.setupPlayerScoreboard(player.getName());
|
||||
ScoreboardManager.enablePlayerRankScoreboard(player);
|
||||
}
|
||||
else if (args[0].equalsIgnoreCase("stats")) {
|
||||
if (!Config.getInstance().getMcstatsScoreboardsEnabled()) {
|
||||
sender.sendMessage("This scoreboard is not enabled."); //TODO: Localize
|
||||
return true;
|
||||
}
|
||||
|
||||
ScoreboardManager.setupPlayerScoreboard(player.getName());
|
||||
ScoreboardManager.enablePlayerStatsScoreboard(UserManager.getPlayer(player));
|
||||
}
|
||||
else if (args[0].equalsIgnoreCase("top")) {
|
||||
if (!Config.getInstance().getMctopScoreboardEnabled()) {
|
||||
sender.sendMessage("This scoreboard is not enabled."); //TODO: Localize
|
||||
return true;
|
||||
}
|
||||
|
||||
ScoreboardManager.enableGlobalStatsScoreboard(player, "all", 1);
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
case 2:
|
||||
if (!args[0].equalsIgnoreCase("top")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!Config.getInstance().getMctopScoreboardEnabled()) {
|
||||
sender.sendMessage("This scoreboard is not enabled."); //TODO: Localize
|
||||
return true;
|
||||
}
|
||||
|
||||
if (StringUtils.isInt(args[1])) {
|
||||
ScoreboardManager.enableGlobalStatsScoreboard(player, "all", Math.abs(Integer.parseInt(args[1])));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (CommandUtils.isInvalidSkill(sender, args[1])) {
|
||||
return true;
|
||||
}
|
||||
|
||||
ScoreboardManager.enableGlobalStatsScoreboard(player, args[1], 1);
|
||||
return true;
|
||||
|
||||
case 3:
|
||||
if (!args[0].equalsIgnoreCase("top")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!Config.getInstance().getMctopScoreboardEnabled()) {
|
||||
sender.sendMessage("This scoreboard is not enabled."); //TODO: Localize
|
||||
return true;
|
||||
}
|
||||
|
||||
if (CommandUtils.isInvalidSkill(sender, args[1])) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (CommandUtils.isInvalidInteger(sender, args[2])) {
|
||||
return true;
|
||||
}
|
||||
|
||||
ScoreboardManager.enableGlobalStatsScoreboard(player, args[1], Math.abs(Integer.parseInt(args[2])));
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
if (args.length == 0) {
|
||||
help(sender);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (args[0].equalsIgnoreCase("clear") || args[0].equalsIgnoreCase("reset")) {
|
||||
ScoreboardManager.clearBoard(sender.getName());
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Scoreboard.Clear"));
|
||||
}
|
||||
else if (args[0].equalsIgnoreCase("keep")) {
|
||||
if (!Config.getInstance().getAllowKeepBoard()) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Disabled"));
|
||||
return true;
|
||||
}
|
||||
if (!ScoreboardManager.isBoardShown(sender.getName())) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Scoreboard.NoBoard"));
|
||||
return true;
|
||||
}
|
||||
ScoreboardManager.keepBoard(sender.getName());
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Scoreboard.Keep"));
|
||||
}
|
||||
else if (args[0].equalsIgnoreCase("time") || args[0].equalsIgnoreCase("timer")) {
|
||||
if (args.length == 1) {
|
||||
help(sender);
|
||||
return true;
|
||||
}
|
||||
if (CommandUtils.isInvalidInteger(sender, args[1])) {
|
||||
return true;
|
||||
}
|
||||
int time = Math.abs(Integer.parseInt(args[1]));
|
||||
ScoreboardManager.setRevertTimer(sender.getName(), time);
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Scoreboard.Timer", time));
|
||||
}
|
||||
else {
|
||||
help(sender);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void help(CommandSender sender) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Scoreboard.Help.0"));
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Scoreboard.Help.1"));
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Scoreboard.Help.2"));
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Scoreboard.Help.3"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
|
||||
switch (args.length) {
|
||||
case 1:
|
||||
return StringUtil.copyPartialMatches(args[0], SCOREBOARD_TYPES, new ArrayList<String>(SCOREBOARD_TYPES.size()));
|
||||
case 2:
|
||||
if (args[0].equalsIgnoreCase("top")) {
|
||||
return StringUtil.copyPartialMatches(args[1], SkillType.SKILL_NAMES, new ArrayList<String>(SkillType.SKILL_NAMES.size()));
|
||||
}
|
||||
// Fallthrough
|
||||
|
||||
return StringUtil.copyPartialMatches(args[0], FIRST_ARGS, new ArrayList<String>(FIRST_ARGS.size()));
|
||||
default:
|
||||
return ImmutableList.of();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void clearScoreboard(Player player) {
|
||||
player.setScoreboard(mcMMO.p.getServer().getScoreboardManager().getMainScoreboard());
|
||||
player.sendMessage("Your scoreboard has been cleared!"); //TODO: Locale
|
||||
return ImmutableList.of();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,9 +12,9 @@ import org.bukkit.util.StringUtil;
|
||||
|
||||
import com.gmail.nossr50.datatypes.MobHealthbarType;
|
||||
import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
public class MobhealthCommand implements TabExecutor {
|
||||
@@ -44,11 +44,11 @@ public class MobhealthCommand implements TabExecutor {
|
||||
try {
|
||||
MobHealthbarType type = MobHealthbarType.valueOf(args[0].toUpperCase().trim());
|
||||
playerProfile.setMobHealthbarType(type);
|
||||
sender.sendMessage("Display type changed to: " + type); //TODO: Localize
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Healthbars.Changed." + type.name()));
|
||||
return true;
|
||||
}
|
||||
catch (IllegalArgumentException ex) {
|
||||
sender.sendMessage("Invalid type!"); //TODO: Localize
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Healthbars.Invalid"));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ public class ConvertDatabaseCommand implements CommandExecutor {
|
||||
DatabaseType previousType = DatabaseType.getDatabaseType(args[1]);
|
||||
DatabaseType newType = mcMMO.getDatabaseManager().getDatabaseType();
|
||||
|
||||
if ((newType == DatabaseType.CUSTOM && DatabaseManagerFactory.getCustomDatabaseManagerClass().getSimpleName().equalsIgnoreCase(args[1])) || previousType == newType) {
|
||||
if (previousType == newType || (newType == DatabaseType.CUSTOM && DatabaseManagerFactory.getCustomDatabaseManagerClass().getSimpleName().equalsIgnoreCase(args[1]))) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.mcconvert.Database.Same", newType.toString()));
|
||||
return true;
|
||||
}
|
||||
@@ -39,17 +39,12 @@ public class ConvertDatabaseCommand implements CommandExecutor {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.mcconvert.Database.InvalidType", args[1]));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.mcconvert.Database.InvalidType", args[1]));
|
||||
return true;
|
||||
}
|
||||
|
||||
try {
|
||||
oldDatabase = DatabaseManagerFactory.createCustomDatabaseManager((Class<? extends DatabaseManager>) clazz);
|
||||
}
|
||||
catch (Throwable t) {
|
||||
sender.sendMessage("An error occurred during the conversion process."); // TODO: Localize
|
||||
catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.mcconvert.Database.InvalidType", args[1]));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ public class McconvertCommand implements TabExecutor {
|
||||
}
|
||||
|
||||
// Custom stuff
|
||||
databaseTypes.remove(DatabaseType.CUSTOM);
|
||||
databaseTypes.remove(DatabaseType.CUSTOM.toString());
|
||||
|
||||
if (mcMMO.getDatabaseManager().getDatabaseType() == DatabaseType.CUSTOM) {
|
||||
databaseTypes.add(DatabaseManagerFactory.getCustomDatabaseManagerClass().getName());
|
||||
|
||||
@@ -2,12 +2,10 @@ package com.gmail.nossr50.commands.experience;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.events.experience.McMMOPlayerLevelUpEvent;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.EventUtils;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||
|
||||
public class AddlevelsCommand extends ExperienceCommand {
|
||||
@Override
|
||||
@@ -22,11 +20,14 @@ public class AddlevelsCommand extends ExperienceCommand {
|
||||
|
||||
@Override
|
||||
protected void handleCommand(SkillType skill) {
|
||||
float xpRemoved = profile.getSkillXpLevelRaw(skill);
|
||||
profile.addLevels(skill, value);
|
||||
|
||||
if (player != null) {
|
||||
mcMMO.p.getServer().getPluginManager().callEvent(new McMMOPlayerLevelUpEvent(player, skill, value));
|
||||
if (player == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
EventUtils.handleLevelChangeEvent(player, skill, value, xpRemoved, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -36,6 +37,6 @@ public class AddlevelsCommand extends ExperienceCommand {
|
||||
|
||||
@Override
|
||||
protected void handlePlayerMessageSkill() {
|
||||
player.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardSkill.1", value, SkillUtils.getSkillName(skill)));
|
||||
player.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardSkill.1", value, skill.getSkillName()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,6 @@ import org.bukkit.command.CommandSender;
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||
|
||||
public class AddxpCommand extends ExperienceCommand {
|
||||
@Override
|
||||
@@ -35,6 +34,6 @@ public class AddxpCommand extends ExperienceCommand {
|
||||
|
||||
@Override
|
||||
protected void handlePlayerMessageSkill() {
|
||||
player.sendMessage(LocaleLoader.getString("Commands.addxp.AwardSkill", value, SkillUtils.getSkillName(skill)));
|
||||
player.sendMessage(LocaleLoader.getString("Commands.addxp.AwardSkill", value, skill.getSkillName()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@ import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
@@ -67,7 +66,7 @@ public abstract class ExperienceCommand implements TabExecutor {
|
||||
}
|
||||
|
||||
String playerName = Misc.getMatchedPlayerName(args[0]);
|
||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(playerName, true);
|
||||
mcMMOPlayer = UserManager.getPlayer(playerName, true);
|
||||
|
||||
// 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) {
|
||||
@@ -149,7 +148,7 @@ public abstract class ExperienceCommand implements TabExecutor {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardAll.2", playerName));
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardSkill.2", SkillUtils.getSkillName(skill), playerName));
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardSkill.2", skill.getSkillName(), playerName));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,13 +2,10 @@ package com.gmail.nossr50.commands.experience;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.events.experience.McMMOPlayerLevelDownEvent;
|
||||
import com.gmail.nossr50.events.experience.McMMOPlayerLevelUpEvent;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.EventUtils;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||
|
||||
public class MmoeditCommand extends ExperienceCommand {
|
||||
@Override
|
||||
@@ -23,20 +20,16 @@ public class MmoeditCommand extends ExperienceCommand {
|
||||
|
||||
@Override
|
||||
protected void handleCommand(SkillType skill) {
|
||||
int skillLevel = profile.getSkillLevel(skill);
|
||||
float xpRemoved = profile.getSkillXpLevelRaw(skill);
|
||||
|
||||
profile.modifySkill(skill, value);
|
||||
|
||||
if (player == null) {
|
||||
if (player == null || value == skillLevel) {
|
||||
return;
|
||||
}
|
||||
|
||||
int skillLevel = profile.getSkillLevel(skill);
|
||||
|
||||
if (value > skillLevel) {
|
||||
mcMMO.p.getServer().getPluginManager().callEvent(new McMMOPlayerLevelUpEvent(player, skill, value - skillLevel));
|
||||
}
|
||||
else if (value < skillLevel) {
|
||||
mcMMO.p.getServer().getPluginManager().callEvent(new McMMOPlayerLevelDownEvent(player, skill, skillLevel - value));
|
||||
}
|
||||
EventUtils.handleLevelChangeEvent(player, skill, value, xpRemoved, value > skillLevel);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -46,6 +39,6 @@ public class MmoeditCommand extends ExperienceCommand {
|
||||
|
||||
@Override
|
||||
protected void handlePlayerMessageSkill() {
|
||||
player.sendMessage(LocaleLoader.getString("Commands.mmoedit.Modified.1", SkillUtils.getSkillName(skill), value));
|
||||
player.sendMessage(LocaleLoader.getString("Commands.mmoedit.Modified.1", skill.getSkillName(), value));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,13 +6,12 @@ import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.events.experience.McMMOPlayerLevelDownEvent;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.EventUtils;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||
|
||||
public class SkillresetCommand extends ExperienceCommand {
|
||||
private CommandSender sender;
|
||||
@@ -103,11 +102,16 @@ public class SkillresetCommand extends ExperienceCommand {
|
||||
return;
|
||||
}
|
||||
|
||||
int levelsRemoved = profile.getSkillLevel(skill);
|
||||
float xpRemoved = profile.getSkillXpLevelRaw(skill);
|
||||
|
||||
profile.modifySkill(skill, 0);
|
||||
|
||||
if (player != null) {
|
||||
mcMMO.p.getServer().getPluginManager().callEvent(new McMMOPlayerLevelDownEvent(player, skill, profile.getSkillLevel(skill)));
|
||||
if (player == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
EventUtils.handleLevelChangeEvent(player, skill, levelsRemoved, xpRemoved, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -117,6 +121,6 @@ public class SkillresetCommand extends ExperienceCommand {
|
||||
|
||||
@Override
|
||||
protected void handlePlayerMessageSkill() {
|
||||
player.sendMessage(LocaleLoader.getString("Commands.Reset.Single", SkillUtils.getSkillName(skill)));
|
||||
player.sendMessage(LocaleLoader.getString("Commands.Reset.Single", skill.getSkillName()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,12 +50,12 @@ public class HardcoreCommand extends HardcoreModeCommand {
|
||||
|
||||
private void toggle(boolean enable) {
|
||||
if (skill.equalsIgnoreCase("ALL")) {
|
||||
for (SkillType skillType : SkillType.nonChildSkills()) {
|
||||
Config.getInstance().setHardcoreStatLossEnabled(skillType, enable);
|
||||
for (SkillType skillType : SkillType.NON_CHILD_SKILLS) {
|
||||
skillType.setHardcoreStatLossEnabled(enable);
|
||||
}
|
||||
}
|
||||
else {
|
||||
Config.getInstance().setHardcoreStatLossEnabled(SkillType.getSkill(skill), enable);
|
||||
SkillType.getSkill(skill).setHardcoreStatLossEnabled(enable);
|
||||
}
|
||||
|
||||
mcMMO.p.getServer().broadcastMessage(LocaleLoader.getString("Hardcore.Mode." + (enable ? "Enabled" : "Disabled"), LocaleLoader.getString("Hardcore.DeathStatLoss.Name"), skill));
|
||||
|
||||
@@ -48,16 +48,16 @@ public class VampirismCommand extends HardcoreModeCommand {
|
||||
sender.sendMessage(LocaleLoader.getString("Hardcore.Vampirism.PercentageChanged", percent.format(newPercent / 100D)));
|
||||
}
|
||||
|
||||
private void toggle(boolean enabled) {
|
||||
private void toggle(boolean enable) {
|
||||
if (skill.equalsIgnoreCase("ALL")) {
|
||||
for (SkillType skillType : SkillType.nonChildSkills()) {
|
||||
Config.getInstance().setHardcoreVampirismEnabled(skillType, enabled);
|
||||
for (SkillType skillType : SkillType.NON_CHILD_SKILLS) {
|
||||
skillType.setHardcoreVampirismEnabled(enable);
|
||||
}
|
||||
}
|
||||
else {
|
||||
Config.getInstance().setHardcoreVampirismEnabled(SkillType.getSkill(skill), enabled);
|
||||
SkillType.getSkill(skill).setHardcoreVampirismEnabled(enable);
|
||||
}
|
||||
|
||||
mcMMO.p.getServer().broadcastMessage(LocaleLoader.getString("Hardcore.Mode." + (enabled ? "Enabled" : "Disabled"), LocaleLoader.getString("Hardcore.Vampirism.Name"), skill));
|
||||
mcMMO.p.getServer().broadcastMessage(LocaleLoader.getString("Hardcore.Mode." + (enable ? "Enabled" : "Disabled"), LocaleLoader.getString("Hardcore.Vampirism.Name"), skill));
|
||||
}
|
||||
}
|
||||
@@ -19,7 +19,7 @@ public class PartyInviteCommand implements CommandExecutor {
|
||||
switch (args.length) {
|
||||
case 2:
|
||||
String targetName = Misc.getMatchedPlayerName(args[1]);
|
||||
McMMOPlayer mcMMOTarget = UserManager.getPlayer(targetName);
|
||||
McMMOPlayer mcMMOTarget = UserManager.getPlayer(targetName, true);
|
||||
|
||||
if (!CommandUtils.checkPlayerExistence(sender, targetName, mcMMOTarget)) {
|
||||
return false;
|
||||
|
||||
@@ -22,7 +22,7 @@ public class PartyKickCommand implements CommandExecutor {
|
||||
OfflinePlayer target = mcMMO.p.getServer().getOfflinePlayer(args[1]);
|
||||
|
||||
if (!playerParty.getMembers().contains(target.getName())) {
|
||||
sender.sendMessage(LocaleLoader.getString("Party.NotInYourParty", args[1]));
|
||||
sender.sendMessage(LocaleLoader.getString("Party.NotInYourParty", target.getName()));
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -34,6 +34,7 @@ public class PartyKickCommand implements CommandExecutor {
|
||||
return true;
|
||||
}
|
||||
|
||||
PartyManager.processPartyLeaving(UserManager.getPlayer(onlineTarget));
|
||||
onlineTarget.sendMessage(LocaleLoader.getString("Commands.Party.Kick", partyName));
|
||||
}
|
||||
|
||||
|
||||
@@ -14,10 +14,10 @@ import org.bukkit.util.StringUtil;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.events.party.McMMOPartyTeleportEvent;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.party.PartyManager;
|
||||
import com.gmail.nossr50.runnables.items.TeleportationWarmup;
|
||||
import com.gmail.nossr50.util.EventUtils;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||
@@ -177,25 +177,7 @@ public class PtpCommand implements TabExecutor {
|
||||
new TeleportationWarmup(mcMMOPlayer, mcMMOTarget).runTaskLater(mcMMO.p, 20 * warmup);
|
||||
}
|
||||
else {
|
||||
handlePartyTeleportEvent(teleportingPlayer, targetPlayer);
|
||||
EventUtils.handlePartyTeleportEvent(teleportingPlayer, targetPlayer);
|
||||
}
|
||||
}
|
||||
|
||||
public static void handlePartyTeleportEvent(Player teleportingPlayer, Player targetPlayer) {
|
||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(teleportingPlayer);
|
||||
McMMOPartyTeleportEvent event = new McMMOPartyTeleportEvent(teleportingPlayer, targetPlayer, mcMMOPlayer.getParty().getName());
|
||||
|
||||
mcMMO.p.getServer().getPluginManager().callEvent(event);
|
||||
|
||||
if (event.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
teleportingPlayer.teleport(targetPlayer);
|
||||
|
||||
teleportingPlayer.sendMessage(LocaleLoader.getString("Party.Teleport.Player", targetPlayer.getName()));
|
||||
targetPlayer.sendMessage(LocaleLoader.getString("Party.Teleport.Target", teleportingPlayer.getName()));
|
||||
|
||||
mcMMOPlayer.actualizePtpLastUse();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,10 +29,6 @@ public class InspectCommand implements TabExecutor {
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
switch (args.length) {
|
||||
case 1:
|
||||
if (sender instanceof Player && Config.getInstance().getInspectScoreboardEnabled()) {
|
||||
ScoreboardManager.setupPlayerScoreboard(sender.getName());
|
||||
}
|
||||
|
||||
String playerName = Misc.getMatchedPlayerName(args[0]);
|
||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(playerName, true);
|
||||
|
||||
@@ -44,30 +40,28 @@ public class InspectCommand implements TabExecutor {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (sender instanceof Player && Config.getInstance().getInspectScoreboardEnabled()) {
|
||||
ScoreboardManager.enablePlayerInspectScoreboardOffline((Player) sender, profile);
|
||||
return true;
|
||||
if (sender instanceof Player && Config.getInstance().getInspectUseBoard()) {
|
||||
ScoreboardManager.enablePlayerInspectScoreboard((Player) sender, profile);
|
||||
if (!Config.getInstance().getInspectUseChat()) return true;
|
||||
}
|
||||
|
||||
sender.sendMessage(LocaleLoader.getString("Inspect.OfflineStats", playerName));
|
||||
|
||||
sender.sendMessage(LocaleLoader.getString("Stats.Header.Gathering"));
|
||||
CommandUtils.displaySkill(sender, profile, SkillType.EXCAVATION);
|
||||
CommandUtils.displaySkill(sender, profile, SkillType.FISHING);
|
||||
CommandUtils.displaySkill(sender, profile, SkillType.HERBALISM);
|
||||
CommandUtils.displaySkill(sender, profile, SkillType.MINING);
|
||||
CommandUtils.displaySkill(sender, profile, SkillType.WOODCUTTING);
|
||||
for (SkillType skill : SkillType.GATHERING_SKILLS) {
|
||||
sender.sendMessage(CommandUtils.displaySkill(profile, skill));
|
||||
}
|
||||
|
||||
sender.sendMessage(LocaleLoader.getString("Stats.Header.Combat"));
|
||||
CommandUtils.displaySkill(sender, profile, SkillType.AXES);
|
||||
CommandUtils.displaySkill(sender, profile, SkillType.ARCHERY);
|
||||
CommandUtils.displaySkill(sender, profile, SkillType.SWORDS);
|
||||
CommandUtils.displaySkill(sender, profile, SkillType.TAMING);
|
||||
CommandUtils.displaySkill(sender, profile, SkillType.UNARMED);
|
||||
for (SkillType skill : SkillType.COMBAT_SKILLS) {
|
||||
sender.sendMessage(CommandUtils.displaySkill(profile, skill));
|
||||
}
|
||||
|
||||
sender.sendMessage(LocaleLoader.getString("Stats.Header.Misc"));
|
||||
CommandUtils.displaySkill(sender, profile, SkillType.ACROBATICS);
|
||||
CommandUtils.displaySkill(sender, profile, SkillType.REPAIR);
|
||||
for (SkillType skill : SkillType.MISC_SKILLS) {
|
||||
sender.sendMessage(CommandUtils.displaySkill(profile, skill));
|
||||
}
|
||||
|
||||
}
|
||||
else {
|
||||
Player target = mcMMOPlayer.getPlayer();
|
||||
@@ -82,9 +76,9 @@ public class InspectCommand implements TabExecutor {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (sender instanceof Player && Config.getInstance().getInspectScoreboardEnabled()) {
|
||||
ScoreboardManager.enablePlayerInspectScoreboardOnline((Player) sender, mcMMOPlayer);
|
||||
return true;
|
||||
if (sender instanceof Player && Config.getInstance().getInspectUseBoard()) {
|
||||
ScoreboardManager.enablePlayerInspectScoreboard((Player) sender, mcMMOPlayer.getProfile());
|
||||
if (!Config.getInstance().getInspectUseChat()) return true;
|
||||
}
|
||||
|
||||
sender.sendMessage(LocaleLoader.getString("Inspect.Stats", target.getName()));
|
||||
|
||||
@@ -0,0 +1,98 @@
|
||||
package com.gmail.nossr50.commands.player;
|
||||
|
||||
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 org.bukkit.permissions.Permissible;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.skills.AbilityType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
import com.gmail.nossr50.util.scoreboards.ScoreboardManager;
|
||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
public class MccooldownCommand implements TabExecutor {
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (CommandUtils.noConsoleUsage(sender)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
switch (args.length) {
|
||||
case 0:
|
||||
Player player = (Player) sender;
|
||||
|
||||
if (Config.getInstance().getCooldownUseBoard()) {
|
||||
ScoreboardManager.enablePlayerCooldownScoreboard(player);
|
||||
if (!Config.getInstance().getCooldownUseChat()) return true;
|
||||
}
|
||||
|
||||
PlayerProfile profile = UserManager.getPlayer(player).getProfile();
|
||||
|
||||
player.sendMessage(LocaleLoader.getString("Commands.Cooldowns.Header"));
|
||||
player.sendMessage(LocaleLoader.getString("mcMMO.NoSkillNote"));
|
||||
|
||||
for (AbilityType ability : AbilityType.NORMAL_ABILITIES) {
|
||||
if (!hasPermission(player, ability)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
int seconds = SkillUtils.calculateTimeLeft(ability, profile, player);
|
||||
|
||||
if (seconds <= 0) {
|
||||
player.sendMessage(LocaleLoader.getString("Commands.Cooldowns.Row.Y", ability.getAbilityName()));
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Commands.Cooldowns.Row.N", ability.getAbilityName(), Integer.toString(seconds)));
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private boolean hasPermission(Permissible permissible, AbilityType ability) {
|
||||
switch (ability) {
|
||||
case BERSERK:
|
||||
return Permissions.berserk(permissible);
|
||||
case BLAST_MINING:
|
||||
return Permissions.remoteDetonation(permissible);
|
||||
case BLOCK_CRACKER:
|
||||
return Permissions.blockCracker(permissible);
|
||||
case GIGA_DRILL_BREAKER:
|
||||
return Permissions.gigaDrillBreaker(permissible);
|
||||
case GREEN_TERRA:
|
||||
return Permissions.greenTerra(permissible);
|
||||
case LEAF_BLOWER:
|
||||
return Permissions.leafBlower(permissible);
|
||||
case SERRATED_STRIKES:
|
||||
return Permissions.serratedStrikes(permissible);
|
||||
case SKULL_SPLITTER:
|
||||
return Permissions.skullSplitter(permissible);
|
||||
case SUPER_BREAKER:
|
||||
return Permissions.superBreaker(permissible);
|
||||
case TREE_FELLER:
|
||||
return Permissions.treeFeller(permissible);
|
||||
default:
|
||||
mcMMO.p.getLogger().warning("MccooldownCommand - couldn't check permission for AbilityType." + ability.name());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
|
||||
return ImmutableList.of();
|
||||
}
|
||||
}
|
||||
@@ -13,13 +13,12 @@ import org.bukkit.util.StringUtil;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.runnables.commands.McrankCommandAsyncTask;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
import com.gmail.nossr50.util.scoreboards.ScoreboardManager;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
public class McrankCommand implements TabExecutor {
|
||||
@@ -36,13 +35,7 @@ public class McrankCommand implements TabExecutor {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (Config.getInstance().getMcrankScoreboardEnabled()) {
|
||||
ScoreboardManager.setupPlayerScoreboard(sender.getName());
|
||||
ScoreboardManager.enablePlayerRankScoreboard((Player) sender);
|
||||
}
|
||||
else {
|
||||
display(sender, sender.getName());
|
||||
}
|
||||
display(sender, sender.getName());
|
||||
|
||||
return true;
|
||||
|
||||
@@ -66,13 +59,7 @@ public class McrankCommand implements TabExecutor {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (sender instanceof Player && Config.getInstance().getMcrankScoreboardEnabled()) {
|
||||
ScoreboardManager.setupPlayerScoreboard(sender.getName());
|
||||
ScoreboardManager.enablePlayerRankScoreboardOthers((Player) sender, playerName);
|
||||
}
|
||||
else {
|
||||
display(sender, playerName);
|
||||
}
|
||||
display(sender, playerName);
|
||||
return true;
|
||||
|
||||
default:
|
||||
@@ -92,6 +79,17 @@ public class McrankCommand implements TabExecutor {
|
||||
}
|
||||
|
||||
private void display(CommandSender sender, String playerName) {
|
||||
new McrankCommandAsyncTask(playerName, sender).runTaskAsynchronously(mcMMO.p);
|
||||
if (sender instanceof Player) {
|
||||
McMMOPlayer mcpl = UserManager.getPlayer(sender.getName());
|
||||
if (mcpl.getDatabaseATS() + Misc.PLAYER_DATABASE_COOLDOWN_MILLIS > System.currentTimeMillis()) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Database.Cooldown"));
|
||||
return;
|
||||
}
|
||||
mcpl.actualizeDatabaseATS();
|
||||
}
|
||||
|
||||
boolean useBoard = (sender instanceof Player) && (Config.getInstance().getRankUseBoard());
|
||||
boolean useChat = useBoard ? Config.getInstance().getRankUseChat() : true;
|
||||
new McrankCommandAsyncTask(playerName, sender, useBoard, useChat).runTaskAsynchronously(mcMMO.p);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,6 @@ import org.bukkit.command.TabExecutor;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
@@ -26,28 +25,25 @@ public class McstatsCommand implements TabExecutor {
|
||||
switch (args.length) {
|
||||
case 0:
|
||||
Player player = (Player) sender;
|
||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
|
||||
|
||||
if (Config.getInstance().getMcstatsScoreboardsEnabled()) {
|
||||
ScoreboardManager.setupPlayerScoreboard(player.getName());
|
||||
ScoreboardManager.enablePlayerStatsScoreboard(mcMMOPlayer);
|
||||
if (Config.getInstance().getStatsUseBoard()) {
|
||||
ScoreboardManager.enablePlayerStatsScoreboard(player);
|
||||
if (!Config.getInstance().getStatsUseChat()) return true;
|
||||
}
|
||||
player.sendMessage(LocaleLoader.getString("Stats.Own.Stats"));
|
||||
player.sendMessage(LocaleLoader.getString("mcMMO.NoSkillNote"));
|
||||
|
||||
CommandUtils.printGatheringSkills(player);
|
||||
CommandUtils.printCombatSkills(player);
|
||||
CommandUtils.printMiscSkills(player);
|
||||
|
||||
int powerLevelCap = Config.getInstance().getPowerLevelCap();
|
||||
|
||||
if (powerLevelCap != Integer.MAX_VALUE) {
|
||||
player.sendMessage(LocaleLoader.getString("Commands.PowerLevel.Capped", UserManager.getPlayer(player).getPowerLevel(), powerLevelCap));
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Stats.Own.Stats"));
|
||||
player.sendMessage(LocaleLoader.getString("mcMMO.NoSkillNote"));
|
||||
|
||||
CommandUtils.printGatheringSkills(player);
|
||||
CommandUtils.printCombatSkills(player);
|
||||
CommandUtils.printMiscSkills(player);
|
||||
|
||||
int powerLevelCap = Config.getInstance().getPowerLevelCap();
|
||||
|
||||
if (powerLevelCap != Integer.MAX_VALUE) {
|
||||
player.sendMessage(LocaleLoader.getString("Commands.PowerLevel.Capped", UserManager.getPlayer(player).getPowerLevel(), powerLevelCap));
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Commands.PowerLevel", UserManager.getPlayer(player).getPowerLevel()));
|
||||
}
|
||||
player.sendMessage(LocaleLoader.getString("Commands.PowerLevel", UserManager.getPlayer(player).getPowerLevel()));
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
@@ -11,36 +11,39 @@ import org.bukkit.util.StringUtil;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.runnables.commands.MctopCommandAsyncTask;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.StringUtils;
|
||||
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||
import com.gmail.nossr50.util.scoreboards.ScoreboardManager;
|
||||
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
public class MctopCommand implements TabExecutor {
|
||||
private SkillType skill;
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
SkillType skill;
|
||||
|
||||
switch (args.length) {
|
||||
case 0:
|
||||
display(1, "ALL", sender, command);
|
||||
display(1, null, sender, command);
|
||||
return true;
|
||||
|
||||
case 1:
|
||||
if (StringUtils.isInt(args[0])) {
|
||||
display(Math.abs(Integer.parseInt(args[0])), "ALL", sender, command);
|
||||
display(Math.abs(Integer.parseInt(args[0])), null, sender, command);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!extractSkill(sender, args[0])) {
|
||||
if ((skill = extractSkill(sender, args[0])) == null) {
|
||||
return true;
|
||||
}
|
||||
|
||||
display(1, skill.toString(), sender, command);
|
||||
display(1, skill, sender, command);
|
||||
return true;
|
||||
|
||||
case 2:
|
||||
@@ -48,11 +51,11 @@ public class MctopCommand implements TabExecutor {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!extractSkill(sender, args[0])) {
|
||||
if ((skill = extractSkill(sender, args[0])) == null) {
|
||||
return true;
|
||||
}
|
||||
|
||||
display(Math.abs(Integer.parseInt(args[1])), skill.toString(), sender, command);
|
||||
display(Math.abs(Integer.parseInt(args[1])), skill, sender, command);
|
||||
return true;
|
||||
|
||||
default:
|
||||
@@ -70,35 +73,41 @@ public class MctopCommand implements TabExecutor {
|
||||
}
|
||||
}
|
||||
|
||||
private void display(int page, String skill, CommandSender sender, Command command) {
|
||||
if (!skill.equalsIgnoreCase("all") && !Permissions.mctop(sender, this.skill)) {
|
||||
private void display(int page, SkillType skill, CommandSender sender, Command command) {
|
||||
if (skill != null && !Permissions.mctop(sender, skill)) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return;
|
||||
}
|
||||
|
||||
if (sender instanceof Player && Config.getInstance().getMctopScoreboardEnabled()) {
|
||||
ScoreboardManager.enableGlobalStatsScoreboard((Player) sender, skill, page);
|
||||
}
|
||||
else {
|
||||
display(page, skill, sender);
|
||||
if (sender instanceof Player) {
|
||||
McMMOPlayer mcpl = UserManager.getPlayer(sender.getName());
|
||||
if (mcpl.getDatabaseATS() + Misc.PLAYER_DATABASE_COOLDOWN_MILLIS > System.currentTimeMillis()) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Database.Cooldown"));
|
||||
return;
|
||||
}
|
||||
mcpl.actualizeDatabaseATS();
|
||||
}
|
||||
|
||||
display(page, skill, sender);
|
||||
}
|
||||
|
||||
private void display(int page, String query, CommandSender sender) {
|
||||
new MctopCommandAsyncTask(page, query, sender).runTaskAsynchronously(mcMMO.p);
|
||||
private void display(int page, SkillType skill, CommandSender sender) {
|
||||
boolean useBoard = (sender instanceof Player) && (Config.getInstance().getTopUseBoard());
|
||||
boolean useChat = useBoard ? Config.getInstance().getTopUseChat() : true;
|
||||
|
||||
new MctopCommandAsyncTask(page, skill, sender, useBoard, useChat).runTaskAsynchronously(mcMMO.p);
|
||||
}
|
||||
|
||||
private boolean extractSkill(CommandSender sender, String skillName) {
|
||||
private SkillType extractSkill(CommandSender sender, String skillName) {
|
||||
if (CommandUtils.isInvalidSkill(sender, skillName)) {
|
||||
return false;
|
||||
return null;
|
||||
}
|
||||
SkillType skill = SkillType.getSkill(skillName);
|
||||
|
||||
if (skill != null && CommandUtils.isChildSkill(sender, skill)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
skill = SkillType.getSkill(skillName);
|
||||
|
||||
if (CommandUtils.isChildSkill(sender, skill)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
return skill;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -82,15 +82,15 @@ public class AcrobaticsCommand extends SkillCommand {
|
||||
@Override
|
||||
protected void statsDisplay() {
|
||||
if (canRoll) {
|
||||
player.sendMessage(LocaleLoader.getString("Acrobatics.Roll.Chance", rollChance) + (isLucky ? LocaleLoader.getString("Perks.lucky.bonus", rollChanceLucky) : ""));
|
||||
player.sendMessage(LocaleLoader.getString("Acrobatics.Roll.Chance", rollChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", rollChanceLucky) : ""));
|
||||
}
|
||||
|
||||
if (canGracefulRoll) {
|
||||
player.sendMessage(LocaleLoader.getString("Acrobatics.Roll.GraceChance", gracefulRollChance) + (isLucky ? LocaleLoader.getString("Perks.lucky.bonus", gracefulRollChanceLucky) : ""));
|
||||
player.sendMessage(LocaleLoader.getString("Acrobatics.Roll.GraceChance", gracefulRollChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", gracefulRollChanceLucky) : ""));
|
||||
}
|
||||
|
||||
if (canDodge) {
|
||||
player.sendMessage(LocaleLoader.getString("Acrobatics.DodgeChance", dodgeChance) + (isLucky ? LocaleLoader.getString("Perks.lucky.bonus", dodgeChanceLucky) : ""));
|
||||
player.sendMessage(LocaleLoader.getString("Acrobatics.DodgeChance", dodgeChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", dodgeChanceLucky) : ""));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -84,11 +84,11 @@ public class ArcheryCommand extends SkillCommand {
|
||||
}
|
||||
|
||||
if (canDaze) {
|
||||
player.sendMessage(LocaleLoader.getString("Archery.Combat.DazeChance", dazeChance) + (isLucky ? LocaleLoader.getString("Perks.lucky.bonus", dazeChanceLucky) : ""));
|
||||
player.sendMessage(LocaleLoader.getString("Archery.Combat.DazeChance", dazeChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", dazeChanceLucky) : ""));
|
||||
}
|
||||
|
||||
if (canRetrieve) {
|
||||
player.sendMessage(LocaleLoader.getString("Archery.Combat.RetrieveChance", retrieveChance) + (isLucky ? LocaleLoader.getString("Perks.lucky.bonus", retrieveChanceLucky) : ""));
|
||||
player.sendMessage(LocaleLoader.getString("Archery.Combat.RetrieveChance", retrieveChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", retrieveChanceLucky) : ""));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -109,11 +109,11 @@ public class AxesCommand extends SkillCommand {
|
||||
}
|
||||
|
||||
if (canCritical) {
|
||||
player.sendMessage(LocaleLoader.getString("Axes.Combat.CritChance", critChance) + (isLucky ? LocaleLoader.getString("Perks.lucky.bonus", critChanceLucky) : ""));
|
||||
player.sendMessage(LocaleLoader.getString("Axes.Combat.CritChance", critChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", critChanceLucky) : ""));
|
||||
}
|
||||
|
||||
if (canSkullSplitter) {
|
||||
player.sendMessage(LocaleLoader.getString("Axes.Combat.SS.Length", skullSplitterLength) + (hasEndurance ? LocaleLoader.getString("Perks.activationtime.bonus", skullSplitterLengthEndurance) : ""));
|
||||
player.sendMessage(LocaleLoader.getString("Axes.Combat.SS.Length", skullSplitterLength) + (hasEndurance ? LocaleLoader.getString("Perks.ActivationTime.Bonus", skullSplitterLengthEndurance) : ""));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ public class ExcavationCommand extends SkillCommand {
|
||||
@Override
|
||||
protected void statsDisplay() {
|
||||
if (canGigaDrill) {
|
||||
player.sendMessage(LocaleLoader.getString("Excavation.Effect.Length", gigaDrillBreakerLength) + (hasEndurance ? LocaleLoader.getString("Perks.activationtime.bonus", gigaDrillBreakerLengthEndurance) : ""));
|
||||
player.sendMessage(LocaleLoader.getString("Excavation.Effect.Length", gigaDrillBreakerLength) + (hasEndurance ? LocaleLoader.getString("Perks.ActivationTime.Bonus", gigaDrillBreakerLengthEndurance) : ""));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,25 +1,36 @@
|
||||
package com.gmail.nossr50.commands.skills;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.block.Biome;
|
||||
import org.bukkit.entity.EntityType;
|
||||
|
||||
import com.gmail.nossr50.config.AdvancedConfig;
|
||||
import com.gmail.nossr50.config.treasure.TreasureConfig;
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.datatypes.treasure.Rarity;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.skills.fishing.Fishing;
|
||||
import com.gmail.nossr50.skills.fishing.Fishing.Tier;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
|
||||
public class FishingCommand extends SkillCommand {
|
||||
private int lootTier;
|
||||
private String magicChance;
|
||||
private String magicChanceLucky;
|
||||
private String chanceRaining = "";
|
||||
private String shakeChance;
|
||||
private String shakeChanceLucky;
|
||||
private int fishermansDietRank;
|
||||
private String biteChance;
|
||||
|
||||
private String trapTreasure;
|
||||
private String commonTreasure;
|
||||
private String uncommonTreasure;
|
||||
private String rareTreasure;
|
||||
private String epicTreasure;
|
||||
private String legendaryTreasure;
|
||||
private String recordTreasure;
|
||||
|
||||
private String magicChance;
|
||||
|
||||
private boolean canTreasureHunt;
|
||||
private boolean canMagicHunt;
|
||||
private boolean canShake;
|
||||
@@ -38,16 +49,24 @@ public class FishingCommand extends SkillCommand {
|
||||
// TREASURE HUNTER
|
||||
if (canTreasureHunt) {
|
||||
lootTier = mcMMOPlayer.getFishingManager().getLootTier();
|
||||
double enchantChance = lootTier * AdvancedConfig.getInstance().getFishingMagicMultiplier();
|
||||
|
||||
if (isStorming) {
|
||||
chanceRaining = LocaleLoader.getString("Fishing.Chance.Raining");
|
||||
enchantChance *= 1.1D;
|
||||
}
|
||||
// Item drop rates
|
||||
trapTreasure = calculateAbilityDisplayValues(TreasureConfig.getInstance().getItemDropRate(lootTier, Rarity.TRAP))[0];
|
||||
commonTreasure = calculateAbilityDisplayValues(TreasureConfig.getInstance().getItemDropRate(lootTier, Rarity.COMMON))[0];
|
||||
uncommonTreasure = calculateAbilityDisplayValues(TreasureConfig.getInstance().getItemDropRate(lootTier, Rarity.UNCOMMON))[0];
|
||||
rareTreasure = calculateAbilityDisplayValues(TreasureConfig.getInstance().getItemDropRate(lootTier, Rarity.RARE))[0];
|
||||
epicTreasure = calculateAbilityDisplayValues(TreasureConfig.getInstance().getItemDropRate(lootTier, Rarity.EPIC))[0];
|
||||
legendaryTreasure = calculateAbilityDisplayValues(TreasureConfig.getInstance().getItemDropRate(lootTier, Rarity.LEGENDARY))[0];
|
||||
recordTreasure = calculateAbilityDisplayValues(TreasureConfig.getInstance().getItemDropRate(lootTier, Rarity.RECORD))[0];
|
||||
|
||||
String[] treasureHunterStrings = calculateAbilityDisplayValues(enchantChance);
|
||||
magicChance = treasureHunterStrings[0];
|
||||
magicChanceLucky = treasureHunterStrings[1];
|
||||
// Magic hunter drop rates
|
||||
double commonEnchantment = TreasureConfig.getInstance().getEnchantmentDropRate(lootTier, Rarity.COMMON);
|
||||
double uncommonEnchantment = TreasureConfig.getInstance().getEnchantmentDropRate(lootTier, Rarity.UNCOMMON);
|
||||
double rareEnchantment = TreasureConfig.getInstance().getEnchantmentDropRate(lootTier, Rarity.RARE);
|
||||
double epicEnchantment = TreasureConfig.getInstance().getEnchantmentDropRate(lootTier, Rarity.EPIC);
|
||||
double legendaryEnchantment = TreasureConfig.getInstance().getEnchantmentDropRate(lootTier, Rarity.LEGENDARY);
|
||||
|
||||
magicChance = calculateAbilityDisplayValues(commonEnchantment + uncommonEnchantment + rareEnchantment + epicEnchantment + legendaryEnchantment)[0];
|
||||
}
|
||||
|
||||
// SHAKE
|
||||
@@ -64,15 +83,17 @@ public class FishingCommand extends SkillCommand {
|
||||
|
||||
// MASTER ANGLER
|
||||
if (canMasterAngler) {
|
||||
double rawBiteChance = ((Math.max((skillValue / 200.0), 1.0)) / (isStorming ? 300 : 500));
|
||||
Biome biome = player.getLocation().getBlock().getBiome();
|
||||
double rawBiteChance = 1.0 / (isStorming ? 300 : 500);
|
||||
Location location = (mcMMOPlayer.getHookLocation() != null) ? mcMMOPlayer.getHookLocation() : player.getLocation();
|
||||
|
||||
Biome biome = location.getBlock().getBiome();
|
||||
|
||||
if (biome == Biome.RIVER || biome == Biome.OCEAN) {
|
||||
rawBiteChance = rawBiteChance * 2.0;
|
||||
rawBiteChance = rawBiteChance * AdvancedConfig.getInstance().getMasterAnglerBiomeModifier();
|
||||
}
|
||||
|
||||
if (player.isInsideVehicle() && player.getVehicle().getType() == EntityType.BOAT) {
|
||||
rawBiteChance = rawBiteChance * 2.0;
|
||||
rawBiteChance = rawBiteChance * AdvancedConfig.getInstance().getMasterAnglerBoatModifier();
|
||||
}
|
||||
|
||||
biteChance = calculateAbilityDisplayValues(rawBiteChance * 100.0)[0];
|
||||
@@ -106,20 +127,20 @@ public class FishingCommand extends SkillCommand {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Fishing.Effect.2"), LocaleLoader.getString("Fishing.Effect.3")));
|
||||
}
|
||||
|
||||
if (canShake) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Fishing.Effect.4"), LocaleLoader.getString("Fishing.Effect.5")));
|
||||
}
|
||||
|
||||
if (canFishermansDiet) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Fishing.Effect.6"), LocaleLoader.getString("Fishing.Effect.7")));
|
||||
if (canIceFish) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Fishing.Effect.10"), LocaleLoader.getString("Fishing.Effect.11")));
|
||||
}
|
||||
|
||||
if (canMasterAngler) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Fishing.Effect.8"), LocaleLoader.getString("Fishing.Effect.9")));
|
||||
}
|
||||
|
||||
if (canIceFish) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Fishing.Effect.10"), LocaleLoader.getString("Fishing.Effect.11")));
|
||||
if (canShake) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Fishing.Effect.4"), LocaleLoader.getString("Fishing.Effect.5")));
|
||||
}
|
||||
|
||||
if (canFishermansDiet) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Fishing.Effect.6"), LocaleLoader.getString("Fishing.Effect.7")));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -130,31 +151,13 @@ public class FishingCommand extends SkillCommand {
|
||||
|
||||
@Override
|
||||
protected void statsDisplay() {
|
||||
if (canMasterAngler) {
|
||||
player.sendMessage(LocaleLoader.getString("Fishing.Ability.Chance", biteChance));
|
||||
}
|
||||
|
||||
if (canTreasureHunt) {
|
||||
player.sendMessage(LocaleLoader.getString("Fishing.Ability.Rank", lootTier));
|
||||
player.sendMessage(LocaleLoader.getString("Fishing.Ability.Rank", lootTier, Tier.EIGHT.toNumerical()));
|
||||
player.sendMessage(LocaleLoader.getString("Fishing.Ability.TH.DropRate", trapTreasure, commonTreasure, uncommonTreasure, rareTreasure, epicTreasure, legendaryTreasure, recordTreasure));
|
||||
}
|
||||
|
||||
if (canMagicHunt) {
|
||||
player.sendMessage(LocaleLoader.getString("Fishing.Enchant.Chance", magicChance) + chanceRaining + (isLucky ? LocaleLoader.getString("Perks.lucky.bonus", magicChanceLucky) : ""));
|
||||
}
|
||||
|
||||
if (canShake) {
|
||||
int unlockLevel = AdvancedConfig.getInstance().getShakeUnlockLevel();
|
||||
|
||||
if (skillValue < unlockLevel) {
|
||||
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Fishing.Ability.Locked.0", unlockLevel)));
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Fishing.Ability.Shake", shakeChance) + (isLucky ? LocaleLoader.getString("Perks.lucky.bonus", shakeChanceLucky) : ""));
|
||||
}
|
||||
}
|
||||
|
||||
if (canFishermansDiet) {
|
||||
player.sendMessage(LocaleLoader.getString("Fishing.Ability.FD", fishermansDietRank));
|
||||
player.sendMessage(LocaleLoader.getString("Fishing.Ability.TH.MagicRate", magicChance));
|
||||
}
|
||||
|
||||
if (canIceFish) {
|
||||
@@ -167,5 +170,31 @@ public class FishingCommand extends SkillCommand {
|
||||
player.sendMessage(LocaleLoader.getString("Fishing.Ability.IceFishing"));
|
||||
}
|
||||
}
|
||||
|
||||
if (canMasterAngler) {
|
||||
int unlockLevel = AdvancedConfig.getInstance().getMasterAnglerUnlockLevel();
|
||||
|
||||
if (skillValue < unlockLevel) {
|
||||
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Fishing.Ability.Locked.2", unlockLevel)));
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Fishing.Ability.Chance", biteChance));
|
||||
}
|
||||
}
|
||||
|
||||
if (canShake) {
|
||||
int unlockLevel = AdvancedConfig.getInstance().getFishingTierLevel(Tier.ONE);
|
||||
|
||||
if (skillValue < unlockLevel) {
|
||||
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Fishing.Ability.Locked.0", unlockLevel)));
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Fishing.Ability.Shake", shakeChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", shakeChanceLucky) : ""));
|
||||
}
|
||||
}
|
||||
|
||||
if (canFishermansDiet) {
|
||||
player.sendMessage(LocaleLoader.getString("Fishing.Ability.FD", fishermansDietRank));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -135,11 +135,11 @@ public class HerbalismCommand extends SkillCommand {
|
||||
@Override
|
||||
protected void statsDisplay() {
|
||||
if (canGreenTerra) {
|
||||
player.sendMessage(LocaleLoader.getString("Herbalism.Ability.GTe.Length", greenTerraLength) + (hasEndurance ? LocaleLoader.getString("Perks.activationtime.bonus", greenTerraLengthEndurance) : ""));
|
||||
player.sendMessage(LocaleLoader.getString("Herbalism.Ability.GTe.Length", greenTerraLength) + (hasEndurance ? LocaleLoader.getString("Perks.ActivationTime.Bonus", greenTerraLengthEndurance) : ""));
|
||||
}
|
||||
|
||||
if (canGreenThumbBlocks || canGreenThumbPlants) {
|
||||
player.sendMessage(LocaleLoader.getString("Herbalism.Ability.GTh.Chance", greenThumbChance) + (isLucky ? LocaleLoader.getString("Perks.lucky.bonus", greenThumbChanceLucky) : ""));
|
||||
player.sendMessage(LocaleLoader.getString("Herbalism.Ability.GTh.Chance", greenThumbChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", greenThumbChanceLucky) : ""));
|
||||
}
|
||||
|
||||
if (canGreenThumbPlants) {
|
||||
@@ -151,15 +151,15 @@ public class HerbalismCommand extends SkillCommand {
|
||||
}
|
||||
|
||||
if (hasHylianLuck) {
|
||||
player.sendMessage(LocaleLoader.getString("Herbalism.Ability.HylianLuck", hylianLuckChance) + (isLucky ? LocaleLoader.getString("Perks.lucky.bonus", hylianLuckChanceLucky) : ""));
|
||||
player.sendMessage(LocaleLoader.getString("Herbalism.Ability.HylianLuck", hylianLuckChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", hylianLuckChanceLucky) : ""));
|
||||
}
|
||||
|
||||
if (canShroomThumb) {
|
||||
player.sendMessage(LocaleLoader.getString("Herbalism.Ability.ShroomThumb.Chance", shroomThumbChance) + (isLucky ? LocaleLoader.getString("Perks.lucky.bonus", shroomThumbChanceLucky) : ""));
|
||||
player.sendMessage(LocaleLoader.getString("Herbalism.Ability.ShroomThumb.Chance", shroomThumbChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", shroomThumbChanceLucky) : ""));
|
||||
}
|
||||
|
||||
if (canDoubleDrop) {
|
||||
player.sendMessage(LocaleLoader.getString("Herbalism.Ability.DoubleDropChance", doubleDropChance) + (isLucky ? LocaleLoader.getString("Perks.lucky.bonus", doubleDropChanceLucky) : ""));
|
||||
player.sendMessage(LocaleLoader.getString("Herbalism.Ability.DoubleDropChance", doubleDropChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", doubleDropChanceLucky) : ""));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.gmail.nossr50.commands.skills;
|
||||
import com.gmail.nossr50.config.AdvancedConfig;
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.skills.mining.BlastMining.Tier;
|
||||
import com.gmail.nossr50.skills.mining.Mining;
|
||||
import com.gmail.nossr50.skills.mining.MiningManager;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
@@ -106,26 +107,26 @@ public class MiningCommand extends SkillCommand {
|
||||
@Override
|
||||
protected void statsDisplay() {
|
||||
if (canDoubleDrop) {
|
||||
player.sendMessage(LocaleLoader.getString("Mining.Effect.DropChance", doubleDropChance) + (isLucky ? LocaleLoader.getString("Perks.lucky.bonus", doubleDropChanceLucky) : ""));
|
||||
player.sendMessage(LocaleLoader.getString("Mining.Effect.DropChance", doubleDropChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", doubleDropChanceLucky) : ""));
|
||||
}
|
||||
|
||||
if (canSuperBreaker) {
|
||||
player.sendMessage(LocaleLoader.getString("Mining.Ability.Length", superBreakerLength) + (hasEndurance ? LocaleLoader.getString("Perks.activationtime.bonus", superBreakerLengthEndurance) : ""));
|
||||
player.sendMessage(LocaleLoader.getString("Mining.Ability.Length", superBreakerLength) + (hasEndurance ? LocaleLoader.getString("Perks.ActivationTime.Bonus", superBreakerLengthEndurance) : ""));
|
||||
}
|
||||
|
||||
if (canBlast) {
|
||||
int unlockLevel = AdvancedConfig.getInstance().getBlastMiningRank1();
|
||||
int unlockLevel = AdvancedConfig.getInstance().getBlastMiningRankLevel(Tier.ONE);
|
||||
|
||||
if (skillValue < unlockLevel) {
|
||||
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Mining.Ability.Locked.0", unlockLevel)));
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Mining.Blast.Rank", blastMiningRank, LocaleLoader.getString("Mining.Blast.Effect", oreBonus, debrisReduction, bonusTNTDrops)));
|
||||
player.sendMessage(LocaleLoader.getString("Mining.Blast.Rank", blastMiningRank, Tier.EIGHT.toNumerical(), LocaleLoader.getString("Mining.Blast.Effect", oreBonus, debrisReduction, bonusTNTDrops)));
|
||||
}
|
||||
}
|
||||
|
||||
if (canBiggerBombs) {
|
||||
int unlockLevel = AdvancedConfig.getInstance().getBlastMiningRank2();
|
||||
int unlockLevel = AdvancedConfig.getInstance().getBlastMiningRankLevel(Tier.TWO);
|
||||
|
||||
if (skillValue < unlockLevel) {
|
||||
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Mining.Ability.Locked.1", unlockLevel)));
|
||||
@@ -136,7 +137,7 @@ public class MiningCommand extends SkillCommand {
|
||||
}
|
||||
|
||||
if (canDemoExpert) {
|
||||
int unlockLevel = AdvancedConfig.getInstance().getBlastMiningRank4();
|
||||
int unlockLevel = AdvancedConfig.getInstance().getBlastMiningRankLevel(Tier.FOUR);
|
||||
|
||||
if (skillValue < unlockLevel) {
|
||||
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Mining.Ability.Locked.2", unlockLevel)));
|
||||
|
||||
@@ -6,9 +6,10 @@ import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.skills.repair.ArcaneForging;
|
||||
import com.gmail.nossr50.skills.repair.ArcaneForging.Tier;
|
||||
import com.gmail.nossr50.skills.repair.Repair;
|
||||
import com.gmail.nossr50.skills.repair.RepairManager;
|
||||
import com.gmail.nossr50.skills.repair.Repairable;
|
||||
import com.gmail.nossr50.skills.repair.repairables.Repairable;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
|
||||
public class RepairCommand extends SkillCommand {
|
||||
@@ -41,10 +42,10 @@ public class RepairCommand extends SkillCommand {
|
||||
@Override
|
||||
protected void dataCalculations() {
|
||||
// We're using pickaxes here, not the best but it works
|
||||
Repairable diamondRepairable = mcMMO.getRepairableManager().getRepairable(Material.DIAMOND_PICKAXE.getId());
|
||||
Repairable goldRepairable = mcMMO.getRepairableManager().getRepairable(Material.GOLD_PICKAXE.getId());
|
||||
Repairable ironRepairable = mcMMO.getRepairableManager().getRepairable(Material.IRON_PICKAXE.getId());
|
||||
Repairable stoneRepairable = mcMMO.getRepairableManager().getRepairable(Material.STONE_PICKAXE.getId());
|
||||
Repairable diamondRepairable = mcMMO.getRepairableManager().getRepairable(Material.DIAMOND_PICKAXE);
|
||||
Repairable goldRepairable = mcMMO.getRepairableManager().getRepairable(Material.GOLD_PICKAXE);
|
||||
Repairable ironRepairable = mcMMO.getRepairableManager().getRepairable(Material.IRON_PICKAXE);
|
||||
Repairable stoneRepairable = mcMMO.getRepairableManager().getRepairable(Material.STONE_PICKAXE);
|
||||
|
||||
// TODO: This isn't really accurate - if they don't have pickaxes loaded it doesn't always mean the repair level is 0
|
||||
diamondLevel = (diamondRepairable == null) ? 0 : diamondRepairable.getMinimumLevel();
|
||||
@@ -139,13 +140,13 @@ public class RepairCommand extends SkillCommand {
|
||||
}
|
||||
|
||||
if (canSuperRepair) {
|
||||
player.sendMessage(LocaleLoader.getString("Repair.Skills.Super.Chance", superRepairChance) + (isLucky ? LocaleLoader.getString("Perks.lucky.bonus", superRepairChanceLucky) : ""));
|
||||
player.sendMessage(LocaleLoader.getString("Repair.Skills.Super.Chance", superRepairChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", superRepairChanceLucky) : ""));
|
||||
}
|
||||
|
||||
if (canArcaneForge) {
|
||||
RepairManager repairManager = mcMMOPlayer.getRepairManager();
|
||||
|
||||
player.sendMessage(LocaleLoader.getString("Repair.Arcane.Rank", repairManager.getArcaneForgingRank()));
|
||||
player.sendMessage(LocaleLoader.getString("Repair.Arcane.Rank", repairManager.getArcaneForgingRank(), Tier.EIGHT.toNumerical()));
|
||||
|
||||
if (ArcaneForging.arcaneForgingEnchantLoss) {
|
||||
player.sendMessage(LocaleLoader.getString("Repair.Arcane.Chance.Success", (arcaneBypass ? 100 : repairManager.getKeepEnchantChance())));
|
||||
|
||||
@@ -23,7 +23,6 @@ import com.gmail.nossr50.util.commands.CommandUtils;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
import com.gmail.nossr50.util.scoreboards.ScoreboardManager;
|
||||
import com.gmail.nossr50.util.skills.PerksUtils;
|
||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
@@ -46,7 +45,7 @@ public abstract class SkillCommand implements TabExecutor {
|
||||
|
||||
public SkillCommand(SkillType skill) {
|
||||
this.skill = skill;
|
||||
skillName = SkillUtils.getSkillName(skill);
|
||||
skillName = skill.getSkillName();
|
||||
skillGuideCommand = new SkillGuideCommand(skill);
|
||||
}
|
||||
|
||||
@@ -70,17 +69,15 @@ public abstract class SkillCommand implements TabExecutor {
|
||||
permissionsCheck();
|
||||
dataCalculations();
|
||||
|
||||
if (Config.getInstance().getSkillUseBoard()) {
|
||||
ScoreboardManager.enablePlayerSkillScoreboard(player, skill);
|
||||
}
|
||||
|
||||
if (!skill.isChildSkill()) {
|
||||
player.sendMessage(LocaleLoader.getString("Skills.Header", skillName));
|
||||
player.sendMessage(LocaleLoader.getString("Commands.XPGain", LocaleLoader.getString("Commands.XPGain." + StringUtils.getCapitalized(skill.toString()))));
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Level", (int) skillValue, profile.getSkillXpLevel(skill), profile.getXpToLevel(skill)));
|
||||
|
||||
if (Config.getInstance().getSkillScoreboardEnabled()) {
|
||||
ScoreboardManager.setupPlayerScoreboard(player.getName());
|
||||
ScoreboardManager.enablePlayerSkillScoreboard(mcMMOPlayer, skill);
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Level", (int) skillValue, profile.getSkillXpLevel(skill), profile.getXpToLevel(skill)));
|
||||
}
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Skills.Header", skillName + " " + LocaleLoader.getString("Skills.Child")));
|
||||
@@ -91,7 +88,7 @@ public abstract class SkillCommand implements TabExecutor {
|
||||
Set<SkillType> parents = FamilyTree.getParents(skill);
|
||||
|
||||
for (SkillType parent : parents) {
|
||||
player.sendMessage(SkillUtils.getSkillName(parent) + " - " + LocaleLoader.getString("Effects.Level", profile.getSkillLevel(parent), profile.getSkillXpLevel(parent), profile.getXpToLevel(parent)));
|
||||
player.sendMessage(parent.getSkillName() + " - " + LocaleLoader.getString("Effects.Level", profile.getSkillLevel(parent), profile.getSkillXpLevel(parent), profile.getXpToLevel(parent)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -143,7 +140,7 @@ public abstract class SkillCommand implements TabExecutor {
|
||||
}
|
||||
|
||||
protected String[] calculateLengthDisplayValues() {
|
||||
int maxLength = skill.getAbility().getMaxTicks();
|
||||
int maxLength = skill.getAbility().getMaxLength();
|
||||
int length = 2 + (int) (skillValue / AdvancedConfig.getInstance().getAbilityLength());
|
||||
int enduranceLength = PerksUtils.handleActivationPerks(player, length, maxLength);
|
||||
|
||||
@@ -157,7 +154,7 @@ public abstract class SkillCommand implements TabExecutor {
|
||||
protected void luckyEffectsDisplay() {
|
||||
if (isLucky) {
|
||||
String perkPrefix = LocaleLoader.getString("MOTD.PerksPrefix");
|
||||
player.sendMessage(perkPrefix + LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Perks.lucky.name"), LocaleLoader.getString("Perks.lucky.desc", skillName)));
|
||||
player.sendMessage(perkPrefix + LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Perks.Lucky.Name"), LocaleLoader.getString("Perks.Lucky.Desc", skillName)));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.gmail.nossr50.commands.skills;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
@@ -9,17 +10,16 @@ import org.bukkit.command.CommandSender;
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.StringUtils;
|
||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||
|
||||
public class SkillGuideCommand implements CommandExecutor {
|
||||
private String header;
|
||||
private String[] guide;
|
||||
private ArrayList<String> guide;
|
||||
|
||||
private String invalidPage;
|
||||
|
||||
public SkillGuideCommand(SkillType skillType) {
|
||||
header = LocaleLoader.getString("Guides.Header", SkillUtils.getSkillName(skillType));
|
||||
guide = LocaleLoader.getString("Guides." + StringUtils.getCapitalized(skillType.toString())).split("\n");
|
||||
header = LocaleLoader.getString("Guides.Header", skillType.getSkillName());
|
||||
guide = getGuide(skillType);
|
||||
|
||||
invalidPage = LocaleLoader.getString("Guides.Page.Invalid");
|
||||
}
|
||||
@@ -59,7 +59,7 @@ public class SkillGuideCommand implements CommandExecutor {
|
||||
}
|
||||
|
||||
private int getTotalPageNumber() {
|
||||
return (int) Math.ceil(guide.length / 8.0);
|
||||
return (int) Math.ceil(guide.size() / 8.0);
|
||||
}
|
||||
|
||||
private void sendGuide(CommandSender sender, int pageNumber) {
|
||||
@@ -76,15 +76,38 @@ public class SkillGuideCommand implements CommandExecutor {
|
||||
|
||||
// Add targeted strings
|
||||
while (allStrings.size() < 9) {
|
||||
if (pageIndexStart + allStrings.size() > guide.length) {
|
||||
if (pageIndexStart + allStrings.size() > guide.size()) {
|
||||
allStrings.add("");
|
||||
}
|
||||
else {
|
||||
allStrings.add(guide[pageIndexStart + (allStrings.size() - 1)]);
|
||||
allStrings.add(guide.get(pageIndexStart + (allStrings.size() - 1)));
|
||||
}
|
||||
}
|
||||
|
||||
allStrings.add("Page " + pagenum + " of " + getTotalPageNumber());
|
||||
return allStrings;
|
||||
}
|
||||
|
||||
private ArrayList<String> getGuide(SkillType skillType) {
|
||||
ArrayList<String> guide = new ArrayList<String>();
|
||||
|
||||
for (int i = 0; i < 10; i++) {
|
||||
String[] section = LocaleLoader.getString("Guides." + StringUtils.getCapitalized(skillType.toString()) + ".Section." + i).split("\n");
|
||||
|
||||
if (section[0].startsWith("!")) {
|
||||
break;
|
||||
}
|
||||
|
||||
guide.addAll(Arrays.asList(section));
|
||||
|
||||
if (section.length < 8) {
|
||||
for (int blankLine = 8 - section.length; blankLine > 0; blankLine--) {
|
||||
guide.add("");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return guide;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import com.gmail.nossr50.config.AdvancedConfig;
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.skills.smelting.Smelting;
|
||||
import com.gmail.nossr50.skills.smelting.Smelting.Tier;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
|
||||
public class SmeltingCommand extends SkillCommand {
|
||||
@@ -90,11 +91,11 @@ public class SmeltingCommand extends SkillCommand {
|
||||
}
|
||||
|
||||
if (canSecondSmelt) {
|
||||
player.sendMessage(LocaleLoader.getString("Smelting.Ability.SecondSmelt", secondSmeltChance) + (isLucky ? LocaleLoader.getString("Perks.lucky.bonus", secondSmeltChanceLucky) : ""));
|
||||
player.sendMessage(LocaleLoader.getString("Smelting.Ability.SecondSmelt", secondSmeltChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", secondSmeltChanceLucky) : ""));
|
||||
}
|
||||
|
||||
if (canVanillaXPBoost) {
|
||||
int unlockLevel = AdvancedConfig.getInstance().getSmeltingVanillaXPBoostRank1Level();
|
||||
int unlockLevel = AdvancedConfig.getInstance().getSmeltingRankLevel(Tier.ONE);
|
||||
|
||||
if (skillValue < unlockLevel) {
|
||||
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Smelting.Ability.Locked.0", unlockLevel)));
|
||||
@@ -109,7 +110,7 @@ public class SmeltingCommand extends SkillCommand {
|
||||
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Smelting.Ability.Locked.1", Smelting.fluxMiningUnlockLevel)));
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Smelting.Ability.FluxMining", fluxMiningChance) + (isLucky ? LocaleLoader.getString("Perks.lucky.bonus", fluxMiningChanceLucky) : ""));
|
||||
player.sendMessage(LocaleLoader.getString("Smelting.Ability.FluxMining", fluxMiningChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", fluxMiningChanceLucky) : ""));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -86,17 +86,17 @@ public class SwordsCommand extends SkillCommand {
|
||||
@Override
|
||||
protected void statsDisplay() {
|
||||
if (canCounter) {
|
||||
player.sendMessage(LocaleLoader.getString("Swords.Combat.Counter.Chance", counterAttackChance) + (isLucky ? LocaleLoader.getString("Perks.lucky.bonus", counterAttackChanceLucky) : ""));
|
||||
player.sendMessage(LocaleLoader.getString("Swords.Combat.Counter.Chance", counterAttackChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", counterAttackChanceLucky) : ""));
|
||||
}
|
||||
|
||||
if (canBleed) {
|
||||
player.sendMessage(LocaleLoader.getString("Swords.Combat.Bleed.Length", bleedLength));
|
||||
player.sendMessage(LocaleLoader.getString("Swords.Combat.Bleed.Note"));
|
||||
player.sendMessage(LocaleLoader.getString("Swords.Combat.Bleed.Chance", bleedChance) + (isLucky ? LocaleLoader.getString("Perks.lucky.bonus", bleedChanceLucky) : ""));
|
||||
player.sendMessage(LocaleLoader.getString("Swords.Combat.Bleed.Chance", bleedChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", bleedChanceLucky) : ""));
|
||||
}
|
||||
|
||||
if (canSerratedStrike) {
|
||||
player.sendMessage(LocaleLoader.getString("Swords.SS.Length", serratedStrikesLength) + (hasEndurance ? LocaleLoader.getString("Perks.activationtime.bonus", serratedStrikesLengthEndurance) : ""));
|
||||
player.sendMessage(LocaleLoader.getString("Swords.SS.Length", serratedStrikesLength) + (hasEndurance ? LocaleLoader.getString("Perks.ActivationTime.Bonus", serratedStrikesLengthEndurance) : ""));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ public class TamingCommand extends SkillCommand {
|
||||
@Override
|
||||
protected void permissionsCheck() {
|
||||
canBeastLore = Permissions.beastLore(player);
|
||||
canCallWild = Permissions.callOfTheWild(player, EntityType.WOLF) || Permissions.callOfTheWild(player, EntityType.OCELOT);
|
||||
canCallWild = Permissions.callOfTheWild(player, EntityType.HORSE) || Permissions.callOfTheWild(player, EntityType.WOLF) || Permissions.callOfTheWild(player, EntityType.OCELOT);
|
||||
canEnvironmentallyAware = Permissions.environmentallyAware(player);
|
||||
canFastFood = Permissions.fastFoodService(player);
|
||||
canGore = Permissions.gore(player);
|
||||
@@ -93,6 +93,7 @@ public class TamingCommand extends SkillCommand {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Taming.Effect.12"), LocaleLoader.getString("Taming.Effect.13")));
|
||||
player.sendMessage(LocaleLoader.getString("Taming.Effect.14", Config.getInstance().getTamingCOTWOcelotCost()));
|
||||
player.sendMessage(LocaleLoader.getString("Taming.Effect.15", Config.getInstance().getTamingCOTWWolfCost()));
|
||||
player.sendMessage(LocaleLoader.getString("Taming.Effect.20", Config.getInstance().getTamingCOTWHorseCost()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -158,7 +159,7 @@ public class TamingCommand extends SkillCommand {
|
||||
}
|
||||
|
||||
if (canGore) {
|
||||
player.sendMessage(LocaleLoader.getString("Taming.Combat.Chance.Gore", goreChance) + (isLucky ? LocaleLoader.getString("Perks.lucky.bonus", goreChanceLucky) : ""));
|
||||
player.sendMessage(LocaleLoader.getString("Taming.Combat.Chance.Gore", goreChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", goreChanceLucky) : ""));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -113,19 +113,19 @@ public class UnarmedCommand extends SkillCommand {
|
||||
}
|
||||
|
||||
if (canDeflect) {
|
||||
player.sendMessage(LocaleLoader.getString("Unarmed.Ability.Chance.ArrowDeflect", deflectChance) + (isLucky ? LocaleLoader.getString("Perks.lucky.bonus", deflectChanceLucky) : ""));
|
||||
player.sendMessage(LocaleLoader.getString("Unarmed.Ability.Chance.ArrowDeflect", deflectChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", deflectChanceLucky) : ""));
|
||||
}
|
||||
|
||||
if (canDisarm) {
|
||||
player.sendMessage(LocaleLoader.getString("Unarmed.Ability.Chance.Disarm", disarmChance) + (isLucky ? LocaleLoader.getString("Perks.lucky.bonus", disarmChanceLucky) : ""));
|
||||
player.sendMessage(LocaleLoader.getString("Unarmed.Ability.Chance.Disarm", disarmChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", disarmChanceLucky) : ""));
|
||||
}
|
||||
|
||||
if (canIronGrip) {
|
||||
player.sendMessage(LocaleLoader.getString("Unarmed.Ability.Chance.IronGrip", ironGripChance) + (isLucky ? LocaleLoader.getString("Perks.lucky.bonus", ironGripChanceLucky) : ""));
|
||||
player.sendMessage(LocaleLoader.getString("Unarmed.Ability.Chance.IronGrip", ironGripChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", ironGripChanceLucky) : ""));
|
||||
}
|
||||
|
||||
if (canBerserk) {
|
||||
player.sendMessage(LocaleLoader.getString("Unarmed.Ability.Berserk.Length", berserkLength) + (hasEndurance ? LocaleLoader.getString("Perks.activationtime.bonus", berserkLengthEndurance) : ""));
|
||||
player.sendMessage(LocaleLoader.getString("Unarmed.Ability.Berserk.Length", berserkLength) + (hasEndurance ? LocaleLoader.getString("Perks.ActivationTime.Bonus", berserkLengthEndurance) : ""));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -85,11 +85,11 @@ public class WoodcuttingCommand extends SkillCommand {
|
||||
}
|
||||
|
||||
if (canDoubleDrop) {
|
||||
player.sendMessage(LocaleLoader.getString("Woodcutting.Ability.Chance.DDrop", doubleDropChance) + (isLucky ? LocaleLoader.getString("Perks.lucky.bonus", doubleDropChanceLucky) : ""));
|
||||
player.sendMessage(LocaleLoader.getString("Woodcutting.Ability.Chance.DDrop", doubleDropChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", doubleDropChanceLucky) : ""));
|
||||
}
|
||||
|
||||
if (canTreeFell) {
|
||||
player.sendMessage(LocaleLoader.getString("Woodcutting.Ability.Length", treeFellerLength) + (hasEndurance ? LocaleLoader.getString("Perks.activationtime.bonus", treeFellerLengthEndurance) : ""));
|
||||
player.sendMessage(LocaleLoader.getString("Woodcutting.Ability.Length", treeFellerLength) + (hasEndurance ? LocaleLoader.getString("Perks.ActivationTime.Bonus", treeFellerLengthEndurance) : ""));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,58 +0,0 @@
|
||||
package com.gmail.nossr50.commands.spout;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.util.StringUtil;
|
||||
|
||||
import com.gmail.nossr50.datatypes.spout.huds.HudType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
public class MchudCommand extends SpoutCommand {
|
||||
private static final List<String> HUD_TYPES;
|
||||
|
||||
static {
|
||||
ArrayList<String> types = new ArrayList<String>();
|
||||
|
||||
for (HudType type : HudType.values()) {
|
||||
types.add(type.toString());
|
||||
}
|
||||
|
||||
Collections.sort(types);
|
||||
HUD_TYPES = ImmutableList.copyOf(types);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
|
||||
switch (args.length) {
|
||||
case 1:
|
||||
return StringUtil.copyPartialMatches(args[0], HUD_TYPES, new ArrayList<String>(HUD_TYPES.size()));
|
||||
default:
|
||||
return ImmutableList.of();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean noArguments(Command command, CommandSender sender, String[] args) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean oneArgument(Command command, CommandSender sender, String[] args) {
|
||||
try {
|
||||
playerProfile.setHudType(HudType.valueOf(args[0].toUpperCase().trim()));
|
||||
spoutHud.initializeXpBar();
|
||||
spoutHud.updateXpBar();
|
||||
return true;
|
||||
}
|
||||
catch (IllegalArgumentException ex) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.mchud.Invalid"));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,54 +0,0 @@
|
||||
package com.gmail.nossr50.commands.spout;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabExecutor;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.spout.SpoutConfig;
|
||||
import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.spout.huds.McMMOHud;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
|
||||
public abstract class SpoutCommand implements TabExecutor {
|
||||
protected PlayerProfile playerProfile;
|
||||
protected McMMOHud spoutHud;
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (CommandUtils.noConsoleUsage(sender)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!mcMMO.isSpoutEnabled() || !SpoutConfig.getInstance().getXPBarEnabled()) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Disabled"));
|
||||
return true;
|
||||
}
|
||||
|
||||
playerProfile = UserManager.getPlayer((Player) sender).getProfile();
|
||||
spoutHud = playerProfile.getSpoutHud();
|
||||
|
||||
if (spoutHud == null) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Disabled"));
|
||||
return true;
|
||||
}
|
||||
|
||||
switch (args.length) {
|
||||
case 0:
|
||||
return noArguments(command, sender, args);
|
||||
|
||||
case 1:
|
||||
return oneArgument(command, sender, args);
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
protected abstract boolean noArguments(Command command, CommandSender sender, String[] args);
|
||||
|
||||
protected abstract boolean oneArgument(Command command, CommandSender sender, String[] args);
|
||||
}
|
||||
@@ -1,90 +0,0 @@
|
||||
package com.gmail.nossr50.commands.spout;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.util.StringUtil;
|
||||
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
public class XplockCommand extends SpoutCommand {
|
||||
@Override
|
||||
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
|
||||
switch (args.length) {
|
||||
case 1:
|
||||
List<String> matches = StringUtil.copyPartialMatches(args[0], CommandUtils.TRUE_FALSE_OPTIONS, new ArrayList<String>(CommandUtils.TRUE_FALSE_OPTIONS.size()));
|
||||
|
||||
if (matches.size() == 0) {
|
||||
return StringUtil.copyPartialMatches(args[0], SkillType.SKILL_NAMES, new ArrayList<String>(SkillType.SKILL_NAMES.size()));
|
||||
}
|
||||
|
||||
return matches;
|
||||
default:
|
||||
return ImmutableList.of();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean noArguments(Command command, CommandSender sender, String[] args) {
|
||||
if (spoutHud.getXpBarLocked()) {
|
||||
unlockXpBar(sender);
|
||||
return true;
|
||||
}
|
||||
|
||||
lockXpBar(sender, spoutHud.getLastGained());
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean oneArgument(Command command, CommandSender sender, String[] args) {
|
||||
if (CommandUtils.shouldEnableToggle(args[0])) {
|
||||
lockXpBar(sender, spoutHud.getLastGained());
|
||||
return true;
|
||||
}
|
||||
|
||||
if (CommandUtils.shouldDisableToggle(args[0])) {
|
||||
unlockXpBar(sender);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (CommandUtils.isInvalidSkill(sender, args[0])) {
|
||||
return true;
|
||||
}
|
||||
|
||||
SkillType skill = SkillType.getSkill(args[0]);
|
||||
|
||||
if (CommandUtils.isChildSkill(sender, skill)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!Permissions.xplock(sender, skill)) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return true;
|
||||
}
|
||||
|
||||
lockXpBar(sender, skill);
|
||||
return true;
|
||||
}
|
||||
|
||||
private void lockXpBar(CommandSender sender, SkillType skill) {
|
||||
if (skill != null) {
|
||||
spoutHud.setXpBarLocked(true);
|
||||
spoutHud.setSkillLock(skill);
|
||||
spoutHud.updateXpBar();
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.xplock.locked", SkillUtils.getSkillName(skill)));
|
||||
}
|
||||
}
|
||||
|
||||
private void unlockXpBar(CommandSender sender) {
|
||||
spoutHud.setXpBarLocked(false);
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.xplock.unlocked"));
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -63,7 +63,7 @@ public abstract class AutoUpdateConfigLoader extends ConfigLoader {
|
||||
output = output.replace(" ", " ");
|
||||
|
||||
// Rip out Bukkit's attempt to save comments at the top of the file
|
||||
while (output.indexOf('#') != -1) {
|
||||
while (output.replaceAll("[//s]", "").startsWith("#")) {
|
||||
output = output.substring(output.indexOf('\n', output.indexOf('#')) + 1);
|
||||
}
|
||||
|
||||
@@ -90,7 +90,7 @@ public abstract class AutoUpdateConfigLoader extends ConfigLoader {
|
||||
|
||||
// Dump to the new one
|
||||
for (String key : comments.keySet()) {
|
||||
if (output.indexOf(key) != -1) {
|
||||
if (output.contains(key)) {
|
||||
output = output.substring(0, output.indexOf(key)) + comments.get(key) + output.substring(output.indexOf(key));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,26 +45,52 @@ public class Config extends AutoUpdateConfigLoader {
|
||||
}
|
||||
|
||||
/* Scoreboards */
|
||||
if (getMcrankScoreboardTime() != -1 && getMcrankScoreboardTime() <= 0) {
|
||||
reason.add("Scoreboards.Mcrank.Display_Time should be greater than 0 or -1!");
|
||||
if (getRankScoreboardTime() != -1 && getRankScoreboardTime() <= 0) {
|
||||
reason.add("Scoreboard.Types.Rank.Display_Time should be greater than 0, or -1!");
|
||||
}
|
||||
|
||||
if (getMcstatsScoreboardTime() != -1 && getMcstatsScoreboardTime() <= 0) {
|
||||
reason.add("Scoreboards.Mcstats.Display_Time should be greater than 0 or -1!");
|
||||
if (getStatsScoreboardTime() != -1 && getStatsScoreboardTime() <= 0) {
|
||||
reason.add("Scoreboard.Types.Stats.Display_Time should be greater than 0, or -1!");
|
||||
}
|
||||
|
||||
if (getMctopScoreboardTime() != -1 && getMctopScoreboardTime() <= 0) {
|
||||
reason.add("Scoreboards.Mctop.Display_Time should be greater than 0 or -1!");
|
||||
if (getTopScoreboardTime() != -1 && getTopScoreboardTime() <= 0) {
|
||||
reason.add("Scoreboard.Types.Top.Display_Time should be greater than 0, or -1!");
|
||||
}
|
||||
|
||||
if (getInspectScoreboardTime() != -1 && getInspectScoreboardTime() <= 0) {
|
||||
reason.add("Scoreboards.Inspect.Display_Time should be greater than 0 or -1!");
|
||||
reason.add("Scoreboard.Types.Inspect.Display_Time should be greater than 0, or -1!");
|
||||
}
|
||||
|
||||
if (getSkillScoreboardTime() != -1 && getSkillScoreboardTime() <= 0) {
|
||||
reason.add("Scoreboards.Skillname.Display_Time should be greater than 0 or -1!");
|
||||
reason.add("Scoreboard.Types.Skill.Display_Time should be greater than 0, or -1!");
|
||||
}
|
||||
|
||||
if (getSkillLevelUpTime() != -1 && getSkillScoreboardTime() <= 0) {
|
||||
reason.add("Scoreboard.Types.Skill.Display_Time should be greater than 0, or -1!");
|
||||
}
|
||||
|
||||
if (!(getRankUseChat() || getRankUseBoard())) {
|
||||
reason.add("Either Board or Print in Scoreboard.Types.Rank must be true!");
|
||||
}
|
||||
|
||||
if (!(getTopUseChat() || getTopUseBoard())) {
|
||||
reason.add("Either Board or Print in Scoreboard.Types.Top must be true!");
|
||||
}
|
||||
|
||||
if (!(getStatsUseChat() || getStatsUseBoard())) {
|
||||
reason.add("Either Board or Print in Scoreboard.Types.Stats must be true!");
|
||||
}
|
||||
|
||||
if (!(getInspectUseChat() || getInspectUseBoard())) {
|
||||
reason.add("Either Board or Print in Scoreboard.Types.Inspect must be true!");
|
||||
}
|
||||
|
||||
/* Skill.Print setting removed, as I can't think of a good use for it
|
||||
if (!(getSkillUseChat() || getSkillUseBoard())) {
|
||||
reason.add("Either Board or Print in Scoreboard.Commands.Skill must be true!");
|
||||
}
|
||||
// */
|
||||
|
||||
/* Database Purging */
|
||||
if (getPurgeInterval() < -1) {
|
||||
reason.add("Database_Purging.Purge_Interval should be greater than, or equal to -1!");
|
||||
@@ -75,12 +101,12 @@ public class Config extends AutoUpdateConfigLoader {
|
||||
}
|
||||
|
||||
/* Hardcore Mode */
|
||||
if (getHardcoreDeathStatPenaltyPercentage() < 1 || getHardcoreDeathStatPenaltyPercentage() > 100) {
|
||||
reason.add("Hardcore.Death_Stat_Loss.Penalty_Percentage only accepts values from 1 to 100!");
|
||||
if (getHardcoreDeathStatPenaltyPercentage() < 0.01 || getHardcoreDeathStatPenaltyPercentage() > 100) {
|
||||
reason.add("Hardcore.Death_Stat_Loss.Penalty_Percentage only accepts values from 0.01 to 100!");
|
||||
}
|
||||
|
||||
if (getHardcoreVampirismStatLeechPercentage() < 1 || getHardcoreVampirismStatLeechPercentage() > 100) {
|
||||
reason.add("Hardcore.Vampirism.Leech_Percentage only accepts values from 1 to 100!");
|
||||
if (getHardcoreVampirismStatLeechPercentage() < 0.01 || getHardcoreVampirismStatLeechPercentage() > 100) {
|
||||
reason.add("Hardcore.Vampirism.Leech_Percentage only accepts values from 0.01 to 100!");
|
||||
}
|
||||
|
||||
/* Items */
|
||||
@@ -92,8 +118,8 @@ public class Config extends AutoUpdateConfigLoader {
|
||||
reason.add("Items.Chimaera_Wing.Recipe_Cost only accepts values from 1 to 64!");
|
||||
}
|
||||
|
||||
if (getChimaeraItemId() < 1) {
|
||||
reason.add("Items.Chimaera_Wing.Item_ID should be at least 1!");
|
||||
if (getChimaeraItem() == null) {
|
||||
reason.add("Items.Chimaera_Wing.Item_Name is invalid!");
|
||||
}
|
||||
|
||||
/* Particles */
|
||||
@@ -135,21 +161,20 @@ public class Config extends AutoUpdateConfigLoader {
|
||||
reason.add("Abilities.Limits.Tree_Feller_Threshold should be greater than 0!");
|
||||
}
|
||||
|
||||
|
||||
if (getDetonatorItemID() < 1) {
|
||||
reason.add("Skills.Mining.Detonator_ID should be at least 1!");
|
||||
if (getDetonatorItem() == null) {
|
||||
reason.add("Skills.Mining.Detonator_Item is invalid!");
|
||||
}
|
||||
|
||||
if (getRepairAnvilId() < 1) {
|
||||
reason.add("Skills.Repair.Anvil_ID should be at least 1!");
|
||||
if (getRepairAnvilMaterial() == null) {
|
||||
reason.add("Skills.Repair.Anvil_Type is invalid!!");
|
||||
}
|
||||
|
||||
if (getSalvageAnvilId() < 1) {
|
||||
reason.add("Skills.Repair.Salvage_Anvil_ID should be at least 1!");
|
||||
if (getSalvageAnvilMaterial() == null) {
|
||||
reason.add("Skills.Repair.Salvage_Anvil_Type is invalid!");
|
||||
}
|
||||
|
||||
if (getRepairAnvilId() == getSalvageAnvilId()) {
|
||||
reason.add("Cannot use the same item ID for Repair and Salvage anvils!");
|
||||
if (getRepairAnvilMaterial() == getSalvageAnvilMaterial()) {
|
||||
reason.add("Cannot use the same item for Repair and Salvage anvils!");
|
||||
}
|
||||
|
||||
if (getTamingCOTWWolfCost() < 1) {
|
||||
@@ -191,12 +216,14 @@ public class Config extends AutoUpdateConfigLoader {
|
||||
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.p.Chat_Prefix_Format", "[[GREEN]]([[WHITE]]{0}[[GREEN]])"); }
|
||||
public boolean getPartyChatColorLeaderName() { return config.getBoolean("Commands.p.Gold_Leader_Name", true); }
|
||||
public boolean getPartyDisplayNames() { return config.getBoolean("Commands.p.Use_Display_Names", true); }
|
||||
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 getPartyDisplayNames() { return config.getBoolean("Commands.partychat.Use_Display_Names", true); }
|
||||
|
||||
public String getAdminChatPrefix() { return config.getString("Commands.a.Chat_Prefix_Format", "[[AQUA]][[[WHITE]]{0}[[AQUA]]]"); }
|
||||
public boolean getAdminDisplayNames() { return config.getBoolean("Commands.a.Use_Display_Names", true); }
|
||||
public String getAdminChatPrefix() { return config.getString("Commands.adminchat.Chat_Prefix_Format", "[[AQUA]][[[WHITE]]{0}[[AQUA]]]"); }
|
||||
public boolean getAdminDisplayNames() { return config.getBoolean("Commands.adminchat.Use_Display_Names", true); }
|
||||
|
||||
public boolean getMatchOfflinePlayers() { return config.getBoolean("Commands.Generic.Match_OfflinePlayers", false); }
|
||||
|
||||
/* Mob Healthbar */
|
||||
public MobHealthbarType getMobHealthbarDefault() {
|
||||
@@ -211,22 +238,36 @@ public class Config extends AutoUpdateConfigLoader {
|
||||
public int getMobHealthbarTime() { return config.getInt("Mob_Healthbar.Display_Time", 3); }
|
||||
|
||||
/* Scoreboards */
|
||||
public boolean getMcrankScoreboardEnabled() { return config.getBoolean("Scoreboards.Mcrank.Use", true); }
|
||||
public int getMcrankScoreboardTime() { return config.getInt("Scoreboards.Mcrank.Display_Time", 10); }
|
||||
public boolean getRankUseChat() { return config.getBoolean("Scoreboard.Types.Rank.Print", false); }
|
||||
public boolean getRankUseBoard() { return config.getBoolean("Scoreboard.Types.Rank.Board", true); }
|
||||
public int getRankScoreboardTime() { return config.getInt("Scoreboard.Types.Rank.Display_Time", 10); }
|
||||
|
||||
public boolean getMcstatsScoreboardsEnabled() { return config.getBoolean("Scoreboards.Mcstats.Use", true); }
|
||||
public int getMcstatsScoreboardTime() { return config.getInt("Scoreboards.Mcstats.Display_Time", 10); }
|
||||
public boolean getTopUseChat() { return config.getBoolean("Scoreboard.Types.Top.Print", true); }
|
||||
public boolean getTopUseBoard() { return config.getBoolean("Scoreboard.Types.Top.Board", true); }
|
||||
public int getTopScoreboardTime() { return config.getInt("Scoreboard.Types.Top.Display_Time", 15); }
|
||||
|
||||
public boolean getMctopScoreboardEnabled() { return config.getBoolean("Scoreboards.Mctop.Use", true); }
|
||||
public int getMctopScoreboardTime() { return config.getInt("Scoreboards.Mctop.Display_Time", 10); }
|
||||
public boolean getStatsUseChat() { return config.getBoolean("Scoreboard.Types.Stats.Print", true); }
|
||||
public boolean getStatsUseBoard() { return config.getBoolean("Scoreboard.Types.Stats.Board", true); }
|
||||
public int getStatsScoreboardTime() { return config.getInt("Scoreboard.Types.Stats.Display_Time", 10); }
|
||||
|
||||
public boolean getInspectScoreboardEnabled() { return config.getBoolean("Scoreboards.Inspect.Use", true); }
|
||||
public int getInspectScoreboardTime() { return config.getInt("Scoreboards.Inspect.Display_Time", 10); }
|
||||
public boolean getInspectUseChat() { return config.getBoolean("Scoreboard.Types.Inspect.Print", true); }
|
||||
public boolean getInspectUseBoard() { return config.getBoolean("Scoreboard.Types.Inspect.Board", true); }
|
||||
public int getInspectScoreboardTime() { return config.getInt("Scoreboard.Types.Inspect.Display_Time", 25); }
|
||||
|
||||
public boolean getSkillScoreboardEnabled() { return config.getBoolean("Scoreboards.Skillname.Use", true); }
|
||||
public int getSkillScoreboardTime() { return config.getInt("Scoreboards.Skillname.Display_Time", 10); }
|
||||
public boolean getCooldownUseChat() { return config.getBoolean("Scoreboard.Types.Cooldown.Print", false); }
|
||||
public boolean getCooldownUseBoard() { return config.getBoolean("Scoreboard.Types.Cooldown.Board", true); }
|
||||
public int getCooldownScoreboardTime() { return config.getInt("Scoreboard.Types.Cooldown.Display_Time", 41); }
|
||||
|
||||
public boolean getPowerLevelsEnabled() { return config.getBoolean("Scoreboards.Power_Level.Use", false); }
|
||||
// public boolean getSkillUseChat() { return config.getBoolean("Scoreboard.Types.Skill.Print", false); }
|
||||
public boolean getSkillUseBoard() { return config.getBoolean("Scoreboard.Types.Skill.Board", true); }
|
||||
public int getSkillScoreboardTime() { return config.getInt("Scoreboard.Types.Skill.Display_Time", 30); }
|
||||
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 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 */
|
||||
public int getPurgeInterval() { return config.getInt("Database_Purging.Purge_Interval", -1); }
|
||||
@@ -235,24 +276,17 @@ public class Config extends AutoUpdateConfigLoader {
|
||||
/* mySQL */
|
||||
public boolean getUseMySQL() { return config.getBoolean("MySQL.Enabled", false); }
|
||||
public String getMySQLTablePrefix() { return config.getString("MySQL.Database.TablePrefix", "mcmmo_"); }
|
||||
public String getMySQLDatabaseName() { return getStringIncludingInts(config, "MySQL.Database.Name"); }
|
||||
public String getMySQLUserName() { return getStringIncludingInts(config, "MySQL.Database.User_Name"); }
|
||||
public String getMySQLDatabaseName() { return getStringIncludingInts("MySQL.Database.Name"); }
|
||||
public String getMySQLUserName() { return getStringIncludingInts("MySQL.Database.User_Name"); }
|
||||
public int getMySQLServerPort() { return config.getInt("MySQL.Server.Port", 3306); }
|
||||
public String getMySQLServerName() { return config.getString("MySQL.Server.Address", "localhost"); }
|
||||
public String getMySQLUserPassword() { return getStringIncludingInts("MySQL.Database.User_Password"); }
|
||||
|
||||
public String getMySQLUserPassword() {
|
||||
if (getStringIncludingInts(config, "MySQL.Database.User_Password") != null) {
|
||||
return getStringIncludingInts(config, "MySQL.Database.User_Password");
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
private static String getStringIncludingInts(ConfigurationSection cfg, String key) {
|
||||
String str = cfg.getString(key);
|
||||
private String getStringIncludingInts(String key) {
|
||||
String str = config.getString(key);
|
||||
|
||||
if (str == null) {
|
||||
str = String.valueOf(cfg.getInt(key));
|
||||
str = String.valueOf(config.getInt(key));
|
||||
}
|
||||
|
||||
if (str.equals("0")) {
|
||||
@@ -265,25 +299,25 @@ public class Config extends AutoUpdateConfigLoader {
|
||||
public boolean getHardcoreStatLossEnabled(SkillType skillType) { return config.getBoolean("Hardcore.Death_Stat_Loss.Enabled." + StringUtils.getCapitalized(skillType.toString()), false); }
|
||||
public void setHardcoreStatLossEnabled(SkillType skillType, boolean enabled) { config.set("Hardcore.Death_Stat_Loss.Enabled." + StringUtils.getCapitalized(skillType.toString()), enabled); }
|
||||
|
||||
public double getHardcoreDeathStatPenaltyPercentage() { return config.getDouble("Hardcore.Death_Stat_Loss.Penalty_Percentage", 75.0); }
|
||||
public double getHardcoreDeathStatPenaltyPercentage() { return config.getDouble("Hardcore.Death_Stat_Loss.Penalty_Percentage", 75.0D); }
|
||||
public void setHardcoreDeathStatPenaltyPercentage(double value) { config.set("Hardcore.Death_Stat_Loss.Penalty_Percentage", value); }
|
||||
|
||||
public boolean getHardcoreVampirismEnabled(SkillType skillType) { return config.getBoolean("Hardcore.Vampirism.Enabled." + StringUtils.getCapitalized(skillType.toString()), false); }
|
||||
public void setHardcoreVampirismEnabled(SkillType skillType, boolean enabled) { config.set("Hardcore.Vampirism.Enabled." + StringUtils.getCapitalized(skillType.toString()), enabled); }
|
||||
|
||||
public double getHardcoreVampirismStatLeechPercentage() { return config.getDouble("Hardcore.Vampirism.Leech_Percentage", 5.0); }
|
||||
public double getHardcoreVampirismStatLeechPercentage() { return config.getDouble("Hardcore.Vampirism.Leech_Percentage", 5.0D); }
|
||||
public void setHardcoreVampirismStatLeechPercentage(double value) { config.set("Hardcore.Vampirism.Leech_Percentage", value); }
|
||||
|
||||
/* SMP Mods */
|
||||
public boolean getToolModsEnabled() { return config.getBoolean("Mods.Tool_Mods_Enabled", false); }
|
||||
public boolean getArmorModsEnabled() { return config.getBoolean("Mods.Tool_Mods_Enabled", false); }
|
||||
public boolean getArmorModsEnabled() { return config.getBoolean("Mods.Armor_Mods_Enabled", false); }
|
||||
public boolean getBlockModsEnabled() { return config.getBoolean("Mods.Block_Mods_Enabled", false); }
|
||||
public boolean getEntityModsEnabled() { return config.getBoolean("Mods.Entity_Mods_Enabled", false); }
|
||||
|
||||
/* Items */
|
||||
public int getChimaeraUseCost() { return config.getInt("Items.Chimaera_Wing.Use_Cost", 1); }
|
||||
public int getChimaeraRecipeCost() { return config.getInt("Items.Chimaera_Wing.Recipe_Cost", 5); }
|
||||
public int getChimaeraItemId() { return config.getInt("Items.Chimaera_Wing.Item_ID", 288); }
|
||||
public Material getChimaeraItem() { return Material.matchMaterial(config.getString("Items.Chimaera_Wing.Item_Name", "Feather")); }
|
||||
public boolean getChimaeraEnabled() { return config.getBoolean("Items.Chimaera_Wing.Enabled", true); }
|
||||
public boolean getChimaeraPreventUseUnderground() { return config.getBoolean("Items.Chimaera_Wing.Prevent_Use_Underground", true); }
|
||||
public int getChimaeraCooldown() { return config.getInt("Items.Chimaera_Wing.Cooldown", 240); }
|
||||
@@ -304,11 +338,11 @@ public class Config extends AutoUpdateConfigLoader {
|
||||
public int getAutoPartyKickInterval() { return config.getInt("Party.AutoKick_Interval", 12); }
|
||||
public int getAutoPartyKickTime() { return config.getInt("Party.Old_Party_Member_Cutoff", 7); }
|
||||
public boolean getExpShareEnabled() { return config.getBoolean("Party.Sharing.ExpShare_enabled", true); }
|
||||
public double getPartyShareBonusBase() { return config.getDouble("Party.Sharing.ExpShare_bonus_base", 1.1); }
|
||||
public double getPartyShareBonusIncrease() { return config.getDouble("Party.Sharing.ExpShare_bonus_increase", 0.05); }
|
||||
public double getPartyShareBonusCap() { return config.getDouble("Party.Sharing.ExpShare_bonus_cap", 1.5); }
|
||||
public double getPartyShareBonusBase() { return config.getDouble("Party.Sharing.ExpShare_bonus_base", 1.1D); }
|
||||
public double getPartyShareBonusIncrease() { return config.getDouble("Party.Sharing.ExpShare_bonus_increase", 0.05D); }
|
||||
public double getPartyShareBonusCap() { return config.getDouble("Party.Sharing.ExpShare_bonus_cap", 1.5D); }
|
||||
public boolean getItemShareEnabled() { return config.getBoolean("Party.Sharing.ItemShare_enabled", true); }
|
||||
public double getPartyShareRange() { return config.getDouble("Party.Sharing.Range", 75.0); }
|
||||
public double getPartyShareRange() { return config.getDouble("Party.Sharing.Range", 75.0D); }
|
||||
|
||||
/* Party Teleport Settings */
|
||||
public int getPTPCommandCooldown() { return config.getInt("Commands.ptp.Cooldown", 120); }
|
||||
@@ -319,7 +353,7 @@ public class Config extends AutoUpdateConfigLoader {
|
||||
public boolean getPTPCommandWorldPermissions() { return config.getBoolean("Commands.ptp.World_Based_Permissions", false); }
|
||||
|
||||
/* Inspect command distance */
|
||||
public double getInspectDistance() { return config.getDouble("Commands.inspect.Max_Distance", 30); }
|
||||
public double getInspectDistance() { return config.getDouble("Commands.inspect.Max_Distance", 30.0D); }
|
||||
|
||||
/*
|
||||
* ABILITY SETTINGS
|
||||
@@ -330,11 +364,11 @@ public class Config extends AutoUpdateConfigLoader {
|
||||
public boolean getAbilitiesEnabled() { return config.getBoolean("Abilities.Enabled", true); }
|
||||
public boolean getAbilitiesOnlyActivateWhenSneaking() { return config.getBoolean("Abilities.Activation.Only_Activate_When_Sneaking", false); }
|
||||
|
||||
public int getCooldown(AbilityType ability) { return config.getInt("Abilities.Cooldowns." + ability.toString()); }
|
||||
public int getMaxTicks(AbilityType ability) { return config.getInt("Abilities.Max_Seconds." + ability.toString()); }
|
||||
public int getCooldown(AbilityType ability) { return config.getInt("Abilities.Cooldowns." + ability.getConfigString()); }
|
||||
public int getMaxLength(AbilityType ability) { return config.getInt("Abilities.Max_Seconds." + ability.getConfigString()); }
|
||||
|
||||
/* Durability Settings */
|
||||
public int getAbilityToolDamage() { return config.getInt("Abilities.Tools.Durability_Loss", 2); }
|
||||
public int getAbilityToolDamage() { return config.getInt("Abilities.Tools.Durability_Loss", 1); }
|
||||
|
||||
/* Thresholds */
|
||||
public int getTreeFellerThreshold() { return config.getInt("Abilities.Limits.Tree_Feller_Threshold", 500); }
|
||||
@@ -368,12 +402,12 @@ public class Config extends AutoUpdateConfigLoader {
|
||||
public boolean getFishingDropsEnabled() { return config.getBoolean("Skills.Fishing.Drops_Enabled", true); }
|
||||
|
||||
/* Mining */
|
||||
public int getDetonatorItemID() { return config.getInt("Skills.Mining.Detonator_ID", 259); }
|
||||
public Material getDetonatorItem() { return Material.matchMaterial(config.getString("Skills.Mining.Detonator_Name", "FLINT_AND_STEEL")); }
|
||||
|
||||
/* Repair */
|
||||
public boolean getRepairAnvilMessagesEnabled() { return config.getBoolean("Skills.Repair.Anvil_Messages", true); }
|
||||
public int getRepairAnvilId() { return config.getInt("Skills.Repair.Anvil_ID", 42); }
|
||||
public int getSalvageAnvilId() { return config.getInt("Skills.Repair.Salvage_Anvil_ID", 41); }
|
||||
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_ID", "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); }
|
||||
@@ -385,7 +419,7 @@ public class Config extends AutoUpdateConfigLoader {
|
||||
public int getTamingCOTWHorseCost() { return config.getInt("Skills.Taming.Call_Of_The_Wild.Apples_Required", 10); }
|
||||
public int getTamingCOTWWolfCost() { return config.getInt("Skills.Taming.Call_Of_The_Wild.Bones_Required", 10); }
|
||||
public int getTamingCOTWOcelotCost() { return config.getInt("Skills.Taming.Call_Of_The_Wild.Fish_Required", 10); }
|
||||
public double getTamingCOTWRange() { return config.getDouble("Skills.Taming.Call_Of_The_Wild.Range", 40); }
|
||||
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 */
|
||||
@@ -396,6 +430,7 @@ public class Config extends AutoUpdateConfigLoader {
|
||||
|
||||
/* AFK Leveling */
|
||||
public boolean getAcrobaticsAFKDisabled() { return config.getBoolean("Skills.Acrobatics.Prevent_AFK_Leveling", true); }
|
||||
public int getAcrobaticsAFKMaxTries() { return config.getInt("Skills.Acrobatics.Max_Tries_At_Same_Location", 3); }
|
||||
public boolean getHerbalismAFKDisabled() { return config.getBoolean("Skills.Herbalism.Prevent_AFK_Leveling", true); }
|
||||
|
||||
/* Level Caps */
|
||||
|
||||
@@ -1,11 +1,6 @@
|
||||
package com.gmail.nossr50.config;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
@@ -16,7 +11,7 @@ import com.gmail.nossr50.mcMMO;
|
||||
public abstract class ConfigLoader {
|
||||
protected static final mcMMO plugin = mcMMO.p;
|
||||
protected String fileName;
|
||||
protected File configFile;
|
||||
private File configFile;
|
||||
protected FileConfiguration config;
|
||||
|
||||
public ConfigLoader(String relativePath, String fileName) {
|
||||
@@ -34,7 +29,13 @@ public abstract class ConfigLoader {
|
||||
protected void loadFile() {
|
||||
if (!configFile.exists()) {
|
||||
plugin.debug("Creating mcMMO " + fileName + " File...");
|
||||
createFile();
|
||||
|
||||
try {
|
||||
plugin.saveResource(fileName, false); // Normal files
|
||||
}
|
||||
catch (IllegalArgumentException ex) {
|
||||
plugin.saveResource(configFile.getParentFile().getName() + File.separator + fileName, false); // Mod files
|
||||
}
|
||||
}
|
||||
else {
|
||||
plugin.debug("Loading mcMMO " + fileName + " File...");
|
||||
@@ -45,53 +46,6 @@ public abstract class ConfigLoader {
|
||||
|
||||
protected abstract void loadKeys();
|
||||
|
||||
protected void createFile() {
|
||||
configFile.getParentFile().mkdirs();
|
||||
|
||||
InputStream inputStream = plugin.getResource(fileName);
|
||||
|
||||
if (inputStream == null) {
|
||||
plugin.getLogger().severe("Missing resource file: '" + fileName + "' please notify the plugin authors");
|
||||
return;
|
||||
}
|
||||
|
||||
OutputStream outputStream = null;
|
||||
|
||||
try {
|
||||
outputStream = new FileOutputStream(configFile);
|
||||
|
||||
int read;
|
||||
byte[] bytes = new byte[1024];
|
||||
|
||||
while ((read = inputStream.read(bytes)) != -1) {
|
||||
outputStream.write(bytes, 0, read);
|
||||
}
|
||||
}
|
||||
catch (FileNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
finally {
|
||||
if (outputStream != null) {
|
||||
try {
|
||||
outputStream.close();
|
||||
}
|
||||
catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
inputStream.close();
|
||||
}
|
||||
catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected boolean validateKeys() {
|
||||
return true;
|
||||
}
|
||||
@@ -114,4 +68,23 @@ public abstract class ConfigLoader {
|
||||
plugin.noErrorsInConfigFiles = false;
|
||||
}
|
||||
}
|
||||
|
||||
public File getFile() {
|
||||
return configFile;
|
||||
}
|
||||
|
||||
public void backup() {
|
||||
plugin.getLogger().warning("You are using an old version of the " + fileName + " file.");
|
||||
plugin.getLogger().warning("Your old file has been renamed to " + fileName + ".old and has been replaced by an updated version.");
|
||||
|
||||
configFile.renameTo(new File(configFile.getPath() + ".old"));
|
||||
|
||||
if (plugin.getResource(fileName) != null) {
|
||||
plugin.saveResource(fileName, true);
|
||||
}
|
||||
|
||||
plugin.getLogger().warning("Reloading " + fileName + " with new values...");
|
||||
loadFile();
|
||||
loadKeys();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ import org.bukkit.entity.EntityType;
|
||||
import com.gmail.nossr50.config.AutoUpdateConfigLoader;
|
||||
import com.gmail.nossr50.datatypes.experience.FormulaType;
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.skills.repair.RepairMaterialType;
|
||||
import com.gmail.nossr50.skills.repair.repairables.RepairMaterialType;
|
||||
import com.gmail.nossr50.util.StringUtils;
|
||||
|
||||
public class ExperienceConfig extends AutoUpdateConfigLoader {
|
||||
@@ -85,6 +85,18 @@ public class ExperienceConfig extends AutoUpdateConfigLoader {
|
||||
reason.add("Experience.Combat.Multiplier.Wither_Skeleton should be at least 0!");
|
||||
}
|
||||
|
||||
if (getDodgeXPModifier() < 0) {
|
||||
reason.add("Skills.Acrobatics.Dodge_XP_Modifier should be at least 0!");
|
||||
}
|
||||
|
||||
if (getRollXPModifier() < 0) {
|
||||
reason.add("Skills.Acrobatics.Roll_XP_Modifier should be at least 0!");
|
||||
}
|
||||
|
||||
if (getFallXPModifier() < 0) {
|
||||
reason.add("Skills.Acrobatics.Fall_XP_Modifier should be at least 0!");
|
||||
}
|
||||
|
||||
/* Fishing */
|
||||
if (getFishingBaseXP() <= 0) {
|
||||
reason.add("Experience.Fishing.Base should be greater than 0!");
|
||||
@@ -176,6 +188,13 @@ public class ExperienceConfig extends AutoUpdateConfigLoader {
|
||||
/* Materials */
|
||||
public int getXp(SkillType skill, Material material) { return config.getInt("Experience." + StringUtils.getCapitalized(skill.toString()) + "." + StringUtils.getPrettyItemString(material).replace(" ", "_")); }
|
||||
|
||||
/* Acrobatics */
|
||||
public int getDodgeXPModifier() { return config.getInt("Experience.Acrobatics.Dodge", 120); }
|
||||
public int getRollXPModifier() { return config.getInt("Experience.Acrobatics.Roll", 80); }
|
||||
public int getFallXPModifier() { return config.getInt("Experience.Acrobatics.Fall", 120); }
|
||||
|
||||
public double getFeatherFallXPModifier() { return config.getDouble("Experience.Acrobatics.FeatherFall_Multiplier", 2.0); }
|
||||
|
||||
/* Fishing */
|
||||
public int getFishingBaseXP() { return config.getInt("Experience.Fishing.Base", 800); }
|
||||
|
||||
|
||||
@@ -1,33 +1,34 @@
|
||||
package com.gmail.nossr50.config.mods;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
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.mods.CustomItem;
|
||||
import com.gmail.nossr50.skills.repair.Repairable;
|
||||
import com.gmail.nossr50.skills.repair.RepairableFactory;
|
||||
import com.gmail.nossr50.skills.repair.Repair;
|
||||
import com.gmail.nossr50.skills.repair.repairables.RepairItemType;
|
||||
import com.gmail.nossr50.skills.repair.repairables.RepairMaterialType;
|
||||
import com.gmail.nossr50.skills.repair.repairables.Repairable;
|
||||
import com.gmail.nossr50.skills.repair.repairables.RepairableFactory;
|
||||
|
||||
public class CustomArmorConfig extends ConfigLoader {
|
||||
private static CustomArmorConfig instance;
|
||||
|
||||
private boolean needsUpdate = false;
|
||||
|
||||
private List<Repairable> repairables;
|
||||
|
||||
public List<Integer> customBootIDs = new ArrayList<Integer>();
|
||||
public List<Integer> customChestplateIDs = new ArrayList<Integer>();
|
||||
public List<Integer> customHelmetIDs = new ArrayList<Integer>();
|
||||
public List<Integer> customLeggingIDs = new ArrayList<Integer>();
|
||||
public List<Integer> customIDs = new ArrayList<Integer>();
|
||||
|
||||
public List<CustomItem> customArmorList = new ArrayList<CustomItem>();
|
||||
public HashMap<Integer, CustomItem> customArmor = new HashMap<Integer, CustomItem>();
|
||||
private List<Material> customBoots = new ArrayList<Material>();
|
||||
private List<Material> customChestplates = new ArrayList<Material>();
|
||||
private List<Material> customHelmets = new ArrayList<Material>();
|
||||
private List<Material> customLeggings = new ArrayList<Material>();
|
||||
|
||||
public CustomArmorConfig() {
|
||||
super("ModConfigs", "armor.yml");
|
||||
super("mods", "armor.yml");
|
||||
loadKeys();
|
||||
}
|
||||
|
||||
@@ -51,13 +52,22 @@ public class CustomArmorConfig extends ConfigLoader {
|
||||
protected void loadKeys() {
|
||||
repairables = new ArrayList<Repairable>();
|
||||
|
||||
loadArmor("Boots", customBootIDs);
|
||||
loadArmor("Chestplates", customChestplateIDs);
|
||||
loadArmor("Helmets", customHelmetIDs);
|
||||
loadArmor("Leggings", customLeggingIDs);
|
||||
loadArmor("Boots", customBoots);
|
||||
loadArmor("Chestplates", customChestplates);
|
||||
loadArmor("Helmets", customHelmets);
|
||||
loadArmor("Leggings", customLeggings);
|
||||
|
||||
if (needsUpdate) {
|
||||
needsUpdate = false;
|
||||
backup();
|
||||
}
|
||||
}
|
||||
|
||||
private void loadArmor(String armorType, List<Integer> idList) {
|
||||
private void loadArmor(String armorType, List<Material> materialList) {
|
||||
if (needsUpdate) {
|
||||
return;
|
||||
}
|
||||
|
||||
ConfigurationSection armorSection = config.getConfigurationSection(armorType);
|
||||
|
||||
if (armorSection == null) {
|
||||
@@ -67,35 +77,60 @@ public class CustomArmorConfig extends ConfigLoader {
|
||||
Set<String> armorConfigSet = armorSection.getKeys(false);
|
||||
|
||||
for (String armorName : armorConfigSet) {
|
||||
int id = config.getInt(armorType + "." + armorName + ".ID", 0);
|
||||
boolean repairable = config.getBoolean(armorType + "." + armorName + ".Repairable");
|
||||
int repairID = config.getInt(armorType + "." + armorName + ".Repair_Material_ID", 0);
|
||||
byte repairData = (byte) config.getInt(armorType + "." + armorName + ".Repair_Material_Data_Value", 0);
|
||||
int repairQuantity = config.getInt(armorType + "." + armorName + ".Repair_Material_Quantity", 0);
|
||||
short durability = (short) config.getInt(armorType + "." + armorName + ".Durability", 0);
|
||||
if (config.contains(armorType + "." + armorName + "." + ".ID")) {
|
||||
needsUpdate = true;
|
||||
return;
|
||||
}
|
||||
|
||||
if (id == 0) {
|
||||
plugin.getLogger().warning("Missing ID. This item will be skipped.");
|
||||
Material armorMaterial = Material.matchMaterial(armorName);
|
||||
|
||||
if (armorMaterial == null) {
|
||||
plugin.getLogger().warning("Invalid material name. This item will be skipped. - " + armorName);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (repairable && (repairID == 0 || repairQuantity == 0 || durability == 0)) {
|
||||
plugin.getLogger().warning("Incomplete repair information. This item will be unrepairable.");
|
||||
boolean repairable = config.getBoolean(armorType + "." + armorName + ".Repairable");
|
||||
Material repairMaterial = Material.matchMaterial(config.getString(armorType + "." + armorName + ".Repair_Material", ""));
|
||||
|
||||
if (repairMaterial == null) {
|
||||
plugin.getLogger().warning("Incomplete repair information. This item will be unrepairable. - " + armorName);
|
||||
repairable = false;
|
||||
}
|
||||
|
||||
CustomItem armor;
|
||||
|
||||
if (repairable) {
|
||||
repairables.add(RepairableFactory.getRepairable(id, repairID, repairData, repairQuantity, durability));
|
||||
byte repairData = (byte) config.getInt(armorType + "." + armorName + ".Repair_Material_Data_Value", -1);
|
||||
int repairQuantity = Repair.getRepairAndSalvageQuantities(new ItemStack(armorMaterial), repairMaterial, repairData);
|
||||
|
||||
if (repairQuantity == 0) {
|
||||
repairQuantity = config.getInt(armorType + "." + armorName + ".Repair_Material_Data_Quantity", 2);
|
||||
}
|
||||
|
||||
short durability = armorMaterial.getMaxDurability();
|
||||
|
||||
if (durability == 0) {
|
||||
durability = (short) config.getInt(armorType + "." + armorName + ".Durability", 70);
|
||||
}
|
||||
|
||||
repairables.add(RepairableFactory.getRepairable(armorMaterial, repairMaterial, repairData, repairQuantity, 0, durability, RepairItemType.ARMOR, RepairMaterialType.OTHER, 1.0));
|
||||
}
|
||||
|
||||
armor = new CustomItem(id, durability);
|
||||
|
||||
idList.add(id);
|
||||
customIDs.add(id);
|
||||
customArmorList.add(armor);
|
||||
customArmor.put(id, armor);
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
package com.gmail.nossr50.config.mods;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.material.MaterialData;
|
||||
|
||||
import com.gmail.nossr50.config.ConfigLoader;
|
||||
@@ -14,20 +15,21 @@ import com.gmail.nossr50.datatypes.mods.CustomBlock;
|
||||
public class CustomBlockConfig extends ConfigLoader {
|
||||
private static CustomBlockConfig instance;
|
||||
|
||||
public List<ItemStack> customExcavationBlocks = new ArrayList<ItemStack>();
|
||||
public List<ItemStack> customHerbalismBlocks = new ArrayList<ItemStack>();
|
||||
public List<ItemStack> customMiningBlocks = new ArrayList<ItemStack>();
|
||||
public List<ItemStack> customWoodcuttingBlocks = new ArrayList<ItemStack>();
|
||||
public List<ItemStack> customOres = new ArrayList<ItemStack>();
|
||||
public List<ItemStack> customLogs = new ArrayList<ItemStack>();
|
||||
public List<ItemStack> customLeaves = new ArrayList<ItemStack>();
|
||||
public List<ItemStack> customAbilityBlocks = new ArrayList<ItemStack>();
|
||||
public List<ItemStack> customItems = new ArrayList<ItemStack>();
|
||||
private boolean needsUpdate = false;
|
||||
|
||||
public List<CustomBlock> customBlocks = new ArrayList<CustomBlock>();
|
||||
private List<MaterialData> customExcavationBlocks = new ArrayList<MaterialData>();
|
||||
private List<MaterialData> customHerbalismBlocks = new ArrayList<MaterialData>();
|
||||
private List<MaterialData> customMiningBlocks = new ArrayList<MaterialData>();
|
||||
private List<MaterialData> customWoodcuttingBlocks = new ArrayList<MaterialData>();
|
||||
private List<MaterialData> customOres = new ArrayList<MaterialData>();
|
||||
private List<MaterialData> customLogs = new ArrayList<MaterialData>();
|
||||
private List<MaterialData> customLeaves = new ArrayList<MaterialData>();
|
||||
private List<MaterialData> customAbilityBlocks = new ArrayList<MaterialData>();
|
||||
|
||||
private HashMap<MaterialData, CustomBlock> customBlockMap = new HashMap<MaterialData, CustomBlock>();
|
||||
|
||||
public CustomBlockConfig() {
|
||||
super("ModConfigs", "blocks.yml");
|
||||
super("mods", "blocks.yml");
|
||||
loadKeys();
|
||||
}
|
||||
|
||||
@@ -46,9 +48,18 @@ public class CustomBlockConfig extends ConfigLoader {
|
||||
loadBlocks("Mining", customMiningBlocks);
|
||||
loadBlocks("Woodcutting", customWoodcuttingBlocks);
|
||||
loadBlocks("Ability_Blocks", customAbilityBlocks);
|
||||
|
||||
if (needsUpdate) {
|
||||
needsUpdate = false;
|
||||
backup();
|
||||
}
|
||||
}
|
||||
|
||||
private void loadBlocks(String skillType, List<ItemStack> blockList) {
|
||||
private void loadBlocks(String skillType, List<MaterialData> blockList) {
|
||||
if (needsUpdate) {
|
||||
return;
|
||||
}
|
||||
|
||||
ConfigurationSection skillSection = config.getConfigurationSection(skillType);
|
||||
|
||||
if (skillSection == null) {
|
||||
@@ -58,63 +69,80 @@ public class CustomBlockConfig extends ConfigLoader {
|
||||
Set<String> skillConfigSet = skillSection.getKeys(false);
|
||||
|
||||
for (String blockName : skillConfigSet) {
|
||||
int id = config.getInt(skillType + "." + blockName + ".ID", 0);
|
||||
byte data = (byte) config.getInt(skillType + "." + blockName + ".Data_Value", 0);
|
||||
int xp = config.getInt(skillType + "." + blockName + ".XP_Gain", 0);
|
||||
int tier = config.getInt(skillType + "." + blockName + ".Tier", 1);
|
||||
boolean dropItem = config.getBoolean(skillType + "." + blockName + ".Drop_Item", false);
|
||||
int dropID = config.getInt(skillType + "." + blockName + ".Drop_Item_ID", 0);
|
||||
byte dropData = (byte) config.getInt(skillType + "." + blockName + ".Drop_Item_Data_Value", 0);
|
||||
int minimumDropAmount = config.getInt(skillType + "." + blockName + ".Min_Drop_Item_Amount", 1);
|
||||
int maxiumDropAmount = config.getInt(skillType + "." + blockName + ".Max_Drop_Item_Amount", 1);
|
||||
if (config.contains(skillType + "." + blockName + "." + ".Drop_Item")) {
|
||||
needsUpdate = true;
|
||||
return;
|
||||
}
|
||||
|
||||
CustomBlock block;
|
||||
ItemStack itemDrop;
|
||||
ItemStack blockItem;
|
||||
String[] blockInfo = blockName.split("[|]");
|
||||
|
||||
if (id == 0) {
|
||||
plugin.getLogger().warning("Missing ID. This block will be skipped.");
|
||||
Material blockMaterial = Material.matchMaterial(blockInfo[0]);
|
||||
|
||||
if (blockMaterial == null) {
|
||||
plugin.getLogger().warning("Invalid material name. This item will be skipped. - " + blockInfo[0]);
|
||||
continue;
|
||||
}
|
||||
|
||||
byte blockData = Byte.valueOf(blockInfo[1]);
|
||||
MaterialData blockMaterialData = new MaterialData(blockMaterial, blockData);
|
||||
blockList.add(blockMaterialData);
|
||||
|
||||
if (skillType.equals("Ability_Blocks")) {
|
||||
blockItem = (new MaterialData(id, data)).toItemStack(1);
|
||||
|
||||
blockList.add(blockItem);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (dropItem && dropID == 0) {
|
||||
plugin.getLogger().warning("Incomplete item drop information. This block will drop itself.");
|
||||
dropItem = false;
|
||||
}
|
||||
|
||||
if (dropItem) {
|
||||
itemDrop = (new MaterialData(dropID, dropData)).toItemStack(1);
|
||||
}
|
||||
else {
|
||||
itemDrop = (new MaterialData(id, data)).toItemStack(1);
|
||||
}
|
||||
|
||||
block = new CustomBlock(minimumDropAmount, maxiumDropAmount, itemDrop, tier, xp, data, id);
|
||||
blockItem = (new MaterialData(id, data)).toItemStack(1);
|
||||
int xp = config.getInt(skillType + "." + blockName + ".XP_Gain");
|
||||
|
||||
if (skillType.equals("Mining") && config.getBoolean(skillType + "." + blockName + ".Is_Ore")) {
|
||||
customOres.add(blockItem);
|
||||
customOres.add(blockMaterialData);
|
||||
}
|
||||
else if (skillType.equals("Woodcutting")) {
|
||||
if (config.getBoolean(skillType + "." + blockName + ".Is_Log")) {
|
||||
customLogs.add(blockItem);
|
||||
customLogs.add(blockMaterialData);
|
||||
}
|
||||
else {
|
||||
customLeaves.add(blockItem);
|
||||
block.setXpGain(0); // Leaves don't grant XP
|
||||
customLeaves.add(blockMaterialData);
|
||||
xp = 0; // Leaves don't grant XP
|
||||
}
|
||||
}
|
||||
|
||||
blockList.add(blockItem);
|
||||
customItems.add(blockItem);
|
||||
customBlocks.add(block);
|
||||
customBlockMap.put(blockMaterialData, new CustomBlock(xp, config.getBoolean(skillType + "." + blockName + ".Double_Drops_Enabled")));
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,29 +1,24 @@
|
||||
package com.gmail.nossr50.config.mods;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.material.MaterialData;
|
||||
|
||||
import com.gmail.nossr50.config.ConfigLoader;
|
||||
import com.gmail.nossr50.datatypes.mods.CustomEntity;
|
||||
|
||||
import org.apache.commons.lang.ClassUtils;
|
||||
|
||||
public class CustomEntityConfig extends ConfigLoader {
|
||||
private static CustomEntityConfig instance;
|
||||
|
||||
public List<Integer> customEntityIds = new ArrayList<Integer>();
|
||||
public List<Integer> customHostileEntityIds = new ArrayList<Integer>();
|
||||
public List<Integer> customNeutralEntityIds = new ArrayList<Integer>();
|
||||
public List<Integer> customPassiveEntityIds = new ArrayList<Integer>();
|
||||
|
||||
public List<EntityType> customEntityTypes = new ArrayList<EntityType>();
|
||||
public List<CustomEntity> customEntities = new ArrayList<CustomEntity>();
|
||||
private HashMap<String, CustomEntity> customEntityClassMap = new HashMap<String, CustomEntity>();
|
||||
private HashMap<String, CustomEntity> customEntityTypeMap = new HashMap<String, CustomEntity>();
|
||||
|
||||
public CustomEntityConfig() {
|
||||
super("ModConfigs", "entities.yml");
|
||||
super("mods", "entities.yml");
|
||||
loadKeys();
|
||||
}
|
||||
|
||||
@@ -37,48 +32,86 @@ public class CustomEntityConfig extends ConfigLoader {
|
||||
|
||||
@Override
|
||||
protected void loadKeys() {
|
||||
loadMobs("Hostile", customHostileEntityIds);
|
||||
loadMobs("Neutral", customNeutralEntityIds);
|
||||
loadMobs("Passive", customPassiveEntityIds);
|
||||
}
|
||||
|
||||
private void loadMobs(String entityType, List<Integer> entityIdList) {
|
||||
ConfigurationSection entitySection = config.getConfigurationSection(entityType);
|
||||
|
||||
if (entitySection == null) {
|
||||
if (config.getConfigurationSection("Hostile") != null) {
|
||||
backup();
|
||||
return;
|
||||
}
|
||||
|
||||
Set<String> entityConfigSet = entitySection.getKeys(false);
|
||||
for (String entityName : config.getKeys(false)) {
|
||||
Class<?> clazz = null;
|
||||
String className = config.getString(entityName + ".Class", "");
|
||||
|
||||
for (String entityName : entityConfigSet) {
|
||||
int id = config.getInt(entityType + "." + entityName + ".ID", 0);
|
||||
EntityType type = EntityType.fromId(id);
|
||||
double xpMultiplier = config.getDouble(entityType + "." + entityName + ".XP_Multiplier", 1.0D);
|
||||
boolean canBeTamed = config.getBoolean(entityType + "." + entityName + ".Tameable", false);
|
||||
int tamingXp = config.getInt(entityType + "." + entityName + "Taming_XP", 0);
|
||||
boolean canBeSummoned = config.getBoolean(entityType + "." + entityName + "CanBeSummoned", false);
|
||||
int callOfTheWildId = config.getInt(entityType + "." + entityName + "COTW_Material_ID", 0);
|
||||
int callOfTheWildData = config.getInt(entityType + "." + entityName + "COTW_Material_Data", 0);
|
||||
int callOfTheWildAmount = config.getInt(entityType + "." + entityName + "COTW_Material_Amount", 0);
|
||||
|
||||
CustomEntity entity;
|
||||
|
||||
if (id == 0) {
|
||||
plugin.getLogger().warning("Missing ID. This block will be skipped.");
|
||||
continue;
|
||||
try {
|
||||
clazz = ClassUtils.getClass(className);
|
||||
}
|
||||
catch (ClassNotFoundException e) {
|
||||
plugin.getLogger().warning("Invalid class (" + className + ") detected for " + entityName + ".");
|
||||
plugin.getLogger().warning("This custom entity may not function properly.");
|
||||
}
|
||||
|
||||
if (canBeSummoned && (callOfTheWildId == 0 || callOfTheWildAmount == 0)) {
|
||||
plugin.getLogger().warning("Incomplete Call of the Wild information. This enitity will not be able to be summoned by Call of the Wild.");
|
||||
String entityTypeName = entityName.replace("_", ".");
|
||||
double xpMultiplier = config.getDouble(entityName + ".XP_Multiplier", 1.0D);
|
||||
|
||||
boolean canBeTamed = config.getBoolean(entityName + ".Tameable");
|
||||
int tamingXp = config.getInt(entityName + ".Taming_XP");
|
||||
|
||||
boolean canBeSummoned = config.getBoolean(entityName + ".CanBeSummoned");
|
||||
Material callOfTheWildMaterial = Material.matchMaterial(config.getString(entityName + ".COTW_Material", ""));
|
||||
byte callOfTheWildData = (byte) config.getInt(entityName + ".COTW_Material_Data");
|
||||
int callOfTheWildAmount = config.getInt(entityName + ".COTW_Material_Amount");
|
||||
|
||||
if (canBeSummoned && (callOfTheWildMaterial == null || callOfTheWildAmount == 0)) {
|
||||
plugin.getLogger().warning("Incomplete Call of the Wild information. This entity will not be able to be summoned by Call of the Wild.");
|
||||
canBeSummoned = false;
|
||||
}
|
||||
|
||||
entity = new CustomEntity(id, type, xpMultiplier, canBeTamed, tamingXp, canBeSummoned, new ItemStack(callOfTheWildId, callOfTheWildData), callOfTheWildAmount);
|
||||
CustomEntity entity = new CustomEntity(xpMultiplier, canBeTamed, tamingXp, canBeSummoned, (canBeSummoned ? new MaterialData(callOfTheWildMaterial, callOfTheWildData).toItemStack(1) : null), callOfTheWildAmount);
|
||||
|
||||
entityIdList.add(id);
|
||||
customEntityTypes.add(type);
|
||||
customEntities.add(entity);
|
||||
customEntityTypeMap.put(entityTypeName, 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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,30 +5,36 @@ import java.util.HashMap;
|
||||
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.mods.CustomTool;
|
||||
import com.gmail.nossr50.skills.repair.Repairable;
|
||||
import com.gmail.nossr50.skills.repair.RepairableFactory;
|
||||
import com.gmail.nossr50.skills.repair.Repair;
|
||||
import com.gmail.nossr50.skills.repair.repairables.RepairItemType;
|
||||
import com.gmail.nossr50.skills.repair.repairables.RepairMaterialType;
|
||||
import com.gmail.nossr50.skills.repair.repairables.Repairable;
|
||||
import com.gmail.nossr50.skills.repair.repairables.RepairableFactory;
|
||||
|
||||
public class CustomToolConfig extends ConfigLoader {
|
||||
private static CustomToolConfig instance;
|
||||
|
||||
private boolean needsUpdate = false;
|
||||
|
||||
private List<Repairable> repairables;
|
||||
|
||||
public List<Integer> customAxeIDs = new ArrayList<Integer>();
|
||||
public List<Integer> customBowIDs = new ArrayList<Integer>();
|
||||
public List<Integer> customHoeIDs = new ArrayList<Integer>();
|
||||
public List<Integer> customPickaxeIDs = new ArrayList<Integer>();
|
||||
public List<Integer> customShovelIDs = new ArrayList<Integer>();
|
||||
public List<Integer> customSwordIDs = new ArrayList<Integer>();
|
||||
public List<Integer> customIDs = new ArrayList<Integer>();
|
||||
private List<Material> customAxes = new ArrayList<Material>();
|
||||
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>();
|
||||
|
||||
public List<CustomTool> customToolList = new ArrayList<CustomTool>();
|
||||
public HashMap<Integer, CustomTool> customTools = new HashMap<Integer, CustomTool>();
|
||||
private HashMap<Material, CustomTool> customToolMap = new HashMap<Material, CustomTool>();
|
||||
|
||||
private CustomToolConfig() {
|
||||
super("ModConfigs", "tools.yml");
|
||||
super("mods", "tools.yml");
|
||||
loadKeys();
|
||||
}
|
||||
|
||||
@@ -52,15 +58,24 @@ public class CustomToolConfig extends ConfigLoader {
|
||||
protected void loadKeys() {
|
||||
repairables = new ArrayList<Repairable>();
|
||||
|
||||
loadTool("Axes", customAxeIDs);
|
||||
loadTool("Bows", customBowIDs);
|
||||
loadTool("Hoes", customHoeIDs);
|
||||
loadTool("Pickaxes", customPickaxeIDs);
|
||||
loadTool("Shovels", customShovelIDs);
|
||||
loadTool("Swords", customSwordIDs);
|
||||
loadTool("Axes", customAxes);
|
||||
loadTool("Bows", customBows);
|
||||
loadTool("Hoes", customHoes);
|
||||
loadTool("Pickaxes", customPickaxes);
|
||||
loadTool("Shovels", customShovels);
|
||||
loadTool("Swords", customSwords);
|
||||
|
||||
if (needsUpdate) {
|
||||
needsUpdate = false;
|
||||
backup();
|
||||
}
|
||||
}
|
||||
|
||||
private void loadTool(String toolType, List<Integer> idList) {
|
||||
private void loadTool(String toolType, List<Material> materialList) {
|
||||
if (needsUpdate) {
|
||||
return;
|
||||
}
|
||||
|
||||
ConfigurationSection toolSection = config.getConfigurationSection(toolType);
|
||||
|
||||
if (toolSection == null) {
|
||||
@@ -70,38 +85,83 @@ public class CustomToolConfig extends ConfigLoader {
|
||||
Set<String> toolConfigSet = toolSection.getKeys(false);
|
||||
|
||||
for (String toolName : toolConfigSet) {
|
||||
int id = config.getInt(toolType + "." + toolName + ".ID", 0);
|
||||
double multiplier = config.getDouble(toolType + "." + toolName + ".XP_Modifier", 1.0);
|
||||
boolean abilityEnabled = config.getBoolean(toolType + "." + toolName + ".Ability_Enabled", true);
|
||||
int tier = config.getInt(toolType + "." + toolName + ".Tier", 1);
|
||||
boolean repairable = config.getBoolean(toolType + "." + toolName + ".Repairable");
|
||||
int repairID = config.getInt(toolType + "." + toolName + ".Repair_Material_ID", 0);
|
||||
byte repairData = (byte) config.getInt(toolType + "." + toolName + ".Repair_Material_Data_Value", 0);
|
||||
int repairQuantity = config.getInt(toolType + "." + toolName + ".Repair_Material_Quantity", 0);
|
||||
short durability = (short) config.getInt(toolType + "." + toolName + ".Durability", 0);
|
||||
if (config.contains(toolType + "." + toolName + "." + ".ID")) {
|
||||
needsUpdate = true;
|
||||
return;
|
||||
}
|
||||
|
||||
if (id == 0) {
|
||||
plugin.getLogger().warning("Missing ID. This item will be skipped.");
|
||||
Material toolMaterial = Material.matchMaterial(toolName);
|
||||
|
||||
if (toolMaterial == null) {
|
||||
plugin.getLogger().warning("Invalid material name. This item will be skipped. - " + toolName);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (repairable && (repairID == 0 || repairQuantity == 0 || durability == 0)) {
|
||||
plugin.getLogger().warning("Incomplete repair information. This item will be unrepairable.");
|
||||
boolean repairable = config.getBoolean(toolType + "." + toolName + ".Repairable");
|
||||
Material repairMaterial = Material.matchMaterial(config.getString(toolType + "." + toolName + ".Repair_Material", ""));
|
||||
|
||||
if (repairMaterial == null) {
|
||||
plugin.getLogger().warning("Incomplete repair information. This item will be unrepairable. - " + toolName);
|
||||
repairable = false;
|
||||
}
|
||||
|
||||
CustomTool tool;
|
||||
|
||||
if (repairable) {
|
||||
repairables.add(RepairableFactory.getRepairable(id, repairID, repairData, repairQuantity, durability));
|
||||
byte repairData = (byte) config.getInt(toolType + "." + toolName + ".Repair_Material_Data_Value", -1);
|
||||
int repairQuantity = Repair.getRepairAndSalvageQuantities(new ItemStack(toolMaterial), repairMaterial, repairData);
|
||||
|
||||
if (repairQuantity == 0) {
|
||||
repairQuantity = config.getInt(toolType + "." + toolName + ".Repair_Material_Data_Quantity", 2);
|
||||
}
|
||||
|
||||
short durability = toolMaterial.getMaxDurability();
|
||||
|
||||
if (durability == 0) {
|
||||
durability = (short) config.getInt(toolType + "." + toolName + ".Durability", 60);
|
||||
}
|
||||
|
||||
repairables.add(RepairableFactory.getRepairable(toolMaterial, repairMaterial, repairData, 0, repairQuantity, durability, RepairItemType.TOOL, RepairMaterialType.OTHER, 1.0));
|
||||
}
|
||||
|
||||
tool = new CustomTool(tier, abilityEnabled, multiplier, durability, id);
|
||||
double multiplier = config.getDouble(toolType + "." + toolName + ".XP_Modifier", 1.0);
|
||||
boolean abilityEnabled = config.getBoolean(toolType + "." + toolName + ".Ability_Enabled", true);
|
||||
int tier = config.getInt(toolType + "." + toolName + ".Tier", 1);
|
||||
|
||||
idList.add(id);
|
||||
customIDs.add(id);
|
||||
customToolList.add(tool);
|
||||
customTools.put(id, tool);
|
||||
CustomTool tool = new CustomTool(tier, abilityEnabled, multiplier);
|
||||
|
||||
materialList.add(toolMaterial);
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,75 +0,0 @@
|
||||
package com.gmail.nossr50.config.spout;
|
||||
|
||||
import com.gmail.nossr50.config.ConfigLoader;
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.datatypes.spout.huds.HudType;
|
||||
|
||||
import org.getspout.spoutapi.keyboard.Keyboard;
|
||||
|
||||
public class SpoutConfig extends ConfigLoader {
|
||||
private static SpoutConfig instance;
|
||||
|
||||
private SpoutConfig() {
|
||||
super("spout.yml");
|
||||
}
|
||||
|
||||
public static SpoutConfig getInstance() {
|
||||
if (instance == null) {
|
||||
instance = new SpoutConfig();
|
||||
}
|
||||
|
||||
return instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadKeys() {
|
||||
// Setup default HUD
|
||||
}
|
||||
|
||||
public HudType getDefaultHudType() {
|
||||
try {
|
||||
return HudType.valueOf(config.getString("Spout.HUD.Default", "STANDARD").toUpperCase().trim());
|
||||
}
|
||||
catch (IllegalArgumentException ex) {
|
||||
return HudType.STANDARD;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean getShowPowerLevel() { return config.getBoolean("HUD.Show_Power_Level", true); }
|
||||
public Keyboard getMenuKey() {
|
||||
try {
|
||||
return Keyboard.valueOf(config.getString("Menu.Key", "KEY_M").toUpperCase().trim());
|
||||
}
|
||||
catch (IllegalArgumentException ex) {
|
||||
return Keyboard.KEY_M;
|
||||
}
|
||||
}
|
||||
|
||||
/* XP Bar */
|
||||
public boolean getXPBarEnabled() { return config.getBoolean("XP.Bar.Enabled", true); }
|
||||
public void setXPBarEnabled(boolean enabled) { config.set("XP.Bar.Enabled", enabled); }
|
||||
|
||||
public boolean getXPBarIconEnabled() { return config.getBoolean("XP.Icon.Enabled", true); }
|
||||
public int getXPBarXPosition() { return config.getInt("XP.Bar.X_POS", 95); }
|
||||
public int getXPBarYPosition() { return config.getInt("XP.Bar.Y_POS", 6); }
|
||||
public int getXPIconXPosition() { return config.getInt("XP.Icon.X_POS", 78); }
|
||||
public int getXPIconYPosition() { return config.getInt("XP.Icon.Y_POS", 2); }
|
||||
|
||||
/* HUD Colors */
|
||||
public double getRetroHUDXPBorderRed() { return config.getDouble("HUD.Retro.Colors.Border.RED", 0.0); }
|
||||
public double getRetroHUDXPBorderGreen() { return config.getDouble("HUD.Retro.Colors.Border.GREEN", 0.0); }
|
||||
public double getRetroHUDXPBorderBlue() { return config.getDouble("HUD.Retro.Colors.Border.BLUE", 0.0); }
|
||||
public double getRetroHUDXPBackgroundRed() { return config.getDouble("HUD.Retro.Colors.Background.RED", 0.75); }
|
||||
public double getRetroHUDXPBackgroundGreen() { return config.getDouble("HUD.Retro.Colors.Background.GREEN", 0.75); }
|
||||
public double getRetroHUDXPBackgroundBlue() { return config.getDouble("HUD.Retro.Colors.Background.BLUE", 0.75); }
|
||||
|
||||
public double getRetroHUDRed(SkillType skill) { return config.getDouble("HUD.Retro.Colors." + skill.toString().toLowerCase() +".RED", 0.3); }
|
||||
public double getRetroHUDGreen(SkillType skill) { return config.getDouble("HUD.Retro.Colors." + skill.toString().toLowerCase() +".RED", 0.3); }
|
||||
public double getRetroHUDBlue(SkillType skill) { return config.getDouble("HUD.Retro.Colors." + skill.toString().toLowerCase() +".RED", 0.3); }
|
||||
|
||||
/* Notification Tiers */
|
||||
public int getNotificationTier1() { return config.getInt("Notifications.Tier1", 200); }
|
||||
public int getNotificationTier2() { return config.getInt("Notifications.Tier2", 400); }
|
||||
public int getNotificationTier3() { return config.getInt("Notifications.Tier3", 600); }
|
||||
public int getNotificationTier4() { return config.getInt("Notifications.Tier4", 800); }
|
||||
}
|
||||
@@ -3,23 +3,26 @@ package com.gmail.nossr50.config.treasure;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import org.bukkit.DyeColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.material.MaterialData;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.material.Dye;
|
||||
import org.bukkit.potion.Potion;
|
||||
import org.bukkit.potion.PotionType;
|
||||
|
||||
import com.gmail.nossr50.config.ConfigLoader;
|
||||
import com.gmail.nossr50.datatypes.treasure.EnchantmentTreasure;
|
||||
import com.gmail.nossr50.datatypes.treasure.ExcavationTreasure;
|
||||
import com.gmail.nossr50.datatypes.treasure.FishingTreasure;
|
||||
import com.gmail.nossr50.datatypes.treasure.HylianTreasure;
|
||||
import com.gmail.nossr50.datatypes.treasure.Rarity;
|
||||
import com.gmail.nossr50.datatypes.treasure.ShakeTreasure;
|
||||
import com.gmail.nossr50.datatypes.treasure.Treasure;
|
||||
import com.gmail.nossr50.util.EnchantmentUtils;
|
||||
|
||||
public class TreasureConfig extends ConfigLoader {
|
||||
private static TreasureConfig instance;
|
||||
@@ -45,6 +48,7 @@ public class TreasureConfig extends ConfigLoader {
|
||||
public List<ShakeTreasure> shakeFromCreeper = new ArrayList<ShakeTreasure>();
|
||||
public List<ShakeTreasure> shakeFromEnderman = new ArrayList<ShakeTreasure>();
|
||||
public List<ShakeTreasure> shakeFromGhast = new ArrayList<ShakeTreasure>();
|
||||
public List<ShakeTreasure> shakeFromHorse = new ArrayList<ShakeTreasure>();
|
||||
public List<ShakeTreasure> shakeFromIronGolem = new ArrayList<ShakeTreasure>();
|
||||
public List<ShakeTreasure> shakeFromMagmaCube = new ArrayList<ShakeTreasure>();
|
||||
public List<ShakeTreasure> shakeFromMushroomCow = new ArrayList<ShakeTreasure>();
|
||||
@@ -58,7 +62,8 @@ public class TreasureConfig extends ConfigLoader {
|
||||
public List<ShakeTreasure> shakeFromWitch = new ArrayList<ShakeTreasure>();
|
||||
public List<ShakeTreasure> shakeFromZombie = new ArrayList<ShakeTreasure>();
|
||||
|
||||
public List<FishingTreasure> fishingRewards = new ArrayList<FishingTreasure>();
|
||||
public HashMap<Rarity, List<FishingTreasure>> fishingRewards = new HashMap<Rarity, List<FishingTreasure>>();
|
||||
public HashMap<Rarity, List<EnchantmentTreasure>> fishingEnchantments = new HashMap<Rarity, List<EnchantmentTreasure>>();
|
||||
|
||||
private TreasureConfig() {
|
||||
super("treasures.yml");
|
||||
@@ -75,375 +80,310 @@ public class TreasureConfig extends ConfigLoader {
|
||||
|
||||
@Override
|
||||
protected void loadKeys() {
|
||||
Map<String, Treasure> treasures = new HashMap<String, Treasure>();
|
||||
ConfigurationSection treasureSection = config.getConfigurationSection("Treasures");
|
||||
if (config.getConfigurationSection("Treasures") != null) {
|
||||
backup();
|
||||
return;
|
||||
}
|
||||
|
||||
loadTreaures("Fishing");
|
||||
loadTreaures("Excavation");
|
||||
loadTreaures("Hylian_Luck");
|
||||
loadEnchantments();
|
||||
|
||||
for (EntityType entity : EntityType.values()) {
|
||||
if (entity.isAlive()) {
|
||||
loadTreaures("Shake." + entity.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void loadTreaures(String type) {
|
||||
boolean isFishing = type.equals("Fishing");
|
||||
boolean isShake = type.contains("Shake");
|
||||
boolean isExcavation = type.equals("Excavation");
|
||||
boolean isHylian = type.equals("Hylian_Luck");
|
||||
|
||||
ConfigurationSection treasureSection = config.getConfigurationSection(type);
|
||||
|
||||
if (treasureSection == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (String treasureName : treasureSection.getKeys(false)) {
|
||||
// Initialize fishing HashMap
|
||||
for (Rarity rarity : Rarity.values()) {
|
||||
if (!fishingRewards.containsKey(rarity)) {
|
||||
fishingRewards.put(rarity, (new ArrayList<FishingTreasure>()));
|
||||
}
|
||||
}
|
||||
|
||||
for (String treasureName : treasureSection.getKeys(false)) {
|
||||
// Validate all the things!
|
||||
List<String> reason = new ArrayList<String>();
|
||||
|
||||
/*
|
||||
* ID, Amount, and Data
|
||||
* Material, Amount, and Data
|
||||
*/
|
||||
Material material;
|
||||
|
||||
if (!config.contains("Treasures." + treasureName + ".ID")) {
|
||||
reason.add("Missing ID");
|
||||
if (treasureName.contains("POTION")) {
|
||||
material = Material.POTION;
|
||||
}
|
||||
else if (treasureName.contains("INK_SACK")) {
|
||||
material = Material.INK_SACK;
|
||||
}
|
||||
else {
|
||||
material = Material.matchMaterial(treasureName);
|
||||
}
|
||||
|
||||
if (!config.contains("Treasures." + treasureName + ".Amount")) {
|
||||
reason.add("Missing Amount");
|
||||
int amount = config.getInt(type + "." + treasureName + ".Amount");
|
||||
int data = config.getInt(type + "." + treasureName + ".Data");
|
||||
|
||||
if (material == null) {
|
||||
reason.add("Invalid material: " + treasureName);
|
||||
}
|
||||
|
||||
if (!config.contains("Treasures." + treasureName + ".Data")) {
|
||||
reason.add("Missing Data");
|
||||
if (amount <= 0) {
|
||||
reason.add("Amount of " + treasureName + " must be greater than 0! " + amount);
|
||||
}
|
||||
|
||||
int id = config.getInt("Treasures." + treasureName + ".ID");
|
||||
int amount = config.getInt("Treasures." + treasureName + ".Amount");
|
||||
int data = config.getInt("Treasures." + treasureName + ".Data");
|
||||
|
||||
if (Material.getMaterial(id) == null) {
|
||||
reason.add("Invalid id: " + id);
|
||||
}
|
||||
|
||||
if (amount < 1) {
|
||||
reason.add("Invalid amount: " + amount);
|
||||
}
|
||||
|
||||
if (id < 256 && (data > 127 || data < -128)) {
|
||||
reason.add("Invalid data: " + data);
|
||||
if (material != null && material.isBlock() && (data > 127 || data < -128)) {
|
||||
reason.add("Data of " + treasureName + " is invalid! " + data);
|
||||
}
|
||||
|
||||
/*
|
||||
* XP, Drop Chance, and Drop Level
|
||||
*/
|
||||
|
||||
if (!config.contains("Treasures." + treasureName + ".XP")) {
|
||||
reason.add("Missing XP");
|
||||
}
|
||||
|
||||
if (!config.contains("Treasures." + treasureName + ".Drop_Chance")) {
|
||||
reason.add("Missing Drop_Chance");
|
||||
}
|
||||
|
||||
if (!config.contains("Treasures." + treasureName + ".Drop_Level")) {
|
||||
reason.add("Missing Drop_Level");
|
||||
}
|
||||
|
||||
int xp = config.getInt("Treasures." + treasureName + ".XP");
|
||||
Double dropChance = config.getDouble("Treasures." + treasureName + ".Drop_Chance");
|
||||
int dropLevel = config.getInt("Treasures." + treasureName + ".Drop_Level");
|
||||
int xp = config.getInt(type + "." + treasureName + ".XP");
|
||||
double dropChance = config.getDouble(type + "." + treasureName + ".Drop_Chance");
|
||||
int dropLevel = config.getInt(type + "." + treasureName + ".Drop_Level");
|
||||
|
||||
if (xp < 0) {
|
||||
reason.add("Invalid xp: " + xp);
|
||||
reason.add(treasureName + " has an invalid XP value: " + xp);
|
||||
}
|
||||
|
||||
if (dropChance < 0) {
|
||||
reason.add("Invalid Drop_Chance: " + dropChance);
|
||||
if (dropChance < 0.0D) {
|
||||
reason.add(treasureName + " has an invalid Drop_Chance: " + dropChance);
|
||||
}
|
||||
|
||||
if (dropLevel < 0) {
|
||||
reason.add("Invalid Drop_Level: " + dropLevel);
|
||||
reason.add(treasureName + " has an invalid Drop_Level: " + dropLevel);
|
||||
}
|
||||
|
||||
/*
|
||||
* Potions
|
||||
* Specific Types
|
||||
*/
|
||||
Rarity rarity = null;
|
||||
|
||||
if (isFishing) {
|
||||
rarity = Rarity.getRarity(config.getString(type + "." + treasureName + ".Rarity"));
|
||||
|
||||
if (rarity == null) {
|
||||
reason.add("Invalid Rarity for item: " + treasureName);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Itemstack
|
||||
*/
|
||||
ItemStack item = null;
|
||||
|
||||
if (config.contains("Treasures." + treasureName + ".Potion_Type")) {
|
||||
String potionType = config.getString("Treasures." + treasureName + ".Potion_Type");
|
||||
if (treasureName.contains("POTION")) {
|
||||
String potionType = treasureName.substring(7);
|
||||
|
||||
try {
|
||||
item = new Potion(PotionType.valueOf(potionType.toUpperCase())).toItemStack(amount);
|
||||
item = new Potion(PotionType.valueOf(potionType.toUpperCase().trim())).toItemStack(amount);
|
||||
}
|
||||
catch (IllegalArgumentException ex) {
|
||||
reason.add("Invalid Potion_Type: " + potionType);
|
||||
}
|
||||
}
|
||||
else {
|
||||
item = (new MaterialData(id, (byte) data)).toItemStack(amount);
|
||||
}
|
||||
|
||||
/*
|
||||
* Drops From & Max Level
|
||||
*/
|
||||
|
||||
if (config.getBoolean("Treasures." + treasureName + ".Drops_From.Fishing", false)) {
|
||||
if (config.getConfigurationSection("Treasures." + treasureName + ".Drops_From").getKeys(false).size() != 1) {
|
||||
reason.add("This can only be a fishing drop.");
|
||||
}
|
||||
|
||||
if (!config.contains("Treasures." + treasureName + ".Max_Level")) {
|
||||
reason.add("Missing Max_Level");
|
||||
}
|
||||
|
||||
int maxLevel = config.getInt("Treasures." + treasureName + ".Max_Level");
|
||||
|
||||
if (noErrorsInConfig(reason)) {
|
||||
FishingTreasure fTreasure = new FishingTreasure(item, xp, dropChance, dropLevel, maxLevel);
|
||||
treasures.put(treasureName, fTreasure);
|
||||
}
|
||||
}
|
||||
else if (config.getBoolean("Treasures." + treasureName + ".Drops_From.Shake", false)) {
|
||||
if (config.getConfigurationSection("Treasures." + treasureName + ".Drops_From").getKeys(false).size() != 1) {
|
||||
reason.add("This can only be a shake drop.");
|
||||
}
|
||||
|
||||
if (!config.contains("Treasures." + treasureName + ".Mob")) {
|
||||
reason.add("Missing Mob");
|
||||
}
|
||||
|
||||
String mobType = config.getString("Treasures." + treasureName + ".Mob");
|
||||
EntityType mob = null;
|
||||
else if (treasureName.contains("INK_SACK")) {
|
||||
String color = treasureName.substring(9);
|
||||
|
||||
try {
|
||||
mob = EntityType.valueOf(mobType.toUpperCase().trim());
|
||||
}
|
||||
catch (IllegalArgumentException ex){
|
||||
reason.add("Invalid Mob: " + mobType);
|
||||
}
|
||||
Dye dye = new Dye();
|
||||
dye.setColor(DyeColor.valueOf(color.toUpperCase().trim()));
|
||||
|
||||
if (noErrorsInConfig(reason)) {
|
||||
ShakeTreasure sTreasure = new ShakeTreasure(item, xp, dropChance, dropLevel, mob);
|
||||
treasures.put(treasureName, sTreasure);
|
||||
item = dye.toItemStack(amount);
|
||||
}
|
||||
catch (IllegalArgumentException ex) {
|
||||
reason.add("Invalid Dye_Color: " + color);
|
||||
}
|
||||
}
|
||||
else {
|
||||
ExcavationTreasure eTreasure = new ExcavationTreasure(item, xp, dropChance, dropLevel);
|
||||
HylianTreasure hTreasure = new HylianTreasure(item, xp, dropChance, dropLevel);
|
||||
else if (material != null) {
|
||||
item = new ItemStack(material, amount, (short) data);
|
||||
|
||||
if (config.getBoolean("Treasures." + treasureName + ".Drops_From.Dirt", false)) {
|
||||
eTreasure.setDropsFromDirt();
|
||||
if (config.contains(type + "." + treasureName + ".Custom_Name")) {
|
||||
ItemMeta itemMeta = item.getItemMeta();
|
||||
itemMeta.setDisplayName(config.getString(type + "." + treasureName + "Custom_Name"));
|
||||
item.setItemMeta(itemMeta);
|
||||
}
|
||||
|
||||
if (config.getBoolean("Treasures." + treasureName + ".Drops_From.Grass", false)) {
|
||||
eTreasure.setDropsFromGrass();
|
||||
}
|
||||
|
||||
if (config.getBoolean("Treasures." + treasureName + ".Drops_From.Sand", false)) {
|
||||
eTreasure.setDropsFromSand();
|
||||
}
|
||||
|
||||
if (config.getBoolean("Treasures." + treasureName + ".Drops_From.Gravel", false)) {
|
||||
eTreasure.setDropsFromGravel();
|
||||
}
|
||||
|
||||
if (config.getBoolean("Treasures." + treasureName + ".Drops_From.Clay", false)) {
|
||||
eTreasure.setDropsFromClay();
|
||||
}
|
||||
|
||||
if (config.getBoolean("Treasures." + treasureName + ".Drops_From.Mycelium", false)) {
|
||||
eTreasure.setDropsFromMycel();
|
||||
}
|
||||
|
||||
if (config.getBoolean("Treasures." + treasureName + ".Drops_From.Soul_Sand", false)) {
|
||||
eTreasure.setDropsFromSoulSand();
|
||||
}
|
||||
|
||||
if (config.getBoolean("Treasures." + treasureName + ".Drops_From.Snow", false)) {
|
||||
eTreasure.setDropsFromSnow();
|
||||
}
|
||||
|
||||
if (config.getBoolean("Treasures." + treasureName + ".Drops_From.Bushes", false)) {
|
||||
hTreasure.setDropsFromBushes();
|
||||
}
|
||||
|
||||
if (config.getBoolean("Treasures." + treasureName + ".Drops_From.Flowers", false)) {
|
||||
hTreasure.setDropsFromFlowers();
|
||||
}
|
||||
|
||||
if (config.getBoolean("Treasures." + treasureName + ".Drops_From.Pots", false)) {
|
||||
hTreasure.setDropsFromPots();
|
||||
}
|
||||
|
||||
if (config.getBoolean("Treasures." + treasureName + ".Drops_From.Fishing", false)) {
|
||||
reason.add("This cannot also be a fishing drop.");
|
||||
}
|
||||
|
||||
if (config.getBoolean("Treasures." + treasureName + ".Drops_From.Shake", false)) {
|
||||
reason.add("This cannot also be a shake drop.");
|
||||
}
|
||||
|
||||
if (noErrorsInConfig(reason) && hTreasure.getDropsFrom() == (byte) 0x0) {
|
||||
treasures.put(treasureName, eTreasure);
|
||||
}
|
||||
else if (noErrorsInConfig(reason) && eTreasure.getDropsFrom() == (byte) 0x0) {
|
||||
treasures.put(treasureName, hTreasure);
|
||||
if (config.contains(type + "." + treasureName + ".Lore")) {
|
||||
ItemMeta itemMeta = item.getItemMeta();
|
||||
itemMeta.setLore(config.getStringList(type + "." + treasureName + "Custom_Name"));
|
||||
item.setItemMeta(itemMeta);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
List<String> excavationTreasures = config.getStringList("Excavation.Treasure");
|
||||
List<String> fishingTreasures = config.getStringList("Fishing.Treasure");
|
||||
List<String> hylianTreasures = config.getStringList("Hylian_Luck.Treasure");
|
||||
List<String> shakeTreasures = config.getStringList("Shake.Treasure");
|
||||
|
||||
for (Entry<String, Treasure> nextEntry : treasures.entrySet()) {
|
||||
String treasureKey = nextEntry.getKey();
|
||||
Treasure treasure = nextEntry.getValue();
|
||||
|
||||
if (treasure instanceof FishingTreasure) {
|
||||
if (fishingTreasures == null || !fishingTreasures.contains(treasureKey)) {
|
||||
continue;
|
||||
if (noErrorsInConfig(reason)) {
|
||||
if (isFishing) {
|
||||
fishingRewards.get(rarity).add(new FishingTreasure(item, xp));
|
||||
}
|
||||
else if (isShake) {
|
||||
ShakeTreasure shakeTreasure = new ShakeTreasure(item, xp, dropChance, dropLevel);
|
||||
|
||||
fishingRewards.add((FishingTreasure) treasure);
|
||||
}
|
||||
else if (treasure instanceof ShakeTreasure) {
|
||||
if (shakeTreasures == null || !shakeTreasures.contains(treasureKey)) {
|
||||
continue;
|
||||
if (type.equals("Shake.BLAZE")) {
|
||||
shakeFromBlaze.add(shakeTreasure);
|
||||
}
|
||||
else if (type.equals("Shake.CAVE_SPIDER")) {
|
||||
shakeFromCaveSpider.add(shakeTreasure);
|
||||
}
|
||||
else if (type.equals("Shake.CHICKEN")) {
|
||||
shakeFromChicken.add(shakeTreasure);
|
||||
}
|
||||
else if (type.equals("Shake.COW")) {
|
||||
shakeFromCow.add(shakeTreasure);
|
||||
}
|
||||
else if (type.equals("Shake.CREEPER")) {
|
||||
shakeFromCreeper.add(shakeTreasure);
|
||||
}
|
||||
else if (type.equals("Shake.ENDERMAN")) {
|
||||
shakeFromEnderman.add(shakeTreasure);
|
||||
}
|
||||
else if (type.equals("Shake.GHAST")) {
|
||||
shakeFromGhast.add(shakeTreasure);
|
||||
}
|
||||
else if (type.equals("Shake.HORSE")) {
|
||||
shakeFromHorse.add(shakeTreasure);
|
||||
}
|
||||
else if (type.equals("Shake.IRON_GOLEM")) {
|
||||
shakeFromIronGolem.add(shakeTreasure);
|
||||
}
|
||||
else if (type.equals("Shake.MAGMA_CUBE")) {
|
||||
shakeFromMagmaCube.add(shakeTreasure);
|
||||
}
|
||||
else if (type.equals("Shake.MUSHROOM_COW")) {
|
||||
shakeFromMushroomCow.add(shakeTreasure);
|
||||
}
|
||||
else if (type.equals("Shake.PIG")) {
|
||||
shakeFromPig.add(shakeTreasure);
|
||||
}
|
||||
else if (type.equals("Shake.PIG_ZOMBIE")) {
|
||||
shakeFromPigZombie.add(shakeTreasure);
|
||||
}
|
||||
else if (type.equals("Shake.SHEEP")) {
|
||||
shakeFromSheep.add(shakeTreasure);
|
||||
}
|
||||
else if (type.equals("Shake.SKELETON")) {
|
||||
shakeFromSkeleton.add(shakeTreasure);
|
||||
}
|
||||
else if (type.equals("Shake.SLIME")) {
|
||||
shakeFromSlime.add(shakeTreasure);
|
||||
}
|
||||
else if (type.equals("Shake.SPIDER")) {
|
||||
shakeFromSpider.add(shakeTreasure);
|
||||
}
|
||||
else if (type.equals("Shake.SNOWMAN")) {
|
||||
shakeFromSnowman.add(shakeTreasure);
|
||||
}
|
||||
else if (type.equals("Shake.SQUID")) {
|
||||
shakeFromSquid.add(shakeTreasure);
|
||||
}
|
||||
else if (type.equals("Shake.WITCH")) {
|
||||
shakeFromWitch.add(shakeTreasure);
|
||||
}
|
||||
else if (type.equals("Shake.ZOMBIE")) {
|
||||
shakeFromZombie.add(shakeTreasure);
|
||||
}
|
||||
}
|
||||
else if (isExcavation) {
|
||||
ExcavationTreasure excavationTreasure = new ExcavationTreasure(item, xp, dropChance, dropLevel);
|
||||
List<String> dropList = config.getStringList(type + "." + treasureName + ".Drops_From");
|
||||
|
||||
ShakeTreasure e = (ShakeTreasure) treasure;
|
||||
switch (e.getMob()) {
|
||||
case BLAZE:
|
||||
shakeFromBlaze.add(e);
|
||||
break;
|
||||
if (dropList.contains("Dirt")) {
|
||||
excavationFromDirt.add(excavationTreasure);
|
||||
}
|
||||
|
||||
case CAVE_SPIDER:
|
||||
shakeFromCaveSpider.add(e);
|
||||
break;
|
||||
if (dropList.contains("Grass")) {
|
||||
excavationFromGrass.add(excavationTreasure);
|
||||
}
|
||||
|
||||
case CHICKEN:
|
||||
shakeFromChicken.add(e);
|
||||
break;
|
||||
if (dropList.contains("Sand")) {
|
||||
excavationFromSand.add(excavationTreasure);
|
||||
}
|
||||
|
||||
case COW:
|
||||
shakeFromCow.add(e);
|
||||
break;
|
||||
if (dropList.contains("Gravel")) {
|
||||
excavationFromGravel.add(excavationTreasure);
|
||||
}
|
||||
|
||||
case CREEPER:
|
||||
shakeFromCreeper.add(e);
|
||||
break;
|
||||
if (dropList.contains("Clay")) {
|
||||
excavationFromClay.add(excavationTreasure);
|
||||
}
|
||||
|
||||
case ENDERMAN:
|
||||
shakeFromEnderman.add(e);
|
||||
break;
|
||||
if (dropList.contains("Mycelium")) {
|
||||
excavationFromMycel.add(excavationTreasure);
|
||||
}
|
||||
|
||||
case GHAST:
|
||||
shakeFromGhast.add(e);
|
||||
break;
|
||||
if (dropList.contains("Soul_Sand")) {
|
||||
excavationFromSoulSand.add(excavationTreasure);
|
||||
}
|
||||
|
||||
case IRON_GOLEM:
|
||||
shakeFromIronGolem.add(e);
|
||||
break;
|
||||
|
||||
case MAGMA_CUBE:
|
||||
shakeFromMagmaCube.add(e);
|
||||
break;
|
||||
|
||||
case MUSHROOM_COW:
|
||||
shakeFromMushroomCow.add(e);
|
||||
break;
|
||||
|
||||
case PIG:
|
||||
shakeFromPig.add(e);
|
||||
break;
|
||||
|
||||
case PIG_ZOMBIE:
|
||||
shakeFromPigZombie.add(e);
|
||||
break;
|
||||
|
||||
case SHEEP:
|
||||
shakeFromSheep.add(e);
|
||||
break;
|
||||
|
||||
case SKELETON:
|
||||
shakeFromSkeleton.add(e);
|
||||
break;
|
||||
|
||||
case SLIME:
|
||||
shakeFromSlime.add(e);
|
||||
break;
|
||||
|
||||
case SPIDER:
|
||||
shakeFromSpider.add(e);
|
||||
break;
|
||||
|
||||
case SNOWMAN:
|
||||
shakeFromSnowman.add(e);
|
||||
break;
|
||||
|
||||
case SQUID:
|
||||
shakeFromSquid.add(e);
|
||||
break;
|
||||
|
||||
case WITCH:
|
||||
shakeFromWitch.add(e);
|
||||
break;
|
||||
|
||||
case ZOMBIE:
|
||||
shakeFromZombie.add(e);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (treasure instanceof HylianTreasure) {
|
||||
if (hylianTreasures == null || !hylianTreasures.contains(treasureKey)) {
|
||||
continue;
|
||||
if (dropList.contains("Snow")) {
|
||||
excavationFromSnow.add(excavationTreasure);
|
||||
}
|
||||
}
|
||||
else if (isHylian) {
|
||||
HylianTreasure hylianTreasure = new HylianTreasure(item, xp, dropChance, dropLevel);
|
||||
List<String> dropList = config.getStringList(type + "." + treasureName + ".Drops_From");
|
||||
|
||||
HylianTreasure hTreasure = (HylianTreasure) treasure;
|
||||
if (dropList.contains("Bushes")) {
|
||||
hylianFromBushes.add(hylianTreasure);
|
||||
}
|
||||
|
||||
if (hTreasure.getDropsFromBushes()) {
|
||||
hylianFromBushes.add(hTreasure);
|
||||
}
|
||||
if (dropList.contains("Flowers")) {
|
||||
hylianFromFlowers.add(hylianTreasure);
|
||||
}
|
||||
|
||||
if (hTreasure.getDropsFromFlowers()) {
|
||||
hylianFromFlowers.add(hTreasure);
|
||||
}
|
||||
|
||||
if (hTreasure.getDropsFromPots()) {
|
||||
hylianFromPots.add(hTreasure);
|
||||
}
|
||||
}
|
||||
else if (treasure instanceof ExcavationTreasure) {
|
||||
if (excavationTreasures == null || !excavationTreasures.contains(treasureKey)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
ExcavationTreasure eTreasure = (ExcavationTreasure) treasure;
|
||||
|
||||
if (eTreasure.getDropsFromDirt()) {
|
||||
excavationFromDirt.add(eTreasure);
|
||||
}
|
||||
|
||||
if (eTreasure.getDropsFromGrass()) {
|
||||
excavationFromGrass.add(eTreasure);
|
||||
}
|
||||
|
||||
if (eTreasure.getDropsFromSand()) {
|
||||
excavationFromSand.add(eTreasure);
|
||||
}
|
||||
|
||||
if (eTreasure.getDropsFromGravel()) {
|
||||
excavationFromGravel.add(eTreasure);
|
||||
}
|
||||
|
||||
if (eTreasure.getDropsFromClay()) {
|
||||
excavationFromClay.add(eTreasure);
|
||||
}
|
||||
|
||||
if (eTreasure.getDropsFromMycel()) {
|
||||
excavationFromMycel.add(eTreasure);
|
||||
}
|
||||
|
||||
if (eTreasure.getDropsFromSoulSand()) {
|
||||
excavationFromSoulSand.add(eTreasure);
|
||||
}
|
||||
|
||||
if (eTreasure.getDropsFromSnow()) {
|
||||
excavationFromSnow.add(eTreasure);
|
||||
if (dropList.contains("Pots")) {
|
||||
hylianFromPots.add(hylianTreasure);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void loadEnchantments() {
|
||||
for (Rarity rarity : Rarity.values()) {
|
||||
if (rarity == Rarity.TRAP || rarity == Rarity.RECORD) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!fishingEnchantments.containsKey(rarity)) {
|
||||
fishingEnchantments.put(rarity, (new ArrayList<EnchantmentTreasure>()));
|
||||
}
|
||||
|
||||
ConfigurationSection enchantmentSection = config.getConfigurationSection("Enchantments_Rarity." + rarity.toString());
|
||||
|
||||
if (enchantmentSection == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (String enchantmentName : enchantmentSection.getKeys(false)) {
|
||||
int level = config.getInt("Enchantments_Rarity." + rarity.toString() + "." + enchantmentName);
|
||||
Enchantment enchantment = EnchantmentUtils.getByName(enchantmentName);
|
||||
|
||||
if (enchantment == null) {
|
||||
plugin.getLogger().warning("Skipping invalid enchantment in treasures.yml: " + enchantmentName);
|
||||
continue;
|
||||
}
|
||||
|
||||
fishingEnchantments.get(rarity).add(new EnchantmentTreasure(enchantment, level));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public double getItemDropRate(int tier, Rarity rarity) { return config.getDouble("Item_Drop_Rates.Tier_" + tier + "." + rarity.toString()); }
|
||||
public double getEnchantmentDropRate(int tier, Rarity rarity) { return config.getDouble("Enchantment_Drop_Rates.Tier_" + tier + "." + rarity.toString()); }
|
||||
}
|
||||
|
||||
@@ -7,10 +7,13 @@ import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.datatypes.database.DatabaseType;
|
||||
import com.gmail.nossr50.datatypes.database.PlayerStat;
|
||||
import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
|
||||
public interface DatabaseManager {
|
||||
// One month in milliseconds
|
||||
public final long PURGE_TIME = 2630000000L * Config.getInstance().getOldUsersCutoff();
|
||||
// During convertUsers, how often to output a status
|
||||
public final int progressInterval = 200;
|
||||
|
||||
/**
|
||||
* Purge users with 0 power level from the database.
|
||||
@@ -34,8 +37,9 @@ public interface DatabaseManager {
|
||||
* Save a user to the database.
|
||||
*
|
||||
* @param profile The profile of the player to save
|
||||
* @return true if successful, false on failure
|
||||
*/
|
||||
public void saveUser(PlayerProfile profile);
|
||||
public boolean saveUser(PlayerProfile profile);
|
||||
|
||||
/**
|
||||
* Retrieve leaderboard info.
|
||||
@@ -45,15 +49,18 @@ public interface DatabaseManager {
|
||||
* @param statsPerPage The number of stats per page
|
||||
* @return the requested leaderboard information
|
||||
*/
|
||||
public List<PlayerStat> readLeaderboard(String skillName, int pageNumber, int statsPerPage);
|
||||
public List<PlayerStat> readLeaderboard(SkillType skill, int pageNumber, int statsPerPage);
|
||||
|
||||
/**
|
||||
* Retrieve rank info.
|
||||
* Retrieve rank info into a HashMap from SkillType to the rank.
|
||||
* <p>
|
||||
* The special value <code>null</code> is used to represent the Power
|
||||
* Level rank (the combination of all skill levels).
|
||||
*
|
||||
* @param playerName The name of the user to retrieve the rankings for
|
||||
* @return the requested rank information
|
||||
*/
|
||||
public Map<String, Integer> readRank(String playerName);
|
||||
public Map<SkillType, Integer> readRank(String playerName);
|
||||
|
||||
/**
|
||||
* Add a new user to the database.
|
||||
|
||||
@@ -10,7 +10,7 @@ public class DatabaseManagerFactory {
|
||||
public static DatabaseManager getDatabaseManager() {
|
||||
if (customManager != null) {
|
||||
try {
|
||||
return createCustomDatabaseManager(customManager);
|
||||
return createDefaultCustomDatabaseManager();
|
||||
}
|
||||
catch (Exception e) {
|
||||
mcMMO.p.debug("Could not create custom database manager");
|
||||
@@ -29,17 +29,18 @@ public class DatabaseManagerFactory {
|
||||
/**
|
||||
* Sets the custom DatabaseManager class for mcMMO to use. This should be
|
||||
* called prior to mcMMO enabling.
|
||||
* <p>
|
||||
* <p/>
|
||||
* The provided class must have an empty constructor, which is the one
|
||||
* that will be used.
|
||||
* <p>
|
||||
* <p/>
|
||||
* This method is intended for API use, but it should not be considered
|
||||
* stable. This method is subject to change and/or removal in future
|
||||
* versions.
|
||||
*
|
||||
* @param clazz the DatabaseManager class to use
|
||||
*
|
||||
* @throws IllegalArgumentException if the provided class does not have
|
||||
* an empty constructor
|
||||
* an empty constructor
|
||||
*/
|
||||
public static void setCustomDatabaseManagerClass(Class<? extends DatabaseManager> clazz) {
|
||||
try {
|
||||
@@ -63,13 +64,24 @@ public class DatabaseManagerFactory {
|
||||
case SQL:
|
||||
return new SQLDatabaseManager();
|
||||
|
||||
case CUSTOM:
|
||||
try {
|
||||
return createDefaultCustomDatabaseManager();
|
||||
}
|
||||
catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
//TODO: Why is clazz never used here?
|
||||
public static DatabaseManager createDefaultCustomDatabaseManager() throws Throwable {
|
||||
return customManager.getConstructor((Class<?>) null).newInstance((Object[]) null);
|
||||
}
|
||||
|
||||
public static DatabaseManager createCustomDatabaseManager(Class<? extends DatabaseManager> clazz) throws Throwable {
|
||||
return customManager.getConstructor((Class<?>) clazz).newInstance((Object[]) null);
|
||||
return clazz.getConstructor((Class<?>) null).newInstance((Object[]) null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,7 +15,6 @@ import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
@@ -26,7 +25,6 @@ import com.gmail.nossr50.datatypes.database.PlayerStat;
|
||||
import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.skills.AbilityType;
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.datatypes.spout.huds.HudType;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
|
||||
public final class FlatfileDatabaseManager implements DatabaseManager {
|
||||
@@ -123,9 +121,10 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
|
||||
try {
|
||||
lastPlayed = Long.parseLong(character[37]) * Misc.TIME_CONVERSION_FACTOR;
|
||||
}
|
||||
catch (NumberFormatException e) {}
|
||||
catch (NumberFormatException e) {
|
||||
}
|
||||
if (lastPlayed == 0) {
|
||||
OfflinePlayer player = Bukkit.getOfflinePlayer(name);
|
||||
OfflinePlayer player = mcMMO.p.getServer().getOfflinePlayer(name);
|
||||
lastPlayed = player.getLastPlayed();
|
||||
rewrite = true;
|
||||
}
|
||||
@@ -204,7 +203,7 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
|
||||
return worked;
|
||||
}
|
||||
|
||||
public void saveUser(PlayerProfile profile) {
|
||||
public boolean saveUser(PlayerProfile profile) {
|
||||
String playerName = profile.getPlayerName();
|
||||
|
||||
BufferedReader in = null;
|
||||
@@ -259,8 +258,7 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
|
||||
writer.append((int) profile.getSkillDATS(AbilityType.SERRATED_STRIKES)).append(":");
|
||||
writer.append((int) profile.getSkillDATS(AbilityType.SKULL_SPLITTER)).append(":");
|
||||
writer.append((int) profile.getSkillDATS(AbilityType.SUPER_BREAKER)).append(":");
|
||||
HudType hudType = profile.getHudType();
|
||||
writer.append(hudType == null ? "STANDARD" : hudType.toString()).append(":");
|
||||
writer.append(":");
|
||||
writer.append(profile.getSkillLevel(SkillType.FISHING)).append(":");
|
||||
writer.append(profile.getSkillXpLevel(SkillType.FISHING)).append(":");
|
||||
writer.append((int) profile.getSkillDATS(AbilityType.BLAST_MINING)).append(":");
|
||||
@@ -274,9 +272,11 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
|
||||
// Write the new file
|
||||
out = new FileWriter(usersFilePath);
|
||||
out.write(writer.toString());
|
||||
return true;
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
finally {
|
||||
tryClose(in);
|
||||
@@ -285,24 +285,24 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
|
||||
}
|
||||
}
|
||||
|
||||
public List<PlayerStat> readLeaderboard(String skillName, int pageNumber, int statsPerPage) {
|
||||
public List<PlayerStat> readLeaderboard(SkillType skill, int pageNumber, int statsPerPage) {
|
||||
updateLeaderboards();
|
||||
List<PlayerStat> statsList = skillName.equalsIgnoreCase("all") ? powerLevels : playerStatHash.get(SkillType.getSkill(skillName));
|
||||
List<PlayerStat> statsList = skill == null ? powerLevels : playerStatHash.get(skill);
|
||||
int fromIndex = (Math.max(pageNumber, 1) - 1) * statsPerPage;
|
||||
|
||||
return statsList.subList(Math.min(fromIndex, statsList.size()), Math.min(fromIndex + statsPerPage, statsList.size()));
|
||||
}
|
||||
|
||||
public Map<String, Integer> readRank(String playerName) {
|
||||
public Map<SkillType, Integer> readRank(String playerName) {
|
||||
updateLeaderboards();
|
||||
|
||||
Map<String, Integer> skills = new HashMap<String, Integer>();
|
||||
Map<SkillType, Integer> skills = new HashMap<SkillType, Integer>();
|
||||
|
||||
for (SkillType skill : SkillType.nonChildSkills()) {
|
||||
skills.put(skill.name(), getPlayerRank(playerName, playerStatHash.get(skill)));
|
||||
for (SkillType skill : SkillType.NON_CHILD_SKILLS) {
|
||||
skills.put(skill, getPlayerRank(playerName, playerStatHash.get(skill)));
|
||||
}
|
||||
|
||||
skills.put("ALL", getPlayerRank(playerName, powerLevels));
|
||||
skills.put(null, getPlayerRank(playerName, powerLevels));
|
||||
|
||||
return skills;
|
||||
}
|
||||
@@ -348,7 +348,7 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
|
||||
out.append("0:"); // DATS
|
||||
out.append("0:"); // DATS
|
||||
out.append("0:"); // DATS
|
||||
out.append("STANDARD").append(":"); // HUD
|
||||
out.append(":");
|
||||
out.append("0:"); // Fishing
|
||||
out.append("0:"); // FishingXp
|
||||
out.append("0:"); // Blast Mining
|
||||
@@ -387,28 +387,41 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
|
||||
}
|
||||
|
||||
PlayerProfile p = loadFromLine(character);
|
||||
in.close();
|
||||
return p;
|
||||
}
|
||||
|
||||
// Didn't find the player, create a new one
|
||||
if (create) {
|
||||
newUser(playerName);
|
||||
return new PlayerProfile(playerName, true);
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
finally {
|
||||
tryClose(in);
|
||||
// I have no idea why it's necessary to inline tryClose() here, but it removes
|
||||
// a resource leak warning, and I'm trusting the compiler on this one.
|
||||
if (in != null) {
|
||||
try {
|
||||
in.close();
|
||||
}
|
||||
catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (create) {
|
||||
newUser(playerName);
|
||||
return new PlayerProfile(playerName, true);
|
||||
}
|
||||
// Return unloaded profile
|
||||
return new PlayerProfile(playerName);
|
||||
}
|
||||
|
||||
public void convertUsers(DatabaseManager destination) {
|
||||
BufferedReader in = null;
|
||||
String usersFilePath = mcMMO.getUsersFilePath();
|
||||
int convertedUsers = 0;
|
||||
long startMillis = System.currentTimeMillis();
|
||||
|
||||
synchronized (fileWritingLock) {
|
||||
try {
|
||||
@@ -425,6 +438,8 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
convertedUsers++;
|
||||
Misc.printProgress(convertedUsers, progressInterval, startMillis);
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
@@ -436,11 +451,6 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
|
||||
}
|
||||
}
|
||||
|
||||
public boolean checkConnected() {
|
||||
// Not implemented
|
||||
return true;
|
||||
}
|
||||
|
||||
public List<String> getStoredUsers() {
|
||||
ArrayList<String> users = new ArrayList<String>();
|
||||
BufferedReader in = null;
|
||||
@@ -495,6 +505,7 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
|
||||
List<PlayerStat> fishing = new ArrayList<PlayerStat>();
|
||||
|
||||
BufferedReader in = null;
|
||||
String playerName = null;
|
||||
// Read from the FlatFile database and fill our arrays with information
|
||||
synchronized (fileWritingLock) {
|
||||
try {
|
||||
@@ -503,7 +514,7 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
|
||||
|
||||
while ((line = in.readLine()) != null) {
|
||||
String[] data = line.split(":");
|
||||
String playerName = data[0];
|
||||
playerName = data[0];
|
||||
int powerLevel = 0;
|
||||
|
||||
Map<SkillType, Integer> skills = getSkillMapFromLine(data);
|
||||
@@ -525,7 +536,7 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
mcMMO.p.getLogger().severe("Exception while reading " + usersFilePath + " (Are you sure you formatted it correctly?)" + e.toString());
|
||||
mcMMO.p.getLogger().severe("Exception while reading " + usersFilePath + " during user " + playerName + " (Are you sure you formatted it correctly?) " + e.toString());
|
||||
}
|
||||
finally {
|
||||
tryClose(in);
|
||||
@@ -579,6 +590,11 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
|
||||
HashSet<String> players = new HashSet<String>();
|
||||
|
||||
while ((line = in.readLine()) != null) {
|
||||
// Remove empty lines from the file
|
||||
if (line.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Length checks depend on last character being ':'
|
||||
if (line.charAt(line.length() - 1) != ':') {
|
||||
line = line + ":";
|
||||
@@ -590,70 +606,81 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (character.length < 33) {
|
||||
// Before Version 1.0 - Drop
|
||||
mcMMO.p.getLogger().warning("Dropping malformed or before version 1.0 line from database - " + line);
|
||||
continue;
|
||||
}
|
||||
|
||||
String oldVersion = null;
|
||||
|
||||
if (!character[33].isEmpty()) {
|
||||
// Removal of Spout Support
|
||||
// Version 1.4.07-dev2
|
||||
// commit 7bac0e2ca5143bce84dc160617fed97f0b1cb968
|
||||
line = line.replace(character[33], "");
|
||||
oldVersion = "1.4.07";
|
||||
}
|
||||
|
||||
// If they're valid, rewrite them to the file.
|
||||
if (character.length > 38) {
|
||||
writer.append(line).append("\r\n");
|
||||
continue;
|
||||
}
|
||||
else if (character.length < 33) {
|
||||
// Before Version 1.0 - Drop
|
||||
mcMMO.p.getLogger().warning("Dropping malformed or before version 1.0 line from database - " + line);
|
||||
}
|
||||
else {
|
||||
String oldVersion = null;
|
||||
StringBuilder newLine = new StringBuilder(line);
|
||||
boolean announce = false;
|
||||
if (character.length <= 33) {
|
||||
// Introduction of HUDType
|
||||
// Version 1.1.06
|
||||
// commit 78f79213cdd7190cd11ae54526f3b4ea42078e8a
|
||||
newLine.append("STANDARD").append(":");
|
||||
oldVersion = "1.1.06";
|
||||
}
|
||||
if (character.length <= 35) {
|
||||
// Introduction of Fishing
|
||||
// Version 1.2.00
|
||||
// commit a814b57311bc7734661109f0e77fc8bab3a0bd29
|
||||
newLine.append(0).append(":");
|
||||
newLine.append(0).append(":");
|
||||
if (oldVersion == null) {
|
||||
oldVersion = "1.2.00";
|
||||
}
|
||||
}
|
||||
if (character.length <= 36) {
|
||||
// Introduction of Blast Mining cooldowns
|
||||
// Version 1.3.00-dev
|
||||
// commit fadbaf429d6b4764b8f1ad0efaa524a090e82ef5
|
||||
newLine.append(0).append(":");
|
||||
if (oldVersion == null) {
|
||||
oldVersion = "1.3.00";
|
||||
}
|
||||
}
|
||||
if (character.length <= 37) {
|
||||
// Making old-purge work with flatfile
|
||||
// Version 1.4.00-dev
|
||||
// commmit 3f6c07ba6aaf44e388cc3b882cac3d8f51d0ac28
|
||||
// XXX Cannot create an OfflinePlayer at startup, use 0 and fix in purge
|
||||
newLine.append("0").append(":");
|
||||
announce = true; // TODO move this down
|
||||
if (oldVersion == null) {
|
||||
oldVersion = "1.4.00";
|
||||
}
|
||||
}
|
||||
if (character.length <= 38) {
|
||||
// Addition of mob healthbars
|
||||
// Version 1.4.06
|
||||
// commit da29185b7dc7e0d992754bba555576d48fa08aa6
|
||||
newLine.append(Config.getInstance().getMobHealthbarDefault().toString()).append(":");
|
||||
if (oldVersion == null) {
|
||||
oldVersion = "1.4.06";
|
||||
}
|
||||
}
|
||||
|
||||
if (announce) {
|
||||
mcMMO.p.debug("Updating database line for player " + character[0] + " from before version " + oldVersion);
|
||||
}
|
||||
writer.append(newLine).append("\r\n");
|
||||
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) {
|
||||
// Introduction of Fishing
|
||||
// Version 1.2.00
|
||||
// commit a814b57311bc7734661109f0e77fc8bab3a0bd29
|
||||
newLine.append(0).append(":");
|
||||
newLine.append(0).append(":");
|
||||
if (oldVersion == null) {
|
||||
oldVersion = "1.2.00";
|
||||
}
|
||||
}
|
||||
if (character.length <= 36) {
|
||||
// Introduction of Blast Mining cooldowns
|
||||
// Version 1.3.00-dev
|
||||
// commit fadbaf429d6b4764b8f1ad0efaa524a090e82ef5
|
||||
newLine.append(0).append(":");
|
||||
if (oldVersion == null) {
|
||||
oldVersion = "1.3.00";
|
||||
}
|
||||
}
|
||||
if (character.length <= 37) {
|
||||
// Making old-purge work with flatfile
|
||||
// Version 1.4.00-dev
|
||||
// commmit 3f6c07ba6aaf44e388cc3b882cac3d8f51d0ac28
|
||||
// XXX Cannot create an OfflinePlayer at startup, use 0 and fix in purge
|
||||
newLine.append("0").append(":");
|
||||
if (oldVersion == null) {
|
||||
oldVersion = "1.4.00";
|
||||
}
|
||||
}
|
||||
if (character.length <= 38) {
|
||||
// Addition of mob healthbars
|
||||
// Version 1.4.06
|
||||
// commit da29185b7dc7e0d992754bba555576d48fa08aa6
|
||||
newLine.append(Config.getInstance().getMobHealthbarDefault().toString()).append(":");
|
||||
if (oldVersion == null) {
|
||||
oldVersion = "1.4.06";
|
||||
}
|
||||
}
|
||||
|
||||
if (oldVersion != null) {
|
||||
mcMMO.p.debug("Updating database line for player " + character[0] + " from before version " + oldVersion);
|
||||
}
|
||||
|
||||
writer.append(newLine).append("\r\n");
|
||||
}
|
||||
|
||||
// Write the new file
|
||||
@@ -728,7 +755,6 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
|
||||
Map<SkillType, Integer> skills = getSkillMapFromLine(character); // Skill levels
|
||||
Map<SkillType, Float> skillsXp = new HashMap<SkillType, Float>(); // Skill & XP
|
||||
Map<AbilityType, Integer> skillsDATS = new HashMap<AbilityType, Integer>(); // Ability & Cooldown
|
||||
HudType hudType;
|
||||
MobHealthbarType mobHealthbarType;
|
||||
|
||||
// TODO on updates, put new values in a try{} ?
|
||||
@@ -759,13 +785,6 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
|
||||
// Acrobatics - Unused
|
||||
skillsDATS.put(AbilityType.BLAST_MINING, Integer.valueOf(character[36]));
|
||||
|
||||
try {
|
||||
hudType = HudType.valueOf(character[33]);
|
||||
}
|
||||
catch (Exception e) {
|
||||
hudType = HudType.STANDARD; // Shouldn't happen unless database is being tampered with
|
||||
}
|
||||
|
||||
try {
|
||||
mobHealthbarType = MobHealthbarType.valueOf(character[38]);
|
||||
}
|
||||
@@ -773,7 +792,7 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
|
||||
mobHealthbarType = Config.getInstance().getMobHealthbarDefault();
|
||||
}
|
||||
|
||||
return new PlayerProfile(character[0], skills, skillsXp, skillsDATS, hudType, mobHealthbarType);
|
||||
return new PlayerProfile(character[0], skills, skillsXp, skillsDATS, mobHealthbarType);
|
||||
}
|
||||
|
||||
private Map<SkillType, Integer> getSkillMapFromLine(String[] character) {
|
||||
|
||||
@@ -12,7 +12,6 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
@@ -23,7 +22,7 @@ import com.gmail.nossr50.datatypes.database.PlayerStat;
|
||||
import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.skills.AbilityType;
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.datatypes.spout.huds.HudType;
|
||||
import com.gmail.nossr50.runnables.database.SQLDatabaseKeepaliveTask;
|
||||
import com.gmail.nossr50.runnables.database.SQLReconnectTask;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
|
||||
@@ -52,6 +51,8 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
|
||||
protected SQLDatabaseManager() {
|
||||
checkStructure();
|
||||
|
||||
new SQLDatabaseKeepaliveTask(this).runTaskTimerAsynchronously(mcMMO.p, 10, 60L * 60 * Misc.TICK_CONVERSION_FACTOR);
|
||||
}
|
||||
|
||||
public void purgePowerlessUsers() {
|
||||
@@ -93,7 +94,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
"WHERE ((" + currentTime + " - lastlogin * " + Misc.TIME_CONVERSION_FACTOR + ") > " + PURGE_TIME + ")");
|
||||
|
||||
processPurge(usernames);
|
||||
mcMMO.p.getLogger().info("Purged " + usernames.size() + " users from the database.");;
|
||||
mcMMO.p.getLogger().info("Purged " + usernames.size() + " users from the database.");
|
||||
}
|
||||
|
||||
public boolean removeUser(String playerName) {
|
||||
@@ -114,9 +115,9 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
return success;
|
||||
}
|
||||
|
||||
public void saveUser(PlayerProfile profile) {
|
||||
public boolean saveUser(PlayerProfile profile) {
|
||||
if (!checkConnected()) {
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
int userId = readId(profile.getPlayerName());
|
||||
@@ -124,16 +125,15 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
newUser(profile.getPlayerName());
|
||||
userId = readId(profile.getPlayerName());
|
||||
if (userId == -1) {
|
||||
mcMMO.p.getLogger().log(Level.WARNING, "Failed to save user " + profile.getPlayerName());
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
boolean success = true;
|
||||
MobHealthbarType mobHealthbarType = profile.getMobHealthbarType();
|
||||
HudType hudType = profile.getHudType();
|
||||
|
||||
saveLogin(userId, ((int) (System.currentTimeMillis() / Misc.TIME_CONVERSION_FACTOR)));
|
||||
saveHuds(userId, (hudType == null ? "STANDARD" : hudType.toString()), (mobHealthbarType == null ? Config.getInstance().getMobHealthbarDefault().toString() : mobHealthbarType.toString()));
|
||||
saveLongs(
|
||||
success &= saveLogin(userId, ((int) (System.currentTimeMillis() / Misc.TIME_CONVERSION_FACTOR)));
|
||||
success &= saveHuds(userId, (mobHealthbarType == null ? Config.getInstance().getMobHealthbarDefault().toString() : mobHealthbarType.toString()));
|
||||
success &= saveLongs(
|
||||
"UPDATE " + tablePrefix + "cooldowns SET "
|
||||
+ " mining = ?, woodcutting = ?, unarmed = ?"
|
||||
+ ", herbalism = ?, excavation = ?, swords = ?"
|
||||
@@ -147,7 +147,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
profile.getSkillDATS(AbilityType.SERRATED_STRIKES),
|
||||
profile.getSkillDATS(AbilityType.SKULL_SPLITTER),
|
||||
profile.getSkillDATS(AbilityType.BLAST_MINING));
|
||||
saveIntegers(
|
||||
success &= saveIntegers(
|
||||
"UPDATE " + tablePrefix + "skills SET "
|
||||
+ " taming = ?, mining = ?, repair = ?, woodcutting = ?"
|
||||
+ ", unarmed = ?, herbalism = ?, excavation = ?"
|
||||
@@ -166,7 +166,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
profile.getSkillLevel(SkillType.ACROBATICS),
|
||||
profile.getSkillLevel(SkillType.FISHING),
|
||||
userId);
|
||||
saveIntegers(
|
||||
success &= saveIntegers(
|
||||
"UPDATE " + tablePrefix + "experience SET "
|
||||
+ " taming = ?, mining = ?, repair = ?, woodcutting = ?"
|
||||
+ ", unarmed = ?, herbalism = ?, excavation = ?"
|
||||
@@ -185,13 +185,14 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
profile.getSkillXpLevel(SkillType.ACROBATICS),
|
||||
profile.getSkillXpLevel(SkillType.FISHING),
|
||||
userId);
|
||||
return success;
|
||||
}
|
||||
|
||||
public List<PlayerStat> readLeaderboard(String skillName, int pageNumber, int statsPerPage) {
|
||||
public List<PlayerStat> readLeaderboard(SkillType skill, int pageNumber, int statsPerPage) {
|
||||
List<PlayerStat> stats = new ArrayList<PlayerStat>();
|
||||
|
||||
if (checkConnected()) {
|
||||
String query = skillName.equalsIgnoreCase("ALL") ? "taming+mining+woodcutting+repair+unarmed+herbalism+excavation+archery+swords+axes+acrobatics+fishing" : skillName;
|
||||
String query = skill == null ? "taming+mining+woodcutting+repair+unarmed+herbalism+excavation+archery+swords+axes+acrobatics+fishing" : skill.name().toLowerCase();
|
||||
ResultSet resultSet = null;
|
||||
PreparedStatement statement = null;
|
||||
|
||||
@@ -229,14 +230,14 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
return stats;
|
||||
}
|
||||
|
||||
public Map<String, Integer> readRank(String playerName) {
|
||||
Map<String, Integer> skills = new HashMap<String, Integer>();
|
||||
public Map<SkillType, Integer> readRank(String playerName) {
|
||||
Map<SkillType, Integer> skills = new HashMap<SkillType, Integer>();
|
||||
|
||||
if (checkConnected()) {
|
||||
ResultSet resultSet;
|
||||
|
||||
try {
|
||||
for (SkillType skillType : SkillType.nonChildSkills()) {
|
||||
for (SkillType skillType : SkillType.NON_CHILD_SKILLS) {
|
||||
String skillName = skillType.name().toLowerCase();
|
||||
String sql = "SELECT COUNT(*) AS rank FROM " + tablePrefix + "users JOIN " + tablePrefix + "skills ON user_id = id WHERE " + skillName + " > 0 " +
|
||||
"AND " + skillName + " > (SELECT " + skillName + " FROM " + tablePrefix + "users JOIN " + tablePrefix + "skills ON user_id = id " +
|
||||
@@ -261,7 +262,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
|
||||
while (resultSet.next()) {
|
||||
if (resultSet.getString("user").equalsIgnoreCase(playerName)) {
|
||||
skills.put(skillType.name(), rank + resultSet.getRow());
|
||||
skills.put(skillType, rank + resultSet.getRow());
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -298,7 +299,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
|
||||
while (resultSet.next()) {
|
||||
if (resultSet.getString("user").equalsIgnoreCase(playerName)) {
|
||||
skills.put("ALL", rank + resultSet.getRow());
|
||||
skills.put(null, rank + resultSet.getRow());
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -345,6 +346,10 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
}
|
||||
|
||||
public PlayerProfile loadPlayerProfile(String playerName, boolean create) {
|
||||
return loadPlayerProfile(playerName, create, true);
|
||||
}
|
||||
|
||||
private PlayerProfile loadPlayerProfile(String playerName, boolean create, boolean retry) {
|
||||
if (!checkConnected()) {
|
||||
return new PlayerProfile(playerName, false); // return fake profile if not connected
|
||||
}
|
||||
@@ -357,7 +362,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
+ "s.taming, s.mining, s.repair, s.woodcutting, s.unarmed, s.herbalism, s.excavation, s.archery, s.swords, s.axes, s.acrobatics, s.fishing, "
|
||||
+ "e.taming, e.mining, e.repair, e.woodcutting, e.unarmed, e.herbalism, e.excavation, e.archery, e.swords, e.axes, e.acrobatics, e.fishing, "
|
||||
+ "c.taming, c.mining, c.repair, c.woodcutting, c.unarmed, c.herbalism, c.excavation, c.archery, c.swords, c.axes, c.acrobatics, c.blast_mining, "
|
||||
+ "h.hudtype, h.mobhealthbar "
|
||||
+ "h.mobhealthbar "
|
||||
+ "FROM " + tablePrefix + "users u "
|
||||
+ "JOIN " + tablePrefix + "skills s ON (u.id = s.user_id) "
|
||||
+ "JOIN " + tablePrefix + "experience e ON (u.id = e.user_id) "
|
||||
@@ -374,7 +379,8 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
result.close();
|
||||
return ret;
|
||||
}
|
||||
catch (SQLException e) {}
|
||||
catch (SQLException e) {
|
||||
}
|
||||
}
|
||||
result.close();
|
||||
}
|
||||
@@ -394,6 +400,11 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
|
||||
// Problem, nothing was returned
|
||||
|
||||
// Quit if this is second time around
|
||||
if (!retry) {
|
||||
return new PlayerProfile(playerName, false);
|
||||
}
|
||||
|
||||
// First, read User Id - this is to check for orphans
|
||||
|
||||
int id = readId(playerName);
|
||||
@@ -402,14 +413,16 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
// There is no such user
|
||||
if (create) {
|
||||
newUser(playerName);
|
||||
return loadPlayerProfile(playerName, false, false);
|
||||
}
|
||||
|
||||
return new PlayerProfile(playerName, create);
|
||||
// Return unloaded profile if can't create
|
||||
return new PlayerProfile(playerName, false);
|
||||
}
|
||||
// There is such a user
|
||||
writeMissingRows(id);
|
||||
// Retry, and abort on re-failure
|
||||
return loadPlayerProfile(playerName, false);
|
||||
return loadPlayerProfile(playerName, create, false);
|
||||
}
|
||||
|
||||
public void convertUsers(DatabaseManager destination) {
|
||||
@@ -425,7 +438,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
+ "s.taming, s.mining, s.repair, s.woodcutting, s.unarmed, s.herbalism, s.excavation, s.archery, s.swords, s.axes, s.acrobatics, s.fishing, "
|
||||
+ "e.taming, e.mining, e.repair, e.woodcutting, e.unarmed, e.herbalism, e.excavation, e.archery, e.swords, e.axes, e.acrobatics, e.fishing, "
|
||||
+ "c.taming, c.mining, c.repair, c.woodcutting, c.unarmed, c.herbalism, c.excavation, c.archery, c.swords, c.axes, c.acrobatics, c.blast_mining, "
|
||||
+ "h.hudtype, h.mobhealthbar "
|
||||
+ "h.mobhealthbar "
|
||||
+ "FROM " + tablePrefix + "users u "
|
||||
+ "JOIN " + tablePrefix + "skills s ON (u.id = s.user_id) "
|
||||
+ "JOIN " + tablePrefix + "experience e ON (u.id = e.user_id) "
|
||||
@@ -434,6 +447,8 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
+ "WHERE u.user = ?");
|
||||
List<String> usernames = getStoredUsers();
|
||||
ResultSet result = null;
|
||||
int convertedUsers = 0;
|
||||
long startMillis = System.currentTimeMillis();
|
||||
for (String playerName : usernames) {
|
||||
statement.setString(1, playerName);
|
||||
try {
|
||||
@@ -445,6 +460,8 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
catch (SQLException e) {
|
||||
// Ignore
|
||||
}
|
||||
convertedUsers++;
|
||||
Misc.printProgress(convertedUsers, progressInterval, startMillis);
|
||||
}
|
||||
}
|
||||
catch (SQLException e) {
|
||||
@@ -454,13 +471,15 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
if (statement != null) {
|
||||
try {
|
||||
statement.close();
|
||||
} catch (SQLException e) {
|
||||
}
|
||||
catch (SQLException e) {
|
||||
// Ignore
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Check connection status and re-establish if dead or stale.
|
||||
*
|
||||
@@ -571,7 +590,8 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
if (stmt != null) {
|
||||
try {
|
||||
stmt.close();
|
||||
} catch (SQLException e) {
|
||||
}
|
||||
catch (SQLException e) {
|
||||
// Ignore
|
||||
}
|
||||
}
|
||||
@@ -634,7 +654,6 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
+ "UNIQUE KEY `user` (`user`)) DEFAULT CHARSET=latin1 AUTO_INCREMENT=1;");
|
||||
write("CREATE TABLE IF NOT EXISTS `" + tablePrefix + "huds` ("
|
||||
+ "`user_id` int(10) unsigned NOT NULL,"
|
||||
+ "`hudtype` varchar(50) NOT NULL DEFAULT 'STANDARD',"
|
||||
+ "`mobhealthbar` varchar(50) NOT NULL DEFAULT '" + Config.getInstance().getMobHealthbarDefault() + "',"
|
||||
+ "PRIMARY KEY (`user_id`)) "
|
||||
+ "DEFAULT CHARSET=latin1;");
|
||||
@@ -735,6 +754,10 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
write("ALTER TABLE `" + tablePrefix + "users` DROP COLUMN `party` ;");
|
||||
return;
|
||||
|
||||
case DROPPED_SPOUT:
|
||||
write("ALTER TABLE `" + tablePrefix + "huds` DROP COLUMN `hudtype` ;");
|
||||
return;
|
||||
|
||||
case KILL_ORPHANS:
|
||||
mcMMO.p.getLogger().info("Killing orphans");
|
||||
write(
|
||||
@@ -841,7 +864,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
return true;
|
||||
}
|
||||
catch (SQLException ex) {
|
||||
if (!sql.equalsIgnoreCase("ALTER TABLE `" + tablePrefix + "users` DROP COLUMN `party` ;")) {
|
||||
if (!sql.contains("DROP COLUMN")) {
|
||||
printErrors(ex);
|
||||
}
|
||||
return false;
|
||||
@@ -1019,7 +1042,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
}
|
||||
}
|
||||
|
||||
private void saveIntegers(String sql, int... args) {
|
||||
private boolean saveIntegers(String sql, int... args) {
|
||||
PreparedStatement statement = null;
|
||||
|
||||
try {
|
||||
@@ -1031,9 +1054,11 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
}
|
||||
|
||||
statement.execute();
|
||||
return true;
|
||||
}
|
||||
catch (SQLException ex) {
|
||||
printErrors(ex);
|
||||
return false;
|
||||
}
|
||||
finally {
|
||||
if (statement != null) {
|
||||
@@ -1047,7 +1072,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
}
|
||||
}
|
||||
|
||||
private void saveLongs(String sql, int id, long... args) {
|
||||
private boolean saveLongs(String sql, int id, long... args) {
|
||||
PreparedStatement statement = null;
|
||||
|
||||
try {
|
||||
@@ -1060,9 +1085,11 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
|
||||
statement.setInt(i++, id);
|
||||
statement.execute();
|
||||
return true;
|
||||
}
|
||||
catch (SQLException ex) {
|
||||
printErrors(ex);
|
||||
return false;
|
||||
}
|
||||
finally {
|
||||
if (statement != null) {
|
||||
@@ -1097,7 +1124,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
return id;
|
||||
}
|
||||
|
||||
private void saveLogin(int id, long login) {
|
||||
private boolean saveLogin(int id, long login) {
|
||||
PreparedStatement statement = null;
|
||||
|
||||
try {
|
||||
@@ -1105,9 +1132,11 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
statement.setLong(1, login);
|
||||
statement.setInt(2, id);
|
||||
statement.execute();
|
||||
return true;
|
||||
}
|
||||
catch (SQLException ex) {
|
||||
printErrors(ex);
|
||||
return false;
|
||||
}
|
||||
finally {
|
||||
if (statement != null) {
|
||||
@@ -1121,18 +1150,19 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
}
|
||||
}
|
||||
|
||||
private void saveHuds(int userId, String hudType, String mobHealthBar) {
|
||||
private boolean saveHuds(int userId, String mobHealthBar) {
|
||||
PreparedStatement statement = null;
|
||||
|
||||
try {
|
||||
statement = connection.prepareStatement("UPDATE " + tablePrefix + "huds SET hudtype = ?, mobhealthbar = ? WHERE user_id = ?");
|
||||
statement.setString(1, hudType);
|
||||
statement.setString(2, mobHealthBar);
|
||||
statement.setInt(3, userId);
|
||||
statement = connection.prepareStatement("UPDATE " + tablePrefix + "huds SET mobhealthbar = ? WHERE user_id = ?");
|
||||
statement.setString(1, mobHealthBar);
|
||||
statement.setInt(2, userId);
|
||||
statement.execute();
|
||||
return true;
|
||||
}
|
||||
catch (SQLException ex) {
|
||||
printErrors(ex);
|
||||
return false;
|
||||
}
|
||||
finally {
|
||||
if (statement != null) {
|
||||
@@ -1150,7 +1180,6 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
Map<SkillType, Integer> skills = new HashMap<SkillType, Integer>(); // Skill & Level
|
||||
Map<SkillType, Float> skillsXp = new HashMap<SkillType, Float>(); // Skill & XP
|
||||
Map<AbilityType, Integer> skillsDATS = new HashMap<AbilityType, Integer>(); // Ability & Cooldown
|
||||
HudType hudType;
|
||||
MobHealthbarType mobHealthbarType;
|
||||
|
||||
final int OFFSET_SKILLS = 0; // TODO update these numbers when the query changes (a new skill is added)
|
||||
@@ -1197,13 +1226,6 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
// Acrobatics - Unused - result.getInt(OFFSET_DATS + 11)
|
||||
skillsDATS.put(AbilityType.BLAST_MINING, result.getInt(OFFSET_DATS + 12));
|
||||
|
||||
try {
|
||||
hudType = HudType.valueOf(result.getString(OFFSET_OTHER + 1));
|
||||
}
|
||||
catch (Exception e) {
|
||||
hudType = HudType.STANDARD; // Shouldn't happen unless database is being tampered with
|
||||
}
|
||||
|
||||
try {
|
||||
mobHealthbarType = MobHealthbarType.valueOf(result.getString(OFFSET_OTHER + 2));
|
||||
}
|
||||
@@ -1211,7 +1233,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
mobHealthbarType = Config.getInstance().getMobHealthbarDefault();
|
||||
}
|
||||
|
||||
return new PlayerProfile(playerName, skills, skillsXp, skillsDATS, hudType, mobHealthbarType);
|
||||
return new PlayerProfile(playerName, skills, skillsXp, skillsDATS, mobHealthbarType);
|
||||
}
|
||||
|
||||
private void printErrors(SQLException ex) {
|
||||
|
||||
@@ -5,7 +5,8 @@ public enum DatabaseUpdateType {
|
||||
BLAST_MINING,
|
||||
INDEX,
|
||||
MOB_HEALTHBARS,
|
||||
PARTY_NAMES,
|
||||
PARTY_NAMES,
|
||||
KILL_ORPHANS,
|
||||
DROPPED_SPOUT
|
||||
;
|
||||
}
|
||||
|
||||
@@ -1,79 +1,19 @@
|
||||
package com.gmail.nossr50.datatypes.mods;
|
||||
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class CustomBlock {
|
||||
private int itemID;
|
||||
private byte dataValue;
|
||||
private int xpGain;
|
||||
private int tier;
|
||||
private ItemStack itemDrop;
|
||||
private int minimumDropAmount;
|
||||
private int maximumDropAmount;
|
||||
private boolean canDoubleDrop;
|
||||
|
||||
public CustomBlock(int minimumDropAmount, int maximumDropAmount, ItemStack itemDrop, int tier, int xpGain, byte dataValue, int itemID) {
|
||||
this.itemID = itemID;
|
||||
this.dataValue = dataValue;
|
||||
public CustomBlock(int xpGain, boolean canDoubleDrop) {
|
||||
this.xpGain = xpGain;
|
||||
this.tier = tier;
|
||||
this.itemDrop = itemDrop;
|
||||
this.minimumDropAmount = minimumDropAmount;
|
||||
this.maximumDropAmount = maximumDropAmount;
|
||||
}
|
||||
|
||||
public int getItemID() {
|
||||
return itemID;
|
||||
}
|
||||
|
||||
public void setItemID(int itemID) {
|
||||
this.itemID = itemID;
|
||||
}
|
||||
|
||||
public byte getDataValue() {
|
||||
return dataValue;
|
||||
}
|
||||
|
||||
public void setDataValue(byte dataValue) {
|
||||
this.dataValue = dataValue;
|
||||
this.canDoubleDrop = canDoubleDrop;
|
||||
}
|
||||
|
||||
public int getXpGain() {
|
||||
return xpGain;
|
||||
}
|
||||
|
||||
public void setXpGain(int xpGain) {
|
||||
this.xpGain = xpGain;
|
||||
}
|
||||
|
||||
public int getTier() {
|
||||
return tier;
|
||||
}
|
||||
|
||||
public void setTier(int tier) {
|
||||
this.tier = tier;
|
||||
}
|
||||
|
||||
public ItemStack getItemDrop() {
|
||||
return itemDrop;
|
||||
}
|
||||
|
||||
public void setItemDrop(ItemStack itemDrop) {
|
||||
this.itemDrop = itemDrop;
|
||||
}
|
||||
|
||||
public int getMinimumDropAmount() {
|
||||
return minimumDropAmount;
|
||||
}
|
||||
|
||||
public void setMinimumDropAmount(int minimumDropAmount) {
|
||||
this.minimumDropAmount = minimumDropAmount;
|
||||
}
|
||||
|
||||
public int getMaximumDropAmount() {
|
||||
return maximumDropAmount;
|
||||
}
|
||||
|
||||
public void setMaximumDropAmount(int maximumDropAmount) {
|
||||
this.maximumDropAmount = maximumDropAmount;
|
||||
public boolean isDoubleDropEnabled() {
|
||||
return canDoubleDrop;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,8 @@
|
||||
package com.gmail.nossr50.datatypes.mods;
|
||||
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class CustomEntity {
|
||||
private int entityID;
|
||||
private EntityType entityType;
|
||||
private double xpMultiplier;
|
||||
private boolean canBeTamed;
|
||||
private int tamingXP;
|
||||
@@ -13,9 +10,7 @@ public class CustomEntity {
|
||||
private ItemStack callOfTheWildItem;
|
||||
private int callOfTheWildAmount;
|
||||
|
||||
public CustomEntity(int entityID, EntityType entityType, double xpMultiplier, boolean canBeTamed, int tamingXP, boolean canBeSummoned, ItemStack callOfTheWildItem, int callOfTheWildAmount) {
|
||||
this.entityID = entityID;
|
||||
this.entityType = entityType;
|
||||
public CustomEntity(double xpMultiplier, boolean canBeTamed, int tamingXP, boolean canBeSummoned, ItemStack callOfTheWildItem, int callOfTheWildAmount) {
|
||||
this.xpMultiplier = xpMultiplier;
|
||||
this.canBeTamed = canBeTamed;
|
||||
this.tamingXP = tamingXP;
|
||||
@@ -24,67 +19,27 @@ public class CustomEntity {
|
||||
this.callOfTheWildAmount = callOfTheWildAmount;
|
||||
}
|
||||
|
||||
public int getEntityID() {
|
||||
return entityID;
|
||||
}
|
||||
|
||||
public void setEntityID(int entityID) {
|
||||
this.entityID = entityID;
|
||||
}
|
||||
|
||||
public EntityType getEntityType() {
|
||||
return entityType;
|
||||
}
|
||||
|
||||
public void setEntityType(EntityType entityType) {
|
||||
this.entityType = entityType;
|
||||
}
|
||||
|
||||
public double getXpMultiplier() {
|
||||
return xpMultiplier;
|
||||
}
|
||||
|
||||
public void setXpMultiplier(double xpMultiplier) {
|
||||
this.xpMultiplier = xpMultiplier;
|
||||
}
|
||||
|
||||
public boolean isCanBeTamed() {
|
||||
public boolean canBeTamed() {
|
||||
return canBeTamed;
|
||||
}
|
||||
|
||||
public void setCanBeTamed(boolean canBeTamed) {
|
||||
this.canBeTamed = canBeTamed;
|
||||
}
|
||||
|
||||
public int getTamingXP() {
|
||||
return tamingXP;
|
||||
}
|
||||
|
||||
public void setTamingXP(int tamingXP) {
|
||||
this.tamingXP = tamingXP;
|
||||
}
|
||||
|
||||
public boolean isCanBeSummoned() {
|
||||
public boolean canBeSummoned() {
|
||||
return canBeSummoned;
|
||||
}
|
||||
|
||||
public void setCanBeSummoned(boolean canBeSummoned) {
|
||||
this.canBeSummoned = canBeSummoned;
|
||||
}
|
||||
|
||||
public ItemStack getCallOfTheWildItem() {
|
||||
return callOfTheWildItem;
|
||||
}
|
||||
|
||||
public void setCallOfTheWildItem(ItemStack callOfTheWildItem) {
|
||||
this.callOfTheWildItem = callOfTheWildItem;
|
||||
}
|
||||
|
||||
public int getCallOfTheWildAmount() {
|
||||
return callOfTheWildAmount;
|
||||
}
|
||||
|
||||
public void setCallOfTheWildAmount(int callOfTheWildAmount) {
|
||||
this.callOfTheWildAmount = callOfTheWildAmount;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,27 +0,0 @@
|
||||
package com.gmail.nossr50.datatypes.mods;
|
||||
|
||||
public class CustomItem {
|
||||
protected int itemID;
|
||||
protected short durability;
|
||||
|
||||
public CustomItem(int itemID, short durability) {
|
||||
this.itemID = itemID;
|
||||
this.durability = durability;
|
||||
}
|
||||
|
||||
public int getItemID() {
|
||||
return itemID;
|
||||
}
|
||||
|
||||
public void setItemID(int itemID) {
|
||||
this.itemID = itemID;
|
||||
}
|
||||
|
||||
public short getDurability() {
|
||||
return durability;
|
||||
}
|
||||
|
||||
public void setDurability(short durability) {
|
||||
this.durability = durability;
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,11 @@
|
||||
package com.gmail.nossr50.datatypes.mods;
|
||||
|
||||
public class CustomTool extends CustomItem {
|
||||
public class CustomTool {
|
||||
private double xpMultiplier;
|
||||
private boolean abilityEnabled;
|
||||
private int tier;
|
||||
|
||||
public CustomTool(int tier, boolean abilityEnabled, double xpMultiplier, short durability, int itemID) {
|
||||
super(itemID, durability);
|
||||
public CustomTool(int tier, boolean abilityEnabled, double xpMultiplier) {
|
||||
this.xpMultiplier = xpMultiplier;
|
||||
this.abilityEnabled = abilityEnabled;
|
||||
this.tier = tier;
|
||||
@@ -16,23 +15,11 @@ public class CustomTool extends CustomItem {
|
||||
return xpMultiplier;
|
||||
}
|
||||
|
||||
public void setXpMultiplier(Double xpMultiplier) {
|
||||
this.xpMultiplier = xpMultiplier;
|
||||
}
|
||||
|
||||
public boolean isAbilityEnabled() {
|
||||
return abilityEnabled;
|
||||
}
|
||||
|
||||
public void setAbilityEnabled(boolean abilityEnabled) {
|
||||
this.abilityEnabled = abilityEnabled;
|
||||
}
|
||||
|
||||
public int getTier() {
|
||||
return tier;
|
||||
}
|
||||
|
||||
public void setTier(int tier) {
|
||||
this.tier = tier;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -67,14 +67,14 @@ public class Party {
|
||||
return onlineMembers;
|
||||
}
|
||||
|
||||
public String getLeader() {
|
||||
return leader;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public String getLeader() {
|
||||
return leader;
|
||||
}
|
||||
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
||||
@@ -6,9 +6,15 @@ import java.util.Set;
|
||||
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.AdvancedConfig;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.config.experience.ExperienceConfig;
|
||||
import com.gmail.nossr50.datatypes.mods.CustomTool;
|
||||
@@ -16,12 +22,11 @@ import com.gmail.nossr50.datatypes.party.Party;
|
||||
import com.gmail.nossr50.datatypes.skills.AbilityType;
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.datatypes.skills.ToolType;
|
||||
import com.gmail.nossr50.datatypes.spout.huds.McMMOHud;
|
||||
import com.gmail.nossr50.events.experience.McMMOPlayerXpGainEvent;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.party.PartyManager;
|
||||
import com.gmail.nossr50.party.ShareHandler;
|
||||
import com.gmail.nossr50.runnables.skills.AbilityDisableTask;
|
||||
import com.gmail.nossr50.runnables.skills.ToolLowerTask;
|
||||
import com.gmail.nossr50.skills.SkillManager;
|
||||
import com.gmail.nossr50.skills.acrobatics.AcrobaticsManager;
|
||||
import com.gmail.nossr50.skills.archery.ArcheryManager;
|
||||
@@ -38,9 +43,12 @@ import com.gmail.nossr50.skills.swords.SwordsManager;
|
||||
import com.gmail.nossr50.skills.taming.TamingManager;
|
||||
import com.gmail.nossr50.skills.unarmed.UnarmedManager;
|
||||
import com.gmail.nossr50.skills.woodcutting.WoodcuttingManager;
|
||||
import com.gmail.nossr50.util.EventUtils;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.ModUtils;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.StringUtils;
|
||||
import com.gmail.nossr50.util.skills.ParticleEffectUtils;
|
||||
import com.gmail.nossr50.util.skills.PerksUtils;
|
||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||
|
||||
@@ -78,6 +86,8 @@ public class McMMOPlayer {
|
||||
private int lastSalvageClick;
|
||||
private boolean godMode;
|
||||
|
||||
private Location hookLocation;
|
||||
|
||||
private final Map<AbilityType, Boolean> abilityMode = new HashMap<AbilityType, Boolean>();
|
||||
private final Map<AbilityType, Boolean> abilityInformed = new HashMap<AbilityType, Boolean>();
|
||||
|
||||
@@ -87,6 +97,7 @@ public class McMMOPlayer {
|
||||
private int recentlyHurt;
|
||||
private int respawnATS;
|
||||
private int teleportATS;
|
||||
private long databaseATS;
|
||||
private int chimeraWingLastUse;
|
||||
private Location teleportCommence;
|
||||
|
||||
@@ -123,6 +134,69 @@ public class McMMOPlayer {
|
||||
toolMode.put(toolType, false);
|
||||
toolATS.put(toolType, 0);
|
||||
}
|
||||
|
||||
if (!profile.isLoaded()) {
|
||||
mcMMO.p.getLogger().warning("Unable to load the PlayerProfile for " + playerName + ". Will retry over the next several seconds.");
|
||||
new RetryProfileLoadingTask().runTaskTimerAsynchronously(mcMMO.p, 11L, 31L);
|
||||
}
|
||||
}
|
||||
|
||||
private class RetryProfileLoadingTask extends BukkitRunnable {
|
||||
private static final int MAX_TRIES = 5;
|
||||
private final String playerName = McMMOPlayer.this.player.getName();
|
||||
private int attempt = 0;
|
||||
|
||||
// WARNING: ASYNC TASK
|
||||
// DO NOT MODIFY THE McMMOPLAYER FROM THIS CODE
|
||||
@Override
|
||||
public void run() {
|
||||
// Quit if they logged out
|
||||
if (!player.isOnline()) {
|
||||
mcMMO.p.getLogger().info("Aborting profile loading recovery for " + playerName + " - player logged out");
|
||||
this.cancel();
|
||||
return;
|
||||
}
|
||||
|
||||
// Send the message that we're doing the recovery
|
||||
if (attempt == 0) {
|
||||
player.sendMessage(LocaleLoader.getString("Recovery.Notice"));
|
||||
}
|
||||
|
||||
// Increment attempt counter and try
|
||||
attempt++;
|
||||
PlayerProfile profile = mcMMO.getDatabaseManager().loadPlayerProfile(playerName, true);
|
||||
// If successful, schedule the apply
|
||||
if (profile.isLoaded()) {
|
||||
new ApplySuccessfulProfile(profile).runTask(mcMMO.p);
|
||||
player.sendMessage(LocaleLoader.getString("Recovery.Success"));
|
||||
this.cancel();
|
||||
return;
|
||||
}
|
||||
|
||||
// If we've failed five times, give up
|
||||
if (attempt >= MAX_TRIES) {
|
||||
mcMMO.p.getLogger().severe("Giving up on attempting to load the PlayerProfile for " + playerName);
|
||||
mcMMO.p.getServer().broadcast(LocaleLoader.getString("Recovery.AdminFailureNotice", playerName), Server.BROADCAST_CHANNEL_ADMINISTRATIVE);
|
||||
player.sendMessage(LocaleLoader.getString("Recovery.Failure").split("\n"));
|
||||
this.cancel();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class ApplySuccessfulProfile extends BukkitRunnable {
|
||||
private final PlayerProfile profile;
|
||||
|
||||
private ApplySuccessfulProfile(PlayerProfile profile) {
|
||||
this.profile = profile;
|
||||
}
|
||||
|
||||
// Synchronized task
|
||||
// No database access permitted
|
||||
@Override
|
||||
public void run() {
|
||||
McMMOPlayer.this.profile = profile;
|
||||
}
|
||||
}
|
||||
|
||||
public AcrobaticsManager getAcrobaticsManager() {
|
||||
@@ -354,28 +428,36 @@ public class McMMOPlayer {
|
||||
teleportATS = (int) (System.currentTimeMillis() / Misc.TIME_CONVERSION_FACTOR);
|
||||
}
|
||||
|
||||
public long getDatabaseATS() {
|
||||
return databaseATS;
|
||||
}
|
||||
|
||||
public void actualizeDatabaseATS() {
|
||||
databaseATS = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
/*
|
||||
* Repair Anvil Placement
|
||||
*/
|
||||
|
||||
public boolean getPlacedAnvil(int anvilId) {
|
||||
if (anvilId == Repair.repairAnvilId) {
|
||||
public boolean getPlacedAnvil(Material anvilType) {
|
||||
if (anvilType == Repair.repairAnvilMaterial) {
|
||||
return placedRepairAnvil;
|
||||
}
|
||||
|
||||
if (anvilId == Repair.salvageAnvilId) {
|
||||
if (anvilType == Repair.salvageAnvilMaterial) {
|
||||
return placedSalvageAnvil;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public void togglePlacedAnvil(int anvilId) {
|
||||
if (anvilId == Repair.repairAnvilId) {
|
||||
public void togglePlacedAnvil(Material anvilType) {
|
||||
if (anvilType == Repair.repairAnvilMaterial) {
|
||||
placedRepairAnvil = !placedRepairAnvil;
|
||||
}
|
||||
|
||||
if (anvilId == Repair.salvageAnvilId) {
|
||||
if (anvilType == Repair.salvageAnvilMaterial) {
|
||||
placedSalvageAnvil = !placedSalvageAnvil;
|
||||
}
|
||||
}
|
||||
@@ -384,34 +466,34 @@ public class McMMOPlayer {
|
||||
* Repair Anvil Usage
|
||||
*/
|
||||
|
||||
public int getLastAnvilUse(int anvilId) {
|
||||
if (anvilId == Repair.repairAnvilId) {
|
||||
public int getLastAnvilUse(Material anvilType) {
|
||||
if (anvilType == Repair.repairAnvilMaterial) {
|
||||
return lastRepairClick;
|
||||
}
|
||||
|
||||
if (anvilId == Repair.salvageAnvilId) {
|
||||
if (anvilType == Repair.salvageAnvilMaterial) {
|
||||
return lastSalvageClick;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public void setLastAnvilUse(int anvilId, int value) {
|
||||
if (anvilId == Repair.repairAnvilId) {
|
||||
public void setLastAnvilUse(Material anvilType, int value) {
|
||||
if (anvilType == Repair.repairAnvilMaterial) {
|
||||
lastRepairClick = value;
|
||||
}
|
||||
|
||||
if (anvilId == Repair.salvageAnvilId) {
|
||||
if (anvilType == Repair.salvageAnvilMaterial) {
|
||||
lastSalvageClick = value;
|
||||
}
|
||||
}
|
||||
|
||||
public void actualizeLastAnvilUse(int anvilId) {
|
||||
if (anvilId == Repair.repairAnvilId) {
|
||||
public void actualizeLastAnvilUse(Material anvilType) {
|
||||
if (anvilType == Repair.repairAnvilMaterial) {
|
||||
lastRepairClick = (int) (System.currentTimeMillis() / Misc.TIME_CONVERSION_FACTOR);
|
||||
}
|
||||
|
||||
if (anvilId == Repair.salvageAnvilId) {
|
||||
if (anvilType == Repair.salvageAnvilMaterial) {
|
||||
lastSalvageClick = (int) (System.currentTimeMillis() / Misc.TIME_CONVERSION_FACTOR);
|
||||
}
|
||||
}
|
||||
@@ -428,6 +510,18 @@ public class McMMOPlayer {
|
||||
godMode = !godMode;
|
||||
}
|
||||
|
||||
/*
|
||||
* Fishing: Master Angler
|
||||
*/
|
||||
|
||||
public Location getHookLocation() {
|
||||
return hookLocation;
|
||||
}
|
||||
|
||||
public void setHookLocation(Location hookLocation) {
|
||||
this.hookLocation = hookLocation;
|
||||
}
|
||||
|
||||
/*
|
||||
* Skill notifications
|
||||
*/
|
||||
@@ -448,7 +542,7 @@ public class McMMOPlayer {
|
||||
public int getPowerLevel() {
|
||||
int powerLevel = 0;
|
||||
|
||||
for (SkillType type : SkillType.nonChildSkills()) {
|
||||
for (SkillType type : SkillType.NON_CHILD_SKILLS) {
|
||||
if (Permissions.skillEnabled(player, type)) {
|
||||
powerLevel += profile.getSkillLevel(type);
|
||||
}
|
||||
@@ -521,23 +615,45 @@ public class McMMOPlayer {
|
||||
return;
|
||||
}
|
||||
|
||||
McMMOPlayerXpGainEvent event = new McMMOPlayerXpGainEvent(player, skillType, xp);
|
||||
mcMMO.p.getServer().getPluginManager().callEvent(event);
|
||||
|
||||
if (event.isCancelled()) {
|
||||
if (!EventUtils.handleXpGainEvent(player, skillType, xp)) {
|
||||
return;
|
||||
}
|
||||
|
||||
profile.setSkillXpLevel(skillType, profile.getSkillXpLevelRaw(skillType) + event.getRawXpGained());
|
||||
|
||||
McMMOHud spoutHud = profile.getSpoutHud();
|
||||
|
||||
if (spoutHud != null) {
|
||||
spoutHud.setLastGained(skillType);
|
||||
}
|
||||
|
||||
isUsingUnarmed = (skillType == SkillType.UNARMED);
|
||||
SkillUtils.xpCheckSkill(skillType, player, profile);
|
||||
checkXp(skillType);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check the XP of a skill.
|
||||
*
|
||||
* @param skillType The skill to check
|
||||
*/
|
||||
private void checkXp(SkillType skillType) {
|
||||
int levelsGained = 0;
|
||||
float xpRemoved = 0;
|
||||
|
||||
if (profile.getSkillXpLevelRaw(skillType) >= profile.getXpToLevel(skillType)) {
|
||||
while (profile.getSkillXpLevelRaw(skillType) >= profile.getXpToLevel(skillType)) {
|
||||
if ((skillType.getMaxLevel() >= profile.getSkillLevel(skillType) + 1) && (Config.getInstance().getPowerLevelCap() >= getPowerLevel() + 1)) {
|
||||
int xp = profile.getXpToLevel(skillType);
|
||||
xpRemoved += xp;
|
||||
|
||||
profile.removeXp(skillType, xp);
|
||||
levelsGained++;
|
||||
profile.skillUp(skillType, 1);
|
||||
}
|
||||
else {
|
||||
profile.addLevels(skillType, 0); // This seems kinda pointless... why do we have this again?
|
||||
}
|
||||
}
|
||||
|
||||
if (!EventUtils.handleLevelChangeEvent(player, skillType, levelsGained, xpRemoved, true)) {
|
||||
return;
|
||||
}
|
||||
|
||||
player.playSound(player.getLocation(), Sound.LEVEL_UP, Misc.LEVELUP_VOLUME, Misc.LEVELUP_PITCH);
|
||||
player.sendMessage(LocaleLoader.getString(StringUtils.getCapitalized(skillType.toString()) + ".Skillup", levelsGained, profile.getSkillLevel(skillType)));
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -722,4 +838,107 @@ public class McMMOPlayer {
|
||||
player.sendMessage(LocaleLoader.getString("Party.Forbidden"));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check to see if an ability can be activated.
|
||||
*
|
||||
* @param skill The skill the ability is based on
|
||||
*/
|
||||
public void checkAbilityActivation(SkillType skill) {
|
||||
ToolType tool = skill.getTool();
|
||||
AbilityType ability = skill.getAbility();
|
||||
|
||||
setToolPreparationMode(tool, false);
|
||||
|
||||
if (getAbilityMode(ability)) {
|
||||
return;
|
||||
}
|
||||
|
||||
int timeRemaining = SkillUtils.calculateTimeLeft(ability, profile, player);
|
||||
|
||||
if (timeRemaining > 0) {
|
||||
/*
|
||||
* Axes and Woodcutting are odd because they share the same tool.
|
||||
* We show them the too tired message when they take action.
|
||||
*/
|
||||
if (skill == SkillType.WOODCUTTING || skill == SkillType.AXES) {
|
||||
player.sendMessage(LocaleLoader.getString("Skills.TooTired", timeRemaining));
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (EventUtils.callPlayerAbilityActivateEvent(player, skill).isCancelled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
int ticks = PerksUtils.handleActivationPerks(player, 2 + (profile.getSkillLevel(skill) / AdvancedConfig.getInstance().getAbilityLength()), ability.getMaxLength());
|
||||
|
||||
// Notify people that ability has been activated
|
||||
ParticleEffectUtils.playAbilityEnabledEffect(player);
|
||||
|
||||
if (useChatNotifications()) {
|
||||
player.sendMessage(ability.getAbilityOn());
|
||||
}
|
||||
|
||||
SkillUtils.sendSkillMessage(player, ability.getAbilityPlayer(player));
|
||||
|
||||
// Enable the ability
|
||||
profile.setSkillDATS(ability, System.currentTimeMillis() + (ticks * Misc.TIME_CONVERSION_FACTOR));
|
||||
setAbilityMode(ability, true);
|
||||
|
||||
if (ability == AbilityType.SUPER_BREAKER || ability == AbilityType.GIGA_DRILL_BREAKER) {
|
||||
SkillUtils.handleAbilitySpeedIncrease(player);
|
||||
}
|
||||
|
||||
new AbilityDisableTask(this, ability).runTaskLater(mcMMO.p, ticks * Misc.TICK_CONVERSION_FACTOR);
|
||||
}
|
||||
|
||||
public void processAbilityActivation(SkillType skill) {
|
||||
if (Config.getInstance().getAbilitiesOnlyActivateWhenSneaking() && !player.isSneaking()) {
|
||||
return;
|
||||
}
|
||||
|
||||
ItemStack inHand = player.getItemInHand();
|
||||
|
||||
if (ModUtils.isCustomTool(inHand) && !ModUtils.getToolFromItemStack(inHand).isAbilityEnabled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!getAbilityUse()) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (AbilityType abilityType : AbilityType.values()) {
|
||||
if (getAbilityMode(abilityType)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
AbilityType ability = skill.getAbility();
|
||||
ToolType tool = skill.getTool();
|
||||
|
||||
/*
|
||||
* Woodcutting & Axes need to be treated differently.
|
||||
* Basically the tool always needs to ready and we check to see if the cooldown is over when the user takes action
|
||||
*/
|
||||
if (ability.getPermissions(player) && tool.inHand(inHand) && !getToolPreparationMode(tool)) {
|
||||
if (skill != SkillType.WOODCUTTING && skill != SkillType.AXES) {
|
||||
int timeRemaining = SkillUtils.calculateTimeLeft(ability, profile, player);
|
||||
|
||||
if (!getAbilityMode(ability) && timeRemaining > 0) {
|
||||
player.sendMessage(LocaleLoader.getString("Skills.TooTired", timeRemaining));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (Config.getInstance().getAbilityMessagesEnabled()) {
|
||||
player.sendMessage(tool.getRaiseTool());
|
||||
}
|
||||
|
||||
setToolPreparationATS(tool, System.currentTimeMillis());
|
||||
setToolPreparationMode(tool, true);
|
||||
new ToolLowerTask(this, tool).runTaskLaterAsynchronously(mcMMO.p, 4 * Misc.TICK_CONVERSION_FACTOR);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,13 +9,10 @@ import org.bukkit.scoreboard.Scoreboard;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.config.experience.ExperienceConfig;
|
||||
import com.gmail.nossr50.config.spout.SpoutConfig;
|
||||
import com.gmail.nossr50.datatypes.MobHealthbarType;
|
||||
import com.gmail.nossr50.datatypes.experience.FormulaType;
|
||||
import com.gmail.nossr50.datatypes.skills.AbilityType;
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.datatypes.spout.huds.HudType;
|
||||
import com.gmail.nossr50.datatypes.spout.huds.McMMOHud;
|
||||
import com.gmail.nossr50.skills.child.FamilyTree;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
|
||||
@@ -25,9 +22,7 @@ public class PlayerProfile {
|
||||
private boolean changed;
|
||||
|
||||
/* HUDs */
|
||||
private HudType hudType;
|
||||
private MobHealthbarType mobHealthbarType;
|
||||
private McMMOHud spoutHud;
|
||||
private Scoreboard playerStatsScoreboard;
|
||||
|
||||
/* Skill Data */
|
||||
@@ -38,14 +33,13 @@ public class PlayerProfile {
|
||||
public PlayerProfile(String playerName) {
|
||||
this.playerName = playerName;
|
||||
|
||||
hudType = mcMMO.isSpoutEnabled() ? SpoutConfig.getInstance().getDefaultHudType() : HudType.DISABLED;
|
||||
mobHealthbarType = Config.getInstance().getMobHealthbarDefault();
|
||||
|
||||
for (AbilityType abilityType : AbilityType.values()) {
|
||||
skillsDATS.put(abilityType, 0);
|
||||
}
|
||||
|
||||
for (SkillType skillType : SkillType.nonChildSkills()) {
|
||||
for (SkillType skillType : SkillType.NON_CHILD_SKILLS) {
|
||||
skills.put(skillType, 0);
|
||||
skillsXp.put(skillType, 0F);
|
||||
}
|
||||
@@ -59,10 +53,9 @@ public class PlayerProfile {
|
||||
/**
|
||||
* Calling this constructor is considered loading the profile.
|
||||
*/
|
||||
public PlayerProfile(String playerName, Map<SkillType, Integer> argSkills, Map<SkillType, Float> argSkillsXp, Map<AbilityType, Integer> argSkillsDats, HudType hudType, MobHealthbarType mobHealthbarType) {
|
||||
this(playerName, true);
|
||||
public PlayerProfile(String playerName, Map<SkillType, Integer> argSkills, Map<SkillType, Float> argSkillsXp, Map<AbilityType, Integer> argSkillsDats, MobHealthbarType mobHealthbarType) {
|
||||
this(playerName);
|
||||
|
||||
this.hudType = hudType;
|
||||
this.mobHealthbarType = mobHealthbarType;
|
||||
|
||||
this.skills.putAll(argSkills);
|
||||
@@ -73,12 +66,14 @@ public class PlayerProfile {
|
||||
}
|
||||
|
||||
public void save() {
|
||||
if (!changed) {
|
||||
if (!changed || !loaded) {
|
||||
return;
|
||||
}
|
||||
|
||||
mcMMO.getDatabaseManager().saveUser(this);
|
||||
changed = false;
|
||||
changed = !mcMMO.getDatabaseManager().saveUser(this);
|
||||
if (changed) {
|
||||
mcMMO.p.getLogger().warning("PlayerProfile for " + playerName + " failed to save");
|
||||
}
|
||||
}
|
||||
|
||||
public String getPlayerName() {
|
||||
@@ -89,26 +84,6 @@ public class PlayerProfile {
|
||||
return loaded;
|
||||
}
|
||||
|
||||
/*
|
||||
* HUD Stuff
|
||||
*/
|
||||
|
||||
public HudType getHudType() {
|
||||
return hudType;
|
||||
}
|
||||
|
||||
public McMMOHud getSpoutHud() {
|
||||
return spoutHud;
|
||||
}
|
||||
|
||||
public void setSpoutHud(McMMOHud spoutHud) {
|
||||
this.spoutHud = spoutHud;
|
||||
}
|
||||
|
||||
public void setHudType(HudType hudType) {
|
||||
this.hudType = hudType;
|
||||
}
|
||||
|
||||
/*
|
||||
* Mob Healthbars
|
||||
*/
|
||||
@@ -177,11 +152,7 @@ public class PlayerProfile {
|
||||
*/
|
||||
|
||||
public int getSkillLevel(SkillType skillType) {
|
||||
if (skillType.isChildSkill()) {
|
||||
return getChildSkillLevel(skillType);
|
||||
}
|
||||
|
||||
return skills.get(skillType);
|
||||
return skillType.isChildSkill() ? getChildSkillLevel(skillType) : skills.get(skillType);
|
||||
}
|
||||
|
||||
public float getSkillXpLevelRaw(SkillType skillType) {
|
||||
|
||||
@@ -1,17 +1,23 @@
|
||||
package com.gmail.nossr50.datatypes.skills;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.BlockUtils;
|
||||
import com.gmail.nossr50.util.EventUtils;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.StringUtils;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
public enum AbilityType {
|
||||
BERSERK(
|
||||
"Unarmed.Skills.Berserk.Name",
|
||||
"Unarmed.Skills.Berserk.On",
|
||||
"Unarmed.Skills.Berserk.Off",
|
||||
"Unarmed.Skills.Berserk.Other.On",
|
||||
@@ -19,6 +25,7 @@ public enum AbilityType {
|
||||
"Unarmed.Skills.Berserk.Other.Off"),
|
||||
|
||||
SUPER_BREAKER(
|
||||
"Mining.Skills.SuperBreaker.Name",
|
||||
"Mining.Skills.SuperBreaker.On",
|
||||
"Mining.Skills.SuperBreaker.Off",
|
||||
"Mining.Skills.SuperBreaker.Other.On",
|
||||
@@ -26,6 +33,7 @@ public enum AbilityType {
|
||||
"Mining.Skills.SuperBreaker.Other.Off"),
|
||||
|
||||
GIGA_DRILL_BREAKER(
|
||||
"Excavation.Skills.GigaDrillBreaker.Name",
|
||||
"Excavation.Skills.GigaDrillBreaker.On",
|
||||
"Excavation.Skills.GigaDrillBreaker.Off",
|
||||
"Excavation.Skills.GigaDrillBreaker.Other.On",
|
||||
@@ -33,6 +41,7 @@ public enum AbilityType {
|
||||
"Excavation.Skills.GigaDrillBreaker.Other.Off"),
|
||||
|
||||
GREEN_TERRA(
|
||||
"Herbalism.Skills.GTe.Name",
|
||||
"Herbalism.Skills.GTe.On",
|
||||
"Herbalism.Skills.GTe.Off",
|
||||
"Herbalism.Skills.GTe.Other.On",
|
||||
@@ -40,6 +49,7 @@ public enum AbilityType {
|
||||
"Herbalism.Skills.GTe.Other.Off"),
|
||||
|
||||
SKULL_SPLITTER(
|
||||
"Axes.Skills.SS.Name",
|
||||
"Axes.Skills.SS.On",
|
||||
"Axes.Skills.SS.Off",
|
||||
"Axes.Skills.SS.Other.On",
|
||||
@@ -47,6 +57,7 @@ public enum AbilityType {
|
||||
"Axes.Skills.SS.Other.Off"),
|
||||
|
||||
TREE_FELLER(
|
||||
"Woodcutting.Skills.TreeFeller.Name",
|
||||
"Woodcutting.Skills.TreeFeller.On",
|
||||
"Woodcutting.Skills.TreeFeller.Off",
|
||||
"Woodcutting.Skills.TreeFeller.Other.On",
|
||||
@@ -54,40 +65,81 @@ public enum AbilityType {
|
||||
"Woodcutting.Skills.TreeFeller.Other.Off"),
|
||||
|
||||
SERRATED_STRIKES(
|
||||
"Swords.Skills.SS.Name",
|
||||
"Swords.Skills.SS.On",
|
||||
"Swords.Skills.SS.Off",
|
||||
"Swords.Skills.SS.Other.On",
|
||||
"Swords.Skills.SS.Refresh",
|
||||
"Swords.Skills.SS.Other.Off"),
|
||||
|
||||
/**
|
||||
* Has cooldown - but has to share a skill with Super Breaker, so needs special treatment
|
||||
*/
|
||||
BLAST_MINING(
|
||||
"Mining.Blast.Name",
|
||||
null,
|
||||
null,
|
||||
"Mining.Blast.Other.On",
|
||||
"Mining.Blast.Refresh",
|
||||
null),
|
||||
|
||||
/**
|
||||
* No cooldown - always active
|
||||
*/
|
||||
LEAF_BLOWER(
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null),
|
||||
|
||||
/**
|
||||
* Not a first-class Ability - part of Berserk
|
||||
*/
|
||||
BLOCK_CRACKER(
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null);
|
||||
|
||||
private String abilityName;
|
||||
private String abilityOn;
|
||||
private String abilityOff;
|
||||
private String abilityPlayer;
|
||||
private String abilityRefresh;
|
||||
private String abilityPlayerOff;
|
||||
|
||||
private AbilityType(String abilityOn, String abilityOff, String abilityPlayer, String abilityRefresh, String abilityPlayerOff) {
|
||||
/**
|
||||
* Those abilities that have a cooldown saved to the database.
|
||||
*/
|
||||
public static final List<AbilityType> NORMAL_ABILITIES;
|
||||
/**
|
||||
* Those abilities that do not have a cooldown saved to the database.
|
||||
*/
|
||||
public static final List<AbilityType> NON_NORMAL_ABILITIES;
|
||||
|
||||
static {
|
||||
NORMAL_ABILITIES = ImmutableList.of(
|
||||
BERSERK,
|
||||
SUPER_BREAKER,
|
||||
GIGA_DRILL_BREAKER,
|
||||
GREEN_TERRA,
|
||||
SKULL_SPLITTER,
|
||||
TREE_FELLER,
|
||||
SERRATED_STRIKES,
|
||||
BLAST_MINING
|
||||
);
|
||||
NON_NORMAL_ABILITIES = ImmutableList.of(
|
||||
LEAF_BLOWER,
|
||||
BLOCK_CRACKER
|
||||
);
|
||||
}
|
||||
|
||||
private AbilityType(String abilityName, String abilityOn, String abilityOff, String abilityPlayer, String abilityRefresh, String abilityPlayerOff) {
|
||||
this.abilityName = abilityName;
|
||||
this.abilityOn = abilityOn;
|
||||
this.abilityOff = abilityOff;
|
||||
this.abilityPlayer = abilityPlayer;
|
||||
@@ -99,8 +151,19 @@ public enum AbilityType {
|
||||
return Config.getInstance().getCooldown(this);
|
||||
}
|
||||
|
||||
public int getMaxTicks() {
|
||||
return Config.getInstance().getMaxTicks(this);
|
||||
public int getMaxLength() {
|
||||
return Config.getInstance().getMaxLength(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* May return null
|
||||
* @return ability name, or null if unavailable
|
||||
*/
|
||||
public String getAbilityName() {
|
||||
if (this.abilityName == null) {
|
||||
return null;
|
||||
}
|
||||
return LocaleLoader.getString(this.abilityName);
|
||||
}
|
||||
|
||||
public String getAbilityOn() {
|
||||
@@ -123,6 +186,11 @@ public enum AbilityType {
|
||||
return LocaleLoader.getString(this.abilityRefresh);
|
||||
}
|
||||
|
||||
public String getConfigString() {
|
||||
// If toString() changes, place old code here to not break config.yml
|
||||
return this.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
String baseString = name();
|
||||
@@ -220,4 +288,23 @@ public enum AbilityType {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check to see if ability should be triggered.
|
||||
*
|
||||
* @param player The player using the ability
|
||||
* @param block The block modified by the ability
|
||||
* @return true if the ability should activate, false otherwise
|
||||
*/
|
||||
public boolean triggerCheck(Player player, Block block) {
|
||||
switch (this) {
|
||||
case BERSERK:
|
||||
case BLOCK_CRACKER:
|
||||
case LEAF_BLOWER:
|
||||
return blockCheck(block.getState()) && EventUtils.simulateBlockBreak(block, player, true);
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,7 +25,6 @@ import com.gmail.nossr50.skills.taming.TamingManager;
|
||||
import com.gmail.nossr50.skills.unarmed.UnarmedManager;
|
||||
import com.gmail.nossr50.skills.woodcutting.WoodcuttingManager;
|
||||
import com.gmail.nossr50.util.StringUtils;
|
||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
@@ -51,15 +50,34 @@ public enum SkillType {
|
||||
|
||||
public static final List<String> SKILL_NAMES;
|
||||
|
||||
public static final List<SkillType> CHILD_SKILLS;
|
||||
public static final List<SkillType> NON_CHILD_SKILLS;
|
||||
|
||||
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> MISC_SKILLS = ImmutableList.of(ACROBATICS, REPAIR, SMELTING);
|
||||
|
||||
static {
|
||||
List<SkillType> childSkills = new ArrayList<SkillType>();
|
||||
List<SkillType> nonChildSkills = new ArrayList<SkillType>();
|
||||
ArrayList<String> names = new ArrayList<String>();
|
||||
|
||||
for (SkillType skill : values()) {
|
||||
names.add(SkillUtils.getSkillName(skill));
|
||||
if (skill.isChildSkill()) {
|
||||
childSkills.add(skill);
|
||||
}
|
||||
else {
|
||||
nonChildSkills.add(skill);
|
||||
}
|
||||
|
||||
names.add(skill.getSkillName());
|
||||
}
|
||||
|
||||
Collections.sort(names);
|
||||
SKILL_NAMES = ImmutableList.copyOf(names);
|
||||
|
||||
CHILD_SKILLS = ImmutableList.copyOf(childSkills);
|
||||
NON_CHILD_SKILLS = ImmutableList.copyOf(nonChildSkills);
|
||||
}
|
||||
|
||||
private SkillType(Class<? extends SkillManager> managerClass, Color runescapeColor) {
|
||||
@@ -109,10 +127,18 @@ public enum SkillType {
|
||||
return Config.getInstance().getHardcoreStatLossEnabled(this);
|
||||
}
|
||||
|
||||
public void setHardcoreStatLossEnabled(boolean enable) {
|
||||
Config.getInstance().setHardcoreStatLossEnabled(this, enable);
|
||||
}
|
||||
|
||||
public boolean getHardcoreVampirismEnabled() {
|
||||
return Config.getInstance().getHardcoreVampirismEnabled(this);
|
||||
}
|
||||
|
||||
public void setHardcoreVampirismEnabled(boolean enable) {
|
||||
Config.getInstance().setHardcoreVampirismEnabled(this, enable);
|
||||
}
|
||||
|
||||
public ToolType getTool() {
|
||||
return tool;
|
||||
}
|
||||
@@ -143,33 +169,14 @@ 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
|
||||
public boolean isChildSkill() {
|
||||
switch (this) {
|
||||
case SMELTING:
|
||||
return true;
|
||||
case SMELTING:
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static SkillType[] nonChildSkills() {
|
||||
return new SkillType[] {SkillType.ACROBATICS,
|
||||
SkillType.ARCHERY,
|
||||
SkillType.AXES,
|
||||
SkillType.EXCAVATION,
|
||||
SkillType.FISHING,
|
||||
SkillType.HERBALISM,
|
||||
SkillType.MINING,
|
||||
SkillType.REPAIR,
|
||||
SkillType.SWORDS,
|
||||
SkillType.TAMING,
|
||||
SkillType.UNARMED,
|
||||
SkillType.WOODCUTTING };
|
||||
}
|
||||
|
||||
public static SkillType[] childSkills() {
|
||||
return new SkillType[] { SkillType.SMELTING };
|
||||
}
|
||||
|
||||
public Color getRunescapeModeColor() {
|
||||
return runescapeColor;
|
||||
}
|
||||
@@ -183,4 +190,8 @@ public enum SkillType {
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public String getSkillName() {
|
||||
return Config.getInstance().getLocale().equalsIgnoreCase("en_US") ? StringUtils.getCapitalized(this.toString()) : StringUtils.getCapitalized(LocaleLoader.getString(StringUtils.getCapitalized(this.toString()) + ".SkillName"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,24 +0,0 @@
|
||||
package com.gmail.nossr50.datatypes.spout.buttons;
|
||||
|
||||
import org.getspout.spoutapi.gui.GenericButton;
|
||||
|
||||
public class McMMOButton extends GenericButton {
|
||||
private Slot slot;
|
||||
|
||||
public McMMOButton(String text, String toolTip) {
|
||||
this.setText(text);
|
||||
this.setTooltip(toolTip);
|
||||
}
|
||||
|
||||
public void connect(Slot slot) {
|
||||
this.slot = slot;
|
||||
}
|
||||
|
||||
public void activate() {
|
||||
slot.activate();
|
||||
}
|
||||
|
||||
public interface Slot {
|
||||
public void activate();
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
package com.gmail.nossr50.datatypes.spout.huds;
|
||||
|
||||
public enum HudType {
|
||||
DISABLED,
|
||||
STANDARD,
|
||||
SMALL,
|
||||
RETRO;
|
||||
|
||||
public HudType getNext() {
|
||||
return values()[(ordinal() + 1) % values().length];
|
||||
}
|
||||
}
|
||||
@@ -1,106 +0,0 @@
|
||||
package com.gmail.nossr50.datatypes.spout.huds;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.spout.SpoutConfig;
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.datatypes.spout.popups.McMMOMenu;
|
||||
import com.gmail.nossr50.datatypes.spout.popups.McMMOXpBar;
|
||||
|
||||
import org.getspout.spoutapi.SpoutManager;
|
||||
|
||||
public class McMMOHud {
|
||||
private Player player;
|
||||
private PlayerProfile profile;
|
||||
|
||||
private SkillType lastGained;
|
||||
private SkillType skillLock;
|
||||
private boolean xpBarLocked;
|
||||
|
||||
private McMMOMenu menu;
|
||||
private McMMOXpBar xpBar;
|
||||
|
||||
public McMMOHud(McMMOPlayer mcMMOPlayer) {
|
||||
this.player = mcMMOPlayer.getPlayer();
|
||||
this.profile = mcMMOPlayer.getProfile();
|
||||
|
||||
initializeXpBar();
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize the HUD.
|
||||
*/
|
||||
public void initializeXpBar() {
|
||||
if (SpoutConfig.getInstance().getXPBarEnabled()) {
|
||||
if (xpBar != null) {
|
||||
xpBar.removeWidgets();
|
||||
}
|
||||
|
||||
xpBar = new McMMOXpBar(SpoutManager.getPlayer(player), profile.getHudType());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the XP bar.
|
||||
*/
|
||||
public void updateXpBar() {
|
||||
SkillType skillType = xpBarLocked ? skillLock : lastGained;
|
||||
|
||||
if (skillType == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
xpBar.update(skillType, profile);
|
||||
}
|
||||
|
||||
public boolean isMenuOpened() {
|
||||
return (menu != null);
|
||||
}
|
||||
|
||||
public void openMenu() {
|
||||
menu = new McMMOMenu(SpoutManager.getPlayer(player), profile);
|
||||
}
|
||||
|
||||
public void onMenuClose() {
|
||||
menu = null;
|
||||
}
|
||||
|
||||
public void removeWidgets() {
|
||||
if (menu != null) {
|
||||
menu.close();
|
||||
}
|
||||
|
||||
SpoutManager.getPlayer(player).getMainScreen().removeWidgets(mcMMO.p);
|
||||
}
|
||||
|
||||
public SkillType getLastGained() {
|
||||
return lastGained;
|
||||
}
|
||||
|
||||
public void setLastGained(SkillType type) {
|
||||
this.lastGained = type;
|
||||
}
|
||||
|
||||
public boolean getXpBarLocked() {
|
||||
return xpBarLocked;
|
||||
}
|
||||
|
||||
public void setXpBarLocked(boolean locked) {
|
||||
this.xpBarLocked = locked;
|
||||
}
|
||||
|
||||
public void toggleXpBarLocked() {
|
||||
xpBarLocked = !xpBarLocked;
|
||||
}
|
||||
|
||||
public SkillType getSkillLock() {
|
||||
return skillLock;
|
||||
}
|
||||
|
||||
public void setSkillLock(SkillType type) {
|
||||
this.skillLock = type;
|
||||
}
|
||||
}
|
||||
@@ -1,82 +0,0 @@
|
||||
package com.gmail.nossr50.datatypes.spout.popups;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.spout.buttons.McMMOButton;
|
||||
import com.gmail.nossr50.datatypes.spout.buttons.McMMOButton.Slot;
|
||||
import com.gmail.nossr50.datatypes.spout.huds.HudType;
|
||||
import com.gmail.nossr50.datatypes.spout.huds.McMMOHud;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
|
||||
import org.getspout.spoutapi.gui.GenericLabel;
|
||||
import org.getspout.spoutapi.gui.GenericPopup;
|
||||
import org.getspout.spoutapi.gui.InGameHUD;
|
||||
import org.getspout.spoutapi.player.SpoutPlayer;
|
||||
|
||||
public class McMMOMenu extends GenericPopup {
|
||||
private McMMOButton hudButton;
|
||||
private McMMOButton escapeButton;
|
||||
|
||||
private GenericLabel titleLabel = new GenericLabel();
|
||||
private GenericLabel escapeLabel = new GenericLabel();
|
||||
|
||||
private static int centerX = 427 / 2;
|
||||
private static int centerY = 240 / 2;
|
||||
|
||||
public McMMOMenu(final SpoutPlayer spoutPlayer, final PlayerProfile playerProfile) {
|
||||
// 240, 427 are the bottom right
|
||||
titleLabel.setText(LocaleLoader.getString("Spout.Menu.Title"));
|
||||
titleLabel.setWidth(100);
|
||||
titleLabel.setHeight(100);
|
||||
titleLabel.setX(centerX - 35);
|
||||
titleLabel.setY((centerY / 2) - 20);
|
||||
|
||||
escapeLabel.setText(LocaleLoader.getString("Spout.Menu.Exit"));
|
||||
escapeLabel.setWidth(100);
|
||||
escapeLabel.setHeight(100);
|
||||
escapeLabel.setX(titleLabel.getX() - 15);
|
||||
escapeLabel.setY(titleLabel.getY() + 10);
|
||||
|
||||
hudButton = new McMMOButton(LocaleLoader.getString("Spout.Menu.HudButton.1", playerProfile.getHudType().toString()), LocaleLoader.getString("Spout.Menu.HudButton.2"));
|
||||
hudButton.setWidth(120);
|
||||
hudButton.setHeight(20);
|
||||
hudButton.setX(centerX - (hudButton.getWidth() / 2));
|
||||
hudButton.setY(centerY / 2);
|
||||
hudButton.connect(new Slot() {
|
||||
@Override
|
||||
public void activate() {
|
||||
HudType nextHudType = playerProfile.getHudType().getNext();
|
||||
McMMOHud spoutHud = playerProfile.getSpoutHud();
|
||||
|
||||
playerProfile.setHudType(nextHudType);
|
||||
spoutHud.initializeXpBar();
|
||||
spoutHud.updateXpBar();
|
||||
|
||||
hudButton.setText("HUD Type: " + nextHudType.toString());
|
||||
hudButton.setDirty(true);
|
||||
}
|
||||
});
|
||||
|
||||
escapeButton = new McMMOButton(LocaleLoader.getString("Spout.Menu.ExitButton"), null);
|
||||
escapeButton.setWidth(60);
|
||||
escapeButton.setHeight(20);
|
||||
escapeButton.setX(centerX - (escapeButton.getWidth() / 2));
|
||||
escapeButton.setY((centerY / 2) + (escapeButton.getHeight() * 2) + 5);
|
||||
escapeButton.connect(new Slot() {
|
||||
@Override
|
||||
public void activate() {
|
||||
spoutPlayer.getMainScreen().closePopup();
|
||||
}
|
||||
});
|
||||
|
||||
attachWidget(mcMMO.p, hudButton);
|
||||
attachWidget(mcMMO.p, titleLabel);
|
||||
attachWidget(mcMMO.p, escapeLabel);
|
||||
attachWidget(mcMMO.p, escapeButton);
|
||||
|
||||
InGameHUD inGameHud = spoutPlayer.getMainScreen();
|
||||
|
||||
inGameHud.attachPopupScreen(this);
|
||||
inGameHud.setDirty(true);
|
||||
}
|
||||
}
|
||||
@@ -1,305 +0,0 @@
|
||||
package com.gmail.nossr50.datatypes.spout.popups;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.spout.SpoutConfig;
|
||||
import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.datatypes.spout.huds.HudType;
|
||||
import com.gmail.nossr50.util.StringUtils;
|
||||
|
||||
import org.getspout.spoutapi.gui.Color;
|
||||
import org.getspout.spoutapi.gui.GenericGradient;
|
||||
import org.getspout.spoutapi.gui.GenericTexture;
|
||||
import org.getspout.spoutapi.gui.InGameHUD;
|
||||
import org.getspout.spoutapi.gui.RenderPriority;
|
||||
import org.getspout.spoutapi.gui.Widget;
|
||||
import org.getspout.spoutapi.player.SpoutPlayer;
|
||||
|
||||
public class McMMOXpBar {
|
||||
private SpoutPlayer spoutPlayer;
|
||||
private Widget xpBar;
|
||||
|
||||
private GenericGradient xpFill;
|
||||
private GenericGradient xpBackground;
|
||||
private GenericGradient xpIconBackground;
|
||||
private GenericGradient xpIconBorder;
|
||||
private GenericTexture xpIcon;
|
||||
|
||||
public McMMOXpBar(SpoutPlayer spoutPlayer, HudType hudType) {
|
||||
this.spoutPlayer = spoutPlayer;
|
||||
|
||||
switch (hudType) {
|
||||
case RETRO:
|
||||
initializeXpBarRetro();
|
||||
break;
|
||||
|
||||
case STANDARD:
|
||||
initializeXpBarStandard();
|
||||
break;
|
||||
|
||||
case SMALL:
|
||||
initializeXpBarSmall();
|
||||
break;
|
||||
|
||||
case DISABLED:
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
spoutPlayer.getMainScreen().setDirty(true);
|
||||
}
|
||||
|
||||
public void removeWidgets() {
|
||||
InGameHUD inGameHud = spoutPlayer.getMainScreen();
|
||||
|
||||
if (xpBar != null) {
|
||||
inGameHud.removeWidget(xpBar);
|
||||
}
|
||||
|
||||
if (xpFill != null) {
|
||||
inGameHud.removeWidget(xpFill);
|
||||
}
|
||||
|
||||
if (xpBackground != null) {
|
||||
inGameHud.removeWidget(xpBackground);
|
||||
}
|
||||
|
||||
if (xpIconBackground != null) {
|
||||
inGameHud.removeWidget(xpIconBackground);
|
||||
}
|
||||
|
||||
if (xpIconBorder != null) {
|
||||
inGameHud.removeWidget(xpIconBorder);
|
||||
}
|
||||
|
||||
if (xpIcon != null) {
|
||||
inGameHud.removeWidget(xpIcon);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize Retro XP bar.
|
||||
*/
|
||||
private void initializeXpBarRetro() {
|
||||
Color border = new Color((float) SpoutConfig.getInstance().getRetroHUDXPBorderRed(), (float) SpoutConfig.getInstance().getRetroHUDXPBorderGreen(), (float) SpoutConfig.getInstance().getRetroHUDXPBorderBlue(), 1f);
|
||||
Color green = new Color(0f, 1f, 0f, 1f);
|
||||
Color background = new Color((float) SpoutConfig.getInstance().getRetroHUDXPBackgroundRed(), (float) SpoutConfig.getInstance().getRetroHUDXPBackgroundGreen(), (float) SpoutConfig.getInstance().getRetroHUDXPBackgroundBlue(), 1f);
|
||||
|
||||
xpBar = new GenericGradient();
|
||||
xpFill = new GenericGradient();
|
||||
xpBackground = new GenericGradient();
|
||||
|
||||
xpBar.setWidth(128);
|
||||
xpBar.setHeight(4);
|
||||
xpBar.setX(149);
|
||||
xpBar.setY(10);
|
||||
((GenericGradient) xpBar).setBottomColor(border);
|
||||
((GenericGradient) xpBar).setTopColor(border);
|
||||
xpBar.setPriority(RenderPriority.Highest);
|
||||
spoutPlayer.getMainScreen().attachWidget(mcMMO.p, xpBar);
|
||||
|
||||
xpFill.setWidth(0);
|
||||
xpFill.setHeight(2);
|
||||
xpFill.setX(150);
|
||||
xpFill.setY(11);
|
||||
xpFill.setBottomColor(green);
|
||||
xpFill.setTopColor(green);
|
||||
xpFill.setPriority(RenderPriority.Lowest);
|
||||
spoutPlayer.getMainScreen().attachWidget(mcMMO.p, xpFill);
|
||||
|
||||
xpBackground.setWidth(126);
|
||||
xpBackground.setHeight(2);
|
||||
xpBackground.setX(150);
|
||||
xpBackground.setY(11);
|
||||
xpBackground.setBottomColor(background);
|
||||
xpBackground.setTopColor(background);
|
||||
xpBackground.setPriority(RenderPriority.Low);
|
||||
spoutPlayer.getMainScreen().attachWidget(mcMMO.p, xpBackground);
|
||||
|
||||
if (SpoutConfig.getInstance().getXPBarIconEnabled()) {
|
||||
Color darkbg = new Color(0.2f, 0.2f, 0.2f, 1f);
|
||||
|
||||
xpIconBackground = new GenericGradient();
|
||||
xpIconBorder = new GenericGradient();
|
||||
xpIcon = new GenericTexture();
|
||||
|
||||
xpIconBackground.setBottomColor(darkbg);
|
||||
xpIconBackground.setTopColor(darkbg);
|
||||
xpIconBackground.setWidth(4);
|
||||
xpIconBackground.setHeight(4);
|
||||
xpIconBackground.setPriority(RenderPriority.High);
|
||||
xpIconBackground.setX(142);
|
||||
xpIconBackground.setY(10);
|
||||
spoutPlayer.getMainScreen().attachWidget(mcMMO.p, xpIconBackground);
|
||||
|
||||
xpIconBorder.setBottomColor(border);
|
||||
xpIconBorder.setTopColor(border);
|
||||
xpIconBorder.setWidth(6);
|
||||
xpIconBorder.setHeight(6);
|
||||
xpIconBorder.setPriority(RenderPriority.Highest);
|
||||
xpIconBorder.setX(141);
|
||||
xpIconBorder.setY(9);
|
||||
spoutPlayer.getMainScreen().attachWidget(mcMMO.p, xpIconBorder);
|
||||
|
||||
xpIcon.setWidth(6);
|
||||
xpIcon.setHeight(6);
|
||||
xpIcon.setX(141);
|
||||
xpIcon.setY(9);
|
||||
xpIcon.setPriority(RenderPriority.Normal);
|
||||
xpIcon.setUrl("Icon_r.png");
|
||||
spoutPlayer.getMainScreen().attachWidget(mcMMO.p, xpIcon);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize Standard XP bar.
|
||||
*/
|
||||
private void initializeXpBarStandard() {
|
||||
xpBar = new GenericTexture();
|
||||
|
||||
((GenericTexture) xpBar).setUrl("xpbar_inc000.png");
|
||||
xpBar.setX(SpoutConfig.getInstance().getXPBarXPosition());
|
||||
xpBar.setY(SpoutConfig.getInstance().getXPBarYPosition());
|
||||
xpBar.setHeight(8);
|
||||
xpBar.setWidth(256);
|
||||
xpBar.setPriority(RenderPriority.Lowest);
|
||||
spoutPlayer.getMainScreen().attachWidget(mcMMO.p, xpBar);
|
||||
|
||||
if (SpoutConfig.getInstance().getXPBarIconEnabled()) {
|
||||
xpIcon = new GenericTexture();
|
||||
|
||||
xpIcon.setUrl("Icon.png");
|
||||
xpIcon.setHeight(16);
|
||||
xpIcon.setWidth(32);
|
||||
xpIcon.setX(SpoutConfig.getInstance().getXPIconXPosition());
|
||||
xpIcon.setY(SpoutConfig.getInstance().getXPIconYPosition());
|
||||
xpIcon.setPriority(RenderPriority.High);
|
||||
spoutPlayer.getMainScreen().attachWidget(mcMMO.p, xpIcon);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize Small XP bar.
|
||||
*/
|
||||
private void initializeXpBarSmall() {
|
||||
xpBar = new GenericTexture();
|
||||
|
||||
((GenericTexture) xpBar).setUrl("xpbar_inc000.png");
|
||||
xpBar.setX(427 / 2 - 64);
|
||||
xpBar.setY(SpoutConfig.getInstance().getXPBarYPosition());
|
||||
xpBar.setHeight(4);
|
||||
xpBar.setWidth(128);
|
||||
xpBar.setPriority(RenderPriority.Lowest);
|
||||
spoutPlayer.getMainScreen().attachWidget(mcMMO.p, xpBar);
|
||||
|
||||
if (SpoutConfig.getInstance().getXPBarIconEnabled()) {
|
||||
xpIcon = new GenericTexture();
|
||||
|
||||
xpIcon.setUrl("Icon.png");
|
||||
xpIcon.setHeight(8);
|
||||
xpIcon.setWidth(16);
|
||||
xpIcon.setX(427 / 2 - (8 + 64));
|
||||
xpIcon.setY(SpoutConfig.getInstance().getXPIconYPosition() + 2);
|
||||
xpIcon.setPriority(RenderPriority.High);
|
||||
spoutPlayer.getMainScreen().attachWidget(mcMMO.p, xpIcon);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the XP bar.
|
||||
*
|
||||
* @param skillType The skill last used
|
||||
* @param playerProfile The profile of the player whose XP bar should be updated
|
||||
*/
|
||||
public void update(SkillType skillType, PlayerProfile playerProfile) {
|
||||
switch (playerProfile.getHudType()) {
|
||||
case RETRO:
|
||||
updateXpBarRetro(skillType, playerProfile);
|
||||
break;
|
||||
|
||||
case STANDARD:
|
||||
case SMALL:
|
||||
updateXpBarStandard(skillType, playerProfile);
|
||||
break;
|
||||
|
||||
case DISABLED:
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update XP bar for Standard & Small styles.
|
||||
*
|
||||
* @param skillType The skill last used
|
||||
* @param playerProfile The profile of the player whose XP bar should be updated
|
||||
*/
|
||||
private void updateXpBarStandard(SkillType skillType, PlayerProfile playerProfile) {
|
||||
xpIcon.setUrl(StringUtils.getCapitalized(skillType.toString()) + ".png");
|
||||
|
||||
((GenericTexture) xpBar).setUrl(getUrlBar(getXpInc(playerProfile.getSkillXpLevel(skillType), playerProfile.getXpToLevel(skillType), HudType.STANDARD)));
|
||||
|
||||
spoutPlayer.getMainScreen().setDirty(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update XP bar for Retro styles.
|
||||
*
|
||||
* @param skillType The skill last used
|
||||
* @param playerProfile The profile of the player whose XP bar should be updated
|
||||
*/
|
||||
private void updateXpBarRetro(SkillType skillType, PlayerProfile playerProfile) {
|
||||
Color color = getRetroColor(skillType);
|
||||
|
||||
xpIcon.setUrl(StringUtils.getCapitalized(skillType.toString()) + "_r.png");
|
||||
|
||||
xpFill.setBottomColor(color);
|
||||
xpFill.setTopColor(color);
|
||||
xpFill.setWidth(getXpInc(playerProfile.getSkillXpLevel(skillType), playerProfile.getXpToLevel(skillType), HudType.RETRO));
|
||||
|
||||
spoutPlayer.getMainScreen().setDirty(true);
|
||||
}
|
||||
|
||||
private static Color getRetroColor(SkillType type) {
|
||||
return new Color((float) SpoutConfig.getInstance().getRetroHUDRed(type), (float) SpoutConfig.getInstance().getRetroHUDGreen(type), (float) SpoutConfig.getInstance().getRetroHUDBlue(type), 1f);
|
||||
}
|
||||
|
||||
private static String getUrlBar(Integer number) {
|
||||
char[] num = number.toString().toCharArray();
|
||||
|
||||
switch (num.length) {
|
||||
case 1:
|
||||
return "xpbar_inc00" + number + ".png";
|
||||
|
||||
case 2:
|
||||
return "xpbar_inc0" + number + ".png";
|
||||
|
||||
default:
|
||||
return "xpbar_inc" + number + ".png";
|
||||
}
|
||||
}
|
||||
|
||||
private static Integer getXpInc(int skillXp, int xpToLevel, HudType hudType) {
|
||||
double percentage = (double) skillXp / xpToLevel;
|
||||
double inc;
|
||||
|
||||
switch (hudType) {
|
||||
case RETRO:
|
||||
inc = 0.0079365079365079;
|
||||
break;
|
||||
|
||||
case STANDARD:
|
||||
inc = 0.0039370078740157;
|
||||
break;
|
||||
|
||||
default:
|
||||
return 1;
|
||||
}
|
||||
|
||||
return (int) (percentage / inc);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.gmail.nossr50.datatypes.treasure;
|
||||
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
|
||||
public class EnchantmentTreasure {
|
||||
private Enchantment enchantment;
|
||||
private int level;
|
||||
|
||||
public EnchantmentTreasure(Enchantment enchantment, int level) {
|
||||
this.setEnchantment(enchantment);
|
||||
this.setLevel(level);
|
||||
}
|
||||
|
||||
public Enchantment getEnchantment() {
|
||||
return enchantment;
|
||||
}
|
||||
|
||||
public void setEnchantment(Enchantment enchantment) {
|
||||
this.enchantment = enchantment;
|
||||
}
|
||||
|
||||
public int getLevel() {
|
||||
return level;
|
||||
}
|
||||
|
||||
public void setLevel(int level) {
|
||||
this.level = level;
|
||||
}
|
||||
}
|
||||
@@ -3,138 +3,7 @@ package com.gmail.nossr50.datatypes.treasure;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class ExcavationTreasure extends Treasure {
|
||||
// dirt | grass | sand | gravel | clay | mycel | soulsand | snow
|
||||
// 00000001 - dirt 1
|
||||
// 00000010 - grass 2
|
||||
// 00000100 - sand 4
|
||||
// 00001000 - gravel 8
|
||||
// 00010000 - clay 16
|
||||
// 00100000 - mycel 32
|
||||
// 01000000 - soulsand 64
|
||||
// 10000000 - snow 128
|
||||
private byte dropsFrom = 0x0;
|
||||
|
||||
public ExcavationTreasure(ItemStack drop, int xp, double dropChance, int dropLevel) {
|
||||
super(drop, xp, dropChance, dropLevel);
|
||||
}
|
||||
|
||||
// Raw getters and setters
|
||||
public byte getDropsFrom() {
|
||||
return dropsFrom;
|
||||
}
|
||||
|
||||
public void setDropsFrom(byte dropsFrom) {
|
||||
this.dropsFrom = dropsFrom;
|
||||
}
|
||||
|
||||
// Getters
|
||||
public boolean getDropsFromDirt() {
|
||||
return getDropFromMask(1);
|
||||
}
|
||||
|
||||
public boolean getDropsFromGrass() {
|
||||
return getDropFromMask(2);
|
||||
}
|
||||
|
||||
public boolean getDropsFromSand() {
|
||||
return getDropFromMask(4);
|
||||
}
|
||||
|
||||
public boolean getDropsFromGravel() {
|
||||
return getDropFromMask(8);
|
||||
}
|
||||
|
||||
public boolean getDropsFromClay() {
|
||||
return getDropFromMask(16);
|
||||
}
|
||||
|
||||
public boolean getDropsFromMycel() {
|
||||
return getDropFromMask(32);
|
||||
}
|
||||
|
||||
public boolean getDropsFromSoulSand() {
|
||||
return getDropFromMask(64);
|
||||
}
|
||||
|
||||
public boolean getDropsFromSnow() {
|
||||
return getDropFromMask(128);
|
||||
}
|
||||
|
||||
private boolean getDropFromMask(int mask) {
|
||||
return ((dropsFrom & mask) > 0) ? true : false;
|
||||
}
|
||||
|
||||
// Setters
|
||||
public void setDropsFromDirt() {
|
||||
setDropFromMask(1);
|
||||
}
|
||||
|
||||
public void setDropsFromGrass() {
|
||||
setDropFromMask(2);
|
||||
}
|
||||
|
||||
public void setDropsFromSand() {
|
||||
setDropFromMask(4);
|
||||
}
|
||||
|
||||
public void setDropsFromGravel() {
|
||||
setDropFromMask(8);
|
||||
}
|
||||
|
||||
public void setDropsFromClay() {
|
||||
setDropFromMask(16);
|
||||
}
|
||||
|
||||
public void setDropsFromMycel() {
|
||||
setDropFromMask(32);
|
||||
}
|
||||
|
||||
public void setDropsFromSoulSand() {
|
||||
setDropFromMask(64);
|
||||
}
|
||||
|
||||
public void setDropsFromSnow() {
|
||||
setDropFromMask(128);
|
||||
}
|
||||
|
||||
private void setDropFromMask(int mask) {
|
||||
dropsFrom |= mask;
|
||||
}
|
||||
|
||||
// Un-setters
|
||||
public void unsetDropsFromDirt() {
|
||||
unsetDropFromMask(1);
|
||||
}
|
||||
|
||||
public void unsetDropsFromGrass() {
|
||||
unsetDropFromMask(2);
|
||||
}
|
||||
|
||||
public void unsetDropsFromSand() {
|
||||
unsetDropFromMask(4);
|
||||
}
|
||||
|
||||
public void unsetDropsFromGravel() {
|
||||
unsetDropFromMask(8);
|
||||
}
|
||||
|
||||
public void unsetDropsFromClay() {
|
||||
unsetDropFromMask(16);
|
||||
}
|
||||
|
||||
public void unsetDropsFromMycel() {
|
||||
unsetDropFromMask(32);
|
||||
}
|
||||
|
||||
public void unsetDropsFromSoulSand() {
|
||||
unsetDropFromMask(64);
|
||||
}
|
||||
|
||||
public void unsetDropsFromSnow() {
|
||||
unsetDropFromMask(128);
|
||||
}
|
||||
|
||||
private void unsetDropFromMask(int mask) {
|
||||
dropsFrom &= ~mask;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,18 +3,8 @@ package com.gmail.nossr50.datatypes.treasure;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class FishingTreasure extends Treasure {
|
||||
private int maxLevel;
|
||||
|
||||
public FishingTreasure(ItemStack drop, int xp, Double dropChance, int dropLevel, int maxLevel) {
|
||||
super(drop, xp, dropChance, dropLevel);
|
||||
this.setMaxLevel(maxLevel);
|
||||
}
|
||||
|
||||
public int getMaxLevel() {
|
||||
return maxLevel;
|
||||
}
|
||||
|
||||
public void setMaxLevel(int maxLevel) {
|
||||
this.maxLevel = maxLevel;
|
||||
public FishingTreasure(ItemStack drop, int xp) {
|
||||
super(drop, xp, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,73 +3,7 @@ package com.gmail.nossr50.datatypes.treasure;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class HylianTreasure extends Treasure {
|
||||
// bushes | flowers | pots
|
||||
// 00000001 - bushes 1
|
||||
// 00000010 - flowers 2
|
||||
// 00000100 - pots 4
|
||||
private byte dropsFrom = 0x0;
|
||||
|
||||
public HylianTreasure(ItemStack drop, int xp, double dropChance, int dropLevel) {
|
||||
super(drop, xp, dropChance, dropLevel);
|
||||
}
|
||||
|
||||
// Raw getters and setters
|
||||
public byte getDropsFrom() {
|
||||
return dropsFrom;
|
||||
}
|
||||
|
||||
public void setDropsFrom(byte dropsFrom) {
|
||||
this.dropsFrom = dropsFrom;
|
||||
}
|
||||
|
||||
// Getters
|
||||
public boolean getDropsFromBushes() {
|
||||
return getDropFromMask(1);
|
||||
}
|
||||
|
||||
public boolean getDropsFromFlowers() {
|
||||
return getDropFromMask(2);
|
||||
}
|
||||
|
||||
public boolean getDropsFromPots() {
|
||||
return getDropFromMask(4);
|
||||
}
|
||||
|
||||
private boolean getDropFromMask(int mask) {
|
||||
return ((dropsFrom & mask) > 0) ? true : false;
|
||||
}
|
||||
|
||||
// Setters
|
||||
public void setDropsFromBushes() {
|
||||
setDropFromMask(1);
|
||||
}
|
||||
|
||||
public void setDropsFromFlowers() {
|
||||
setDropFromMask(2);
|
||||
}
|
||||
|
||||
public void setDropsFromPots() {
|
||||
setDropFromMask(4);
|
||||
}
|
||||
|
||||
private void setDropFromMask(int mask) {
|
||||
dropsFrom |= mask;
|
||||
}
|
||||
|
||||
// Un-setters
|
||||
public void unsetDropsFromBushes() {
|
||||
unsetDropFromMask(1);
|
||||
}
|
||||
|
||||
public void unsetDropsFromFlowers() {
|
||||
unsetDropFromMask(2);
|
||||
}
|
||||
|
||||
public void unsetDropsFromPots() {
|
||||
unsetDropFromMask(4);
|
||||
}
|
||||
|
||||
private void unsetDropFromMask(int mask) {
|
||||
dropsFrom &= ~mask;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.gmail.nossr50.datatypes.treasure;
|
||||
|
||||
public enum Rarity {
|
||||
RECORD,
|
||||
LEGENDARY,
|
||||
EPIC,
|
||||
RARE,
|
||||
UNCOMMON,
|
||||
COMMON,
|
||||
TRAP;
|
||||
|
||||
public static Rarity getRarity(String string) {
|
||||
try {
|
||||
return valueOf(string);
|
||||
}
|
||||
catch (IllegalArgumentException ex) {
|
||||
return COMMON;
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -1,21 +1,9 @@
|
||||
package com.gmail.nossr50.datatypes.treasure;
|
||||
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class ShakeTreasure extends Treasure {
|
||||
private EntityType mob;
|
||||
|
||||
public ShakeTreasure(ItemStack drop, int xp, double dropChance, int dropLevel, EntityType mob) {
|
||||
public ShakeTreasure(ItemStack drop, int xp, double dropChance, int dropLevel) {
|
||||
super(drop, xp, dropChance, dropLevel);
|
||||
this.mob = mob;
|
||||
}
|
||||
|
||||
public EntityType getMob() {
|
||||
return mob;
|
||||
}
|
||||
|
||||
public void setMob(EntityType mob) {
|
||||
this.mob = mob;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,28 +3,16 @@ package com.gmail.nossr50.events.skills.abilities;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Cancellable;
|
||||
|
||||
import com.gmail.nossr50.datatypes.skills.AbilityType;
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.events.skills.McMMOPlayerSkillEvent;
|
||||
|
||||
public class McMMOPlayerAbilityActivateEvent extends McMMOPlayerSkillEvent implements Cancellable {
|
||||
|
||||
private AbilityType abilityType;
|
||||
public class McMMOPlayerAbilityActivateEvent extends McMMOPlayerAbilityEvent implements Cancellable {
|
||||
private boolean cancelled;
|
||||
|
||||
public McMMOPlayerAbilityActivateEvent(Player player, SkillType skill) {
|
||||
super(player, skill);
|
||||
abilityType = skill.getAbility();
|
||||
cancelled = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The ability type involved in this event
|
||||
*/
|
||||
public AbilityType getAbilityType() {
|
||||
return abilityType;
|
||||
}
|
||||
|
||||
public boolean isCancelled() {
|
||||
return cancelled;
|
||||
}
|
||||
|
||||
@@ -2,21 +2,10 @@ package com.gmail.nossr50.events.skills.abilities;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.datatypes.skills.AbilityType;
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.events.skills.McMMOPlayerSkillEvent;
|
||||
|
||||
public class McMMOPlayerAbilityDeactivateEvent extends McMMOPlayerSkillEvent {
|
||||
|
||||
private AbilityType ability;
|
||||
|
||||
public class McMMOPlayerAbilityDeactivateEvent extends McMMOPlayerAbilityEvent {
|
||||
public McMMOPlayerAbilityDeactivateEvent(Player player, SkillType skill) {
|
||||
super(player, skill);
|
||||
this.ability = skill.getAbility();
|
||||
}
|
||||
|
||||
public AbilityType getAbility() {
|
||||
return ability;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.gmail.nossr50.events.skills.abilities;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.datatypes.skills.AbilityType;
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.events.skills.McMMOPlayerSkillEvent;
|
||||
|
||||
public class McMMOPlayerAbilityEvent extends McMMOPlayerSkillEvent {
|
||||
private AbilityType ability;
|
||||
|
||||
protected McMMOPlayerAbilityEvent(Player player, SkillType skill) {
|
||||
super(player, skill);
|
||||
ability = skill.getAbility();
|
||||
}
|
||||
|
||||
public AbilityType getAbility() {
|
||||
return ability;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.gmail.nossr50.events.skills.fishing;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Cancellable;
|
||||
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.events.skills.McMMOPlayerSkillEvent;
|
||||
|
||||
public class McMMOPlayerFishingEvent extends McMMOPlayerSkillEvent implements Cancellable {
|
||||
private boolean cancelled;
|
||||
|
||||
protected McMMOPlayerFishingEvent(Player player) {
|
||||
super(player, SkillType.FISHING);
|
||||
cancelled = false;
|
||||
}
|
||||
|
||||
public boolean isCancelled() {
|
||||
return cancelled;
|
||||
}
|
||||
|
||||
public void setCancelled(boolean newValue) {
|
||||
this.cancelled = newValue;
|
||||
}
|
||||
}
|
||||
@@ -1,20 +1,14 @@
|
||||
package com.gmail.nossr50.events.skills.fishing;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.events.skills.McMMOPlayerSkillEvent;
|
||||
|
||||
public class McMMOPlayerFishingTreasureEvent extends McMMOPlayerSkillEvent implements Cancellable {
|
||||
|
||||
private boolean cancelled = false;
|
||||
public class McMMOPlayerFishingTreasureEvent extends McMMOPlayerFishingEvent {
|
||||
private ItemStack treasure;
|
||||
private int xp;
|
||||
|
||||
public McMMOPlayerFishingTreasureEvent(Player player, ItemStack treasure, int xp) {
|
||||
super(player, SkillType.FISHING);
|
||||
super(player);
|
||||
this.treasure = treasure;
|
||||
this.xp = xp;
|
||||
}
|
||||
@@ -27,14 +21,6 @@ public class McMMOPlayerFishingTreasureEvent extends McMMOPlayerSkillEvent imple
|
||||
this.treasure = item;
|
||||
}
|
||||
|
||||
public boolean isCancelled() {
|
||||
return cancelled;
|
||||
}
|
||||
|
||||
public void setCancelled(boolean newValue) {
|
||||
this.cancelled = newValue;
|
||||
}
|
||||
|
||||
public int getXp() {
|
||||
return xp;
|
||||
}
|
||||
|
||||
@@ -7,7 +7,6 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class McMMOPlayerMagicHunterEvent extends McMMOPlayerFishingTreasureEvent {
|
||||
|
||||
private Map<Enchantment, Integer> enchants;
|
||||
|
||||
public McMMOPlayerMagicHunterEvent(Player player, ItemStack treasure, int xp, Map<Enchantment, Integer> enchants) {
|
||||
|
||||
@@ -1,30 +1,16 @@
|
||||
package com.gmail.nossr50.events.skills.fishing;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.events.skills.McMMOPlayerSkillEvent;
|
||||
|
||||
public class McMMOPlayerShakeEvent extends McMMOPlayerSkillEvent implements Cancellable {
|
||||
|
||||
private boolean cancelled = false;
|
||||
public class McMMOPlayerShakeEvent extends McMMOPlayerFishingEvent {
|
||||
private ItemStack drop;
|
||||
|
||||
public McMMOPlayerShakeEvent(Player player, ItemStack drop) {
|
||||
super(player, SkillType.FISHING);
|
||||
super(player);
|
||||
this.drop = drop;
|
||||
}
|
||||
|
||||
public boolean isCancelled() {
|
||||
return cancelled;
|
||||
}
|
||||
|
||||
public void setCancelled(boolean newValue) {
|
||||
this.cancelled = newValue;
|
||||
}
|
||||
|
||||
public ItemStack getDrop() {
|
||||
return drop;
|
||||
}
|
||||
@@ -32,5 +18,4 @@ public class McMMOPlayerShakeEvent extends McMMOPlayerSkillEvent implements Canc
|
||||
public void setDrop(ItemStack drop) {
|
||||
this.drop = drop;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ public class BlockListener implements Listener {
|
||||
*
|
||||
* @param event The event to monitor
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onBlockPistonExtend(BlockPistonExtendEvent event) {
|
||||
List<Block> blocks = event.getBlocks();
|
||||
BlockFace direction = event.getDirection();
|
||||
@@ -84,7 +84,7 @@ public class BlockListener implements Listener {
|
||||
*
|
||||
* @param event The event to watch
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onBlockPistonRetract(BlockPistonRetractEvent event) {
|
||||
if (event.isSticky()) {
|
||||
// Needed only because under some circumstances Minecraft doesn't move the block
|
||||
@@ -113,7 +113,7 @@ public class BlockListener implements Listener {
|
||||
}
|
||||
|
||||
if (Repair.anvilMessagesEnabled && BlockUtils.isMcMMOAnvil(blockState)) {
|
||||
UserManager.getPlayer(player).getRepairManager().placedAnvilCheck(blockState.getTypeId());
|
||||
UserManager.getPlayer(player).getRepairManager().placedAnvilCheck(blockState.getType());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -149,7 +149,7 @@ public class BlockListener implements Listener {
|
||||
|
||||
/* Green Terra */
|
||||
if (herbalismManager.canActivateAbility()) {
|
||||
SkillUtils.abilityCheck(mcMMOPlayer, SkillType.HERBALISM);
|
||||
mcMMOPlayer.checkAbilityActivation(SkillType.HERBALISM);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -221,6 +221,11 @@ public class BlockListener implements Listener {
|
||||
blockState.update(true);
|
||||
event.setCancelled(true);
|
||||
}
|
||||
else if (blockState.getType() == Material.FLOWER_POT) {
|
||||
blockState.setType(Material.AIR);
|
||||
blockState.update(true);
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (ItemUtils.isPickaxe(heldItem) && !heldItem.containsEnchantment(Enchantment.SILK_TOUCH)) {
|
||||
@@ -275,19 +280,19 @@ public class BlockListener implements Listener {
|
||||
}
|
||||
|
||||
if (mcMMOPlayer.getToolPreparationMode(ToolType.HOE) && ItemUtils.isHoe(heldItem) && (BlockUtils.affectedByGreenTerra(blockState) || BlockUtils.canMakeMossy(blockState)) && Permissions.greenTerra(player)) {
|
||||
SkillUtils.abilityCheck(mcMMOPlayer, SkillType.HERBALISM);
|
||||
mcMMOPlayer.checkAbilityActivation(SkillType.HERBALISM);
|
||||
}
|
||||
else if (mcMMOPlayer.getToolPreparationMode(ToolType.AXE) && ItemUtils.isAxe(heldItem) && BlockUtils.isLog(blockState) && Permissions.treeFeller(player)) {
|
||||
SkillUtils.abilityCheck(mcMMOPlayer, SkillType.WOODCUTTING);
|
||||
mcMMOPlayer.checkAbilityActivation(SkillType.WOODCUTTING);
|
||||
}
|
||||
else if (mcMMOPlayer.getToolPreparationMode(ToolType.PICKAXE) && ItemUtils.isPickaxe(heldItem) && BlockUtils.affectedBySuperBreaker(blockState) && Permissions.superBreaker(player)) {
|
||||
SkillUtils.abilityCheck(mcMMOPlayer, SkillType.MINING);
|
||||
mcMMOPlayer.checkAbilityActivation(SkillType.MINING);
|
||||
}
|
||||
else if (mcMMOPlayer.getToolPreparationMode(ToolType.SHOVEL) && ItemUtils.isShovel(heldItem) && BlockUtils.affectedByGigaDrillBreaker(blockState) && Permissions.gigaDrillBreaker(player)) {
|
||||
SkillUtils.abilityCheck(mcMMOPlayer, SkillType.EXCAVATION);
|
||||
mcMMOPlayer.checkAbilityActivation(SkillType.EXCAVATION);
|
||||
}
|
||||
else if (mcMMOPlayer.getToolPreparationMode(ToolType.FISTS) && heldItem.getType() == Material.AIR && (BlockUtils.affectedByGigaDrillBreaker(blockState) || blockState.getType() == Material.SNOW || BlockUtils.affectedByBlockCracker(blockState) && Permissions.berserk(player))) {
|
||||
SkillUtils.abilityCheck(mcMMOPlayer, SkillType.UNARMED);
|
||||
mcMMOPlayer.checkAbilityActivation(SkillType.UNARMED);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -334,17 +339,17 @@ public class BlockListener implements Listener {
|
||||
}
|
||||
}
|
||||
else if (mcMMOPlayer.getAbilityMode(AbilityType.BERSERK) && heldItem.getType() == Material.AIR) {
|
||||
if (SkillUtils.triggerCheck(player, block, AbilityType.BERSERK)) {
|
||||
if (AbilityType.BERSERK.triggerCheck(player, block)) {
|
||||
event.setInstaBreak(true);
|
||||
player.playSound(block.getLocation(), Sound.ITEM_PICKUP, Misc.POP_VOLUME, Misc.getPopPitch());
|
||||
}
|
||||
else if (mcMMOPlayer.getUnarmedManager().canUseBlockCracker() && SkillUtils.triggerCheck(player, block, AbilityType.BLOCK_CRACKER)) {
|
||||
else if (mcMMOPlayer.getUnarmedManager().canUseBlockCracker() && AbilityType.BLOCK_CRACKER.triggerCheck(player, block)) {
|
||||
if (mcMMOPlayer.getUnarmedManager().blockCrackerCheck(blockState)) {
|
||||
blockState.update();
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (mcMMOPlayer.getWoodcuttingManager().canUseLeafBlower(heldItem) && SkillUtils.triggerCheck(player, block, AbilityType.LEAF_BLOWER)) {
|
||||
else if (mcMMOPlayer.getWoodcuttingManager().canUseLeafBlower(heldItem) && AbilityType.LEAF_BLOWER.triggerCheck(player, block)) {
|
||||
event.setInstaBreak(true);
|
||||
player.playSound(blockState.getLocation(), Sound.ITEM_PICKUP, Misc.POP_VOLUME, Misc.getPopPitch());
|
||||
}
|
||||
|
||||
@@ -151,6 +151,10 @@ public class EntityListener implements Listener {
|
||||
|
||||
Entity attacker = event.getDamager();
|
||||
|
||||
if (Misc.isNPCEntity(attacker)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (attacker instanceof Projectile) {
|
||||
attacker = ((Projectile) attacker).getShooter();
|
||||
}
|
||||
@@ -455,6 +459,22 @@ public class EntityListener implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle EntityExplode events that involve modifying the event.
|
||||
*
|
||||
* @param event The event to modify
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||
public void onEntityExplodeMonitor(EntityExplodeEvent event) {
|
||||
Entity entity = event.getEntity();
|
||||
|
||||
if (!(entity instanceof TNTPrimed) || !entity.hasMetadata(mcMMO.tntsafeMetadataKey)) {
|
||||
return;
|
||||
}
|
||||
|
||||
event.blockList().clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle FoodLevelChange events that involve modifying the event.
|
||||
*
|
||||
|
||||
@@ -49,6 +49,7 @@ import com.gmail.nossr50.skills.taming.TamingManager;
|
||||
import com.gmail.nossr50.skills.unarmed.Unarmed;
|
||||
import com.gmail.nossr50.util.BlockUtils;
|
||||
import com.gmail.nossr50.util.ChimaeraWing;
|
||||
import com.gmail.nossr50.util.EventUtils;
|
||||
import com.gmail.nossr50.util.HardcoreManager;
|
||||
import com.gmail.nossr50.util.ItemUtils;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
@@ -56,7 +57,6 @@ import com.gmail.nossr50.util.MobHealthbarUtils;
|
||||
import com.gmail.nossr50.util.Motd;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
import com.gmail.nossr50.util.scoreboards.ScoreboardManager;
|
||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||
|
||||
public class PlayerListener implements Listener {
|
||||
@@ -362,7 +362,6 @@ public class PlayerListener implements Listener {
|
||||
}
|
||||
|
||||
UserManager.addUser(player).actualizeRespawnATS();
|
||||
ScoreboardManager.enablePowerLevelDisplay(player);
|
||||
|
||||
if (Config.getInstance().getMOTDEnabled() && Permissions.motd(player)) {
|
||||
Motd.displayAll(player);
|
||||
@@ -373,8 +372,8 @@ public class PlayerListener implements Listener {
|
||||
}
|
||||
|
||||
if (Permissions.updateNotifications(player) && plugin.isUpdateAvailable()) {
|
||||
player.sendMessage(LocaleLoader.getString("UpdateChecker.outdated"));
|
||||
player.sendMessage(LocaleLoader.getString("UpdateChecker.newavailable"));
|
||||
player.sendMessage(LocaleLoader.getString("UpdateChecker.Outdated"));
|
||||
player.sendMessage(LocaleLoader.getString("UpdateChecker.NewAvailable"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -418,27 +417,27 @@ public class PlayerListener implements Listener {
|
||||
|
||||
switch (event.getAction()) {
|
||||
case RIGHT_CLICK_BLOCK:
|
||||
int blockID = block.getTypeId();
|
||||
Material type = block.getType();
|
||||
|
||||
if (!Config.getInstance().getAbilitiesOnlyActivateWhenSneaking() || player.isSneaking()) {
|
||||
/* REPAIR CHECKS */
|
||||
if (blockID == Repair.repairAnvilId && Permissions.skillEnabled(player, SkillType.REPAIR) && mcMMO.getRepairableManager().isRepairable(heldItem)) {
|
||||
if (type == Repair.repairAnvilMaterial && Permissions.skillEnabled(player, SkillType.REPAIR) && mcMMO.getRepairableManager().isRepairable(heldItem)) {
|
||||
RepairManager repairManager = mcMMOPlayer.getRepairManager();
|
||||
event.setCancelled(true);
|
||||
|
||||
// Make sure the player knows what he's doing when trying to repair an enchanted item
|
||||
if (!(heldItem.getEnchantments().size() > 0) || repairManager.checkConfirmation(blockID, true)) {
|
||||
if (!(heldItem.getEnchantments().size() > 0) || repairManager.checkConfirmation(type, true)) {
|
||||
repairManager.handleRepair(heldItem);
|
||||
player.updateInventory();
|
||||
}
|
||||
}
|
||||
/* SALVAGE CHECKS */
|
||||
else if (blockID == Repair.salvageAnvilId && Permissions.salvage(player) && Repair.isSalvageable(heldItem)) {
|
||||
else if (type == Repair.salvageAnvilMaterial && Permissions.salvage(player) && Repair.isSalvageable(heldItem)) {
|
||||
RepairManager repairManager = mcMMOPlayer.getRepairManager();
|
||||
event.setCancelled(true);
|
||||
|
||||
// Make sure the player knows what he's doing when trying to salvage an enchanted item
|
||||
if (!(heldItem.getEnchantments().size() > 0) || repairManager.checkConfirmation(blockID, true)) {
|
||||
if (!(heldItem.getEnchantments().size() > 0) || repairManager.checkConfirmation(type, true)) {
|
||||
repairManager.handleSalvage(block.getLocation(), heldItem);
|
||||
player.updateInventory();
|
||||
}
|
||||
@@ -446,7 +445,7 @@ public class PlayerListener implements Listener {
|
||||
}
|
||||
/* BLAST MINING CHECK */
|
||||
else if (miningManager.canDetonate()) {
|
||||
if (block.getType() == Material.TNT) {
|
||||
if (type == Material.TNT) {
|
||||
event.setCancelled(true); // Don't detonate the TNT if they're too close
|
||||
}
|
||||
else {
|
||||
@@ -457,26 +456,26 @@ public class PlayerListener implements Listener {
|
||||
break;
|
||||
|
||||
case LEFT_CLICK_BLOCK:
|
||||
blockID = block.getTypeId();
|
||||
type = block.getType();
|
||||
|
||||
if ((Config.getInstance().getAbilitiesOnlyActivateWhenSneaking() && player.isSneaking()) || !Config.getInstance().getAbilitiesOnlyActivateWhenSneaking()) {
|
||||
/* REPAIR CHECKS */
|
||||
if (blockID == Repair.repairAnvilId && Permissions.skillEnabled(player, SkillType.REPAIR) && mcMMO.getRepairableManager().isRepairable(heldItem)) {
|
||||
if (type == Repair.repairAnvilMaterial && Permissions.skillEnabled(player, SkillType.REPAIR) && mcMMO.getRepairableManager().isRepairable(heldItem)) {
|
||||
RepairManager repairManager = mcMMOPlayer.getRepairManager();
|
||||
|
||||
// Cancel repairing an enchanted item
|
||||
if (repairManager.checkConfirmation(blockID, false) && Config.getInstance().getRepairConfirmRequired()) {
|
||||
mcMMOPlayer.setLastAnvilUse(Repair.repairAnvilId, 0);
|
||||
if (repairManager.checkConfirmation(type, false) && Config.getInstance().getRepairConfirmRequired()) {
|
||||
mcMMOPlayer.setLastAnvilUse(Repair.repairAnvilMaterial, 0);
|
||||
player.sendMessage(LocaleLoader.getString("Skills.Cancelled", LocaleLoader.getString("Repair.Pretty.Name")));
|
||||
}
|
||||
}
|
||||
/* SALVAGE CHECKS */
|
||||
else if (blockID == Repair.salvageAnvilId && Permissions.salvage(player) && Repair.isSalvageable(heldItem)) {
|
||||
else if (type == Repair.salvageAnvilMaterial && Permissions.salvage(player) && Repair.isSalvageable(heldItem)) {
|
||||
RepairManager repairManager = mcMMOPlayer.getRepairManager();
|
||||
|
||||
// Cancel salvaging an enchanted item
|
||||
if (repairManager.checkConfirmation(blockID, false) && Config.getInstance().getRepairConfirmRequired()) {
|
||||
mcMMOPlayer.setLastAnvilUse(Repair.salvageAnvilId, 0);
|
||||
if (repairManager.checkConfirmation(type, false) && Config.getInstance().getRepairConfirmRequired()) {
|
||||
mcMMOPlayer.setLastAnvilUse(Repair.salvageAnvilMaterial, 0);
|
||||
player.sendMessage(LocaleLoader.getString("Skills.Cancelled", LocaleLoader.getString("Salvage.Pretty.Name")));
|
||||
}
|
||||
}
|
||||
@@ -514,15 +513,15 @@ public class PlayerListener implements Listener {
|
||||
if (BlockUtils.canActivateAbilities(blockState)) {
|
||||
if (Config.getInstance().getAbilitiesEnabled()) {
|
||||
if (BlockUtils.canActivateHerbalism(blockState)) {
|
||||
SkillUtils.activationCheck(player, SkillType.HERBALISM);
|
||||
mcMMOPlayer.processAbilityActivation(SkillType.HERBALISM);
|
||||
}
|
||||
|
||||
SkillUtils.activationCheck(player, SkillType.AXES);
|
||||
SkillUtils.activationCheck(player, SkillType.EXCAVATION);
|
||||
SkillUtils.activationCheck(player, SkillType.MINING);
|
||||
SkillUtils.activationCheck(player, SkillType.SWORDS);
|
||||
SkillUtils.activationCheck(player, SkillType.UNARMED);
|
||||
SkillUtils.activationCheck(player, SkillType.WOODCUTTING);
|
||||
mcMMOPlayer.processAbilityActivation(SkillType.AXES);
|
||||
mcMMOPlayer.processAbilityActivation(SkillType.EXCAVATION);
|
||||
mcMMOPlayer.processAbilityActivation(SkillType.MINING);
|
||||
mcMMOPlayer.processAbilityActivation(SkillType.SWORDS);
|
||||
mcMMOPlayer.processAbilityActivation(SkillType.UNARMED);
|
||||
mcMMOPlayer.processAbilityActivation(SkillType.WOODCUTTING);
|
||||
}
|
||||
|
||||
ChimaeraWing.activationCheck(player);
|
||||
@@ -534,14 +533,14 @@ public class PlayerListener implements Listener {
|
||||
if (herbalismManager.canGreenThumbBlock(blockState)) {
|
||||
player.setItemInHand(new ItemStack(Material.SEEDS, heldItem.getAmount() - 1));
|
||||
|
||||
if (herbalismManager.processGreenThumbBlocks(blockState) && SkillUtils.blockBreakSimulate(block, player, false)) {
|
||||
if (herbalismManager.processGreenThumbBlocks(blockState) && EventUtils.simulateBlockBreak(block, player, false)) {
|
||||
blockState.update(true);
|
||||
}
|
||||
}
|
||||
|
||||
/* SHROOM THUMB CHECK */
|
||||
else if (herbalismManager.canUseShroomThumb(blockState)) {
|
||||
if (herbalismManager.processShroomThumb(blockState) && SkillUtils.blockBreakSimulate(block, player, false)) {
|
||||
if (herbalismManager.processShroomThumb(blockState) && EventUtils.simulateBlockBreak(block, player, false)) {
|
||||
blockState.update(true);
|
||||
}
|
||||
}
|
||||
@@ -551,13 +550,13 @@ public class PlayerListener implements Listener {
|
||||
|
||||
/* ACTIVATION CHECKS */
|
||||
if (Config.getInstance().getAbilitiesEnabled()) {
|
||||
SkillUtils.activationCheck(player, SkillType.AXES);
|
||||
SkillUtils.activationCheck(player, SkillType.EXCAVATION);
|
||||
SkillUtils.activationCheck(player, SkillType.HERBALISM);
|
||||
SkillUtils.activationCheck(player, SkillType.MINING);
|
||||
SkillUtils.activationCheck(player, SkillType.SWORDS);
|
||||
SkillUtils.activationCheck(player, SkillType.UNARMED);
|
||||
SkillUtils.activationCheck(player, SkillType.WOODCUTTING);
|
||||
mcMMOPlayer.processAbilityActivation(SkillType.AXES);
|
||||
mcMMOPlayer.processAbilityActivation(SkillType.EXCAVATION);
|
||||
mcMMOPlayer.processAbilityActivation(SkillType.HERBALISM);
|
||||
mcMMOPlayer.processAbilityActivation(SkillType.MINING);
|
||||
mcMMOPlayer.processAbilityActivation(SkillType.SWORDS);
|
||||
mcMMOPlayer.processAbilityActivation(SkillType.UNARMED);
|
||||
mcMMOPlayer.processAbilityActivation(SkillType.WOODCUTTING);
|
||||
}
|
||||
|
||||
/* ITEM CHECKS */
|
||||
@@ -659,7 +658,7 @@ public class PlayerListener implements Listener {
|
||||
// Do these ACTUALLY have to be lower case to work properly?
|
||||
for (SkillType skill : SkillType.values()) {
|
||||
String skillName = skill.toString().toLowerCase();
|
||||
String localizedName = SkillUtils.getSkillName(skill).toLowerCase();
|
||||
String localizedName = skill.getSkillName().toLowerCase();
|
||||
|
||||
if (lowerCaseCommand.equals(localizedName)) {
|
||||
event.setMessage(message.replace(command, skillName));
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
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
|
||||
public void onPlayerJoin(PlayerJoinEvent e) {
|
||||
ScoreboardManager.setupPlayer(e.getPlayer());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerQuit(PlayerQuitEvent e) {
|
||||
ScoreboardManager.teardownPlayer(e.getPlayer());
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPlayerLevelUp(McMMOPlayerLevelUpEvent e) {
|
||||
ScoreboardManager.handleLevelUp(e.getPlayer(), e.getSkill());
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPlayerXp(McMMOPlayerXpGainEvent e) {
|
||||
ScoreboardManager.handleXp(e.getPlayer(), e.getSkill());
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onAbility(McMMOPlayerAbilityActivateEvent e) {
|
||||
ScoreboardManager.cooldownUpdate(e.getPlayer(), e.getSkill());
|
||||
}
|
||||
}
|
||||
@@ -1,93 +0,0 @@
|
||||
package com.gmail.nossr50.listeners;
|
||||
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
|
||||
import com.gmail.nossr50.config.spout.SpoutConfig;
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.datatypes.spout.buttons.McMMOButton;
|
||||
import com.gmail.nossr50.datatypes.spout.huds.McMMOHud;
|
||||
import com.gmail.nossr50.datatypes.spout.popups.McMMOMenu;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
|
||||
import org.getspout.spoutapi.event.input.KeyPressedEvent;
|
||||
import org.getspout.spoutapi.event.screen.ButtonClickEvent;
|
||||
import org.getspout.spoutapi.event.screen.ScreenCloseEvent;
|
||||
import org.getspout.spoutapi.event.spout.SpoutCraftEnableEvent;
|
||||
import org.getspout.spoutapi.gui.Button;
|
||||
import org.getspout.spoutapi.gui.ScreenType;
|
||||
import org.getspout.spoutapi.player.SpoutPlayer;
|
||||
|
||||
public class SpoutListener implements Listener {
|
||||
|
||||
/**
|
||||
* Monitor SpoutCraftEnable events.
|
||||
*
|
||||
* @param event The event to watch
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onSpoutCraftEnable(SpoutCraftEnableEvent event) {
|
||||
SpoutPlayer spoutPlayer = event.getPlayer();
|
||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(spoutPlayer);
|
||||
|
||||
// TODO: Add custom titles based on skills
|
||||
if (SpoutConfig.getInstance().getShowPowerLevel()) {
|
||||
spoutPlayer.setTitle(LocaleLoader.getString("Spout.Title", spoutPlayer.getTitle(), mcMMOPlayer.getPowerLevel()));
|
||||
}
|
||||
|
||||
mcMMOPlayer.getProfile().setSpoutHud(new McMMOHud(mcMMOPlayer)); // Setup Party HUD stuff
|
||||
}
|
||||
|
||||
/**
|
||||
* Monitor Spout ButtonClick events.
|
||||
*
|
||||
* @param event The event to watch
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onButtonClick(ButtonClickEvent event) {
|
||||
Button button = event.getButton();
|
||||
|
||||
if (button instanceof McMMOButton) {
|
||||
((McMMOButton) button).activate();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Monitor Spout ScreenClose events.
|
||||
*
|
||||
* @param event The event to watch
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onScreenClose(ScreenCloseEvent event) {
|
||||
if (event.getScreen() instanceof McMMOMenu) {
|
||||
SpoutPlayer spoutPlayer = event.getPlayer();
|
||||
|
||||
UserManager.getPlayer(spoutPlayer).getProfile().getSpoutHud().onMenuClose();
|
||||
spoutPlayer.getMainScreen().setDirty(true);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Monitor Spout KeyPressed events.
|
||||
*
|
||||
* @param event The event to watch
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onKeyPressedEvent(KeyPressedEvent event) {
|
||||
SpoutPlayer spoutPlayer = event.getPlayer();
|
||||
|
||||
if (spoutPlayer.getMainScreen().getActivePopup() != null || event.getScreenType() != ScreenType.GAME_SCREEN) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (event.getKey() == SpoutConfig.getInstance().getMenuKey()) {
|
||||
McMMOHud spoutHud = UserManager.getPlayer(spoutPlayer).getProfile().getSpoutHud();
|
||||
|
||||
if (!spoutHud.isMenuOpened()) {
|
||||
spoutHud.openMenu();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -7,6 +7,7 @@ import java.util.ResourceBundle;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
|
||||
public final class LocaleLoader {
|
||||
@@ -40,6 +41,10 @@ public final class LocaleLoader {
|
||||
return getString(key, enBundle, messageArguments);
|
||||
}
|
||||
catch (MissingResourceException ex2) {
|
||||
if (!key.contains("Guides")) {
|
||||
mcMMO.p.getLogger().warning("Could not find locale string: " + key);
|
||||
}
|
||||
|
||||
return '!' + key + '!';
|
||||
}
|
||||
}
|
||||
@@ -56,6 +61,7 @@ public final class LocaleLoader {
|
||||
string = formatter.format(messageArguments);
|
||||
}
|
||||
|
||||
string.replaceAll("\'", "''");
|
||||
string = addColors(string);
|
||||
|
||||
return string;
|
||||
|
||||
@@ -18,7 +18,6 @@ import com.gmail.nossr50.config.mods.CustomArmorConfig;
|
||||
import com.gmail.nossr50.config.mods.CustomBlockConfig;
|
||||
import com.gmail.nossr50.config.mods.CustomEntityConfig;
|
||||
import com.gmail.nossr50.config.mods.CustomToolConfig;
|
||||
import com.gmail.nossr50.config.spout.SpoutConfig;
|
||||
import com.gmail.nossr50.config.treasure.TreasureConfig;
|
||||
import com.gmail.nossr50.database.DatabaseManager;
|
||||
import com.gmail.nossr50.database.DatabaseManagerFactory;
|
||||
@@ -26,22 +25,22 @@ import com.gmail.nossr50.listeners.BlockListener;
|
||||
import com.gmail.nossr50.listeners.EntityListener;
|
||||
import com.gmail.nossr50.listeners.InventoryListener;
|
||||
import com.gmail.nossr50.listeners.PlayerListener;
|
||||
import com.gmail.nossr50.listeners.ScoreboardsListener;
|
||||
import com.gmail.nossr50.listeners.SelfListener;
|
||||
import com.gmail.nossr50.listeners.SpoutListener;
|
||||
import com.gmail.nossr50.listeners.WorldListener;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.metrics.MetricsManager;
|
||||
import com.gmail.nossr50.party.PartyManager;
|
||||
import com.gmail.nossr50.runnables.SaveTimerTask;
|
||||
import com.gmail.nossr50.runnables.UpdateCheckerTask;
|
||||
import com.gmail.nossr50.runnables.database.UserPurgeTask;
|
||||
import com.gmail.nossr50.runnables.party.PartyAutoKickTask;
|
||||
import com.gmail.nossr50.runnables.player.PowerLevelUpdatingTask;
|
||||
import com.gmail.nossr50.runnables.skills.BleedTimerTask;
|
||||
import com.gmail.nossr50.skills.child.ChildConfig;
|
||||
import com.gmail.nossr50.skills.repair.Repairable;
|
||||
import com.gmail.nossr50.skills.repair.RepairableManager;
|
||||
import com.gmail.nossr50.skills.repair.RepairableManagerFactory;
|
||||
import com.gmail.nossr50.skills.repair.config.RepairConfigManager;
|
||||
import com.gmail.nossr50.skills.repair.repairables.Repairable;
|
||||
import com.gmail.nossr50.skills.repair.repairables.RepairableManager;
|
||||
import com.gmail.nossr50.skills.repair.repairables.SimpleRepairableManager;
|
||||
import com.gmail.nossr50.util.ChimaeraWing;
|
||||
import com.gmail.nossr50.util.LogFilter;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
@@ -51,8 +50,11 @@ import com.gmail.nossr50.util.blockmeta.chunkmeta.ChunkManagerFactory;
|
||||
import com.gmail.nossr50.util.commands.CommandRegistrationManager;
|
||||
import com.gmail.nossr50.util.experience.FormulaManager;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
import com.gmail.nossr50.util.spout.SpoutUtils;
|
||||
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;
|
||||
|
||||
public class mcMMO extends JavaPlugin {
|
||||
@@ -77,8 +79,11 @@ public class mcMMO extends JavaPlugin {
|
||||
private boolean updateAvailable;
|
||||
|
||||
/* Plugin Checks */
|
||||
private static boolean spoutEnabled;
|
||||
private static boolean combatTagEnabled;
|
||||
private static boolean healthBarPluginEnabled;
|
||||
private static boolean noCheatPlusPluginEnabled;
|
||||
private static boolean compatNoCheatPlusPluginEnabled;
|
||||
private static boolean mcpcEnabled;
|
||||
|
||||
// Config Validation Check
|
||||
public boolean noErrorsInConfigFiles = true;
|
||||
@@ -91,6 +96,7 @@ public class mcMMO extends JavaPlugin {
|
||||
public final static String blockMetadataKey = "mcMMO: Piston Tracking";
|
||||
public final static String furnaceMetadataKey = "mcMMO: Tracked Furnace";
|
||||
public final static String tntMetadataKey = "mcMMO: Tracked TNT";
|
||||
public final static String tntsafeMetadataKey = "mcMMO: Safe TNT";
|
||||
public final static String customNameKey = "mcMMO: Custom Name";
|
||||
public final static String customVisibleKey = "mcMMO: Name Visibility";
|
||||
public final static String droppedItemKey = "mcMMO: Tracked Item";
|
||||
@@ -112,14 +118,31 @@ public class mcMMO extends JavaPlugin {
|
||||
metadataValue = new FixedMetadataValue(this, true);
|
||||
|
||||
setupFilePaths();
|
||||
setupSpout();
|
||||
|
||||
loadConfigFiles();
|
||||
|
||||
if (!noErrorsInConfigFiles) {
|
||||
return;
|
||||
}
|
||||
|
||||
mcpcEnabled = getServer().getName().equals("MCPC+");
|
||||
combatTagEnabled = getServer().getPluginManager().getPlugin("CombatTag") != null;
|
||||
healthBarPluginEnabled = getServer().getPluginManager().getPlugin("HealthBar") != null;
|
||||
noCheatPlusPluginEnabled = getServer().getPluginManager().getPlugin("NoCheatPlus") != null;
|
||||
compatNoCheatPlusPluginEnabled = getServer().getPluginManager().getPlugin("CompatNoCheatPlus") != null;
|
||||
|
||||
if (mcpcEnabled) {
|
||||
checkModConfigs();
|
||||
}
|
||||
|
||||
if (healthBarPluginEnabled) {
|
||||
getLogger().info("HealthBar plugin found, mcMMO's healthbars are automatically disabled.");
|
||||
}
|
||||
|
||||
if (noCheatPlusPluginEnabled && !compatNoCheatPlusPluginEnabled) {
|
||||
getLogger().warning("NoCheatPlus plugin found, but CompatNoCheatPlus was not found!");
|
||||
getLogger().warning("mcMMO will not work properly alongside NoCheatPlus without CompatNoCheatPlus");
|
||||
}
|
||||
|
||||
databaseManager = DatabaseManagerFactory.getDatabaseManager();
|
||||
|
||||
@@ -132,6 +155,7 @@ public class mcMMO extends JavaPlugin {
|
||||
|
||||
for (Player player : getServer().getOnlinePlayers()) {
|
||||
UserManager.addUser(player); // In case of reload add all users back into UserManager
|
||||
ScoreboardManager.setupPlayer(player);
|
||||
}
|
||||
|
||||
debug("Version " + getDescription().getVersion() + " is enabled!");
|
||||
@@ -171,6 +195,7 @@ public class mcMMO extends JavaPlugin {
|
||||
try {
|
||||
UserManager.saveAll(); // Make sure to save player information if the server shuts down
|
||||
PartyManager.saveParties(); // Save our parties
|
||||
ScoreboardManager.teardownAll();
|
||||
formulaManager.saveFormula();
|
||||
placeStore.saveAll(); // Save our metadata
|
||||
placeStore.cleanUp(); // Cleanup empty metadata stores
|
||||
@@ -259,23 +284,41 @@ public class mcMMO extends JavaPlugin {
|
||||
mcMMO.databaseManager = databaseManager;
|
||||
}
|
||||
|
||||
public static boolean isSpoutEnabled() {
|
||||
return spoutEnabled;
|
||||
}
|
||||
|
||||
public static boolean isCombatTagEnabled() {
|
||||
return combatTagEnabled;
|
||||
}
|
||||
|
||||
public static boolean isHealthBarPluginEnabled() {
|
||||
return healthBarPluginEnabled;
|
||||
}
|
||||
|
||||
public static boolean isMCPCEnabled() {
|
||||
return mcpcEnabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setup the various storage file paths
|
||||
*/
|
||||
private void setupFilePaths() {
|
||||
mcmmo = getFile();
|
||||
mainDirectory = getDataFolder().getPath() + File.separator;
|
||||
flatFileDirectory = mainDirectory + "FlatFileStuff" + File.separator;
|
||||
flatFileDirectory = mainDirectory + "flatfile" + File.separator;
|
||||
usersFile = flatFileDirectory + "mcmmo.users";
|
||||
modDirectory = mainDirectory + "ModConfigs" + File.separator;
|
||||
modDirectory = mainDirectory + "mods" + File.separator;
|
||||
fixFilePaths();
|
||||
}
|
||||
|
||||
private void fixFilePaths() {
|
||||
File oldFlatfilePath = new File(mainDirectory + "FlatFileStuff" + File.separator);
|
||||
File oldModPath = new File(mainDirectory + "ModConfigs" + File.separator);
|
||||
|
||||
if (oldFlatfilePath.exists()) {
|
||||
oldFlatfilePath.renameTo(new File(flatFileDirectory));
|
||||
}
|
||||
|
||||
if (oldModPath.exists()) {
|
||||
oldModPath.renameTo(new File(modDirectory));
|
||||
}
|
||||
}
|
||||
|
||||
private void checkForUpdates() {
|
||||
@@ -283,15 +326,21 @@ public class mcMMO extends JavaPlugin {
|
||||
return;
|
||||
}
|
||||
|
||||
getServer().getScheduler().runTaskAsynchronously(this, new UpdateCheckerTask());
|
||||
}
|
||||
Updater updater = new Updater(this, 31030, mcmmo, UpdateType.NO_DOWNLOAD, false);
|
||||
|
||||
public void updateCheckerCallback(boolean updateAvailable) {
|
||||
this.updateAvailable = updateAvailable;
|
||||
if (updateAvailable) {
|
||||
getLogger().info(LocaleLoader.getString("UpdateChecker.outdated"));
|
||||
getLogger().info(LocaleLoader.getString("UpdateChecker.newavailable"));
|
||||
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() {
|
||||
@@ -322,23 +371,10 @@ public class mcMMO extends JavaPlugin {
|
||||
// Load repair configs, make manager, and register them at this time
|
||||
RepairConfigManager rManager = new RepairConfigManager(this);
|
||||
repairables.addAll(rManager.getLoadedRepairables());
|
||||
repairableManager = RepairableManagerFactory.getRepairManager(repairables.size());
|
||||
repairableManager = new SimpleRepairableManager(repairables.size());
|
||||
repairableManager.registerRepairables(repairables);
|
||||
}
|
||||
|
||||
private void setupSpout() {
|
||||
if (!getServer().getPluginManager().isPluginEnabled("Spout")) {
|
||||
return;
|
||||
}
|
||||
|
||||
spoutEnabled = true;
|
||||
|
||||
SpoutConfig.getInstance();
|
||||
getServer().getPluginManager().registerEvents(new SpoutListener(), this);
|
||||
SpoutUtils.preCacheFiles();
|
||||
SpoutUtils.reloadSpoutPlayers(); // Handle spout players after a /reload
|
||||
}
|
||||
|
||||
private void registerEvents() {
|
||||
PluginManager pluginManager = getServer().getPluginManager();
|
||||
|
||||
@@ -348,6 +384,7 @@ public class mcMMO extends JavaPlugin {
|
||||
pluginManager.registerEvents(new EntityListener(this), this);
|
||||
pluginManager.registerEvents(new InventoryListener(this), this);
|
||||
pluginManager.registerEvents(new SelfListener(), this);
|
||||
pluginManager.registerEvents(new ScoreboardsListener(), this);
|
||||
pluginManager.registerEvents(new WorldListener(this), this);
|
||||
}
|
||||
|
||||
@@ -384,5 +421,30 @@ public class mcMMO extends JavaPlugin {
|
||||
else if (kickIntervalTicks > 0) {
|
||||
new PartyAutoKickTask().runTaskTimer(this, kickIntervalTicks, kickIntervalTicks);
|
||||
}
|
||||
|
||||
// Update power level tag scoreboards
|
||||
new PowerLevelUpdatingTask().runTaskTimer(this, 2 * Misc.TICK_CONVERSION_FACTOR, 2 * Misc.TICK_CONVERSION_FACTOR);
|
||||
}
|
||||
|
||||
private void checkModConfigs() {
|
||||
if (!Config.getInstance().getToolModsEnabled()) {
|
||||
getLogger().info("MCPC+ implementation found, but the custom tool config for mcMMO is disabled!");
|
||||
getLogger().info("To enable, set Mods.Tool_Mods_Enabled to TRUE in config.yml.");
|
||||
}
|
||||
|
||||
if (!Config.getInstance().getArmorModsEnabled()) {
|
||||
getLogger().info("MCPC+ implementation found, but the custom armor config for mcMMO is disabled!");
|
||||
getLogger().info("To enable, set Mods.Armor_Mods_Enabled to TRUE in config.yml.");
|
||||
}
|
||||
|
||||
if (!Config.getInstance().getBlockModsEnabled()) {
|
||||
getLogger().info("MCPC+ implementation found, but the custom block config for mcMMO is disabled!");
|
||||
getLogger().info("To enable, set Mods.Block_Mods_Enabled to TRUE in config.yml.");
|
||||
}
|
||||
|
||||
if (!Config.getInstance().getEntityModsEnabled()) {
|
||||
getLogger().info("MCPC+ implementation found, but the custom entity config for mcMMO is disabled!");
|
||||
getLogger().info("To enable, set Mods.Entity_Mods_Enabled to TRUE in config.yml.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -189,11 +189,7 @@ public final class PartyManager {
|
||||
public static Party getParty(Player player) {
|
||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
|
||||
|
||||
if (mcMMOPlayer != null) {
|
||||
return mcMMOPlayer.getParty();
|
||||
}
|
||||
|
||||
return getPlayerParty(player.getName());
|
||||
return mcMMOPlayer.getParty();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -246,8 +242,8 @@ public final class PartyManager {
|
||||
* @param party The party to remove
|
||||
*/
|
||||
public static void disbandParty(Party party) {
|
||||
for (String memberName : party.getMembers()) {
|
||||
processPartyLeaving(UserManager.getPlayer(memberName));
|
||||
for (Player member : party.getOnlineMembers()) {
|
||||
processPartyLeaving(UserManager.getPlayer(member));
|
||||
}
|
||||
|
||||
parties.remove(party);
|
||||
@@ -315,10 +311,11 @@ public final class PartyManager {
|
||||
public static void joinInvitedParty(McMMOPlayer mcMMOPlayer) {
|
||||
Party invite = mcMMOPlayer.getPartyInvite();
|
||||
|
||||
// // Pretty sure this isn't possible
|
||||
// if (!parties.contains(invite)) {
|
||||
// parties.add(invite);
|
||||
// }
|
||||
// Check if the party still exists, it might have been disbanded
|
||||
if (!parties.contains(invite)) {
|
||||
mcMMOPlayer.getPlayer().sendMessage(LocaleLoader.getString("Party.Disband"));
|
||||
return;
|
||||
}
|
||||
|
||||
mcMMOPlayer.getPlayer().sendMessage(LocaleLoader.getString("Commands.Invite.Accepted", invite.getName()));
|
||||
mcMMOPlayer.removePartyInvite();
|
||||
|
||||
@@ -1,19 +0,0 @@
|
||||
package com.gmail.nossr50.runnables;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.util.UpdateChecker;
|
||||
|
||||
/**
|
||||
* Async task
|
||||
*/
|
||||
public class UpdateCheckerTask implements Runnable {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
mcMMO.p.updateCheckerCallback(UpdateChecker.updateAvailable());
|
||||
}
|
||||
catch (Exception e) {
|
||||
mcMMO.p.updateCheckerCallback(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user