mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2026-02-21 11:13:00 +01:00
Compare commits
149 Commits
dev-1.4.09
...
dev-uuid-c
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a38d1176cb | ||
|
|
7d65b9422a | ||
|
|
e7ee31c291 | ||
|
|
23cbfc9038 | ||
|
|
c24c19f5f5 | ||
|
|
216ecc465d | ||
|
|
635f2bdb43 | ||
|
|
2286728308 | ||
|
|
f809bca47b | ||
|
|
71d6cb661f | ||
|
|
2248316ed3 | ||
|
|
9668bb2ee7 | ||
|
|
f0503c7797 | ||
|
|
9a12d86eac | ||
|
|
ed82a838c8 | ||
|
|
e6a7c8f5d2 | ||
|
|
fc393e1047 | ||
|
|
f8f73a49b5 | ||
|
|
a7841adec5 | ||
|
|
7917b84eca | ||
|
|
49f2bf5452 | ||
|
|
16b40c3eba | ||
|
|
1396d6d9ad | ||
|
|
b2015d68d1 | ||
|
|
a3066803d0 | ||
|
|
d02058ca13 | ||
|
|
7d0fd36a2a | ||
|
|
1c4ac1d766 | ||
|
|
7861e93497 | ||
|
|
7118f8850d | ||
|
|
384bb6306a | ||
|
|
8fd9982f69 | ||
|
|
c5e1a735f9 | ||
|
|
80754b4426 | ||
|
|
4524a3e437 | ||
|
|
83c8d3cdb9 | ||
|
|
ed95cfcbfc | ||
|
|
69ebde052d | ||
|
|
072e7c8b19 | ||
|
|
792f21bc20 | ||
|
|
e619e01c23 | ||
|
|
e7d5aa17bf | ||
|
|
8d6f151a54 | ||
|
|
d3faff67ad | ||
|
|
dc21e18cc2 | ||
|
|
7643edfdcd | ||
|
|
48c7aa3e84 | ||
|
|
87bce65098 | ||
|
|
c288dc433b | ||
|
|
0cc29d070f | ||
|
|
8fd94b625c | ||
|
|
ccca3fff26 | ||
|
|
f77446919f | ||
|
|
96fdf265d5 | ||
|
|
b964e3f7c3 | ||
|
|
d93c83f775 | ||
|
|
6b9f6c29ec | ||
|
|
09b0bf62e2 | ||
|
|
15d7d3f8a2 | ||
|
|
dedbdf890a | ||
|
|
30085e1e34 | ||
|
|
1c30146491 | ||
|
|
037022b175 | ||
|
|
0aa67727f5 | ||
|
|
8e3e1d5f11 | ||
|
|
d2d70089ca | ||
|
|
94a566acc9 | ||
|
|
daab095557 | ||
|
|
2b9b5df1ee | ||
|
|
e7e62b8d40 | ||
|
|
3d242bbdb6 | ||
|
|
e796eae3c3 | ||
|
|
a257e83a62 | ||
|
|
d527584248 | ||
|
|
0a4de6e2fc | ||
|
|
4b20f12eff | ||
|
|
0de1187012 | ||
|
|
8e474170e4 | ||
|
|
2eeb9b1f35 | ||
|
|
3de6e2c3f1 | ||
|
|
98d166808f | ||
|
|
f75e15dfdc | ||
|
|
f2b892b7d5 | ||
|
|
883ada01f8 | ||
|
|
3a8f45a04d | ||
|
|
906609696b | ||
|
|
66ccde4310 | ||
|
|
4970cdc3f4 | ||
|
|
1becc874ba | ||
|
|
b107a8dc7c | ||
|
|
37aebc1716 | ||
|
|
836877ff93 | ||
|
|
28a846e0cb | ||
|
|
0185a30ec9 | ||
|
|
38e1947302 | ||
|
|
4fb4d6fc0c | ||
|
|
6d719988bf | ||
|
|
b1c1f0e21e | ||
|
|
3f34cc7365 | ||
|
|
3c6c2837bd | ||
|
|
4bcef76fd8 | ||
|
|
2fd5d7aa81 | ||
|
|
5080c68dce | ||
|
|
3403aef37d | ||
|
|
53a34c12d2 | ||
|
|
59417d6721 | ||
|
|
93d63dbca5 | ||
|
|
4643cf1070 | ||
|
|
91bf54019e | ||
|
|
ead716ef0d | ||
|
|
8fec1af257 | ||
|
|
99248caba3 | ||
|
|
af64bdf742 | ||
|
|
66a4925371 | ||
|
|
8eb6acd60f | ||
|
|
ce6892f2e6 | ||
|
|
c14a4e9305 | ||
|
|
5825eb1696 | ||
|
|
bfebbd0095 | ||
|
|
b204507a82 | ||
|
|
9f53426511 | ||
|
|
03c2282c3f | ||
|
|
20092d55fd | ||
|
|
69a2a5cfff | ||
|
|
618cfad100 | ||
|
|
56e625a9df | ||
|
|
79a1ef5d3e | ||
|
|
10dd7619bf | ||
|
|
f9dfec5bd0 | ||
|
|
a9488bc18b | ||
|
|
f0ee708710 | ||
|
|
3390a31cc6 | ||
|
|
0b4b272223 | ||
|
|
8d200ea653 | ||
|
|
eb359c5595 | ||
|
|
e1b8088c17 | ||
|
|
70a1eea231 | ||
|
|
c744974192 | ||
|
|
faa11a87a9 | ||
|
|
91da5c4ab1 | ||
|
|
da5e770e06 | ||
|
|
09557e378b | ||
|
|
72d26fed0f | ||
|
|
225de799e8 | ||
|
|
334c44760f | ||
|
|
ac7fc1020d | ||
|
|
461871327b | ||
|
|
60ddd799de | ||
|
|
80571fbe8f |
@@ -7,7 +7,7 @@ Key:
|
|||||||
! Change
|
! Change
|
||||||
- Removal
|
- Removal
|
||||||
|
|
||||||
Version 1.4.09-dev
|
Version 1.5.01-dev
|
||||||
+ Added new child skill; Salvage
|
+ Added new child skill; Salvage
|
||||||
+ Added new feature to Herbalism. Instantly-regrown crops are protected from being broken for 1 second
|
+ Added new feature to Herbalism. Instantly-regrown crops are protected from being broken for 1 second
|
||||||
+ Added option to config.yml to show the /mcstats scoreboard automatically after logging in
|
+ Added option to config.yml to show the /mcstats scoreboard automatically after logging in
|
||||||
@@ -15,17 +15,50 @@ Version 1.4.09-dev
|
|||||||
+ Added support for `MATERIAL|data` format in treasures.yml
|
+ Added support for `MATERIAL|data` format in treasures.yml
|
||||||
+ Added API to experience events to get XP gain reason
|
+ Added API to experience events to get XP gain reason
|
||||||
+ Added API to check if an entity is bleeding
|
+ Added API to check if an entity is bleeding
|
||||||
|
+ Added options to tools.yml and armor.yml config files to set a pretty repair material name
|
||||||
|
+ Added full support for repairables in tools.yml and armor.yml config files
|
||||||
|
+ Added new API class SkillAPI used to get a list of valid skill names
|
||||||
|
= Fixed bug where pistons would mess with the block tracking
|
||||||
= Fixed bug where the Updater was running on the main thread.
|
= Fixed bug where the Updater was running on the main thread.
|
||||||
= Fixed bug when players would use /ptp without being in a party
|
= Fixed bug when players would use /ptp without being in a party
|
||||||
= Fixed bug where player didn't have a mcMMOPlayer object in AsyncPlayerChatEvent
|
= Fixed bug where player didn't have a mcMMOPlayer object in AsyncPlayerChatEvent
|
||||||
= Fixed bug where dodge would check the wrong player skill level
|
= Fixed bug where dodge would check the wrong player skill level
|
||||||
= Fixed bug which causes /party teleport to stop working
|
= Fixed bug which causes /party teleport to stop working
|
||||||
= Fixed bug where SaveTimerTask would produce an IndexOutOfBoundsException
|
= Fixed bug where SaveTimerTask would produce an IndexOutOfBoundsException
|
||||||
|
= Fixed bug where Alchemy would not fire BrewEvents
|
||||||
|
= Fixed bug with setting custom names and lore in treasures config
|
||||||
|
= Fixed bug which would cause a NullPointerException with getFlowerAndGrassXp()
|
||||||
|
= Fixed bug which could cause and SQLException regarding the connection property 'maxReconnects'.
|
||||||
|
= Fixed bug where falling blocks were incorrectly tracked
|
||||||
|
= Fixed bug where items would get deleted when in Berserk with a full inventory
|
||||||
|
= Fixed bug where the console would not correctly show party chat colors
|
||||||
|
= Fixed bug where party chat was using non thread safe methods
|
||||||
|
= Fixed bug where Blast Mining unlock levels could be to high in certain occasions
|
||||||
|
= Fixed bug where Blast Minings ability "Demolition Expert" would not work
|
||||||
|
! Changed SecondaryAbilityEvent to implement Cancellable and it now gets fired for damage related secondary abilities
|
||||||
|
! Changed the way mcMMO handles bonus damage, updated for the new damage event API
|
||||||
! Changed player data saving. Save tasks are now asynchronous
|
! Changed player data saving. Save tasks are now asynchronous
|
||||||
! Vanished players no longer get hit by AoE effects
|
! Vanished players no longer get hit by AoE effects
|
||||||
! Changed Alchemy config option 'Prevent_Hopper_Transfer' renamed to 'Prevent_Hopper_Transfer_Ingredients'
|
! Changed Alchemy config option 'Prevent_Hopper_Transfer' renamed to 'Prevent_Hopper_Transfer_Ingredients'
|
||||||
|
! Changed Alchemy XP distribution. XP is granted based on the stage of the potion.
|
||||||
|
! Changed behavior of the Blast Mining ability "Demolition Expert"; now only decreases damage for the ability user
|
||||||
|
! Updated for new getOnlinePlayers() behavior
|
||||||
- Removed salvage ability from Repair, salvage has it's own (child) skill now
|
- Removed salvage ability from Repair, salvage has it's own (child) skill now
|
||||||
|
|
||||||
|
Version 1.5.00
|
||||||
|
+ Added Podzol & Red Sand to Excavation
|
||||||
|
+ Added Hardened Clay, Stained Clay, and Packed Ice to Mining blocks
|
||||||
|
+ Added Acacia and Dark Oak to Woodcutting blocks
|
||||||
|
+ Added Salmon, Clownfish, and Pufferfish to Fishing XP
|
||||||
|
+ Added new flowers and grasses to Herbalism XP
|
||||||
|
+ Added option to config.yml which allows players to always catch fish, even when a treasure is found
|
||||||
|
+ Added option to config.yml to override vanilla Minecraft treasures
|
||||||
|
! Fishing XP now depends on the type of fish.
|
||||||
|
! Woodcutting XP in experience.yml and Woodcutting double drops in config.yml now use the tree species names. Oak is now Generic, and Spruce is now Redwood.
|
||||||
|
! Red_Rose was replaced by Poppy, and so the key in experience.yml has been updated accordingly.
|
||||||
|
- Removed deprecated permission nodes
|
||||||
|
- Removed "Treasure found!" message
|
||||||
|
|
||||||
Version 1.4.08
|
Version 1.4.08
|
||||||
+ Added a new skill; Alchemy. Special thanks to EasyMFnE for creating this!
|
+ Added a new skill; Alchemy. Special thanks to EasyMFnE for creating this!
|
||||||
+ Added SecondaryAbilityType enum, and new SecondaryAbilityWeightedActivationCheckEvent, fired when a secondary ability checkes its activation chances
|
+ Added SecondaryAbilityType enum, and new SecondaryAbilityWeightedActivationCheckEvent, fired when a secondary ability checkes its activation chances
|
||||||
|
|||||||
132
extras/mods/1.7.x/twilightforest.armor.yml
Normal file
132
extras/mods/1.7.x/twilightforest.armor.yml
Normal file
@@ -0,0 +1,132 @@
|
|||||||
|
# Config created by joulesbeef
|
||||||
|
# Created For twilightforest-2.2.3
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# Settings for Boots
|
||||||
|
###
|
||||||
|
Boots:
|
||||||
|
# Ironwood
|
||||||
|
TWILIGHTFOREST_ITEM_IRONWOODBOOTS:
|
||||||
|
Repairable: true
|
||||||
|
Repair_Material: TWILIGHTFOREST_ITEM_IRONWOODINGOT
|
||||||
|
Repair_Material_Data_Value: 0
|
||||||
|
Repair_Material_Quantity: 2
|
||||||
|
Durability: 500
|
||||||
|
# Fiery
|
||||||
|
TWILIGHTFOREST_ITEM_FIERYBOOTS:
|
||||||
|
Repairable: true
|
||||||
|
Repair_Material: TWILIGHTFOREST_ITEM_FIERYINGOT
|
||||||
|
Repair_Material_Data_Value: 0
|
||||||
|
Repair_Material_Quantity: 2
|
||||||
|
Durability: 500
|
||||||
|
# Stealeaf
|
||||||
|
TWILIGHTFOREST_ITEM_STEELEAFBOOTS:
|
||||||
|
Repairable: true
|
||||||
|
Repair_Material: TWILIGHTFOREST_ITEM_STEELEAFINGOT
|
||||||
|
Repair_Material_Data_Value: 0
|
||||||
|
Repair_Material_Quantity: 2
|
||||||
|
Durability: 500
|
||||||
|
# Knightmetal
|
||||||
|
TWILIGHTFOREST_ITEM_KNIGHTLYBOOTS:
|
||||||
|
Repairable: true
|
||||||
|
Repair_Material: TWILIGHTFOREST_ITEM_KNIGHTMETAL
|
||||||
|
Repair_Material_Data_Value: 0
|
||||||
|
Repair_Material_Quantity: 2
|
||||||
|
Durability: 500
|
||||||
|
|
||||||
|
#
|
||||||
|
# Settings for Chestplates
|
||||||
|
###
|
||||||
|
Chestplates:
|
||||||
|
# Ironwood
|
||||||
|
TWILIGHTFOREST_ITEM_IRONWOODPLATE:
|
||||||
|
Repairable: true
|
||||||
|
Repair_Material: TWILIGHTFOREST_ITEM_IRONWOODINGOT
|
||||||
|
Repair_Material_Data_Value: 0
|
||||||
|
Repair_Material_Quantity: 2
|
||||||
|
Durability: 500
|
||||||
|
# Fiery
|
||||||
|
TWILIGHTFOREST_ITEM_FIERYPLATE:
|
||||||
|
Repairable: true
|
||||||
|
Repair_Material: TWILIGHTFOREST_ITEM_FIERYINGOT
|
||||||
|
Repair_Material_Data_Value: 0
|
||||||
|
Repair_Material_Quantity: 2
|
||||||
|
Durability: 500
|
||||||
|
# Stealeaf
|
||||||
|
TWILIGHTFOREST_ITEM_STEELEAFPLATE:
|
||||||
|
Repairable: true
|
||||||
|
Repair_Material: TWILIGHTFOREST_ITEM_STEELEAFINGOT
|
||||||
|
Repair_Material_Data_Value: 0
|
||||||
|
Repair_Material_Quantity: 2
|
||||||
|
Durability: 500
|
||||||
|
# Knightmetal
|
||||||
|
TWILIGHTFOREST_ITEM_KNIGHTLYPLATE:
|
||||||
|
Repairable: true
|
||||||
|
Repair_Material: TWILIGHTFOREST_ITEM_KNIGHTMETAL
|
||||||
|
Repair_Material_Data_Value: 0
|
||||||
|
Repair_Material_Quantity: 2
|
||||||
|
Durability: 500
|
||||||
|
|
||||||
|
#
|
||||||
|
# Settings for Helmets
|
||||||
|
###
|
||||||
|
Helmets:
|
||||||
|
# Ironwood
|
||||||
|
TWILIGHTFOREST_ITEM_IRONWOODHELM:
|
||||||
|
Repairable: true
|
||||||
|
Repair_Material: TWILIGHTFOREST_ITEM_IRONWOODINGOT
|
||||||
|
Repair_Material_Data_Value: 0
|
||||||
|
Repair_Material_Quantity: 2
|
||||||
|
Durability: 500
|
||||||
|
# Fiery
|
||||||
|
TWILIGHTFOREST_ITEM_FIERYHELM:
|
||||||
|
Repairable: true
|
||||||
|
Repair_Material: TWILIGHTFOREST_ITEM_FIERYINGOT
|
||||||
|
Repair_Material_Data_Value: 0
|
||||||
|
Repair_Material_Quantity: 2
|
||||||
|
Durability: 500
|
||||||
|
# Stealeaf
|
||||||
|
TWILIGHTFOREST_ITEM_STEELEAFHELM:
|
||||||
|
Repairable: true
|
||||||
|
Repair_Material: TWILIGHTFOREST_ITEM_STEELEAFINGOT
|
||||||
|
Repair_Material_Data_Value: 0
|
||||||
|
Repair_Material_Quantity: 2
|
||||||
|
Durability: 500
|
||||||
|
# Knightmetal
|
||||||
|
TWILIGHTFOREST_ITEM_KNIGHTLYHELM:
|
||||||
|
Repairable: true
|
||||||
|
Repair_Material: TWILIGHTFOREST_ITEM_KNIGHTMETAL
|
||||||
|
Repair_Material_Data_Value: 0
|
||||||
|
Repair_Material_Quantity: 2
|
||||||
|
Durability: 50
|
||||||
|
# Settings for Leggings
|
||||||
|
###
|
||||||
|
Leggings:
|
||||||
|
# Ironwood
|
||||||
|
TWILIGHTFOREST_ITEM_IRONWOODLEGS:
|
||||||
|
Repairable: true
|
||||||
|
Repair_Material: TWILIGHTFOREST_ITEM_IRONWOODINGOT
|
||||||
|
Repair_Material_Data_Value: 0
|
||||||
|
Repair_Material_Quantity: 2
|
||||||
|
Durability: 500
|
||||||
|
# Fiery
|
||||||
|
TWILIGHTFOREST_ITEM_FIERYLEGS:
|
||||||
|
Repairable: true
|
||||||
|
Repair_Material: TWILIGHTFOREST_ITEM_FIERYINGOT
|
||||||
|
Repair_Material_Data_Value: 0
|
||||||
|
Repair_Material_Quantity: 2
|
||||||
|
Durability: 500
|
||||||
|
# Stealeaf
|
||||||
|
TWILIGHTFOREST_ITEM_STEELEAFLEGS:
|
||||||
|
Repairable: true
|
||||||
|
Repair_Material: TWILIGHTFOREST_ITEM_STEELEAFINGOT
|
||||||
|
Repair_Material_Data_Value: 0
|
||||||
|
Repair_Material_Quantity: 2
|
||||||
|
Durability: 500
|
||||||
|
# Knightmetal
|
||||||
|
TWILIGHTFOREST_ITEM_KNIGHTLYLEGS:
|
||||||
|
Repairable: true
|
||||||
|
Repair_Material: TWILIGHTFOREST_ITEM_KNIGHTMETAL
|
||||||
|
Repair_Material_Data_Value: 0
|
||||||
|
Repair_Material_Quantity: 2
|
||||||
|
Durability: 500
|
||||||
116
extras/mods/1.7.x/twilightforest.blocks.yml
Normal file
116
extras/mods/1.7.x/twilightforest.blocks.yml
Normal file
@@ -0,0 +1,116 @@
|
|||||||
|
# Config created by joulesbeef
|
||||||
|
# Created For twilightforest-2.2.3
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# Settings for Custom Herbalism Blocks
|
||||||
|
###
|
||||||
|
Herbalism:
|
||||||
|
# Mushgloom
|
||||||
|
TWILIGHTFOREST_TILE_TFLOG|9:
|
||||||
|
XP_Gain: 150
|
||||||
|
Double_Drops_Enabled: true
|
||||||
|
# Torchberry Plant
|
||||||
|
TWILIGHTFOREST_TILE_TFLOG|13:
|
||||||
|
XP_Gain: 20
|
||||||
|
Double_Drops_Enabled: true
|
||||||
|
# Mayapple
|
||||||
|
TWILIGHTFOREST_TILE_TFLOG|4:
|
||||||
|
XP_Gain: 30
|
||||||
|
Double_Drops_Enabled: true
|
||||||
|
# Fiddlehead
|
||||||
|
TWILIGHTFOREST_TILE_TFLOG|8:
|
||||||
|
XP_Gain: 35
|
||||||
|
Double_Drops_Enabled: true
|
||||||
|
|
||||||
|
|
||||||
|
#
|
||||||
|
# Settings for Custom Mining Blocks
|
||||||
|
###
|
||||||
|
Mining:
|
||||||
|
# Mazestone
|
||||||
|
TWILIGHTFOREST_TILE_TFMAZESTONE|0:
|
||||||
|
XP_Gain: 250
|
||||||
|
Double_Drops_Enabled: true
|
||||||
|
Is_Ore: false
|
||||||
|
TWILIGHTFOREST_TILE_TFMAZESTONE|1:
|
||||||
|
XP_Gain: 250
|
||||||
|
Double_Drops_Enabled: true
|
||||||
|
Is_Ore: false
|
||||||
|
TWILIGHTFOREST_TILE_TFMAZESTONE|2:
|
||||||
|
XP_Gain: 250
|
||||||
|
Double_Drops_Enabled: true
|
||||||
|
Is_Ore: false
|
||||||
|
TWILIGHTFOREST_TILE_TFMAZESTONE|3:
|
||||||
|
XP_Gain: 250
|
||||||
|
Double_Drops_Enabled: true
|
||||||
|
Is_Ore: false
|
||||||
|
TWILIGHTFOREST_TILE_TFMAZESTONE|4:
|
||||||
|
XP_Gain: 250
|
||||||
|
Double_Drops_Enabled: true
|
||||||
|
Is_Ore: false
|
||||||
|
TWILIGHTFOREST_TILE_TFMAZESTONE|5:
|
||||||
|
XP_Gain: 250
|
||||||
|
Double_Drops_Enabled: true
|
||||||
|
Is_Ore: false
|
||||||
|
TWILIGHTFOREST_TILE_TFMAZESTONE|6:
|
||||||
|
XP_Gain: 250
|
||||||
|
Double_Drops_Enabled: true
|
||||||
|
Is_Ore: false
|
||||||
|
TWILIGHTFOREST_TILE_TFMAZESTONE|7:
|
||||||
|
XP_Gain: 250
|
||||||
|
Double_Drops_Enabled: true
|
||||||
|
Is_Ore: false
|
||||||
|
|
||||||
|
#
|
||||||
|
# Settings for Custom Woodcutting Blocks
|
||||||
|
###
|
||||||
|
Woodcutting:
|
||||||
|
# Twilight Oak
|
||||||
|
TWILIGHTFOREST_TILE_TFLOG|0:
|
||||||
|
XP_Gain: 70
|
||||||
|
Double_Drops_Enabled: true
|
||||||
|
Is_Log: true
|
||||||
|
# Canopy
|
||||||
|
TWILIGHTFOREST_TILE_TFLOG|1:
|
||||||
|
XP_Gain: 80
|
||||||
|
Double_Drops_Enabled: true
|
||||||
|
Is_Log: true
|
||||||
|
# Mangrove
|
||||||
|
TWILIGHTFOREST_TILE_TFLOG|2:
|
||||||
|
XP_Gain: 90
|
||||||
|
Double_Drops_Enabled: true
|
||||||
|
Is_Log: true
|
||||||
|
# Darkwood
|
||||||
|
TWILIGHTFOREST_TILE_TFLOG|3:
|
||||||
|
XP_Gain: 100
|
||||||
|
Double_Drops_Enabled: true
|
||||||
|
Is_Log: true
|
||||||
|
# Roots
|
||||||
|
TWILIGHTFOREST_TILE_TFROOTS|0:
|
||||||
|
XP_Gain: 10
|
||||||
|
Double_Drops_Enabled: true
|
||||||
|
Is_Log: false
|
||||||
|
TWILIGHTFOREST_TILE_TFROOTS|1:
|
||||||
|
XP_Gain: 10
|
||||||
|
Double_Drops_Enabled: true
|
||||||
|
Is_Log: false
|
||||||
|
# Timewood
|
||||||
|
TWILIGHTFOREST_TILE_TFMAGICLOG|0:
|
||||||
|
XP_Gain: 1000
|
||||||
|
Double_Drops_Enabled: true
|
||||||
|
Is_Log: true
|
||||||
|
# Transwood
|
||||||
|
TWILIGHTFOREST_TILE_TFMAGICLOG|1:
|
||||||
|
XP_Gain: 1000
|
||||||
|
Double_Drops_Enabled: true
|
||||||
|
Is_Log: true
|
||||||
|
# Minewood
|
||||||
|
TWILIGHTFOREST_TILE_TFMAGICLOG|2:
|
||||||
|
XP_Gain: 1000
|
||||||
|
Double_Drops_Enabled: true
|
||||||
|
Is_Log: true
|
||||||
|
# Sortingwood
|
||||||
|
TWILIGHTFOREST_TILE_TFMAGICLOG|3:
|
||||||
|
XP_Gain: 1000
|
||||||
|
Double_Drops_Enabled: true
|
||||||
|
Is_Log: true
|
||||||
152
extras/mods/1.7.x/twilightforest.entities.yml
Normal file
152
extras/mods/1.7.x/twilightforest.entities.yml
Normal file
@@ -0,0 +1,152 @@
|
|||||||
|
# Config created by joulesbeef
|
||||||
|
# Created For twilightforest-2.2.3
|
||||||
|
#
|
||||||
|
# Settings for Custom Mobs
|
||||||
|
MoCreatures-Ogre:
|
||||||
|
Class: Monster
|
||||||
|
XP_Multiplier: 1.0
|
||||||
|
Tameable: false
|
||||||
|
Taming_XP: 0
|
||||||
|
CanBeSummoned: false
|
||||||
|
COTW_Material: ''
|
||||||
|
COTW_Material_Data: 0
|
||||||
|
COTW_Material_Amount: 0
|
||||||
|
TwilightForest-TwilightLich:
|
||||||
|
Class: Monster
|
||||||
|
XP_Multiplier: 1.0
|
||||||
|
Tameable: false
|
||||||
|
Taming_XP: 0
|
||||||
|
CanBeSummoned: false
|
||||||
|
COTW_Material: ''
|
||||||
|
COTW_Material_Data: 0
|
||||||
|
COTW_Material_Amount: 0
|
||||||
|
TwilightForest-HelmetCrab:
|
||||||
|
Class: Monster
|
||||||
|
XP_Multiplier: 1.0
|
||||||
|
Tameable: false
|
||||||
|
Taming_XP: 0
|
||||||
|
CanBeSummoned: false
|
||||||
|
COTW_Material: ''
|
||||||
|
COTW_Material_Data: 0
|
||||||
|
COTW_Material_Amount: 0
|
||||||
|
TwilightForest-SlimeBeetle:
|
||||||
|
Class: Monster
|
||||||
|
XP_Multiplier: 1.0
|
||||||
|
Tameable: false
|
||||||
|
Taming_XP: 0
|
||||||
|
CanBeSummoned: false
|
||||||
|
COTW_Material: ''
|
||||||
|
COTW_Material_Data: 0
|
||||||
|
COTW_Material_Amount: 0
|
||||||
|
TwilightForest-TwilightWraith:
|
||||||
|
Class: Monster
|
||||||
|
XP_Multiplier: 1.0
|
||||||
|
Tameable: false
|
||||||
|
Taming_XP: 0
|
||||||
|
CanBeSummoned: false
|
||||||
|
COTW_Material: ''
|
||||||
|
COTW_Material_Data: 0
|
||||||
|
COTW_Material_Amount: 0
|
||||||
|
TwilightForest-Naga:
|
||||||
|
Class: Monster
|
||||||
|
XP_Multiplier: 1.0
|
||||||
|
Tameable: false
|
||||||
|
Taming_XP: 0
|
||||||
|
CanBeSummoned: false
|
||||||
|
COTW_Material: ''
|
||||||
|
COTW_Material_Data: 0
|
||||||
|
COTW_Material_Amount: 0
|
||||||
|
MoCreatures-Shark:
|
||||||
|
Class: Monster
|
||||||
|
XP_Multiplier: 1.0
|
||||||
|
Tameable: false
|
||||||
|
Taming_XP: 0
|
||||||
|
CanBeSummoned: false
|
||||||
|
COTW_Material: ''
|
||||||
|
COTW_Material_Data: 0
|
||||||
|
COTW_Material_Amount: 0
|
||||||
|
TwilightForest-TowerTermite:
|
||||||
|
Class: Monster
|
||||||
|
XP_Multiplier: 1.0
|
||||||
|
Tameable: false
|
||||||
|
Taming_XP: 0
|
||||||
|
CanBeSummoned: false
|
||||||
|
COTW_Material: ''
|
||||||
|
COTW_Material_Data: 0
|
||||||
|
COTW_Material_Amount: 0
|
||||||
|
MoCreatures-SmallFish:
|
||||||
|
Class: Monster
|
||||||
|
XP_Multiplier: 1.0
|
||||||
|
Tameable: false
|
||||||
|
Taming_XP: 0
|
||||||
|
CanBeSummoned: false
|
||||||
|
COTW_Material: ''
|
||||||
|
COTW_Material_Data: 0
|
||||||
|
COTW_Material_Amount: 0
|
||||||
|
TwilightForest-Redcap:
|
||||||
|
Class: Monster
|
||||||
|
XP_Multiplier: 1.0
|
||||||
|
Tameable: false
|
||||||
|
Taming_XP: 0
|
||||||
|
CanBeSummoned: false
|
||||||
|
COTW_Material: ''
|
||||||
|
COTW_Material_Data: 0
|
||||||
|
COTW_Material_Amount: 0
|
||||||
|
TwilightForest-YetiBoss:
|
||||||
|
Class: Monster
|
||||||
|
XP_Multiplier: 1.0
|
||||||
|
Tameable: false
|
||||||
|
Taming_XP: 0
|
||||||
|
CanBeSummoned: false
|
||||||
|
COTW_Material: ''
|
||||||
|
COTW_Material_Data: 0
|
||||||
|
COTW_Material_Amount: 0
|
||||||
|
MoCreatures-HellRat:
|
||||||
|
Class: Monster
|
||||||
|
XP_Multiplier: 1.0
|
||||||
|
Tameable: false
|
||||||
|
Taming_XP: 0
|
||||||
|
CanBeSummoned: false
|
||||||
|
COTW_Material: ''
|
||||||
|
COTW_Material_Data: 0
|
||||||
|
COTW_Material_Amount: 0
|
||||||
|
TwilightForest-Hydra:
|
||||||
|
XP_Multiplier: 1.0
|
||||||
|
Tameable: false
|
||||||
|
Taming_XP: 0
|
||||||
|
CanBeSummoned: false
|
||||||
|
COTW_Material: ''
|
||||||
|
COTW_Material_Data: 0
|
||||||
|
COTW_Material_Amount: 0
|
||||||
|
TwilightForest-Firefly:
|
||||||
|
XP_Multiplier: 1.0
|
||||||
|
Tameable: false
|
||||||
|
Taming_XP: 0
|
||||||
|
CanBeSummoned: false
|
||||||
|
COTW_Material: ''
|
||||||
|
COTW_Material_Data: 0
|
||||||
|
COTW_Material_Amount: 0
|
||||||
|
TwilightForest-KnightPhantom:
|
||||||
|
XP_Multiplier: 1.0
|
||||||
|
Tameable: false
|
||||||
|
Taming_XP: 0
|
||||||
|
CanBeSummoned: false
|
||||||
|
COTW_Material: ''
|
||||||
|
COTW_Material_Data: 0
|
||||||
|
COTW_Material_Amount: 0
|
||||||
|
TwilightForest-TowerGolem:
|
||||||
|
XP_Multiplier: 1.0
|
||||||
|
Tameable: false
|
||||||
|
Taming_XP: 0
|
||||||
|
CanBeSummoned: false
|
||||||
|
COTW_Material: ''
|
||||||
|
COTW_Material_Data: 0
|
||||||
|
COTW_Material_Amount: 0
|
||||||
|
MoCreatures-FishBowl:
|
||||||
|
XP_Multiplier: 1.0
|
||||||
|
Tameable: false
|
||||||
|
Taming_XP: 0
|
||||||
|
CanBeSummoned: false
|
||||||
|
COTW_Material: ''
|
||||||
|
COTW_Material_Data: 0
|
||||||
|
COTW_Material_Amount: 0
|
||||||
184
extras/mods/1.7.x/twilightforest.tools.yml
Normal file
184
extras/mods/1.7.x/twilightforest.tools.yml
Normal file
@@ -0,0 +1,184 @@
|
|||||||
|
# Config created by joulesbeef
|
||||||
|
# Created For twilightforest-2.2.3
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# Settings for Axes
|
||||||
|
###
|
||||||
|
Axes:
|
||||||
|
# Ironwood
|
||||||
|
TWILIGHTFOREST_ITEM_IRONWOODAXE:
|
||||||
|
XP_Modifer: 1.0
|
||||||
|
Ability_Enabled: true
|
||||||
|
Tier: 1
|
||||||
|
Repairable: true
|
||||||
|
Repair_Material: TWILIGHTFOREST_ITEM_IRONWOODINGOT
|
||||||
|
Repair_Material_Data_Value: 0
|
||||||
|
Repair_Material_Quantity: 2
|
||||||
|
Durability: 500
|
||||||
|
# Steeleaf
|
||||||
|
TWILIGHTFOREST_ITEM_STEELEAFAXE:
|
||||||
|
XP_Modifer: 1.0
|
||||||
|
Ability_Enabled: true
|
||||||
|
Tier: 1
|
||||||
|
Repairable: true
|
||||||
|
Repair_Material: TWILIGHTFOREST_ITEM_STEELEAFINGOT
|
||||||
|
Repair_Material_Data_Value: 0
|
||||||
|
Repair_Material_Quantity: 2
|
||||||
|
Durability: 500
|
||||||
|
# Knightmetal
|
||||||
|
TWILIGHTFOREST_ITEM_KNIGHTLYAXE:
|
||||||
|
XP_Modifer: 1.0
|
||||||
|
Ability_Enabled: true
|
||||||
|
Tier: 1
|
||||||
|
Repairable: true
|
||||||
|
Repair_Material: TWILIGHTFOREST_ITEM_KNIGHTMETAL
|
||||||
|
Repair_Material_Data_Value: 0
|
||||||
|
Repair_Material_Quantity: 2
|
||||||
|
Durability: 500
|
||||||
|
# Minotaur
|
||||||
|
TWILIGHTFOREST_ITEM_MINOTAURAXE:
|
||||||
|
XP_Modifer: 1.0
|
||||||
|
Ability_Enabled: true
|
||||||
|
Tier: 1
|
||||||
|
Repairable: true
|
||||||
|
Repair_Material: Diamond
|
||||||
|
Repair_Material_Data_Value: 0
|
||||||
|
Repair_Material_Quantity: 2
|
||||||
|
Durability: 500
|
||||||
|
#
|
||||||
|
# Settings for Hoes
|
||||||
|
###
|
||||||
|
Hoes:
|
||||||
|
# Ironwood
|
||||||
|
TWILIGHTFOREST_ITEM_IRONWOODHOE:
|
||||||
|
XP_Modifer: 1.0
|
||||||
|
Ability_Enabled: true
|
||||||
|
Tier: 1
|
||||||
|
Repairable: true
|
||||||
|
Repair_Material: TWILIGHTFOREST_ITEM_IRONWOODINGOT
|
||||||
|
Repair_Material_Data_Value: 0
|
||||||
|
Repair_Material_Quantity: 2
|
||||||
|
Durability: 500
|
||||||
|
# Steeleaf
|
||||||
|
TWILIGHTFOREST_ITEM_STEELEAFHOE:
|
||||||
|
XP_Modifer: 1.0
|
||||||
|
Ability_Enabled: true
|
||||||
|
Tier: 1
|
||||||
|
Repairable: true
|
||||||
|
Repair_Material: TWILIGHTFOREST_ITEM_STEELEAFINGOT
|
||||||
|
Repair_Material_Data_Value: 0
|
||||||
|
Repair_Material_Quantity: 2
|
||||||
|
Durability: 500
|
||||||
|
|
||||||
|
#
|
||||||
|
# Settings for Pickaxes
|
||||||
|
###
|
||||||
|
Pickaxes:
|
||||||
|
# Ironwood
|
||||||
|
TWILIGHTFOREST_ITEM_IRONWOODPICK:
|
||||||
|
XP_Modifer: 1.0
|
||||||
|
Ability_Enabled: true
|
||||||
|
Tier: 1
|
||||||
|
Repairable: true
|
||||||
|
Repair_Material: TWILIGHTFOREST_ITEM_IRONWOODINGOT
|
||||||
|
Repair_Material_Data_Value: 0
|
||||||
|
Repair_Material_Quantity: 2
|
||||||
|
Durability: 500
|
||||||
|
# Fiery
|
||||||
|
TWILIGHTFOREST_ITEM_FIERYPICK:
|
||||||
|
XP_Modifer: 1.0
|
||||||
|
Ability_Enabled: true
|
||||||
|
Tier: 1
|
||||||
|
Repairable: true
|
||||||
|
Repair_Material: TWILIGHTFOREST_ITEM_FIERYINGOT
|
||||||
|
Repair_Material_Data_Value: 0
|
||||||
|
Repair_Material_Quantity: 2
|
||||||
|
Durability: 500
|
||||||
|
# Steeleaf
|
||||||
|
TWILIGHTFOREST_ITEM_STEELEAFPICK:
|
||||||
|
XP_Modifer: 1.0
|
||||||
|
Ability_Enabled: true
|
||||||
|
Tier: 1
|
||||||
|
Repairable: true
|
||||||
|
Repair_Material: TWILIGHTFOREST_ITEM_STEELEAFINGOT
|
||||||
|
Repair_Material_Data_Value: 0
|
||||||
|
Repair_Material_Quantity: 2
|
||||||
|
Durability: 500
|
||||||
|
# Knightmetal
|
||||||
|
TWILIGHTFOREST_ITEM_KNIGHTLYPICK:
|
||||||
|
XP_Modifer: 1.0
|
||||||
|
Ability_Enabled: true
|
||||||
|
Tier: 1
|
||||||
|
Repairable: true
|
||||||
|
Repair_Material: TWILIGHTFOREST_ITEM_KNIGHTMETAL
|
||||||
|
Repair_Material_Data_Value: 0
|
||||||
|
Repair_Material_Quantity: 2
|
||||||
|
Durability: 500
|
||||||
|
#
|
||||||
|
# Settings for Shovels
|
||||||
|
###
|
||||||
|
Shovels:
|
||||||
|
# Ironwood
|
||||||
|
TWILIGHTFOREST_ITEM_IRONWOODSHOVEL:
|
||||||
|
XP_Modifer: 1.0
|
||||||
|
Ability_Enabled: true
|
||||||
|
Tier: 1
|
||||||
|
Repairable: true
|
||||||
|
Repair_Material: TWILIGHTFOREST_ITEM_IRONWOODINGOT
|
||||||
|
Repair_Material_Data_Value: 0
|
||||||
|
Repair_Material_Quantity: 2
|
||||||
|
Durability: 500
|
||||||
|
# Steeleaf
|
||||||
|
TWILIGHTFOREST_ITEM_STEELEAFSHOVEL:
|
||||||
|
XP_Modifer: 1.0
|
||||||
|
Ability_Enabled: true
|
||||||
|
Tier: 1
|
||||||
|
Repairable: true
|
||||||
|
Repair_Material: TWILIGHTFOREST_ITEM_STEELEAFINGOT
|
||||||
|
Repair_Material_Data_Value: 0
|
||||||
|
Repair_Material_Quantity: 2
|
||||||
|
Durability: 500
|
||||||
|
#
|
||||||
|
# Settings for Swords
|
||||||
|
###
|
||||||
|
Swords:
|
||||||
|
# Ironwood
|
||||||
|
TWILIGHTFOREST_ITEM_IRONWOODSWORD:
|
||||||
|
XP_Modifer: 1.0
|
||||||
|
Ability_Enabled: true
|
||||||
|
Tier: 1
|
||||||
|
Repairable: true
|
||||||
|
Repair_Material: TWILIGHTFOREST_ITEM_IRONWOODINGOT
|
||||||
|
Repair_Material_Data_Value: 0
|
||||||
|
Repair_Material_Quantity: 2
|
||||||
|
Durability: 500
|
||||||
|
# Fiery
|
||||||
|
TWILIGHTFOREST_ITEM_FIERYSWORD:
|
||||||
|
XP_Modifer: 1.0
|
||||||
|
Ability_Enabled: true
|
||||||
|
Tier: 1
|
||||||
|
Repairable: true
|
||||||
|
Repair_Material: TWILIGHTFOREST_ITEM_FIERYINGOT
|
||||||
|
Repair_Material_Data_Value: 0
|
||||||
|
Repair_Material_Quantity: 2
|
||||||
|
Durability: 500
|
||||||
|
# Steeleaf
|
||||||
|
TWILIGHTFOREST_ITEM_STEELEAFSWORD:
|
||||||
|
XP_Modifer: 1.0
|
||||||
|
Ability_Enabled: true
|
||||||
|
Tier: 1
|
||||||
|
Repairable: true
|
||||||
|
Repair_Material: TWILIGHTFOREST_ITEM_STEELEAFINGOT
|
||||||
|
Repair_Material_Data_Value: 0
|
||||||
|
Repair_Material_Quantity: 2
|
||||||
|
Durability: 500
|
||||||
|
# Knightmetal
|
||||||
|
TWILIGHTFOREST_ITEM_KNIGHTLYSWORD:
|
||||||
|
XP_Modifer: 1.0
|
||||||
|
Ability_Enabled: true
|
||||||
|
Tier: 1
|
||||||
|
Repairable: true
|
||||||
|
Repair_Material: TWILIGHTFOREST_ITEM_KNIGHTMETAL
|
||||||
|
Repair_Material_Data_Value: 0
|
||||||
|
Repair_Material_Quantity: 2
|
||||||
|
Durability: 500
|
||||||
19
pom.xml
19
pom.xml
@@ -2,7 +2,7 @@
|
|||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>com.gmail.nossr50.mcMMO</groupId>
|
<groupId>com.gmail.nossr50.mcMMO</groupId>
|
||||||
<artifactId>mcMMO</artifactId>
|
<artifactId>mcMMO</artifactId>
|
||||||
<version>1.4.09-SNAPSHOT</version>
|
<version>1.5.01-SNAPSHOT</version>
|
||||||
<name>mcMMO</name>
|
<name>mcMMO</name>
|
||||||
<url>https://github.com/mcMMO-Dev/mcMMO</url>
|
<url>https://github.com/mcMMO-Dev/mcMMO</url>
|
||||||
<issueManagement>
|
<issueManagement>
|
||||||
@@ -76,6 +76,8 @@
|
|||||||
<artifactSet>
|
<artifactSet>
|
||||||
<includes>
|
<includes>
|
||||||
<include>com.turt2live.metrics:MetricsExtension</include>
|
<include>com.turt2live.metrics:MetricsExtension</include>
|
||||||
|
<include>commons-logging:commons-logging</include>
|
||||||
|
<include>net.snaq:dbpool</include>
|
||||||
</includes>
|
</includes>
|
||||||
</artifactSet>
|
</artifactSet>
|
||||||
<relocations>
|
<relocations>
|
||||||
@@ -83,6 +85,14 @@
|
|||||||
<pattern>com.turt2live.metrics</pattern>
|
<pattern>com.turt2live.metrics</pattern>
|
||||||
<shadedPattern>com.gmail.nossr50.metrics.mcstats</shadedPattern>
|
<shadedPattern>com.gmail.nossr50.metrics.mcstats</shadedPattern>
|
||||||
</relocation>
|
</relocation>
|
||||||
|
<relocation>
|
||||||
|
<pattern>org.apache.commons.logging</pattern>
|
||||||
|
<shadedPattern>com.gmail.nossr50.commons.logging</shadedPattern>
|
||||||
|
</relocation>
|
||||||
|
<relocation>
|
||||||
|
<pattern>net.snaq</pattern>
|
||||||
|
<shadedPattern>com.gmail.nossr50.dbpool</shadedPattern>
|
||||||
|
</relocation>
|
||||||
</relocations>
|
</relocations>
|
||||||
</configuration>
|
</configuration>
|
||||||
<executions>
|
<executions>
|
||||||
@@ -121,7 +131,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.bukkit</groupId>
|
<groupId>org.bukkit</groupId>
|
||||||
<artifactId>bukkit</artifactId>
|
<artifactId>bukkit</artifactId>
|
||||||
<version>1.6.4-R2.0</version>
|
<version>LATEST</version>
|
||||||
<type>jar</type>
|
<type>jar</type>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
@@ -136,6 +146,11 @@
|
|||||||
<artifactId>MetricsExtension</artifactId>
|
<artifactId>MetricsExtension</artifactId>
|
||||||
<version>0.0.5-SNAPSHOT</version>
|
<version>0.0.5-SNAPSHOT</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>net.snaq</groupId>
|
||||||
|
<artifactId>dbpool</artifactId>
|
||||||
|
<version>5.1</version>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
<distributionManagement>
|
<distributionManagement>
|
||||||
<repository>
|
<repository>
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.gmail.nossr50.api;
|
package com.gmail.nossr50.api;
|
||||||
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@@ -86,6 +87,14 @@ public final class ExperienceAPI {
|
|||||||
UserManager.getPlayer(player).applyXpGain(getSkillType(skillType), XP, getXPGainReason(xpGainReason));
|
UserManager.getPlayer(player).applyXpGain(getSkillType(skillType), XP, getXPGainReason(xpGainReason));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds raw XP to an offline player.
|
||||||
|
* </br>
|
||||||
|
* This function is designed for API usage.
|
||||||
|
*
|
||||||
|
* @deprecated We're using float for our XP values now
|
||||||
|
* replaced by {@link #addRawXPOffline(String playerName, String skillType, float XP)}
|
||||||
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public static void addRawXPOffline(String playerName, String skillType, int XP) {
|
public static void addRawXPOffline(String playerName, String skillType, int XP) {
|
||||||
addRawXPOffline(playerName, skillType, (float) XP);
|
addRawXPOffline(playerName, skillType, (float) XP);
|
||||||
@@ -96,6 +105,9 @@ public final class ExperienceAPI {
|
|||||||
* </br>
|
* </br>
|
||||||
* This function is designed for API usage.
|
* This function is designed for API usage.
|
||||||
*
|
*
|
||||||
|
* @deprecated We're using uuids to get an offline player
|
||||||
|
* replaced by {@link #addRawXPOffline(UUID uuid, String skillType, float XP)}
|
||||||
|
*
|
||||||
* @param playerName The player to add XP to
|
* @param playerName The player to add XP to
|
||||||
* @param skillType The skill to add XP to
|
* @param skillType The skill to add XP to
|
||||||
* @param XP The amount of XP to add
|
* @param XP The amount of XP to add
|
||||||
@@ -103,10 +115,27 @@ public final class ExperienceAPI {
|
|||||||
* @throws InvalidSkillException if the given skill is not valid
|
* @throws InvalidSkillException if the given skill is not valid
|
||||||
* @throws InvalidPlayerException if the given player does not exist in the database
|
* @throws InvalidPlayerException if the given player does not exist in the database
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
public static void addRawXPOffline(String playerName, String skillType, float XP) {
|
public static void addRawXPOffline(String playerName, String skillType, float XP) {
|
||||||
addOfflineXP(playerName, getSkillType(skillType), (int) Math.floor(XP));
|
addOfflineXP(playerName, getSkillType(skillType), (int) Math.floor(XP));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds raw XP to an offline player.
|
||||||
|
* </br>
|
||||||
|
* This function is designed for API usage.
|
||||||
|
*
|
||||||
|
* @param uuid The UUID of player to add XP to
|
||||||
|
* @param skillType The skill to add XP to
|
||||||
|
* @param XP The amount of XP to add
|
||||||
|
*
|
||||||
|
* @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(UUID uuid, String skillType, float XP) {
|
||||||
|
addOfflineXP(uuid, getSkillType(skillType), (int) Math.floor(XP));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds XP to the player, calculates for XP Rate only.
|
* Adds XP to the player, calculates for XP Rate only.
|
||||||
* </br>
|
* </br>
|
||||||
@@ -152,6 +181,7 @@ public final class ExperienceAPI {
|
|||||||
* @throws InvalidSkillException if the given skill is not valid
|
* @throws InvalidSkillException if the given skill is not valid
|
||||||
* @throws InvalidPlayerException if the given player does not exist in the database
|
* @throws InvalidPlayerException if the given player does not exist in the database
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
public static void addMultipliedXPOffline(String playerName, String skillType, int XP) {
|
public static void addMultipliedXPOffline(String playerName, String skillType, int XP) {
|
||||||
addOfflineXP(playerName, getSkillType(skillType), (int) (XP * ExperienceConfig.getInstance().getExperienceGainsGlobalMultiplier()));
|
addOfflineXP(playerName, getSkillType(skillType), (int) (XP * ExperienceConfig.getInstance().getExperienceGainsGlobalMultiplier()));
|
||||||
}
|
}
|
||||||
@@ -203,6 +233,7 @@ public final class ExperienceAPI {
|
|||||||
* @throws InvalidSkillException if the given skill is not valid
|
* @throws InvalidSkillException if the given skill is not valid
|
||||||
* @throws InvalidPlayerException if the given player does not exist in the database
|
* @throws InvalidPlayerException if the given player does not exist in the database
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
public static void addModifiedXPOffline(String playerName, String skillType, int XP) {
|
public static void addModifiedXPOffline(String playerName, String skillType, int XP) {
|
||||||
SkillType skill = getSkillType(skillType);
|
SkillType skill = getSkillType(skillType);
|
||||||
|
|
||||||
@@ -273,10 +304,28 @@ public final class ExperienceAPI {
|
|||||||
* @throws InvalidPlayerException if the given player does not exist in the database
|
* @throws InvalidPlayerException if the given player does not exist in the database
|
||||||
* @throws UnsupportedOperationException if the given skill is a child skill
|
* @throws UnsupportedOperationException if the given skill is a child skill
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
public static int getOfflineXP(String playerName, String skillType) {
|
public static int getOfflineXP(String playerName, String skillType) {
|
||||||
return getOfflineProfile(playerName).getSkillXpLevel(getNonChildSkillType(skillType));
|
return getOfflineProfile(playerName).getSkillXpLevel(getNonChildSkillType(skillType));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the amount of XP an offline player has in a specific skill.
|
||||||
|
* </br>
|
||||||
|
* This function is designed for API usage.
|
||||||
|
*
|
||||||
|
* @param uuid The player to get XP for
|
||||||
|
* @param skillType The skill to get XP for
|
||||||
|
* @return the amount of XP in a given skill
|
||||||
|
*
|
||||||
|
* @throws InvalidSkillException if the given skill is not valid
|
||||||
|
* @throws InvalidPlayerException if the given player does not exist in the database
|
||||||
|
* @throws UnsupportedOperationException if the given skill is a child skill
|
||||||
|
*/
|
||||||
|
public static int getOfflineXP(UUID uuid, String skillType) {
|
||||||
|
return getOfflineProfile(uuid).getSkillXpLevel(getNonChildSkillType(skillType));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the raw amount of XP a player has in a specific skill.
|
* Get the raw amount of XP a player has in a specific skill.
|
||||||
* </br>
|
* </br>
|
||||||
@@ -306,10 +355,28 @@ public final class ExperienceAPI {
|
|||||||
* @throws InvalidPlayerException if the given player does not exist in the database
|
* @throws InvalidPlayerException if the given player does not exist in the database
|
||||||
* @throws UnsupportedOperationException if the given skill is a child skill
|
* @throws UnsupportedOperationException if the given skill is a child skill
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
public static float getOfflineXPRaw(String playerName, String skillType) {
|
public static float getOfflineXPRaw(String playerName, String skillType) {
|
||||||
return getOfflineProfile(playerName).getSkillXpLevelRaw(getNonChildSkillType(skillType));
|
return getOfflineProfile(playerName).getSkillXpLevelRaw(getNonChildSkillType(skillType));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the raw amount of XP an offline player has in a specific skill.
|
||||||
|
* </br>
|
||||||
|
* This function is designed for API usage.
|
||||||
|
*
|
||||||
|
* @param uuid The player to get XP for
|
||||||
|
* @param skillType The skill to get XP for
|
||||||
|
* @return the amount of XP in a given skill
|
||||||
|
*
|
||||||
|
* @throws InvalidSkillException if the given skill is not valid
|
||||||
|
* @throws InvalidPlayerException if the given player does not exist in the database
|
||||||
|
* @throws UnsupportedOperationException if the given skill is a child skill
|
||||||
|
*/
|
||||||
|
public static float getOfflineXPRaw(UUID uuid, String skillType) {
|
||||||
|
return getOfflineProfile(uuid).getSkillXpLevelRaw(getNonChildSkillType(skillType));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the total amount of XP needed to reach the next level.
|
* Get the total amount of XP needed to reach the next level.
|
||||||
* </br>
|
* </br>
|
||||||
@@ -339,10 +406,28 @@ public final class ExperienceAPI {
|
|||||||
* @throws InvalidPlayerException if the given player does not exist in the database
|
* @throws InvalidPlayerException if the given player does not exist in the database
|
||||||
* @throws UnsupportedOperationException if the given skill is a child skill
|
* @throws UnsupportedOperationException if the given skill is a child skill
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
public static int getOfflineXPToNextLevel(String playerName, String skillType) {
|
public static int getOfflineXPToNextLevel(String playerName, String skillType) {
|
||||||
return getOfflineProfile(playerName).getXpToLevel(getNonChildSkillType(skillType));
|
return getOfflineProfile(playerName).getXpToLevel(getNonChildSkillType(skillType));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the total amount of XP an offline player needs to reach the next level.
|
||||||
|
* </br>
|
||||||
|
* This function is designed for API usage.
|
||||||
|
*
|
||||||
|
* @param uuid The player to get XP for
|
||||||
|
* @param skillType The skill to get XP for
|
||||||
|
* @return the total amount of XP needed to reach the next level
|
||||||
|
*
|
||||||
|
* @throws InvalidSkillException if the given skill is not valid
|
||||||
|
* @throws InvalidPlayerException if the given player does not exist in the database
|
||||||
|
* @throws UnsupportedOperationException if the given skill is a child skill
|
||||||
|
*/
|
||||||
|
public static int getOfflineXPToNextLevel(UUID uuid, String skillType) {
|
||||||
|
return getOfflineProfile(uuid).getXpToLevel(getNonChildSkillType(skillType));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the amount of XP remaining until the next level.
|
* Get the amount of XP remaining until the next level.
|
||||||
* </br>
|
* </br>
|
||||||
@@ -376,14 +461,34 @@ public final class ExperienceAPI {
|
|||||||
* @throws InvalidPlayerException if the given player does not exist in the database
|
* @throws InvalidPlayerException if the given player does not exist in the database
|
||||||
* @throws UnsupportedOperationException if the given skill is a child skill
|
* @throws UnsupportedOperationException if the given skill is a child skill
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
public static int getOfflineXPRemaining(String playerName, String skillType) {
|
public static int getOfflineXPRemaining(String playerName, String skillType) {
|
||||||
SkillType skill = getNonChildSkillType(skillType);
|
SkillType skill = getNonChildSkillType(skillType);
|
||||||
|
|
||||||
PlayerProfile profile = getOfflineProfile(playerName);
|
PlayerProfile profile = getOfflineProfile(playerName);
|
||||||
|
|
||||||
return profile.getXpToLevel(skill) - profile.getSkillXpLevel(skill);
|
return profile.getXpToLevel(skill) - profile.getSkillXpLevel(skill);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the amount of XP an offline player has left before leveling up.
|
||||||
|
* </br>
|
||||||
|
* This function is designed for API usage.
|
||||||
|
*
|
||||||
|
* @param uuid The player to get XP for
|
||||||
|
* @param skillType The skill to get XP for
|
||||||
|
* @return the amount of XP needed to reach the next level
|
||||||
|
*
|
||||||
|
* @throws InvalidSkillException if the given skill is not valid
|
||||||
|
* @throws InvalidPlayerException if the given player does not exist in the database
|
||||||
|
* @throws UnsupportedOperationException if the given skill is a child skill
|
||||||
|
*/
|
||||||
|
public static float getOfflineXPRemaining(UUID uuid, String skillType) {
|
||||||
|
SkillType skill = getNonChildSkillType(skillType);
|
||||||
|
PlayerProfile profile = getOfflineProfile(uuid);
|
||||||
|
|
||||||
|
return profile.getXpToLevel(skill) - profile.getSkillXpLevelRaw(skill);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add levels to a skill.
|
* Add levels to a skill.
|
||||||
* </br>
|
* </br>
|
||||||
@@ -411,6 +516,7 @@ public final class ExperienceAPI {
|
|||||||
* @throws InvalidSkillException if the given skill is not valid
|
* @throws InvalidSkillException if the given skill is not valid
|
||||||
* @throws InvalidPlayerException if the given player does not exist in the database
|
* @throws InvalidPlayerException if the given player does not exist in the database
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
public static void addLevelOffline(String playerName, String skillType, int levels) {
|
public static void addLevelOffline(String playerName, String skillType, int levels) {
|
||||||
PlayerProfile profile = getOfflineProfile(playerName);
|
PlayerProfile profile = getOfflineProfile(playerName);
|
||||||
SkillType skill = getSkillType(skillType);
|
SkillType skill = getSkillType(skillType);
|
||||||
@@ -430,6 +536,37 @@ public final class ExperienceAPI {
|
|||||||
profile.scheduleAsyncSave();
|
profile.scheduleAsyncSave();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add levels to a skill for an offline player.
|
||||||
|
* </br>
|
||||||
|
* This function is designed for API usage.
|
||||||
|
*
|
||||||
|
* @param uuid The player to add levels to
|
||||||
|
* @param skillType Type of skill to add levels to
|
||||||
|
* @param levels Number of levels to add
|
||||||
|
*
|
||||||
|
* @throws InvalidSkillException if the given skill is not valid
|
||||||
|
* @throws InvalidPlayerException if the given player does not exist in the database
|
||||||
|
*/
|
||||||
|
public static void addLevelOffline(UUID uuid, String skillType, int levels) {
|
||||||
|
PlayerProfile profile = getOfflineProfile(uuid);
|
||||||
|
SkillType skill = getSkillType(skillType);
|
||||||
|
|
||||||
|
if (skill.isChildSkill()) {
|
||||||
|
Set<SkillType> parentSkills = FamilyTree.getParents(skill);
|
||||||
|
|
||||||
|
for (SkillType parentSkill : parentSkills) {
|
||||||
|
profile.addLevels(parentSkill, (levels / parentSkills.size()));
|
||||||
|
}
|
||||||
|
|
||||||
|
profile.scheduleAsyncSave();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
profile.addLevels(skill, levels);
|
||||||
|
profile.scheduleAsyncSave();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the level a player has in a specific skill.
|
* Get the level a player has in a specific skill.
|
||||||
* </br>
|
* </br>
|
||||||
@@ -457,10 +594,27 @@ public final class ExperienceAPI {
|
|||||||
* @throws InvalidSkillException if the given skill is not valid
|
* @throws InvalidSkillException if the given skill is not valid
|
||||||
* @throws InvalidPlayerException if the given player does not exist in the database
|
* @throws InvalidPlayerException if the given player does not exist in the database
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
public static int getLevelOffline(String playerName, String skillType) {
|
public static int getLevelOffline(String playerName, String skillType) {
|
||||||
return getOfflineProfile(playerName).getSkillLevel(getSkillType(skillType));
|
return getOfflineProfile(playerName).getSkillLevel(getSkillType(skillType));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the level an offline player has in a specific skill.
|
||||||
|
* </br>
|
||||||
|
* This function is designed for API usage.
|
||||||
|
*
|
||||||
|
* @param uuid The player to get the level for
|
||||||
|
* @param skillType The skill to get the level for
|
||||||
|
* @return the level of a given skill
|
||||||
|
*
|
||||||
|
* @throws InvalidSkillException if the given skill is not valid
|
||||||
|
* @throws InvalidPlayerException if the given player does not exist in the database
|
||||||
|
*/
|
||||||
|
public static int getLevelOffline(UUID uuid, String skillType) {
|
||||||
|
return getOfflineProfile(uuid).getSkillLevel(getSkillType(skillType));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the power level of a player.
|
* Gets the power level of a player.
|
||||||
* </br>
|
* </br>
|
||||||
@@ -483,6 +637,7 @@ public final class ExperienceAPI {
|
|||||||
*
|
*
|
||||||
* @throws InvalidPlayerException if the given player does not exist in the database
|
* @throws InvalidPlayerException if the given player does not exist in the database
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
public static int getPowerLevelOffline(String playerName) {
|
public static int getPowerLevelOffline(String playerName) {
|
||||||
int powerLevel = 0;
|
int powerLevel = 0;
|
||||||
PlayerProfile profile = getOfflineProfile(playerName);
|
PlayerProfile profile = getOfflineProfile(playerName);
|
||||||
@@ -494,6 +649,27 @@ public final class ExperienceAPI {
|
|||||||
return powerLevel;
|
return powerLevel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the power level of an offline player.
|
||||||
|
* </br>
|
||||||
|
* This function is designed for API usage.
|
||||||
|
*
|
||||||
|
* @param uuid The player to get the power level for
|
||||||
|
* @return the power level of the player
|
||||||
|
*
|
||||||
|
* @throws InvalidPlayerException if the given player does not exist in the database
|
||||||
|
*/
|
||||||
|
public static int getPowerLevelOffline(UUID uuid) {
|
||||||
|
int powerLevel = 0;
|
||||||
|
PlayerProfile profile = getOfflineProfile(uuid);
|
||||||
|
|
||||||
|
for (SkillType type : SkillType.NON_CHILD_SKILLS) {
|
||||||
|
powerLevel += profile.getSkillLevel(type);
|
||||||
|
}
|
||||||
|
|
||||||
|
return powerLevel;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the level cap of a specific skill.
|
* Get the level cap of a specific skill.
|
||||||
* </br>
|
* </br>
|
||||||
@@ -533,10 +709,28 @@ public final class ExperienceAPI {
|
|||||||
*
|
*
|
||||||
* @return the position on the leaderboard
|
* @return the position on the leaderboard
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
public static int getPlayerRankSkill(String playerName, String skillType) {
|
public static int getPlayerRankSkill(String playerName, String skillType) {
|
||||||
return mcMMO.getDatabaseManager().readRank(getOfflineProfile(playerName).getPlayerName()).get(getNonChildSkillType(skillType));
|
return mcMMO.getDatabaseManager().readRank(getOfflineProfile(playerName).getPlayerName()).get(getNonChildSkillType(skillType));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the position on the leaderboard of a player.
|
||||||
|
* </br>
|
||||||
|
* This function is designed for API usage.
|
||||||
|
*
|
||||||
|
* @param uuid The name of the player to check
|
||||||
|
* @param skillType The skill to check
|
||||||
|
*
|
||||||
|
* @throws InvalidSkillException if the given skill is not valid
|
||||||
|
* @throws InvalidPlayerException if the given player does not exist in the database
|
||||||
|
* @throws UnsupportedOperationException if the given skill is a child skill
|
||||||
|
*
|
||||||
|
* @return the position on the leaderboard
|
||||||
|
*/
|
||||||
|
public static int getPlayerRankSkill(UUID uuid, String skillType) {
|
||||||
|
return mcMMO.getDatabaseManager().readRank(getOfflineProfile(uuid).getPlayerName()).get(getNonChildSkillType(skillType));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the position on the power level leaderboard of a player.
|
* Get the position on the power level leaderboard of a player.
|
||||||
@@ -549,10 +743,26 @@ public final class ExperienceAPI {
|
|||||||
*
|
*
|
||||||
* @return the position on the power level leaderboard
|
* @return the position on the power level leaderboard
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
public static int getPlayerRankOverall(String playerName) {
|
public static int getPlayerRankOverall(String playerName) {
|
||||||
return mcMMO.getDatabaseManager().readRank(getOfflineProfile(playerName).getPlayerName()).get(null);
|
return mcMMO.getDatabaseManager().readRank(getOfflineProfile(playerName).getPlayerName()).get(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the position on the power level leaderboard of a player.
|
||||||
|
* </br>
|
||||||
|
* This function is designed for API usage.
|
||||||
|
*
|
||||||
|
* @param uuid The name of the player to check
|
||||||
|
*
|
||||||
|
* @throws InvalidPlayerException if the given player does not exist in the database
|
||||||
|
*
|
||||||
|
* @return the position on the power level leaderboard
|
||||||
|
*/
|
||||||
|
public static int getPlayerRankOverall(UUID uuid) {
|
||||||
|
return mcMMO.getDatabaseManager().readRank(getOfflineProfile(uuid).getPlayerName()).get(null);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the level of a player in a specific skill type.
|
* Sets the level of a player in a specific skill type.
|
||||||
* </br>
|
* </br>
|
||||||
@@ -580,10 +790,27 @@ public final class ExperienceAPI {
|
|||||||
* @throws InvalidSkillException if the given skill is not valid
|
* @throws InvalidSkillException if the given skill is not valid
|
||||||
* @throws InvalidPlayerException if the given player does not exist in the database
|
* @throws InvalidPlayerException if the given player does not exist in the database
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
public static void setLevelOffline(String playerName, String skillType, int skillLevel) {
|
public static void setLevelOffline(String playerName, String skillType, int skillLevel) {
|
||||||
getOfflineProfile(playerName).modifySkill(getSkillType(skillType), skillLevel);
|
getOfflineProfile(playerName).modifySkill(getSkillType(skillType), skillLevel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the level of an offline player in a specific skill type.
|
||||||
|
* </br>
|
||||||
|
* This function is designed for API usage.
|
||||||
|
*
|
||||||
|
* @param uuid The player to set the level of
|
||||||
|
* @param skillType The skill to set the level for
|
||||||
|
* @param skillLevel The value to set the level to
|
||||||
|
*
|
||||||
|
* @throws InvalidSkillException if the given skill is not valid
|
||||||
|
* @throws InvalidPlayerException if the given player does not exist in the database
|
||||||
|
*/
|
||||||
|
public static void setLevelOffline(UUID uuid, String skillType, int skillLevel) {
|
||||||
|
getOfflineProfile(uuid).modifySkill(getSkillType(skillType), skillLevel);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the XP of a player in a specific skill type.
|
* Sets the XP of a player in a specific skill type.
|
||||||
* </br>
|
* </br>
|
||||||
@@ -613,10 +840,28 @@ public final class ExperienceAPI {
|
|||||||
* @throws InvalidPlayerException if the given player does not exist in the database
|
* @throws InvalidPlayerException if the given player does not exist in the database
|
||||||
* @throws UnsupportedOperationException if the given skill is a child skill
|
* @throws UnsupportedOperationException if the given skill is a child skill
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
public static void setXPOffline(String playerName, String skillType, int newValue) {
|
public static void setXPOffline(String playerName, String skillType, int newValue) {
|
||||||
getOfflineProfile(playerName).setSkillXpLevel(getNonChildSkillType(skillType), newValue);
|
getOfflineProfile(playerName).setSkillXpLevel(getNonChildSkillType(skillType), newValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the XP of an offline player in a specific skill type.
|
||||||
|
* </br>
|
||||||
|
* This function is designed for API usage.
|
||||||
|
*
|
||||||
|
* @param uuid The player to set the XP of
|
||||||
|
* @param skillType The skill to set the XP for
|
||||||
|
* @param newValue The value to set the XP to
|
||||||
|
*
|
||||||
|
* @throws InvalidSkillException if the given skill is not valid
|
||||||
|
* @throws InvalidPlayerException if the given player does not exist in the database
|
||||||
|
* @throws UnsupportedOperationException if the given skill is a child skill
|
||||||
|
*/
|
||||||
|
public static void setXPOffline(UUID uuid, String skillType, int newValue) {
|
||||||
|
getOfflineProfile(uuid).setSkillXpLevel(getNonChildSkillType(skillType), newValue);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes XP from a player in a specific skill type.
|
* Removes XP from a player in a specific skill type.
|
||||||
* </br>
|
* </br>
|
||||||
@@ -646,12 +891,37 @@ public final class ExperienceAPI {
|
|||||||
* @throws InvalidPlayerException if the given player does not exist in the database
|
* @throws InvalidPlayerException if the given player does not exist in the database
|
||||||
* @throws UnsupportedOperationException if the given skill is a child skill
|
* @throws UnsupportedOperationException if the given skill is a child skill
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
public static void removeXPOffline(String playerName, String skillType, int xp) {
|
public static void removeXPOffline(String playerName, String skillType, int xp) {
|
||||||
getOfflineProfile(playerName).removeXp(getNonChildSkillType(skillType), xp);
|
getOfflineProfile(playerName).removeXp(getNonChildSkillType(skillType), xp);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Utility methods follow.
|
/**
|
||||||
|
* Removes XP from an offline player in a specific skill type.
|
||||||
|
* </br>
|
||||||
|
* This function is designed for API usage.
|
||||||
|
*
|
||||||
|
* @param uuid The player to change the XP of
|
||||||
|
* @param skillType The skill to change the XP for
|
||||||
|
* @param xp The amount of XP to remove
|
||||||
|
*
|
||||||
|
* @throws InvalidSkillException if the given skill is not valid
|
||||||
|
* @throws InvalidPlayerException if the given player does not exist in the database
|
||||||
|
* @throws UnsupportedOperationException if the given skill is a child skill
|
||||||
|
*/
|
||||||
|
public static void removeXPOffline(UUID uuid, String skillType, int xp) {
|
||||||
|
getOfflineProfile(uuid).removeXp(getNonChildSkillType(skillType), xp);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Utility methods follow.
|
||||||
|
private static void addOfflineXP(UUID playerUniqueId, SkillType skill, int XP) {
|
||||||
|
PlayerProfile profile = getOfflineProfile(playerUniqueId);
|
||||||
|
|
||||||
|
profile.addXp(skill, XP);
|
||||||
|
profile.save();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
private static void addOfflineXP(String playerName, SkillType skill, int XP) {
|
private static void addOfflineXP(String playerName, SkillType skill, int XP) {
|
||||||
PlayerProfile profile = getOfflineProfile(playerName);
|
PlayerProfile profile = getOfflineProfile(playerName);
|
||||||
|
|
||||||
@@ -659,8 +929,20 @@ public final class ExperienceAPI {
|
|||||||
profile.scheduleAsyncSave();
|
profile.scheduleAsyncSave();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static PlayerProfile getOfflineProfile(UUID uuid) {
|
||||||
|
PlayerProfile profile = mcMMO.getDatabaseManager().loadPlayerProfile(uuid);
|
||||||
|
|
||||||
|
if (!profile.isLoaded()) {
|
||||||
|
throw new InvalidPlayerException();
|
||||||
|
}
|
||||||
|
|
||||||
|
return profile;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
private static PlayerProfile getOfflineProfile(String playerName) {
|
private static PlayerProfile getOfflineProfile(String playerName) {
|
||||||
PlayerProfile profile = mcMMO.getDatabaseManager().loadPlayerProfile(playerName, false);
|
UUID uuid = mcMMO.p.getServer().getOfflinePlayer(playerName).getUniqueId();
|
||||||
|
PlayerProfile profile = mcMMO.getDatabaseManager().loadPlayerProfile(uuid);
|
||||||
|
|
||||||
if (!profile.isLoaded()) {
|
if (!profile.isLoaded()) {
|
||||||
throw new InvalidPlayerException();
|
throw new InvalidPlayerException();
|
||||||
|
|||||||
93
src/main/java/com/gmail/nossr50/api/SkillAPI.java
Normal file
93
src/main/java/com/gmail/nossr50/api/SkillAPI.java
Normal file
@@ -0,0 +1,93 @@
|
|||||||
|
package com.gmail.nossr50.api;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||||
|
|
||||||
|
public final class SkillAPI {
|
||||||
|
private SkillAPI() {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a list of strings with mcMMO's skills
|
||||||
|
* This includes parent and child skills
|
||||||
|
* </br>
|
||||||
|
* This function is designed for API usage.
|
||||||
|
*
|
||||||
|
* @return a list of strings with valid skill names
|
||||||
|
*/
|
||||||
|
public static List<String> getSkills() {
|
||||||
|
return getListFromEnum(Arrays.asList(SkillType.values()));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a list of strings with mcMMO's skills
|
||||||
|
* This only includes parent skills
|
||||||
|
* </br>
|
||||||
|
* This function is designed for API usage.
|
||||||
|
*
|
||||||
|
* @return a list of strings with valid skill names
|
||||||
|
*/
|
||||||
|
public static List<String> getNonChildSkills() {
|
||||||
|
return getListFromEnum(SkillType.NON_CHILD_SKILLS);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a list of strings with mcMMO's skills
|
||||||
|
* This only includes child skills
|
||||||
|
* </br>
|
||||||
|
* This function is designed for API usage.
|
||||||
|
*
|
||||||
|
* @return a list of strings with valid skill names
|
||||||
|
*/
|
||||||
|
public static List<String> getChildSkills() {
|
||||||
|
return getListFromEnum(SkillType.CHILD_SKILLS);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a list of strings with mcMMO's skills
|
||||||
|
* This only includes combat skills
|
||||||
|
* </br>
|
||||||
|
* This function is designed for API usage.
|
||||||
|
*
|
||||||
|
* @return a list of strings with valid skill names
|
||||||
|
*/
|
||||||
|
public static List<String> getCombatSkills() {
|
||||||
|
return getListFromEnum(SkillType.COMBAT_SKILLS);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a list of strings with mcMMO's skills
|
||||||
|
* This only includes gathering skills
|
||||||
|
* </br>
|
||||||
|
* This function is designed for API usage.
|
||||||
|
*
|
||||||
|
* @return a list of strings with valid skill names
|
||||||
|
*/
|
||||||
|
public static List<String> getGatheringSkills() {
|
||||||
|
return getListFromEnum(SkillType.GATHERING_SKILLS);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a list of strings with mcMMO's skills
|
||||||
|
* This only includes misc skills
|
||||||
|
* </br>
|
||||||
|
* This function is designed for API usage.
|
||||||
|
*
|
||||||
|
* @return a list of strings with valid skill names
|
||||||
|
*/
|
||||||
|
public static List<String> getMiscSkills() {
|
||||||
|
return getListFromEnum(SkillType.MISC_SKILLS);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static List<String> getListFromEnum(List<SkillType> skillsTypes) {
|
||||||
|
List<String> skills = new ArrayList<String>();
|
||||||
|
|
||||||
|
for (SkillType skillType : skillsTypes) {
|
||||||
|
skills.add(skillType.name());
|
||||||
|
}
|
||||||
|
|
||||||
|
return skills;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,16 +1,11 @@
|
|||||||
package com.gmail.nossr50.chat;
|
package com.gmail.nossr50.chat;
|
||||||
|
|
||||||
import java.util.regex.Matcher;
|
|
||||||
import java.util.regex.Pattern;
|
|
||||||
|
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
|
|
||||||
import com.gmail.nossr50.config.Config;
|
import com.gmail.nossr50.config.Config;
|
||||||
import com.gmail.nossr50.datatypes.party.Party;
|
import com.gmail.nossr50.datatypes.party.Party;
|
||||||
import com.gmail.nossr50.events.chat.McMMOPartyChatEvent;
|
import com.gmail.nossr50.events.chat.McMMOPartyChatEvent;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.runnables.party.PartyChatTask;
|
||||||
|
|
||||||
public class PartyChatManager extends ChatManager {
|
public class PartyChatManager extends ChatManager {
|
||||||
private Party party;
|
private Party party;
|
||||||
@@ -30,21 +25,6 @@ public class PartyChatManager extends ChatManager {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void sendMessage() {
|
protected void sendMessage() {
|
||||||
if (Config.getInstance().getPartyChatColorLeaderName() && senderName.equalsIgnoreCase(party.getLeader())) {
|
new PartyChatTask(plugin, party, senderName, displayName, message).runTask(plugin);
|
||||||
message = message.replaceFirst(Pattern.quote(displayName), ChatColor.GOLD + Matcher.quoteReplacement(displayName) + ChatColor.RESET);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (Player member : party.getOnlineMembers()) {
|
|
||||||
member.sendMessage(message);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (party.getAlly() != null) {
|
|
||||||
for (Player member : party.getAlly().getOnlineMembers()) {
|
|
||||||
String allyPrefix = LocaleLoader.formatString(Config.getInstance().getPartyChatPrefixAlly());
|
|
||||||
member.sendMessage(allyPrefix + message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
plugin.getLogger().info("[P]<" + party.getName() + ">" + message);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import com.gmail.nossr50.datatypes.database.DatabaseType;
|
|||||||
import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.runnables.database.DatabaseConversionTask;
|
import com.gmail.nossr50.runnables.database.DatabaseConversionTask;
|
||||||
|
import com.gmail.nossr50.runnables.player.PlayerProfileLoadingTask;
|
||||||
import com.gmail.nossr50.util.player.UserManager;
|
import com.gmail.nossr50.util.player.UserManager;
|
||||||
|
|
||||||
public class ConvertDatabaseCommand implements CommandExecutor {
|
public class ConvertDatabaseCommand implements CommandExecutor {
|
||||||
@@ -55,13 +56,13 @@ public class ConvertDatabaseCommand implements CommandExecutor {
|
|||||||
UserManager.clearAll();
|
UserManager.clearAll();
|
||||||
|
|
||||||
for (Player player : mcMMO.p.getServer().getOnlinePlayers()) {
|
for (Player player : mcMMO.p.getServer().getOnlinePlayers()) {
|
||||||
PlayerProfile profile = oldDatabase.loadPlayerProfile(player.getName(), false);
|
PlayerProfile profile = oldDatabase.loadPlayerProfile(player.getUniqueId());
|
||||||
|
|
||||||
if (profile.isLoaded()) {
|
if (profile.isLoaded()) {
|
||||||
mcMMO.getDatabaseManager().saveUser(profile);
|
mcMMO.getDatabaseManager().saveUser(profile);
|
||||||
}
|
}
|
||||||
|
|
||||||
UserManager.addUser(player);
|
new PlayerProfileLoadingTask(player).runTaskTimerAsynchronously(mcMMO.p, 1, 20); // 1 Tick delay to ensure the player is marked as online before we begin loading
|
||||||
}
|
}
|
||||||
|
|
||||||
new DatabaseConversionTask(oldDatabase, sender, previousType.toString(), newType.toString()).runTaskAsynchronously(mcMMO.p);
|
new DatabaseConversionTask(oldDatabase, sender, previousType.toString(), newType.toString()).runTaskAsynchronously(mcMMO.p);
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import com.gmail.nossr50.mcMMO;
|
|||||||
import com.gmail.nossr50.datatypes.experience.FormulaType;
|
import com.gmail.nossr50.datatypes.experience.FormulaType;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.runnables.database.FormulaConversionTask;
|
import com.gmail.nossr50.runnables.database.FormulaConversionTask;
|
||||||
|
import com.gmail.nossr50.runnables.player.PlayerProfileLoadingTask;
|
||||||
import com.gmail.nossr50.util.player.UserManager;
|
import com.gmail.nossr50.util.player.UserManager;
|
||||||
|
|
||||||
public class ConvertExperienceCommand implements CommandExecutor {
|
public class ConvertExperienceCommand implements CommandExecutor {
|
||||||
@@ -37,7 +38,7 @@ public class ConvertExperienceCommand implements CommandExecutor {
|
|||||||
new FormulaConversionTask(sender, newType).runTaskLater(mcMMO.p, 1);
|
new FormulaConversionTask(sender, newType).runTaskLater(mcMMO.p, 1);
|
||||||
|
|
||||||
for (Player player : mcMMO.p.getServer().getOnlinePlayers()) {
|
for (Player player : mcMMO.p.getServer().getOnlinePlayers()) {
|
||||||
UserManager.addUser(player);
|
new PlayerProfileLoadingTask(player).runTaskTimerAsynchronously(mcMMO.p, 1, 20); // 1 Tick delay to ensure the player is marked as online before we begin loading
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ public class ArcheryCommand extends SkillCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (canDaze) {
|
if (canDaze) {
|
||||||
messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Archery.Effect.2"), LocaleLoader.getString("Archery.Effect.3", Archery.dazeModifier)));
|
messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Archery.Effect.2"), LocaleLoader.getString("Archery.Effect.3", Archery.dazeBonusDamage)));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (canRetrieve) {
|
if (canRetrieve) {
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import java.util.ArrayList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.block.Biome;
|
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@@ -98,9 +97,7 @@ public class FishingCommand extends SkillCommand {
|
|||||||
location = player.getLocation();
|
location = player.getLocation();
|
||||||
}
|
}
|
||||||
|
|
||||||
Biome biome = location.getBlock().getBiome();
|
if (Fishing.masterAnglerBiomes.contains(location.getBlock().getBiome())) {
|
||||||
|
|
||||||
if (biome == Biome.RIVER || biome == Biome.OCEAN) {
|
|
||||||
rawBiteChance = rawBiteChance * AdvancedConfig.getInstance().getMasterAnglerBiomeModifier();
|
rawBiteChance = rawBiteChance * AdvancedConfig.getInstance().getMasterAnglerBiomeModifier();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import com.gmail.nossr50.config.AdvancedConfig;
|
|||||||
import com.gmail.nossr50.datatypes.skills.SecondaryAbility;
|
import com.gmail.nossr50.datatypes.skills.SecondaryAbility;
|
||||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
|
import com.gmail.nossr50.skills.mining.BlastMining;
|
||||||
import com.gmail.nossr50.skills.mining.BlastMining.Tier;
|
import com.gmail.nossr50.skills.mining.BlastMining.Tier;
|
||||||
import com.gmail.nossr50.skills.mining.MiningManager;
|
import com.gmail.nossr50.skills.mining.MiningManager;
|
||||||
import com.gmail.nossr50.util.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
@@ -126,7 +127,7 @@ public class MiningCommand extends SkillCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (canBiggerBombs) {
|
if (canBiggerBombs) {
|
||||||
int unlockLevel = AdvancedConfig.getInstance().getBlastMiningRankLevel(Tier.TWO);
|
int unlockLevel = BlastMining.getBiggerBombsUnlockLevel();
|
||||||
|
|
||||||
if (skillValue < unlockLevel) {
|
if (skillValue < unlockLevel) {
|
||||||
messages.add(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Mining.Ability.Locked.1", unlockLevel)));
|
messages.add(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Mining.Ability.Locked.1", unlockLevel)));
|
||||||
@@ -137,7 +138,7 @@ public class MiningCommand extends SkillCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (canDemoExpert) {
|
if (canDemoExpert) {
|
||||||
int unlockLevel = AdvancedConfig.getInstance().getBlastMiningRankLevel(Tier.FOUR);
|
int unlockLevel = BlastMining.getDemolitionExpertUnlockLevel();
|
||||||
|
|
||||||
if (skillValue < unlockLevel) {
|
if (skillValue < unlockLevel) {
|
||||||
messages.add(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Mining.Ability.Locked.2", unlockLevel)));
|
messages.add(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Mining.Ability.Locked.2", unlockLevel)));
|
||||||
|
|||||||
@@ -134,7 +134,7 @@ public class AdvancedConfig extends AutoUpdateConfigLoader {
|
|||||||
reason.add("Skills.Acrobatics.Daze.MaxBonusLevel should be at least 1!");
|
reason.add("Skills.Acrobatics.Daze.MaxBonusLevel should be at least 1!");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getDazeModifier() < 0) {
|
if (getDazeBonusDamage() < 0) {
|
||||||
reason.add("Skills.Acrobatics.Daze.BonusDamage should be at least 0!");
|
reason.add("Skills.Acrobatics.Daze.BonusDamage should be at least 0!");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -714,7 +714,7 @@ public class AdvancedConfig extends AutoUpdateConfigLoader {
|
|||||||
public double getSkillShotBonusMax() { return config.getDouble("Skills.Archery.SkillShot.MaxBonus", 2.0D); }
|
public double getSkillShotBonusMax() { return config.getDouble("Skills.Archery.SkillShot.MaxBonus", 2.0D); }
|
||||||
public double getSkillShotDamageMax() { return config.getDouble("Skills.Archery.SkillShot.MaxDamage", 9.0D); }
|
public double getSkillShotDamageMax() { return config.getDouble("Skills.Archery.SkillShot.MaxDamage", 9.0D); }
|
||||||
|
|
||||||
public double getDazeModifier() { return config.getDouble("Skills.Archery.Daze.BonusDamage", 4.0D); }
|
public double getDazeBonusDamage() { return config.getDouble("Skills.Archery.Daze.BonusDamage", 4.0D); }
|
||||||
|
|
||||||
public double getForceMultiplier() { return config.getDouble("Skills.Archery.ForceMultiplier", 2.0D); }
|
public double getForceMultiplier() { return config.getDouble("Skills.Archery.ForceMultiplier", 2.0D); }
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import java.util.List;
|
|||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.TreeSpecies;
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
|
|
||||||
@@ -231,12 +232,12 @@ public class Config extends AutoUpdateConfigLoader {
|
|||||||
/* General Settings */
|
/* General Settings */
|
||||||
public String getLocale() { return config.getString("General.Locale", "en_us"); }
|
public String getLocale() { return config.getString("General.Locale", "en_us"); }
|
||||||
public boolean getMOTDEnabled() { return config.getBoolean("General.MOTD_Enabled", true); }
|
public boolean getMOTDEnabled() { return config.getBoolean("General.MOTD_Enabled", true); }
|
||||||
|
public boolean getShowProfileLoadedMessage() { return config.getBoolean("General.Show_Profile_Loaded", true); }
|
||||||
public boolean getDonateMessageEnabled() { return config.getBoolean("Commands.mcmmo.Donate_Message", true); }
|
public boolean getDonateMessageEnabled() { return config.getBoolean("Commands.mcmmo.Donate_Message", true); }
|
||||||
public int getSaveInterval() { return config.getInt("General.Save_Interval", 10); }
|
public int getSaveInterval() { return config.getInt("General.Save_Interval", 10); }
|
||||||
public boolean getStatsTrackingEnabled() { return config.getBoolean("General.Stats_Tracking", true); }
|
public boolean getStatsTrackingEnabled() { return config.getBoolean("General.Stats_Tracking", true); }
|
||||||
public boolean getUpdateCheckEnabled() { return config.getBoolean("General.Update_Check", true); }
|
public boolean getUpdateCheckEnabled() { return config.getBoolean("General.Update_Check", true); }
|
||||||
public boolean getPreferBeta() { return config.getBoolean("General.Prefer_Beta", false); }
|
public boolean getPreferBeta() { return config.getBoolean("General.Prefer_Beta", false); }
|
||||||
public boolean getEventCallbackEnabled() { return config.getBoolean("General.Event_Callback", true); }
|
|
||||||
public boolean getVerboseLoggingEnabled() { return config.getBoolean("General.Verbose_Logging", false); }
|
public boolean getVerboseLoggingEnabled() { return config.getBoolean("General.Verbose_Logging", false); }
|
||||||
|
|
||||||
public String getPartyChatPrefix() { return config.getString("Commands.partychat.Chat_Prefix_Format", "[[GREEN]]([[WHITE]]{0}[[GREEN]])"); }
|
public String getPartyChatPrefix() { return config.getString("Commands.partychat.Chat_Prefix_Format", "[[GREEN]]([[WHITE]]{0}[[GREEN]])"); }
|
||||||
@@ -313,6 +314,8 @@ public class Config extends AutoUpdateConfigLoader {
|
|||||||
public int getMySQLServerPort() { return config.getInt("MySQL.Server.Port", 3306); }
|
public int getMySQLServerPort() { return config.getInt("MySQL.Server.Port", 3306); }
|
||||||
public String getMySQLServerName() { return config.getString("MySQL.Server.Address", "localhost"); }
|
public String getMySQLServerName() { return config.getString("MySQL.Server.Address", "localhost"); }
|
||||||
public String getMySQLUserPassword() { return getStringIncludingInts("MySQL.Database.User_Password"); }
|
public String getMySQLUserPassword() { return getStringIncludingInts("MySQL.Database.User_Password"); }
|
||||||
|
public int getMySQLMaxConnections() { return config.getInt("MySQL.Database.MaxConnections"); }
|
||||||
|
public int getMySQLMaxPoolSize() { return config.getInt("MySQL.Database.MaxPoolSize"); }
|
||||||
|
|
||||||
private String getStringIncludingInts(String key) {
|
private String getStringIncludingInts(String key) {
|
||||||
String str = config.getString(key);
|
String str = config.getString(key);
|
||||||
@@ -452,6 +455,7 @@ public class Config extends AutoUpdateConfigLoader {
|
|||||||
|
|
||||||
/* Fishing */
|
/* Fishing */
|
||||||
public boolean getFishingDropsEnabled() { return config.getBoolean("Skills.Fishing.Drops_Enabled", true); }
|
public boolean getFishingDropsEnabled() { return config.getBoolean("Skills.Fishing.Drops_Enabled", true); }
|
||||||
|
public boolean getFishingOverrideTreasures() { return config.getBoolean("Skills.Fishing.Override_Vanilla_Treasures", true); }
|
||||||
public boolean getFishingExtraFish() { return config.getBoolean("Skills.Fishing.Extra_Fish", true); }
|
public boolean getFishingExtraFish() { return config.getBoolean("Skills.Fishing.Extra_Fish", true); }
|
||||||
|
|
||||||
/* Mining */
|
/* Mining */
|
||||||
@@ -473,6 +477,7 @@ public class Config extends AutoUpdateConfigLoader {
|
|||||||
|
|
||||||
/* Unarmed */
|
/* Unarmed */
|
||||||
public boolean getUnarmedBlockCrackerSmoothbrickToCracked() { return config.getBoolean("Skills.Unarmed.Block_Cracker.SmoothBrick_To_CrackedBrick", true); }
|
public boolean getUnarmedBlockCrackerSmoothbrickToCracked() { return config.getBoolean("Skills.Unarmed.Block_Cracker.SmoothBrick_To_CrackedBrick", true); }
|
||||||
|
public boolean getUnarmedItemPickupDisabled() { return config.getBoolean("Skills.Unarmed.Item_Pickup_Disabled_Full_Inventory", true); }
|
||||||
|
|
||||||
/* Taming */
|
/* Taming */
|
||||||
public Material getTamingCOTWMaterial(EntityType type) { return Material.matchMaterial(config.getString("Skills.Taming.Call_Of_The_Wild." + StringUtils.getPrettyEntityTypeString(type) + ".Item_Material")); }
|
public Material getTamingCOTWMaterial(EntityType type) { return Material.matchMaterial(config.getString("Skills.Taming.Call_Of_The_Wild." + StringUtils.getPrettyEntityTypeString(type) + ".Item_Material")); }
|
||||||
@@ -481,10 +486,7 @@ public class Config extends AutoUpdateConfigLoader {
|
|||||||
public double getTamingCOTWRange() { return config.getDouble("Skills.Taming.Call_Of_The_Wild.Range", 40.0D); }
|
public double getTamingCOTWRange() { return config.getDouble("Skills.Taming.Call_Of_The_Wild.Range", 40.0D); }
|
||||||
|
|
||||||
/* Woodcutting */
|
/* Woodcutting */
|
||||||
public boolean getOakDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Woodcutting.Oak", true); }
|
public boolean getWoodcuttingDoubleDropsEnabled(TreeSpecies species) { return config.getBoolean("Double_Drops.Woodcutting." + StringUtils.getPrettyTreeSpeciesString(species).replace(" ", "_")); }
|
||||||
public boolean getBirchDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Woodcutting.Birch", true); }
|
|
||||||
public boolean getSpruceDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Woodcutting.Spruce", true); }
|
|
||||||
public boolean getJungleDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Woodcutting.Jungle", true); }
|
|
||||||
public boolean getTreeFellerSoundsEnabled() { return config.getBoolean("Skills.Woodcutting.Tree_Feller_Sounds", true); }
|
public boolean getTreeFellerSoundsEnabled() { return config.getBoolean("Skills.Woodcutting.Tree_Feller_Sounds", true); }
|
||||||
|
|
||||||
/* AFK Leveling */
|
/* AFK Leveling */
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ public class HiddenConfig {
|
|||||||
private static int conversionRate;
|
private static int conversionRate;
|
||||||
private static boolean useEnchantmentBuffs;
|
private static boolean useEnchantmentBuffs;
|
||||||
private static boolean resendChunksAfterBlockAbility;
|
private static boolean resendChunksAfterBlockAbility;
|
||||||
|
private static int uuidConvertAmount;
|
||||||
|
|
||||||
public HiddenConfig(String fileName) {
|
public HiddenConfig(String fileName) {
|
||||||
HiddenConfig.fileName = fileName;
|
HiddenConfig.fileName = fileName;
|
||||||
@@ -33,6 +34,7 @@ public class HiddenConfig {
|
|||||||
conversionRate = config.getInt("Options.ConversionRate", 1);
|
conversionRate = config.getInt("Options.ConversionRate", 1);
|
||||||
useEnchantmentBuffs = config.getBoolean("Options.EnchantmentBuffs", true);
|
useEnchantmentBuffs = config.getBoolean("Options.EnchantmentBuffs", true);
|
||||||
resendChunksAfterBlockAbility = config.getBoolean("Options.RefreshChunks", false);
|
resendChunksAfterBlockAbility = config.getBoolean("Options.RefreshChunks", false);
|
||||||
|
uuidConvertAmount = config.getInt("Options.UUIDConvertAmount", 5);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -51,4 +53,8 @@ public class HiddenConfig {
|
|||||||
public boolean resendChunksAfterBlockAbility() {
|
public boolean resendChunksAfterBlockAbility() {
|
||||||
return resendChunksAfterBlockAbility;
|
return resendChunksAfterBlockAbility;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getUUIDConvertAmount() {
|
||||||
|
return uuidConvertAmount;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,13 +3,18 @@ package com.gmail.nossr50.config.experience;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.bukkit.GrassSpecies;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.TreeSpecies;
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
|
import org.bukkit.material.LongGrass;
|
||||||
|
import org.bukkit.material.MaterialData;
|
||||||
|
|
||||||
import com.gmail.nossr50.config.AutoUpdateConfigLoader;
|
import com.gmail.nossr50.config.AutoUpdateConfigLoader;
|
||||||
import com.gmail.nossr50.datatypes.experience.FormulaType;
|
import com.gmail.nossr50.datatypes.experience.FormulaType;
|
||||||
import com.gmail.nossr50.datatypes.skills.MaterialType;
|
import com.gmail.nossr50.datatypes.skills.MaterialType;
|
||||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||||
|
import com.gmail.nossr50.datatypes.skills.alchemy.PotionStage;
|
||||||
import com.gmail.nossr50.util.StringUtils;
|
import com.gmail.nossr50.util.StringUtils;
|
||||||
|
|
||||||
public class ExperienceConfig extends AutoUpdateConfigLoader {
|
public class ExperienceConfig extends AutoUpdateConfigLoader {
|
||||||
@@ -77,8 +82,10 @@ public class ExperienceConfig extends AutoUpdateConfigLoader {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/* Alchemy */
|
/* Alchemy */
|
||||||
if (getPotionXP() <= 0) {
|
for (PotionStage potionStage : PotionStage.values()) {
|
||||||
reason.add("Experience.Alchemy.Potion should be greater than 0!");
|
if (getPotionXP(potionStage) < 0) {
|
||||||
|
reason.add("Experience.Alchemy.Potion_Stage_" + potionStage.toNumerical() + " should be at least 0!");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Combat XP Multipliers */
|
/* Combat XP Multipliers */
|
||||||
@@ -103,9 +110,7 @@ public class ExperienceConfig extends AutoUpdateConfigLoader {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Fishing */
|
/* Fishing */
|
||||||
if (getFishingBaseXP() <= 0) {
|
// TODO: Add validation for each fish type once enum is available.
|
||||||
reason.add("Experience.Fishing.Base should be greater than 0!");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (getFishingShakeXP() <= 0) {
|
if (getFishingShakeXP() <= 0) {
|
||||||
reason.add("Experience.Fishing.Shake should be greater than 0!");
|
reason.add("Experience.Fishing.Shake should be greater than 0!");
|
||||||
@@ -126,20 +131,12 @@ public class ExperienceConfig extends AutoUpdateConfigLoader {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Woodcutting */
|
/* Woodcutting */
|
||||||
if (getWoodcuttingXPOak() <= 0) {
|
for (TreeSpecies species : TreeSpecies.values()) {
|
||||||
reason.add("Experience.Woodcutting.Oak should be greater than 0!");
|
String key = "Experience.Woodcutting." + StringUtils.getPrettyTreeSpeciesString(species).replace(" ", "_");
|
||||||
}
|
|
||||||
|
|
||||||
if (getWoodcuttingXPBirch() <= 0) {
|
if (config.getInt(key) <= 0) {
|
||||||
reason.add("Experience.Woodcutting.Birch should be greater than 0!");
|
reason.add(key + " should be greater than 0!");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getWoodcuttingXPSpruce() <= 0) {
|
|
||||||
reason.add("Experience.Woodcutting.Spruce should be greater than 0!");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (getWoodcuttingXPJungle() <= 0) {
|
|
||||||
reason.add("Experience.Woodcutting.Jungle should be greater than 0!");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getWoodcuttingXPHugeBrownMushroom() <= 0) {
|
if (getWoodcuttingXPHugeBrownMushroom() <= 0) {
|
||||||
@@ -208,12 +205,116 @@ public class ExperienceConfig extends AutoUpdateConfigLoader {
|
|||||||
public double getFeatherFallXPModifier() { return config.getDouble("Experience.Acrobatics.FeatherFall_Multiplier", 2.0); }
|
public double getFeatherFallXPModifier() { return config.getDouble("Experience.Acrobatics.FeatherFall_Multiplier", 2.0); }
|
||||||
|
|
||||||
/* Alchemy */
|
/* Alchemy */
|
||||||
public double getPotionXP() { return config.getDouble("Experience.Alchemy.Potion", 150D); }
|
public double getPotionXP(PotionStage stage) { return config.getDouble("Experience.Alchemy.Potion_Stage_" + stage.toNumerical(), 10D); }
|
||||||
|
|
||||||
/* Fishing */
|
/* Fishing */
|
||||||
public int getFishingBaseXP() { return config.getInt("Experience.Fishing.Base", 800); }
|
public int getFishXp(MaterialData data) {
|
||||||
|
switch (data.getData()) {
|
||||||
|
case 0x0:
|
||||||
|
return config.getInt("Experience.Fishing.Raw_Fish", 800);
|
||||||
|
|
||||||
|
case 0x1:
|
||||||
|
return config.getInt("Experience.Fishing.Raw_Salmon", 800);
|
||||||
|
|
||||||
|
case 0x2:
|
||||||
|
return config.getInt("Experience.Fishing.Clownfish", 800);
|
||||||
|
|
||||||
|
case 0x3:
|
||||||
|
return config.getInt("Experience.Fishing.Pufferfish", 800);
|
||||||
|
|
||||||
|
default:
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public int getFishingShakeXP() { return config.getInt("Experience.Fishing.Shake", 50); }
|
public int getFishingShakeXP() { return config.getInt("Experience.Fishing.Shake", 50); }
|
||||||
|
|
||||||
|
/* Herbalism */
|
||||||
|
public int getFlowerAndGrassXp(MaterialData data) {
|
||||||
|
Material type = data.getItemType();
|
||||||
|
|
||||||
|
if (type == Material.RED_ROSE) {
|
||||||
|
switch (data.getData()) {
|
||||||
|
case 0x0:
|
||||||
|
return config.getInt("Experience.Herbalism.Poppy", 100);
|
||||||
|
|
||||||
|
case 0x1:
|
||||||
|
return config.getInt("Experience.Herbalism.Blue_Orchid", 150);
|
||||||
|
|
||||||
|
case 0x2:
|
||||||
|
return config.getInt("Experience.Herbalism.Allium", 300);
|
||||||
|
|
||||||
|
case 0x3:
|
||||||
|
return config.getInt("Experience.Herbalism.Azure_Bluet", 150);
|
||||||
|
|
||||||
|
case 0x4:
|
||||||
|
return config.getInt("Experience.Herbalism.Red_Tulip", 150);
|
||||||
|
|
||||||
|
case 0x5:
|
||||||
|
return config.getInt("Experience.Herbalism.Orange_Tulip", 150);
|
||||||
|
|
||||||
|
case 0x6:
|
||||||
|
return config.getInt("Experience.Herbalism.White_Tulip", 150);
|
||||||
|
|
||||||
|
case 0x7:
|
||||||
|
return config.getInt("Experience.Herbalism.Pink_Tulip", 150);
|
||||||
|
|
||||||
|
case 0x8:
|
||||||
|
return config.getInt("Experience.Herbalism.Oxeye_Daisy", 150);
|
||||||
|
|
||||||
|
default:
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
else if (type == Material.LONG_GRASS) {
|
||||||
|
GrassSpecies species = ((LongGrass) data).getSpecies();
|
||||||
|
if (species == null) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (species) {
|
||||||
|
case DEAD:
|
||||||
|
return config.getInt("Experience.Herbalism.Dead_Bush", 30);
|
||||||
|
|
||||||
|
case FERN_LIKE:
|
||||||
|
return config.getInt("Experience.Herbalism.Small_Fern", 10);
|
||||||
|
|
||||||
|
case NORMAL:
|
||||||
|
return config.getInt("Experience.Herbalism.Small_Grass", 10);
|
||||||
|
|
||||||
|
default:
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (type == Material.DOUBLE_PLANT) {
|
||||||
|
switch (data.getData()) {
|
||||||
|
case 0x0:
|
||||||
|
return config.getInt("Experience.Herbalism.Sunflower", 50);
|
||||||
|
|
||||||
|
case 0x1:
|
||||||
|
return config.getInt("Experience.Herbalism.Lilac", 50);
|
||||||
|
|
||||||
|
case 0x2:
|
||||||
|
return config.getInt("Experience.Herbalism.Tall_Grass", 50);
|
||||||
|
|
||||||
|
case 0x3:
|
||||||
|
return config.getInt("Experience.Herbalism.Tall_Fern", 50);
|
||||||
|
|
||||||
|
case 0x4:
|
||||||
|
return config.getInt("Experience.Herbalism.Rose_Bush", 50);
|
||||||
|
|
||||||
|
case 0x5:
|
||||||
|
return config.getInt("Experience.Herbalism.Peony", 50);
|
||||||
|
|
||||||
|
default:
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/* Repair */
|
/* Repair */
|
||||||
public double getRepairXPBase() { return config.getDouble("Experience.Repair.Base", 1000.0); }
|
public double getRepairXPBase() { return config.getDouble("Experience.Repair.Base", 1000.0); }
|
||||||
public double getRepairXP(MaterialType repairMaterialType) { return config.getDouble("Experience.Repair." + StringUtils.getCapitalized(repairMaterialType.toString())); }
|
public double getRepairXP(MaterialType repairMaterialType) { return config.getDouble("Experience.Repair." + StringUtils.getCapitalized(repairMaterialType.toString())); }
|
||||||
@@ -224,10 +325,7 @@ public class ExperienceConfig extends AutoUpdateConfigLoader {
|
|||||||
public int getTamingXPOcelot() { return config.getInt("Experience.Taming.Animal_Taming.Ocelot", 500); }
|
public int getTamingXPOcelot() { return config.getInt("Experience.Taming.Animal_Taming.Ocelot", 500); }
|
||||||
|
|
||||||
/* Woodcutting */
|
/* Woodcutting */
|
||||||
public int getWoodcuttingXPOak() { return config.getInt("Experience.Woodcutting.Oak", 70); }
|
public int getWoodcuttingTreeXP(TreeSpecies species) { return config.getInt("Experience.Woodcutting." + StringUtils.getPrettyTreeSpeciesString(species).replace(" ", "_")); }
|
||||||
public int getWoodcuttingXPBirch() { return config.getInt("Experience.Woodcutting.Birch", 90); }
|
|
||||||
public int getWoodcuttingXPSpruce() { return config.getInt("Experience.Woodcutting.Spruce", 80); }
|
|
||||||
public int getWoodcuttingXPJungle() { return config.getInt("Experience.Woodcutting.Jungle", 100); }
|
|
||||||
public int getWoodcuttingXPHugeBrownMushroom() { return config.getInt("Experience.Woodcutting.Huge_Mushroom_Brown", 70); }
|
public int getWoodcuttingXPHugeBrownMushroom() { return config.getInt("Experience.Woodcutting.Huge_Mushroom_Brown", 70); }
|
||||||
public int getWoodcuttingXPHugeRedMushroom() { return config.getInt("Experience.Woodcutting.Huge_Mushroom_Red", 70); }
|
public int getWoodcuttingXPHugeRedMushroom() { return config.getInt("Experience.Woodcutting.Huge_Mushroom_Red", 70); }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -85,13 +85,17 @@ public class CustomArmorConfig extends ConfigLoader {
|
|||||||
repairQuantity = config.getInt(armorType + "." + armorName + ".Repair_Material_Data_Quantity", 2);
|
repairQuantity = config.getInt(armorType + "." + armorName + ".Repair_Material_Data_Quantity", 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String repairItemName = config.getString(armorType + "." + armorName + ".Repair_Material_Pretty_Name");
|
||||||
|
int repairMinimumLevel = config.getInt(armorType + "." + armorName + ".Repair_MinimumLevel", 0);
|
||||||
|
double repairXpMultiplier = config.getDouble(armorType + "." + armorName + ".Repair_XpMultiplier", 1);
|
||||||
|
|
||||||
short durability = armorMaterial.getMaxDurability();
|
short durability = armorMaterial.getMaxDurability();
|
||||||
|
|
||||||
if (durability == 0) {
|
if (durability == 0) {
|
||||||
durability = (short) config.getInt(armorType + "." + armorName + ".Durability", 70);
|
durability = (short) config.getInt(armorType + "." + armorName + ".Durability", 70);
|
||||||
}
|
}
|
||||||
|
|
||||||
repairables.add(RepairableFactory.getRepairable(armorMaterial, repairMaterial, repairData, 0, repairQuantity, durability, ItemType.ARMOR, MaterialType.OTHER, 1.0));
|
repairables.add(RepairableFactory.getRepairable(armorMaterial, repairMaterial, repairData, repairItemName, repairMinimumLevel, repairQuantity, durability, ItemType.ARMOR, MaterialType.OTHER, repairXpMultiplier));
|
||||||
}
|
}
|
||||||
|
|
||||||
materialList.add(armorMaterial);
|
materialList.add(armorMaterial);
|
||||||
|
|||||||
@@ -68,61 +68,39 @@ public class CustomBlockConfig extends ConfigLoader {
|
|||||||
Material blockMaterial = Material.matchMaterial(blockInfo[0]);
|
Material blockMaterial = Material.matchMaterial(blockInfo[0]);
|
||||||
|
|
||||||
if (blockMaterial == null) {
|
if (blockMaterial == null) {
|
||||||
plugin.getLogger().warning("Invalid material name. [" + blockInfo[0] + "] This item will be skipped. - " + blockName);
|
plugin.getLogger().warning("Invalid material name. This item will be skipped. - " + blockInfo[0]);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (blockInfo.length == 2) {
|
byte blockData = (blockInfo.length == 2) ? Byte.valueOf(blockInfo[1]) : 0;
|
||||||
String[] dataInfo = blockInfo[1].split("[-]");
|
MaterialData blockMaterialData = new MaterialData(blockMaterial, blockData);
|
||||||
|
|
||||||
if (dataInfo.length == 2) {
|
if (blockList != null) {
|
||||||
byte startData = Byte.valueOf(dataInfo[0]);
|
blockList.add(blockMaterialData);
|
||||||
byte endData = Byte.valueOf(dataInfo[1]);
|
}
|
||||||
System.out.println(blockName + " Data range; [" + startData + " - " + endData + "]");
|
|
||||||
|
|
||||||
for (byte blockData = startData; blockData <= endData; blockData++) {
|
if (skillType.equals("Ability_Blocks")) {
|
||||||
MaterialData blockMaterialData = new MaterialData(blockMaterial, blockData);
|
continue;
|
||||||
loadBlock(skillType, blockList, blockName, blockMaterialData);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return;
|
int xp = config.getInt(skillType + "." + blockName + ".XP_Gain");
|
||||||
|
int smeltingXp = 0;
|
||||||
|
|
||||||
|
if (skillType.equals("Mining") && config.getBoolean(skillType + "." + blockName + ".Is_Ore")) {
|
||||||
|
customOres.add(blockMaterialData);
|
||||||
|
smeltingXp = config.getInt(skillType + "." + blockName + ".Smelting_XP_Gain", xp / 10);
|
||||||
|
}
|
||||||
|
else if (skillType.equals("Woodcutting")) {
|
||||||
|
if (config.getBoolean(skillType + "." + blockName + ".Is_Log")) {
|
||||||
|
customLogs.add(blockMaterialData);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
customLeaves.add(blockMaterialData);
|
||||||
|
xp = 0; // Leaves don't grant XP
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
byte blockData = (blockInfo.length == 2) ? Byte.valueOf(blockInfo[1]) : 0;
|
customBlockMap.put(blockMaterialData, new CustomBlock(xp, config.getBoolean(skillType + "." + blockName + ".Double_Drops_Enabled"), smeltingXp));
|
||||||
|
|
||||||
MaterialData blockMaterialData = new MaterialData(blockMaterial, blockData);
|
|
||||||
loadBlock(skillType, blockList, blockName, blockMaterialData);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void loadBlock(String skillType, List<MaterialData> blockList, String blockName, MaterialData blockMaterialData) {
|
|
||||||
System.out.println("Loading block: " + blockMaterialData.getItemType() + " " + blockMaterialData.getData());
|
|
||||||
if (blockList != null) {
|
|
||||||
blockList.add(blockMaterialData);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (skillType.equals("Ability_Blocks")) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
int xp = config.getInt(skillType + "." + blockName + ".XP_Gain");
|
|
||||||
int smeltingXp = 0;
|
|
||||||
|
|
||||||
if (skillType.equals("Mining") && config.getBoolean(skillType + "." + blockName + ".Is_Ore")) {
|
|
||||||
customOres.add(blockMaterialData);
|
|
||||||
smeltingXp = config.getInt(skillType + "." + blockName + ".Smelting_XP_Gain", xp / 10);
|
|
||||||
}
|
|
||||||
else if (skillType.equals("Woodcutting")) {
|
|
||||||
if (config.getBoolean(skillType + "." + blockName + ".Is_Log")) {
|
|
||||||
customLogs.add(blockMaterialData);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
customLeaves.add(blockMaterialData);
|
|
||||||
xp = 0; // Leaves don't grant XP
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
customBlockMap.put(blockMaterialData, new CustomBlock(xp, config.getBoolean(skillType + "." + blockName + ".Double_Drops_Enabled"), smeltingXp));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -93,13 +93,17 @@ public class CustomToolConfig extends ConfigLoader {
|
|||||||
repairQuantity = config.getInt(toolType + "." + toolName + ".Repair_Material_Data_Quantity", 2);
|
repairQuantity = config.getInt(toolType + "." + toolName + ".Repair_Material_Data_Quantity", 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String repairItemName = config.getString(toolType + "." + toolName + ".Repair_Material_Pretty_Name");
|
||||||
|
int repairMinimumLevel = config.getInt(toolType + "." + toolName + ".Repair_MinimumLevel", 0);
|
||||||
|
double repairXpMultiplier = config.getDouble(toolType + "." + toolName + ".Repair_XpMultiplier", 1);
|
||||||
|
|
||||||
short durability = toolMaterial.getMaxDurability();
|
short durability = toolMaterial.getMaxDurability();
|
||||||
|
|
||||||
if (durability == 0) {
|
if (durability == 0) {
|
||||||
durability = (short) config.getInt(toolType + "." + toolName + ".Durability", 60);
|
durability = (short) config.getInt(toolType + "." + toolName + ".Durability", 60);
|
||||||
}
|
}
|
||||||
|
|
||||||
repairables.add(RepairableFactory.getRepairable(toolMaterial, repairMaterial, repairData, 0, repairQuantity, durability, ItemType.TOOL, MaterialType.OTHER, 1.0));
|
repairables.add(RepairableFactory.getRepairable(toolMaterial, repairMaterial, repairData, repairItemName, repairMinimumLevel, repairQuantity, durability, ItemType.TOOL, MaterialType.OTHER, repairXpMultiplier));
|
||||||
}
|
}
|
||||||
|
|
||||||
double multiplier = config.getDouble(toolType + "." + toolName + ".XP_Modifier", 1.0);
|
double multiplier = config.getDouble(toolType + "." + toolName + ".XP_Modifier", 1.0);
|
||||||
|
|||||||
@@ -35,6 +35,8 @@ public class TreasureConfig extends ConfigLoader {
|
|||||||
public List<ExcavationTreasure> excavationFromMycel = new ArrayList<ExcavationTreasure>();
|
public List<ExcavationTreasure> excavationFromMycel = new ArrayList<ExcavationTreasure>();
|
||||||
public List<ExcavationTreasure> excavationFromSoulSand = new ArrayList<ExcavationTreasure>();
|
public List<ExcavationTreasure> excavationFromSoulSand = new ArrayList<ExcavationTreasure>();
|
||||||
public List<ExcavationTreasure> excavationFromSnow = new ArrayList<ExcavationTreasure>();
|
public List<ExcavationTreasure> excavationFromSnow = new ArrayList<ExcavationTreasure>();
|
||||||
|
public List<ExcavationTreasure> excavationFromRedSand = new ArrayList<ExcavationTreasure>();
|
||||||
|
public List<ExcavationTreasure> excavationFromPodzol = new ArrayList<ExcavationTreasure>();
|
||||||
|
|
||||||
public List<HylianTreasure> hylianFromBushes = new ArrayList<HylianTreasure>();
|
public List<HylianTreasure> hylianFromBushes = new ArrayList<HylianTreasure>();
|
||||||
public List<HylianTreasure> hylianFromFlowers = new ArrayList<HylianTreasure>();
|
public List<HylianTreasure> hylianFromFlowers = new ArrayList<HylianTreasure>();
|
||||||
@@ -257,13 +259,13 @@ public class TreasureConfig extends ConfigLoader {
|
|||||||
|
|
||||||
if (config.contains(type + "." + treasureName + ".Custom_Name")) {
|
if (config.contains(type + "." + treasureName + ".Custom_Name")) {
|
||||||
ItemMeta itemMeta = item.getItemMeta();
|
ItemMeta itemMeta = item.getItemMeta();
|
||||||
itemMeta.setDisplayName(config.getString(type + "." + treasureName + "Custom_Name"));
|
itemMeta.setDisplayName(config.getString(type + "." + treasureName + ".Custom_Name"));
|
||||||
item.setItemMeta(itemMeta);
|
item.setItemMeta(itemMeta);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (config.contains(type + "." + treasureName + ".Lore")) {
|
if (config.contains(type + "." + treasureName + ".Lore")) {
|
||||||
ItemMeta itemMeta = item.getItemMeta();
|
ItemMeta itemMeta = item.getItemMeta();
|
||||||
itemMeta.setLore(config.getStringList(type + "." + treasureName + "Custom_Name"));
|
itemMeta.setLore(config.getStringList(type + "." + treasureName + ".Lore"));
|
||||||
item.setItemMeta(itemMeta);
|
item.setItemMeta(itemMeta);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -374,6 +376,14 @@ public class TreasureConfig extends ConfigLoader {
|
|||||||
if (dropList.contains("Snow")) {
|
if (dropList.contains("Snow")) {
|
||||||
excavationFromSnow.add(excavationTreasure);
|
excavationFromSnow.add(excavationTreasure);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (dropList.contains("Red_Sand")) {
|
||||||
|
excavationFromRedSand.add(excavationTreasure);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (dropList.contains("Podzol")) {
|
||||||
|
excavationFromPodzol.add(excavationTreasure);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (isHylian) {
|
else if (isHylian) {
|
||||||
HylianTreasure hylianTreasure = new HylianTreasure(item, xp, dropChance, dropLevel);
|
HylianTreasure hylianTreasure = new HylianTreasure(item, xp, dropChance, dropLevel);
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package com.gmail.nossr50.database;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
import com.gmail.nossr50.config.Config;
|
import com.gmail.nossr50.config.Config;
|
||||||
import com.gmail.nossr50.datatypes.database.DatabaseType;
|
import com.gmail.nossr50.datatypes.database.DatabaseType;
|
||||||
@@ -67,19 +68,42 @@ public interface DatabaseManager {
|
|||||||
*
|
*
|
||||||
* @param playerName The name of the player to be added to the database
|
* @param playerName The name of the player to be added to the database
|
||||||
*/
|
*/
|
||||||
public void newUser(String playerName);
|
public void newUser(String playerName, String uuid);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load a player from the database.
|
* Load a player from the database.
|
||||||
*
|
*
|
||||||
|
* @deprecated replaced by {@link #loadPlayerProfile(String playerName, UUID uuid, boolean createNew)}
|
||||||
|
*
|
||||||
* @param playerName The name of the player to load from the database
|
* @param playerName The name of the player to load from the database
|
||||||
* @param createNew Whether to create a new record if the player is not
|
* @param createNew Whether to create a new record if the player is not
|
||||||
* found
|
* found
|
||||||
* @return The player's data, or an unloaded PlayerProfile if not found
|
* @return The player's data, or an unloaded PlayerProfile if not found
|
||||||
* and createNew is false
|
* and createNew is false
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
public PlayerProfile loadPlayerProfile(String playerName, boolean createNew);
|
public PlayerProfile loadPlayerProfile(String playerName, boolean createNew);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Load a player from the database.
|
||||||
|
*
|
||||||
|
* @param uuid The uuid of the player to load from the database
|
||||||
|
* @return The player's data, or an unloaded PlayerProfile if not found
|
||||||
|
*/
|
||||||
|
public PlayerProfile loadPlayerProfile(UUID uuid);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Load a player from the database. Attempt to use uuid, fall back on playername
|
||||||
|
*
|
||||||
|
* @param playerName The name of the player to load from the database
|
||||||
|
* @param uuid The uuid of the player to load from the database
|
||||||
|
* @param createNew Whether to create a new record if the player is not
|
||||||
|
* found
|
||||||
|
* @return The player's data, or an unloaded PlayerProfile if not found
|
||||||
|
* and createNew is false
|
||||||
|
*/
|
||||||
|
public PlayerProfile loadPlayerProfile(String playerName, UUID uuid, boolean createNew);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get all users currently stored in the database.
|
* Get all users currently stored in the database.
|
||||||
*
|
*
|
||||||
@@ -95,10 +119,19 @@ public interface DatabaseManager {
|
|||||||
*/
|
*/
|
||||||
public void convertUsers(DatabaseManager destination);
|
public void convertUsers(DatabaseManager destination);
|
||||||
|
|
||||||
|
public boolean saveUserUUID(String userName, UUID uuid);
|
||||||
|
|
||||||
|
public boolean saveUserUUIDs(Map<String, UUID> fetchedUUIDs);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve the type of database in use. Custom databases should return CUSTOM.
|
* Retrieve the type of database in use. Custom databases should return CUSTOM.
|
||||||
*
|
*
|
||||||
* @return The type of database
|
* @return The type of database
|
||||||
*/
|
*/
|
||||||
public DatabaseType getDatabaseType();
|
public DatabaseType getDatabaseType();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when the plugin disables
|
||||||
|
*/
|
||||||
|
public void onDisable();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ package com.gmail.nossr50.database;
|
|||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.BufferedWriter;
|
import java.io.BufferedWriter;
|
||||||
import java.io.Closeable;
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileReader;
|
import java.io.FileReader;
|
||||||
import java.io.FileWriter;
|
import java.io.FileWriter;
|
||||||
@@ -10,10 +9,12 @@ import java.io.IOException;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
|
import java.util.EnumMap;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
|
|
||||||
@@ -22,9 +23,11 @@ import com.gmail.nossr50.config.Config;
|
|||||||
import com.gmail.nossr50.datatypes.MobHealthbarType;
|
import com.gmail.nossr50.datatypes.MobHealthbarType;
|
||||||
import com.gmail.nossr50.datatypes.database.DatabaseType;
|
import com.gmail.nossr50.datatypes.database.DatabaseType;
|
||||||
import com.gmail.nossr50.datatypes.database.PlayerStat;
|
import com.gmail.nossr50.datatypes.database.PlayerStat;
|
||||||
|
import com.gmail.nossr50.datatypes.database.UpgradeType;
|
||||||
import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
||||||
import com.gmail.nossr50.datatypes.skills.AbilityType;
|
import com.gmail.nossr50.datatypes.skills.AbilityType;
|
||||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||||
|
import com.gmail.nossr50.runnables.database.UUIDUpdateAsyncTask;
|
||||||
import com.gmail.nossr50.util.Misc;
|
import com.gmail.nossr50.util.Misc;
|
||||||
import com.gmail.nossr50.util.StringUtils;
|
import com.gmail.nossr50.util.StringUtils;
|
||||||
|
|
||||||
@@ -43,6 +46,10 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
|
|||||||
usersFile = new File(mcMMO.getUsersFilePath());
|
usersFile = new File(mcMMO.getUsersFilePath());
|
||||||
checkStructure();
|
checkStructure();
|
||||||
updateLeaderboards();
|
updateLeaderboards();
|
||||||
|
|
||||||
|
if (mcMMO.getUpgradeManager().shouldUpgrade(UpgradeType.ADD_UUIDS)) {
|
||||||
|
new UUIDUpdateAsyncTask(mcMMO.p, getStoredUsers()).runTaskAsynchronously(mcMMO.p);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void purgePowerlessUsers() {
|
public void purgePowerlessUsers() {
|
||||||
@@ -91,8 +98,22 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
|
|||||||
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 + " (Are you sure you formatted it correctly?)" + e.toString());
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
tryClose(in);
|
if (in != null) {
|
||||||
tryClose(out);
|
try {
|
||||||
|
in.close();
|
||||||
|
}
|
||||||
|
catch (IOException e) {
|
||||||
|
// Ignore
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (out != null) {
|
||||||
|
try {
|
||||||
|
out.close();
|
||||||
|
}
|
||||||
|
catch (IOException e) {
|
||||||
|
// Ignore
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -157,8 +178,22 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
|
|||||||
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 + " (Are you sure you formatted it correctly?)" + e.toString());
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
tryClose(in);
|
if (in != null) {
|
||||||
tryClose(out);
|
try {
|
||||||
|
in.close();
|
||||||
|
}
|
||||||
|
catch (IOException e) {
|
||||||
|
// Ignore
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (out != null) {
|
||||||
|
try {
|
||||||
|
out.close();
|
||||||
|
}
|
||||||
|
catch (IOException e) {
|
||||||
|
// Ignore
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -196,8 +231,22 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
|
|||||||
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 + " (Are you sure you formatted it correctly?)" + e.toString());
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
tryClose(in);
|
if (in != null) {
|
||||||
tryClose(out);
|
try {
|
||||||
|
in.close();
|
||||||
|
}
|
||||||
|
catch (IOException e) {
|
||||||
|
// Ignore
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (out != null) {
|
||||||
|
try {
|
||||||
|
out.close();
|
||||||
|
}
|
||||||
|
catch (IOException e) {
|
||||||
|
// Ignore
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -208,6 +257,7 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
|
|||||||
|
|
||||||
public boolean saveUser(PlayerProfile profile) {
|
public boolean saveUser(PlayerProfile profile) {
|
||||||
String playerName = profile.getPlayerName();
|
String playerName = profile.getPlayerName();
|
||||||
|
UUID uuid = profile.getUniqueId();
|
||||||
|
|
||||||
BufferedReader in = null;
|
BufferedReader in = null;
|
||||||
FileWriter out = null;
|
FileWriter out = null;
|
||||||
@@ -222,8 +272,9 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
|
|||||||
|
|
||||||
// While not at the end of the file
|
// While not at the end of the file
|
||||||
while ((line = in.readLine()) != null) {
|
while ((line = in.readLine()) != null) {
|
||||||
// Read the line in and copy it to the output it's not the player we want to edit
|
// Read the line in and copy it to the output if it's not the player we want to edit
|
||||||
if (!line.split(":")[0].equalsIgnoreCase(playerName)) {
|
String[] character = line.split(":");
|
||||||
|
if (!character[41].equalsIgnoreCase(uuid.toString()) && !character[0].equalsIgnoreCase(playerName)) {
|
||||||
writer.append(line).append("\r\n");
|
writer.append(line).append("\r\n");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -270,6 +321,7 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
|
|||||||
writer.append(mobHealthbarType == null ? Config.getInstance().getMobHealthbarDefault().toString() : mobHealthbarType.toString()).append(":");
|
writer.append(mobHealthbarType == null ? Config.getInstance().getMobHealthbarDefault().toString() : mobHealthbarType.toString()).append(":");
|
||||||
writer.append(profile.getSkillLevel(SkillType.ALCHEMY)).append(":");
|
writer.append(profile.getSkillLevel(SkillType.ALCHEMY)).append(":");
|
||||||
writer.append(profile.getSkillXpLevel(SkillType.ALCHEMY)).append(":");
|
writer.append(profile.getSkillXpLevel(SkillType.ALCHEMY)).append(":");
|
||||||
|
writer.append(uuid.toString()).append(":");
|
||||||
writer.append("\r\n");
|
writer.append("\r\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -284,8 +336,22 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
tryClose(in);
|
if (in != null) {
|
||||||
tryClose(out);
|
try {
|
||||||
|
in.close();
|
||||||
|
}
|
||||||
|
catch (IOException e) {
|
||||||
|
// Ignore
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (out != null) {
|
||||||
|
try {
|
||||||
|
out.close();
|
||||||
|
}
|
||||||
|
catch (IOException e) {
|
||||||
|
// Ignore
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -301,7 +367,7 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
|
|||||||
public Map<SkillType, Integer> readRank(String playerName) {
|
public Map<SkillType, Integer> readRank(String playerName) {
|
||||||
updateLeaderboards();
|
updateLeaderboards();
|
||||||
|
|
||||||
Map<SkillType, Integer> skills = new HashMap<SkillType, Integer>();
|
Map<SkillType, Integer> skills = new EnumMap<SkillType, Integer>(SkillType.class);
|
||||||
|
|
||||||
for (SkillType skill : SkillType.NON_CHILD_SKILLS) {
|
for (SkillType skill : SkillType.NON_CHILD_SKILLS) {
|
||||||
skills.put(skill, getPlayerRank(playerName, playerStatHash.get(skill)));
|
skills.put(skill, getPlayerRank(playerName, playerStatHash.get(skill)));
|
||||||
@@ -312,7 +378,7 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
|
|||||||
return skills;
|
return skills;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void newUser(String playerName) {
|
public void newUser(String playerName, String uuid) {
|
||||||
BufferedWriter out = null;
|
BufferedWriter out = null;
|
||||||
synchronized (fileWritingLock) {
|
synchronized (fileWritingLock) {
|
||||||
try {
|
try {
|
||||||
@@ -361,6 +427,7 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
|
|||||||
out.append(Config.getInstance().getMobHealthbarDefault().toString()).append(":"); // Mob Healthbar HUD
|
out.append(Config.getInstance().getMobHealthbarDefault().toString()).append(":"); // Mob Healthbar HUD
|
||||||
out.append("0:"); // Alchemy
|
out.append("0:"); // Alchemy
|
||||||
out.append("0:"); // AlchemyXp
|
out.append("0:"); // AlchemyXp
|
||||||
|
out.append(uuid).append(":"); // UUID
|
||||||
|
|
||||||
// Add more in the same format as the line above
|
// Add more in the same format as the line above
|
||||||
|
|
||||||
@@ -370,12 +437,32 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
|
|||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
tryClose(out);
|
if (out != null) {
|
||||||
|
try {
|
||||||
|
out.close();
|
||||||
|
}
|
||||||
|
catch (IOException e) {
|
||||||
|
// Ignore
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public PlayerProfile loadPlayerProfile(String playerName, boolean create) {
|
public PlayerProfile loadPlayerProfile(String playerName, boolean create) {
|
||||||
|
return loadPlayerProfile(playerName, "", false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public PlayerProfile loadPlayerProfile(UUID uuid) {
|
||||||
|
return loadPlayerProfile("", uuid.toString(), false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public PlayerProfile loadPlayerProfile(String playerName, UUID uuid, boolean create) {
|
||||||
|
return loadPlayerProfile(playerName, uuid.toString(), create);
|
||||||
|
}
|
||||||
|
|
||||||
|
private PlayerProfile loadPlayerProfile(String playerName, String uuid, boolean create) {
|
||||||
BufferedReader in = null;
|
BufferedReader in = null;
|
||||||
String usersFilePath = mcMMO.getUsersFilePath();
|
String usersFilePath = mcMMO.getUsersFilePath();
|
||||||
|
|
||||||
@@ -389,17 +476,28 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
|
|||||||
// Find if the line contains the player we want.
|
// Find if the line contains the player we want.
|
||||||
String[] character = line.split(":");
|
String[] character = line.split(":");
|
||||||
|
|
||||||
if (!character[0].equalsIgnoreCase(playerName)) {
|
if (!character[41].equalsIgnoreCase(uuid) && !character[0].equalsIgnoreCase(playerName)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Update playerName in database after name change
|
||||||
|
if (!character[0].equalsIgnoreCase(playerName)) {
|
||||||
|
mcMMO.p.debug("Name change detected: " + character[0] + " => " + playerName);
|
||||||
|
character[0] = playerName;
|
||||||
|
}
|
||||||
|
|
||||||
return loadFromLine(character);
|
return loadFromLine(character);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Didn't find the player, create a new one
|
// Didn't find the player, create a new one
|
||||||
if (create) {
|
if (create) {
|
||||||
newUser(playerName);
|
if (uuid.isEmpty()) {
|
||||||
return new PlayerProfile(playerName, true);
|
newUser(playerName, uuid);
|
||||||
|
return new PlayerProfile(playerName, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
newUser(playerName, uuid);
|
||||||
|
return new PlayerProfile(playerName, UUID.fromString(uuid), true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e) {
|
catch (Exception e) {
|
||||||
@@ -413,14 +511,18 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
|
|||||||
in.close();
|
in.close();
|
||||||
}
|
}
|
||||||
catch (IOException e) {
|
catch (IOException e) {
|
||||||
e.printStackTrace();
|
// Ignore
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return unloaded profile
|
// Return unloaded profile
|
||||||
return new PlayerProfile(playerName);
|
if (uuid.isEmpty()) {
|
||||||
|
return new PlayerProfile(playerName);
|
||||||
|
}
|
||||||
|
|
||||||
|
return new PlayerProfile(playerName, UUID.fromString(uuid));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void convertUsers(DatabaseManager destination) {
|
public void convertUsers(DatabaseManager destination) {
|
||||||
@@ -452,11 +554,131 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
|
|||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
tryClose(in);
|
if (in != null) {
|
||||||
|
try {
|
||||||
|
in.close();
|
||||||
|
}
|
||||||
|
catch (IOException e) {
|
||||||
|
// Ignore
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean saveUserUUID(String userName, UUID uuid) {
|
||||||
|
boolean worked = false;
|
||||||
|
|
||||||
|
BufferedReader in = null;
|
||||||
|
FileWriter out = null;
|
||||||
|
String usersFilePath = mcMMO.getUsersFilePath();
|
||||||
|
|
||||||
|
synchronized (fileWritingLock) {
|
||||||
|
try {
|
||||||
|
in = new BufferedReader(new FileReader(usersFilePath));
|
||||||
|
StringBuilder writer = new StringBuilder();
|
||||||
|
String line;
|
||||||
|
|
||||||
|
while ((line = in.readLine()) != null) {
|
||||||
|
String[] character = line.split(":");
|
||||||
|
if (!worked && character[0].equalsIgnoreCase(userName)) {
|
||||||
|
if (character.length < 42) {
|
||||||
|
mcMMO.p.getLogger().severe("Could not update UUID for " + userName + "!");
|
||||||
|
mcMMO.p.getLogger().severe("Database entry is invalid.");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
line = line.replace(character[41], uuid.toString());
|
||||||
|
worked = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
writer.append(line).append("\r\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
out = new FileWriter(usersFilePath); // Write out the new file
|
||||||
|
out.write(writer.toString());
|
||||||
|
}
|
||||||
|
catch (Exception e) {
|
||||||
|
mcMMO.p.getLogger().severe("Exception while reading " + usersFilePath + " (Are you sure you formatted it correctly?)" + e.toString());
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
if (in != null) {
|
||||||
|
try {
|
||||||
|
in.close();
|
||||||
|
}
|
||||||
|
catch (IOException e) {
|
||||||
|
// Ignore
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (out != null) {
|
||||||
|
try {
|
||||||
|
out.close();
|
||||||
|
}
|
||||||
|
catch (IOException e) {
|
||||||
|
// Ignore
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return worked;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean saveUserUUIDs(Map<String, UUID> fetchedUUIDs) {
|
||||||
|
BufferedReader in = null;
|
||||||
|
FileWriter out = null;
|
||||||
|
String usersFilePath = mcMMO.getUsersFilePath();
|
||||||
|
|
||||||
|
synchronized (fileWritingLock) {
|
||||||
|
try {
|
||||||
|
in = new BufferedReader(new FileReader(usersFilePath));
|
||||||
|
StringBuilder writer = new StringBuilder();
|
||||||
|
String line;
|
||||||
|
|
||||||
|
while (((line = in.readLine()) != null) && !fetchedUUIDs.isEmpty()) {
|
||||||
|
String[] character = line.split(":");
|
||||||
|
if (fetchedUUIDs.containsKey(character[0])) {
|
||||||
|
if (character.length < 42) {
|
||||||
|
mcMMO.p.getLogger().severe("Could not update UUID for " + character[0] + "!");
|
||||||
|
mcMMO.p.getLogger().severe("Database entry is invalid.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
line = line.replace(character[41], fetchedUUIDs.remove(character[0]).toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
writer.append(line).append("\r\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
out = new FileWriter(usersFilePath); // Write out the new file
|
||||||
|
out.write(writer.toString());
|
||||||
|
}
|
||||||
|
catch (Exception e) {
|
||||||
|
mcMMO.p.getLogger().severe("Exception while reading " + usersFilePath + " (Are you sure you formatted it correctly?)" + e.toString());
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
if (in != null) {
|
||||||
|
try {
|
||||||
|
in.close();
|
||||||
|
}
|
||||||
|
catch (IOException e) {
|
||||||
|
// Ignore
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (out != null) {
|
||||||
|
try {
|
||||||
|
out.close();
|
||||||
|
}
|
||||||
|
catch (IOException e) {
|
||||||
|
// Ignore
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
public List<String> getStoredUsers() {
|
public List<String> getStoredUsers() {
|
||||||
ArrayList<String> users = new ArrayList<String>();
|
ArrayList<String> users = new ArrayList<String>();
|
||||||
BufferedReader in = null;
|
BufferedReader in = null;
|
||||||
@@ -477,7 +699,14 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
|
|||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
tryClose(in);
|
if (in != null) {
|
||||||
|
try {
|
||||||
|
in.close();
|
||||||
|
}
|
||||||
|
catch (IOException e) {
|
||||||
|
// Ignore
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return users;
|
return users;
|
||||||
@@ -547,7 +776,14 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
|
|||||||
mcMMO.p.getLogger().severe("Exception while reading " + usersFilePath + " during user " + playerName + " (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 {
|
finally {
|
||||||
tryClose(in);
|
if (in != null) {
|
||||||
|
try {
|
||||||
|
in.close();
|
||||||
|
}
|
||||||
|
catch (IOException e) {
|
||||||
|
// Ignore
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -597,6 +833,7 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
|
|||||||
in = new BufferedReader(new FileReader(usersFilePath));
|
in = new BufferedReader(new FileReader(usersFilePath));
|
||||||
StringBuilder writer = new StringBuilder();
|
StringBuilder writer = new StringBuilder();
|
||||||
String line;
|
String line;
|
||||||
|
HashSet<String> usernames = new HashSet<String>();
|
||||||
HashSet<String> players = new HashSet<String>();
|
HashSet<String> players = new HashSet<String>();
|
||||||
|
|
||||||
while ((line = in.readLine()) != null) {
|
while ((line = in.readLine()) != null) {
|
||||||
@@ -611,8 +848,13 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
|
|||||||
}
|
}
|
||||||
String[] character = line.split(":");
|
String[] character = line.split(":");
|
||||||
|
|
||||||
|
// Prevent the same username from being present multiple times
|
||||||
|
if (!usernames.add(character[0])) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
// Prevent the same player from being present multiple times
|
// Prevent the same player from being present multiple times
|
||||||
if (!players.add(character[0])) {
|
if (character.length == 42 && (!character[41].isEmpty() && !players.add(character[41]))) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -644,7 +886,7 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// If they're valid, rewrite them to the file.
|
// If they're valid, rewrite them to the file.
|
||||||
if (character.length == 41) {
|
if (character.length == 42) {
|
||||||
writer.append(line).append("\r\n");
|
writer.append(line).append("\r\n");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -698,16 +940,25 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
|
|||||||
oldVersion = "1.4.08";
|
oldVersion = "1.4.08";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (character.length <= 41) {
|
||||||
|
// Addition of UUIDs
|
||||||
|
// Version 1.5.01
|
||||||
|
// Add a space because otherwise it gets removed
|
||||||
|
newLine.append(" :");
|
||||||
|
if (oldVersion == null) {
|
||||||
|
oldVersion = "1.5.01";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Remove any blanks that shouldn't be there, and validate the other fields
|
// Remove any blanks that shouldn't be there, and validate the other fields
|
||||||
String[] newCharacter = newLine.toString().split(":");
|
String[] newCharacter = newLine.toString().split(":");
|
||||||
boolean corrupted = false;
|
boolean corrupted = false;
|
||||||
|
|
||||||
for (int i = 0; i < newCharacter.length; i++) {
|
for (int i = 0; i < newCharacter.length; i++) {
|
||||||
if (newCharacter[i].isEmpty() && !(i == 2 || i == 3 || i == 23 || i == 33)) {
|
if (newCharacter[i].isEmpty() && !(i == 2 || i == 3 || i == 23 || i == 33 || i == 41)) {
|
||||||
corrupted = true;
|
corrupted = true;
|
||||||
|
|
||||||
if (newCharacter.length != 41) {
|
if (newCharacter.length != 42) {
|
||||||
newCharacter = (String[]) ArrayUtils.remove(newCharacter, i);
|
newCharacter = (String[]) ArrayUtils.remove(newCharacter, i);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -728,7 +979,7 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
|
|||||||
newCharacter[i] = Config.getInstance().getMobHealthbarDefault().toString();
|
newCharacter[i] = Config.getInstance().getMobHealthbarDefault().toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!StringUtils.isInt(newCharacter[i]) && !(i == 0 || i == 2 || i == 3 || i == 23 || i == 33 || i == 38)) {
|
if (!StringUtils.isInt(newCharacter[i]) && !(i == 0 || i == 2 || i == 3 || i == 23 || i == 33 || i == 38 || i == 41)) {
|
||||||
corrupted = true;
|
corrupted = true;
|
||||||
newCharacter[i] = "0";
|
newCharacter[i] = "0";
|
||||||
}
|
}
|
||||||
@@ -736,11 +987,15 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
|
|||||||
|
|
||||||
if (corrupted) {
|
if (corrupted) {
|
||||||
mcMMO.p.debug("Updating corrupted database line for player " + newCharacter[0]);
|
mcMMO.p.debug("Updating corrupted database line for player " + newCharacter[0]);
|
||||||
newLine = new StringBuilder(org.apache.commons.lang.StringUtils.join(newCharacter, ":"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (oldVersion != null) {
|
if (oldVersion != null) {
|
||||||
mcMMO.p.debug("Updating database line for player " + character[0] + " from before version " + oldVersion);
|
mcMMO.p.debug("Updating database line from before version " + oldVersion + " for player " + character[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (corrupted || oldVersion != null) {
|
||||||
|
newLine = new StringBuilder(org.apache.commons.lang.StringUtils.join(newCharacter, ":"));
|
||||||
|
newLine = newLine.append(":");
|
||||||
}
|
}
|
||||||
|
|
||||||
writer.append(newLine).append("\r\n");
|
writer.append(newLine).append("\r\n");
|
||||||
@@ -754,10 +1009,32 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
|
|||||||
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 + " (Are you sure you formatted it correctly?)" + e.toString());
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
tryClose(in);
|
if (in != null) {
|
||||||
tryClose(out);
|
try {
|
||||||
|
in.close();
|
||||||
|
}
|
||||||
|
catch (IOException e) {
|
||||||
|
// Ignore
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (out != null) {
|
||||||
|
try {
|
||||||
|
out.close();
|
||||||
|
}
|
||||||
|
catch (IOException e) {
|
||||||
|
// Ignore
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mcMMO.getUpgradeManager().setUpgradeCompleted(UpgradeType.ADD_FISHING);
|
||||||
|
mcMMO.getUpgradeManager().setUpgradeCompleted(UpgradeType.ADD_BLAST_MINING_COOLDOWN);
|
||||||
|
mcMMO.getUpgradeManager().setUpgradeCompleted(UpgradeType.ADD_SQL_INDEXES);
|
||||||
|
mcMMO.getUpgradeManager().setUpgradeCompleted(UpgradeType.ADD_MOB_HEALTHBARS);
|
||||||
|
mcMMO.getUpgradeManager().setUpgradeCompleted(UpgradeType.DROP_SQL_PARTY_NAMES);
|
||||||
|
mcMMO.getUpgradeManager().setUpgradeCompleted(UpgradeType.DROP_SPOUT);
|
||||||
|
mcMMO.getUpgradeManager().setUpgradeCompleted(UpgradeType.ADD_ALCHEMY);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -772,18 +1049,6 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void tryClose(Closeable c) {
|
|
||||||
if (c == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
c.close();
|
|
||||||
}
|
|
||||||
catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private Integer getPlayerRank(String playerName, List<PlayerStat> statsList) {
|
private Integer getPlayerRank(String playerName, List<PlayerStat> statsList) {
|
||||||
if (statsList == null) {
|
if (statsList == null) {
|
||||||
return null;
|
return null;
|
||||||
@@ -816,8 +1081,8 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
|
|||||||
|
|
||||||
private PlayerProfile loadFromLine(String[] character) {
|
private PlayerProfile loadFromLine(String[] character) {
|
||||||
Map<SkillType, Integer> skills = getSkillMapFromLine(character); // Skill levels
|
Map<SkillType, Integer> skills = getSkillMapFromLine(character); // Skill levels
|
||||||
Map<SkillType, Float> skillsXp = new HashMap<SkillType, Float>(); // Skill & XP
|
Map<SkillType, Float> skillsXp = new EnumMap<SkillType, Float>(SkillType.class); // Skill & XP
|
||||||
Map<AbilityType, Integer> skillsDATS = new HashMap<AbilityType, Integer>(); // Ability & Cooldown
|
Map<AbilityType, Integer> skillsDATS = new EnumMap<AbilityType, Integer>(AbilityType.class); // Ability & Cooldown
|
||||||
MobHealthbarType mobHealthbarType;
|
MobHealthbarType mobHealthbarType;
|
||||||
|
|
||||||
// TODO on updates, put new values in a try{} ?
|
// TODO on updates, put new values in a try{} ?
|
||||||
@@ -856,11 +1121,19 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
|
|||||||
mobHealthbarType = Config.getInstance().getMobHealthbarDefault();
|
mobHealthbarType = Config.getInstance().getMobHealthbarDefault();
|
||||||
}
|
}
|
||||||
|
|
||||||
return new PlayerProfile(character[0], skills, skillsXp, skillsDATS, mobHealthbarType);
|
UUID uuid;
|
||||||
|
try {
|
||||||
|
uuid = UUID.fromString(character[41]);
|
||||||
|
}
|
||||||
|
catch (Exception e) {
|
||||||
|
uuid = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return new PlayerProfile(character[0], uuid, skills, skillsXp, skillsDATS, mobHealthbarType);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Map<SkillType, Integer> getSkillMapFromLine(String[] character) {
|
private Map<SkillType, Integer> getSkillMapFromLine(String[] character) {
|
||||||
Map<SkillType, Integer> skills = new HashMap<SkillType, Integer>(); // Skill & Level
|
Map<SkillType, Integer> skills = new EnumMap<SkillType, Integer>(SkillType.class); // Skill & Level
|
||||||
|
|
||||||
skills.put(SkillType.TAMING, Integer.valueOf(character[24]));
|
skills.put(SkillType.TAMING, Integer.valueOf(character[24]));
|
||||||
skills.put(SkillType.MINING, Integer.valueOf(character[1]));
|
skills.put(SkillType.MINING, Integer.valueOf(character[1]));
|
||||||
@@ -882,4 +1155,7 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
|
|||||||
public DatabaseType getDatabaseType() {
|
public DatabaseType getDatabaseType() {
|
||||||
return DatabaseType.FLATFILE;
|
return DatabaseType.FLATFILE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDisable() { }
|
||||||
}
|
}
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -1,13 +0,0 @@
|
|||||||
package com.gmail.nossr50.datatypes.database;
|
|
||||||
|
|
||||||
public enum DatabaseUpdateType {
|
|
||||||
FISHING,
|
|
||||||
BLAST_MINING,
|
|
||||||
INDEX,
|
|
||||||
MOB_HEALTHBARS,
|
|
||||||
PARTY_NAMES,
|
|
||||||
KILL_ORPHANS,
|
|
||||||
DROPPED_SPOUT,
|
|
||||||
ALCHEMY
|
|
||||||
;
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
package com.gmail.nossr50.datatypes.database;
|
||||||
|
|
||||||
|
public enum UpgradeType {
|
||||||
|
ADD_FISHING,
|
||||||
|
ADD_BLAST_MINING_COOLDOWN,
|
||||||
|
ADD_SQL_INDEXES,
|
||||||
|
ADD_MOB_HEALTHBARS,
|
||||||
|
DROP_SQL_PARTY_NAMES,
|
||||||
|
DROP_SPOUT,
|
||||||
|
ADD_ALCHEMY,
|
||||||
|
ADD_UUIDS;
|
||||||
|
}
|
||||||
@@ -3,6 +3,7 @@ package com.gmail.nossr50.datatypes.player;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
import org.bukkit.GameMode;
|
import org.bukkit.GameMode;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
@@ -92,15 +93,20 @@ public class McMMOPlayer {
|
|||||||
private boolean isUsingUnarmed;
|
private boolean isUsingUnarmed;
|
||||||
private final FixedMetadataValue playerMetadata;
|
private final FixedMetadataValue playerMetadata;
|
||||||
|
|
||||||
public McMMOPlayer(Player player) {
|
public McMMOPlayer(Player player, PlayerProfile profile) {
|
||||||
String playerName = player.getName();
|
String playerName = player.getName();
|
||||||
|
UUID uuid = player.getUniqueId();
|
||||||
|
|
||||||
this.player = player;
|
this.player = player;
|
||||||
playerMetadata = new FixedMetadataValue(mcMMO.p, playerName);
|
playerMetadata = new FixedMetadataValue(mcMMO.p, playerName);
|
||||||
profile = mcMMO.getDatabaseManager().loadPlayerProfile(playerName, true);
|
this.profile = profile;
|
||||||
party = PartyManager.getPlayerParty(playerName);
|
party = PartyManager.getPlayerParty(playerName);
|
||||||
ptpRecord = new PartyTeleportRecord();
|
ptpRecord = new PartyTeleportRecord();
|
||||||
|
|
||||||
|
if (profile.getUniqueId() == null) {
|
||||||
|
profile.setUniqueId(uuid);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* I'm using this method because it makes code shorter and safer (we don't have to add all SkillTypes manually),
|
* I'm using this method because it makes code shorter and safer (we don't have to add all SkillTypes manually),
|
||||||
* but I actually have no idea about the performance impact, if there is any.
|
* but I actually have no idea about the performance impact, if there is any.
|
||||||
@@ -124,69 +130,6 @@ public class McMMOPlayer {
|
|||||||
for (ToolType toolType : ToolType.values()) {
|
for (ToolType toolType : ToolType.values()) {
|
||||||
toolMode.put(toolType, false);
|
toolMode.put(toolType, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
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() {
|
public AcrobaticsManager getAcrobaticsManager() {
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package com.gmail.nossr50.datatypes.player;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.gmail.nossr50.config.Config;
|
import com.gmail.nossr50.config.Config;
|
||||||
@@ -19,6 +20,7 @@ import com.google.common.collect.ImmutableMap;
|
|||||||
|
|
||||||
public class PlayerProfile {
|
public class PlayerProfile {
|
||||||
private final String playerName;
|
private final String playerName;
|
||||||
|
private UUID uuid;
|
||||||
private boolean loaded;
|
private boolean loaded;
|
||||||
private volatile boolean changed;
|
private volatile boolean changed;
|
||||||
|
|
||||||
@@ -30,7 +32,13 @@ public class PlayerProfile {
|
|||||||
private final Map<SkillType, Float> skillsXp = new HashMap<SkillType, Float>(); // Skill & XP
|
private final Map<SkillType, Float> skillsXp = new HashMap<SkillType, Float>(); // Skill & XP
|
||||||
private final Map<AbilityType, Integer> abilityDATS = new HashMap<AbilityType, Integer>(); // Ability & Cooldown
|
private final Map<AbilityType, Integer> abilityDATS = new HashMap<AbilityType, Integer>(); // Ability & Cooldown
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public PlayerProfile(String playerName) {
|
public PlayerProfile(String playerName) {
|
||||||
|
this(playerName, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public PlayerProfile(String playerName, UUID uuid) {
|
||||||
|
this.uuid = uuid;
|
||||||
this.playerName = playerName;
|
this.playerName = playerName;
|
||||||
|
|
||||||
mobHealthbarType = Config.getInstance().getMobHealthbarDefault();
|
mobHealthbarType = Config.getInstance().getMobHealthbarDefault();
|
||||||
@@ -45,13 +53,20 @@ public class PlayerProfile {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public PlayerProfile(String playerName, boolean isLoaded) {
|
public PlayerProfile(String playerName, boolean isLoaded) {
|
||||||
this(playerName);
|
this(playerName);
|
||||||
this.loaded = isLoaded;
|
this.loaded = isLoaded;
|
||||||
}
|
}
|
||||||
|
|
||||||
public PlayerProfile(String playerName, Map<SkillType, Integer> levelData, Map<SkillType, Float> xpData, Map<AbilityType, Integer> cooldownData, MobHealthbarType mobHealthbarType) {
|
public PlayerProfile(String playerName, UUID uuid, boolean isLoaded) {
|
||||||
|
this(playerName, uuid);
|
||||||
|
this.loaded = isLoaded;
|
||||||
|
}
|
||||||
|
|
||||||
|
public PlayerProfile(String playerName, UUID uuid, Map<SkillType, Integer> levelData, Map<SkillType, Float> xpData, Map<AbilityType, Integer> cooldownData, MobHealthbarType mobHealthbarType) {
|
||||||
this.playerName = playerName;
|
this.playerName = playerName;
|
||||||
|
this.uuid = uuid;
|
||||||
this.mobHealthbarType = mobHealthbarType;
|
this.mobHealthbarType = mobHealthbarType;
|
||||||
|
|
||||||
skills.putAll(levelData);
|
skills.putAll(levelData);
|
||||||
@@ -71,11 +86,11 @@ public class PlayerProfile {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TODO should this part be synchronized?
|
// TODO should this part be synchronized?
|
||||||
PlayerProfile profileCopy = new PlayerProfile(playerName, ImmutableMap.copyOf(skills), ImmutableMap.copyOf(skillsXp), ImmutableMap.copyOf(abilityDATS), mobHealthbarType);
|
PlayerProfile profileCopy = new PlayerProfile(playerName, uuid, ImmutableMap.copyOf(skills), ImmutableMap.copyOf(skillsXp), ImmutableMap.copyOf(abilityDATS), mobHealthbarType);
|
||||||
changed = !mcMMO.getDatabaseManager().saveUser(profileCopy);
|
changed = !mcMMO.getDatabaseManager().saveUser(profileCopy);
|
||||||
|
|
||||||
if (changed) {
|
if (changed) {
|
||||||
mcMMO.p.getLogger().warning("PlayerProfile for " + playerName + " failed to save");
|
mcMMO.p.getLogger().warning("PlayerProfile saving failed for player: " + playerName + " " + uuid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -83,6 +98,16 @@ public class PlayerProfile {
|
|||||||
return playerName;
|
return playerName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public UUID getUniqueId() {
|
||||||
|
return uuid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUniqueId(UUID uuid) {
|
||||||
|
changed = true;
|
||||||
|
|
||||||
|
this.uuid = uuid;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isLoaded() {
|
public boolean isLoaded() {
|
||||||
return loaded;
|
return loaded;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import java.util.Map.Entry;
|
|||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.inventory.meta.PotionMeta;
|
import org.bukkit.inventory.meta.PotionMeta;
|
||||||
|
import org.bukkit.potion.Potion;
|
||||||
import org.bukkit.potion.PotionEffect;
|
import org.bukkit.potion.PotionEffect;
|
||||||
|
|
||||||
public class AlchemyPotion {
|
public class AlchemyPotion {
|
||||||
@@ -50,6 +51,10 @@ public class AlchemyPotion {
|
|||||||
return potion;
|
return potion;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Potion toPotion(int amount) {
|
||||||
|
return Potion.fromItemStack(this.toItemStack(amount));
|
||||||
|
}
|
||||||
|
|
||||||
public short getDataValue() {
|
public short getDataValue() {
|
||||||
return dataValue;
|
return dataValue;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,72 @@
|
|||||||
|
package com.gmail.nossr50.datatypes.skills.alchemy;
|
||||||
|
|
||||||
|
import org.bukkit.potion.Potion;
|
||||||
|
|
||||||
|
public enum PotionStage {
|
||||||
|
FIVE(5),
|
||||||
|
FOUR(4),
|
||||||
|
THREE(3),
|
||||||
|
TWO(2),
|
||||||
|
ONE(1);
|
||||||
|
|
||||||
|
int numerical;
|
||||||
|
|
||||||
|
private PotionStage(int numerical) {
|
||||||
|
this.numerical = numerical;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int toNumerical() {
|
||||||
|
return numerical;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static PotionStage getPotionStageNumerical(int numerical) {
|
||||||
|
for (PotionStage potionStage : values()) {
|
||||||
|
if (numerical >= potionStage.toNumerical()) {
|
||||||
|
return potionStage;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return ONE;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static PotionStage getPotionStage(AlchemyPotion input, AlchemyPotion output) {
|
||||||
|
PotionStage potionStage = getPotionStage(output);
|
||||||
|
if (!isWaterBottle(input) && getPotionStage(input) == potionStage) {
|
||||||
|
potionStage = PotionStage.FIVE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return potionStage;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static boolean isWaterBottle(AlchemyPotion input) {
|
||||||
|
return input.getDataValue() == 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static PotionStage getPotionStage(AlchemyPotion alchemyPotion) {
|
||||||
|
Potion potion = alchemyPotion.toPotion(1);
|
||||||
|
|
||||||
|
int stage = 1;
|
||||||
|
|
||||||
|
// Check if potion isn't awkward or mundane
|
||||||
|
if (potion.getType() != null) {
|
||||||
|
stage++;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if potion has a glowstone dust amplifier
|
||||||
|
if (potion.getLevel() > 1) {
|
||||||
|
stage++;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if potion has a redstone dust amplifier
|
||||||
|
if (potion.hasExtendedDuration()) {
|
||||||
|
stage++;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if potion has a gunpowder amplifier
|
||||||
|
if (potion.isSplash()) {
|
||||||
|
stage++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return PotionStage.getPotionStageNumerical(stage);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
package com.gmail.nossr50.events.fake;
|
||||||
|
|
||||||
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.event.inventory.BrewEvent;
|
||||||
|
import org.bukkit.inventory.BrewerInventory;
|
||||||
|
|
||||||
|
public class FakeBrewEvent extends BrewEvent {
|
||||||
|
public FakeBrewEvent(Block brewer, BrewerInventory contents) {
|
||||||
|
super(brewer, contents);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,13 +1,36 @@
|
|||||||
package com.gmail.nossr50.events.fake;
|
package com.gmail.nossr50.events.fake;
|
||||||
|
|
||||||
|
import java.util.EnumMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||||
|
|
||||||
|
import com.google.common.base.Function;
|
||||||
|
import com.google.common.base.Functions;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when mcMMO applies damage from an entity due to special abilities.
|
* Called when mcMMO applies damage from an entity due to special abilities.
|
||||||
*/
|
*/
|
||||||
public class FakeEntityDamageByEntityEvent extends EntityDamageByEntityEvent {
|
public class FakeEntityDamageByEntityEvent extends EntityDamageByEntityEvent {
|
||||||
|
|
||||||
|
public FakeEntityDamageByEntityEvent(Entity damager, Entity damagee, DamageCause cause, final Map<DamageModifier, Double> modifiers) {
|
||||||
|
super(damager, damagee, cause, modifiers, getFunctionModifiers(modifiers));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public FakeEntityDamageByEntityEvent(Entity damager, Entity damagee, DamageCause cause, double damage) {
|
public FakeEntityDamageByEntityEvent(Entity damager, Entity damagee, DamageCause cause, double damage) {
|
||||||
super(damager, damagee, cause, damage);
|
super(damager, damagee, cause, damage);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static EnumMap<DamageModifier, Function<? super Double, Double>> getFunctionModifiers(Map<DamageModifier, Double> modifiers) {
|
||||||
|
EnumMap<DamageModifier, Function<? super Double, Double>> modifierFunctions = new EnumMap<DamageModifier, Function<? super Double, Double>>(DamageModifier.class);
|
||||||
|
Function<? super Double, Double> ZERO = Functions.constant(-0.0);
|
||||||
|
|
||||||
|
for (DamageModifier modifier : modifiers.keySet()) {
|
||||||
|
modifierFunctions.put(modifier, ZERO);
|
||||||
|
}
|
||||||
|
|
||||||
|
return modifierFunctions;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,13 +1,36 @@
|
|||||||
package com.gmail.nossr50.events.fake;
|
package com.gmail.nossr50.events.fake;
|
||||||
|
|
||||||
|
import java.util.EnumMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.event.entity.EntityDamageEvent;
|
import org.bukkit.event.entity.EntityDamageEvent;
|
||||||
|
|
||||||
|
import com.google.common.base.Function;
|
||||||
|
import com.google.common.base.Functions;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when mcMMO applies damage due to special abilities.
|
* Called when mcMMO applies damage due to special abilities.
|
||||||
*/
|
*/
|
||||||
public class FakeEntityDamageEvent extends EntityDamageEvent {
|
public class FakeEntityDamageEvent extends EntityDamageEvent {
|
||||||
|
|
||||||
|
public FakeEntityDamageEvent(Entity damagee, DamageCause cause, final Map<DamageModifier, Double> modifiers) {
|
||||||
|
super(damagee, cause, modifiers, getFunctionModifiers(modifiers));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public FakeEntityDamageEvent(Entity damagee, DamageCause cause, double damage) {
|
public FakeEntityDamageEvent(Entity damagee, DamageCause cause, double damage) {
|
||||||
super(damagee, cause, damage);
|
super(damagee, cause, damage);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static EnumMap<DamageModifier, Function<? super Double, Double>> getFunctionModifiers(Map<DamageModifier, Double> modifiers) {
|
||||||
|
EnumMap<DamageModifier, Function<? super Double, Double>> modifierFunctions = new EnumMap<DamageModifier, Function<? super Double, Double>>(DamageModifier.class);
|
||||||
|
Function<? super Double, Double> ZERO = Functions.constant(-0.0);
|
||||||
|
|
||||||
|
for (DamageModifier modifier : modifiers.keySet()) {
|
||||||
|
modifierFunctions.put(modifier, ZERO);
|
||||||
|
}
|
||||||
|
|
||||||
|
return modifierFunctions;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,18 +1,20 @@
|
|||||||
package com.gmail.nossr50.events.skills.secondaryabilities;
|
package com.gmail.nossr50.events.skills.secondaryabilities;
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.Cancellable;
|
||||||
|
|
||||||
import com.gmail.nossr50.datatypes.skills.SecondaryAbility;
|
import com.gmail.nossr50.datatypes.skills.SecondaryAbility;
|
||||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||||
import com.gmail.nossr50.events.skills.McMMOPlayerSkillEvent;
|
import com.gmail.nossr50.events.skills.McMMOPlayerSkillEvent;
|
||||||
|
|
||||||
public abstract class SecondaryAbilityEvent extends McMMOPlayerSkillEvent {
|
public class SecondaryAbilityEvent extends McMMOPlayerSkillEvent implements Cancellable {
|
||||||
|
|
||||||
private SecondaryAbility secondaryAbility;
|
private SecondaryAbility secondaryAbility;
|
||||||
|
private boolean cancelled;
|
||||||
|
|
||||||
public SecondaryAbilityEvent(Player player, SecondaryAbility secondaryAbility) {
|
public SecondaryAbilityEvent(Player player, SecondaryAbility secondaryAbility) {
|
||||||
super(player, SkillType.bySecondaryAbility(secondaryAbility));
|
super(player, SkillType.bySecondaryAbility(secondaryAbility));
|
||||||
this.secondaryAbility = secondaryAbility;
|
this.secondaryAbility = secondaryAbility;
|
||||||
|
cancelled = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -22,4 +24,12 @@ public abstract class SecondaryAbilityEvent extends McMMOPlayerSkillEvent {
|
|||||||
public SecondaryAbility getSecondaryAbility() {
|
public SecondaryAbility getSecondaryAbility() {
|
||||||
return secondaryAbility;
|
return secondaryAbility;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isCancelled() {
|
||||||
|
return cancelled;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCancelled(boolean newValue) {
|
||||||
|
this.cancelled = newValue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import org.bukkit.entity.Player;
|
|||||||
import com.gmail.nossr50.datatypes.skills.SecondaryAbility;
|
import com.gmail.nossr50.datatypes.skills.SecondaryAbility;
|
||||||
|
|
||||||
public class SecondaryAbilityWeightedActivationCheckEvent extends SecondaryAbilityEvent {
|
public class SecondaryAbilityWeightedActivationCheckEvent extends SecondaryAbilityEvent {
|
||||||
|
|
||||||
private double chance;
|
private double chance;
|
||||||
|
|
||||||
public SecondaryAbilityWeightedActivationCheckEvent(Player player, SecondaryAbility ability, double chance) {
|
public SecondaryAbilityWeightedActivationCheckEvent(Player player, SecondaryAbility ability, double chance) {
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ import com.gmail.nossr50.datatypes.skills.SkillType;
|
|||||||
import com.gmail.nossr50.datatypes.skills.ToolType;
|
import com.gmail.nossr50.datatypes.skills.ToolType;
|
||||||
import com.gmail.nossr50.events.fake.FakeBlockBreakEvent;
|
import com.gmail.nossr50.events.fake.FakeBlockBreakEvent;
|
||||||
import com.gmail.nossr50.events.fake.FakeBlockDamageEvent;
|
import com.gmail.nossr50.events.fake.FakeBlockDamageEvent;
|
||||||
|
import com.gmail.nossr50.runnables.PistonTrackerTask;
|
||||||
import com.gmail.nossr50.runnables.StickyPistonTrackerTask;
|
import com.gmail.nossr50.runnables.StickyPistonTrackerTask;
|
||||||
import com.gmail.nossr50.skills.alchemy.Alchemy;
|
import com.gmail.nossr50.skills.alchemy.Alchemy;
|
||||||
import com.gmail.nossr50.skills.excavation.ExcavationManager;
|
import com.gmail.nossr50.skills.excavation.ExcavationManager;
|
||||||
@@ -63,27 +64,27 @@ public class BlockListener implements Listener {
|
|||||||
*/
|
*/
|
||||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||||
public void onBlockPistonExtend(BlockPistonExtendEvent event) {
|
public void onBlockPistonExtend(BlockPistonExtendEvent event) {
|
||||||
List<Block> blocks = event.getBlocks();
|
if (!EventUtils.shouldProcessEvent(event.getBlock(), true)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
BlockFace direction = event.getDirection();
|
BlockFace direction = event.getDirection();
|
||||||
Block futureEmptyBlock = event.getBlock().getRelative(direction); // Block that would be air after piston is finished
|
Block futureEmptyBlock = event.getBlock().getRelative(direction); // Block that would be air after piston is finished
|
||||||
|
|
||||||
|
if (futureEmptyBlock.getType() == Material.AIR) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
List<Block> blocks = event.getBlocks();
|
||||||
|
|
||||||
for (Block b : blocks) {
|
for (Block b : blocks) {
|
||||||
if (BlockUtils.shouldBeWatched(b.getState()) && mcMMO.getPlaceStore().isTrue(b)) {
|
if (BlockUtils.shouldBeWatched(b.getState()) && mcMMO.getPlaceStore().isTrue(b)) {
|
||||||
b.getRelative(direction).setMetadata(mcMMO.blockMetadataKey, mcMMO.metadataValue);
|
b.getRelative(direction).setMetadata(mcMMO.blockMetadataKey, mcMMO.metadataValue);
|
||||||
if (b.equals(futureEmptyBlock) && futureEmptyBlock.getType() == Material.AIR) {
|
|
||||||
mcMMO.getPlaceStore().setFalse(b);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Block b : blocks) {
|
// Needed because blocks sometimes don't move when two pistons push towards each other
|
||||||
Block nextBlock = b.getRelative(direction);
|
new PistonTrackerTask(blocks, direction, futureEmptyBlock).runTaskLater(plugin, 2);
|
||||||
|
|
||||||
if (nextBlock.hasMetadata(mcMMO.blockMetadataKey)) {
|
|
||||||
mcMMO.getPlaceStore().setTrue(nextBlock);
|
|
||||||
nextBlock.removeMetadata(mcMMO.blockMetadataKey, plugin);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -93,6 +94,10 @@ public class BlockListener implements Listener {
|
|||||||
*/
|
*/
|
||||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||||
public void onBlockPistonRetract(BlockPistonRetractEvent event) {
|
public void onBlockPistonRetract(BlockPistonRetractEvent event) {
|
||||||
|
if (!EventUtils.shouldProcessEvent(event.getBlock(), false)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!event.isSticky()) {
|
if (!event.isSticky()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ import org.bukkit.inventory.meta.PotionMeta;
|
|||||||
import org.bukkit.metadata.FixedMetadataValue;
|
import org.bukkit.metadata.FixedMetadataValue;
|
||||||
import org.bukkit.potion.PotionEffect;
|
import org.bukkit.potion.PotionEffect;
|
||||||
import org.bukkit.potion.PotionEffectType;
|
import org.bukkit.potion.PotionEffectType;
|
||||||
|
import org.bukkit.projectiles.ProjectileSource;
|
||||||
|
|
||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.gmail.nossr50.config.AdvancedConfig;
|
import com.gmail.nossr50.config.AdvancedConfig;
|
||||||
@@ -52,6 +53,7 @@ import com.gmail.nossr50.skills.acrobatics.AcrobaticsManager;
|
|||||||
import com.gmail.nossr50.skills.archery.Archery;
|
import com.gmail.nossr50.skills.archery.Archery;
|
||||||
import com.gmail.nossr50.skills.fishing.Fishing;
|
import com.gmail.nossr50.skills.fishing.Fishing;
|
||||||
import com.gmail.nossr50.skills.herbalism.Herbalism;
|
import com.gmail.nossr50.skills.herbalism.Herbalism;
|
||||||
|
import com.gmail.nossr50.skills.mining.BlastMining;
|
||||||
import com.gmail.nossr50.skills.mining.MiningManager;
|
import com.gmail.nossr50.skills.mining.MiningManager;
|
||||||
import com.gmail.nossr50.skills.taming.Taming;
|
import com.gmail.nossr50.skills.taming.Taming;
|
||||||
import com.gmail.nossr50.skills.taming.TamingManager;
|
import com.gmail.nossr50.skills.taming.TamingManager;
|
||||||
@@ -108,7 +110,9 @@ public class EntityListener implements Listener {
|
|||||||
public void onEntityChangeBlock(EntityChangeBlockEvent event) {
|
public void onEntityChangeBlock(EntityChangeBlockEvent event) {
|
||||||
Block block = event.getBlock();
|
Block block = event.getBlock();
|
||||||
|
|
||||||
if (!BlockUtils.shouldBeWatched(block.getState())) {
|
// When the event is fired for the falling block that changes back to a normal block
|
||||||
|
// event.getBlock().getType() returns AIR
|
||||||
|
if (!BlockUtils.shouldBeWatched(block.getState()) && block.getType() != Material.AIR) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -146,7 +150,7 @@ public class EntityListener implements Listener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
double damage = event.getDamage();
|
double damage = event.getFinalDamage();
|
||||||
|
|
||||||
if (damage <= 0) {
|
if (damage <= 0) {
|
||||||
return;
|
return;
|
||||||
@@ -176,7 +180,11 @@ public class EntityListener implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (attacker instanceof Projectile) {
|
if (attacker instanceof Projectile) {
|
||||||
attacker = ((Projectile) attacker).getShooter();
|
ProjectileSource projectileSource = ((Projectile) attacker).getShooter();
|
||||||
|
|
||||||
|
if (projectileSource instanceof LivingEntity) {
|
||||||
|
attacker = (LivingEntity) projectileSource;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (attacker instanceof Tameable) {
|
else if (attacker instanceof Tameable) {
|
||||||
AnimalTamer animalTamer = ((Tameable) attacker).getOwner();
|
AnimalTamer animalTamer = ((Tameable) attacker).getOwner();
|
||||||
@@ -185,6 +193,11 @@ public class EntityListener implements Listener {
|
|||||||
attacker = (Entity) animalTamer;
|
attacker = (Entity) animalTamer;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (attacker instanceof TNTPrimed && defender instanceof Player) {
|
||||||
|
if (BlastMining.processBlastMiningExplosion(event, (TNTPrimed) attacker, (Player) defender)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (defender instanceof Player && attacker instanceof Player) {
|
if (defender instanceof Player && attacker instanceof Player) {
|
||||||
Player defendingPlayer = (Player) defender;
|
Player defendingPlayer = (Player) defender;
|
||||||
@@ -206,7 +219,7 @@ public class EntityListener implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
CombatUtils.processCombatAttack(event, attacker, target);
|
CombatUtils.processCombatAttack(event, attacker, target);
|
||||||
CombatUtils.handleHealthbars(attacker, target, event.getDamage());
|
CombatUtils.handleHealthbars(attacker, target, event.getFinalDamage());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -220,7 +233,7 @@ public class EntityListener implements Listener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
double damage = event.getDamage();
|
double damage = event.getFinalDamage();
|
||||||
|
|
||||||
if (damage <= 0) {
|
if (damage <= 0) {
|
||||||
return;
|
return;
|
||||||
@@ -271,20 +284,7 @@ public class EntityListener implements Listener {
|
|||||||
if (acrobaticsManager.canRoll()) {
|
if (acrobaticsManager.canRoll()) {
|
||||||
event.setDamage(acrobaticsManager.rollCheck(event.getDamage()));
|
event.setDamage(acrobaticsManager.rollCheck(event.getDamage()));
|
||||||
|
|
||||||
if (event.getDamage() == 0) {
|
if (event.getFinalDamage() == 0) {
|
||||||
event.setCancelled(true);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case BLOCK_EXPLOSION:
|
|
||||||
MiningManager miningManager = mcMMOPlayer.getMiningManager();
|
|
||||||
|
|
||||||
if (miningManager.canUseDemolitionsExpertise()) {
|
|
||||||
event.setDamage(miningManager.processDemolitionsExpertise(event.getDamage()));
|
|
||||||
|
|
||||||
if (event.getDamage() == 0) {
|
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -295,7 +295,7 @@ public class EntityListener implements Listener {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event.getDamage() >= 1) {
|
if (event.getFinalDamage() >= 1) {
|
||||||
mcMMOPlayer.actualizeRecentlyHurt();
|
mcMMOPlayer.actualizeRecentlyHurt();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -329,7 +329,7 @@ public class EntityListener implements Listener {
|
|||||||
if (tamingManager.canUseThickFur()) {
|
if (tamingManager.canUseThickFur()) {
|
||||||
event.setDamage(Taming.processThickFur(wolf, event.getDamage()));
|
event.setDamage(Taming.processThickFur(wolf, event.getDamage()));
|
||||||
|
|
||||||
if (event.getDamage() == 0) {
|
if (event.getFinalDamage() == 0) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -355,7 +355,7 @@ public class EntityListener implements Listener {
|
|||||||
if (tamingManager.canUseShockProof()) {
|
if (tamingManager.canUseShockProof()) {
|
||||||
event.setDamage(Taming.processShockProof(wolf, event.getDamage()));
|
event.setDamage(Taming.processShockProof(wolf, event.getDamage()));
|
||||||
|
|
||||||
if (event.getDamage() == 0) {
|
if (event.getFinalDamage() == 0) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ import org.bukkit.event.player.PlayerJoinEvent;
|
|||||||
import org.bukkit.event.player.PlayerPickupItemEvent;
|
import org.bukkit.event.player.PlayerPickupItemEvent;
|
||||||
import org.bukkit.event.player.PlayerQuitEvent;
|
import org.bukkit.event.player.PlayerQuitEvent;
|
||||||
import org.bukkit.event.player.PlayerRespawnEvent;
|
import org.bukkit.event.player.PlayerRespawnEvent;
|
||||||
|
import org.bukkit.event.player.PlayerStatisticIncrementEvent;
|
||||||
import org.bukkit.event.player.PlayerTeleportEvent;
|
import org.bukkit.event.player.PlayerTeleportEvent;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
@@ -40,7 +41,7 @@ import com.gmail.nossr50.datatypes.skills.AbilityType;
|
|||||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.party.ShareHandler;
|
import com.gmail.nossr50.party.ShareHandler;
|
||||||
import com.gmail.nossr50.runnables.commands.McScoreboardKeepTask;
|
import com.gmail.nossr50.runnables.player.PlayerProfileLoadingTask;
|
||||||
import com.gmail.nossr50.runnables.skills.BleedTimerTask;
|
import com.gmail.nossr50.runnables.skills.BleedTimerTask;
|
||||||
import com.gmail.nossr50.skills.fishing.FishingManager;
|
import com.gmail.nossr50.skills.fishing.FishingManager;
|
||||||
import com.gmail.nossr50.skills.herbalism.HerbalismManager;
|
import com.gmail.nossr50.skills.herbalism.HerbalismManager;
|
||||||
@@ -225,6 +226,13 @@ public class PlayerListener implements Listener {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
case CAUGHT_FISH:
|
case CAUGHT_FISH:
|
||||||
|
//TODO Update to new API once available! Waiting for case CAUGHT_TREASURE:
|
||||||
|
Item fishingCatch = (Item) event.getCaught();
|
||||||
|
|
||||||
|
if (Config.getInstance().getFishingOverrideTreasures() && fishingCatch.getItemStack().getType() != Material.RAW_FISH) {
|
||||||
|
fishingCatch.setItemStack(new ItemStack(Material.RAW_FISH, 1));
|
||||||
|
}
|
||||||
|
|
||||||
if (Permissions.vanillaXpBoost(player, SkillType.FISHING)) {
|
if (Permissions.vanillaXpBoost(player, SkillType.FISHING)) {
|
||||||
event.setExpToDrop(fishingManager.handleVanillaXpBoost(event.getExpToDrop()));
|
event.setExpToDrop(fishingManager.handleVanillaXpBoost(event.getExpToDrop()));
|
||||||
}
|
}
|
||||||
@@ -324,9 +332,11 @@ public class PlayerListener implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ((mcMMOPlayer.isUsingUnarmed() && ItemUtils.isSharable(dropStack)) || mcMMOPlayer.getAbilityMode(AbilityType.BERSERK)) {
|
if ((mcMMOPlayer.isUsingUnarmed() && ItemUtils.isSharable(dropStack)) || mcMMOPlayer.getAbilityMode(AbilityType.BERSERK)) {
|
||||||
event.setCancelled(Unarmed.handleItemPickup(player.getInventory(), drop));
|
boolean pickupSuccess = Unarmed.handleItemPickup(player.getInventory(), drop);
|
||||||
|
boolean cancel = Config.getInstance().getUnarmedItemPickupDisabled() || pickupSuccess;
|
||||||
|
event.setCancelled(cancel);
|
||||||
|
|
||||||
if (event.isCancelled()) {
|
if (pickupSuccess) {
|
||||||
player.playSound(player.getLocation(), Sound.ITEM_PICKUP, Misc.POP_VOLUME, Misc.getPopPitch());
|
player.playSound(player.getLocation(), Sound.ITEM_PICKUP, Misc.POP_VOLUME, Misc.getPopPitch());
|
||||||
player.updateInventory();
|
player.updateInventory();
|
||||||
return;
|
return;
|
||||||
@@ -377,9 +387,7 @@ public class PlayerListener implements Listener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
McMMOPlayer mcMMOPlayer = UserManager.addUser(player);
|
new PlayerProfileLoadingTask(player).runTaskTimerAsynchronously(mcMMO.p, 1, 20); // 1 Tick delay to ensure the player is marked as online before we begin loading
|
||||||
mcMMOPlayer.actualizeRespawnATS();
|
|
||||||
ScoreboardManager.setupPlayer(player);
|
|
||||||
|
|
||||||
if (Config.getInstance().getMOTDEnabled() && Permissions.motd(player)) {
|
if (Config.getInstance().getMOTDEnabled() && Permissions.motd(player)) {
|
||||||
Motd.displayAll(player);
|
Motd.displayAll(player);
|
||||||
@@ -393,11 +401,6 @@ public class PlayerListener implements Listener {
|
|||||||
player.sendMessage(LocaleLoader.getString("UpdateChecker.Outdated"));
|
player.sendMessage(LocaleLoader.getString("UpdateChecker.Outdated"));
|
||||||
player.sendMessage(LocaleLoader.getString("UpdateChecker.NewAvailable"));
|
player.sendMessage(LocaleLoader.getString("UpdateChecker.NewAvailable"));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Config.getInstance().getShowStatsAfterLogin()) {
|
|
||||||
ScoreboardManager.enablePlayerStatsScoreboard(player);
|
|
||||||
new McScoreboardKeepTask(player).runTaskLater(mcMMO.p, 1 * Misc.TICK_CONVERSION_FACTOR);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -694,4 +697,13 @@ public class PlayerListener implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||||
|
public void onPlayerStatisticIncrementEvent(PlayerStatisticIncrementEvent event) {
|
||||||
|
if (!mcMMO.getHolidayManager().isAprilFirst()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
mcMMO.getHolidayManager().handleStatisticEvent(event);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ import com.gmail.nossr50.runnables.UpdaterResultAsyncTask;
|
|||||||
import com.gmail.nossr50.runnables.backups.CleanBackupsTask;
|
import com.gmail.nossr50.runnables.backups.CleanBackupsTask;
|
||||||
import com.gmail.nossr50.runnables.database.UserPurgeTask;
|
import com.gmail.nossr50.runnables.database.UserPurgeTask;
|
||||||
import com.gmail.nossr50.runnables.party.PartyAutoKickTask;
|
import com.gmail.nossr50.runnables.party.PartyAutoKickTask;
|
||||||
|
import com.gmail.nossr50.runnables.player.PlayerProfileLoadingTask;
|
||||||
import com.gmail.nossr50.runnables.player.PowerLevelUpdatingTask;
|
import com.gmail.nossr50.runnables.player.PowerLevelUpdatingTask;
|
||||||
import com.gmail.nossr50.runnables.skills.BleedTimerTask;
|
import com.gmail.nossr50.runnables.skills.BleedTimerTask;
|
||||||
import com.gmail.nossr50.skills.alchemy.Alchemy;
|
import com.gmail.nossr50.skills.alchemy.Alchemy;
|
||||||
@@ -60,6 +61,7 @@ import com.gmail.nossr50.util.commands.CommandRegistrationManager;
|
|||||||
import com.gmail.nossr50.util.experience.FormulaManager;
|
import com.gmail.nossr50.util.experience.FormulaManager;
|
||||||
import com.gmail.nossr50.util.player.UserManager;
|
import com.gmail.nossr50.util.player.UserManager;
|
||||||
import com.gmail.nossr50.util.scoreboards.ScoreboardManager;
|
import com.gmail.nossr50.util.scoreboards.ScoreboardManager;
|
||||||
|
import com.gmail.nossr50.util.upgrade.UpgradeManager;
|
||||||
|
|
||||||
import net.shatteredlands.shatt.backup.ZipLibrary;
|
import net.shatteredlands.shatt.backup.ZipLibrary;
|
||||||
|
|
||||||
@@ -72,6 +74,7 @@ public class mcMMO extends JavaPlugin {
|
|||||||
private static DatabaseManager databaseManager;
|
private static DatabaseManager databaseManager;
|
||||||
private static FormulaManager formulaManager;
|
private static FormulaManager formulaManager;
|
||||||
private static HolidayManager holidayManager;
|
private static HolidayManager holidayManager;
|
||||||
|
private static UpgradeManager upgradeManager;
|
||||||
|
|
||||||
/* File Paths */
|
/* File Paths */
|
||||||
private static String mainDirectory;
|
private static String mainDirectory;
|
||||||
@@ -112,6 +115,7 @@ public class mcMMO extends JavaPlugin {
|
|||||||
public final static String disarmedItemKey = "mcMMO: Disarmed Item";
|
public final static String disarmedItemKey = "mcMMO: Disarmed Item";
|
||||||
public final static String playerDataKey = "mcMMO: Player Data";
|
public final static String playerDataKey = "mcMMO: Player Data";
|
||||||
public final static String greenThumbDataKey = "mcMMO: Green Thumb";
|
public final static String greenThumbDataKey = "mcMMO: Green Thumb";
|
||||||
|
public final static String pistonDataKey = "mcMMO: Piston State";
|
||||||
|
|
||||||
public static FixedMetadataValue metadataValue;
|
public static FixedMetadataValue metadataValue;
|
||||||
|
|
||||||
@@ -128,6 +132,8 @@ public class mcMMO extends JavaPlugin {
|
|||||||
PluginManager pluginManager = getServer().getPluginManager();
|
PluginManager pluginManager = getServer().getPluginManager();
|
||||||
healthBarPluginEnabled = pluginManager.getPlugin("HealthBar") != null;
|
healthBarPluginEnabled = pluginManager.getPlugin("HealthBar") != null;
|
||||||
|
|
||||||
|
upgradeManager = new UpgradeManager();
|
||||||
|
|
||||||
setupFilePaths();
|
setupFilePaths();
|
||||||
|
|
||||||
modManager = new ModManager();
|
modManager = new ModManager();
|
||||||
@@ -138,7 +144,7 @@ public class mcMMO extends JavaPlugin {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getServer().getName().equals("MCPC+")) {
|
if (getServer().getName().equals("Cauldron") || getServer().getName().equals("MCPC+")) {
|
||||||
checkModConfigs();
|
checkModConfigs();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -162,8 +168,7 @@ public class mcMMO extends JavaPlugin {
|
|||||||
holidayManager = new HolidayManager();
|
holidayManager = new HolidayManager();
|
||||||
|
|
||||||
for (Player player : getServer().getOnlinePlayers()) {
|
for (Player player : getServer().getOnlinePlayers()) {
|
||||||
UserManager.addUser(player); // In case of reload add all users back into UserManager
|
new PlayerProfileLoadingTask(player).runTaskTimerAsynchronously(mcMMO.p, 1, 20); // 1 Tick delay to ensure the player is marked as online before we begin loading
|
||||||
ScoreboardManager.setupPlayer(player);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
debug("Version " + getDescription().getVersion() + " is enabled!");
|
debug("Version " + getDescription().getVersion() + " is enabled!");
|
||||||
@@ -237,6 +242,7 @@ public class mcMMO extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
databaseManager.onDisable();
|
||||||
debug("Was disabled."); // How informative!
|
debug("Was disabled."); // How informative!
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -308,6 +314,10 @@ public class mcMMO extends JavaPlugin {
|
|||||||
return modManager;
|
return modManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static UpgradeManager getUpgradeManager() {
|
||||||
|
return upgradeManager;
|
||||||
|
}
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public static void setDatabaseManager(DatabaseManager databaseManager) {
|
public static void setDatabaseManager(DatabaseManager databaseManager) {
|
||||||
mcMMO.databaseManager = databaseManager;
|
mcMMO.databaseManager = databaseManager;
|
||||||
@@ -485,22 +495,22 @@ public class mcMMO extends JavaPlugin {
|
|||||||
|
|
||||||
private void checkModConfigs() {
|
private void checkModConfigs() {
|
||||||
if (!Config.getInstance().getToolModsEnabled()) {
|
if (!Config.getInstance().getToolModsEnabled()) {
|
||||||
getLogger().info("MCPC+ implementation found, but the custom tool config for mcMMO is disabled!");
|
getLogger().warning("Cauldron implementation found, but the custom tool config for mcMMO is disabled!");
|
||||||
getLogger().info("To enable, set Mods.Tool_Mods_Enabled to TRUE in config.yml.");
|
getLogger().info("To enable, set Mods.Tool_Mods_Enabled to TRUE in config.yml.");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Config.getInstance().getArmorModsEnabled()) {
|
if (!Config.getInstance().getArmorModsEnabled()) {
|
||||||
getLogger().info("MCPC+ implementation found, but the custom armor config for mcMMO is disabled!");
|
getLogger().warning("Cauldron implementation found, but the custom armor config for mcMMO is disabled!");
|
||||||
getLogger().info("To enable, set Mods.Armor_Mods_Enabled to TRUE in config.yml.");
|
getLogger().info("To enable, set Mods.Armor_Mods_Enabled to TRUE in config.yml.");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Config.getInstance().getBlockModsEnabled()) {
|
if (!Config.getInstance().getBlockModsEnabled()) {
|
||||||
getLogger().info("MCPC+ implementation found, but the custom block config for mcMMO is disabled!");
|
getLogger().warning("Cauldron implementation found, but the custom block config for mcMMO is disabled!");
|
||||||
getLogger().info("To enable, set Mods.Block_Mods_Enabled to TRUE in config.yml.");
|
getLogger().info("To enable, set Mods.Block_Mods_Enabled to TRUE in config.yml.");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Config.getInstance().getEntityModsEnabled()) {
|
if (!Config.getInstance().getEntityModsEnabled()) {
|
||||||
getLogger().info("MCPC+ implementation found, but the custom entity config for mcMMO is disabled!");
|
getLogger().warning("Cauldron implementation found, but the custom entity config for mcMMO is disabled!");
|
||||||
getLogger().info("To enable, set Mods.Entity_Mods_Enabled to TRUE in config.yml.");
|
getLogger().info("To enable, set Mods.Entity_Mods_Enabled to TRUE in config.yml.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,47 @@
|
|||||||
|
package com.gmail.nossr50.runnables;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.block.BlockFace;
|
||||||
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
|
||||||
|
import com.gmail.nossr50.mcMMO;
|
||||||
|
import com.gmail.nossr50.util.BlockUtils;
|
||||||
|
|
||||||
|
public class PistonTrackerTask extends BukkitRunnable {
|
||||||
|
private List<Block> blocks;
|
||||||
|
private BlockFace direction;
|
||||||
|
private Block futureEmptyBlock;
|
||||||
|
|
||||||
|
public PistonTrackerTask(List<Block> blocks, BlockFace direction, Block futureEmptyBlock) {
|
||||||
|
this.blocks = blocks;
|
||||||
|
this.direction = direction;
|
||||||
|
this.futureEmptyBlock = futureEmptyBlock;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
// Check to see if futureEmptyBlock is empty - if it isn't; the blocks didn't move
|
||||||
|
if (!BlockUtils.isPistonPiece(futureEmptyBlock.getState())) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mcMMO.getPlaceStore().isTrue(futureEmptyBlock)) {
|
||||||
|
mcMMO.getPlaceStore().setFalse(futureEmptyBlock);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (Block b : blocks) {
|
||||||
|
Block nextBlock = b.getRelative(direction);
|
||||||
|
|
||||||
|
if (nextBlock.hasMetadata(mcMMO.blockMetadataKey)) {
|
||||||
|
mcMMO.getPlaceStore().setTrue(nextBlock);
|
||||||
|
nextBlock.removeMetadata(mcMMO.blockMetadataKey, mcMMO.p);
|
||||||
|
}
|
||||||
|
else if (mcMMO.getPlaceStore().isTrue(nextBlock)) {
|
||||||
|
// Block doesn't have metadatakey but isTrue - set it to false
|
||||||
|
mcMMO.getPlaceStore().setFalse(nextBlock);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,7 +2,6 @@ package com.gmail.nossr50.runnables;
|
|||||||
|
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.block.BlockFace;
|
import org.bukkit.block.BlockFace;
|
||||||
import org.bukkit.block.PistonMoveReaction;
|
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
|
||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
@@ -21,10 +20,16 @@ public class StickyPistonTrackerTask extends BukkitRunnable {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if (!BlockUtils.shouldBeWatched(movedBlock.getState()) || movedBlock.getPistonMoveReaction() != PistonMoveReaction.MOVE || !mcMMO.getPlaceStore().isTrue(movedBlock)) {
|
if (!mcMMO.getPlaceStore().isTrue(movedBlock)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!BlockUtils.isPistonPiece(movedBlock.getState())) {
|
||||||
|
// The block didn't move
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// The sticky piston actually pulled the block so move the PlaceStore data
|
||||||
mcMMO.getPlaceStore().setFalse(movedBlock);
|
mcMMO.getPlaceStore().setFalse(movedBlock);
|
||||||
mcMMO.getPlaceStore().setTrue(block.getRelative(direction));
|
mcMMO.getPlaceStore().setTrue(block.getRelative(direction));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,39 +0,0 @@
|
|||||||
package com.gmail.nossr50.runnables.database;
|
|
||||||
|
|
||||||
import java.lang.ref.WeakReference;
|
|
||||||
|
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
|
||||||
|
|
||||||
import com.gmail.nossr50.database.SQLDatabaseManager;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This task is in charge of sending a MySQL ping over the MySQL connection
|
|
||||||
* every hour to prevent the connection from timing out and losing players'
|
|
||||||
* data when they join.
|
|
||||||
* <p/>
|
|
||||||
* A WeakReference is used to keep the database instance, because
|
|
||||||
* {@link com.gmail.nossr50.commands.database.ConvertDatabaseCommand database
|
|
||||||
* conversion} may create a SQLDatabaseManager that will be thrown out. If a
|
|
||||||
* normal reference was used, the conversion would cause a combined data and
|
|
||||||
* resource leak through this task.
|
|
||||||
*/
|
|
||||||
public class SQLDatabaseKeepaliveTask extends BukkitRunnable {
|
|
||||||
WeakReference<SQLDatabaseManager> databaseInstance;
|
|
||||||
|
|
||||||
public SQLDatabaseKeepaliveTask(SQLDatabaseManager dbman) {
|
|
||||||
databaseInstance = new WeakReference<SQLDatabaseManager>(dbman);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void run() {
|
|
||||||
SQLDatabaseManager dbman = databaseInstance.get();
|
|
||||||
if (dbman != null) {
|
|
||||||
dbman.checkConnected();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
// This happens when the database was started for a conversion,
|
|
||||||
// or discarded by its creator for any other reason. If this code
|
|
||||||
// was not present, we would leak the connection resources.
|
|
||||||
this.cancel();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
package com.gmail.nossr50.runnables.database;
|
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
|
||||||
|
|
||||||
import com.gmail.nossr50.mcMMO;
|
|
||||||
import com.gmail.nossr50.database.SQLDatabaseManager;
|
|
||||||
import com.gmail.nossr50.util.player.UserManager;
|
|
||||||
|
|
||||||
public class SQLReconnectTask extends BukkitRunnable {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
if (((SQLDatabaseManager) mcMMO.getDatabaseManager()).checkConnected()) {
|
|
||||||
UserManager.saveAll(); // Save all profiles
|
|
||||||
UserManager.clearAll(); // Clear the profiles
|
|
||||||
|
|
||||||
for (Player player : mcMMO.p.getServer().getOnlinePlayers()) {
|
|
||||||
UserManager.addUser(player); // Add in new profiles, forcing them to 'load' again from MySQL
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,73 @@
|
|||||||
|
package com.gmail.nossr50.runnables.database;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
|
||||||
|
import com.gmail.nossr50.mcMMO;
|
||||||
|
import com.gmail.nossr50.config.HiddenConfig;
|
||||||
|
import com.gmail.nossr50.database.DatabaseManager;
|
||||||
|
import com.gmail.nossr50.datatypes.database.UpgradeType;
|
||||||
|
import com.gmail.nossr50.util.Misc;
|
||||||
|
import com.gmail.nossr50.util.uuid.UUIDFetcher;
|
||||||
|
|
||||||
|
public class UUIDUpdateAsyncTask extends BukkitRunnable {
|
||||||
|
private mcMMO plugin;
|
||||||
|
private static final int MAX_LOOKUP = Math.max(HiddenConfig.getInstance().getUUIDConvertAmount(), 100);
|
||||||
|
|
||||||
|
private List<String> userNames;
|
||||||
|
private int size;
|
||||||
|
private int checkedUsers;
|
||||||
|
private long startMillis;
|
||||||
|
|
||||||
|
public UUIDUpdateAsyncTask(mcMMO plugin, List<String> userNames) {
|
||||||
|
this.plugin = plugin;
|
||||||
|
this.userNames = userNames;
|
||||||
|
|
||||||
|
this.checkedUsers = 0;
|
||||||
|
this.startMillis = System.currentTimeMillis();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
size = userNames.size();
|
||||||
|
|
||||||
|
plugin.getLogger().info("Starting to check and update UUIDs, total amount of users: " + size);
|
||||||
|
|
||||||
|
List<String> userNamesSection;
|
||||||
|
Map<String, UUID> fetchedUUIDs = new HashMap<String, UUID>();
|
||||||
|
|
||||||
|
while (size != 0) {
|
||||||
|
if (size > MAX_LOOKUP) {
|
||||||
|
userNamesSection = userNames.subList(size - MAX_LOOKUP, size);
|
||||||
|
size -= MAX_LOOKUP;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
userNamesSection = userNames.subList(0, size);
|
||||||
|
size = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
fetchedUUIDs.putAll(new UUIDFetcher(userNamesSection).call());
|
||||||
|
}
|
||||||
|
catch (Exception e) {
|
||||||
|
plugin.getLogger().severe("Unable to fetch UUIDs!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
checkedUsers += userNamesSection.size();
|
||||||
|
userNamesSection.clear();
|
||||||
|
size = userNames.size();
|
||||||
|
|
||||||
|
Misc.printProgress(checkedUsers, DatabaseManager.progressInterval, startMillis);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mcMMO.getDatabaseManager().saveUserUUIDs(fetchedUUIDs)) {
|
||||||
|
mcMMO.getUpgradeManager().setUpgradeCompleted(UpgradeType.ADD_UUIDS);
|
||||||
|
plugin.getLogger().info("UUID upgrade completed!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,51 @@
|
|||||||
|
package com.gmail.nossr50.runnables.party;
|
||||||
|
|
||||||
|
import java.util.regex.Matcher;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.plugin.Plugin;
|
||||||
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
|
||||||
|
import com.gmail.nossr50.config.Config;
|
||||||
|
import com.gmail.nossr50.datatypes.party.Party;
|
||||||
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
|
|
||||||
|
public class PartyChatTask extends BukkitRunnable {
|
||||||
|
private Plugin plugin;
|
||||||
|
|
||||||
|
private Party party;
|
||||||
|
private String senderName;
|
||||||
|
private String displayName;
|
||||||
|
private String message;
|
||||||
|
|
||||||
|
public PartyChatTask(Plugin plugin, Party party, String senderName, String displayName, String message) {
|
||||||
|
this.plugin = plugin;
|
||||||
|
|
||||||
|
this.party = party;
|
||||||
|
this.senderName = senderName;
|
||||||
|
this.displayName = displayName;
|
||||||
|
this.message = message;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
if (Config.getInstance().getPartyChatColorLeaderName() && senderName.equalsIgnoreCase(party.getLeader())) {
|
||||||
|
message = message.replaceFirst(Pattern.quote(displayName), ChatColor.GOLD + Matcher.quoteReplacement(displayName) + ChatColor.RESET);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (Player member : party.getOnlineMembers()) {
|
||||||
|
member.sendMessage(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (party.getAlly() != null) {
|
||||||
|
for (Player member : party.getAlly().getOnlineMembers()) {
|
||||||
|
String allyPrefix = LocaleLoader.formatString(Config.getInstance().getPartyChatPrefixAlly());
|
||||||
|
member.sendMessage(allyPrefix + message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
plugin.getServer().getConsoleSender().sendMessage("[mcMMO] [P]<" + party.getName() + ">" + message);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,108 @@
|
|||||||
|
package com.gmail.nossr50.runnables.player;
|
||||||
|
|
||||||
|
import java.util.concurrent.locks.ReentrantLock;
|
||||||
|
|
||||||
|
import org.bukkit.Server;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
|
||||||
|
import com.gmail.nossr50.mcMMO;
|
||||||
|
import com.gmail.nossr50.config.Config;
|
||||||
|
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||||
|
import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
||||||
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
|
import com.gmail.nossr50.runnables.commands.McScoreboardKeepTask;
|
||||||
|
import com.gmail.nossr50.util.Misc;
|
||||||
|
import com.gmail.nossr50.util.player.UserManager;
|
||||||
|
import com.gmail.nossr50.util.scoreboards.ScoreboardManager;
|
||||||
|
|
||||||
|
public class PlayerProfileLoadingTask extends BukkitRunnable {
|
||||||
|
private static final int MAX_TRIES = 5;
|
||||||
|
private final Player player;
|
||||||
|
private int attempt = 0;
|
||||||
|
private ReentrantLock lock = new ReentrantLock();
|
||||||
|
private boolean cancelled = false;
|
||||||
|
|
||||||
|
public PlayerProfileLoadingTask(Player player) {
|
||||||
|
this.player = player;
|
||||||
|
}
|
||||||
|
|
||||||
|
// WARNING: ASYNC TASK
|
||||||
|
// DO NOT MODIFY THE McMMOPLAYER FROM THIS CODE
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
lock.lock();
|
||||||
|
|
||||||
|
if (this.cancelled) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Quit if they logged out
|
||||||
|
if (!player.isOnline()) {
|
||||||
|
mcMMO.p.getLogger().info("Aborting profile loading recovery for " + player.getName() + " - player logged out");
|
||||||
|
this.cancel();
|
||||||
|
cancelled = true;
|
||||||
|
lock.unlock();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Increment attempt counter and try
|
||||||
|
attempt++;
|
||||||
|
|
||||||
|
PlayerProfile profile = mcMMO.getDatabaseManager().loadPlayerProfile(player.getName(), player.getUniqueId(), true);
|
||||||
|
// If successful, schedule the apply
|
||||||
|
if (profile.isLoaded()) {
|
||||||
|
new ApplySuccessfulProfile(profile).runTask(mcMMO.p);
|
||||||
|
this.cancel();
|
||||||
|
cancelled = true;
|
||||||
|
lock.unlock();
|
||||||
|
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 " + player.getName());
|
||||||
|
mcMMO.p.getServer().broadcast(LocaleLoader.getString("Profile.Loading.AdminFailureNotice", player.getName()), Server.BROADCAST_CHANNEL_ADMINISTRATIVE);
|
||||||
|
player.sendMessage(LocaleLoader.getString("Profile.Loading.Failure").split("\n"));
|
||||||
|
this.cancel();
|
||||||
|
cancelled = true;
|
||||||
|
lock.unlock();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
lock.unlock();
|
||||||
|
}
|
||||||
|
|
||||||
|
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() {
|
||||||
|
if (!player.isOnline()) {
|
||||||
|
mcMMO.p.getLogger().info("Aborting profile loading recovery for " + player.getName() + " - player logged out");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
McMMOPlayer mcMMOPlayer = new McMMOPlayer(player, profile);
|
||||||
|
UserManager.track(mcMMOPlayer);
|
||||||
|
mcMMOPlayer.actualizeRespawnATS();
|
||||||
|
ScoreboardManager.setupPlayer(player);
|
||||||
|
|
||||||
|
if (Config.getInstance().getShowProfileLoadedMessage()) {
|
||||||
|
player.sendMessage(LocaleLoader.getString("Profile.Loading.Success"));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Config.getInstance().getShowStatsAfterLogin()) {
|
||||||
|
ScoreboardManager.enablePlayerStatsScoreboard(player);
|
||||||
|
new McScoreboardKeepTask(player).runTaskLater(mcMMO.p, 1 * Misc.TICK_CONVERSION_FACTOR);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -2,6 +2,7 @@ package com.gmail.nossr50.runnables.skills;
|
|||||||
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Sound;
|
import org.bukkit.Sound;
|
||||||
|
import org.bukkit.Statistic;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
|
||||||
@@ -19,6 +20,7 @@ public class AprilTask extends BukkitRunnable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (Player player : mcMMO.p.getServer().getOnlinePlayers()) {
|
for (Player player : mcMMO.p.getServer().getOnlinePlayers()) {
|
||||||
|
int random = Misc.getRandom().nextInt(40) + 11;
|
||||||
int betterRandom = Misc.getRandom().nextInt(2000);
|
int betterRandom = Misc.getRandom().nextInt(2000);
|
||||||
if (betterRandom == 0) {
|
if (betterRandom == 0) {
|
||||||
player.playSound(player.getLocation(), Sound.LEVEL_UP, Misc.LEVELUP_VOLUME, Misc.LEVELUP_PITCH);
|
player.playSound(player.getLocation(), Sound.LEVEL_UP, Misc.LEVELUP_VOLUME, Misc.LEVELUP_PITCH);
|
||||||
@@ -26,10 +28,9 @@ public class AprilTask extends BukkitRunnable {
|
|||||||
fireworksShow(player);
|
fireworksShow(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (HolidayManager.FakeSkillType fakeSkillType : HolidayManager.FakeSkillType.values()) {
|
for (Statistic statistic : mcMMO.getHolidayManager().movementStatistics) {
|
||||||
int random = Misc.getRandom().nextInt(250);
|
if (player.getStatistic(statistic) > 0 && player.getStatistic(statistic) % random == 0) {
|
||||||
if (random == 0) {
|
mcMMO.getHolidayManager().levelUpApril(player, HolidayManager.FakeSkillType.getByStatistic(statistic));
|
||||||
mcMMO.getHolidayManager().levelUpApril(player, fakeSkillType);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import com.gmail.nossr50.config.skills.alchemy.PotionConfig;
|
|||||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||||
import com.gmail.nossr50.datatypes.skills.XPGainReason;
|
import com.gmail.nossr50.datatypes.skills.XPGainReason;
|
||||||
|
import com.gmail.nossr50.datatypes.skills.alchemy.PotionStage;
|
||||||
import com.gmail.nossr50.skills.SkillManager;
|
import com.gmail.nossr50.skills.SkillManager;
|
||||||
import com.gmail.nossr50.util.StringUtils;
|
import com.gmail.nossr50.util.StringUtils;
|
||||||
|
|
||||||
@@ -64,7 +65,7 @@ public class AlchemyManager extends SkillManager {
|
|||||||
return Math.min(Alchemy.catalysisMaxSpeed, Alchemy.catalysisMinSpeed + (Alchemy.catalysisMaxSpeed - Alchemy.catalysisMinSpeed) * (skillLevel - Alchemy.catalysisUnlockLevel) / (Alchemy.catalysisMaxBonusLevel - Alchemy.catalysisUnlockLevel)) * (isLucky ? LUCKY_MODIFIER : 1.0);
|
return Math.min(Alchemy.catalysisMaxSpeed, Alchemy.catalysisMinSpeed + (Alchemy.catalysisMaxSpeed - Alchemy.catalysisMinSpeed) * (skillLevel - Alchemy.catalysisUnlockLevel) / (Alchemy.catalysisMaxBonusLevel - Alchemy.catalysisUnlockLevel)) * (isLucky ? LUCKY_MODIFIER : 1.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void handlePotionBrewSuccesses(int amount) {
|
public void handlePotionBrewSuccesses(PotionStage potionStage, int amount) {
|
||||||
applyXpGain((float) (ExperienceConfig.getInstance().getPotionXP() * amount), XPGainReason.PVE);
|
applyXpGain((float) (ExperienceConfig.getInstance().getPotionXP(potionStage) * amount), XPGainReason.PVE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.gmail.nossr50.skills.alchemy;
|
package com.gmail.nossr50.skills.alchemy;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
@@ -17,6 +18,8 @@ import com.gmail.nossr50.mcMMO;
|
|||||||
import com.gmail.nossr50.config.skills.alchemy.PotionConfig;
|
import com.gmail.nossr50.config.skills.alchemy.PotionConfig;
|
||||||
import com.gmail.nossr50.datatypes.skills.SecondaryAbility;
|
import com.gmail.nossr50.datatypes.skills.SecondaryAbility;
|
||||||
import com.gmail.nossr50.datatypes.skills.alchemy.AlchemyPotion;
|
import com.gmail.nossr50.datatypes.skills.alchemy.AlchemyPotion;
|
||||||
|
import com.gmail.nossr50.datatypes.skills.alchemy.PotionStage;
|
||||||
|
import com.gmail.nossr50.events.fake.FakeBrewEvent;
|
||||||
import com.gmail.nossr50.runnables.player.PlayerUpdateInventoryTask;
|
import com.gmail.nossr50.runnables.player.PlayerUpdateInventoryTask;
|
||||||
import com.gmail.nossr50.runnables.skills.AlchemyBrewCheckTask;
|
import com.gmail.nossr50.runnables.skills.AlchemyBrewCheckTask;
|
||||||
import com.gmail.nossr50.util.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
@@ -100,6 +103,8 @@ public final class AlchemyPotionBrewer {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
List<AlchemyPotion> inputList = new ArrayList<AlchemyPotion>();
|
||||||
|
|
||||||
for (int i = 0; i < 3; i++) {
|
for (int i = 0; i < 3; i++) {
|
||||||
ItemStack item = inventory.getItem(i);
|
ItemStack item = inventory.getItem(i);
|
||||||
|
|
||||||
@@ -110,12 +115,26 @@ public final class AlchemyPotionBrewer {
|
|||||||
AlchemyPotion input = PotionConfig.getInstance().getPotion(item.getDurability());
|
AlchemyPotion input = PotionConfig.getInstance().getPotion(item.getDurability());
|
||||||
AlchemyPotion output = PotionConfig.getInstance().getPotion(input.getChildDataValue(ingredient));
|
AlchemyPotion output = PotionConfig.getInstance().getPotion(input.getChildDataValue(ingredient));
|
||||||
|
|
||||||
|
inputList.add(input);
|
||||||
|
|
||||||
if (output != null) {
|
if (output != null) {
|
||||||
inventory.setItem(i, output.toItemStack(item.getAmount()).clone());
|
inventory.setItem(i, output.toItemStack(item.getAmount()).clone());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (player != null) {
|
FakeBrewEvent event = new FakeBrewEvent(brewingStand.getBlock(), inventory);
|
||||||
UserManager.getPlayer(player).getAlchemyManager().handlePotionBrewSuccesses(1);
|
mcMMO.p.getServer().getPluginManager().callEvent(event);
|
||||||
}
|
|
||||||
|
if (event.isCancelled() || inputList.isEmpty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (AlchemyPotion input : inputList) {
|
||||||
|
AlchemyPotion output = PotionConfig.getInstance().getPotion(input.getChildDataValue(ingredient));
|
||||||
|
|
||||||
|
if (output != null && player != null) {
|
||||||
|
PotionStage potionStage = PotionStage.getPotionStage(input, output);
|
||||||
|
UserManager.getPlayer(player).getAlchemyManager().handlePotionBrewSuccesses(potionStage, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ public class Archery {
|
|||||||
public static double skillShotMaxBonusPercentage = AdvancedConfig.getInstance().getSkillShotBonusMax();
|
public static double skillShotMaxBonusPercentage = AdvancedConfig.getInstance().getSkillShotBonusMax();
|
||||||
public static double skillShotMaxBonusDamage = AdvancedConfig.getInstance().getSkillShotDamageMax();
|
public static double skillShotMaxBonusDamage = AdvancedConfig.getInstance().getSkillShotDamageMax();
|
||||||
|
|
||||||
public static double dazeModifier = AdvancedConfig.getInstance().getDazeModifier();
|
public static double dazeBonusDamage = AdvancedConfig.getInstance().getDazeBonusDamage();
|
||||||
|
|
||||||
public static final double DISTANCE_XP_MULTIPLIER = 0.025;
|
public static final double DISTANCE_XP_MULTIPLIER = 0.025;
|
||||||
|
|
||||||
|
|||||||
@@ -1,11 +1,9 @@
|
|||||||
package com.gmail.nossr50.skills.archery;
|
package com.gmail.nossr50.skills.archery;
|
||||||
|
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.entity.Arrow;
|
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.LivingEntity;
|
import org.bukkit.entity.LivingEntity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
|
||||||
import org.bukkit.potion.PotionEffect;
|
import org.bukkit.potion.PotionEffect;
|
||||||
import org.bukkit.potion.PotionEffectType;
|
import org.bukkit.potion.PotionEffectType;
|
||||||
|
|
||||||
@@ -18,7 +16,6 @@ import com.gmail.nossr50.skills.SkillManager;
|
|||||||
import com.gmail.nossr50.util.Misc;
|
import com.gmail.nossr50.util.Misc;
|
||||||
import com.gmail.nossr50.util.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
import com.gmail.nossr50.util.player.UserManager;
|
import com.gmail.nossr50.util.player.UserManager;
|
||||||
import com.gmail.nossr50.util.skills.CombatUtils;
|
|
||||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||||
|
|
||||||
public class ArcheryManager extends SkillManager {
|
public class ArcheryManager extends SkillManager {
|
||||||
@@ -70,9 +67,8 @@ public class ArcheryManager extends SkillManager {
|
|||||||
* Handle the effects of the Daze ability
|
* Handle the effects of the Daze ability
|
||||||
*
|
*
|
||||||
* @param defender The {@link Player} being affected by the ability
|
* @param defender The {@link Player} being affected by the ability
|
||||||
* @param arrow The {@link Arrow} that was fired
|
|
||||||
*/
|
*/
|
||||||
public double daze(Player defender, Arrow arrow) {
|
public double daze(Player defender) {
|
||||||
if (!SkillUtils.activationSuccessful(SecondaryAbility.DAZE, getPlayer(), getSkillLevel(), activationChance)) {
|
if (!SkillUtils.activationSuccessful(SecondaryAbility.DAZE, getPlayer(), getSkillLevel(), activationChance)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -91,20 +87,21 @@ public class ArcheryManager extends SkillManager {
|
|||||||
getPlayer().sendMessage(LocaleLoader.getString("Combat.TargetDazed"));
|
getPlayer().sendMessage(LocaleLoader.getString("Combat.TargetDazed"));
|
||||||
}
|
}
|
||||||
|
|
||||||
return CombatUtils.callFakeDamageEvent(arrow, defender, DamageCause.PROJECTILE, Archery.dazeModifier);
|
return Archery.dazeBonusDamage;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handle the effects of the Skill Shot ability
|
* Handle the effects of the Skill Shot ability
|
||||||
*
|
*
|
||||||
* @param target The {@link LivingEntity} being affected by the ability
|
|
||||||
* @param damage The amount of damage initially dealt by the event
|
* @param damage The amount of damage initially dealt by the event
|
||||||
* @param arrow The {@link Arrow} that was fired
|
|
||||||
*/
|
*/
|
||||||
public double skillShot(LivingEntity target, double damage, Arrow arrow) {
|
public double skillShot(double damage) {
|
||||||
double damageBonusPercent = Math.min(((getSkillLevel() / Archery.skillShotIncreaseLevel) * Archery.skillShotIncreasePercentage), Archery.skillShotMaxBonusPercentage);
|
if (!SkillUtils.activationSuccessful(SecondaryAbility.SKILL_SHOT, getPlayer())) {
|
||||||
double archeryBonus = Math.min(damage * damageBonusPercent, Archery.skillShotMaxBonusDamage);
|
return damage;
|
||||||
|
}
|
||||||
|
|
||||||
return CombatUtils.callFakeDamageEvent(arrow, target, DamageCause.PROJECTILE, archeryBonus);
|
double damageBonusPercent = Math.min(((getSkillLevel() / Archery.skillShotIncreaseLevel) * Archery.skillShotIncreasePercentage), Archery.skillShotMaxBonusPercentage);
|
||||||
|
|
||||||
|
return Math.min(damage * damageBonusPercent, Archery.skillShotMaxBonusDamage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,20 +1,20 @@
|
|||||||
package com.gmail.nossr50.skills.axes;
|
package com.gmail.nossr50.skills.axes;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
import org.bukkit.entity.LivingEntity;
|
import org.bukkit.entity.LivingEntity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.entity.EntityDamageEvent.DamageModifier;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
import com.gmail.nossr50.mcMMO;
|
|
||||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||||
import com.gmail.nossr50.datatypes.skills.AbilityType;
|
import com.gmail.nossr50.datatypes.skills.AbilityType;
|
||||||
import com.gmail.nossr50.datatypes.skills.SecondaryAbility;
|
import com.gmail.nossr50.datatypes.skills.SecondaryAbility;
|
||||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||||
import com.gmail.nossr50.datatypes.skills.ToolType;
|
import com.gmail.nossr50.datatypes.skills.ToolType;
|
||||||
import com.gmail.nossr50.events.skills.secondaryabilities.SecondaryAbilityWeightedActivationCheckEvent;
|
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.skills.SkillManager;
|
import com.gmail.nossr50.skills.SkillManager;
|
||||||
import com.gmail.nossr50.util.ItemUtils;
|
import com.gmail.nossr50.util.ItemUtils;
|
||||||
import com.gmail.nossr50.util.Misc;
|
|
||||||
import com.gmail.nossr50.util.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
import com.gmail.nossr50.util.player.UserManager;
|
import com.gmail.nossr50.util.player.UserManager;
|
||||||
import com.gmail.nossr50.util.skills.CombatUtils;
|
import com.gmail.nossr50.util.skills.CombatUtils;
|
||||||
@@ -52,13 +52,13 @@ public class AxesManager extends SkillManager {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Handle the effects of the Axe Mastery ability
|
* Handle the effects of the Axe Mastery ability
|
||||||
*
|
|
||||||
* @param target The {@link LivingEntity} being affected by the ability
|
|
||||||
*/
|
*/
|
||||||
public double axeMastery(LivingEntity target) {
|
public double axeMastery() {
|
||||||
double axeBonus = Math.min(getSkillLevel() / (Axes.axeMasteryMaxBonusLevel / Axes.axeMasteryMaxBonus), Axes.axeMasteryMaxBonus);
|
if (!SkillUtils.activationSuccessful(SecondaryAbility.AXE_MASTERY, getPlayer())) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
return CombatUtils.callFakeDamageEvent(getPlayer(), target, axeBonus);
|
return Math.min(getSkillLevel() / (Axes.axeMasteryMaxBonusLevel / Axes.axeMasteryMaxBonus), Axes.axeMasteryMaxBonus);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -85,7 +85,7 @@ public class AxesManager extends SkillManager {
|
|||||||
damage = (damage * Axes.criticalHitPVEModifier) - damage;
|
damage = (damage * Axes.criticalHitPVEModifier) - damage;
|
||||||
}
|
}
|
||||||
|
|
||||||
return CombatUtils.callFakeDamageEvent(player, target, damage);
|
return damage;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -98,10 +98,7 @@ public class AxesManager extends SkillManager {
|
|||||||
|
|
||||||
for (ItemStack armor : target.getEquipment().getArmorContents()) {
|
for (ItemStack armor : target.getEquipment().getArmorContents()) {
|
||||||
if (ItemUtils.isArmor(armor)) {
|
if (ItemUtils.isArmor(armor)) {
|
||||||
double chance = Axes.impactChance / activationChance;
|
if (SkillUtils.activationSuccessful(SecondaryAbility.ARMOR_IMPACT, getPlayer(), Axes.impactChance, activationChance)) {
|
||||||
SecondaryAbilityWeightedActivationCheckEvent event = new SecondaryAbilityWeightedActivationCheckEvent(getPlayer(), SecondaryAbility.ARMOR_IMPACT, chance);
|
|
||||||
mcMMO.p.getServer().getPluginManager().callEvent(event);
|
|
||||||
if ((event.getChance() * activationChance) > Misc.getRandom().nextInt(activationChance)) {
|
|
||||||
SkillUtils.handleDurabilityChange(armor, durabilityDamage, Axes.impactMaxDurabilityModifier);
|
SkillUtils.handleDurabilityChange(armor, durabilityDamage, Axes.impactMaxDurabilityModifier);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -114,10 +111,7 @@ public class AxesManager extends SkillManager {
|
|||||||
* @param target The {@link LivingEntity} being affected by the ability
|
* @param target The {@link LivingEntity} being affected by the ability
|
||||||
*/
|
*/
|
||||||
public double greaterImpact(LivingEntity target) {
|
public double greaterImpact(LivingEntity target) {
|
||||||
double chance = Axes.greaterImpactChance / activationChance;
|
if (!SkillUtils.activationSuccessful(SecondaryAbility.GREATER_IMPACT, getPlayer(), Axes.greaterImpactChance, activationChance)) {
|
||||||
SecondaryAbilityWeightedActivationCheckEvent event = new SecondaryAbilityWeightedActivationCheckEvent(getPlayer(), SecondaryAbility.GREATER_IMPACT, chance);
|
|
||||||
mcMMO.p.getServer().getPluginManager().callEvent(event);
|
|
||||||
if ((event.getChance() * activationChance) <= Misc.getRandom().nextInt(activationChance)) {
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -138,7 +132,7 @@ public class AxesManager extends SkillManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return CombatUtils.callFakeDamageEvent(player, target, Axes.greaterImpactBonusDamage);
|
return Axes.greaterImpactBonusDamage;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -147,7 +141,7 @@ public class AxesManager extends SkillManager {
|
|||||||
* @param target The {@link LivingEntity} being affected by the ability
|
* @param target The {@link LivingEntity} being affected by the ability
|
||||||
* @param damage The amount of damage initially dealt by the event
|
* @param damage The amount of damage initially dealt by the event
|
||||||
*/
|
*/
|
||||||
public void skullSplitterCheck(LivingEntity target, double damage) {
|
public void skullSplitterCheck(LivingEntity target, double damage, Map<DamageModifier, Double> modifiers) {
|
||||||
CombatUtils.applyAbilityAoE(getPlayer(), target, damage / Axes.skullSplitterModifier, skill);
|
CombatUtils.applyAbilityAoE(getPlayer(), target, damage / Axes.skullSplitterModifier, modifiers, skill);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,13 +21,13 @@ public class Excavation {
|
|||||||
protected static List<ExcavationTreasure> getTreasures(BlockState blockState) {
|
protected static List<ExcavationTreasure> getTreasures(BlockState blockState) {
|
||||||
switch (blockState.getType()) {
|
switch (blockState.getType()) {
|
||||||
case DIRT:
|
case DIRT:
|
||||||
return TreasureConfig.getInstance().excavationFromDirt;
|
return blockState.getRawData() == 0x2 ? TreasureConfig.getInstance().excavationFromPodzol : TreasureConfig.getInstance().excavationFromDirt;
|
||||||
|
|
||||||
case GRASS:
|
case GRASS:
|
||||||
return TreasureConfig.getInstance().excavationFromGrass;
|
return TreasureConfig.getInstance().excavationFromGrass;
|
||||||
|
|
||||||
case SAND:
|
case SAND:
|
||||||
return TreasureConfig.getInstance().excavationFromSand;
|
return blockState.getRawData() == 0x1 ? TreasureConfig.getInstance().excavationFromRedSand : TreasureConfig.getInstance().excavationFromSand;
|
||||||
|
|
||||||
case GRAVEL:
|
case GRAVEL:
|
||||||
return TreasureConfig.getInstance().excavationFromGravel;
|
return TreasureConfig.getInstance().excavationFromGravel;
|
||||||
|
|||||||
@@ -1,9 +1,12 @@
|
|||||||
package com.gmail.nossr50.skills.fishing;
|
package com.gmail.nossr50.skills.fishing;
|
||||||
|
|
||||||
|
import java.util.EnumSet;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.block.Biome;
|
||||||
import org.bukkit.enchantments.Enchantment;
|
import org.bukkit.enchantments.Enchantment;
|
||||||
import org.bukkit.entity.LivingEntity;
|
import org.bukkit.entity.LivingEntity;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
@@ -54,6 +57,13 @@ public final class Fishing {
|
|||||||
public static int fishermansDietRankLevel2 = fishermansDietRankLevel1 * 2;
|
public static int fishermansDietRankLevel2 = fishermansDietRankLevel1 * 2;
|
||||||
public static int fishermansDietMaxLevel = fishermansDietRankLevel1 * 5;
|
public static int fishermansDietMaxLevel = fishermansDietRankLevel1 * 5;
|
||||||
|
|
||||||
|
public static Set<Biome> masterAnglerBiomes = EnumSet.of(Biome.RIVER, Biome.OCEAN, Biome.DEEP_OCEAN);
|
||||||
|
public static Set<Biome> iceFishingBiomes = EnumSet.of(
|
||||||
|
Biome.FROZEN_OCEAN, Biome.FROZEN_RIVER,
|
||||||
|
Biome.TAIGA, Biome.TAIGA_HILLS, Biome.TAIGA_MOUNTAINS,
|
||||||
|
Biome.ICE_PLAINS, Biome.ICE_MOUNTAINS, Biome.ICE_PLAINS_SPIKES,
|
||||||
|
Biome.COLD_TAIGA, Biome.COLD_TAIGA_HILLS, Biome.COLD_TAIGA_MOUNTAINS);
|
||||||
|
|
||||||
private Fishing() {}
|
private Fishing() {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -12,7 +12,6 @@ import org.bukkit.Material;
|
|||||||
import org.bukkit.Sound;
|
import org.bukkit.Sound;
|
||||||
import org.bukkit.WeatherType;
|
import org.bukkit.WeatherType;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.block.Biome;
|
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.block.BlockFace;
|
import org.bukkit.block.BlockFace;
|
||||||
import org.bukkit.enchantments.Enchantment;
|
import org.bukkit.enchantments.Enchantment;
|
||||||
@@ -199,10 +198,7 @@ public class FishingManager extends SkillManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Make sure this is a body of water, not just a block of ice.
|
// Make sure this is a body of water, not just a block of ice.
|
||||||
Biome biome = block.getBiome();
|
if (!Fishing.iceFishingBiomes.contains(block.getBiome()) && (block.getRelative(BlockFace.DOWN, 3).getType() != Material.STATIONARY_WATER)) {
|
||||||
boolean isFrozenBiome = (biome == Biome.FROZEN_OCEAN || biome == Biome.FROZEN_RIVER || biome == Biome.TAIGA || biome == Biome.TAIGA_HILLS || biome == Biome.ICE_PLAINS || biome == Biome.ICE_MOUNTAINS);
|
|
||||||
|
|
||||||
if (!isFrozenBiome && (block.getRelative(BlockFace.DOWN, 3).getType() != Material.STATIONARY_WATER)) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -282,12 +278,11 @@ public class FishingManager extends SkillManager {
|
|||||||
public void masterAngler(Fish hook) {
|
public void masterAngler(Fish hook) {
|
||||||
Player player = getPlayer();
|
Player player = getPlayer();
|
||||||
Location location = hook.getLocation();
|
Location location = hook.getLocation();
|
||||||
Biome biome = location.getBlock().getBiome();
|
|
||||||
double biteChance = hook.getBiteChance();
|
double biteChance = hook.getBiteChance();
|
||||||
|
|
||||||
hookLocation = location;
|
hookLocation = location;
|
||||||
|
|
||||||
if (biome == Biome.RIVER || biome == Biome.OCEAN) {
|
if (Fishing.masterAnglerBiomes.contains(location.getBlock().getBiome())) {
|
||||||
biteChance = biteChance * AdvancedConfig.getInstance().getMasterAnglerBiomeModifier();
|
biteChance = biteChance * AdvancedConfig.getInstance().getMasterAnglerBiomeModifier();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -305,6 +300,7 @@ public class FishingManager extends SkillManager {
|
|||||||
*/
|
*/
|
||||||
public void handleFishing(Item fishingCatch) {
|
public void handleFishing(Item fishingCatch) {
|
||||||
this.fishingCatch = fishingCatch;
|
this.fishingCatch = fishingCatch;
|
||||||
|
int fishXp = ExperienceConfig.getInstance().getFishXp(fishingCatch.getItemStack().getData());
|
||||||
int treasureXp = 0;
|
int treasureXp = 0;
|
||||||
Player player = getPlayer();
|
Player player = getPlayer();
|
||||||
FishingTreasure treasure = null;
|
FishingTreasure treasure = null;
|
||||||
@@ -315,8 +311,6 @@ public class FishingManager extends SkillManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (treasure != null) {
|
if (treasure != null) {
|
||||||
player.sendMessage(LocaleLoader.getString("Fishing.Ability.TH.ItemFound"));
|
|
||||||
|
|
||||||
ItemStack treasureDrop = treasure.getDrop().clone(); // Not cloning is bad, m'kay?
|
ItemStack treasureDrop = treasure.getDrop().clone(); // Not cloning is bad, m'kay?
|
||||||
Map<Enchantment, Integer> enchants = new HashMap<Enchantment, Integer>();
|
Map<Enchantment, Integer> enchants = new HashMap<Enchantment, Integer>();
|
||||||
|
|
||||||
@@ -356,7 +350,7 @@ public class FishingManager extends SkillManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
applyXpGain(ExperienceConfig.getInstance().getFishingBaseXP() + treasureXp, XPGainReason.PVE);
|
applyXpGain(fishXp + treasureXp, XPGainReason.PVE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -455,6 +449,8 @@ public class FishingManager extends SkillManager {
|
|||||||
*/
|
*/
|
||||||
private FishingTreasure getFishingTreasure() {
|
private FishingTreasure getFishingTreasure() {
|
||||||
double diceRoll = Misc.getRandom().nextDouble() * 100;
|
double diceRoll = Misc.getRandom().nextDouble() * 100;
|
||||||
|
diceRoll -= getPlayer().getItemInHand().getEnchantmentLevel(Enchantment.LUCK);
|
||||||
|
|
||||||
FishingTreasure treasure = null;
|
FishingTreasure treasure = null;
|
||||||
|
|
||||||
for (Rarity rarity : Rarity.values()) {
|
for (Rarity rarity : Rarity.values()) {
|
||||||
|
|||||||
@@ -148,7 +148,12 @@ public class HerbalismManager extends SkillManager {
|
|||||||
processGreenThumbPlants(blockState, greenTerra);
|
processGreenThumbPlants(blockState, greenTerra);
|
||||||
}
|
}
|
||||||
|
|
||||||
xp = ExperienceConfig.getInstance().getXp(skill, material);
|
if (material == Material.DOUBLE_PLANT || material == Material.RED_ROSE || material == Material.LONG_GRASS) {
|
||||||
|
xp = ExperienceConfig.getInstance().getFlowerAndGrassXp(blockState.getData());
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
xp = ExperienceConfig.getInstance().getXp(skill, material);
|
||||||
|
}
|
||||||
|
|
||||||
if (Config.getInstance().getDoubleDropsEnabled(skill, material) && Permissions.secondaryAbilityEnabled(player, SecondaryAbility.HERBALISM_DOUBLE_DROPS)) {
|
if (Config.getInstance().getDoubleDropsEnabled(skill, material) && Permissions.secondaryAbilityEnabled(player, SecondaryAbility.HERBALISM_DOUBLE_DROPS)) {
|
||||||
drops = blockState.getBlock().getDrops();
|
drops = blockState.getBlock().getDrops();
|
||||||
|
|||||||
@@ -1,9 +1,18 @@
|
|||||||
package com.gmail.nossr50.skills.mining;
|
package com.gmail.nossr50.skills.mining;
|
||||||
|
|
||||||
import org.bukkit.Material;
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.entity.TNTPrimed;
|
||||||
|
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||||
|
import org.bukkit.event.entity.EntityDamageEvent.DamageModifier;
|
||||||
|
|
||||||
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.gmail.nossr50.config.AdvancedConfig;
|
import com.gmail.nossr50.config.AdvancedConfig;
|
||||||
import com.gmail.nossr50.config.Config;
|
import com.gmail.nossr50.config.Config;
|
||||||
|
import com.gmail.nossr50.util.player.UserManager;
|
||||||
|
|
||||||
public class BlastMining {
|
public class BlastMining {
|
||||||
// The order of the values is extremely important, a few methods depend on it to work properly
|
// The order of the values is extremely important, a few methods depend on it to work properly
|
||||||
@@ -55,4 +64,58 @@ public class BlastMining {
|
|||||||
public static Material detonator = Config.getInstance().getDetonatorItem();
|
public static Material detonator = Config.getInstance().getDetonatorItem();
|
||||||
|
|
||||||
public final static int MAXIMUM_REMOTE_DETONATION_DISTANCE = 100;
|
public final static int MAXIMUM_REMOTE_DETONATION_DISTANCE = 100;
|
||||||
|
|
||||||
|
public static int getDemolitionExpertUnlockLevel() {
|
||||||
|
List<Tier> tierList = Arrays.asList(Tier.values());
|
||||||
|
for (Tier tier : tierList) {
|
||||||
|
if (tier.getBlastDamageDecrease() > 0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
return tier == Tier.EIGHT ? tier.getLevel() : tierList.get(tierList.indexOf(tier) - 1).getLevel();
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int getBiggerBombsUnlockLevel() {
|
||||||
|
List<Tier> tierList = Arrays.asList(Tier.values());
|
||||||
|
for (Tier tier : tierList) {
|
||||||
|
if (tier.getBlastRadiusModifier() > 1.0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
return tier == Tier.EIGHT ? tier.getLevel() : tierList.get(tierList.indexOf(tier) - 1).getLevel();
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean processBlastMiningExplosion(EntityDamageByEntityEvent event, TNTPrimed tnt, Player defender) {
|
||||||
|
if (!tnt.hasMetadata(mcMMO.tntMetadataKey) || !UserManager.hasPlayerDataKey(defender)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// We can make this assumption because we (should) be the only ones using this exact metadata
|
||||||
|
Player player = mcMMO.p.getServer().getPlayerExact(tnt.getMetadata(mcMMO.tntMetadataKey).get(0).asString());
|
||||||
|
|
||||||
|
if (!player.equals(defender)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
MiningManager miningManager = UserManager.getPlayer(defender).getMiningManager();
|
||||||
|
|
||||||
|
if (!miningManager.canUseDemolitionsExpertise()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
event.setDamage(DamageModifier.BASE, miningManager.processDemolitionsExpertise(event.getDamage()));
|
||||||
|
|
||||||
|
if (event.getFinalDamage() == 0) {
|
||||||
|
event.setCancelled(true);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,11 +39,13 @@ public class Mining {
|
|||||||
switch (blockType) {
|
switch (blockType) {
|
||||||
case ENDER_STONE:
|
case ENDER_STONE:
|
||||||
case GOLD_ORE:
|
case GOLD_ORE:
|
||||||
|
case HARD_CLAY:
|
||||||
case IRON_ORE:
|
case IRON_ORE:
|
||||||
case MOSSY_COBBLESTONE:
|
case MOSSY_COBBLESTONE:
|
||||||
case NETHERRACK:
|
case NETHERRACK:
|
||||||
case OBSIDIAN:
|
case OBSIDIAN:
|
||||||
case SANDSTONE:
|
case SANDSTONE:
|
||||||
|
case STAINED_CLAY:
|
||||||
handleMiningDrops(blockState);
|
handleMiningDrops(blockState);
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -55,12 +57,13 @@ public class Mining {
|
|||||||
|
|
||||||
case COAL_ORE:
|
case COAL_ORE:
|
||||||
case DIAMOND_ORE:
|
case DIAMOND_ORE:
|
||||||
case REDSTONE_ORE:
|
case EMERALD_ORE:
|
||||||
case GLOWSTONE:
|
case GLOWSTONE:
|
||||||
case LAPIS_ORE:
|
case LAPIS_ORE:
|
||||||
case STONE:
|
case PACKED_ICE:
|
||||||
case EMERALD_ORE:
|
|
||||||
case QUARTZ_ORE:
|
case QUARTZ_ORE:
|
||||||
|
case REDSTONE_ORE:
|
||||||
|
case STONE:
|
||||||
Misc.dropItem(blockState.getLocation(), new ItemStack(blockType));
|
Misc.dropItem(blockState.getLocation(), new ItemStack(blockType));
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -82,17 +85,20 @@ public class Mining {
|
|||||||
case COAL_ORE:
|
case COAL_ORE:
|
||||||
case DIAMOND_ORE:
|
case DIAMOND_ORE:
|
||||||
case EMERALD_ORE:
|
case EMERALD_ORE:
|
||||||
case GLOWSTONE:
|
|
||||||
case LAPIS_ORE:
|
|
||||||
case STONE:
|
|
||||||
case ENDER_STONE:
|
case ENDER_STONE:
|
||||||
|
case GLOWSTONE:
|
||||||
case GOLD_ORE:
|
case GOLD_ORE:
|
||||||
|
case HARD_CLAY:
|
||||||
case IRON_ORE:
|
case IRON_ORE:
|
||||||
|
case LAPIS_ORE:
|
||||||
case MOSSY_COBBLESTONE:
|
case MOSSY_COBBLESTONE:
|
||||||
case NETHERRACK:
|
case NETHERRACK:
|
||||||
case OBSIDIAN:
|
case OBSIDIAN:
|
||||||
|
case PACKED_ICE:
|
||||||
case REDSTONE_ORE:
|
case REDSTONE_ORE:
|
||||||
case SANDSTONE:
|
case SANDSTONE:
|
||||||
|
case STAINED_CLAY:
|
||||||
|
case STONE:
|
||||||
case QUARTZ_ORE:
|
case QUARTZ_ORE:
|
||||||
Misc.dropItems(blockState.getLocation(), blockState.getBlock().getDrops());
|
Misc.dropItems(blockState.getLocation(), blockState.getBlock().getDrops());
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ public class MiningManager extends SkillManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean canUseDemolitionsExpertise() {
|
public boolean canUseDemolitionsExpertise() {
|
||||||
return getSkillLevel() >= BlastMining.Tier.FOUR.getLevel() && Permissions.demolitionsExpertise(getPlayer());
|
return getSkillLevel() >= BlastMining.getDemolitionExpertUnlockLevel() && Permissions.demolitionsExpertise(getPlayer());
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean canDetonate() {
|
public boolean canDetonate() {
|
||||||
@@ -47,7 +47,7 @@ public class MiningManager extends SkillManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean canUseBiggerBombs() {
|
public boolean canUseBiggerBombs() {
|
||||||
return getSkillLevel() >= BlastMining.Tier.TWO.getLevel() && Permissions.biggerBombs(getPlayer());
|
return getSkillLevel() >= BlastMining.getBiggerBombsUnlockLevel() && Permissions.biggerBombs(getPlayer());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -97,7 +97,8 @@ public class RepairManager extends SkillManager {
|
|||||||
|
|
||||||
// Check if they have the proper material to repair with
|
// Check if they have the proper material to repair with
|
||||||
if (!inventory.contains(repairMaterial)) {
|
if (!inventory.contains(repairMaterial)) {
|
||||||
String message = LocaleLoader.getString("Skills.NeedMore", StringUtils.getPrettyItemString(repairMaterial));
|
String prettyName = repairable.getRepairMaterialPrettyName() == null ? StringUtils.getPrettyItemString(repairMaterial) : repairable.getRepairMaterialPrettyName();
|
||||||
|
String message = LocaleLoader.getString("Skills.NeedMore", prettyName);
|
||||||
|
|
||||||
if (repairMaterialMetadata != (byte) -1 && !inventory.containsAtLeast(toRemove, 1)) {
|
if (repairMaterialMetadata != (byte) -1 && !inventory.containsAtLeast(toRemove, 1)) {
|
||||||
message += ":" + repairMaterialMetadata;
|
message += ":" + repairMaterialMetadata;
|
||||||
|
|||||||
@@ -28,6 +28,13 @@ public interface Repairable {
|
|||||||
*/
|
*/
|
||||||
public byte getRepairMaterialMetadata();
|
public byte getRepairMaterialMetadata();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the pretty name of the material used to repair this item
|
||||||
|
*
|
||||||
|
* @return the pretty name of the repair material
|
||||||
|
*/
|
||||||
|
public String getRepairMaterialPrettyName();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the RepairItemType value for this repairable item
|
* Gets the RepairItemType value for this repairable item
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -8,11 +8,15 @@ import com.gmail.nossr50.datatypes.skills.MaterialType;
|
|||||||
|
|
||||||
public class RepairableFactory {
|
public class RepairableFactory {
|
||||||
public static Repairable getRepairable(Material itemMaterial, Material repairMaterial, byte repairMetadata, int minimumQuantity, short maximumDurability) {
|
public static Repairable getRepairable(Material itemMaterial, Material repairMaterial, byte repairMetadata, int minimumQuantity, short maximumDurability) {
|
||||||
return getRepairable(itemMaterial, repairMaterial, repairMetadata, 0, minimumQuantity, maximumDurability, ItemType.OTHER, MaterialType.OTHER, 1);
|
return getRepairable(itemMaterial, repairMaterial, repairMetadata, null, 0, minimumQuantity, maximumDurability, ItemType.OTHER, MaterialType.OTHER, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Repairable getRepairable(Material itemMaterial, Material repairMaterial, byte repairMetadata, int minimumLevel, int minimumQuantity, short maximumDurability, ItemType repairItemType, MaterialType repairMaterialType, double xpMultiplier) {
|
public static Repairable getRepairable(Material itemMaterial, Material repairMaterial, byte repairMetadata, int minimumLevel, int minimumQuantity, short maximumDurability, ItemType repairItemType, MaterialType repairMaterialType, double xpMultiplier) {
|
||||||
|
return getRepairable(itemMaterial, repairMaterial, repairMetadata, null, minimumLevel, minimumQuantity, maximumDurability, repairItemType, repairMaterialType, xpMultiplier);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Repairable getRepairable(Material itemMaterial, Material repairMaterial, byte repairMetadata, String repairMaterialPrettyName, int minimumLevel, int minimumQuantity, short maximumDurability, ItemType repairItemType, MaterialType repairMaterialType, double xpMultiplier) {
|
||||||
// TODO: Add in loading from config what type of repairable we want.
|
// TODO: Add in loading from config what type of repairable we want.
|
||||||
return new SimpleRepairable(itemMaterial, repairMaterial, repairMetadata, minimumLevel, minimumQuantity, maximumDurability, repairItemType, repairMaterialType, xpMultiplier);
|
return new SimpleRepairable(itemMaterial, repairMaterial, repairMetadata, repairMaterialPrettyName, minimumLevel, minimumQuantity, maximumDurability, repairItemType, repairMaterialType, xpMultiplier);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,14 +11,16 @@ public class SimpleRepairable implements Repairable {
|
|||||||
private final int minimumQuantity, minimumLevel;
|
private final int minimumQuantity, minimumLevel;
|
||||||
private final short maximumDurability, baseRepairDurability;
|
private final short maximumDurability, baseRepairDurability;
|
||||||
private final byte repairMetadata;
|
private final byte repairMetadata;
|
||||||
|
private String repairMaterialPrettyName;
|
||||||
private final ItemType repairItemType;
|
private final ItemType repairItemType;
|
||||||
private final MaterialType repairMaterialType;
|
private final MaterialType repairMaterialType;
|
||||||
private final double xpMultiplier;
|
private final double xpMultiplier;
|
||||||
|
|
||||||
protected SimpleRepairable(Material type, Material repairMaterial, byte repairMetadata, int minimumLevel, int minimumQuantity, short maximumDurability, ItemType repairItemType, MaterialType repairMaterialType, double xpMultiplier) {
|
protected SimpleRepairable(Material type, Material repairMaterial, byte repairMetadata, String repairMaterialPrettyName, int minimumLevel, int minimumQuantity, short maximumDurability, ItemType repairItemType, MaterialType repairMaterialType, double xpMultiplier) {
|
||||||
this.itemMaterial = type;
|
this.itemMaterial = type;
|
||||||
this.repairMaterial = repairMaterial;
|
this.repairMaterial = repairMaterial;
|
||||||
this.repairMetadata = repairMetadata;
|
this.repairMetadata = repairMetadata;
|
||||||
|
this.repairMaterialPrettyName = repairMaterialPrettyName;
|
||||||
this.repairItemType = repairItemType;
|
this.repairItemType = repairItemType;
|
||||||
this.repairMaterialType = repairMaterialType;
|
this.repairMaterialType = repairMaterialType;
|
||||||
this.minimumLevel = minimumLevel;
|
this.minimumLevel = minimumLevel;
|
||||||
@@ -43,6 +45,11 @@ public class SimpleRepairable implements Repairable {
|
|||||||
return repairMetadata;
|
return repairMetadata;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getRepairMaterialPrettyName() {
|
||||||
|
return repairMaterialPrettyName;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ItemType getRepairItemType() {
|
public ItemType getRepairItemType() {
|
||||||
return repairItemType;
|
return repairItemType;
|
||||||
|
|||||||
@@ -84,8 +84,6 @@ public class SalvageManager extends SkillManager {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
byte salvageMaterialMetadata = salvageable.getSalvageMaterialMetadata();
|
|
||||||
|
|
||||||
int salvageableAmount = Salvage.calculateSalvageableAmount(item.getDurability(), salvageable.getMaximumDurability(), salvageable.getMaximumQuantity());
|
int salvageableAmount = Salvage.calculateSalvageableAmount(item.getDurability(), salvageable.getMaximumDurability(), salvageable.getMaximumQuantity());
|
||||||
|
|
||||||
if (salvageableAmount == 0) {
|
if (salvageableAmount == 0) {
|
||||||
@@ -108,6 +106,8 @@ public class SalvageManager extends SkillManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
byte salvageMaterialMetadata = (salvageable.getSalvageMaterialMetadata() != (byte) -1) ? salvageable.getSalvageMaterialMetadata() : 0;
|
||||||
|
|
||||||
Misc.dropItems(location, new MaterialData(salvageable.getSalvageMaterial(), salvageMaterialMetadata).toItemStack(salvageableAmount), 1);
|
Misc.dropItems(location, new MaterialData(salvageable.getSalvageMaterial(), salvageMaterialMetadata).toItemStack(salvageableAmount), 1);
|
||||||
|
|
||||||
// BWONG BWONG BWONG - CLUNK!
|
// BWONG BWONG BWONG - CLUNK!
|
||||||
|
|||||||
@@ -7,37 +7,37 @@ import com.gmail.nossr50.datatypes.skills.MaterialType;
|
|||||||
|
|
||||||
public interface Salvageable {
|
public interface Salvageable {
|
||||||
/**
|
/**
|
||||||
* Gets the type of this repairable item
|
* Gets the type of this salvageable item
|
||||||
*
|
*
|
||||||
* @return the type of this repairable
|
* @return the type of this salvageable
|
||||||
*/
|
*/
|
||||||
public Material getItemMaterial();
|
public Material getItemMaterial();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the id of the material used to repair this item
|
* Gets the material of the items dropped when salvaging this item
|
||||||
*
|
*
|
||||||
* @return the id of the repair material
|
* @return the material of the salvage drop
|
||||||
*/
|
*/
|
||||||
public Material getSalvageMaterial();
|
public Material getSalvageMaterial();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the metadata byte value of the material used to repair this item
|
* Gets the metadata byte value of the items dropped when salvaging this item
|
||||||
*
|
*
|
||||||
* @return the byte metadata of the repair material
|
* @return the byte metadata of the salvage drop
|
||||||
*/
|
*/
|
||||||
public byte getSalvageMaterialMetadata();
|
public byte getSalvageMaterialMetadata();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the RepairItemType value for this repairable item
|
* Gets the ItemType value for this salvageable item
|
||||||
*
|
*
|
||||||
* @return the RepairItemType for this repairable
|
* @return the ItemType for this salvageable
|
||||||
*/
|
*/
|
||||||
public ItemType getSalvageItemType();
|
public ItemType getSalvageItemType();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the RepairMaterialType value for this repairable item
|
* Gets the MaterialType value for this salvageable item
|
||||||
*
|
*
|
||||||
* @return the RepairMaterialType for this repairable
|
* @return the MaterialType for this salvageable
|
||||||
*/
|
*/
|
||||||
public MaterialType getSalvageMaterialType();
|
public MaterialType getSalvageMaterialType();
|
||||||
|
|
||||||
@@ -58,25 +58,25 @@ public interface Salvageable {
|
|||||||
public short getMaximumDurability();
|
public short getMaximumDurability();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the base repair durability on which to calculate bonuses.
|
* Gets the base salvage durability on which to calculate bonuses.
|
||||||
*
|
*
|
||||||
* This is actually the maximum durability divided by the minimum quantity
|
* This is actually the maximum durability divided by the minimum quantity
|
||||||
*
|
*
|
||||||
* @return the base repair durability
|
* @return the base salvage durability
|
||||||
*/
|
*/
|
||||||
public short getBaseSalvageDurability();
|
public short getBaseSalvageDurability();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the minimum repair level needed to repair this item
|
* Gets the minimum salvage level needed to salvage this item
|
||||||
*
|
*
|
||||||
* @return the minimum level to repair this item, or 0 for no minimum
|
* @return the minimum level to salvage this item, or 0 for no minimum
|
||||||
*/
|
*/
|
||||||
public int getMinimumLevel();
|
public int getMinimumLevel();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the xpMultiplier for this repairable
|
* Gets the xpMultiplier for this salvageable
|
||||||
*
|
*
|
||||||
* @return the xpMultiplier of this repairable
|
* @return the xpMultiplier of this salvageable
|
||||||
*/
|
*/
|
||||||
public double getXpMultiplier();
|
public double getXpMultiplier();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,11 @@
|
|||||||
package com.gmail.nossr50.skills.swords;
|
package com.gmail.nossr50.skills.swords;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.LivingEntity;
|
import org.bukkit.entity.LivingEntity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.entity.EntityDamageEvent.DamageModifier;
|
||||||
|
|
||||||
import com.gmail.nossr50.config.AdvancedConfig;
|
import com.gmail.nossr50.config.AdvancedConfig;
|
||||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||||
@@ -96,8 +99,8 @@ public class SwordsManager extends SkillManager {
|
|||||||
* @param target The {@link LivingEntity} being affected by the ability
|
* @param target The {@link LivingEntity} being affected by the ability
|
||||||
* @param damage The amount of damage initially dealt by the event
|
* @param damage The amount of damage initially dealt by the event
|
||||||
*/
|
*/
|
||||||
public void serratedStrikes(LivingEntity target, double damage) {
|
public void serratedStrikes(LivingEntity target, double damage, Map<DamageModifier, Double> modifiers) {
|
||||||
CombatUtils.applyAbilityAoE(getPlayer(), target, damage / Swords.serratedStrikesModifier, skill);
|
CombatUtils.applyAbilityAoE(getPlayer(), target, damage / Swords.serratedStrikesModifier, modifiers, skill);
|
||||||
BleedTimerTask.add(target, Swords.serratedStrikesBleedTicks);
|
BleedTimerTask.add(target, Swords.serratedStrikesBleedTicks);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,14 +18,12 @@ import com.gmail.nossr50.datatypes.skills.SecondaryAbility;
|
|||||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||||
import com.gmail.nossr50.datatypes.skills.XPGainReason;
|
import com.gmail.nossr50.datatypes.skills.XPGainReason;
|
||||||
import com.gmail.nossr50.events.fake.FakeEntityTameEvent;
|
import com.gmail.nossr50.events.fake.FakeEntityTameEvent;
|
||||||
import com.gmail.nossr50.events.skills.secondaryabilities.SecondaryAbilityWeightedActivationCheckEvent;
|
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.runnables.skills.BleedTimerTask;
|
import com.gmail.nossr50.runnables.skills.BleedTimerTask;
|
||||||
import com.gmail.nossr50.skills.SkillManager;
|
import com.gmail.nossr50.skills.SkillManager;
|
||||||
import com.gmail.nossr50.util.Misc;
|
import com.gmail.nossr50.util.Misc;
|
||||||
import com.gmail.nossr50.util.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
import com.gmail.nossr50.util.StringUtils;
|
import com.gmail.nossr50.util.StringUtils;
|
||||||
import com.gmail.nossr50.util.skills.CombatUtils;
|
|
||||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||||
|
|
||||||
public class TamingManager extends SkillManager {
|
public class TamingManager extends SkillManager {
|
||||||
@@ -96,18 +94,16 @@ public class TamingManager extends SkillManager {
|
|||||||
* @param damage The damage being absorbed by the wolf
|
* @param damage The damage being absorbed by the wolf
|
||||||
*/
|
*/
|
||||||
public void fastFoodService(Wolf wolf, double damage) {
|
public void fastFoodService(Wolf wolf, double damage) {
|
||||||
double chance = Taming.fastFoodServiceActivationChance / activationChance;
|
if (!SkillUtils.activationSuccessful(SecondaryAbility.FAST_FOOD, getPlayer(), Taming.fastFoodServiceActivationChance, activationChance)) {
|
||||||
SecondaryAbilityWeightedActivationCheckEvent event = new SecondaryAbilityWeightedActivationCheckEvent(getPlayer(), SecondaryAbility.FAST_FOOD, chance);
|
return;
|
||||||
mcMMO.p.getServer().getPluginManager().callEvent(event);
|
}
|
||||||
if ((event.getChance() * activationChance) > Misc.getRandom().nextInt(activationChance)) {
|
|
||||||
|
|
||||||
double health = wolf.getHealth();
|
double health = wolf.getHealth();
|
||||||
double maxHealth = wolf.getMaxHealth();
|
double maxHealth = wolf.getMaxHealth();
|
||||||
|
|
||||||
if (health < maxHealth) {
|
if (health < maxHealth) {
|
||||||
double newHealth = health + damage;
|
double newHealth = health + damage;
|
||||||
wolf.setHealth(Math.min(newHealth, maxHealth));
|
wolf.setHealth(Math.min(newHealth, maxHealth));
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -116,9 +112,8 @@ public class TamingManager extends SkillManager {
|
|||||||
*
|
*
|
||||||
* @param target The LivingEntity to apply Gore on
|
* @param target The LivingEntity to apply Gore on
|
||||||
* @param damage The initial damage
|
* @param damage The initial damage
|
||||||
* @param wolf The wolf using the ability
|
|
||||||
*/
|
*/
|
||||||
public double gore(LivingEntity target, double damage, Wolf wolf) {
|
public double gore(LivingEntity target, double damage) {
|
||||||
if (!SkillUtils.activationSuccessful(SecondaryAbility.GORE, getPlayer(), getSkillLevel(), activationChance)) {
|
if (!SkillUtils.activationSuccessful(SecondaryAbility.GORE, getPlayer(), getSkillLevel(), activationChance)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -132,11 +127,11 @@ public class TamingManager extends SkillManager {
|
|||||||
getPlayer().sendMessage(LocaleLoader.getString("Combat.Gore"));
|
getPlayer().sendMessage(LocaleLoader.getString("Combat.Gore"));
|
||||||
|
|
||||||
damage = (damage * Taming.goreModifier) - damage;
|
damage = (damage * Taming.goreModifier) - damage;
|
||||||
return CombatUtils.callFakeDamageEvent(wolf, target, damage);
|
return damage;
|
||||||
}
|
}
|
||||||
|
|
||||||
public double sharpenedClaws(LivingEntity target, Wolf wolf) {
|
public double sharpenedClaws() {
|
||||||
return CombatUtils.callFakeDamageEvent(wolf, target, Taming.sharpenedClawsBonusDamage);
|
return Taming.sharpenedClawsBonusDamage;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -69,6 +69,9 @@ public class Unarmed {
|
|||||||
|
|
||||||
nextSlot++;
|
nextSlot++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Inventory is full - cancel the item pickup
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
else if (firstEmpty != -1) {
|
else if (firstEmpty != -1) {
|
||||||
drop.remove();
|
drop.remove();
|
||||||
|
|||||||
@@ -22,7 +22,6 @@ import com.gmail.nossr50.util.EventUtils;
|
|||||||
import com.gmail.nossr50.util.Misc;
|
import com.gmail.nossr50.util.Misc;
|
||||||
import com.gmail.nossr50.util.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
import com.gmail.nossr50.util.player.UserManager;
|
import com.gmail.nossr50.util.player.UserManager;
|
||||||
import com.gmail.nossr50.util.skills.CombatUtils;
|
|
||||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||||
|
|
||||||
public class UnarmedManager extends SkillManager {
|
public class UnarmedManager extends SkillManager {
|
||||||
@@ -57,6 +56,10 @@ public class UnarmedManager extends SkillManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean blockCrackerCheck(BlockState blockState) {
|
public boolean blockCrackerCheck(BlockState blockState) {
|
||||||
|
if (!SkillUtils.activationSuccessful(SecondaryAbility.BLOCK_CRACKER, getPlayer())) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
MaterialData data = blockState.getData();
|
MaterialData data = blockState.getData();
|
||||||
|
|
||||||
switch (blockState.getType()) {
|
switch (blockState.getType()) {
|
||||||
@@ -117,24 +120,23 @@ public class UnarmedManager extends SkillManager {
|
|||||||
/**
|
/**
|
||||||
* Handle the effects of the Berserk ability
|
* Handle the effects of the Berserk ability
|
||||||
*
|
*
|
||||||
* @param target The {@link LivingEntity} being affected by the ability
|
|
||||||
* @param damage The amount of damage initially dealt by the event
|
* @param damage The amount of damage initially dealt by the event
|
||||||
*/
|
*/
|
||||||
public double berserkDamage(LivingEntity target, double damage) {
|
public double berserkDamage(double damage) {
|
||||||
damage = (damage * Unarmed.berserkDamageModifier) - damage;
|
damage = (damage * Unarmed.berserkDamageModifier) - damage;
|
||||||
|
|
||||||
return CombatUtils.callFakeDamageEvent(getPlayer(), target, damage);
|
return damage;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handle the effects of the Iron Arm ability
|
* Handle the effects of the Iron Arm ability
|
||||||
*
|
|
||||||
* @param target The {@link LivingEntity} being affected by the ability
|
|
||||||
*/
|
*/
|
||||||
public double ironArm(LivingEntity target) {
|
public double ironArm() {
|
||||||
double unarmedBonus = Math.min(Unarmed.ironArmMinBonusDamage + (getSkillLevel() / Unarmed.ironArmIncreaseLevel), Unarmed.ironArmMaxBonusDamage);
|
if (!SkillUtils.activationSuccessful(SecondaryAbility.IRON_ARM, getPlayer())) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
return CombatUtils.callFakeDamageEvent(getPlayer(), target, unarmedBonus);
|
return Math.min(Unarmed.ironArmMinBonusDamage + (getSkillLevel() / Unarmed.ironArmIncreaseLevel), Unarmed.ironArmMaxBonusDamage);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import java.util.List;
|
|||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.TreeSpecies;
|
||||||
import org.bukkit.block.BlockFace;
|
import org.bukkit.block.BlockFace;
|
||||||
import org.bukkit.block.BlockState;
|
import org.bukkit.block.BlockState;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
@@ -55,28 +56,19 @@ public final class Woodcutting {
|
|||||||
return mcMMO.getModManager().getBlock(blockState).getXpGain();
|
return mcMMO.getModManager().getBlock(blockState).getXpGain();
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (((Tree) blockState.getData()).getSpecies()) {
|
//TODO Remove this workaround when casting to Tree works again
|
||||||
case GENERIC:
|
TreeSpecies species = TreeSpecies.GENERIC;
|
||||||
return ExperienceConfig.getInstance().getWoodcuttingXPOak();
|
if (blockState.getData() instanceof Tree) {
|
||||||
|
species = ((Tree) blockState.getData()).getSpecies();
|
||||||
case REDWOOD:
|
|
||||||
return ExperienceConfig.getInstance().getWoodcuttingXPSpruce();
|
|
||||||
|
|
||||||
case BIRCH:
|
|
||||||
return ExperienceConfig.getInstance().getWoodcuttingXPBirch();
|
|
||||||
|
|
||||||
case JUNGLE:
|
|
||||||
int xp = ExperienceConfig.getInstance().getWoodcuttingXPJungle();
|
|
||||||
|
|
||||||
if (experienceGainMethod == ExperienceGainMethod.TREE_FELLER) {
|
|
||||||
xp *= 0.5;
|
|
||||||
}
|
|
||||||
|
|
||||||
return xp;
|
|
||||||
|
|
||||||
default:
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int xp = ExperienceConfig.getInstance().getWoodcuttingTreeXP(species);
|
||||||
|
|
||||||
|
if (species == TreeSpecies.JUNGLE && experienceGainMethod == ExperienceGainMethod.TREE_FELLER) {
|
||||||
|
xp *= 0.5;
|
||||||
|
}
|
||||||
|
|
||||||
|
return xp;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -89,33 +81,14 @@ public final class Woodcutting {
|
|||||||
Misc.dropItems(blockState.getLocation(), blockState.getBlock().getDrops());
|
Misc.dropItems(blockState.getLocation(), blockState.getBlock().getDrops());
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
switch (((Tree) blockState.getData()).getSpecies()) {
|
//TODO Remove this workaround when casting to Tree works again
|
||||||
case GENERIC:
|
TreeSpecies species = TreeSpecies.GENERIC;
|
||||||
if (Config.getInstance().getOakDoubleDropsEnabled()) {
|
if (blockState.getData() instanceof Tree) {
|
||||||
Misc.dropItems(blockState.getLocation(), blockState.getBlock().getDrops());
|
species = ((Tree) blockState.getData()).getSpecies();
|
||||||
}
|
}
|
||||||
return;
|
|
||||||
|
|
||||||
case REDWOOD:
|
if (Config.getInstance().getWoodcuttingDoubleDropsEnabled(species)) {
|
||||||
if (Config.getInstance().getSpruceDoubleDropsEnabled()) {
|
Misc.dropItems(blockState.getLocation(), blockState.getBlock().getDrops());
|
||||||
Misc.dropItems(blockState.getLocation(), blockState.getBlock().getDrops());
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
|
|
||||||
case BIRCH:
|
|
||||||
if (Config.getInstance().getBirchDoubleDropsEnabled()) {
|
|
||||||
Misc.dropItems(blockState.getLocation(), blockState.getBlock().getDrops());
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
|
|
||||||
case JUNGLE:
|
|
||||||
if (Config.getInstance().getJungleDoubleDropsEnabled()) {
|
|
||||||
Misc.dropItems(blockState.getLocation(), blockState.getBlock().getDrops());
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
|
|
||||||
default:
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -141,11 +141,15 @@ public class WoodcuttingManager extends SkillManager {
|
|||||||
Misc.dropItems(blockState.getLocation(), block.getDrops());
|
Misc.dropItems(blockState.getLocation(), block.getDrops());
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Tree tree = (Tree) blockState.getData();
|
//TODO Remove this workaround when casting to Tree works again
|
||||||
tree.setDirection(BlockFace.UP);
|
if (blockState.getData() instanceof Tree) {
|
||||||
|
Tree tree = (Tree) blockState.getData();
|
||||||
|
tree.setDirection(BlockFace.UP);
|
||||||
|
}
|
||||||
|
|
||||||
switch (material) {
|
switch (material) {
|
||||||
case LOG:
|
case LOG:
|
||||||
|
case LOG_2:
|
||||||
if (canGetDoubleDrops()) {
|
if (canGetDoubleDrops()) {
|
||||||
Woodcutting.checkForDoubleDrop(blockState);
|
Woodcutting.checkForDoubleDrop(blockState);
|
||||||
}
|
}
|
||||||
@@ -154,6 +158,7 @@ public class WoodcuttingManager extends SkillManager {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case LEAVES:
|
case LEAVES:
|
||||||
|
case LEAVES_2:
|
||||||
Misc.dropItems(blockState.getLocation(), block.getDrops());
|
Misc.dropItems(blockState.getLocation(), block.getDrops());
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -168,5 +173,4 @@ public class WoodcuttingManager extends SkillManager {
|
|||||||
|
|
||||||
applyXpGain(xp, XPGainReason.PVE);
|
applyXpGain(xp, XPGainReason.PVE);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -113,7 +113,9 @@ public final class BlockUtils {
|
|||||||
switch (blockState.getType()) {
|
switch (blockState.getType()) {
|
||||||
case BROWN_MUSHROOM:
|
case BROWN_MUSHROOM:
|
||||||
case CACTUS:
|
case CACTUS:
|
||||||
|
case DOUBLE_PLANT:
|
||||||
case MELON_BLOCK:
|
case MELON_BLOCK:
|
||||||
|
case LONG_GRASS:
|
||||||
case PUMPKIN:
|
case PUMPKIN:
|
||||||
case RED_MUSHROOM:
|
case RED_MUSHROOM:
|
||||||
case RED_ROSE:
|
case RED_ROSE:
|
||||||
@@ -151,10 +153,13 @@ public final class BlockUtils {
|
|||||||
switch (blockState.getType()) {
|
switch (blockState.getType()) {
|
||||||
case ENDER_STONE:
|
case ENDER_STONE:
|
||||||
case GLOWSTONE:
|
case GLOWSTONE:
|
||||||
|
case HARD_CLAY:
|
||||||
case MOSSY_COBBLESTONE:
|
case MOSSY_COBBLESTONE:
|
||||||
case NETHERRACK:
|
case NETHERRACK:
|
||||||
case OBSIDIAN:
|
case OBSIDIAN:
|
||||||
|
case PACKED_ICE:
|
||||||
case SANDSTONE:
|
case SANDSTONE:
|
||||||
|
case STAINED_CLAY:
|
||||||
case STONE:
|
case STONE:
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
@@ -196,6 +201,7 @@ public final class BlockUtils {
|
|||||||
public static boolean isLog(BlockState blockState) {
|
public static boolean isLog(BlockState blockState) {
|
||||||
switch (blockState.getType()) {
|
switch (blockState.getType()) {
|
||||||
case LOG:
|
case LOG:
|
||||||
|
case LOG_2:
|
||||||
case HUGE_MUSHROOM_1:
|
case HUGE_MUSHROOM_1:
|
||||||
case HUGE_MUSHROOM_2:
|
case HUGE_MUSHROOM_2:
|
||||||
return true;
|
return true;
|
||||||
@@ -214,6 +220,7 @@ public final class BlockUtils {
|
|||||||
public static boolean isLeaves(BlockState blockState) {
|
public static boolean isLeaves(BlockState blockState) {
|
||||||
switch (blockState.getType()) {
|
switch (blockState.getType()) {
|
||||||
case LEAVES:
|
case LEAVES:
|
||||||
|
case LEAVES_2:
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@@ -276,7 +283,7 @@ public final class BlockUtils {
|
|||||||
* Determine if a given block can be made into Mycelium
|
* Determine if a given block can be made into Mycelium
|
||||||
*
|
*
|
||||||
* @param blockState The {@link BlockState} of the block to check
|
* @param blockState The {@link BlockState} of the block to check
|
||||||
* @return true if the block can be made in Mycelium, false otherwise
|
* @return true if the block can be made into Mycelium, false otherwise
|
||||||
*/
|
*/
|
||||||
public static boolean canMakeShroomy(BlockState blockState) {
|
public static boolean canMakeShroomy(BlockState blockState) {
|
||||||
switch (blockState.getType()) {
|
switch (blockState.getType()) {
|
||||||
@@ -301,6 +308,12 @@ public final class BlockUtils {
|
|||||||
return type == Repair.anvilMaterial || type == Salvage.anvilMaterial;
|
return type == Repair.anvilMaterial || type == Salvage.anvilMaterial;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean isPistonPiece(BlockState blockState) {
|
||||||
|
Material type = blockState.getType();
|
||||||
|
|
||||||
|
return type == Material.PISTON_MOVING_PIECE || type == Material.AIR;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a HashSet containing every transparent block
|
* Get a HashSet containing every transparent block
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import org.bukkit.entity.Fish;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.player.PlayerFishEvent;
|
import org.bukkit.event.player.PlayerFishEvent;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.metadata.FixedMetadataValue;
|
||||||
import org.bukkit.plugin.PluginManager;
|
import org.bukkit.plugin.PluginManager;
|
||||||
|
|
||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
@@ -15,6 +16,7 @@ import com.gmail.nossr50.datatypes.party.Party;
|
|||||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||||
import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
||||||
import com.gmail.nossr50.datatypes.skills.AbilityType;
|
import com.gmail.nossr50.datatypes.skills.AbilityType;
|
||||||
|
import com.gmail.nossr50.datatypes.skills.SecondaryAbility;
|
||||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||||
import com.gmail.nossr50.datatypes.skills.XPGainReason;
|
import com.gmail.nossr50.datatypes.skills.XPGainReason;
|
||||||
import com.gmail.nossr50.events.experience.McMMOPlayerLevelChangeEvent;
|
import com.gmail.nossr50.events.experience.McMMOPlayerLevelChangeEvent;
|
||||||
@@ -34,6 +36,7 @@ import com.gmail.nossr50.events.skills.abilities.McMMOPlayerAbilityDeactivateEve
|
|||||||
import com.gmail.nossr50.events.skills.fishing.McMMOPlayerFishingTreasureEvent;
|
import com.gmail.nossr50.events.skills.fishing.McMMOPlayerFishingTreasureEvent;
|
||||||
import com.gmail.nossr50.events.skills.fishing.McMMOPlayerMagicHunterEvent;
|
import com.gmail.nossr50.events.skills.fishing.McMMOPlayerMagicHunterEvent;
|
||||||
import com.gmail.nossr50.events.skills.repair.McMMOPlayerRepairCheckEvent;
|
import com.gmail.nossr50.events.skills.repair.McMMOPlayerRepairCheckEvent;
|
||||||
|
import com.gmail.nossr50.events.skills.secondaryabilities.SecondaryAbilityEvent;
|
||||||
import com.gmail.nossr50.events.skills.unarmed.McMMOPlayerDisarmEvent;
|
import com.gmail.nossr50.events.skills.unarmed.McMMOPlayerDisarmEvent;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.util.player.UserManager;
|
import com.gmail.nossr50.util.player.UserManager;
|
||||||
@@ -46,6 +49,13 @@ public class EventUtils {
|
|||||||
return event;
|
return event;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static SecondaryAbilityEvent callSecondaryAbilityEvent(Player player, SecondaryAbility secondaryAbility) {
|
||||||
|
SecondaryAbilityEvent event = new SecondaryAbilityEvent(player, secondaryAbility);
|
||||||
|
mcMMO.p.getServer().getPluginManager().callEvent(event);
|
||||||
|
|
||||||
|
return event;
|
||||||
|
}
|
||||||
|
|
||||||
public static FakePlayerAnimationEvent callFakeArmSwingEvent(Player player) {
|
public static FakePlayerAnimationEvent callFakeArmSwingEvent(Player player) {
|
||||||
FakePlayerAnimationEvent event = new FakePlayerAnimationEvent(player);
|
FakePlayerAnimationEvent event = new FakePlayerAnimationEvent(player);
|
||||||
mcMMO.p.getServer().getPluginManager().callEvent(event);
|
mcMMO.p.getServer().getPluginManager().callEvent(event);
|
||||||
@@ -194,4 +204,26 @@ public class EventUtils {
|
|||||||
|
|
||||||
return event;
|
return event;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* There is a bug in CraftBukkit that causes piston events to
|
||||||
|
* fire multiple times. Check this method to see if the piston event
|
||||||
|
* should be processed.
|
||||||
|
*
|
||||||
|
* @param block Block object of the piston block
|
||||||
|
* @param isExtendEvent should be true when called from BlockPistonExtendEvent
|
||||||
|
*
|
||||||
|
* @return true if the PistonEvent should be processed, false otherwise
|
||||||
|
*/
|
||||||
|
public static boolean shouldProcessEvent(Block block, boolean isExtendEvent) {
|
||||||
|
String pistonAction = isExtendEvent ? "EXTEND" : "RETRACT";
|
||||||
|
String lastAction = block.hasMetadata(mcMMO.pistonDataKey) ? block.getMetadata(mcMMO.pistonDataKey).get(0).asString() : "";
|
||||||
|
|
||||||
|
if (!lastAction.equals(pistonAction)) {
|
||||||
|
block.setMetadata(mcMMO.pistonDataKey, new FixedMetadataValue(mcMMO.p, pistonAction));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,8 +10,10 @@ import java.util.ArrayList;
|
|||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
import java.util.EnumSet;
|
||||||
import java.util.GregorianCalendar;
|
import java.util.GregorianCalendar;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
@@ -20,11 +22,13 @@ import org.bukkit.DyeColor;
|
|||||||
import org.bukkit.FireworkEffect;
|
import org.bukkit.FireworkEffect;
|
||||||
import org.bukkit.FireworkEffect.Type;
|
import org.bukkit.FireworkEffect.Type;
|
||||||
import org.bukkit.Sound;
|
import org.bukkit.Sound;
|
||||||
|
import org.bukkit.Statistic;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.command.PluginCommand;
|
import org.bukkit.command.PluginCommand;
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
import org.bukkit.entity.Firework;
|
import org.bukkit.entity.Firework;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.player.PlayerStatisticIncrementEvent;
|
||||||
import org.bukkit.inventory.meta.FireworkMeta;
|
import org.bukkit.inventory.meta.FireworkMeta;
|
||||||
|
|
||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
@@ -67,8 +71,45 @@ public final class HolidayManager {
|
|||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static FakeSkillType getByStatistic(Statistic statistic) {
|
||||||
|
switch (statistic) {
|
||||||
|
case DAMAGE_TAKEN:
|
||||||
|
return FakeSkillType.MACHO;
|
||||||
|
case JUMP:
|
||||||
|
return FakeSkillType.JUMPING;
|
||||||
|
case DROP:
|
||||||
|
return FakeSkillType.THROWING;
|
||||||
|
case MINE_BLOCK:
|
||||||
|
case BREAK_ITEM:
|
||||||
|
return FakeSkillType.WRECKING;
|
||||||
|
case CRAFT_ITEM:
|
||||||
|
return FakeSkillType.CRAFTING;
|
||||||
|
case WALK_ONE_CM:
|
||||||
|
return FakeSkillType.WALKING;
|
||||||
|
case SWIM_ONE_CM:
|
||||||
|
return FakeSkillType.SWIMMING;
|
||||||
|
case FALL_ONE_CM:
|
||||||
|
return FakeSkillType.FALLING;
|
||||||
|
case CLIMB_ONE_CM:
|
||||||
|
return FakeSkillType.CLIMBING;
|
||||||
|
case FLY_ONE_CM:
|
||||||
|
return FakeSkillType.FLYING;
|
||||||
|
case DIVE_ONE_CM:
|
||||||
|
return FakeSkillType.DIVING;
|
||||||
|
case PIG_ONE_CM:
|
||||||
|
return FakeSkillType.PIGGY;
|
||||||
|
default:
|
||||||
|
return FakeSkillType.UNKNOWN;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public final Set<Statistic> movementStatistics = EnumSet.of(
|
||||||
|
Statistic.WALK_ONE_CM, Statistic.SWIM_ONE_CM, Statistic.FALL_ONE_CM,
|
||||||
|
Statistic.CLIMB_ONE_CM, Statistic.FLY_ONE_CM, Statistic.DIVE_ONE_CM,
|
||||||
|
Statistic.PIG_ONE_CM);
|
||||||
|
|
||||||
static {
|
static {
|
||||||
List<Color> colors = new ArrayList<Color>();
|
List<Color> colors = new ArrayList<Color>();
|
||||||
List<ChatColor> chatColors = new ArrayList<ChatColor>();
|
List<ChatColor> chatColors = new ArrayList<ChatColor>();
|
||||||
@@ -301,8 +342,40 @@ public final class HolidayManager {
|
|||||||
return mcMMO.getHolidayManager().getDateRange(day.getTime(), start.getTime(), end.getTime());
|
return mcMMO.getHolidayManager().getDateRange(day.getTime(), start.getTime(), end.getTime());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void handleStatisticEvent(PlayerStatisticIncrementEvent event) {
|
||||||
|
Player player = event.getPlayer();
|
||||||
|
Statistic statistic = event.getStatistic();
|
||||||
|
int newValue = event.getNewValue();
|
||||||
|
|
||||||
|
int modifier;
|
||||||
|
switch (statistic) {
|
||||||
|
case DAMAGE_TAKEN:
|
||||||
|
modifier = 500;
|
||||||
|
break;
|
||||||
|
case JUMP:
|
||||||
|
modifier = 500;
|
||||||
|
break;
|
||||||
|
case DROP:
|
||||||
|
modifier = 200;
|
||||||
|
break;
|
||||||
|
case MINE_BLOCK:
|
||||||
|
case BREAK_ITEM:
|
||||||
|
modifier = 500;
|
||||||
|
break;
|
||||||
|
case CRAFT_ITEM:
|
||||||
|
modifier = 100;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (newValue % modifier == 0) {
|
||||||
|
mcMMO.getHolidayManager().levelUpApril(player, FakeSkillType.getByStatistic(statistic));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void levelUpApril(Player player, FakeSkillType fakeSkillType) {
|
public void levelUpApril(Player player, FakeSkillType fakeSkillType) {
|
||||||
int levelTotal = Misc.getRandom().nextInt(UserManager.getPlayer(player).getSkillLevel(SkillType.MINING)) + 1;
|
int levelTotal = Misc.getRandom().nextInt(1 + UserManager.getPlayer(player).getSkillLevel(SkillType.MINING)) + 1;
|
||||||
player.playSound(player.getLocation(), Sound.LEVEL_UP, Misc.LEVELUP_VOLUME, Misc.LEVELUP_PITCH);
|
player.playSound(player.getLocation(), Sound.LEVEL_UP, Misc.LEVELUP_VOLUME, Misc.LEVELUP_PITCH);
|
||||||
player.sendMessage(ChatColor.YELLOW + StringUtils.getCapitalized(fakeSkillType.toString()) + " skill increased by 1. Total (" + levelTotal + ")");
|
player.sendMessage(ChatColor.YELLOW + StringUtils.getCapitalized(fakeSkillType.toString()) + " skill increased by 1. Total (" + levelTotal + ")");
|
||||||
ParticleEffectUtils.fireworkParticleShower(player, ALL_COLORS.get(Misc.getRandom().nextInt(ALL_COLORS.size())));
|
ParticleEffectUtils.fireworkParticleShower(player, ALL_COLORS.get(Misc.getRandom().nextInt(ALL_COLORS.size())));
|
||||||
|
|||||||
@@ -1,12 +1,14 @@
|
|||||||
package com.gmail.nossr50.util;
|
package com.gmail.nossr50.util;
|
||||||
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.CoalType;
|
||||||
import org.bukkit.DyeColor;
|
import org.bukkit.DyeColor;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.inventory.FurnaceRecipe;
|
import org.bukkit.inventory.FurnaceRecipe;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.inventory.Recipe;
|
import org.bukkit.inventory.Recipe;
|
||||||
import org.bukkit.inventory.meta.ItemMeta;
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
|
import org.bukkit.material.Coal;
|
||||||
import org.bukkit.material.Dye;
|
import org.bukkit.material.Dye;
|
||||||
|
|
||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
@@ -586,6 +588,8 @@ public final class ItemUtils {
|
|||||||
case PUMPKIN_SEEDS:
|
case PUMPKIN_SEEDS:
|
||||||
case WATER_LILY:
|
case WATER_LILY:
|
||||||
case VINE:
|
case VINE:
|
||||||
|
case LONG_GRASS:
|
||||||
|
case DOUBLE_PLANT:
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
case INK_SACK:
|
case INK_SACK:
|
||||||
@@ -614,7 +618,6 @@ public final class ItemUtils {
|
|||||||
case PORK:
|
case PORK:
|
||||||
case GRILLED_PORK:
|
case GRILLED_PORK:
|
||||||
case WOOL:
|
case WOOL:
|
||||||
case RED_ROSE: // Not sure we should include this, as it will also trigger from herbalism
|
|
||||||
case IRON_INGOT:
|
case IRON_INGOT:
|
||||||
case SNOW_BALL:
|
case SNOW_BALL:
|
||||||
case BLAZE_ROD:
|
case BLAZE_ROD:
|
||||||
@@ -627,12 +630,17 @@ public final class ItemUtils {
|
|||||||
case ARROW:
|
case ARROW:
|
||||||
case SLIME_BALL:
|
case SLIME_BALL:
|
||||||
case NETHER_STAR:
|
case NETHER_STAR:
|
||||||
case COAL: // Not sure we should include this, as it will also trigger when mining
|
|
||||||
case ROTTEN_FLESH:
|
case ROTTEN_FLESH:
|
||||||
case GOLD_NUGGET:
|
case GOLD_NUGGET:
|
||||||
case EGG:
|
case EGG:
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
case COAL: // Not sure we should include this, as it will also trigger when mining
|
||||||
|
return (((Coal) item.getData()).getType() == CoalType.COAL);
|
||||||
|
|
||||||
|
case RED_ROSE: // Not sure we should include this, as it will also trigger from herbalism
|
||||||
|
return (item.getData().getData() == 0x0);
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -647,7 +655,9 @@ public final class ItemUtils {
|
|||||||
public static boolean isWoodcuttingDrop(ItemStack item) {
|
public static boolean isWoodcuttingDrop(ItemStack item) {
|
||||||
switch (item.getType()) {
|
switch (item.getType()) {
|
||||||
case LOG:
|
case LOG:
|
||||||
|
case LOG_2:
|
||||||
case LEAVES:
|
case LEAVES:
|
||||||
|
case LEAVES_2:
|
||||||
case SAPLING:
|
case SAPLING:
|
||||||
case APPLE:
|
case APPLE:
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import org.bukkit.inventory.ItemStack;
|
|||||||
|
|
||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.gmail.nossr50.events.items.McMMOItemSpawnEvent;
|
import com.gmail.nossr50.events.items.McMMOItemSpawnEvent;
|
||||||
|
import com.gmail.nossr50.runnables.player.PlayerProfileLoadingTask;
|
||||||
import com.gmail.nossr50.util.player.UserManager;
|
import com.gmail.nossr50.util.player.UserManager;
|
||||||
|
|
||||||
public final class Misc {
|
public final class Misc {
|
||||||
@@ -112,7 +113,7 @@ public final class Misc {
|
|||||||
|
|
||||||
if (player != null) {
|
if (player != null) {
|
||||||
UserManager.remove(player);
|
UserManager.remove(player);
|
||||||
UserManager.addUser(player);
|
new PlayerProfileLoadingTask(player).runTaskTimerAsynchronously(mcMMO.p, 1, 20); // 1 Tick delay to ensure the player is marked as online before we begin loading
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.gmail.nossr50.util;
|
package com.gmail.nossr50.util;
|
||||||
|
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.TreeSpecies;
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
|
|
||||||
import com.gmail.nossr50.datatypes.party.PartyFeature;
|
import com.gmail.nossr50.datatypes.party.PartyFeature;
|
||||||
@@ -30,6 +31,10 @@ public class StringUtils {
|
|||||||
return createPrettyEnumString(ability.toString());
|
return createPrettyEnumString(ability.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String getPrettyTreeSpeciesString(TreeSpecies species) {
|
||||||
|
return createPrettyEnumString(species.toString());
|
||||||
|
}
|
||||||
|
|
||||||
public static String getPrettySecondaryAbilityString(SecondaryAbility secondaryAbility) {
|
public static String getPrettySecondaryAbilityString(SecondaryAbility secondaryAbility) {
|
||||||
switch (secondaryAbility) {
|
switch (secondaryAbility) {
|
||||||
case HERBALISM_DOUBLE_DROPS:
|
case HERBALISM_DOUBLE_DROPS:
|
||||||
|
|||||||
@@ -11,21 +11,19 @@ import org.bukkit.metadata.FixedMetadataValue;
|
|||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableList;
|
||||||
|
|
||||||
public final class UserManager {
|
public final class UserManager {
|
||||||
|
|
||||||
private UserManager() {}
|
private UserManager() {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a new user.
|
* Track a new user.
|
||||||
*
|
*
|
||||||
* @param player The player to create a user record for
|
* @param mcMMOPlayer the player profile to start tracking
|
||||||
* @return the player's {@link McMMOPlayer} object
|
|
||||||
*/
|
*/
|
||||||
public static McMMOPlayer addUser(Player player) {
|
public static void track(McMMOPlayer mcMMOPlayer) {
|
||||||
McMMOPlayer mcMMOPlayer = new McMMOPlayer(player);
|
mcMMOPlayer.getPlayer().setMetadata(mcMMO.playerDataKey, new FixedMetadataValue(mcMMO.p, mcMMOPlayer));
|
||||||
player.setMetadata(mcMMO.playerDataKey, new FixedMetadataValue(mcMMO.p, mcMMOPlayer));
|
|
||||||
|
|
||||||
return mcMMOPlayer;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -50,8 +48,8 @@ public final class UserManager {
|
|||||||
* Save all users ON THIS THREAD.
|
* Save all users ON THIS THREAD.
|
||||||
*/
|
*/
|
||||||
public static void saveAll() {
|
public static void saveAll() {
|
||||||
Player[] onlinePlayers = mcMMO.p.getServer().getOnlinePlayers();
|
ImmutableList<Player> onlinePlayers = ImmutableList.copyOf(mcMMO.p.getServer().getOnlinePlayers());
|
||||||
mcMMO.p.debug("Saving mcMMOPlayers... (" + onlinePlayers.length + ")");
|
mcMMO.p.debug("Saving mcMMOPlayers... (" + onlinePlayers.size() + ")");
|
||||||
|
|
||||||
for (Player player : onlinePlayers) {
|
for (Player player : onlinePlayers) {
|
||||||
getPlayer(player).getProfile().save();
|
getPlayer(player).getProfile().save();
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.OfflinePlayer;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.scoreboard.DisplaySlot;
|
import org.bukkit.scoreboard.DisplaySlot;
|
||||||
import org.bukkit.scoreboard.Objective;
|
import org.bukkit.scoreboard.Objective;
|
||||||
@@ -23,6 +22,7 @@ import com.gmail.nossr50.locale.LocaleLoader;
|
|||||||
import com.gmail.nossr50.util.Misc;
|
import com.gmail.nossr50.util.Misc;
|
||||||
import com.gmail.nossr50.util.player.UserManager;
|
import com.gmail.nossr50.util.player.UserManager;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableList;
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
|
|
||||||
@@ -40,21 +40,21 @@ public class ScoreboardManager {
|
|||||||
|
|
||||||
static final String POWER_LEVEL = LocaleLoader.getString("Scoreboard.Misc.PowerLevel");
|
static final String POWER_LEVEL = LocaleLoader.getString("Scoreboard.Misc.PowerLevel");
|
||||||
|
|
||||||
static final OfflinePlayer LABEL_POWER_LEVEL = getOfflinePlayer(POWER_LEVEL);
|
static final String LABEL_POWER_LEVEL = POWER_LEVEL;
|
||||||
static final OfflinePlayer LABEL_LEVEL = getOfflinePlayer(LocaleLoader.getString("Scoreboard.Misc.Level"));
|
static final String LABEL_LEVEL = LocaleLoader.getString("Scoreboard.Misc.Level");
|
||||||
static final OfflinePlayer LABEL_CURRENT_XP = getOfflinePlayer(LocaleLoader.getString("Scoreboard.Misc.CurrentXP"));
|
static final String LABEL_CURRENT_XP = LocaleLoader.getString("Scoreboard.Misc.CurrentXP");
|
||||||
static final OfflinePlayer LABEL_REMAINING_XP = getOfflinePlayer(LocaleLoader.getString("Scoreboard.Misc.RemainingXP"));
|
static final String LABEL_REMAINING_XP = LocaleLoader.getString("Scoreboard.Misc.RemainingXP");
|
||||||
static final OfflinePlayer LABEL_ABILITY_COOLDOWN = getOfflinePlayer(LocaleLoader.getString("Scoreboard.Misc.Cooldown"));
|
static final String LABEL_ABILITY_COOLDOWN = LocaleLoader.getString("Scoreboard.Misc.Cooldown");
|
||||||
static final OfflinePlayer LABEL_OVERALL = getOfflinePlayer(LocaleLoader.getString("Scoreboard.Misc.Overall"));
|
static final String LABEL_OVERALL = LocaleLoader.getString("Scoreboard.Misc.Overall");
|
||||||
|
|
||||||
static final Map<SkillType, OfflinePlayer> skillLabels;
|
static final Map<SkillType, String> skillLabels;
|
||||||
static final Map<AbilityType, OfflinePlayer> abilityLabelsColored;
|
static final Map<AbilityType, String> abilityLabelsColored;
|
||||||
static final Map<AbilityType, OfflinePlayer> abilityLabelsSkill;
|
static final Map<AbilityType, String> abilityLabelsSkill;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
ImmutableMap.Builder<SkillType, OfflinePlayer> skillLabelBuilder = ImmutableMap.builder();
|
ImmutableMap.Builder<SkillType, String> skillLabelBuilder = ImmutableMap.builder();
|
||||||
ImmutableMap.Builder<AbilityType, OfflinePlayer> abilityLabelBuilder = ImmutableMap.builder();
|
ImmutableMap.Builder<AbilityType, String> abilityLabelBuilder = ImmutableMap.builder();
|
||||||
ImmutableMap.Builder<AbilityType, OfflinePlayer> abilityLabelSkillBuilder = ImmutableMap.builder();
|
ImmutableMap.Builder<AbilityType, String> abilityLabelSkillBuilder = ImmutableMap.builder();
|
||||||
|
|
||||||
if (Config.getInstance().getScoreboardRainbows()) {
|
if (Config.getInstance().getScoreboardRainbows()) {
|
||||||
// Everything but black, gray, gold
|
// Everything but black, gray, gold
|
||||||
@@ -78,36 +78,38 @@ public class ScoreboardManager {
|
|||||||
int i = 0;
|
int i = 0;
|
||||||
for (SkillType type : SkillType.values()) {
|
for (SkillType type : SkillType.values()) {
|
||||||
// Include child skills
|
// Include child skills
|
||||||
skillLabelBuilder.put(type, getOfflinePlayer(colors.get(i) + type.getName()));
|
skillLabelBuilder.put(type, getShortenedName(colors.get(i) + type.getName(), false));
|
||||||
|
|
||||||
if (type.getAbility() != null) {
|
if (type.getAbility() != null) {
|
||||||
abilityLabelBuilder.put(type.getAbility(), getOfflinePlayer(colors.get(i) + type.getAbility().getName()));
|
abilityLabelBuilder.put(type.getAbility(), getShortenedName(colors.get(i) + type.getAbility().getName()));
|
||||||
|
|
||||||
if (type == SkillType.MINING) {
|
if (type == SkillType.MINING) {
|
||||||
abilityLabelBuilder.put(AbilityType.BLAST_MINING, getOfflinePlayer(colors.get(i) + AbilityType.BLAST_MINING.getName()));
|
abilityLabelBuilder.put(AbilityType.BLAST_MINING, getShortenedName(colors.get(i) + AbilityType.BLAST_MINING.getName()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (++i == colors.size()) i = 0;
|
if (++i == colors.size()) {
|
||||||
|
i = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
for (SkillType type : SkillType.values()) {
|
for (SkillType type : SkillType.values()) {
|
||||||
// Include child skills
|
// Include child skills
|
||||||
skillLabelBuilder.put(type, getOfflinePlayer(ChatColor.GREEN + type.getName()));
|
skillLabelBuilder.put(type, getShortenedName(ChatColor.GREEN + type.getName()));
|
||||||
|
|
||||||
if (type.getAbility() != null) {
|
if (type.getAbility() != null) {
|
||||||
abilityLabelBuilder.put(type.getAbility(), getOfflinePlayerDots(ChatColor.AQUA + type.getAbility().getName()));
|
abilityLabelBuilder.put(type.getAbility(), getShortenedName(ChatColor.AQUA + type.getAbility().getName()));
|
||||||
|
|
||||||
if (type == SkillType.MINING) {
|
if (type == SkillType.MINING) {
|
||||||
abilityLabelBuilder.put(AbilityType.BLAST_MINING, getOfflinePlayerDots(ChatColor.AQUA + AbilityType.BLAST_MINING.getName()));
|
abilityLabelBuilder.put(AbilityType.BLAST_MINING, getShortenedName(ChatColor.AQUA + AbilityType.BLAST_MINING.getName()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (AbilityType type : AbilityType.values()) {
|
for (AbilityType type : AbilityType.values()) {
|
||||||
abilityLabelSkillBuilder.put(type, getOfflinePlayerDots((type == AbilityType.BLAST_MINING ? ChatColor.BLUE : ChatColor.AQUA) + type.getName()));
|
abilityLabelSkillBuilder.put(type, getShortenedName((type == AbilityType.BLAST_MINING ? ChatColor.BLUE : ChatColor.AQUA) + type.getName()));
|
||||||
}
|
}
|
||||||
|
|
||||||
skillLabels = skillLabelBuilder.build();
|
skillLabels = skillLabelBuilder.build();
|
||||||
@@ -117,22 +119,6 @@ public class ScoreboardManager {
|
|||||||
|
|
||||||
private static List<String> dirtyPowerLevels = new ArrayList<String>();
|
private static List<String> dirtyPowerLevels = new ArrayList<String>();
|
||||||
|
|
||||||
private static OfflinePlayer getOfflinePlayer(String name) {
|
|
||||||
return getOfflinePlayer(name, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static OfflinePlayer getOfflinePlayerDots(String name) {
|
|
||||||
return getOfflinePlayer(name, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static OfflinePlayer getOfflinePlayer(String name, boolean useDots) {
|
|
||||||
if (name.length() > 16) {
|
|
||||||
name = useDots ? name.substring(0, 14) + ".." : name.substring(0, 16);
|
|
||||||
}
|
|
||||||
|
|
||||||
return mcMMO.p.getServer().getOfflinePlayer(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
public enum SidebarType {
|
public enum SidebarType {
|
||||||
NONE,
|
NONE,
|
||||||
SKILL_BOARD,
|
SKILL_BOARD,
|
||||||
@@ -142,6 +128,18 @@ public class ScoreboardManager {
|
|||||||
TOP_BOARD;
|
TOP_BOARD;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static String getShortenedName(String name) {
|
||||||
|
return getShortenedName(name, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String getShortenedName(String name, boolean useDots) {
|
||||||
|
if (name.length() > 16) {
|
||||||
|
name = useDots ? name.substring(0, 14) + ".." : name.substring(0, 16);
|
||||||
|
}
|
||||||
|
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
// **** Listener call-ins **** //
|
// **** Listener call-ins **** //
|
||||||
|
|
||||||
// Called by PlayerJoinEvent listener
|
// Called by PlayerJoinEvent listener
|
||||||
@@ -161,8 +159,8 @@ public class ScoreboardManager {
|
|||||||
|
|
||||||
// Called in onDisable()
|
// Called in onDisable()
|
||||||
public static void teardownAll() {
|
public static void teardownAll() {
|
||||||
Player[] onlinePlayers = mcMMO.p.getServer().getOnlinePlayers();
|
ImmutableList<Player> onlinePlayers = ImmutableList.copyOf(mcMMO.p.getServer().getOnlinePlayers());
|
||||||
mcMMO.p.debug("Tearing down scoreboards... (" + onlinePlayers.length + ")");
|
mcMMO.p.debug("Tearing down scoreboards... (" + onlinePlayers.size() + ")");
|
||||||
for (Player player : onlinePlayers) {
|
for (Player player : onlinePlayers) {
|
||||||
teardownPlayer(player);
|
teardownPlayer(player);
|
||||||
}
|
}
|
||||||
@@ -338,7 +336,7 @@ public class ScoreboardManager {
|
|||||||
Player player = mcMMOPlayer.getPlayer();
|
Player player = mcMMOPlayer.getPlayer();
|
||||||
int power = mcMMOPlayer.getPowerLevel();
|
int power = mcMMOPlayer.getPowerLevel();
|
||||||
|
|
||||||
mainObjective.getScore(player).setScore(power);
|
mainObjective.getScore(playerName).setScore(power);
|
||||||
|
|
||||||
for (ScoreboardWrapper wrapper : PLAYER_SCOREBOARDS.values()) {
|
for (ScoreboardWrapper wrapper : PLAYER_SCOREBOARDS.values()) {
|
||||||
wrapper.updatePowerLevel(player, power);
|
wrapper.updatePowerLevel(player, power);
|
||||||
@@ -351,7 +349,7 @@ public class ScoreboardManager {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets or creates the power level objective on the main scoreboard.
|
* Gets or creates the power level objective on the main scoreboard.
|
||||||
* <p>
|
* <p/>
|
||||||
* If power levels are disabled, the objective is deleted and null is
|
* If power levels are disabled, the objective is deleted and null is
|
||||||
* returned.
|
* returned.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -28,7 +28,6 @@ import com.gmail.nossr50.util.scoreboards.ScoreboardManager.SidebarType;
|
|||||||
import org.apache.commons.lang.Validate;
|
import org.apache.commons.lang.Validate;
|
||||||
|
|
||||||
public class ScoreboardWrapper {
|
public class ScoreboardWrapper {
|
||||||
|
|
||||||
// Initialization variables
|
// Initialization variables
|
||||||
public final String playerName;
|
public final String playerName;
|
||||||
private final Scoreboard scoreboard;
|
private final Scoreboard scoreboard;
|
||||||
@@ -59,7 +58,7 @@ public class ScoreboardWrapper {
|
|||||||
powerObjective.setDisplaySlot(DisplaySlot.BELOW_NAME);
|
powerObjective.setDisplaySlot(DisplaySlot.BELOW_NAME);
|
||||||
|
|
||||||
for (McMMOPlayer mcMMOPlayer : UserManager.getPlayers()) {
|
for (McMMOPlayer mcMMOPlayer : UserManager.getPlayers()) {
|
||||||
powerObjective.getScore(mcMMOPlayer.getPlayer()).setScore(mcMMOPlayer.getPowerLevel());
|
powerObjective.getScore(mcMMOPlayer.getProfile().getPlayerName()).setScore(mcMMOPlayer.getPowerLevel());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -69,6 +68,7 @@ public class ScoreboardWrapper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public BukkitTask updateTask = null;
|
public BukkitTask updateTask = null;
|
||||||
|
|
||||||
private class ScoreboardQuickUpdate extends BukkitRunnable {
|
private class ScoreboardQuickUpdate extends BukkitRunnable {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
@@ -78,6 +78,7 @@ public class ScoreboardWrapper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public BukkitTask revertTask = null;
|
public BukkitTask revertTask = null;
|
||||||
|
|
||||||
private class ScoreboardChangeTask extends BukkitRunnable {
|
private class ScoreboardChangeTask extends BukkitRunnable {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
@@ -87,6 +88,7 @@ public class ScoreboardWrapper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public BukkitTask cooldownTask = null;
|
public BukkitTask cooldownTask = null;
|
||||||
|
|
||||||
private class ScoreboardCooldownTask extends BukkitRunnable {
|
private class ScoreboardCooldownTask extends BukkitRunnable {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
@@ -121,7 +123,8 @@ public class ScoreboardWrapper {
|
|||||||
try {
|
try {
|
||||||
cooldownTask.cancel();
|
cooldownTask.cancel();
|
||||||
}
|
}
|
||||||
catch (Throwable ignored) {}
|
catch (Throwable ignored) {
|
||||||
|
}
|
||||||
|
|
||||||
cooldownTask = null;
|
cooldownTask = null;
|
||||||
}
|
}
|
||||||
@@ -274,7 +277,7 @@ public class ScoreboardWrapper {
|
|||||||
targetProfile = null;
|
targetProfile = null;
|
||||||
leaderboardPage = -1;
|
leaderboardPage = -1;
|
||||||
|
|
||||||
loadObjective(ScoreboardManager.skillLabels.get(skill).getName());
|
loadObjective(ScoreboardManager.skillLabels.get(skill));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTypeSelfStats() {
|
public void setTypeSelfStats() {
|
||||||
@@ -355,7 +358,7 @@ public class ScoreboardWrapper {
|
|||||||
|
|
||||||
int endPosition = page * 15;
|
int endPosition = page * 15;
|
||||||
int startPosition = endPosition - 14;
|
int startPosition = endPosition - 14;
|
||||||
loadObjective(String.format("%s (%2d - %2d)", ScoreboardManager.skillLabels.get(skill).getName(), startPosition, endPosition));
|
loadObjective(String.format("%s (%2d - %2d)", ScoreboardManager.skillLabels.get(skill), startPosition, endPosition));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Setup for after a board type change
|
// Setup for after a board type change
|
||||||
@@ -381,7 +384,8 @@ public class ScoreboardWrapper {
|
|||||||
try {
|
try {
|
||||||
updateTask.cancel();
|
updateTask.cancel();
|
||||||
}
|
}
|
||||||
catch (Throwable ignored) {} // catch NullPointerException and IllegalStateException and any Error; don't care
|
catch (Throwable ignored) {
|
||||||
|
} // catch NullPointerException and IllegalStateException and any Error; don't care
|
||||||
|
|
||||||
updateTask = null;
|
updateTask = null;
|
||||||
|
|
||||||
@@ -399,123 +403,123 @@ public class ScoreboardWrapper {
|
|||||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
|
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
|
||||||
|
|
||||||
switch (sidebarType) {
|
switch (sidebarType) {
|
||||||
case NONE:
|
case NONE:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SKILL_BOARD:
|
case SKILL_BOARD:
|
||||||
Validate.notNull(targetSkill);
|
Validate.notNull(targetSkill);
|
||||||
|
|
||||||
if (!targetSkill.isChildSkill()) {
|
if (!targetSkill.isChildSkill()) {
|
||||||
int currentXP = mcMMOPlayer.getSkillXpLevel(targetSkill);
|
int currentXP = mcMMOPlayer.getSkillXpLevel(targetSkill);
|
||||||
|
|
||||||
sidebarObjective.getScore(ScoreboardManager.LABEL_CURRENT_XP).setScore(currentXP);
|
sidebarObjective.getScore(ScoreboardManager.LABEL_CURRENT_XP).setScore(currentXP);
|
||||||
sidebarObjective.getScore(ScoreboardManager.LABEL_REMAINING_XP).setScore(mcMMOPlayer.getXpToLevel(targetSkill) - currentXP);
|
sidebarObjective.getScore(ScoreboardManager.LABEL_REMAINING_XP).setScore(mcMMOPlayer.getXpToLevel(targetSkill) - currentXP);
|
||||||
}
|
|
||||||
else {
|
|
||||||
for (SkillType parentSkill : FamilyTree.getParents(targetSkill)) {
|
|
||||||
sidebarObjective.getScore(ScoreboardManager.skillLabels.get(parentSkill)).setScore(mcMMOPlayer.getSkillLevel(parentSkill));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
sidebarObjective.getScore(ScoreboardManager.LABEL_LEVEL).setScore(mcMMOPlayer.getSkillLevel(targetSkill));
|
|
||||||
|
|
||||||
if (targetSkill.getAbility() != null) {
|
|
||||||
boolean stopUpdating;
|
|
||||||
|
|
||||||
if (targetSkill == SkillType.MINING) {
|
|
||||||
// Special-Case: Mining has two abilities, both with cooldowns
|
|
||||||
Score cooldownSB = sidebarObjective.getScore(ScoreboardManager.abilityLabelsSkill.get(AbilityType.SUPER_BREAKER));
|
|
||||||
Score cooldownBM = sidebarObjective.getScore(ScoreboardManager.abilityLabelsSkill.get(AbilityType.BLAST_MINING));
|
|
||||||
int secondsSB = Math.max(mcMMOPlayer.calculateTimeRemaining(AbilityType.SUPER_BREAKER), 0);
|
|
||||||
int secondsBM = Math.max(mcMMOPlayer.calculateTimeRemaining(AbilityType.BLAST_MINING), 0);
|
|
||||||
|
|
||||||
cooldownSB.setScore(secondsSB);
|
|
||||||
cooldownBM.setScore(secondsBM);
|
|
||||||
|
|
||||||
stopUpdating = (secondsSB == 0 && secondsBM == 0);
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
AbilityType ability = targetSkill.getAbility();
|
for (SkillType parentSkill : FamilyTree.getParents(targetSkill)) {
|
||||||
Score cooldown = sidebarObjective.getScore(ScoreboardManager.abilityLabelsSkill.get(ability));
|
sidebarObjective.getScore(ScoreboardManager.skillLabels.get(parentSkill)).setScore(mcMMOPlayer.getSkillLevel(parentSkill));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
sidebarObjective.getScore(ScoreboardManager.LABEL_LEVEL).setScore(mcMMOPlayer.getSkillLevel(targetSkill));
|
||||||
|
|
||||||
|
if (targetSkill.getAbility() != null) {
|
||||||
|
boolean stopUpdating;
|
||||||
|
|
||||||
|
if (targetSkill == SkillType.MINING) {
|
||||||
|
// Special-Case: Mining has two abilities, both with cooldowns
|
||||||
|
Score cooldownSB = sidebarObjective.getScore(ScoreboardManager.abilityLabelsSkill.get(AbilityType.SUPER_BREAKER));
|
||||||
|
Score cooldownBM = sidebarObjective.getScore(ScoreboardManager.abilityLabelsSkill.get(AbilityType.BLAST_MINING));
|
||||||
|
int secondsSB = Math.max(mcMMOPlayer.calculateTimeRemaining(AbilityType.SUPER_BREAKER), 0);
|
||||||
|
int secondsBM = Math.max(mcMMOPlayer.calculateTimeRemaining(AbilityType.BLAST_MINING), 0);
|
||||||
|
|
||||||
|
cooldownSB.setScore(secondsSB);
|
||||||
|
cooldownBM.setScore(secondsBM);
|
||||||
|
|
||||||
|
stopUpdating = (secondsSB == 0 && secondsBM == 0);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
AbilityType ability = targetSkill.getAbility();
|
||||||
|
Score cooldown = sidebarObjective.getScore(ScoreboardManager.abilityLabelsSkill.get(ability));
|
||||||
|
int seconds = Math.max(mcMMOPlayer.calculateTimeRemaining(ability), 0);
|
||||||
|
|
||||||
|
cooldown.setScore(seconds);
|
||||||
|
|
||||||
|
stopUpdating = seconds == 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (stopUpdating) {
|
||||||
|
stopCooldownUpdating();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
startCooldownUpdating();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case COOLDOWNS_BOARD:
|
||||||
|
boolean anyCooldownsActive = false;
|
||||||
|
|
||||||
|
for (AbilityType ability : AbilityType.values()) {
|
||||||
int seconds = Math.max(mcMMOPlayer.calculateTimeRemaining(ability), 0);
|
int seconds = Math.max(mcMMOPlayer.calculateTimeRemaining(ability), 0);
|
||||||
|
|
||||||
cooldown.setScore(seconds);
|
if (seconds != 0) {
|
||||||
|
anyCooldownsActive = true;
|
||||||
|
}
|
||||||
|
|
||||||
stopUpdating = seconds == 0;
|
sidebarObjective.getScore(ScoreboardManager.abilityLabelsColored.get(ability)).setScore(seconds);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (stopUpdating) {
|
if (anyCooldownsActive) {
|
||||||
stopCooldownUpdating();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
startCooldownUpdating();
|
startCooldownUpdating();
|
||||||
}
|
}
|
||||||
}
|
else {
|
||||||
break;
|
stopCooldownUpdating();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
case COOLDOWNS_BOARD:
|
case STATS_BOARD:
|
||||||
boolean anyCooldownsActive = false;
|
// Select the profile to read from
|
||||||
|
PlayerProfile newProfile;
|
||||||
|
|
||||||
for (AbilityType ability : AbilityType.values()) {
|
if (targetProfile != null) {
|
||||||
int seconds = Math.max(mcMMOPlayer.calculateTimeRemaining(ability), 0);
|
newProfile = targetProfile; // offline
|
||||||
|
}
|
||||||
if (seconds != 0) {
|
else if (targetPlayer == null) {
|
||||||
anyCooldownsActive = true;
|
newProfile = mcMMOPlayer.getProfile(); // self
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
newProfile = UserManager.getPlayer(targetPlayer).getProfile(); // online
|
||||||
}
|
}
|
||||||
|
|
||||||
sidebarObjective.getScore(ScoreboardManager.abilityLabelsColored.get(ability)).setScore(seconds);
|
// Calculate power level here
|
||||||
}
|
int powerLevel = 0;
|
||||||
|
for (SkillType skill : SkillType.NON_CHILD_SKILLS) { // Don't include child skills, makes the list too long
|
||||||
|
int level = newProfile.getSkillLevel(skill);
|
||||||
|
|
||||||
if (anyCooldownsActive) {
|
powerLevel += level;
|
||||||
startCooldownUpdating();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
stopCooldownUpdating();
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case STATS_BOARD:
|
// TODO: Verify that this is what we want - calculated in power level but not displayed
|
||||||
// Select the profile to read from
|
if (!skill.getPermissions(player)) {
|
||||||
PlayerProfile newProfile;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (targetProfile != null) {
|
sidebarObjective.getScore(ScoreboardManager.skillLabels.get(skill)).setScore(level);
|
||||||
newProfile = targetProfile; // offline
|
|
||||||
}
|
|
||||||
else if (targetPlayer == null) {
|
|
||||||
newProfile = mcMMOPlayer.getProfile(); // self
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
newProfile = UserManager.getPlayer(targetPlayer).getProfile(); // online
|
|
||||||
}
|
|
||||||
|
|
||||||
// Calculate power level here
|
|
||||||
int powerLevel = 0;
|
|
||||||
for (SkillType skill : SkillType.NON_CHILD_SKILLS) { // Don't include child skills, makes the list too long
|
|
||||||
int level = newProfile.getSkillLevel(skill);
|
|
||||||
|
|
||||||
powerLevel += level;
|
|
||||||
|
|
||||||
// TODO: Verify that this is what we want - calculated in power level but not displayed
|
|
||||||
if (!skill.getPermissions(player)) {
|
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sidebarObjective.getScore(ScoreboardManager.skillLabels.get(skill)).setScore(level);
|
sidebarObjective.getScore(ScoreboardManager.LABEL_POWER_LEVEL).setScore(powerLevel);
|
||||||
}
|
break;
|
||||||
|
|
||||||
sidebarObjective.getScore(ScoreboardManager.LABEL_POWER_LEVEL).setScore(powerLevel);
|
case RANK_BOARD:
|
||||||
break;
|
case TOP_BOARD:
|
||||||
|
|
||||||
case RANK_BOARD:
|
|
||||||
case TOP_BOARD:
|
|
||||||
/*
|
/*
|
||||||
* @see #acceptRankData(Map<SkillType, Integer> rank)
|
* @see #acceptRankData(Map<SkillType, Integer> rank)
|
||||||
* @see #acceptLeaderboardData(List<PlayerStat> stats)
|
* @see #acceptLeaderboardData(List<PlayerStat> stats)
|
||||||
*/
|
*/
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -550,11 +554,11 @@ public class ScoreboardWrapper {
|
|||||||
name = ChatColor.GOLD + "--You--";
|
name = ChatColor.GOLD + "--You--";
|
||||||
}
|
}
|
||||||
|
|
||||||
sidebarObjective.getScore(mcMMO.p.getServer().getOfflinePlayer(name)).setScore(stat.statVal);
|
sidebarObjective.getScore(name).setScore(stat.statVal);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updatePowerLevel(Player player, int newPowerLevel) {
|
public void updatePowerLevel(Player player, int newPowerLevel) {
|
||||||
powerObjective.getScore(player).setScore(newPowerLevel);
|
powerObjective.getScore(player.getName()).setScore(newPowerLevel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user