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

Compare commits

..

98 Commits

Author SHA1 Message Date
t00thpick1
63ae7e97e1 Ranks config idea 2013-10-04 17:52:47 -04:00
GJ
b8e937a234 ALWAYS remove pots broken by swords. 2013-10-04 13:16:41 -04:00
GJ
eb2e0d3abf Fixed Hylian Luck not working at all.
Fixes #1508
2013-10-04 10:27:18 -04:00
GJ
3365da7f8d MCPC+ checks, notify server owners that they're missing out. 2013-10-04 09:50:49 -04:00
TfT_02
a0e37a4a09 I forgot to invert this check 2013-10-03 22:04:39 +02:00
GJ
5541c15753 Try/catch was stupid. 2013-10-02 09:07:30 -04:00
GJ
f87110749e ACTUALLY fix the NPE here. 2013-10-02 09:03:09 -04:00
GJ
a0ef0d5708 Check vanilla's maxDurability here as well, just to be safe.
Fixes #1504
2013-10-02 08:56:48 -04:00
TfT_02
2e2abcd645 Handle this nicer 2013-10-02 10:42:06 +02:00
TfT_02
6baf820afa Cleanup and formatting 2013-10-01 22:14:29 +02:00
Kane York
288287badf Add holiday celebration for the console 2013-10-01 22:06:51 +02:00
TfT_02
ca4feca073 Cleanup changelog.txt a bit 2013-10-01 15:09:45 +02:00
GJ
7c9356955e ACTUALLY handle SQL passwords (or other fields) with '#' in them properly. 2013-09-30 16:17:44 -04:00
GJ
57541ec233 This can never be null, and there's no reason to pass that as a variable. 2013-09-30 14:19:07 -04:00
TfT_02
9c6d1ce020 Fixing these infinite recursing methods
Oops, that was silly. Thanks @t00thpick1
2013-09-30 19:38:22 +02:00
TfT_02
c72ead9d0a Prevent breaking other plugins who use this API 2013-09-30 19:03:44 +02:00
TfT_02
4262a1b2a5 Added two more treasures to Excavation 2013-09-30 16:24:21 +02:00
TfT_02
eb589b6e78 Renamed some config options in the Commands section.
The following keys have been renamed:
* General => Generic
* p => partychat
* a => adminchat
2013-09-30 15:43:37 +02:00
GJ
98e5e53fda Ignore "#" in SQL passwords. 2013-09-30 08:36:32 -04:00
TfT_02
00918fbdc1 Change this back, getPlayerExact() is faster 2013-09-30 14:04:34 +02:00
TfT_02
5ad0f2c624 Do a little bit of localebending 2013-09-30 11:32:35 +02:00
TfT_02
babb9baa2b Handle joining disbanded parties properly 2013-09-30 11:22:15 +02:00
TfT_02
45143836e5 Fixed /party kick
Fixes #1499
2013-09-30 10:39:33 +02:00
TfT_02
ceacd7dc52 Fixed /party disband 2013-09-30 10:39:14 +02:00
TfT_02
6eb255632f Clean this up a little bit 2013-09-30 10:24:36 +02:00
TfT_02
3a37d0e092 Fixing an error due to confusingly named check
Refactored healthBarEnabled to healthBarPluginEnabled to avoid this
from happening again.
2013-09-29 23:57:13 +02:00
TfT_02
4c7fb1854d addRawXP should use float instead of int 2013-09-29 15:48:11 +02:00
TfT_02
763cff6898 Fixed a bug where Repair wasn't asking for confirmation 2013-09-28 19:46:47 +02:00
riking
fa34d06341 Clear child skill FamilyTree on reload 2013-09-27 15:46:19 -07:00
TfT_02
1ca53da0e2 Also try to count recipe ingredients regardless of repairMaterial
when the normal counting and the config value result in 0

Fixes #1484
2013-09-27 13:42:50 +02:00
TfT_02
57dfa00541 Fixed a NPE when an invalid repair material was entered
#1484
2013-09-27 10:46:54 +02:00
TfT_02
36ae84eada Update README.md 2013-09-26 23:06:07 +02:00
GJ
7f290504ad Set random jump strength for horses as well. 2013-09-26 10:43:45 -04:00
GJ
92b4be9a01 We don't use these parts of the updater. 2013-09-26 09:39:13 -04:00
GJ
8cb8dea642 Move Updater to independent package due to custom changes being overwritten by other plugins using the updater. 2013-09-26 09:37:31 -04:00
GJ
a63f745c73 Add custom mobs automatically as they're killed. 2013-09-26 15:06:36 +02:00
GJ
4a0fee5796 Use class names to better find custom entities. 2013-09-26 15:06:21 +02:00
GJ
cf90236e57 Redo blocks.yml
** YOU WILL NEED TO UPDATE THIS FILE **
2013-09-26 15:06:21 +02:00
GJ
fc6c7bb1de Rework custom tool config.
** YOU WILL NEED TO UPDATE YOUR CONFIG TO THE NEW FORMAT **
2013-09-26 15:06:21 +02:00
GJ
1b92131ce9 Added Carrot on a Stick, and Flint & Steel to repair.vanilla.yml 2013-09-26 14:58:31 +02:00
GJ
792ecd6aad Rework armor.yml to take item names instead of IDs in advance of 1.7 changes.
** YOU WILL NEED TO REDO YOUR armor.yml FILE **
2013-09-26 14:58:30 +02:00
TfT_02
933b6f278b Disable partial name matching for offline players by default
#1482
2013-09-25 14:26:24 +02:00
TfT_02
45dfc13ebd Match playernames using OfflinePlayers instead
Fixes #1482
2013-09-24 11:40:53 +02:00
dddeeefff
1254ab232a Add randomized Horse appearance to Call Of The Wild 2013-09-23 22:29:02 +02:00
dddeeefff
b49e56c857 Added missing COTW message when there are too many Horses nearby 2013-09-23 22:29:01 +02:00
TfT_02
d5bd9a1693 Fixed some small mistakes in CommandUtils 2013-09-23 20:22:41 +02:00
GJ
9b60cd96f9 Don't need these keys with the new format either. 2013-09-23 10:33:50 -04:00
TfT_02
0a05ed98d0 Updated to the new format! 2013-09-22 23:28:09 +02:00
TfT_02
6a3a564bd4 Use cooldownExpired here as well. 2013-09-22 23:28:09 +02:00
TfT_02
3828f78480 Fixed respawn cooldown checks
Thanks @Riking for pointing this out!
2013-09-22 23:28:08 +02:00
Travis Ralston
239d7e33cb Revert "Metrics be dead"
This reverts commit 0a9fd4a92e.
2013-09-22 12:33:01 -06:00
TfT_02
b8c479549c Disable our healthbars when the plugin "HealthBar" is found
Adds #1477
2013-09-22 16:55:02 +02:00
t00thpick1
0a9fd4a92e Metrics be dead 2013-09-20 22:23:38 -04:00
TfT_02
4c96161acb Don't throw errors about dropped columns 2013-09-20 21:39:20 +02:00
TfT_02
ce7a7a31a7 A bit of cleaning up 2013-09-20 00:15:22 +02:00
TfT_02
834e26b44e Minor improvements 2013-09-19 21:47:12 +02:00
GJ
f71b302f6f Don't need this anymore. 2013-09-19 15:19:16 -04:00
GJ
566a381e95 Remove debug message, use recipe method for salvage. 2013-09-19 15:17:19 -04:00
GJ
5d7d779a49 Changed format of repair.vanilla.yml. **YOU WILL NEED TO UPDATE YOUR FILE TO THE NEW FORMAT** 2013-09-19 11:02:47 -04:00
GJ
59a35b170c Oh yeah, that's why. 2013-09-18 15:42:54 -04:00
GJ
14eb473355 Why we were making this so complicated, I'll never know. 2013-09-18 14:55:17 -04:00
GJ
a8e23e08ee Remove HudType from Flatfile records. 2013-09-18 11:54:23 -04:00
GJ
15f5dcf860 Removed HudType references from the database. 2013-09-18 09:57:28 -04:00
GJ
9be9908a22 Remove unused imports. 2013-09-18 09:39:54 -04:00
GJ
446b6c107b Remove empty lines from FlatFile - the plugin will not enable if these are present. 2013-09-18 08:34:47 -04:00
GJ
5a3f8ad15f Add COTW info for horses to the Taming command. 2013-09-17 14:13:11 -04:00
GJ
3a2c6a0827 We can have ' again! 2013-09-17 14:09:39 -04:00
GJ
e865acd871 Fix locale parsing issues.
Fixes #1463
2013-09-17 14:03:00 -04:00
TfT_02
4a0e1ba444 Fix a small boo boo 2013-09-16 23:26:06 +02:00
GJ
1a88b0b944 Better way to handle ink sacks, allows for dropping of multiple types. 2013-09-16 12:48:08 -04:00
GJ
e0592b3f62 Don't try to ever pull the mcMMOPlayer here.
Fixes #1466
2013-09-16 12:12:31 -04:00
GJ
1ec55c2d7e Remove the last bits of Spout from our code. 2013-09-16 12:05:39 -04:00
GJ
6427a7dcdf Fix issues with Skulls in treasures.yml 2013-09-16 11:45:57 -04:00
TfT_02
7bac0e2ca5 Dropped SpoutPlugin support
Because SpoutPlugin is not being updated to 1.6.x and mcMMO 1.4.07 does
not support any CB version below 1.6.x SpoutPlugin support is no longer
needed.
https://blog.spout.org/minecraft-1-6-and-the-legacy-finale/
2013-09-16 16:48:42 +02:00
GJ
e8bc2475c3 Add sound for level-up even when not using Spout. 2013-09-16 09:52:09 -04:00
GJ
816b08b14a Make sure the attacker is a valid player too.
Fixes #1464
2013-09-16 08:53:55 -04:00
GJ
64e1448782 Added ability to give items names & lore through treasures.yml.
Adds #1419
2013-09-15 21:09:32 -04:00
TfT_02
ae0a27991b Register when the config files were last updated 2013-09-15 23:10:35 +02:00
TfT_02
f1b82dcbe6 Fixed regex of version string parsing 2013-09-15 23:09:06 +02:00
TfT_02
bfbd50d8f4 Fix another wrong default Material name 2013-09-15 22:52:59 +02:00
GJ
de07316261 Just in case there's something broken in the file. 2013-09-15 16:49:41 -04:00
GJ
eae196c6a1 Fix wrong default material name. 2013-09-15 16:48:05 -04:00
GJ
8af41975ff Don't keep trying to load if they've got an old file. 2013-09-15 16:09:41 -04:00
GJ
957bbbc9b2 Warn if treasures.yml is outdated. 2013-09-15 15:59:29 -04:00
TfT_02
17faf1561f Refactor to getMaxLength 2013-09-15 21:45:16 +02:00
TfT_02
ec6419f0ff Fix formatting of the new Updater 2013-09-15 21:45:16 +02:00
GJ
f6e60bebcc Fix dropping sideways logs and leaf blocks.
Fixes #1460
2013-09-15 15:09:48 -04:00
GJ
797ac20567 Added Horses to the "Shake" ability.
Witches no longer drop water bottles from Shake, since they no longer drop them in Vanilla.
Changed format of treasures.yml.

**YOU WILL NEED TO UPDATE YOUR FILE TO THE NEW FORMAT**
2013-09-15 01:07:04 -04:00
GJ
3bc029a0de Make Updater work with our versioning setup. 2013-09-13 11:46:55 -04:00
GJ
4eba33a1c6 Use doubles in config.yml where appropriate. Change item IDs to item names
in light of upcoming Minecraft changes that will remove access to item
IDs.
2013-09-13 09:52:52 -04:00
GJ
800a452d62 Remove use of deprecated function. 2013-09-13 09:11:34 -04:00
GJ
177604e94a Condense this into one function. 2013-09-13 08:11:32 -04:00
GJ
088015dd4d Switch to H31ix's updater for security reasons. 2013-09-13 00:59:07 -04:00
t00thpick1
0f2d0aee5f Fix NPE on /addxp 2013-09-12 21:21:00 -04:00
t00thpick1
1004e2a32b These duplicate checks are handled in config validation. 2013-09-12 20:52:26 -04:00
t00thpick1
5c2b523f7a Allow less than one percentages for hardcore losses 2013-09-12 20:52:26 -04:00
GJ
de42063171 Fixed a bug where Kraken messages couldn't be disabled.
Fixes #1174
2013-09-12 15:53:43 -04:00
GJ
a49d373af0 Back to active development. 2013-09-12 14:28:51 -04:00
425 changed files with 3380 additions and 5608 deletions

View File

@@ -8,6 +8,8 @@ Key:
- Removal
Version 1.4.07-dev
+ Added Carrot on a Stick and Flint & Steel to repair.vanilla.yml
+ Added horses to the "Shake" ability
+ Added ability to summon horses via "Call of the Wild" using apples
+ Added XP gain to Taming for horses
+ Added new permission nodes to allow more control over Taming and "Call of the Wild"
@@ -22,6 +24,10 @@ Version 1.4.07-dev
+ Added new McMMOPlayerDeathPenaltyEvent, fired when a player dies and would lose levels
+ Added new McMMOPlayerLevelChangeEvent, fired when a players level changes
+ Added new McMMOPlayerLevelDownEvent, fired when a player loses levels
+ Added ability to give custom names to items in treasures.yml - use the key "Custom_Name" to set, expects a string.
+ Added ability to give lore to items in treasures.yml - use the key "Lore" to set, expects a list of strings.
+ Added Quartz and Name Tags to the default Excavation treasures
+ Killing a custom entity will automatically add it to the custom entity config file with default values.
= Fixed bug which allowed players to bypass fishing's exploit prevention
= Fixed bug where FakeEntityDamageByEntityEvent wasn't being fired
= Fixed bug with "Skull Splitter" not finding the locale string
@@ -32,22 +38,31 @@ Version 1.4.07-dev
= Fixed a bug where teleport location was never reset if warmup was set to 0 for "Chimaera Wing".
= Fixed a bug where the "Dodge" DamageModifier wasn't being read from advanced.yml
= Fixed a bug where squid were not awarding XP.
= Fixed a bug where Combat XP was granted within 5 seconds for respawned players
= Fixed a bug where wrong feedback messages were being send when using a command on an offline player
! Changed format of mod config files. (blocks.yml, tools.yml, armor.yml and entities.yml) **YOU WILL NEED TO UPDATE YOUR FILE TO THE NEW FORMAT**
! Changed format of treasures.yml. **YOU WILL NEED TO UPDATE YOUR FILE TO THE NEW FORMAT**
! Changed format of repair.vanilla.yml. **YOU WILL NEED TO UPDATE YOUR FILE TO THE NEW FORMAT**
! Changed default XP multiplier for repairing shears
! Changed "Shake" drops for Witches. They no longer drop water bottles, since they no longer drop them in Vanilla.
! Changed various values to double in advanced.yml for the sake of consistency.
! Nerfed Archery damage to eliminate constant one-hit kills.
! Changed the way Repair hands out XP, also added config options to control Repair XP
! Changed Swords "Counter Attack" ability from passive to active. Blocking is required to activate.
! Hardcore mode can now be toggled for each skill individually
! Hardcore modes can now be toggled for each skill individually
! Vampirism can now be enabled without having Skill Death Penalty enabled
! Admin and Party chat prefixes are now customizable
! Changed the color of party leader names in Party chat
! Improved profile saving
! Improved partial name matcher
! Slightly improved update checker feedback
! Improved update checker
! Updated localization files
! Party item share category states are now saved when the server shuts down.
! When using "Super Breaker" or "Giga Driller" abilities extra tool durability is used (again)
! Mob healthbars are automatically disabled when the plugin "HealthBar" is found
- The /mmoupdate command has been removed. It is replaced by /mcconvert database
- Removed Abilities.Tools.Durability_Loss_Enabled, set Abilities.Tools.Durability_Loss to 0 to disable instead.
- Removed SpoutPlugin support
Version 1.4.06
+ Added "Ice Fishing" ability to Fishing

View File

@@ -5,7 +5,7 @@
Our latest development builds are available [here](http://ci.mcmmo.info).
### Brief Description
The goal of mcMMO is to take core Minecraft game mechanics and expand them into add an extensive and quality RPG experience. Everything in mcMMO has been carefully thought out and is constantly being improved upon. Currently, mcMMO adds thirteen unique skills to train and level in. Each of these skills is highly customizable through our configuration files, allowing server admins to tweak mcMMO to best suit the needs of his or her server. Additionally, when run in conjuction with SpoutPlugin, mcMMO also has a custom XP bar to allow for easy tracking of progress towards leveling up. Know that the mcMMO team is dedicated to providing an ever-evolving experience, and that we carefully read all feedback and bug reports in order to evaluate and balance the mechanics of mcMMO in every update.
The goal of mcMMO is to take core Minecraft game mechanics and expand them into add an extensive and quality RPG experience. Everything in mcMMO has been carefully thought out and is constantly being improved upon. Currently, mcMMO adds thirteen unique skills to train and level in. Each of these skills is highly customizable through our configuration files, allowing server admins to tweak mcMMO to best suit the needs of his or her server. Know that the mcMMO team is dedicated to providing an ever-evolving experience, and that we carefully read all feedback and bug reports in order to evaluate and balance the mechanics of mcMMO in every update.
## About the Team
@@ -34,10 +34,9 @@ mcMMO is currently developed by a team of individuals from all over the world.
mcMMO uses Maven 3 to manage dependancies, packaging, and shading of necessary classes; Maven 3 is required to compile mcMMO.
The typical command used to build mcMMO is: mvn clean package install
The typical command used to build mcMMO is: `mvn clean package install`
Required Libraries:
* Spout API
* JUnit
* EMetrics
* Bukkit

View File

@@ -1,11 +1,11 @@
#
# Repair configuration
# Last updated on ${project.version}-b${BUILD_NUMBER}
#
# Any file named repair.*.yml in the mcmmmo folder will be loaded as a repair config
# All repair configs have a main section titled "Repairables"
# Afterwards, all sub-items are considered a Repairable to be loaded
# The bare minimum of a Repairable is that it have an ItemId, a RepairMaterialId, and a MaximumDurability
#
# ItemId: This is the id of the item to be repairable.
## This is required to be set.
# Afterwards, all sub-items are considered a Repairable to be loaded. The names of each subitem should be the exact material name.
# The bare minimum of a Repairable is that it have a RepairMaterial and a MaximumDurability
#
# ItemType: This is the type of item to be repaired, this is only important to permissions.
## Valid values are ARMOR, TOOL, and OTHER.
@@ -15,7 +15,7 @@
## Valid values are STRING, LEATHER, WOOD, STONE, IRON, GOLD, DIAMOND, and OTHER
## This defaults to OTHER.
#
# RepairMaterialId: This is the id of the item used to repair this repairable.
# RepairMaterial: This is the material name of the item used to repair this repairable.
## This is required to be set.
#
# RepairMaterialMetadata: This is the metadata of the item used to repair this repairable.
@@ -26,7 +26,7 @@
## This is required to be set.
#
# MinimumLevel: This is the minimum repair level needed to repair this item.
## Valid values are > 0
## Valid values are => 0
## This defaults to 0
#
# MinimumQuantity: This is the minimum number of items needed to repair this item ignoring all other repair bonuses.
@@ -42,32 +42,19 @@
#
###
Repairables:
ChainHelmet:
ItemId: 302
ItemType: ARMOR
RepairMaterialId: 51
MaximumDurability: 165
MinimumQuantity: 5
#
# Chainmail repairables
###
# Armor
CHAINMAIL_HELMET:
RepairMaterial: FIRE
XpMultiplier: 2
ChainChest:
ItemId: 303
ItemType: ARMOR
RepairMaterialId: 51
MaximumDurability: 240
MinimumQuantity: 8
CHAINMAIL_CHESTPLATE:
RepairMaterial: FIRE
XpMultiplier: 2
ChainLegs:
ItemId: 304
ItemType: ARMOR
RepairMaterialId: 51
MaximumDurability: 225
MinimumQuantity: 7
CHAINMAIL_LEGGINGS:
RepairMaterial: FIRE
XpMultiplier: 2
ChainBoots:
ItemId: 305
ItemType: ARMOR
RepairMaterialId: 51
RepairMaterialMetadata: -1
MaximumDurability: 195
MinimumQuantity: 4
CHAINMAIL_BOOTS:
RepairMaterial: FIRE
XpMultiplier: 2

45
pom.xml
View File

@@ -2,7 +2,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.gmail.nossr50.mcMMO</groupId>
<artifactId>mcMMO</artifactId>
<version>1.4.07-beta1</version>
<version>1.4.07-dev2</version>
<name>mcMMO</name>
<url>https://github.com/mcMMO-Dev/mcMMO</url>
<issueManagement>
@@ -22,38 +22,6 @@
<include>.jenkins</include>
</includes>
</resource>
<resource>
<targetPath>resources</targetPath>
<filtering>false</filtering>
<directory>${basedir}/src/main/resources/xpbar/</directory>
<includes>
<include>xpbar*.png</include>
</includes>
</resource>
<resource>
<targetPath>resources</targetPath>
<filtering>false</filtering>
<directory>${basedir}/src/main/resources/healthbar/</directory>
<includes>
<include>health*.png</include>
</includes>
</resource>
<resource>
<targetPath>resources</targetPath>
<filtering>false</filtering>
<directory>${basedir}/src/main/resources/skillicon/</directory>
<includes>
<include>*.png</include>
</includes>
</resource>
<resource>
<targetPath>resources</targetPath>
<filtering>false</filtering>
<directory>${basedir}/src/main/resources/sound/</directory>
<includes>
<include>*.wav</include>
</includes>
</resource>
<resource>
<targetPath>com/gmail/nossr50/locale</targetPath>
<filtering>true</filtering>
@@ -132,10 +100,6 @@
<id>bukkit-repo</id>
<url>http://repo.bukkit.org/content/groups/public/</url>
</repository>
<repository>
<id>spout-repo</id>
<url>http://nexus.spout.org/content/groups/public/</url>
</repository>
<repository>
<id>Plugin MetricsExtension</id>
<url>http://repo.turt2live.com</url>
@@ -149,13 +113,6 @@
<type>jar</type>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.getspout</groupId>
<artifactId>spoutplugin</artifactId>
<version>LATEST</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit-dep</artifactId>

View File

@@ -48,6 +48,11 @@ public final class ExperienceAPI {
return !skill.isChildSkill();
}
@Deprecated
public static void addRawXP(Player player, String skillType, int XP) {
addRawXP(player, skillType, (float) XP);
}
/**
* Adds raw XP to the player.
* </br>
@@ -59,10 +64,15 @@ public final class ExperienceAPI {
*
* @throws InvalidSkillException if the given skill is not valid
*/
public static void addRawXP(Player player, String skillType, int XP) {
public static void addRawXP(Player player, String skillType, float XP) {
UserManager.getPlayer(player).applyXpGain(getSkillType(skillType), XP);
}
@Deprecated
public static void addRawXPOffline(String playerName, String skillType, int XP) {
addRawXPOffline(playerName, skillType, (float) XP);
}
/**
* Adds raw XP to an offline player.
* </br>
@@ -75,8 +85,8 @@ public final class ExperienceAPI {
* @throws InvalidSkillException if the given skill is not valid
* @throws InvalidPlayerException if the given player does not exist in the database
*/
public static void addRawXPOffline(String playerName, String skillType, int XP) {
addOfflineXP(playerName, getSkillType(skillType), XP);
public static void addRawXPOffline(String playerName, String skillType, float XP) {
addOfflineXP(playerName, getSkillType(skillType), (int) Math.floor(XP));
}
/**

View File

@@ -1,29 +0,0 @@
package com.gmail.nossr50.api;
import org.bukkit.entity.Player;
import com.gmail.nossr50.config.spout.SpoutConfig;
import com.gmail.nossr50.datatypes.spout.huds.HudType;
import com.gmail.nossr50.util.player.UserManager;
public class SpoutHudAPI {
private SpoutHudAPI() {}
/**
* Disable the mcMMO XP bar for a player.
* </br>
* This function is designed for API usage.
*/
public static void disableXpBar(Player player) {
UserManager.getPlayer(player).getProfile().setHudType(HudType.DISABLED);
}
/**
* Disable the mcMMO XP bar for the server.
* </br>
* This function is designed for API usage.
*/
public static void disableXpBar() {
SpoutConfig.getInstance().setXPBarEnabled(false);
}
}

View File

@@ -1,53 +0,0 @@
package com.gmail.nossr50.api;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.inventory.ItemStack;
import com.gmail.nossr50.datatypes.skills.ToolType;
public final class SpoutToolsAPI {
public static final List<ItemStack> spoutSwords = new ArrayList<ItemStack>();
public static final List<ItemStack> spoutAxes = new ArrayList<ItemStack>();
public static final List<ItemStack> spoutPickaxes = new ArrayList<ItemStack>();
public static final List<ItemStack> spoutHoes = new ArrayList<ItemStack>();
public static final List<ItemStack> spoutShovels = new ArrayList<ItemStack>();
private SpoutToolsAPI() {}
/**
* Add a custom Spout tool to mcMMO for XP gain & ability use.
* </br>
* This function is designed for API usage.
*
* @param spoutTool The tool to add
* @param type The type of tool to add
*/
public static void addCustomTool(ItemStack spoutTool, ToolType type) {
switch (type) {
case AXE:
spoutAxes.add(spoutTool);
break;
case HOE:
spoutHoes.add(spoutTool);
break;
case PICKAXE:
spoutPickaxes.add(spoutTool);
break;
case SHOVEL:
spoutShovels.add(spoutTool);
break;
case SWORD:
spoutSwords.add(spoutTool);
break;
default:
break;
}
}
}

View File

@@ -4,14 +4,13 @@ import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.commands.party.PartySubcommandType;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.HolidayManager;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.spout.SpoutUtils;
public class McmmoCommand implements CommandExecutor {
@Override
@@ -28,16 +27,12 @@ public class McmmoCommand implements CommandExecutor {
sender.sendMessage(mcSplit);
if (Config.getInstance().getDonateMessageEnabled()) {
if (mcMMO.isSpoutEnabled() && sender instanceof Player) {
SpoutUtils.sendDonationNotification((Player) sender);
}
else {
sender.sendMessage(LocaleLoader.getString("MOTD.Donate"));
sender.sendMessage(ChatColor.GOLD + " - " + ChatColor.GREEN + "gjmcferrin@gmail.com" + ChatColor.GOLD + " Paypal");
}
sender.sendMessage(LocaleLoader.getString("MOTD.Donate"));
sender.sendMessage(ChatColor.GOLD + " - " + ChatColor.GREEN + "gjmcferrin@gmail.com" + ChatColor.GOLD + " Paypal");
}
sender.sendMessage(LocaleLoader.getString("MOTD.Version", mcMMO.p.getDescription().getVersion()));
HolidayManager.anniversaryCheck(sender);
return true;
case 1:

View File

@@ -67,7 +67,7 @@ public abstract class ExperienceCommand implements TabExecutor {
}
String playerName = Misc.getMatchedPlayerName(args[0]);
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(playerName, true);
mcMMOPlayer = UserManager.getPlayer(playerName, true);
// If the mcMMOPlayer doesn't exist, create a temporary profile and check if it's present in the database. If it's not, abort the process.
if (mcMMOPlayer == null) {

View File

@@ -19,7 +19,7 @@ public class PartyInviteCommand implements CommandExecutor {
switch (args.length) {
case 2:
String targetName = Misc.getMatchedPlayerName(args[1]);
McMMOPlayer mcMMOTarget = UserManager.getPlayer(targetName);
McMMOPlayer mcMMOTarget = UserManager.getPlayer(targetName, true);
if (!CommandUtils.checkPlayerExistence(sender, targetName, mcMMOTarget)) {
return false;

View File

@@ -22,7 +22,7 @@ public class PartyKickCommand implements CommandExecutor {
OfflinePlayer target = mcMMO.p.getServer().getOfflinePlayer(args[1]);
if (!playerParty.getMembers().contains(target.getName())) {
sender.sendMessage(LocaleLoader.getString("Party.NotInYourParty", args[1]));
sender.sendMessage(LocaleLoader.getString("Party.NotInYourParty", target.getName()));
return true;
}
@@ -34,6 +34,7 @@ public class PartyKickCommand implements CommandExecutor {
return true;
}
PartyManager.processPartyLeaving(UserManager.getPlayer(onlineTarget));
onlineTarget.sendMessage(LocaleLoader.getString("Commands.Party.Kick", partyName));
}

View File

@@ -82,15 +82,15 @@ public class AcrobaticsCommand extends SkillCommand {
@Override
protected void statsDisplay() {
if (canRoll) {
player.sendMessage(LocaleLoader.getString("Acrobatics.Roll.Chance", rollChance) + (isLucky ? LocaleLoader.getString("Perks.lucky.bonus", rollChanceLucky) : ""));
player.sendMessage(LocaleLoader.getString("Acrobatics.Roll.Chance", rollChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", rollChanceLucky) : ""));
}
if (canGracefulRoll) {
player.sendMessage(LocaleLoader.getString("Acrobatics.Roll.GraceChance", gracefulRollChance) + (isLucky ? LocaleLoader.getString("Perks.lucky.bonus", gracefulRollChanceLucky) : ""));
player.sendMessage(LocaleLoader.getString("Acrobatics.Roll.GraceChance", gracefulRollChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", gracefulRollChanceLucky) : ""));
}
if (canDodge) {
player.sendMessage(LocaleLoader.getString("Acrobatics.DodgeChance", dodgeChance) + (isLucky ? LocaleLoader.getString("Perks.lucky.bonus", dodgeChanceLucky) : ""));
player.sendMessage(LocaleLoader.getString("Acrobatics.DodgeChance", dodgeChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", dodgeChanceLucky) : ""));
}
}
}

View File

@@ -84,11 +84,11 @@ public class ArcheryCommand extends SkillCommand {
}
if (canDaze) {
player.sendMessage(LocaleLoader.getString("Archery.Combat.DazeChance", dazeChance) + (isLucky ? LocaleLoader.getString("Perks.lucky.bonus", dazeChanceLucky) : ""));
player.sendMessage(LocaleLoader.getString("Archery.Combat.DazeChance", dazeChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", dazeChanceLucky) : ""));
}
if (canRetrieve) {
player.sendMessage(LocaleLoader.getString("Archery.Combat.RetrieveChance", retrieveChance) + (isLucky ? LocaleLoader.getString("Perks.lucky.bonus", retrieveChanceLucky) : ""));
player.sendMessage(LocaleLoader.getString("Archery.Combat.RetrieveChance", retrieveChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", retrieveChanceLucky) : ""));
}
}
}

View File

@@ -109,11 +109,11 @@ public class AxesCommand extends SkillCommand {
}
if (canCritical) {
player.sendMessage(LocaleLoader.getString("Axes.Combat.CritChance", critChance) + (isLucky ? LocaleLoader.getString("Perks.lucky.bonus", critChanceLucky) : ""));
player.sendMessage(LocaleLoader.getString("Axes.Combat.CritChance", critChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", critChanceLucky) : ""));
}
if (canSkullSplitter) {
player.sendMessage(LocaleLoader.getString("Axes.Combat.SS.Length", skullSplitterLength) + (hasEndurance ? LocaleLoader.getString("Perks.activationtime.bonus", skullSplitterLengthEndurance) : ""));
player.sendMessage(LocaleLoader.getString("Axes.Combat.SS.Length", skullSplitterLength) + (hasEndurance ? LocaleLoader.getString("Perks.ActivationTime.Bonus", skullSplitterLengthEndurance) : ""));
}
}
}

View File

@@ -57,7 +57,7 @@ public class ExcavationCommand extends SkillCommand {
@Override
protected void statsDisplay() {
if (canGigaDrill) {
player.sendMessage(LocaleLoader.getString("Excavation.Effect.Length", gigaDrillBreakerLength) + (hasEndurance ? LocaleLoader.getString("Perks.activationtime.bonus", gigaDrillBreakerLengthEndurance) : ""));
player.sendMessage(LocaleLoader.getString("Excavation.Effect.Length", gigaDrillBreakerLength) + (hasEndurance ? LocaleLoader.getString("Perks.ActivationTime.Bonus", gigaDrillBreakerLengthEndurance) : ""));
}
}
}

View File

@@ -139,7 +139,7 @@ public class FishingCommand extends SkillCommand {
}
if (canMagicHunt) {
player.sendMessage(LocaleLoader.getString("Fishing.Enchant.Chance", magicChance) + chanceRaining + (isLucky ? LocaleLoader.getString("Perks.lucky.bonus", magicChanceLucky) : ""));
player.sendMessage(LocaleLoader.getString("Fishing.Enchant.Chance", magicChance) + chanceRaining + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", magicChanceLucky) : ""));
}
if (canShake) {
@@ -149,7 +149,7 @@ public class FishingCommand extends SkillCommand {
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Fishing.Ability.Locked.0", unlockLevel)));
}
else {
player.sendMessage(LocaleLoader.getString("Fishing.Ability.Shake", shakeChance) + (isLucky ? LocaleLoader.getString("Perks.lucky.bonus", shakeChanceLucky) : ""));
player.sendMessage(LocaleLoader.getString("Fishing.Ability.Shake", shakeChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", shakeChanceLucky) : ""));
}
}

View File

@@ -135,11 +135,11 @@ public class HerbalismCommand extends SkillCommand {
@Override
protected void statsDisplay() {
if (canGreenTerra) {
player.sendMessage(LocaleLoader.getString("Herbalism.Ability.GTe.Length", greenTerraLength) + (hasEndurance ? LocaleLoader.getString("Perks.activationtime.bonus", greenTerraLengthEndurance) : ""));
player.sendMessage(LocaleLoader.getString("Herbalism.Ability.GTe.Length", greenTerraLength) + (hasEndurance ? LocaleLoader.getString("Perks.ActivationTime.Bonus", greenTerraLengthEndurance) : ""));
}
if (canGreenThumbBlocks || canGreenThumbPlants) {
player.sendMessage(LocaleLoader.getString("Herbalism.Ability.GTh.Chance", greenThumbChance) + (isLucky ? LocaleLoader.getString("Perks.lucky.bonus", greenThumbChanceLucky) : ""));
player.sendMessage(LocaleLoader.getString("Herbalism.Ability.GTh.Chance", greenThumbChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", greenThumbChanceLucky) : ""));
}
if (canGreenThumbPlants) {
@@ -151,15 +151,15 @@ public class HerbalismCommand extends SkillCommand {
}
if (hasHylianLuck) {
player.sendMessage(LocaleLoader.getString("Herbalism.Ability.HylianLuck", hylianLuckChance) + (isLucky ? LocaleLoader.getString("Perks.lucky.bonus", hylianLuckChanceLucky) : ""));
player.sendMessage(LocaleLoader.getString("Herbalism.Ability.HylianLuck", hylianLuckChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", hylianLuckChanceLucky) : ""));
}
if (canShroomThumb) {
player.sendMessage(LocaleLoader.getString("Herbalism.Ability.ShroomThumb.Chance", shroomThumbChance) + (isLucky ? LocaleLoader.getString("Perks.lucky.bonus", shroomThumbChanceLucky) : ""));
player.sendMessage(LocaleLoader.getString("Herbalism.Ability.ShroomThumb.Chance", shroomThumbChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", shroomThumbChanceLucky) : ""));
}
if (canDoubleDrop) {
player.sendMessage(LocaleLoader.getString("Herbalism.Ability.DoubleDropChance", doubleDropChance) + (isLucky ? LocaleLoader.getString("Perks.lucky.bonus", doubleDropChanceLucky) : ""));
player.sendMessage(LocaleLoader.getString("Herbalism.Ability.DoubleDropChance", doubleDropChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", doubleDropChanceLucky) : ""));
}
}
}

View File

@@ -106,11 +106,11 @@ public class MiningCommand extends SkillCommand {
@Override
protected void statsDisplay() {
if (canDoubleDrop) {
player.sendMessage(LocaleLoader.getString("Mining.Effect.DropChance", doubleDropChance) + (isLucky ? LocaleLoader.getString("Perks.lucky.bonus", doubleDropChanceLucky) : ""));
player.sendMessage(LocaleLoader.getString("Mining.Effect.DropChance", doubleDropChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", doubleDropChanceLucky) : ""));
}
if (canSuperBreaker) {
player.sendMessage(LocaleLoader.getString("Mining.Ability.Length", superBreakerLength) + (hasEndurance ? LocaleLoader.getString("Perks.activationtime.bonus", superBreakerLengthEndurance) : ""));
player.sendMessage(LocaleLoader.getString("Mining.Ability.Length", superBreakerLength) + (hasEndurance ? LocaleLoader.getString("Perks.ActivationTime.Bonus", superBreakerLengthEndurance) : ""));
}
if (canBlast) {

View File

@@ -41,10 +41,10 @@ public class RepairCommand extends SkillCommand {
@Override
protected void dataCalculations() {
// We're using pickaxes here, not the best but it works
Repairable diamondRepairable = mcMMO.getRepairableManager().getRepairable(Material.DIAMOND_PICKAXE.getId());
Repairable goldRepairable = mcMMO.getRepairableManager().getRepairable(Material.GOLD_PICKAXE.getId());
Repairable ironRepairable = mcMMO.getRepairableManager().getRepairable(Material.IRON_PICKAXE.getId());
Repairable stoneRepairable = mcMMO.getRepairableManager().getRepairable(Material.STONE_PICKAXE.getId());
Repairable diamondRepairable = mcMMO.getRepairableManager().getRepairable(Material.DIAMOND_PICKAXE);
Repairable goldRepairable = mcMMO.getRepairableManager().getRepairable(Material.GOLD_PICKAXE);
Repairable ironRepairable = mcMMO.getRepairableManager().getRepairable(Material.IRON_PICKAXE);
Repairable stoneRepairable = mcMMO.getRepairableManager().getRepairable(Material.STONE_PICKAXE);
// TODO: This isn't really accurate - if they don't have pickaxes loaded it doesn't always mean the repair level is 0
diamondLevel = (diamondRepairable == null) ? 0 : diamondRepairable.getMinimumLevel();
@@ -139,7 +139,7 @@ public class RepairCommand extends SkillCommand {
}
if (canSuperRepair) {
player.sendMessage(LocaleLoader.getString("Repair.Skills.Super.Chance", superRepairChance) + (isLucky ? LocaleLoader.getString("Perks.lucky.bonus", superRepairChanceLucky) : ""));
player.sendMessage(LocaleLoader.getString("Repair.Skills.Super.Chance", superRepairChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", superRepairChanceLucky) : ""));
}
if (canArcaneForge) {

View File

@@ -143,7 +143,7 @@ public abstract class SkillCommand implements TabExecutor {
}
protected String[] calculateLengthDisplayValues() {
int maxLength = skill.getAbility().getMaxTicks();
int maxLength = skill.getAbility().getMaxLength();
int length = 2 + (int) (skillValue / AdvancedConfig.getInstance().getAbilityLength());
int enduranceLength = PerksUtils.handleActivationPerks(player, length, maxLength);
@@ -157,7 +157,7 @@ public abstract class SkillCommand implements TabExecutor {
protected void luckyEffectsDisplay() {
if (isLucky) {
String perkPrefix = LocaleLoader.getString("MOTD.PerksPrefix");
player.sendMessage(perkPrefix + LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Perks.lucky.name"), LocaleLoader.getString("Perks.lucky.desc", skillName)));
player.sendMessage(perkPrefix + LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Perks.Lucky.Name"), LocaleLoader.getString("Perks.Lucky.Desc", skillName)));
}
}

View File

@@ -90,7 +90,7 @@ public class SmeltingCommand extends SkillCommand {
}
if (canSecondSmelt) {
player.sendMessage(LocaleLoader.getString("Smelting.Ability.SecondSmelt", secondSmeltChance) + (isLucky ? LocaleLoader.getString("Perks.lucky.bonus", secondSmeltChanceLucky) : ""));
player.sendMessage(LocaleLoader.getString("Smelting.Ability.SecondSmelt", secondSmeltChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", secondSmeltChanceLucky) : ""));
}
if (canVanillaXPBoost) {
@@ -109,7 +109,7 @@ public class SmeltingCommand extends SkillCommand {
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Smelting.Ability.Locked.1", Smelting.fluxMiningUnlockLevel)));
}
else {
player.sendMessage(LocaleLoader.getString("Smelting.Ability.FluxMining", fluxMiningChance) + (isLucky ? LocaleLoader.getString("Perks.lucky.bonus", fluxMiningChanceLucky) : ""));
player.sendMessage(LocaleLoader.getString("Smelting.Ability.FluxMining", fluxMiningChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", fluxMiningChanceLucky) : ""));
}
}
}

View File

@@ -86,17 +86,17 @@ public class SwordsCommand extends SkillCommand {
@Override
protected void statsDisplay() {
if (canCounter) {
player.sendMessage(LocaleLoader.getString("Swords.Combat.Counter.Chance", counterAttackChance) + (isLucky ? LocaleLoader.getString("Perks.lucky.bonus", counterAttackChanceLucky) : ""));
player.sendMessage(LocaleLoader.getString("Swords.Combat.Counter.Chance", counterAttackChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", counterAttackChanceLucky) : ""));
}
if (canBleed) {
player.sendMessage(LocaleLoader.getString("Swords.Combat.Bleed.Length", bleedLength));
player.sendMessage(LocaleLoader.getString("Swords.Combat.Bleed.Note"));
player.sendMessage(LocaleLoader.getString("Swords.Combat.Bleed.Chance", bleedChance) + (isLucky ? LocaleLoader.getString("Perks.lucky.bonus", bleedChanceLucky) : ""));
player.sendMessage(LocaleLoader.getString("Swords.Combat.Bleed.Chance", bleedChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", bleedChanceLucky) : ""));
}
if (canSerratedStrike) {
player.sendMessage(LocaleLoader.getString("Swords.SS.Length", serratedStrikesLength) + (hasEndurance ? LocaleLoader.getString("Perks.activationtime.bonus", serratedStrikesLengthEndurance) : ""));
player.sendMessage(LocaleLoader.getString("Swords.SS.Length", serratedStrikesLength) + (hasEndurance ? LocaleLoader.getString("Perks.ActivationTime.Bonus", serratedStrikesLengthEndurance) : ""));
}
}
}

View File

@@ -38,7 +38,7 @@ public class TamingCommand extends SkillCommand {
@Override
protected void permissionsCheck() {
canBeastLore = Permissions.beastLore(player);
canCallWild = Permissions.callOfTheWild(player, EntityType.WOLF) || Permissions.callOfTheWild(player, EntityType.OCELOT);
canCallWild = Permissions.callOfTheWild(player, EntityType.HORSE) || Permissions.callOfTheWild(player, EntityType.WOLF) || Permissions.callOfTheWild(player, EntityType.OCELOT);
canEnvironmentallyAware = Permissions.environmentallyAware(player);
canFastFood = Permissions.fastFoodService(player);
canGore = Permissions.gore(player);
@@ -93,6 +93,7 @@ public class TamingCommand extends SkillCommand {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Taming.Effect.12"), LocaleLoader.getString("Taming.Effect.13")));
player.sendMessage(LocaleLoader.getString("Taming.Effect.14", Config.getInstance().getTamingCOTWOcelotCost()));
player.sendMessage(LocaleLoader.getString("Taming.Effect.15", Config.getInstance().getTamingCOTWWolfCost()));
player.sendMessage(LocaleLoader.getString("Taming.Effect.20", Config.getInstance().getTamingCOTWHorseCost()));
}
}
@@ -158,7 +159,7 @@ public class TamingCommand extends SkillCommand {
}
if (canGore) {
player.sendMessage(LocaleLoader.getString("Taming.Combat.Chance.Gore", goreChance) + (isLucky ? LocaleLoader.getString("Perks.lucky.bonus", goreChanceLucky) : ""));
player.sendMessage(LocaleLoader.getString("Taming.Combat.Chance.Gore", goreChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", goreChanceLucky) : ""));
}
}
}

View File

@@ -113,19 +113,19 @@ public class UnarmedCommand extends SkillCommand {
}
if (canDeflect) {
player.sendMessage(LocaleLoader.getString("Unarmed.Ability.Chance.ArrowDeflect", deflectChance) + (isLucky ? LocaleLoader.getString("Perks.lucky.bonus", deflectChanceLucky) : ""));
player.sendMessage(LocaleLoader.getString("Unarmed.Ability.Chance.ArrowDeflect", deflectChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", deflectChanceLucky) : ""));
}
if (canDisarm) {
player.sendMessage(LocaleLoader.getString("Unarmed.Ability.Chance.Disarm", disarmChance) + (isLucky ? LocaleLoader.getString("Perks.lucky.bonus", disarmChanceLucky) : ""));
player.sendMessage(LocaleLoader.getString("Unarmed.Ability.Chance.Disarm", disarmChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", disarmChanceLucky) : ""));
}
if (canIronGrip) {
player.sendMessage(LocaleLoader.getString("Unarmed.Ability.Chance.IronGrip", ironGripChance) + (isLucky ? LocaleLoader.getString("Perks.lucky.bonus", ironGripChanceLucky) : ""));
player.sendMessage(LocaleLoader.getString("Unarmed.Ability.Chance.IronGrip", ironGripChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", ironGripChanceLucky) : ""));
}
if (canBerserk) {
player.sendMessage(LocaleLoader.getString("Unarmed.Ability.Berserk.Length", berserkLength) + (hasEndurance ? LocaleLoader.getString("Perks.activationtime.bonus", berserkLengthEndurance) : ""));
player.sendMessage(LocaleLoader.getString("Unarmed.Ability.Berserk.Length", berserkLength) + (hasEndurance ? LocaleLoader.getString("Perks.ActivationTime.Bonus", berserkLengthEndurance) : ""));
}
}
}

View File

@@ -85,11 +85,11 @@ public class WoodcuttingCommand extends SkillCommand {
}
if (canDoubleDrop) {
player.sendMessage(LocaleLoader.getString("Woodcutting.Ability.Chance.DDrop", doubleDropChance) + (isLucky ? LocaleLoader.getString("Perks.lucky.bonus", doubleDropChanceLucky) : ""));
player.sendMessage(LocaleLoader.getString("Woodcutting.Ability.Chance.DDrop", doubleDropChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", doubleDropChanceLucky) : ""));
}
if (canTreeFell) {
player.sendMessage(LocaleLoader.getString("Woodcutting.Ability.Length", treeFellerLength) + (hasEndurance ? LocaleLoader.getString("Perks.activationtime.bonus", treeFellerLengthEndurance) : ""));
player.sendMessage(LocaleLoader.getString("Woodcutting.Ability.Length", treeFellerLength) + (hasEndurance ? LocaleLoader.getString("Perks.ActivationTime.Bonus", treeFellerLengthEndurance) : ""));
}
}
}

View File

@@ -1,58 +0,0 @@
package com.gmail.nossr50.commands.spout;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.util.StringUtil;
import com.gmail.nossr50.datatypes.spout.huds.HudType;
import com.gmail.nossr50.locale.LocaleLoader;
import com.google.common.collect.ImmutableList;
public class MchudCommand extends SpoutCommand {
private static final List<String> HUD_TYPES;
static {
ArrayList<String> types = new ArrayList<String>();
for (HudType type : HudType.values()) {
types.add(type.toString());
}
Collections.sort(types);
HUD_TYPES = ImmutableList.copyOf(types);
}
@Override
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
switch (args.length) {
case 1:
return StringUtil.copyPartialMatches(args[0], HUD_TYPES, new ArrayList<String>(HUD_TYPES.size()));
default:
return ImmutableList.of();
}
}
@Override
protected boolean noArguments(Command command, CommandSender sender, String[] args) {
return false;
}
@Override
protected boolean oneArgument(Command command, CommandSender sender, String[] args) {
try {
playerProfile.setHudType(HudType.valueOf(args[0].toUpperCase().trim()));
spoutHud.initializeXpBar();
spoutHud.updateXpBar();
return true;
}
catch (IllegalArgumentException ex) {
sender.sendMessage(LocaleLoader.getString("Commands.mchud.Invalid"));
return true;
}
}
}

View File

@@ -1,54 +0,0 @@
package com.gmail.nossr50.commands.spout;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabExecutor;
import org.bukkit.entity.Player;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.spout.SpoutConfig;
import com.gmail.nossr50.datatypes.player.PlayerProfile;
import com.gmail.nossr50.datatypes.spout.huds.McMMOHud;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.commands.CommandUtils;
import com.gmail.nossr50.util.player.UserManager;
public abstract class SpoutCommand implements TabExecutor {
protected PlayerProfile playerProfile;
protected McMMOHud spoutHud;
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (CommandUtils.noConsoleUsage(sender)) {
return true;
}
if (!mcMMO.isSpoutEnabled() || !SpoutConfig.getInstance().getXPBarEnabled()) {
sender.sendMessage(LocaleLoader.getString("Commands.Disabled"));
return true;
}
playerProfile = UserManager.getPlayer((Player) sender).getProfile();
spoutHud = playerProfile.getSpoutHud();
if (spoutHud == null) {
sender.sendMessage(LocaleLoader.getString("Commands.Disabled"));
return true;
}
switch (args.length) {
case 0:
return noArguments(command, sender, args);
case 1:
return oneArgument(command, sender, args);
default:
return false;
}
}
protected abstract boolean noArguments(Command command, CommandSender sender, String[] args);
protected abstract boolean oneArgument(Command command, CommandSender sender, String[] args);
}

View File

@@ -1,90 +0,0 @@
package com.gmail.nossr50.commands.spout;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.util.StringUtil;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.commands.CommandUtils;
import com.gmail.nossr50.util.skills.SkillUtils;
import com.google.common.collect.ImmutableList;
public class XplockCommand extends SpoutCommand {
@Override
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
switch (args.length) {
case 1:
List<String> matches = StringUtil.copyPartialMatches(args[0], CommandUtils.TRUE_FALSE_OPTIONS, new ArrayList<String>(CommandUtils.TRUE_FALSE_OPTIONS.size()));
if (matches.size() == 0) {
return StringUtil.copyPartialMatches(args[0], SkillType.SKILL_NAMES, new ArrayList<String>(SkillType.SKILL_NAMES.size()));
}
return matches;
default:
return ImmutableList.of();
}
}
@Override
protected boolean noArguments(Command command, CommandSender sender, String[] args) {
if (spoutHud.getXpBarLocked()) {
unlockXpBar(sender);
return true;
}
lockXpBar(sender, spoutHud.getLastGained());
return true;
}
@Override
protected boolean oneArgument(Command command, CommandSender sender, String[] args) {
if (CommandUtils.shouldEnableToggle(args[0])) {
lockXpBar(sender, spoutHud.getLastGained());
return true;
}
if (CommandUtils.shouldDisableToggle(args[0])) {
unlockXpBar(sender);
return true;
}
if (CommandUtils.isInvalidSkill(sender, args[0])) {
return true;
}
SkillType skill = SkillType.getSkill(args[0]);
if (CommandUtils.isChildSkill(sender, skill)) {
return true;
}
if (!Permissions.xplock(sender, skill)) {
sender.sendMessage(command.getPermissionMessage());
return true;
}
lockXpBar(sender, skill);
return true;
}
private void lockXpBar(CommandSender sender, SkillType skill) {
if (skill != null) {
spoutHud.setXpBarLocked(true);
spoutHud.setSkillLock(skill);
spoutHud.updateXpBar();
sender.sendMessage(LocaleLoader.getString("Commands.xplock.locked", SkillUtils.getSkillName(skill)));
}
}
private void unlockXpBar(CommandSender sender) {
spoutHud.setXpBarLocked(false);
sender.sendMessage(LocaleLoader.getString("Commands.xplock.unlocked"));
}
}

View File

@@ -1052,10 +1052,10 @@ public class AdvancedConfig extends AutoUpdateConfigLoader {
public int getKrakenTriesBeforeRelease() { return config.getInt("Kraken.Tries_Before_Release", 50); }
public double getKrakenHealth() { return config.getDouble("Kraken.Health", 50.0D); }
public String getKrakenName() { return config.getString("Kraken.Name", "The Kraken"); }
public String getServerUnleashMessage() { return config.getString("Kraken.Unleashed_Message.Server", "(PLAYER) has unleashed the kraken!"); }
public String getPlayerUnleashMessage() { return config.getString("Kraken.Unleashed_Message.Player", "THE KRAKEN HAS BEEN UNLEASHED!"); }
public String getPlayerDefeatMessage() { return config.getString("Kraken.Defeated_Message.Killed", "You have slain the kraken!"); }
public String getPlayerEscapeMessage() { return config.getString("Kraken.Defeated_Message.Escape", "You have escaped from the kraken!"); }
public String getServerUnleashMessage() { return config.getString("Kraken.Unleashed_Message.Server", ""); }
public String getPlayerUnleashMessage() { return config.getString("Kraken.Unleashed_Message.Player", ""); }
public String getPlayerDefeatMessage() { return config.getString("Kraken.Defeated_Message.Killed", ""); }
public String getPlayerEscapeMessage() { return config.getString("Kraken.Defeated_Message.Escape", ""); }
public int getKrakenAttackInterval() { return config.getInt("Kraken.Attack_Interval_Seconds", 1); }
public double getKrakenAttackDamage() { return config.getDouble("Kraken.Attack_Damage", 1.0D); }
}

View File

@@ -63,7 +63,7 @@ public abstract class AutoUpdateConfigLoader extends ConfigLoader {
output = output.replace(" ", " ");
// Rip out Bukkit's attempt to save comments at the top of the file
while (output.indexOf('#') != -1) {
while (output.replaceAll("[//s]", "").startsWith("#")) {
output = output.substring(output.indexOf('\n', output.indexOf('#')) + 1);
}
@@ -90,7 +90,7 @@ public abstract class AutoUpdateConfigLoader extends ConfigLoader {
// Dump to the new one
for (String key : comments.keySet()) {
if (output.indexOf(key) != -1) {
if (output.contains(key)) {
output = output.substring(0, output.indexOf(key)) + comments.get(key) + output.substring(output.indexOf(key));
}
}

View File

@@ -75,12 +75,12 @@ public class Config extends AutoUpdateConfigLoader {
}
/* Hardcore Mode */
if (getHardcoreDeathStatPenaltyPercentage() < 1 || getHardcoreDeathStatPenaltyPercentage() > 100) {
reason.add("Hardcore.Death_Stat_Loss.Penalty_Percentage only accepts values from 1 to 100!");
if (getHardcoreDeathStatPenaltyPercentage() < 0.01 || getHardcoreDeathStatPenaltyPercentage() > 100) {
reason.add("Hardcore.Death_Stat_Loss.Penalty_Percentage only accepts values from 0.01 to 100!");
}
if (getHardcoreVampirismStatLeechPercentage() < 1 || getHardcoreVampirismStatLeechPercentage() > 100) {
reason.add("Hardcore.Vampirism.Leech_Percentage only accepts values from 1 to 100!");
if (getHardcoreVampirismStatLeechPercentage() < 0.01 || getHardcoreVampirismStatLeechPercentage() > 100) {
reason.add("Hardcore.Vampirism.Leech_Percentage only accepts values from 0.01 to 100!");
}
/* Items */
@@ -92,8 +92,8 @@ public class Config extends AutoUpdateConfigLoader {
reason.add("Items.Chimaera_Wing.Recipe_Cost only accepts values from 1 to 64!");
}
if (getChimaeraItemId() < 1) {
reason.add("Items.Chimaera_Wing.Item_ID should be at least 1!");
if (getChimaeraItem() == null) {
reason.add("Items.Chimaera_Wing.Item_Name is invalid!");
}
/* Particles */
@@ -135,21 +135,20 @@ public class Config extends AutoUpdateConfigLoader {
reason.add("Abilities.Limits.Tree_Feller_Threshold should be greater than 0!");
}
if (getDetonatorItemID() < 1) {
reason.add("Skills.Mining.Detonator_ID should be at least 1!");
if (getDetonatorItem() == null) {
reason.add("Skills.Mining.Detonator_Item is invalid!");
}
if (getRepairAnvilId() < 1) {
reason.add("Skills.Repair.Anvil_ID should be at least 1!");
if (getRepairAnvilMaterial() == null) {
reason.add("Skills.Repair.Anvil_Type is invalid!!");
}
if (getSalvageAnvilId() < 1) {
reason.add("Skills.Repair.Salvage_Anvil_ID should be at least 1!");
if (getSalvageAnvilMaterial() == null) {
reason.add("Skills.Repair.Salvage_Anvil_Type is invalid!");
}
if (getRepairAnvilId() == getSalvageAnvilId()) {
reason.add("Cannot use the same item ID for Repair and Salvage anvils!");
if (getRepairAnvilMaterial() == getSalvageAnvilMaterial()) {
reason.add("Cannot use the same item for Repair and Salvage anvils!");
}
if (getTamingCOTWWolfCost() < 1) {
@@ -191,12 +190,14 @@ public class Config extends AutoUpdateConfigLoader {
public boolean getVerboseLoggingEnabled() { return config.getBoolean("General.Verbose_Logging", false); }
public boolean getConfigOverwriteEnabled() { return config.getBoolean("General.Config_Update_Overwrite", true); }
public String getPartyChatPrefix() { return config.getString("Commands.p.Chat_Prefix_Format", "[[GREEN]]([[WHITE]]{0}[[GREEN]])"); }
public boolean getPartyChatColorLeaderName() { return config.getBoolean("Commands.p.Gold_Leader_Name", true); }
public boolean getPartyDisplayNames() { return config.getBoolean("Commands.p.Use_Display_Names", true); }
public String getPartyChatPrefix() { return config.getString("Commands.partychat.Chat_Prefix_Format", "[[GREEN]]([[WHITE]]{0}[[GREEN]])"); }
public boolean getPartyChatColorLeaderName() { return config.getBoolean("Commands.partychat.Gold_Leader_Name", true); }
public boolean getPartyDisplayNames() { return config.getBoolean("Commands.partychat.Use_Display_Names", true); }
public String getAdminChatPrefix() { return config.getString("Commands.a.Chat_Prefix_Format", "[[AQUA]][[[WHITE]]{0}[[AQUA]]]"); }
public boolean getAdminDisplayNames() { return config.getBoolean("Commands.a.Use_Display_Names", true); }
public String getAdminChatPrefix() { return config.getString("Commands.adminchat.Chat_Prefix_Format", "[[AQUA]][[[WHITE]]{0}[[AQUA]]]"); }
public boolean getAdminDisplayNames() { return config.getBoolean("Commands.adminchat.Use_Display_Names", true); }
public boolean getMatchOfflinePlayers() { return config.getBoolean("Commands.Generic.Match_OfflinePlayers", false); }
/* Mob Healthbar */
public MobHealthbarType getMobHealthbarDefault() {
@@ -235,24 +236,17 @@ public class Config extends AutoUpdateConfigLoader {
/* mySQL */
public boolean getUseMySQL() { return config.getBoolean("MySQL.Enabled", false); }
public String getMySQLTablePrefix() { return config.getString("MySQL.Database.TablePrefix", "mcmmo_"); }
public String getMySQLDatabaseName() { return getStringIncludingInts(config, "MySQL.Database.Name"); }
public String getMySQLUserName() { return getStringIncludingInts(config, "MySQL.Database.User_Name"); }
public String getMySQLDatabaseName() { return getStringIncludingInts("MySQL.Database.Name"); }
public String getMySQLUserName() { return getStringIncludingInts("MySQL.Database.User_Name"); }
public int getMySQLServerPort() { return config.getInt("MySQL.Server.Port", 3306); }
public String getMySQLServerName() { return config.getString("MySQL.Server.Address", "localhost"); }
public String getMySQLUserPassword() { return getStringIncludingInts("MySQL.Database.User_Password"); }
public String getMySQLUserPassword() {
if (getStringIncludingInts(config, "MySQL.Database.User_Password") != null) {
return getStringIncludingInts(config, "MySQL.Database.User_Password");
}
return "";
}
private static String getStringIncludingInts(ConfigurationSection cfg, String key) {
String str = cfg.getString(key);
private String getStringIncludingInts(String key) {
String str = config.getString(key);
if (str == null) {
str = String.valueOf(cfg.getInt(key));
str = String.valueOf(config.getInt(key));
}
if (str.equals("0")) {
@@ -265,13 +259,13 @@ public class Config extends AutoUpdateConfigLoader {
public boolean getHardcoreStatLossEnabled(SkillType skillType) { return config.getBoolean("Hardcore.Death_Stat_Loss.Enabled." + StringUtils.getCapitalized(skillType.toString()), false); }
public void setHardcoreStatLossEnabled(SkillType skillType, boolean enabled) { config.set("Hardcore.Death_Stat_Loss.Enabled." + StringUtils.getCapitalized(skillType.toString()), enabled); }
public double getHardcoreDeathStatPenaltyPercentage() { return config.getDouble("Hardcore.Death_Stat_Loss.Penalty_Percentage", 75.0); }
public double getHardcoreDeathStatPenaltyPercentage() { return config.getDouble("Hardcore.Death_Stat_Loss.Penalty_Percentage", 75.0D); }
public void setHardcoreDeathStatPenaltyPercentage(double value) { config.set("Hardcore.Death_Stat_Loss.Penalty_Percentage", value); }
public boolean getHardcoreVampirismEnabled(SkillType skillType) { return config.getBoolean("Hardcore.Vampirism.Enabled." + StringUtils.getCapitalized(skillType.toString()), false); }
public void setHardcoreVampirismEnabled(SkillType skillType, boolean enabled) { config.set("Hardcore.Vampirism.Enabled." + StringUtils.getCapitalized(skillType.toString()), enabled); }
public double getHardcoreVampirismStatLeechPercentage() { return config.getDouble("Hardcore.Vampirism.Leech_Percentage", 5.0); }
public double getHardcoreVampirismStatLeechPercentage() { return config.getDouble("Hardcore.Vampirism.Leech_Percentage", 5.0D); }
public void setHardcoreVampirismStatLeechPercentage(double value) { config.set("Hardcore.Vampirism.Leech_Percentage", value); }
/* SMP Mods */
@@ -283,7 +277,7 @@ public class Config extends AutoUpdateConfigLoader {
/* Items */
public int getChimaeraUseCost() { return config.getInt("Items.Chimaera_Wing.Use_Cost", 1); }
public int getChimaeraRecipeCost() { return config.getInt("Items.Chimaera_Wing.Recipe_Cost", 5); }
public int getChimaeraItemId() { return config.getInt("Items.Chimaera_Wing.Item_ID", 288); }
public Material getChimaeraItem() { return Material.matchMaterial(config.getString("Items.Chimaera_Wing.Item_Name", "Feather")); }
public boolean getChimaeraEnabled() { return config.getBoolean("Items.Chimaera_Wing.Enabled", true); }
public boolean getChimaeraPreventUseUnderground() { return config.getBoolean("Items.Chimaera_Wing.Prevent_Use_Underground", true); }
public int getChimaeraCooldown() { return config.getInt("Items.Chimaera_Wing.Cooldown", 240); }
@@ -304,11 +298,11 @@ public class Config extends AutoUpdateConfigLoader {
public int getAutoPartyKickInterval() { return config.getInt("Party.AutoKick_Interval", 12); }
public int getAutoPartyKickTime() { return config.getInt("Party.Old_Party_Member_Cutoff", 7); }
public boolean getExpShareEnabled() { return config.getBoolean("Party.Sharing.ExpShare_enabled", true); }
public double getPartyShareBonusBase() { return config.getDouble("Party.Sharing.ExpShare_bonus_base", 1.1); }
public double getPartyShareBonusIncrease() { return config.getDouble("Party.Sharing.ExpShare_bonus_increase", 0.05); }
public double getPartyShareBonusCap() { return config.getDouble("Party.Sharing.ExpShare_bonus_cap", 1.5); }
public double getPartyShareBonusBase() { return config.getDouble("Party.Sharing.ExpShare_bonus_base", 1.1D); }
public double getPartyShareBonusIncrease() { return config.getDouble("Party.Sharing.ExpShare_bonus_increase", 0.05D); }
public double getPartyShareBonusCap() { return config.getDouble("Party.Sharing.ExpShare_bonus_cap", 1.5D); }
public boolean getItemShareEnabled() { return config.getBoolean("Party.Sharing.ItemShare_enabled", true); }
public double getPartyShareRange() { return config.getDouble("Party.Sharing.Range", 75.0); }
public double getPartyShareRange() { return config.getDouble("Party.Sharing.Range", 75.0D); }
/* Party Teleport Settings */
public int getPTPCommandCooldown() { return config.getInt("Commands.ptp.Cooldown", 120); }
@@ -319,7 +313,7 @@ public class Config extends AutoUpdateConfigLoader {
public boolean getPTPCommandWorldPermissions() { return config.getBoolean("Commands.ptp.World_Based_Permissions", false); }
/* Inspect command distance */
public double getInspectDistance() { return config.getDouble("Commands.inspect.Max_Distance", 30); }
public double getInspectDistance() { return config.getDouble("Commands.inspect.Max_Distance", 30.0D); }
/*
* ABILITY SETTINGS
@@ -331,7 +325,7 @@ public class Config extends AutoUpdateConfigLoader {
public boolean getAbilitiesOnlyActivateWhenSneaking() { return config.getBoolean("Abilities.Activation.Only_Activate_When_Sneaking", false); }
public int getCooldown(AbilityType ability) { return config.getInt("Abilities.Cooldowns." + ability.toString()); }
public int getMaxTicks(AbilityType ability) { return config.getInt("Abilities.Max_Seconds." + ability.toString()); }
public int getMaxLength(AbilityType ability) { return config.getInt("Abilities.Max_Seconds." + ability.toString()); }
/* Durability Settings */
public int getAbilityToolDamage() { return config.getInt("Abilities.Tools.Durability_Loss", 2); }
@@ -368,12 +362,12 @@ public class Config extends AutoUpdateConfigLoader {
public boolean getFishingDropsEnabled() { return config.getBoolean("Skills.Fishing.Drops_Enabled", true); }
/* Mining */
public int getDetonatorItemID() { return config.getInt("Skills.Mining.Detonator_ID", 259); }
public Material getDetonatorItem() { return Material.matchMaterial(config.getString("Skills.Mining.Detonator_Name", "FLINT_AND_STEEL")); }
/* Repair */
public boolean getRepairAnvilMessagesEnabled() { return config.getBoolean("Skills.Repair.Anvil_Messages", true); }
public int getRepairAnvilId() { return config.getInt("Skills.Repair.Anvil_ID", 42); }
public int getSalvageAnvilId() { return config.getInt("Skills.Repair.Salvage_Anvil_ID", 41); }
public Material getRepairAnvilMaterial() { return Material.matchMaterial(config.getString("Skills.Repair.Anvil_Material", "IRON_BLOCK")); }
public Material getSalvageAnvilMaterial() { return Material.matchMaterial(config.getString("Skills.Repair.Salvage_Anvil_ID", "GOLD_BLOCK")); }
public boolean getSalvageTools() { return config.getBoolean("Skills.Repair.Salvage_tools", true); }
public boolean getSalvageArmor() { return config.getBoolean("Skills.Repair.Salvage_armor", true); }
public boolean getRepairConfirmRequired() { return config.getBoolean("Skills.Repair.Confirm_Required", true); }
@@ -385,7 +379,7 @@ public class Config extends AutoUpdateConfigLoader {
public int getTamingCOTWHorseCost() { return config.getInt("Skills.Taming.Call_Of_The_Wild.Apples_Required", 10); }
public int getTamingCOTWWolfCost() { return config.getInt("Skills.Taming.Call_Of_The_Wild.Bones_Required", 10); }
public int getTamingCOTWOcelotCost() { return config.getInt("Skills.Taming.Call_Of_The_Wild.Fish_Required", 10); }
public double getTamingCOTWRange() { return config.getDouble("Skills.Taming.Call_Of_The_Wild.Range", 40); }
public double getTamingCOTWRange() { return config.getDouble("Skills.Taming.Call_Of_The_Wild.Range", 40.0D); }
public int getTamingCOTWAmount(EntityType type) { return config.getInt("Skills.Taming.Call_Of_The_Wild." + StringUtils.getPrettyEntityTypeString(type)+ "_Amount"); }
/* Woodcutting */

View File

@@ -114,4 +114,8 @@ public abstract class ConfigLoader {
plugin.noErrorsInConfigFiles = false;
}
}
public File getFile() {
return configFile;
}
}

View File

@@ -1,14 +1,17 @@
package com.gmail.nossr50.config.mods;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Set;
import org.bukkit.Material;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.inventory.ItemStack;
import com.gmail.nossr50.config.ConfigLoader;
import com.gmail.nossr50.datatypes.mods.CustomItem;
import com.gmail.nossr50.skills.repair.Repair;
import com.gmail.nossr50.skills.repair.RepairItemType;
import com.gmail.nossr50.skills.repair.RepairMaterialType;
import com.gmail.nossr50.skills.repair.Repairable;
import com.gmail.nossr50.skills.repair.RepairableFactory;
@@ -17,14 +20,10 @@ public class CustomArmorConfig extends ConfigLoader {
private List<Repairable> repairables;
public List<Integer> customBootIDs = new ArrayList<Integer>();
public List<Integer> customChestplateIDs = new ArrayList<Integer>();
public List<Integer> customHelmetIDs = new ArrayList<Integer>();
public List<Integer> customLeggingIDs = new ArrayList<Integer>();
public List<Integer> customIDs = new ArrayList<Integer>();
public List<CustomItem> customArmorList = new ArrayList<CustomItem>();
public HashMap<Integer, CustomItem> customArmor = new HashMap<Integer, CustomItem>();
private List<Material> customBoots = new ArrayList<Material>();
private List<Material> customChestplates = new ArrayList<Material>();
private List<Material> customHelmets = new ArrayList<Material>();
private List<Material> customLeggings = new ArrayList<Material>();
public CustomArmorConfig() {
super("ModConfigs", "armor.yml");
@@ -51,13 +50,13 @@ public class CustomArmorConfig extends ConfigLoader {
protected void loadKeys() {
repairables = new ArrayList<Repairable>();
loadArmor("Boots", customBootIDs);
loadArmor("Chestplates", customChestplateIDs);
loadArmor("Helmets", customHelmetIDs);
loadArmor("Leggings", customLeggingIDs);
loadArmor("Boots", customBoots);
loadArmor("Chestplates", customChestplates);
loadArmor("Helmets", customHelmets);
loadArmor("Leggings", customLeggings);
}
private void loadArmor(String armorType, List<Integer> idList) {
private void loadArmor(String armorType, List<Material> materialList) {
ConfigurationSection armorSection = config.getConfigurationSection(armorType);
if (armorSection == null) {
@@ -67,35 +66,55 @@ public class CustomArmorConfig extends ConfigLoader {
Set<String> armorConfigSet = armorSection.getKeys(false);
for (String armorName : armorConfigSet) {
int id = config.getInt(armorType + "." + armorName + ".ID", 0);
boolean repairable = config.getBoolean(armorType + "." + armorName + ".Repairable");
int repairID = config.getInt(armorType + "." + armorName + ".Repair_Material_ID", 0);
byte repairData = (byte) config.getInt(armorType + "." + armorName + ".Repair_Material_Data_Value", 0);
int repairQuantity = config.getInt(armorType + "." + armorName + ".Repair_Material_Quantity", 0);
short durability = (short) config.getInt(armorType + "." + armorName + ".Durability", 0);
Material armorMaterial = Material.matchMaterial(armorName);
if (id == 0) {
plugin.getLogger().warning("Missing ID. This item will be skipped.");
if (armorMaterial == null) {
plugin.getLogger().warning("Invalid material name. This item will be skipped.");
continue;
}
if (repairable && (repairID == 0 || repairQuantity == 0 || durability == 0)) {
boolean repairable = config.getBoolean(armorType + "." + armorName + ".Repairable");
Material repairMaterial = Material.matchMaterial(config.getString(armorType + "." + armorName + ".Repair_Material", ""));
if (repairMaterial == null) {
plugin.getLogger().warning("Incomplete repair information. This item will be unrepairable.");
repairable = false;
}
CustomItem armor;
if (repairable) {
repairables.add(RepairableFactory.getRepairable(id, repairID, repairData, repairQuantity, durability));
byte repairData = (byte) config.getInt(armorType + "." + armorName + ".Repair_Material_Data_Value", -1);
int repairQuantity = Repair.getRepairAndSalvageQuantities(new ItemStack(armorMaterial), repairMaterial, repairData);
if (repairQuantity == 0) {
repairQuantity = config.getInt(armorType + "." + armorName + ".Repair_Material_Data_Quantity", 2);
}
short durability = armorMaterial.getMaxDurability();
if (durability == 0) {
durability = (short) config.getInt(armorType + "." + armorName + ".Durability", 70);
}
repairables.add(RepairableFactory.getRepairable(armorMaterial, repairMaterial, repairData, repairQuantity, 0, durability, RepairItemType.ARMOR, RepairMaterialType.OTHER, 1.0));
}
armor = new CustomItem(id, durability);
idList.add(id);
customIDs.add(id);
customArmorList.add(armor);
customArmor.put(id, armor);
materialList.add(armorMaterial);
}
}
public boolean isCustomBoots(Material material) {
return customBoots.contains(material);
}
public boolean isCustomChestplate(Material material) {
return customChestplates.contains(material);
}
public boolean isCustomHelmet(Material material) {
return customHelmets.contains(material);
}
public boolean isCustomLeggings(Material material) {
return customLeggings.contains(material);
}
}

View File

@@ -1,9 +1,11 @@
package com.gmail.nossr50.config.mods;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Set;
import org.bukkit.Material;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.inventory.ItemStack;
import org.bukkit.material.MaterialData;
@@ -14,17 +16,16 @@ import com.gmail.nossr50.datatypes.mods.CustomBlock;
public class CustomBlockConfig extends ConfigLoader {
private static CustomBlockConfig instance;
public List<ItemStack> customExcavationBlocks = new ArrayList<ItemStack>();
public List<ItemStack> customHerbalismBlocks = new ArrayList<ItemStack>();
public List<ItemStack> customMiningBlocks = new ArrayList<ItemStack>();
public List<ItemStack> customWoodcuttingBlocks = new ArrayList<ItemStack>();
public List<ItemStack> customOres = new ArrayList<ItemStack>();
public List<ItemStack> customLogs = new ArrayList<ItemStack>();
public List<ItemStack> customLeaves = new ArrayList<ItemStack>();
public List<ItemStack> customAbilityBlocks = new ArrayList<ItemStack>();
public List<ItemStack> customItems = new ArrayList<ItemStack>();
private List<MaterialData> customExcavationBlocks = new ArrayList<MaterialData>();
private List<MaterialData> customHerbalismBlocks = new ArrayList<MaterialData>();
private List<MaterialData> customMiningBlocks = new ArrayList<MaterialData>();
private List<MaterialData> customWoodcuttingBlocks = new ArrayList<MaterialData>();
private List<MaterialData> customOres = new ArrayList<MaterialData>();
private List<MaterialData> customLogs = new ArrayList<MaterialData>();
private List<MaterialData> customLeaves = new ArrayList<MaterialData>();
private List<MaterialData> customAbilityBlocks = new ArrayList<MaterialData>();
public List<CustomBlock> customBlocks = new ArrayList<CustomBlock>();
private HashMap<MaterialData, CustomBlock> customBlockMap = new HashMap<MaterialData, CustomBlock>();
public CustomBlockConfig() {
super("ModConfigs", "blocks.yml");
@@ -48,7 +49,7 @@ public class CustomBlockConfig extends ConfigLoader {
loadBlocks("Ability_Blocks", customAbilityBlocks);
}
private void loadBlocks(String skillType, List<ItemStack> blockList) {
private void loadBlocks(String skillType, List<MaterialData> blockList) {
ConfigurationSection skillSection = config.getConfigurationSection(skillType);
if (skillSection == null) {
@@ -58,63 +59,96 @@ public class CustomBlockConfig extends ConfigLoader {
Set<String> skillConfigSet = skillSection.getKeys(false);
for (String blockName : skillConfigSet) {
int id = config.getInt(skillType + "." + blockName + ".ID", 0);
byte data = (byte) config.getInt(skillType + "." + blockName + ".Data_Value", 0);
int xp = config.getInt(skillType + "." + blockName + ".XP_Gain", 0);
int tier = config.getInt(skillType + "." + blockName + ".Tier", 1);
boolean dropItem = config.getBoolean(skillType + "." + blockName + ".Drop_Item", false);
int dropID = config.getInt(skillType + "." + blockName + ".Drop_Item_ID", 0);
byte dropData = (byte) config.getInt(skillType + "." + blockName + ".Drop_Item_Data_Value", 0);
String[] blockInfo = blockName.split("[|]");
Material blockMaterial = Material.matchMaterial(blockInfo[0]);
if (blockMaterial == null) {
plugin.getLogger().warning("Invalid material name. This item will be skipped. - " + blockInfo[0]);
continue;
}
byte blockData = Byte.valueOf(blockInfo[1]);
MaterialData blockMaterialData = new MaterialData(blockMaterial, blockData);
blockList.add(blockMaterialData);
if (skillType.equals("Ability_Blocks")) {
continue;
}
int xp = config.getInt(skillType + "." + blockName + ".XP_Gain");
boolean shouldDropItem = config.getBoolean(skillType + "." + blockName + ".Drop_Item");
Material dropMaterial = Material.matchMaterial(config.getString(skillType + "." + blockName + ".Drop_Item_Name"));
if (shouldDropItem && dropMaterial == null) {
plugin.getLogger().warning("Incomplete item drop information. This block will drop itself. - " + blockInfo[0]);
shouldDropItem = false;
}
ItemStack itemDrop;
if (shouldDropItem) {
byte dropData = (byte) config.getInt(skillType + "." + blockName + ".Drop_Item_Data_Value");
itemDrop = (new MaterialData(dropMaterial, dropData)).toItemStack(1);
}
else {
itemDrop = blockMaterialData.toItemStack(1);
}
int minimumDropAmount = config.getInt(skillType + "." + blockName + ".Min_Drop_Item_Amount", 1);
int maxiumDropAmount = config.getInt(skillType + "." + blockName + ".Max_Drop_Item_Amount", 1);
CustomBlock block;
ItemStack itemDrop;
ItemStack blockItem;
if (id == 0) {
plugin.getLogger().warning("Missing ID. This block will be skipped.");
continue;
}
if (skillType.equals("Ability_Blocks")) {
blockItem = (new MaterialData(id, data)).toItemStack(1);
blockList.add(blockItem);
continue;
}
if (dropItem && dropID == 0) {
plugin.getLogger().warning("Incomplete item drop information. This block will drop itself.");
dropItem = false;
}
if (dropItem) {
itemDrop = (new MaterialData(dropID, dropData)).toItemStack(1);
}
else {
itemDrop = (new MaterialData(id, data)).toItemStack(1);
}
block = new CustomBlock(minimumDropAmount, maxiumDropAmount, itemDrop, tier, xp, data, id);
blockItem = (new MaterialData(id, data)).toItemStack(1);
if (skillType.equals("Mining") && config.getBoolean(skillType + "." + blockName + ".Is_Ore")) {
customOres.add(blockItem);
customOres.add(blockMaterialData);
}
else if (skillType.equals("Woodcutting")) {
if (config.getBoolean(skillType + "." + blockName + ".Is_Log")) {
customLogs.add(blockItem);
customLogs.add(blockMaterialData);
}
else {
customLeaves.add(blockItem);
block.setXpGain(0); // Leaves don't grant XP
customLeaves.add(blockMaterialData);
xp = 0; // Leaves don't grant XP
}
}
blockList.add(blockItem);
customItems.add(blockItem);
customBlocks.add(block);
customBlockMap.put(blockMaterialData, new CustomBlock(minimumDropAmount, maxiumDropAmount, itemDrop, xp));
}
}
public CustomBlock getCustomBlock(MaterialData data) {
return customBlockMap.get(data);
}
public boolean isCustomOre(MaterialData data) {
return customOres.contains(data);
}
public boolean isCustomLog(MaterialData data) {
return customLogs.contains(data);
}
public boolean isCustomLeaf(MaterialData data) {
return customLeaves.contains(data);
}
public boolean isCustomAbilityBlock(MaterialData data) {
return customAbilityBlocks.contains(data);
}
public boolean isCustomExcavationBlock(MaterialData data) {
return customExcavationBlocks.contains(data);
}
public boolean isCustomHerbalismBlock(MaterialData data) {
return customHerbalismBlocks.contains(data);
}
public boolean isCustomMiningBlock(MaterialData data) {
return customMiningBlocks.contains(data);
}
public boolean isCustomWoodcuttingBlock(MaterialData data) {
return customWoodcuttingBlocks.contains(data);
}
}

View File

@@ -1,26 +1,21 @@
package com.gmail.nossr50.config.mods;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import java.util.HashMap;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.entity.EntityType;
import org.bukkit.inventory.ItemStack;
import org.bukkit.Material;
import org.bukkit.entity.Entity;
import org.bukkit.material.MaterialData;
import com.gmail.nossr50.config.ConfigLoader;
import com.gmail.nossr50.datatypes.mods.CustomEntity;
import org.apache.commons.lang.ClassUtils;
public class CustomEntityConfig extends ConfigLoader {
private static CustomEntityConfig instance;
public List<Integer> customEntityIds = new ArrayList<Integer>();
public List<Integer> customHostileEntityIds = new ArrayList<Integer>();
public List<Integer> customNeutralEntityIds = new ArrayList<Integer>();
public List<Integer> customPassiveEntityIds = new ArrayList<Integer>();
public List<EntityType> customEntityTypes = new ArrayList<EntityType>();
public List<CustomEntity> customEntities = new ArrayList<CustomEntity>();
private HashMap<String, CustomEntity> customEntityClassMap = new HashMap<String, CustomEntity>();
private HashMap<String, CustomEntity> customEntityTypeMap = new HashMap<String, CustomEntity>();
public CustomEntityConfig() {
super("ModConfigs", "entities.yml");
@@ -37,48 +32,81 @@ public class CustomEntityConfig extends ConfigLoader {
@Override
protected void loadKeys() {
loadMobs("Hostile", customHostileEntityIds);
loadMobs("Neutral", customNeutralEntityIds);
loadMobs("Passive", customPassiveEntityIds);
}
for (String entityName : config.getKeys(false)) {
Class<?> clazz = null;
String className = config.getString(entityName + ".Class", "");
private void loadMobs(String entityType, List<Integer> entityIdList) {
ConfigurationSection entitySection = config.getConfigurationSection(entityType);
if (entitySection == null) {
return;
}
Set<String> entityConfigSet = entitySection.getKeys(false);
for (String entityName : entityConfigSet) {
int id = config.getInt(entityType + "." + entityName + ".ID", 0);
EntityType type = EntityType.fromId(id);
double xpMultiplier = config.getDouble(entityType + "." + entityName + ".XP_Multiplier", 1.0D);
boolean canBeTamed = config.getBoolean(entityType + "." + entityName + ".Tameable", false);
int tamingXp = config.getInt(entityType + "." + entityName + "Taming_XP", 0);
boolean canBeSummoned = config.getBoolean(entityType + "." + entityName + "CanBeSummoned", false);
int callOfTheWildId = config.getInt(entityType + "." + entityName + "COTW_Material_ID", 0);
int callOfTheWildData = config.getInt(entityType + "." + entityName + "COTW_Material_Data", 0);
int callOfTheWildAmount = config.getInt(entityType + "." + entityName + "COTW_Material_Amount", 0);
CustomEntity entity;
if (id == 0) {
plugin.getLogger().warning("Missing ID. This block will be skipped.");
continue;
try {
clazz = ClassUtils.getClass(className);
}
catch (ClassNotFoundException e) {
plugin.getLogger().warning("Invalid class (" + className + ") detected for " + entityName + ".");
plugin.getLogger().warning("This custom entity may not function properly.");
}
if (canBeSummoned && (callOfTheWildId == 0 || callOfTheWildAmount == 0)) {
plugin.getLogger().warning("Incomplete Call of the Wild information. This enitity will not be able to be summoned by Call of the Wild.");
String entityTypeName = entityName.replace("_", ".");
double xpMultiplier = config.getDouble(entityName + ".XP_Multiplier", 1.0D);
boolean canBeTamed = config.getBoolean(entityName + ".Tameable");
int tamingXp = config.getInt(entityName + ".Taming_XP");
boolean canBeSummoned = config.getBoolean(entityName + ".CanBeSummoned");
Material callOfTheWildMaterial = Material.matchMaterial(config.getString(entityName + ".COTW_Material", ""));
byte callOfTheWildData = (byte) config.getInt(entityName + ".COTW_Material_Data");
int callOfTheWildAmount = config.getInt(entityName + ".COTW_Material_Amount");
if (canBeSummoned && (callOfTheWildMaterial == null || callOfTheWildAmount == 0)) {
plugin.getLogger().warning("Incomplete Call of the Wild information. This entity will not be able to be summoned by Call of the Wild.");
canBeSummoned = false;
}
entity = new CustomEntity(id, type, xpMultiplier, canBeTamed, tamingXp, canBeSummoned, new ItemStack(callOfTheWildId, callOfTheWildData), callOfTheWildAmount);
CustomEntity entity = new CustomEntity(xpMultiplier, canBeTamed, tamingXp, canBeSummoned, (canBeSummoned ? new MaterialData(callOfTheWildMaterial, callOfTheWildData).toItemStack(1) : null), callOfTheWildAmount);
entityIdList.add(id);
customEntityTypes.add(type);
customEntities.add(entity);
customEntityTypeMap.put(entityTypeName, entity);
customEntityClassMap.put(clazz == null ? null : clazz.getName(), entity);
}
}
public boolean isCustomEntity(Entity entity) {
if (customEntityTypeMap.containsKey(entity.getType().toString())) {
return true;
}
try {
return customEntityClassMap.containsKey(((Class<?>) entity.getClass().getDeclaredField("entityClass").get(entity)).getName());
}
catch (Exception e) {
if (e instanceof NoSuchFieldException || e instanceof IllegalArgumentException || e instanceof IllegalAccessException) {
return customEntityClassMap.containsKey(entity.getClass().getName());
}
e.printStackTrace();
return false;
}
}
public CustomEntity getCustomEntity(Entity entity) {
CustomEntity customEntity = customEntityTypeMap.get(entity.getType().toString());
if (customEntity == null) {
try {
customEntity = customEntityClassMap.get(((Class<?>) entity.getClass().getDeclaredField("entityClass").get(entity)).getName());
}
catch (Exception e) {
if (e instanceof NoSuchFieldException || e instanceof IllegalArgumentException || e instanceof IllegalAccessException) {
customEntity = customEntityClassMap.get(entity.getClass().getName());
}
else {
e.printStackTrace();
}
}
}
return customEntity;
}
public void addEntity(CustomEntity customEntity, String className, String entityName) {
customEntityTypeMap.put(entityName, customEntity);
customEntityClassMap.put(className, customEntity);
}
}

View File

@@ -5,10 +5,15 @@ import java.util.HashMap;
import java.util.List;
import java.util.Set;
import org.bukkit.Material;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.inventory.ItemStack;
import com.gmail.nossr50.config.ConfigLoader;
import com.gmail.nossr50.datatypes.mods.CustomTool;
import com.gmail.nossr50.skills.repair.Repair;
import com.gmail.nossr50.skills.repair.RepairItemType;
import com.gmail.nossr50.skills.repair.RepairMaterialType;
import com.gmail.nossr50.skills.repair.Repairable;
import com.gmail.nossr50.skills.repair.RepairableFactory;
@@ -16,16 +21,14 @@ public class CustomToolConfig extends ConfigLoader {
private static CustomToolConfig instance;
private List<Repairable> repairables;
public List<Integer> customAxeIDs = new ArrayList<Integer>();
public List<Integer> customBowIDs = new ArrayList<Integer>();
public List<Integer> customHoeIDs = new ArrayList<Integer>();
public List<Integer> customPickaxeIDs = new ArrayList<Integer>();
public List<Integer> customShovelIDs = new ArrayList<Integer>();
public List<Integer> customSwordIDs = new ArrayList<Integer>();
public List<Integer> customIDs = new ArrayList<Integer>();
private List<Material> customAxes = new ArrayList<Material>();
private List<Material> customBows = new ArrayList<Material>();
private List<Material> customHoes = new ArrayList<Material>();
private List<Material> customPickaxes = new ArrayList<Material>();
private List<Material> customShovels = new ArrayList<Material>();
private List<Material> customSwords = new ArrayList<Material>();
public List<CustomTool> customToolList = new ArrayList<CustomTool>();
public HashMap<Integer, CustomTool> customTools = new HashMap<Integer, CustomTool>();
private HashMap<Material, CustomTool> customToolMap = new HashMap<Material, CustomTool>();
private CustomToolConfig() {
super("ModConfigs", "tools.yml");
@@ -52,15 +55,15 @@ public class CustomToolConfig extends ConfigLoader {
protected void loadKeys() {
repairables = new ArrayList<Repairable>();
loadTool("Axes", customAxeIDs);
loadTool("Bows", customBowIDs);
loadTool("Hoes", customHoeIDs);
loadTool("Pickaxes", customPickaxeIDs);
loadTool("Shovels", customShovelIDs);
loadTool("Swords", customSwordIDs);
loadTool("Axes", customAxes);
loadTool("Bows", customBows);
loadTool("Hoes", customHoes);
loadTool("Pickaxes", customPickaxes);
loadTool("Shovels", customShovels);
loadTool("Swords", customSwords);
}
private void loadTool(String toolType, List<Integer> idList) {
private void loadTool(String toolType, List<Material> materialList) {
ConfigurationSection toolSection = config.getConfigurationSection(toolType);
if (toolSection == null) {
@@ -70,38 +73,78 @@ public class CustomToolConfig extends ConfigLoader {
Set<String> toolConfigSet = toolSection.getKeys(false);
for (String toolName : toolConfigSet) {
int id = config.getInt(toolType + "." + toolName + ".ID", 0);
double multiplier = config.getDouble(toolType + "." + toolName + ".XP_Modifier", 1.0);
boolean abilityEnabled = config.getBoolean(toolType + "." + toolName + ".Ability_Enabled", true);
int tier = config.getInt(toolType + "." + toolName + ".Tier", 1);
boolean repairable = config.getBoolean(toolType + "." + toolName + ".Repairable");
int repairID = config.getInt(toolType + "." + toolName + ".Repair_Material_ID", 0);
byte repairData = (byte) config.getInt(toolType + "." + toolName + ".Repair_Material_Data_Value", 0);
int repairQuantity = config.getInt(toolType + "." + toolName + ".Repair_Material_Quantity", 0);
short durability = (short) config.getInt(toolType + "." + toolName + ".Durability", 0);
Material toolMaterial = Material.matchMaterial(toolName);
if (id == 0) {
plugin.getLogger().warning("Missing ID. This item will be skipped.");
if (toolMaterial == null) {
plugin.getLogger().warning("Invalid material name. This item will be skipped. - " + toolName);
continue;
}
if (repairable && (repairID == 0 || repairQuantity == 0 || durability == 0)) {
plugin.getLogger().warning("Incomplete repair information. This item will be unrepairable.");
boolean repairable = config.getBoolean(toolType + "." + toolName + ".Repairable");
Material repairMaterial = Material.matchMaterial(config.getString(toolType + "." + toolName + ".Repair_Material", ""));
if (repairMaterial == null) {
plugin.getLogger().warning("Incomplete repair information. This item will be unrepairable. - " + toolName);
repairable = false;
}
CustomTool tool;
if (repairable) {
repairables.add(RepairableFactory.getRepairable(id, repairID, repairData, repairQuantity, durability));
byte repairData = (byte) config.getInt(toolType + "." + toolName + ".Repair_Material_Data_Value", -1);
int repairQuantity = Repair.getRepairAndSalvageQuantities(new ItemStack(toolMaterial), repairMaterial, repairData);
if (repairQuantity == 0) {
repairQuantity = config.getInt(toolType + "." + toolName + ".Repair_Material_Data_Quantity", 2);
}
short durability = toolMaterial.getMaxDurability();
if (durability == 0) {
durability = (short) config.getInt(toolType + "." + toolName + ".Durability", 60);
}
repairables.add(RepairableFactory.getRepairable(toolMaterial, repairMaterial, repairData, 0, repairQuantity, durability, RepairItemType.TOOL, RepairMaterialType.OTHER, 1.0));
}
tool = new CustomTool(tier, abilityEnabled, multiplier, durability, id);
double multiplier = config.getDouble(toolType + "." + toolName + ".XP_Modifier", 1.0);
boolean abilityEnabled = config.getBoolean(toolType + "." + toolName + ".Ability_Enabled", true);
int tier = config.getInt(toolType + "." + toolName + ".Tier", 1);
idList.add(id);
customIDs.add(id);
customToolList.add(tool);
customTools.put(id, tool);
CustomTool tool = new CustomTool(tier, abilityEnabled, multiplier);
materialList.add(toolMaterial);
customToolMap.put(toolMaterial, tool);
}
}
public boolean isCustomAxe(Material material) {
return customAxes.contains(material);
}
public boolean isCustomBow(Material material) {
return customBows.contains(material);
}
public boolean isCustomHoe(Material material) {
return customHoes.contains(material);
}
public boolean isCustomPickaxe(Material material) {
return customPickaxes.contains(material);
}
public boolean isCustomShovel(Material material) {
return customShovels.contains(material);
}
public boolean isCustomSword(Material material) {
return customSwords.contains(material);
}
public boolean isCustomTool(Material material) {
return customToolMap.containsKey(material);
}
public CustomTool getCustomTool(Material material) {
return customToolMap.get(material);
}
}

View File

@@ -1,75 +0,0 @@
package com.gmail.nossr50.config.spout;
import com.gmail.nossr50.config.ConfigLoader;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.datatypes.spout.huds.HudType;
import org.getspout.spoutapi.keyboard.Keyboard;
public class SpoutConfig extends ConfigLoader {
private static SpoutConfig instance;
private SpoutConfig() {
super("spout.yml");
}
public static SpoutConfig getInstance() {
if (instance == null) {
instance = new SpoutConfig();
}
return instance;
}
@Override
protected void loadKeys() {
// Setup default HUD
}
public HudType getDefaultHudType() {
try {
return HudType.valueOf(config.getString("Spout.HUD.Default", "STANDARD").toUpperCase().trim());
}
catch (IllegalArgumentException ex) {
return HudType.STANDARD;
}
}
public boolean getShowPowerLevel() { return config.getBoolean("HUD.Show_Power_Level", true); }
public Keyboard getMenuKey() {
try {
return Keyboard.valueOf(config.getString("Menu.Key", "KEY_M").toUpperCase().trim());
}
catch (IllegalArgumentException ex) {
return Keyboard.KEY_M;
}
}
/* XP Bar */
public boolean getXPBarEnabled() { return config.getBoolean("XP.Bar.Enabled", true); }
public void setXPBarEnabled(boolean enabled) { config.set("XP.Bar.Enabled", enabled); }
public boolean getXPBarIconEnabled() { return config.getBoolean("XP.Icon.Enabled", true); }
public int getXPBarXPosition() { return config.getInt("XP.Bar.X_POS", 95); }
public int getXPBarYPosition() { return config.getInt("XP.Bar.Y_POS", 6); }
public int getXPIconXPosition() { return config.getInt("XP.Icon.X_POS", 78); }
public int getXPIconYPosition() { return config.getInt("XP.Icon.Y_POS", 2); }
/* HUD Colors */
public double getRetroHUDXPBorderRed() { return config.getDouble("HUD.Retro.Colors.Border.RED", 0.0); }
public double getRetroHUDXPBorderGreen() { return config.getDouble("HUD.Retro.Colors.Border.GREEN", 0.0); }
public double getRetroHUDXPBorderBlue() { return config.getDouble("HUD.Retro.Colors.Border.BLUE", 0.0); }
public double getRetroHUDXPBackgroundRed() { return config.getDouble("HUD.Retro.Colors.Background.RED", 0.75); }
public double getRetroHUDXPBackgroundGreen() { return config.getDouble("HUD.Retro.Colors.Background.GREEN", 0.75); }
public double getRetroHUDXPBackgroundBlue() { return config.getDouble("HUD.Retro.Colors.Background.BLUE", 0.75); }
public double getRetroHUDRed(SkillType skill) { return config.getDouble("HUD.Retro.Colors." + skill.toString().toLowerCase() +".RED", 0.3); }
public double getRetroHUDGreen(SkillType skill) { return config.getDouble("HUD.Retro.Colors." + skill.toString().toLowerCase() +".RED", 0.3); }
public double getRetroHUDBlue(SkillType skill) { return config.getDouble("HUD.Retro.Colors." + skill.toString().toLowerCase() +".RED", 0.3); }
/* Notification Tiers */
public int getNotificationTier1() { return config.getInt("Notifications.Tier1", 200); }
public int getNotificationTier2() { return config.getInt("Notifications.Tier2", 400); }
public int getNotificationTier3() { return config.getInt("Notifications.Tier3", 600); }
public int getNotificationTier4() { return config.getInt("Notifications.Tier4", 800); }
}

View File

@@ -0,0 +1,45 @@
package com.gmail.nossr50.config.tiers;
import org.bukkit.configuration.ConfigurationSection;
public class BlastMiningRank extends Rank {
private double blastDamageDecrease;
private double oreBonus;
private double debrisReduction;
private int dropMultiplier;
private double blastRadiusModifier;
public BlastMiningRank(int level, double blastDamageDecrease, double oreBonus, double debrisReduction, int dropMultiplier, double blastRadiusModifier) {
super(level);
this.blastDamageDecrease = blastDamageDecrease;
this.oreBonus = oreBonus;
this.debrisReduction = debrisReduction;
this.dropMultiplier = dropMultiplier;
this.blastRadiusModifier = blastRadiusModifier;
}
public BlastMiningRank(ConfigurationSection section) {
this(section.getInt("Level"), section.getDouble("BlastDamageDecrease"), section.getDouble("OreBonus"), section.getDouble("DebrisReduction"), section.getInt("DropMultiplier"), section.getDouble("BlastRadiusModifier"));
}
public double getBlastDamageDecrease() {
return blastDamageDecrease;
}
public double getOreBonus() {
return oreBonus;
}
public double getDebrisReduction() {
return debrisReduction;
}
public int getDropMultiplier() {
return dropMultiplier;
}
public double getBlastRadiusModifier() {
return blastRadiusModifier;
}
}

View File

@@ -0,0 +1,27 @@
package com.gmail.nossr50.config.tiers;
import org.bukkit.configuration.ConfigurationSection;
public class FishingRank extends Rank {
private double shakeChance;
private int xpBoost;
private FishingRank(int level, double shakeChance, int xpBoost) {
super(level);
this.shakeChance = shakeChance;
this.xpBoost = xpBoost;
}
public FishingRank(ConfigurationSection section) {
this(section.getInt("Level"), section.getDouble("ShakeChance"), section.getInt("VanillaXPBoost"));
}
public double getShakeChance() {
return shakeChance;
}
public int getXpBoost() {
return xpBoost;
}
}

View File

@@ -0,0 +1,13 @@
package com.gmail.nossr50.config.tiers;
public abstract class Rank {
private int level;
public Rank(int level) {
this.level = level;
}
public int getLevel() {
return level;
}
}

View File

@@ -0,0 +1,117 @@
package com.gmail.nossr50.config.tiers;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.Iterator;
import java.util.List;
import org.bukkit.configuration.ConfigurationSection;
import com.gmail.nossr50.config.ConfigLoader;
public class RankLoader extends ConfigLoader {
private List<FishingRank> fishingRanks;
private List<SmeltingRank> smeltingRanks;
private List<BlastMiningRank> blastMiningRanks;
private List<RepairRank> repairRanks;
private static RankLoader instance;
private RankLoader() {
super("ranks.yml");
fishingRanks = new ArrayList<FishingRank>();
smeltingRanks = new ArrayList<SmeltingRank>();
blastMiningRanks = new ArrayList<BlastMiningRank>();
repairRanks = new ArrayList<RepairRank>();
loadKeys();
}
public static RankLoader getInstance() {
if (instance == null) {
instance = new RankLoader();
}
return instance;
}
@Override
protected void loadKeys() {
ConfigurationSection section = config.getConfigurationSection("Ranks.Fishing");
RankComparator rankComparator = new RankComparator();
for (String rank : section.getKeys(false)) {
fishingRanks.add(new FishingRank(section.getConfigurationSection(rank)));
}
Collections.sort(fishingRanks, rankComparator);
section = config.getConfigurationSection("Ranks.BlastMining");
for (String rank : section.getKeys(false)) {
blastMiningRanks.add(new BlastMiningRank(section.getConfigurationSection(rank)));
}
Collections.sort(blastMiningRanks, rankComparator);
section = config.getConfigurationSection("Ranks.Repair");
for (String rank : section.getKeys(false)) {
repairRanks.add(new RepairRank(section.getConfigurationSection(rank)));
}
Collections.sort(repairRanks, rankComparator);
section = config.getConfigurationSection("Ranks.Smelting");
for (String rank : section.getKeys(false)) {
smeltingRanks.add(new SmeltingRank(section.getConfigurationSection(rank)));
}
Collections.sort(smeltingRanks, rankComparator);
}
public FishingRank getFishingRank(int level) {
Iterator<FishingRank> it = fishingRanks.iterator();
while (it.hasNext()) {
FishingRank rank = it.next();
if (rank.getLevel() > level) {
return rank;
}
}
return null;
}
public RepairRank getRepairRank(int level) {
Iterator<RepairRank> it = repairRanks.iterator();
while (it.hasNext()) {
RepairRank rank = it.next();
if (rank.getLevel() > level) {
return rank;
}
}
return null;
}
public SmeltingRank getSmeltingRank(int level) {
Iterator<SmeltingRank> it = smeltingRanks.iterator();
while (it.hasNext()) {
SmeltingRank rank = it.next();
if (rank.getLevel() > level) {
return rank;
}
}
return null;
}
public BlastMiningRank getBlastMiningRank(int level) {
Iterator<BlastMiningRank> it = blastMiningRanks.iterator();
while (it.hasNext()) {
BlastMiningRank rank = it.next();
if (rank.getLevel() > level) {
return rank;
}
}
return null;
}
private class RankComparator implements Comparator<Rank> {
@Override
public int compare(Rank o1, Rank o2) {
return Integer.valueOf(o1.getLevel()).compareTo(Integer.valueOf(o2.getLevel()));
}
}
}

View File

@@ -0,0 +1,27 @@
package com.gmail.nossr50.config.tiers;
import org.bukkit.configuration.ConfigurationSection;
public class RepairRank extends Rank {
private double downgradeChance;
private double keepEnchantsChance;
public RepairRank(int level, double downgradeChance, double keepEnchantsChance) {
super(level);
this.downgradeChance = downgradeChance;
this.keepEnchantsChance = keepEnchantsChance;
}
public RepairRank(ConfigurationSection section) {
this(section.getInt("Level"), section.getDouble("DowngradeChance"), section.getDouble("KeepEnchantsChance"));
}
public double getDowngradeChance() {
return downgradeChance;
}
public double getKeepEnchantsChance() {
return keepEnchantsChance;
}
}

View File

@@ -0,0 +1,21 @@
package com.gmail.nossr50.config.tiers;
import org.bukkit.configuration.ConfigurationSection;
public class SmeltingRank extends Rank {
private int xpMultiplier;
public SmeltingRank(int level, int xpMultiplier) {
super(level);
this.xpMultiplier = xpMultiplier;
}
public SmeltingRank(ConfigurationSection section) {
this(section.getInt("Level"), section.getInt("VanillaXPMultiplier"));
}
public int getXpMultiplier() {
return xpMultiplier;
}
}

View File

@@ -1,16 +1,15 @@
package com.gmail.nossr50.config.treasure;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import org.bukkit.DyeColor;
import org.bukkit.Material;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.entity.EntityType;
import org.bukkit.inventory.ItemStack;
import org.bukkit.material.MaterialData;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.material.Dye;
import org.bukkit.potion.Potion;
import org.bukkit.potion.PotionType;
@@ -19,7 +18,6 @@ import com.gmail.nossr50.datatypes.treasure.ExcavationTreasure;
import com.gmail.nossr50.datatypes.treasure.FishingTreasure;
import com.gmail.nossr50.datatypes.treasure.HylianTreasure;
import com.gmail.nossr50.datatypes.treasure.ShakeTreasure;
import com.gmail.nossr50.datatypes.treasure.Treasure;
public class TreasureConfig extends ConfigLoader {
private static TreasureConfig instance;
@@ -45,6 +43,7 @@ public class TreasureConfig extends ConfigLoader {
public List<ShakeTreasure> shakeFromCreeper = new ArrayList<ShakeTreasure>();
public List<ShakeTreasure> shakeFromEnderman = new ArrayList<ShakeTreasure>();
public List<ShakeTreasure> shakeFromGhast = new ArrayList<ShakeTreasure>();
public List<ShakeTreasure> shakeFromHorse = new ArrayList<ShakeTreasure>();
public List<ShakeTreasure> shakeFromIronGolem = new ArrayList<ShakeTreasure>();
public List<ShakeTreasure> shakeFromMagmaCube = new ArrayList<ShakeTreasure>();
public List<ShakeTreasure> shakeFromMushroomCow = new ArrayList<ShakeTreasure>();
@@ -75,47 +74,67 @@ public class TreasureConfig extends ConfigLoader {
@Override
protected void loadKeys() {
Map<String, Treasure> treasures = new HashMap<String, Treasure>();
ConfigurationSection treasureSection = config.getConfigurationSection("Treasures");
if (config.getConfigurationSection("Treasures") != null) {
plugin.getLogger().warning("You are using an old version of the treasures.yml file.");
plugin.getLogger().warning("You should delete your current file and allow a new one to generate.");
plugin.getLogger().warning("Shake, Hylian Luck, Fishing, and Excavation will not work properly until you do.");
return;
}
loadTreaures("Fishing");
loadTreaures("Excavation");
loadTreaures("Hylian_Luck");
for (EntityType entity : EntityType.values()) {
if (entity.isAlive()) {
loadTreaures("Shake." + entity.toString());
}
}
}
private void loadTreaures(String type) {
boolean isFishing = type.equals("Fishing");
boolean isShake = type.contains("Shake");
boolean isExcavation = type.equals("Excavation");
boolean isHylian = type.equals("Hylian_Luck");
ConfigurationSection treasureSection = config.getConfigurationSection(type);
if (treasureSection == null) {
return;
}
for (String treasureName : treasureSection.getKeys(false)) {
// Validate all the things!
List<String> reason = new ArrayList<String>();
/*
* ID, Amount, and Data
* Material, Amount, and Data
*/
Material material;
if (!config.contains("Treasures." + treasureName + ".ID")) {
reason.add("Missing ID");
if (treasureName.contains("POTION")) {
material = Material.POTION;
}
else if (treasureName.contains("INK_SACK")) {
material = Material.INK_SACK;
}
else {
material = Material.matchMaterial(treasureName);
}
if (!config.contains("Treasures." + treasureName + ".Amount")) {
reason.add("Missing Amount");
}
int amount = config.getInt(type + "." + treasureName + ".Amount");
int data = config.getInt(type + "." + treasureName + ".Data");
if (!config.contains("Treasures." + treasureName + ".Data")) {
reason.add("Missing Data");
}
int id = config.getInt("Treasures." + treasureName + ".ID");
int amount = config.getInt("Treasures." + treasureName + ".Amount");
int data = config.getInt("Treasures." + treasureName + ".Data");
if (Material.getMaterial(id) == null) {
reason.add("Invalid id: " + id);
if (material == null) {
reason.add("Invalid material: " + treasureName);
}
if (amount < 1) {
reason.add("Invalid amount: " + amount);
}
if (id < 256 && (data > 127 || data < -128)) {
if (material != null && material.isBlock() && (data > 127 || data < -128)) {
reason.add("Invalid data: " + data);
}
@@ -123,27 +142,15 @@ public class TreasureConfig extends ConfigLoader {
* XP, Drop Chance, and Drop Level
*/
if (!config.contains("Treasures." + treasureName + ".XP")) {
reason.add("Missing XP");
}
if (!config.contains("Treasures." + treasureName + ".Drop_Chance")) {
reason.add("Missing Drop_Chance");
}
if (!config.contains("Treasures." + treasureName + ".Drop_Level")) {
reason.add("Missing Drop_Level");
}
int xp = config.getInt("Treasures." + treasureName + ".XP");
Double dropChance = config.getDouble("Treasures." + treasureName + ".Drop_Chance");
int dropLevel = config.getInt("Treasures." + treasureName + ".Drop_Level");
int xp = config.getInt(type + "." + treasureName + ".XP");
double dropChance = config.getDouble(type + "." + treasureName + ".Drop_Chance");
int dropLevel = config.getInt(type + "." + treasureName + ".Drop_Level");
if (xp < 0) {
reason.add("Invalid xp: " + xp);
}
if (dropChance < 0) {
if (dropChance < 0.0D) {
reason.add("Invalid Drop_Chance: " + dropChance);
}
@@ -152,298 +159,190 @@ public class TreasureConfig extends ConfigLoader {
}
/*
* Potions
* Specific Types
*/
int maxLevel = 0;
if (isFishing) {
maxLevel = config.getInt(type + "." + treasureName + ".Max_Level");
if (maxLevel < -1) {
reason.add("Invalid Max_Level: " + maxLevel);
}
if (maxLevel != -1 && maxLevel < dropLevel) {
reason.add("Max_Level must be -1 or greater than Drop_Level!");
}
}
/*
* Itemstack
*/
ItemStack item = null;
if (config.contains("Treasures." + treasureName + ".Potion_Type")) {
String potionType = config.getString("Treasures." + treasureName + ".Potion_Type");
if (treasureName.contains("POTION")) {
String potionType = treasureName.substring(7);
try {
item = new Potion(PotionType.valueOf(potionType.toUpperCase())).toItemStack(amount);
item = new Potion(PotionType.valueOf(potionType.toUpperCase().trim())).toItemStack(amount);
}
catch (IllegalArgumentException ex) {
reason.add("Invalid Potion_Type: " + potionType);
}
}
else {
item = (new MaterialData(id, (byte) data)).toItemStack(amount);
}
/*
* Drops From & Max Level
*/
if (config.getBoolean("Treasures." + treasureName + ".Drops_From.Fishing", false)) {
if (config.getConfigurationSection("Treasures." + treasureName + ".Drops_From").getKeys(false).size() != 1) {
reason.add("This can only be a fishing drop.");
}
if (!config.contains("Treasures." + treasureName + ".Max_Level")) {
reason.add("Missing Max_Level");
}
int maxLevel = config.getInt("Treasures." + treasureName + ".Max_Level");
if (noErrorsInConfig(reason)) {
FishingTreasure fTreasure = new FishingTreasure(item, xp, dropChance, dropLevel, maxLevel);
treasures.put(treasureName, fTreasure);
}
}
else if (config.getBoolean("Treasures." + treasureName + ".Drops_From.Shake", false)) {
if (config.getConfigurationSection("Treasures." + treasureName + ".Drops_From").getKeys(false).size() != 1) {
reason.add("This can only be a shake drop.");
}
if (!config.contains("Treasures." + treasureName + ".Mob")) {
reason.add("Missing Mob");
}
String mobType = config.getString("Treasures." + treasureName + ".Mob");
EntityType mob = null;
else if (treasureName.contains("INK_SACK")) {
String color = treasureName.substring(9);
try {
mob = EntityType.valueOf(mobType.toUpperCase().trim());
}
catch (IllegalArgumentException ex){
reason.add("Invalid Mob: " + mobType);
}
Dye dye = new Dye();
dye.setColor(DyeColor.valueOf(color.toUpperCase().trim()));
if (noErrorsInConfig(reason)) {
ShakeTreasure sTreasure = new ShakeTreasure(item, xp, dropChance, dropLevel, mob);
treasures.put(treasureName, sTreasure);
item = dye.toItemStack(amount);
}
catch (IllegalArgumentException ex) {
reason.add("Invalid Dye_Color: " + color);
}
}
else {
ExcavationTreasure eTreasure = new ExcavationTreasure(item, xp, dropChance, dropLevel);
HylianTreasure hTreasure = new HylianTreasure(item, xp, dropChance, dropLevel);
else if (material != null) {
item = new ItemStack(material, amount, (short) data);
if (config.getBoolean("Treasures." + treasureName + ".Drops_From.Dirt", false)) {
eTreasure.setDropsFromDirt();
if (config.contains(type + "." + treasureName + ".Custom_Name")) {
ItemMeta itemMeta = item.getItemMeta();
itemMeta.setDisplayName(config.getString(type + "." + treasureName + "Custom_Name"));
item.setItemMeta(itemMeta);
}
if (config.getBoolean("Treasures." + treasureName + ".Drops_From.Grass", false)) {
eTreasure.setDropsFromGrass();
}
if (config.getBoolean("Treasures." + treasureName + ".Drops_From.Sand", false)) {
eTreasure.setDropsFromSand();
}
if (config.getBoolean("Treasures." + treasureName + ".Drops_From.Gravel", false)) {
eTreasure.setDropsFromGravel();
}
if (config.getBoolean("Treasures." + treasureName + ".Drops_From.Clay", false)) {
eTreasure.setDropsFromClay();
}
if (config.getBoolean("Treasures." + treasureName + ".Drops_From.Mycelium", false)) {
eTreasure.setDropsFromMycel();
}
if (config.getBoolean("Treasures." + treasureName + ".Drops_From.Soul_Sand", false)) {
eTreasure.setDropsFromSoulSand();
}
if (config.getBoolean("Treasures." + treasureName + ".Drops_From.Snow", false)) {
eTreasure.setDropsFromSnow();
}
if (config.getBoolean("Treasures." + treasureName + ".Drops_From.Bushes", false)) {
hTreasure.setDropsFromBushes();
}
if (config.getBoolean("Treasures." + treasureName + ".Drops_From.Flowers", false)) {
hTreasure.setDropsFromFlowers();
}
if (config.getBoolean("Treasures." + treasureName + ".Drops_From.Pots", false)) {
hTreasure.setDropsFromPots();
}
if (config.getBoolean("Treasures." + treasureName + ".Drops_From.Fishing", false)) {
reason.add("This cannot also be a fishing drop.");
}
if (config.getBoolean("Treasures." + treasureName + ".Drops_From.Shake", false)) {
reason.add("This cannot also be a shake drop.");
}
if (noErrorsInConfig(reason) && hTreasure.getDropsFrom() == (byte) 0x0) {
treasures.put(treasureName, eTreasure);
}
else if (noErrorsInConfig(reason) && eTreasure.getDropsFrom() == (byte) 0x0) {
treasures.put(treasureName, hTreasure);
if (config.contains(type + "." + treasureName + ".Lore")) {
ItemMeta itemMeta = item.getItemMeta();
itemMeta.setLore(config.getStringList(type + "." + treasureName + "Custom_Name"));
item.setItemMeta(itemMeta);
}
}
}
List<String> excavationTreasures = config.getStringList("Excavation.Treasure");
List<String> fishingTreasures = config.getStringList("Fishing.Treasure");
List<String> hylianTreasures = config.getStringList("Hylian_Luck.Treasure");
List<String> shakeTreasures = config.getStringList("Shake.Treasure");
for (Entry<String, Treasure> nextEntry : treasures.entrySet()) {
String treasureKey = nextEntry.getKey();
Treasure treasure = nextEntry.getValue();
if (treasure instanceof FishingTreasure) {
if (fishingTreasures == null || !fishingTreasures.contains(treasureKey)) {
continue;
if (noErrorsInConfig(reason)) {
if (isFishing) {
fishingRewards.add(new FishingTreasure(item, xp, dropChance, dropLevel, maxLevel));
}
else if (isShake) {
ShakeTreasure shakeTreasure = new ShakeTreasure(item, xp, dropChance, dropLevel);
fishingRewards.add((FishingTreasure) treasure);
}
else if (treasure instanceof ShakeTreasure) {
if (shakeTreasures == null || !shakeTreasures.contains(treasureKey)) {
continue;
if (type.equals("Shake.BLAZE")) {
shakeFromBlaze.add(shakeTreasure);
}
else if (type.equals("Shake.CAVE_SPIDER")) {
shakeFromCaveSpider.add(shakeTreasure);
}
else if (type.equals("Shake.CHICKEN")) {
shakeFromChicken.add(shakeTreasure);
}
else if (type.equals("Shake.COW")) {
shakeFromCow.add(shakeTreasure);
}
else if (type.equals("Shake.CREEPER")) {
shakeFromCreeper.add(shakeTreasure);
}
else if (type.equals("Shake.ENDERMAN")) {
shakeFromEnderman.add(shakeTreasure);
}
else if (type.equals("Shake.GHAST")) {
shakeFromGhast.add(shakeTreasure);
}
else if (type.equals("Shake.HORSE")) {
shakeFromHorse.add(shakeTreasure);
}
else if (type.equals("Shake.IRON_GOLEM")) {
shakeFromIronGolem.add(shakeTreasure);
}
else if (type.equals("Shake.MAGMA_CUBE")) {
shakeFromMagmaCube.add(shakeTreasure);
}
else if (type.equals("Shake.MUSHROOM_COW")) {
shakeFromMushroomCow.add(shakeTreasure);
}
else if (type.equals("Shake.PIG")) {
shakeFromPig.add(shakeTreasure);
}
else if (type.equals("Shake.PIG_ZOMBIE")) {
shakeFromPigZombie.add(shakeTreasure);
}
else if (type.equals("Shake.SHEEP")) {
shakeFromSheep.add(shakeTreasure);
}
else if (type.equals("Shake.SKELETON")) {
shakeFromSkeleton.add(shakeTreasure);
}
else if (type.equals("Shake.SLIME")) {
shakeFromSlime.add(shakeTreasure);
}
else if (type.equals("Shake.SPIDER")) {
shakeFromSpider.add(shakeTreasure);
}
else if (type.equals("Shake.SNOWMAN")) {
shakeFromSnowman.add(shakeTreasure);
}
else if (type.equals("Shake.SQUID")) {
shakeFromSquid.add(shakeTreasure);
}
else if (type.equals("Shake.WITCH")) {
shakeFromWitch.add(shakeTreasure);
}
else if (type.equals("Shake.ZOMBIE")) {
shakeFromZombie.add(shakeTreasure);
}
}
else if (isExcavation) {
ExcavationTreasure excavationTreasure = new ExcavationTreasure(item, xp, dropChance, dropLevel);
List<String> dropList = config.getStringList(type + "." + treasureName + ".Drops_From");
ShakeTreasure e = (ShakeTreasure) treasure;
switch (e.getMob()) {
case BLAZE:
shakeFromBlaze.add(e);
break;
if (dropList.contains("Dirt")) {
excavationFromDirt.add(excavationTreasure);
}
case CAVE_SPIDER:
shakeFromCaveSpider.add(e);
break;
if (dropList.contains("Grass")) {
excavationFromGrass.add(excavationTreasure);
}
case CHICKEN:
shakeFromChicken.add(e);
break;
if (dropList.contains("Sand")) {
excavationFromSand.add(excavationTreasure);
}
case COW:
shakeFromCow.add(e);
break;
if (dropList.contains("Gravel")) {
excavationFromGravel.add(excavationTreasure);
}
case CREEPER:
shakeFromCreeper.add(e);
break;
if (dropList.contains("Clay")) {
excavationFromClay.add(excavationTreasure);
}
case ENDERMAN:
shakeFromEnderman.add(e);
break;
if (dropList.contains("Mycelium")) {
excavationFromMycel.add(excavationTreasure);
}
case GHAST:
shakeFromGhast.add(e);
break;
if (dropList.contains("Soul_Sand")) {
excavationFromSoulSand.add(excavationTreasure);
}
case IRON_GOLEM:
shakeFromIronGolem.add(e);
break;
case MAGMA_CUBE:
shakeFromMagmaCube.add(e);
break;
case MUSHROOM_COW:
shakeFromMushroomCow.add(e);
break;
case PIG:
shakeFromPig.add(e);
break;
case PIG_ZOMBIE:
shakeFromPigZombie.add(e);
break;
case SHEEP:
shakeFromSheep.add(e);
break;
case SKELETON:
shakeFromSkeleton.add(e);
break;
case SLIME:
shakeFromSlime.add(e);
break;
case SPIDER:
shakeFromSpider.add(e);
break;
case SNOWMAN:
shakeFromSnowman.add(e);
break;
case SQUID:
shakeFromSquid.add(e);
break;
case WITCH:
shakeFromWitch.add(e);
break;
case ZOMBIE:
shakeFromZombie.add(e);
break;
default:
break;
}
}
else if (treasure instanceof HylianTreasure) {
if (hylianTreasures == null || !hylianTreasures.contains(treasureKey)) {
continue;
if (dropList.contains("Snow")) {
excavationFromSnow.add(excavationTreasure);
}
}
else if (isHylian) {
HylianTreasure hylianTreasure = new HylianTreasure(item, xp, dropChance, dropLevel);
List<String> dropList = config.getStringList(type + "." + treasureName + ".Drops_From");
HylianTreasure hTreasure = (HylianTreasure) treasure;
if (dropList.contains("Bushes")) {
hylianFromBushes.add(hylianTreasure);
}
if (hTreasure.getDropsFromBushes()) {
hylianFromBushes.add(hTreasure);
}
if (dropList.contains("Flowers")) {
hylianFromFlowers.add(hylianTreasure);
}
if (hTreasure.getDropsFromFlowers()) {
hylianFromFlowers.add(hTreasure);
}
if (hTreasure.getDropsFromPots()) {
hylianFromPots.add(hTreasure);
}
}
else if (treasure instanceof ExcavationTreasure) {
if (excavationTreasures == null || !excavationTreasures.contains(treasureKey)) {
continue;
}
ExcavationTreasure eTreasure = (ExcavationTreasure) treasure;
if (eTreasure.getDropsFromDirt()) {
excavationFromDirt.add(eTreasure);
}
if (eTreasure.getDropsFromGrass()) {
excavationFromGrass.add(eTreasure);
}
if (eTreasure.getDropsFromSand()) {
excavationFromSand.add(eTreasure);
}
if (eTreasure.getDropsFromGravel()) {
excavationFromGravel.add(eTreasure);
}
if (eTreasure.getDropsFromClay()) {
excavationFromClay.add(eTreasure);
}
if (eTreasure.getDropsFromMycel()) {
excavationFromMycel.add(eTreasure);
}
if (eTreasure.getDropsFromSoulSand()) {
excavationFromSoulSand.add(eTreasure);
}
if (eTreasure.getDropsFromSnow()) {
excavationFromSnow.add(eTreasure);
if (dropList.contains("Pots")) {
hylianFromPots.add(hylianTreasure);
}
}
}
}
}
}
}

View File

@@ -26,7 +26,6 @@ import com.gmail.nossr50.datatypes.database.PlayerStat;
import com.gmail.nossr50.datatypes.player.PlayerProfile;
import com.gmail.nossr50.datatypes.skills.AbilityType;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.datatypes.spout.huds.HudType;
import com.gmail.nossr50.util.Misc;
public final class FlatfileDatabaseManager implements DatabaseManager {
@@ -259,8 +258,7 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
writer.append((int) profile.getSkillDATS(AbilityType.SERRATED_STRIKES)).append(":");
writer.append((int) profile.getSkillDATS(AbilityType.SKULL_SPLITTER)).append(":");
writer.append((int) profile.getSkillDATS(AbilityType.SUPER_BREAKER)).append(":");
HudType hudType = profile.getHudType();
writer.append(hudType == null ? "STANDARD" : hudType.toString()).append(":");
writer.append(":");
writer.append(profile.getSkillLevel(SkillType.FISHING)).append(":");
writer.append(profile.getSkillXpLevel(SkillType.FISHING)).append(":");
writer.append((int) profile.getSkillDATS(AbilityType.BLAST_MINING)).append(":");
@@ -348,7 +346,7 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
out.append("0:"); // DATS
out.append("0:"); // DATS
out.append("0:"); // DATS
out.append("STANDARD").append(":"); // HUD
out.append(":");
out.append("0:"); // Fishing
out.append("0:"); // FishingXp
out.append("0:"); // Blast Mining
@@ -579,6 +577,11 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
HashSet<String> players = new HashSet<String>();
while ((line = in.readLine()) != null) {
// Remove empty lines from the file
if (line.isEmpty()) {
continue;
}
// Length checks depend on last character being ':'
if (line.charAt(line.length() - 1) != ':') {
line = line + ":";
@@ -590,70 +593,81 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
continue;
}
if (character.length < 33) {
// Before Version 1.0 - Drop
mcMMO.p.getLogger().warning("Dropping malformed or before version 1.0 line from database - " + line);
continue;
}
String oldVersion = null;
if (!character[33].isEmpty()) {
// Removal of Spout Support
// Version 1.4.07-dev2
// commit 7bac0e2ca5143bce84dc160617fed97f0b1cb968
line = line.replace(character[33], "");
oldVersion = "1.4.07";
}
// If they're valid, rewrite them to the file.
if (character.length > 38) {
writer.append(line).append("\r\n");
continue;
}
else if (character.length < 33) {
// Before Version 1.0 - Drop
mcMMO.p.getLogger().warning("Dropping malformed or before version 1.0 line from database - " + line);
}
else {
String oldVersion = null;
StringBuilder newLine = new StringBuilder(line);
boolean announce = false;
if (character.length <= 33) {
// Introduction of HUDType
// Version 1.1.06
// commit 78f79213cdd7190cd11ae54526f3b4ea42078e8a
newLine.append("STANDARD").append(":");
oldVersion = "1.1.06";
}
if (character.length <= 35) {
// Introduction of Fishing
// Version 1.2.00
// commit a814b57311bc7734661109f0e77fc8bab3a0bd29
newLine.append(0).append(":");
newLine.append(0).append(":");
if (oldVersion == null) {
oldVersion = "1.2.00";
}
}
if (character.length <= 36) {
// Introduction of Blast Mining cooldowns
// Version 1.3.00-dev
// commit fadbaf429d6b4764b8f1ad0efaa524a090e82ef5
newLine.append(0).append(":");
if (oldVersion == null) {
oldVersion = "1.3.00";
}
}
if (character.length <= 37) {
// Making old-purge work with flatfile
// Version 1.4.00-dev
// commmit 3f6c07ba6aaf44e388cc3b882cac3d8f51d0ac28
// XXX Cannot create an OfflinePlayer at startup, use 0 and fix in purge
newLine.append("0").append(":");
announce = true; // TODO move this down
if (oldVersion == null) {
oldVersion = "1.4.00";
}
}
if (character.length <= 38) {
// Addition of mob healthbars
// Version 1.4.06
// commit da29185b7dc7e0d992754bba555576d48fa08aa6
newLine.append(Config.getInstance().getMobHealthbarDefault().toString()).append(":");
if (oldVersion == null) {
oldVersion = "1.4.06";
}
}
if (announce) {
mcMMO.p.debug("Updating database line for player " + character[0] + " from before version " + oldVersion);
}
writer.append(newLine).append("\r\n");
StringBuilder newLine = new StringBuilder(line);
if (character.length <= 33) {
// Introduction of HUDType
// Version 1.1.06
// commit 78f79213cdd7190cd11ae54526f3b4ea42078e8a
newLine.append(":");
oldVersion = "1.1.06";
}
if (character.length <= 35) {
// Introduction of Fishing
// Version 1.2.00
// commit a814b57311bc7734661109f0e77fc8bab3a0bd29
newLine.append(0).append(":");
newLine.append(0).append(":");
if (oldVersion == null) {
oldVersion = "1.2.00";
}
}
if (character.length <= 36) {
// Introduction of Blast Mining cooldowns
// Version 1.3.00-dev
// commit fadbaf429d6b4764b8f1ad0efaa524a090e82ef5
newLine.append(0).append(":");
if (oldVersion == null) {
oldVersion = "1.3.00";
}
}
if (character.length <= 37) {
// Making old-purge work with flatfile
// Version 1.4.00-dev
// commmit 3f6c07ba6aaf44e388cc3b882cac3d8f51d0ac28
// XXX Cannot create an OfflinePlayer at startup, use 0 and fix in purge
newLine.append("0").append(":");
if (oldVersion == null) {
oldVersion = "1.4.00";
}
}
if (character.length <= 38) {
// Addition of mob healthbars
// Version 1.4.06
// commit da29185b7dc7e0d992754bba555576d48fa08aa6
newLine.append(Config.getInstance().getMobHealthbarDefault().toString()).append(":");
if (oldVersion == null) {
oldVersion = "1.4.06";
}
}
if (oldVersion != null) {
mcMMO.p.debug("Updating database line for player " + character[0] + " from before version " + oldVersion);
}
writer.append(newLine).append("\r\n");
}
// Write the new file
@@ -728,7 +742,6 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
Map<SkillType, Integer> skills = getSkillMapFromLine(character); // Skill levels
Map<SkillType, Float> skillsXp = new HashMap<SkillType, Float>(); // Skill & XP
Map<AbilityType, Integer> skillsDATS = new HashMap<AbilityType, Integer>(); // Ability & Cooldown
HudType hudType;
MobHealthbarType mobHealthbarType;
// TODO on updates, put new values in a try{} ?
@@ -759,13 +772,6 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
// Acrobatics - Unused
skillsDATS.put(AbilityType.BLAST_MINING, Integer.valueOf(character[36]));
try {
hudType = HudType.valueOf(character[33]);
}
catch (Exception e) {
hudType = HudType.STANDARD; // Shouldn't happen unless database is being tampered with
}
try {
mobHealthbarType = MobHealthbarType.valueOf(character[38]);
}
@@ -773,7 +779,7 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
mobHealthbarType = Config.getInstance().getMobHealthbarDefault();
}
return new PlayerProfile(character[0], skills, skillsXp, skillsDATS, hudType, mobHealthbarType);
return new PlayerProfile(character[0], skills, skillsXp, skillsDATS, mobHealthbarType);
}
private Map<SkillType, Integer> getSkillMapFromLine(String[] character) {

View File

@@ -23,7 +23,6 @@ import com.gmail.nossr50.datatypes.database.PlayerStat;
import com.gmail.nossr50.datatypes.player.PlayerProfile;
import com.gmail.nossr50.datatypes.skills.AbilityType;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.datatypes.spout.huds.HudType;
import com.gmail.nossr50.runnables.database.SQLReconnectTask;
import com.gmail.nossr50.util.Misc;
@@ -129,10 +128,9 @@ public final class SQLDatabaseManager implements DatabaseManager {
}
}
MobHealthbarType mobHealthbarType = profile.getMobHealthbarType();
HudType hudType = profile.getHudType();
saveLogin(userId, ((int) (System.currentTimeMillis() / Misc.TIME_CONVERSION_FACTOR)));
saveHuds(userId, (hudType == null ? "STANDARD" : hudType.toString()), (mobHealthbarType == null ? Config.getInstance().getMobHealthbarDefault().toString() : mobHealthbarType.toString()));
saveHuds(userId, (mobHealthbarType == null ? Config.getInstance().getMobHealthbarDefault().toString() : mobHealthbarType.toString()));
saveLongs(
"UPDATE " + tablePrefix + "cooldowns SET "
+ " mining = ?, woodcutting = ?, unarmed = ?"
@@ -357,7 +355,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
+ "s.taming, s.mining, s.repair, s.woodcutting, s.unarmed, s.herbalism, s.excavation, s.archery, s.swords, s.axes, s.acrobatics, s.fishing, "
+ "e.taming, e.mining, e.repair, e.woodcutting, e.unarmed, e.herbalism, e.excavation, e.archery, e.swords, e.axes, e.acrobatics, e.fishing, "
+ "c.taming, c.mining, c.repair, c.woodcutting, c.unarmed, c.herbalism, c.excavation, c.archery, c.swords, c.axes, c.acrobatics, c.blast_mining, "
+ "h.hudtype, h.mobhealthbar "
+ "h.mobhealthbar "
+ "FROM " + tablePrefix + "users u "
+ "JOIN " + tablePrefix + "skills s ON (u.id = s.user_id) "
+ "JOIN " + tablePrefix + "experience e ON (u.id = e.user_id) "
@@ -425,7 +423,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
+ "s.taming, s.mining, s.repair, s.woodcutting, s.unarmed, s.herbalism, s.excavation, s.archery, s.swords, s.axes, s.acrobatics, s.fishing, "
+ "e.taming, e.mining, e.repair, e.woodcutting, e.unarmed, e.herbalism, e.excavation, e.archery, e.swords, e.axes, e.acrobatics, e.fishing, "
+ "c.taming, c.mining, c.repair, c.woodcutting, c.unarmed, c.herbalism, c.excavation, c.archery, c.swords, c.axes, c.acrobatics, c.blast_mining, "
+ "h.hudtype, h.mobhealthbar "
+ "h.mobhealthbar "
+ "FROM " + tablePrefix + "users u "
+ "JOIN " + tablePrefix + "skills s ON (u.id = s.user_id) "
+ "JOIN " + tablePrefix + "experience e ON (u.id = e.user_id) "
@@ -634,7 +632,6 @@ public final class SQLDatabaseManager implements DatabaseManager {
+ "UNIQUE KEY `user` (`user`)) DEFAULT CHARSET=latin1 AUTO_INCREMENT=1;");
write("CREATE TABLE IF NOT EXISTS `" + tablePrefix + "huds` ("
+ "`user_id` int(10) unsigned NOT NULL,"
+ "`hudtype` varchar(50) NOT NULL DEFAULT 'STANDARD',"
+ "`mobhealthbar` varchar(50) NOT NULL DEFAULT '" + Config.getInstance().getMobHealthbarDefault() + "',"
+ "PRIMARY KEY (`user_id`)) "
+ "DEFAULT CHARSET=latin1;");
@@ -735,6 +732,10 @@ public final class SQLDatabaseManager implements DatabaseManager {
write("ALTER TABLE `" + tablePrefix + "users` DROP COLUMN `party` ;");
return;
case DROPPED_SPOUT:
write("ALTER TABLE `" + tablePrefix + "huds` DROP COLUMN `hudtype` ;");
return;
case KILL_ORPHANS:
mcMMO.p.getLogger().info("Killing orphans");
write(
@@ -841,7 +842,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
return true;
}
catch (SQLException ex) {
if (!sql.equalsIgnoreCase("ALTER TABLE `" + tablePrefix + "users` DROP COLUMN `party` ;")) {
if (!sql.contains("DROP COLUMN")) {
printErrors(ex);
}
return false;
@@ -1121,14 +1122,13 @@ public final class SQLDatabaseManager implements DatabaseManager {
}
}
private void saveHuds(int userId, String hudType, String mobHealthBar) {
private void saveHuds(int userId, String mobHealthBar) {
PreparedStatement statement = null;
try {
statement = connection.prepareStatement("UPDATE " + tablePrefix + "huds SET hudtype = ?, mobhealthbar = ? WHERE user_id = ?");
statement.setString(1, hudType);
statement.setString(2, mobHealthBar);
statement.setInt(3, userId);
statement = connection.prepareStatement("UPDATE " + tablePrefix + "huds SET mobhealthbar = ? WHERE user_id = ?");
statement.setString(1, mobHealthBar);
statement.setInt(2, userId);
statement.execute();
}
catch (SQLException ex) {
@@ -1150,7 +1150,6 @@ public final class SQLDatabaseManager implements DatabaseManager {
Map<SkillType, Integer> skills = new HashMap<SkillType, Integer>(); // Skill & Level
Map<SkillType, Float> skillsXp = new HashMap<SkillType, Float>(); // Skill & XP
Map<AbilityType, Integer> skillsDATS = new HashMap<AbilityType, Integer>(); // Ability & Cooldown
HudType hudType;
MobHealthbarType mobHealthbarType;
final int OFFSET_SKILLS = 0; // TODO update these numbers when the query changes (a new skill is added)
@@ -1197,13 +1196,6 @@ public final class SQLDatabaseManager implements DatabaseManager {
// Acrobatics - Unused - result.getInt(OFFSET_DATS + 11)
skillsDATS.put(AbilityType.BLAST_MINING, result.getInt(OFFSET_DATS + 12));
try {
hudType = HudType.valueOf(result.getString(OFFSET_OTHER + 1));
}
catch (Exception e) {
hudType = HudType.STANDARD; // Shouldn't happen unless database is being tampered with
}
try {
mobHealthbarType = MobHealthbarType.valueOf(result.getString(OFFSET_OTHER + 2));
}
@@ -1211,7 +1203,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
mobHealthbarType = Config.getInstance().getMobHealthbarDefault();
}
return new PlayerProfile(playerName, skills, skillsXp, skillsDATS, hudType, mobHealthbarType);
return new PlayerProfile(playerName, skills, skillsXp, skillsDATS, mobHealthbarType);
}
private void printErrors(SQLException ex) {

View File

@@ -5,7 +5,8 @@ public enum DatabaseUpdateType {
BLAST_MINING,
INDEX,
MOB_HEALTHBARS,
PARTY_NAMES,
PARTY_NAMES,
KILL_ORPHANS,
DROPPED_SPOUT
;
}

View File

@@ -3,77 +3,31 @@ package com.gmail.nossr50.datatypes.mods;
import org.bukkit.inventory.ItemStack;
public class CustomBlock {
private int itemID;
private byte dataValue;
private int xpGain;
private int tier;
private ItemStack itemDrop;
private int minimumDropAmount;
private int maximumDropAmount;
public CustomBlock(int minimumDropAmount, int maximumDropAmount, ItemStack itemDrop, int tier, int xpGain, byte dataValue, int itemID) {
this.itemID = itemID;
this.dataValue = dataValue;
public CustomBlock(int minimumDropAmount, int maximumDropAmount, ItemStack itemDrop, int xpGain) {
this.xpGain = xpGain;
this.tier = tier;
this.itemDrop = itemDrop;
this.minimumDropAmount = minimumDropAmount;
this.maximumDropAmount = maximumDropAmount;
}
public int getItemID() {
return itemID;
}
public void setItemID(int itemID) {
this.itemID = itemID;
}
public byte getDataValue() {
return dataValue;
}
public void setDataValue(byte dataValue) {
this.dataValue = dataValue;
}
public int getXpGain() {
return xpGain;
}
public void setXpGain(int xpGain) {
this.xpGain = xpGain;
}
public int getTier() {
return tier;
}
public void setTier(int tier) {
this.tier = tier;
}
public ItemStack getItemDrop() {
return itemDrop;
}
public void setItemDrop(ItemStack itemDrop) {
this.itemDrop = itemDrop;
}
public int getMinimumDropAmount() {
return minimumDropAmount;
}
public void setMinimumDropAmount(int minimumDropAmount) {
this.minimumDropAmount = minimumDropAmount;
}
public int getMaximumDropAmount() {
return maximumDropAmount;
}
public void setMaximumDropAmount(int maximumDropAmount) {
this.maximumDropAmount = maximumDropAmount;
}
}

View File

@@ -1,11 +1,8 @@
package com.gmail.nossr50.datatypes.mods;
import org.bukkit.entity.EntityType;
import org.bukkit.inventory.ItemStack;
public class CustomEntity {
private int entityID;
private EntityType entityType;
private double xpMultiplier;
private boolean canBeTamed;
private int tamingXP;
@@ -13,9 +10,7 @@ public class CustomEntity {
private ItemStack callOfTheWildItem;
private int callOfTheWildAmount;
public CustomEntity(int entityID, EntityType entityType, double xpMultiplier, boolean canBeTamed, int tamingXP, boolean canBeSummoned, ItemStack callOfTheWildItem, int callOfTheWildAmount) {
this.entityID = entityID;
this.entityType = entityType;
public CustomEntity(double xpMultiplier, boolean canBeTamed, int tamingXP, boolean canBeSummoned, ItemStack callOfTheWildItem, int callOfTheWildAmount) {
this.xpMultiplier = xpMultiplier;
this.canBeTamed = canBeTamed;
this.tamingXP = tamingXP;
@@ -24,67 +19,27 @@ public class CustomEntity {
this.callOfTheWildAmount = callOfTheWildAmount;
}
public int getEntityID() {
return entityID;
}
public void setEntityID(int entityID) {
this.entityID = entityID;
}
public EntityType getEntityType() {
return entityType;
}
public void setEntityType(EntityType entityType) {
this.entityType = entityType;
}
public double getXpMultiplier() {
return xpMultiplier;
}
public void setXpMultiplier(double xpMultiplier) {
this.xpMultiplier = xpMultiplier;
}
public boolean isCanBeTamed() {
public boolean canBeTamed() {
return canBeTamed;
}
public void setCanBeTamed(boolean canBeTamed) {
this.canBeTamed = canBeTamed;
}
public int getTamingXP() {
return tamingXP;
}
public void setTamingXP(int tamingXP) {
this.tamingXP = tamingXP;
}
public boolean isCanBeSummoned() {
public boolean canBeSummoned() {
return canBeSummoned;
}
public void setCanBeSummoned(boolean canBeSummoned) {
this.canBeSummoned = canBeSummoned;
}
public ItemStack getCallOfTheWildItem() {
return callOfTheWildItem;
}
public void setCallOfTheWildItem(ItemStack callOfTheWildItem) {
this.callOfTheWildItem = callOfTheWildItem;
}
public int getCallOfTheWildAmount() {
return callOfTheWildAmount;
}
public void setCallOfTheWildAmount(int callOfTheWildAmount) {
this.callOfTheWildAmount = callOfTheWildAmount;
}
}

View File

@@ -1,27 +0,0 @@
package com.gmail.nossr50.datatypes.mods;
public class CustomItem {
protected int itemID;
protected short durability;
public CustomItem(int itemID, short durability) {
this.itemID = itemID;
this.durability = durability;
}
public int getItemID() {
return itemID;
}
public void setItemID(int itemID) {
this.itemID = itemID;
}
public short getDurability() {
return durability;
}
public void setDurability(short durability) {
this.durability = durability;
}
}

View File

@@ -1,12 +1,11 @@
package com.gmail.nossr50.datatypes.mods;
public class CustomTool extends CustomItem {
public class CustomTool {
private double xpMultiplier;
private boolean abilityEnabled;
private int tier;
public CustomTool(int tier, boolean abilityEnabled, double xpMultiplier, short durability, int itemID) {
super(itemID, durability);
public CustomTool(int tier, boolean abilityEnabled, double xpMultiplier) {
this.xpMultiplier = xpMultiplier;
this.abilityEnabled = abilityEnabled;
this.tier = tier;
@@ -16,23 +15,11 @@ public class CustomTool extends CustomItem {
return xpMultiplier;
}
public void setXpMultiplier(Double xpMultiplier) {
this.xpMultiplier = xpMultiplier;
}
public boolean isAbilityEnabled() {
return abilityEnabled;
}
public void setAbilityEnabled(boolean abilityEnabled) {
this.abilityEnabled = abilityEnabled;
}
public int getTier() {
return tier;
}
public void setTier(int tier) {
this.tier = tier;
}
}

View File

@@ -67,14 +67,14 @@ public class Party {
return onlineMembers;
}
public String getLeader() {
return leader;
}
public String getName() {
return name;
}
public String getLeader() {
return leader;
}
public String getPassword() {
return password;
}

View File

@@ -6,6 +6,7 @@ import java.util.Set;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import com.gmail.nossr50.mcMMO;
@@ -16,7 +17,6 @@ import com.gmail.nossr50.datatypes.party.Party;
import com.gmail.nossr50.datatypes.skills.AbilityType;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.datatypes.skills.ToolType;
import com.gmail.nossr50.datatypes.spout.huds.McMMOHud;
import com.gmail.nossr50.events.experience.McMMOPlayerXpGainEvent;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.party.PartyManager;
@@ -358,24 +358,24 @@ public class McMMOPlayer {
* Repair Anvil Placement
*/
public boolean getPlacedAnvil(int anvilId) {
if (anvilId == Repair.repairAnvilId) {
public boolean getPlacedAnvil(Material anvilType) {
if (anvilType == Repair.repairAnvilMaterial) {
return placedRepairAnvil;
}
if (anvilId == Repair.salvageAnvilId) {
if (anvilType == Repair.salvageAnvilMaterial) {
return placedSalvageAnvil;
}
return true;
}
public void togglePlacedAnvil(int anvilId) {
if (anvilId == Repair.repairAnvilId) {
public void togglePlacedAnvil(Material anvilType) {
if (anvilType == Repair.repairAnvilMaterial) {
placedRepairAnvil = !placedRepairAnvil;
}
if (anvilId == Repair.salvageAnvilId) {
if (anvilType == Repair.salvageAnvilMaterial) {
placedSalvageAnvil = !placedSalvageAnvil;
}
}
@@ -384,34 +384,34 @@ public class McMMOPlayer {
* Repair Anvil Usage
*/
public int getLastAnvilUse(int anvilId) {
if (anvilId == Repair.repairAnvilId) {
public int getLastAnvilUse(Material anvilType) {
if (anvilType == Repair.repairAnvilMaterial) {
return lastRepairClick;
}
if (anvilId == Repair.salvageAnvilId) {
if (anvilType == Repair.salvageAnvilMaterial) {
return lastSalvageClick;
}
return 0;
}
public void setLastAnvilUse(int anvilId, int value) {
if (anvilId == Repair.repairAnvilId) {
public void setLastAnvilUse(Material anvilType, int value) {
if (anvilType == Repair.repairAnvilMaterial) {
lastRepairClick = value;
}
if (anvilId == Repair.salvageAnvilId) {
if (anvilType == Repair.salvageAnvilMaterial) {
lastSalvageClick = value;
}
}
public void actualizeLastAnvilUse(int anvilId) {
if (anvilId == Repair.repairAnvilId) {
public void actualizeLastAnvilUse(Material anvilType) {
if (anvilType == Repair.repairAnvilMaterial) {
lastRepairClick = (int) (System.currentTimeMillis() / Misc.TIME_CONVERSION_FACTOR);
}
if (anvilId == Repair.salvageAnvilId) {
if (anvilType == Repair.salvageAnvilMaterial) {
lastSalvageClick = (int) (System.currentTimeMillis() / Misc.TIME_CONVERSION_FACTOR);
}
}
@@ -530,12 +530,6 @@ public class McMMOPlayer {
profile.setSkillXpLevel(skillType, profile.getSkillXpLevelRaw(skillType) + event.getRawXpGained());
McMMOHud spoutHud = profile.getSpoutHud();
if (spoutHud != null) {
spoutHud.setLastGained(skillType);
}
isUsingUnarmed = (skillType == SkillType.UNARMED);
SkillUtils.xpCheckSkill(skillType, player, profile);
}

View File

@@ -9,13 +9,10 @@ import org.bukkit.scoreboard.Scoreboard;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.config.experience.ExperienceConfig;
import com.gmail.nossr50.config.spout.SpoutConfig;
import com.gmail.nossr50.datatypes.MobHealthbarType;
import com.gmail.nossr50.datatypes.experience.FormulaType;
import com.gmail.nossr50.datatypes.skills.AbilityType;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.datatypes.spout.huds.HudType;
import com.gmail.nossr50.datatypes.spout.huds.McMMOHud;
import com.gmail.nossr50.skills.child.FamilyTree;
import com.gmail.nossr50.util.player.UserManager;
@@ -25,9 +22,7 @@ public class PlayerProfile {
private boolean changed;
/* HUDs */
private HudType hudType;
private MobHealthbarType mobHealthbarType;
private McMMOHud spoutHud;
private Scoreboard playerStatsScoreboard;
/* Skill Data */
@@ -38,7 +33,6 @@ public class PlayerProfile {
public PlayerProfile(String playerName) {
this.playerName = playerName;
hudType = mcMMO.isSpoutEnabled() ? SpoutConfig.getInstance().getDefaultHudType() : HudType.DISABLED;
mobHealthbarType = Config.getInstance().getMobHealthbarDefault();
for (AbilityType abilityType : AbilityType.values()) {
@@ -59,10 +53,9 @@ public class PlayerProfile {
/**
* Calling this constructor is considered loading the profile.
*/
public PlayerProfile(String playerName, Map<SkillType, Integer> argSkills, Map<SkillType, Float> argSkillsXp, Map<AbilityType, Integer> argSkillsDats, HudType hudType, MobHealthbarType mobHealthbarType) {
public PlayerProfile(String playerName, Map<SkillType, Integer> argSkills, Map<SkillType, Float> argSkillsXp, Map<AbilityType, Integer> argSkillsDats, MobHealthbarType mobHealthbarType) {
this(playerName, true);
this.hudType = hudType;
this.mobHealthbarType = mobHealthbarType;
this.skills.putAll(argSkills);
@@ -89,26 +82,6 @@ public class PlayerProfile {
return loaded;
}
/*
* HUD Stuff
*/
public HudType getHudType() {
return hudType;
}
public McMMOHud getSpoutHud() {
return spoutHud;
}
public void setSpoutHud(McMMOHud spoutHud) {
this.spoutHud = spoutHud;
}
public void setHudType(HudType hudType) {
this.hudType = hudType;
}
/*
* Mob Healthbars
*/

View File

@@ -99,8 +99,8 @@ public enum AbilityType {
return Config.getInstance().getCooldown(this);
}
public int getMaxTicks() {
return Config.getInstance().getMaxTicks(this);
public int getMaxLength() {
return Config.getInstance().getMaxLength(this);
}
public String getAbilityOn() {

View File

@@ -1,24 +0,0 @@
package com.gmail.nossr50.datatypes.spout.buttons;
import org.getspout.spoutapi.gui.GenericButton;
public class McMMOButton extends GenericButton {
private Slot slot;
public McMMOButton(String text, String toolTip) {
this.setText(text);
this.setTooltip(toolTip);
}
public void connect(Slot slot) {
this.slot = slot;
}
public void activate() {
slot.activate();
}
public interface Slot {
public void activate();
}
}

View File

@@ -1,12 +0,0 @@
package com.gmail.nossr50.datatypes.spout.huds;
public enum HudType {
DISABLED,
STANDARD,
SMALL,
RETRO;
public HudType getNext() {
return values()[(ordinal() + 1) % values().length];
}
}

View File

@@ -1,106 +0,0 @@
package com.gmail.nossr50.datatypes.spout.huds;
import org.bukkit.entity.Player;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.spout.SpoutConfig;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.player.PlayerProfile;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.datatypes.spout.popups.McMMOMenu;
import com.gmail.nossr50.datatypes.spout.popups.McMMOXpBar;
import org.getspout.spoutapi.SpoutManager;
public class McMMOHud {
private Player player;
private PlayerProfile profile;
private SkillType lastGained;
private SkillType skillLock;
private boolean xpBarLocked;
private McMMOMenu menu;
private McMMOXpBar xpBar;
public McMMOHud(McMMOPlayer mcMMOPlayer) {
this.player = mcMMOPlayer.getPlayer();
this.profile = mcMMOPlayer.getProfile();
initializeXpBar();
}
/**
* Initialize the HUD.
*/
public void initializeXpBar() {
if (SpoutConfig.getInstance().getXPBarEnabled()) {
if (xpBar != null) {
xpBar.removeWidgets();
}
xpBar = new McMMOXpBar(SpoutManager.getPlayer(player), profile.getHudType());
}
}
/**
* Update the XP bar.
*/
public void updateXpBar() {
SkillType skillType = xpBarLocked ? skillLock : lastGained;
if (skillType == null) {
return;
}
xpBar.update(skillType, profile);
}
public boolean isMenuOpened() {
return (menu != null);
}
public void openMenu() {
menu = new McMMOMenu(SpoutManager.getPlayer(player), profile);
}
public void onMenuClose() {
menu = null;
}
public void removeWidgets() {
if (menu != null) {
menu.close();
}
SpoutManager.getPlayer(player).getMainScreen().removeWidgets(mcMMO.p);
}
public SkillType getLastGained() {
return lastGained;
}
public void setLastGained(SkillType type) {
this.lastGained = type;
}
public boolean getXpBarLocked() {
return xpBarLocked;
}
public void setXpBarLocked(boolean locked) {
this.xpBarLocked = locked;
}
public void toggleXpBarLocked() {
xpBarLocked = !xpBarLocked;
}
public SkillType getSkillLock() {
return skillLock;
}
public void setSkillLock(SkillType type) {
this.skillLock = type;
}
}

View File

@@ -1,82 +0,0 @@
package com.gmail.nossr50.datatypes.spout.popups;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.datatypes.player.PlayerProfile;
import com.gmail.nossr50.datatypes.spout.buttons.McMMOButton;
import com.gmail.nossr50.datatypes.spout.buttons.McMMOButton.Slot;
import com.gmail.nossr50.datatypes.spout.huds.HudType;
import com.gmail.nossr50.datatypes.spout.huds.McMMOHud;
import com.gmail.nossr50.locale.LocaleLoader;
import org.getspout.spoutapi.gui.GenericLabel;
import org.getspout.spoutapi.gui.GenericPopup;
import org.getspout.spoutapi.gui.InGameHUD;
import org.getspout.spoutapi.player.SpoutPlayer;
public class McMMOMenu extends GenericPopup {
private McMMOButton hudButton;
private McMMOButton escapeButton;
private GenericLabel titleLabel = new GenericLabel();
private GenericLabel escapeLabel = new GenericLabel();
private static int centerX = 427 / 2;
private static int centerY = 240 / 2;
public McMMOMenu(final SpoutPlayer spoutPlayer, final PlayerProfile playerProfile) {
// 240, 427 are the bottom right
titleLabel.setText(LocaleLoader.getString("Spout.Menu.Title"));
titleLabel.setWidth(100);
titleLabel.setHeight(100);
titleLabel.setX(centerX - 35);
titleLabel.setY((centerY / 2) - 20);
escapeLabel.setText(LocaleLoader.getString("Spout.Menu.Exit"));
escapeLabel.setWidth(100);
escapeLabel.setHeight(100);
escapeLabel.setX(titleLabel.getX() - 15);
escapeLabel.setY(titleLabel.getY() + 10);
hudButton = new McMMOButton(LocaleLoader.getString("Spout.Menu.HudButton.1", playerProfile.getHudType().toString()), LocaleLoader.getString("Spout.Menu.HudButton.2"));
hudButton.setWidth(120);
hudButton.setHeight(20);
hudButton.setX(centerX - (hudButton.getWidth() / 2));
hudButton.setY(centerY / 2);
hudButton.connect(new Slot() {
@Override
public void activate() {
HudType nextHudType = playerProfile.getHudType().getNext();
McMMOHud spoutHud = playerProfile.getSpoutHud();
playerProfile.setHudType(nextHudType);
spoutHud.initializeXpBar();
spoutHud.updateXpBar();
hudButton.setText("HUD Type: " + nextHudType.toString());
hudButton.setDirty(true);
}
});
escapeButton = new McMMOButton(LocaleLoader.getString("Spout.Menu.ExitButton"), null);
escapeButton.setWidth(60);
escapeButton.setHeight(20);
escapeButton.setX(centerX - (escapeButton.getWidth() / 2));
escapeButton.setY((centerY / 2) + (escapeButton.getHeight() * 2) + 5);
escapeButton.connect(new Slot() {
@Override
public void activate() {
spoutPlayer.getMainScreen().closePopup();
}
});
attachWidget(mcMMO.p, hudButton);
attachWidget(mcMMO.p, titleLabel);
attachWidget(mcMMO.p, escapeLabel);
attachWidget(mcMMO.p, escapeButton);
InGameHUD inGameHud = spoutPlayer.getMainScreen();
inGameHud.attachPopupScreen(this);
inGameHud.setDirty(true);
}
}

View File

@@ -1,305 +0,0 @@
package com.gmail.nossr50.datatypes.spout.popups;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.spout.SpoutConfig;
import com.gmail.nossr50.datatypes.player.PlayerProfile;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.datatypes.spout.huds.HudType;
import com.gmail.nossr50.util.StringUtils;
import org.getspout.spoutapi.gui.Color;
import org.getspout.spoutapi.gui.GenericGradient;
import org.getspout.spoutapi.gui.GenericTexture;
import org.getspout.spoutapi.gui.InGameHUD;
import org.getspout.spoutapi.gui.RenderPriority;
import org.getspout.spoutapi.gui.Widget;
import org.getspout.spoutapi.player.SpoutPlayer;
public class McMMOXpBar {
private SpoutPlayer spoutPlayer;
private Widget xpBar;
private GenericGradient xpFill;
private GenericGradient xpBackground;
private GenericGradient xpIconBackground;
private GenericGradient xpIconBorder;
private GenericTexture xpIcon;
public McMMOXpBar(SpoutPlayer spoutPlayer, HudType hudType) {
this.spoutPlayer = spoutPlayer;
switch (hudType) {
case RETRO:
initializeXpBarRetro();
break;
case STANDARD:
initializeXpBarStandard();
break;
case SMALL:
initializeXpBarSmall();
break;
case DISABLED:
break;
default:
break;
}
spoutPlayer.getMainScreen().setDirty(true);
}
public void removeWidgets() {
InGameHUD inGameHud = spoutPlayer.getMainScreen();
if (xpBar != null) {
inGameHud.removeWidget(xpBar);
}
if (xpFill != null) {
inGameHud.removeWidget(xpFill);
}
if (xpBackground != null) {
inGameHud.removeWidget(xpBackground);
}
if (xpIconBackground != null) {
inGameHud.removeWidget(xpIconBackground);
}
if (xpIconBorder != null) {
inGameHud.removeWidget(xpIconBorder);
}
if (xpIcon != null) {
inGameHud.removeWidget(xpIcon);
}
}
/**
* Initialize Retro XP bar.
*/
private void initializeXpBarRetro() {
Color border = new Color((float) SpoutConfig.getInstance().getRetroHUDXPBorderRed(), (float) SpoutConfig.getInstance().getRetroHUDXPBorderGreen(), (float) SpoutConfig.getInstance().getRetroHUDXPBorderBlue(), 1f);
Color green = new Color(0f, 1f, 0f, 1f);
Color background = new Color((float) SpoutConfig.getInstance().getRetroHUDXPBackgroundRed(), (float) SpoutConfig.getInstance().getRetroHUDXPBackgroundGreen(), (float) SpoutConfig.getInstance().getRetroHUDXPBackgroundBlue(), 1f);
xpBar = new GenericGradient();
xpFill = new GenericGradient();
xpBackground = new GenericGradient();
xpBar.setWidth(128);
xpBar.setHeight(4);
xpBar.setX(149);
xpBar.setY(10);
((GenericGradient) xpBar).setBottomColor(border);
((GenericGradient) xpBar).setTopColor(border);
xpBar.setPriority(RenderPriority.Highest);
spoutPlayer.getMainScreen().attachWidget(mcMMO.p, xpBar);
xpFill.setWidth(0);
xpFill.setHeight(2);
xpFill.setX(150);
xpFill.setY(11);
xpFill.setBottomColor(green);
xpFill.setTopColor(green);
xpFill.setPriority(RenderPriority.Lowest);
spoutPlayer.getMainScreen().attachWidget(mcMMO.p, xpFill);
xpBackground.setWidth(126);
xpBackground.setHeight(2);
xpBackground.setX(150);
xpBackground.setY(11);
xpBackground.setBottomColor(background);
xpBackground.setTopColor(background);
xpBackground.setPriority(RenderPriority.Low);
spoutPlayer.getMainScreen().attachWidget(mcMMO.p, xpBackground);
if (SpoutConfig.getInstance().getXPBarIconEnabled()) {
Color darkbg = new Color(0.2f, 0.2f, 0.2f, 1f);
xpIconBackground = new GenericGradient();
xpIconBorder = new GenericGradient();
xpIcon = new GenericTexture();
xpIconBackground.setBottomColor(darkbg);
xpIconBackground.setTopColor(darkbg);
xpIconBackground.setWidth(4);
xpIconBackground.setHeight(4);
xpIconBackground.setPriority(RenderPriority.High);
xpIconBackground.setX(142);
xpIconBackground.setY(10);
spoutPlayer.getMainScreen().attachWidget(mcMMO.p, xpIconBackground);
xpIconBorder.setBottomColor(border);
xpIconBorder.setTopColor(border);
xpIconBorder.setWidth(6);
xpIconBorder.setHeight(6);
xpIconBorder.setPriority(RenderPriority.Highest);
xpIconBorder.setX(141);
xpIconBorder.setY(9);
spoutPlayer.getMainScreen().attachWidget(mcMMO.p, xpIconBorder);
xpIcon.setWidth(6);
xpIcon.setHeight(6);
xpIcon.setX(141);
xpIcon.setY(9);
xpIcon.setPriority(RenderPriority.Normal);
xpIcon.setUrl("Icon_r.png");
spoutPlayer.getMainScreen().attachWidget(mcMMO.p, xpIcon);
}
}
/**
* Initialize Standard XP bar.
*/
private void initializeXpBarStandard() {
xpBar = new GenericTexture();
((GenericTexture) xpBar).setUrl("xpbar_inc000.png");
xpBar.setX(SpoutConfig.getInstance().getXPBarXPosition());
xpBar.setY(SpoutConfig.getInstance().getXPBarYPosition());
xpBar.setHeight(8);
xpBar.setWidth(256);
xpBar.setPriority(RenderPriority.Lowest);
spoutPlayer.getMainScreen().attachWidget(mcMMO.p, xpBar);
if (SpoutConfig.getInstance().getXPBarIconEnabled()) {
xpIcon = new GenericTexture();
xpIcon.setUrl("Icon.png");
xpIcon.setHeight(16);
xpIcon.setWidth(32);
xpIcon.setX(SpoutConfig.getInstance().getXPIconXPosition());
xpIcon.setY(SpoutConfig.getInstance().getXPIconYPosition());
xpIcon.setPriority(RenderPriority.High);
spoutPlayer.getMainScreen().attachWidget(mcMMO.p, xpIcon);
}
}
/**
* Initialize Small XP bar.
*/
private void initializeXpBarSmall() {
xpBar = new GenericTexture();
((GenericTexture) xpBar).setUrl("xpbar_inc000.png");
xpBar.setX(427 / 2 - 64);
xpBar.setY(SpoutConfig.getInstance().getXPBarYPosition());
xpBar.setHeight(4);
xpBar.setWidth(128);
xpBar.setPriority(RenderPriority.Lowest);
spoutPlayer.getMainScreen().attachWidget(mcMMO.p, xpBar);
if (SpoutConfig.getInstance().getXPBarIconEnabled()) {
xpIcon = new GenericTexture();
xpIcon.setUrl("Icon.png");
xpIcon.setHeight(8);
xpIcon.setWidth(16);
xpIcon.setX(427 / 2 - (8 + 64));
xpIcon.setY(SpoutConfig.getInstance().getXPIconYPosition() + 2);
xpIcon.setPriority(RenderPriority.High);
spoutPlayer.getMainScreen().attachWidget(mcMMO.p, xpIcon);
}
}
/**
* Update the XP bar.
*
* @param skillType The skill last used
* @param playerProfile The profile of the player whose XP bar should be updated
*/
public void update(SkillType skillType, PlayerProfile playerProfile) {
switch (playerProfile.getHudType()) {
case RETRO:
updateXpBarRetro(skillType, playerProfile);
break;
case STANDARD:
case SMALL:
updateXpBarStandard(skillType, playerProfile);
break;
case DISABLED:
break;
default:
break;
}
}
/**
* Update XP bar for Standard & Small styles.
*
* @param skillType The skill last used
* @param playerProfile The profile of the player whose XP bar should be updated
*/
private void updateXpBarStandard(SkillType skillType, PlayerProfile playerProfile) {
xpIcon.setUrl(StringUtils.getCapitalized(skillType.toString()) + ".png");
((GenericTexture) xpBar).setUrl(getUrlBar(getXpInc(playerProfile.getSkillXpLevel(skillType), playerProfile.getXpToLevel(skillType), HudType.STANDARD)));
spoutPlayer.getMainScreen().setDirty(true);
}
/**
* Update XP bar for Retro styles.
*
* @param skillType The skill last used
* @param playerProfile The profile of the player whose XP bar should be updated
*/
private void updateXpBarRetro(SkillType skillType, PlayerProfile playerProfile) {
Color color = getRetroColor(skillType);
xpIcon.setUrl(StringUtils.getCapitalized(skillType.toString()) + "_r.png");
xpFill.setBottomColor(color);
xpFill.setTopColor(color);
xpFill.setWidth(getXpInc(playerProfile.getSkillXpLevel(skillType), playerProfile.getXpToLevel(skillType), HudType.RETRO));
spoutPlayer.getMainScreen().setDirty(true);
}
private static Color getRetroColor(SkillType type) {
return new Color((float) SpoutConfig.getInstance().getRetroHUDRed(type), (float) SpoutConfig.getInstance().getRetroHUDGreen(type), (float) SpoutConfig.getInstance().getRetroHUDBlue(type), 1f);
}
private static String getUrlBar(Integer number) {
char[] num = number.toString().toCharArray();
switch (num.length) {
case 1:
return "xpbar_inc00" + number + ".png";
case 2:
return "xpbar_inc0" + number + ".png";
default:
return "xpbar_inc" + number + ".png";
}
}
private static Integer getXpInc(int skillXp, int xpToLevel, HudType hudType) {
double percentage = (double) skillXp / xpToLevel;
double inc;
switch (hudType) {
case RETRO:
inc = 0.0079365079365079;
break;
case STANDARD:
inc = 0.0039370078740157;
break;
default:
return 1;
}
return (int) (percentage / inc);
}
}

View File

@@ -3,138 +3,7 @@ package com.gmail.nossr50.datatypes.treasure;
import org.bukkit.inventory.ItemStack;
public class ExcavationTreasure extends Treasure {
// dirt | grass | sand | gravel | clay | mycel | soulsand | snow
// 00000001 - dirt 1
// 00000010 - grass 2
// 00000100 - sand 4
// 00001000 - gravel 8
// 00010000 - clay 16
// 00100000 - mycel 32
// 01000000 - soulsand 64
// 10000000 - snow 128
private byte dropsFrom = 0x0;
public ExcavationTreasure(ItemStack drop, int xp, double dropChance, int dropLevel) {
super(drop, xp, dropChance, dropLevel);
}
// Raw getters and setters
public byte getDropsFrom() {
return dropsFrom;
}
public void setDropsFrom(byte dropsFrom) {
this.dropsFrom = dropsFrom;
}
// Getters
public boolean getDropsFromDirt() {
return getDropFromMask(1);
}
public boolean getDropsFromGrass() {
return getDropFromMask(2);
}
public boolean getDropsFromSand() {
return getDropFromMask(4);
}
public boolean getDropsFromGravel() {
return getDropFromMask(8);
}
public boolean getDropsFromClay() {
return getDropFromMask(16);
}
public boolean getDropsFromMycel() {
return getDropFromMask(32);
}
public boolean getDropsFromSoulSand() {
return getDropFromMask(64);
}
public boolean getDropsFromSnow() {
return getDropFromMask(128);
}
private boolean getDropFromMask(int mask) {
return ((dropsFrom & mask) > 0) ? true : false;
}
// Setters
public void setDropsFromDirt() {
setDropFromMask(1);
}
public void setDropsFromGrass() {
setDropFromMask(2);
}
public void setDropsFromSand() {
setDropFromMask(4);
}
public void setDropsFromGravel() {
setDropFromMask(8);
}
public void setDropsFromClay() {
setDropFromMask(16);
}
public void setDropsFromMycel() {
setDropFromMask(32);
}
public void setDropsFromSoulSand() {
setDropFromMask(64);
}
public void setDropsFromSnow() {
setDropFromMask(128);
}
private void setDropFromMask(int mask) {
dropsFrom |= mask;
}
// Un-setters
public void unsetDropsFromDirt() {
unsetDropFromMask(1);
}
public void unsetDropsFromGrass() {
unsetDropFromMask(2);
}
public void unsetDropsFromSand() {
unsetDropFromMask(4);
}
public void unsetDropsFromGravel() {
unsetDropFromMask(8);
}
public void unsetDropsFromClay() {
unsetDropFromMask(16);
}
public void unsetDropsFromMycel() {
unsetDropFromMask(32);
}
public void unsetDropsFromSoulSand() {
unsetDropFromMask(64);
}
public void unsetDropsFromSnow() {
unsetDropFromMask(128);
}
private void unsetDropFromMask(int mask) {
dropsFrom &= ~mask;
}
}

View File

@@ -3,73 +3,7 @@ package com.gmail.nossr50.datatypes.treasure;
import org.bukkit.inventory.ItemStack;
public class HylianTreasure extends Treasure {
// bushes | flowers | pots
// 00000001 - bushes 1
// 00000010 - flowers 2
// 00000100 - pots 4
private byte dropsFrom = 0x0;
public HylianTreasure(ItemStack drop, int xp, double dropChance, int dropLevel) {
super(drop, xp, dropChance, dropLevel);
}
// Raw getters and setters
public byte getDropsFrom() {
return dropsFrom;
}
public void setDropsFrom(byte dropsFrom) {
this.dropsFrom = dropsFrom;
}
// Getters
public boolean getDropsFromBushes() {
return getDropFromMask(1);
}
public boolean getDropsFromFlowers() {
return getDropFromMask(2);
}
public boolean getDropsFromPots() {
return getDropFromMask(4);
}
private boolean getDropFromMask(int mask) {
return ((dropsFrom & mask) > 0) ? true : false;
}
// Setters
public void setDropsFromBushes() {
setDropFromMask(1);
}
public void setDropsFromFlowers() {
setDropFromMask(2);
}
public void setDropsFromPots() {
setDropFromMask(4);
}
private void setDropFromMask(int mask) {
dropsFrom |= mask;
}
// Un-setters
public void unsetDropsFromBushes() {
unsetDropFromMask(1);
}
public void unsetDropsFromFlowers() {
unsetDropFromMask(2);
}
public void unsetDropsFromPots() {
unsetDropFromMask(4);
}
private void unsetDropFromMask(int mask) {
dropsFrom &= ~mask;
}
}

View File

@@ -1,21 +1,9 @@
package com.gmail.nossr50.datatypes.treasure;
import org.bukkit.entity.EntityType;
import org.bukkit.inventory.ItemStack;
public class ShakeTreasure extends Treasure {
private EntityType mob;
public ShakeTreasure(ItemStack drop, int xp, double dropChance, int dropLevel, EntityType mob) {
public ShakeTreasure(ItemStack drop, int xp, double dropChance, int dropLevel) {
super(drop, xp, dropChance, dropLevel);
this.mob = mob;
}
public EntityType getMob() {
return mob;
}
public void setMob(EntityType mob) {
this.mob = mob;
}
}

View File

@@ -113,7 +113,7 @@ public class BlockListener implements Listener {
}
if (Repair.anvilMessagesEnabled && BlockUtils.isMcMMOAnvil(blockState)) {
UserManager.getPlayer(player).getRepairManager().placedAnvilCheck(blockState.getTypeId());
UserManager.getPlayer(player).getRepairManager().placedAnvilCheck(blockState.getType());
}
}
@@ -221,6 +221,11 @@ public class BlockListener implements Listener {
blockState.update(true);
event.setCancelled(true);
}
else if (blockState.getType() == Material.FLOWER_POT) {
blockState.setType(Material.AIR);
blockState.update(true);
event.setCancelled(true);
}
}
}
else if (ItemUtils.isPickaxe(heldItem) && !heldItem.containsEnchantment(Enchantment.SILK_TOUCH)) {

View File

@@ -151,6 +151,10 @@ public class EntityListener implements Listener {
Entity attacker = event.getDamager();
if (Misc.isNPCEntity(attacker)) {
return;
}
if (attacker instanceof Projectile) {
attacker = ((Projectile) attacker).getShooter();
}

View File

@@ -373,8 +373,8 @@ public class PlayerListener implements Listener {
}
if (Permissions.updateNotifications(player) && plugin.isUpdateAvailable()) {
player.sendMessage(LocaleLoader.getString("UpdateChecker.outdated"));
player.sendMessage(LocaleLoader.getString("UpdateChecker.newavailable"));
player.sendMessage(LocaleLoader.getString("UpdateChecker.Outdated"));
player.sendMessage(LocaleLoader.getString("UpdateChecker.NewAvailable"));
}
}
@@ -418,27 +418,27 @@ public class PlayerListener implements Listener {
switch (event.getAction()) {
case RIGHT_CLICK_BLOCK:
int blockID = block.getTypeId();
Material type = block.getType();
if (!Config.getInstance().getAbilitiesOnlyActivateWhenSneaking() || player.isSneaking()) {
/* REPAIR CHECKS */
if (blockID == Repair.repairAnvilId && Permissions.skillEnabled(player, SkillType.REPAIR) && mcMMO.getRepairableManager().isRepairable(heldItem)) {
if (type == Repair.repairAnvilMaterial && Permissions.skillEnabled(player, SkillType.REPAIR) && mcMMO.getRepairableManager().isRepairable(heldItem)) {
RepairManager repairManager = mcMMOPlayer.getRepairManager();
event.setCancelled(true);
// Make sure the player knows what he's doing when trying to repair an enchanted item
if (!(heldItem.getEnchantments().size() > 0) || repairManager.checkConfirmation(blockID, true)) {
if (!(heldItem.getEnchantments().size() > 0) || repairManager.checkConfirmation(type, true)) {
repairManager.handleRepair(heldItem);
player.updateInventory();
}
}
/* SALVAGE CHECKS */
else if (blockID == Repair.salvageAnvilId && Permissions.salvage(player) && Repair.isSalvageable(heldItem)) {
else if (type == Repair.salvageAnvilMaterial && Permissions.salvage(player) && Repair.isSalvageable(heldItem)) {
RepairManager repairManager = mcMMOPlayer.getRepairManager();
event.setCancelled(true);
// Make sure the player knows what he's doing when trying to salvage an enchanted item
if (!(heldItem.getEnchantments().size() > 0) || repairManager.checkConfirmation(blockID, true)) {
if (!(heldItem.getEnchantments().size() > 0) || repairManager.checkConfirmation(type, true)) {
repairManager.handleSalvage(block.getLocation(), heldItem);
player.updateInventory();
}
@@ -446,7 +446,7 @@ public class PlayerListener implements Listener {
}
/* BLAST MINING CHECK */
else if (miningManager.canDetonate()) {
if (block.getType() == Material.TNT) {
if (type == Material.TNT) {
event.setCancelled(true); // Don't detonate the TNT if they're too close
}
else {
@@ -457,26 +457,26 @@ public class PlayerListener implements Listener {
break;
case LEFT_CLICK_BLOCK:
blockID = block.getTypeId();
type = block.getType();
if ((Config.getInstance().getAbilitiesOnlyActivateWhenSneaking() && player.isSneaking()) || !Config.getInstance().getAbilitiesOnlyActivateWhenSneaking()) {
/* REPAIR CHECKS */
if (blockID == Repair.repairAnvilId && Permissions.skillEnabled(player, SkillType.REPAIR) && mcMMO.getRepairableManager().isRepairable(heldItem)) {
if (type == Repair.repairAnvilMaterial && Permissions.skillEnabled(player, SkillType.REPAIR) && mcMMO.getRepairableManager().isRepairable(heldItem)) {
RepairManager repairManager = mcMMOPlayer.getRepairManager();
// Cancel repairing an enchanted item
if (repairManager.checkConfirmation(blockID, false) && Config.getInstance().getRepairConfirmRequired()) {
mcMMOPlayer.setLastAnvilUse(Repair.repairAnvilId, 0);
if (repairManager.checkConfirmation(type, false) && Config.getInstance().getRepairConfirmRequired()) {
mcMMOPlayer.setLastAnvilUse(Repair.repairAnvilMaterial, 0);
player.sendMessage(LocaleLoader.getString("Skills.Cancelled", LocaleLoader.getString("Repair.Pretty.Name")));
}
}
/* SALVAGE CHECKS */
else if (blockID == Repair.salvageAnvilId && Permissions.salvage(player) && Repair.isSalvageable(heldItem)) {
else if (type == Repair.salvageAnvilMaterial && Permissions.salvage(player) && Repair.isSalvageable(heldItem)) {
RepairManager repairManager = mcMMOPlayer.getRepairManager();
// Cancel salvaging an enchanted item
if (repairManager.checkConfirmation(blockID, false) && Config.getInstance().getRepairConfirmRequired()) {
mcMMOPlayer.setLastAnvilUse(Repair.salvageAnvilId, 0);
if (repairManager.checkConfirmation(type, false) && Config.getInstance().getRepairConfirmRequired()) {
mcMMOPlayer.setLastAnvilUse(Repair.salvageAnvilMaterial, 0);
player.sendMessage(LocaleLoader.getString("Skills.Cancelled", LocaleLoader.getString("Salvage.Pretty.Name")));
}
}

View File

@@ -1,93 +0,0 @@
package com.gmail.nossr50.listeners;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import com.gmail.nossr50.config.spout.SpoutConfig;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.spout.buttons.McMMOButton;
import com.gmail.nossr50.datatypes.spout.huds.McMMOHud;
import com.gmail.nossr50.datatypes.spout.popups.McMMOMenu;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.player.UserManager;
import org.getspout.spoutapi.event.input.KeyPressedEvent;
import org.getspout.spoutapi.event.screen.ButtonClickEvent;
import org.getspout.spoutapi.event.screen.ScreenCloseEvent;
import org.getspout.spoutapi.event.spout.SpoutCraftEnableEvent;
import org.getspout.spoutapi.gui.Button;
import org.getspout.spoutapi.gui.ScreenType;
import org.getspout.spoutapi.player.SpoutPlayer;
public class SpoutListener implements Listener {
/**
* Monitor SpoutCraftEnable events.
*
* @param event The event to watch
*/
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onSpoutCraftEnable(SpoutCraftEnableEvent event) {
SpoutPlayer spoutPlayer = event.getPlayer();
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(spoutPlayer);
// TODO: Add custom titles based on skills
if (SpoutConfig.getInstance().getShowPowerLevel()) {
spoutPlayer.setTitle(LocaleLoader.getString("Spout.Title", spoutPlayer.getTitle(), mcMMOPlayer.getPowerLevel()));
}
mcMMOPlayer.getProfile().setSpoutHud(new McMMOHud(mcMMOPlayer)); // Setup Party HUD stuff
}
/**
* Monitor Spout ButtonClick events.
*
* @param event The event to watch
*/
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onButtonClick(ButtonClickEvent event) {
Button button = event.getButton();
if (button instanceof McMMOButton) {
((McMMOButton) button).activate();
}
}
/**
* Monitor Spout ScreenClose events.
*
* @param event The event to watch
*/
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onScreenClose(ScreenCloseEvent event) {
if (event.getScreen() instanceof McMMOMenu) {
SpoutPlayer spoutPlayer = event.getPlayer();
UserManager.getPlayer(spoutPlayer).getProfile().getSpoutHud().onMenuClose();
spoutPlayer.getMainScreen().setDirty(true);
}
}
/**
* Monitor Spout KeyPressed events.
*
* @param event The event to watch
*/
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onKeyPressedEvent(KeyPressedEvent event) {
SpoutPlayer spoutPlayer = event.getPlayer();
if (spoutPlayer.getMainScreen().getActivePopup() != null || event.getScreenType() != ScreenType.GAME_SCREEN) {
return;
}
if (event.getKey() == SpoutConfig.getInstance().getMenuKey()) {
McMMOHud spoutHud = UserManager.getPlayer(spoutPlayer).getProfile().getSpoutHud();
if (!spoutHud.isMenuOpened()) {
spoutHud.openMenu();
}
}
}
}

View File

@@ -46,7 +46,7 @@ public final class LocaleLoader {
}
private static String getString(String key, ResourceBundle bundle, Object... messageArguments) throws MissingResourceException {
return formatString(bundle.getString(key), messageArguments);
return formatString(bundle.getString(key).replace("\'", "''"), messageArguments);
}
public static String formatString(String string, Object... messageArguments) {

View File

@@ -18,7 +18,6 @@ import com.gmail.nossr50.config.mods.CustomArmorConfig;
import com.gmail.nossr50.config.mods.CustomBlockConfig;
import com.gmail.nossr50.config.mods.CustomEntityConfig;
import com.gmail.nossr50.config.mods.CustomToolConfig;
import com.gmail.nossr50.config.spout.SpoutConfig;
import com.gmail.nossr50.config.treasure.TreasureConfig;
import com.gmail.nossr50.database.DatabaseManager;
import com.gmail.nossr50.database.DatabaseManagerFactory;
@@ -27,13 +26,11 @@ import com.gmail.nossr50.listeners.EntityListener;
import com.gmail.nossr50.listeners.InventoryListener;
import com.gmail.nossr50.listeners.PlayerListener;
import com.gmail.nossr50.listeners.SelfListener;
import com.gmail.nossr50.listeners.SpoutListener;
import com.gmail.nossr50.listeners.WorldListener;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.metrics.MetricsManager;
import com.gmail.nossr50.party.PartyManager;
import com.gmail.nossr50.runnables.SaveTimerTask;
import com.gmail.nossr50.runnables.UpdateCheckerTask;
import com.gmail.nossr50.runnables.database.UserPurgeTask;
import com.gmail.nossr50.runnables.party.PartyAutoKickTask;
import com.gmail.nossr50.runnables.skills.BleedTimerTask;
@@ -51,8 +48,10 @@ import com.gmail.nossr50.util.blockmeta.chunkmeta.ChunkManagerFactory;
import com.gmail.nossr50.util.commands.CommandRegistrationManager;
import com.gmail.nossr50.util.experience.FormulaManager;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.spout.SpoutUtils;
import net.h31ix.updater.mcmmo.Updater;
import net.h31ix.updater.mcmmo.Updater.UpdateResult;
import net.h31ix.updater.mcmmo.Updater.UpdateType;
import net.shatteredlands.shatt.backup.ZipLibrary;
public class mcMMO extends JavaPlugin {
@@ -77,8 +76,9 @@ public class mcMMO extends JavaPlugin {
private boolean updateAvailable;
/* Plugin Checks */
private static boolean spoutEnabled;
private static boolean combatTagEnabled;
private static boolean healthBarPluginEnabled;
private static boolean mcpcEnabled;
// Config Validation Check
public boolean noErrorsInConfigFiles = true;
@@ -112,7 +112,7 @@ public class mcMMO extends JavaPlugin {
metadataValue = new FixedMetadataValue(this, true);
setupFilePaths();
setupSpout();
loadConfigFiles();
if (!noErrorsInConfigFiles) {
@@ -120,6 +120,16 @@ public class mcMMO extends JavaPlugin {
}
combatTagEnabled = getServer().getPluginManager().getPlugin("CombatTag") != null;
healthBarPluginEnabled = getServer().getPluginManager().getPlugin("HealthBar") != null;
mcpcEnabled = getServer().getName().equals("MCPC+");
if (mcpcEnabled) {
checkModConfigs();
}
if (healthBarPluginEnabled) {
getLogger().info("HealthBar plugin found, mcMMO's healthbars are automatically disabled.");
}
databaseManager = DatabaseManagerFactory.getDatabaseManager();
@@ -259,14 +269,18 @@ public class mcMMO extends JavaPlugin {
mcMMO.databaseManager = databaseManager;
}
public static boolean isSpoutEnabled() {
return spoutEnabled;
}
public static boolean isCombatTagEnabled() {
return combatTagEnabled;
}
public static boolean isHealthBarPluginEnabled() {
return healthBarPluginEnabled;
}
public static boolean isMCPCEnabled() {
return mcpcEnabled;
}
/**
* Setup the various storage file paths
*/
@@ -283,15 +297,21 @@ public class mcMMO extends JavaPlugin {
return;
}
getServer().getScheduler().runTaskAsynchronously(this, new UpdateCheckerTask());
}
Updater updater = new Updater(this, "mcmmo", mcmmo, UpdateType.NO_DOWNLOAD, false);
public void updateCheckerCallback(boolean updateAvailable) {
this.updateAvailable = updateAvailable;
if (updateAvailable) {
getLogger().info(LocaleLoader.getString("UpdateChecker.outdated"));
getLogger().info(LocaleLoader.getString("UpdateChecker.newavailable"));
if (updater.getResult() != UpdateResult.UPDATE_AVAILABLE) {
this.updateAvailable = false;
return;
}
if (updater.getLatestVersionString().contains("-beta") && !Config.getInstance().getPreferBeta()) {
this.updateAvailable = false;
return;
}
this.updateAvailable = true;
getLogger().info(LocaleLoader.getString("UpdateChecker.Outdated"));
getLogger().info(LocaleLoader.getString("UpdateChecker.NewAvailable"));
}
private void loadConfigFiles() {
@@ -326,19 +346,6 @@ public class mcMMO extends JavaPlugin {
repairableManager.registerRepairables(repairables);
}
private void setupSpout() {
if (!getServer().getPluginManager().isPluginEnabled("Spout")) {
return;
}
spoutEnabled = true;
SpoutConfig.getInstance();
getServer().getPluginManager().registerEvents(new SpoutListener(), this);
SpoutUtils.preCacheFiles();
SpoutUtils.reloadSpoutPlayers(); // Handle spout players after a /reload
}
private void registerEvents() {
PluginManager pluginManager = getServer().getPluginManager();
@@ -385,4 +392,26 @@ public class mcMMO extends JavaPlugin {
new PartyAutoKickTask().runTaskTimer(this, kickIntervalTicks, kickIntervalTicks);
}
}
private void checkModConfigs() {
if (!Config.getInstance().getToolModsEnabled()) {
getLogger().info("MCPC+ implementation found, but the custom tool config for mcMMO is disabled!");
getLogger().info("To enable, set Mods.Tool_Mods_Enabled to TRUE in config.yml.");
}
if (!Config.getInstance().getArmorModsEnabled()) {
getLogger().info("MCPC+ implementation found, but the custom armor config for mcMMO is disabled!");
getLogger().info("To enable, set Mods.Armor_Mods_Enabled to TRUE in config.yml.");
}
if (!Config.getInstance().getBlockModsEnabled()) {
getLogger().info("MCPC+ implementation found, but the custom block config for mcMMO is disabled!");
getLogger().info("To enable, set Mods.Block_Mods_Enabled to TRUE in config.yml.");
}
if (!Config.getInstance().getEntityModsEnabled()) {
getLogger().info("MCPC+ implementation found, but the custom entity config for mcMMO is disabled!");
getLogger().info("To enable, set Mods.Entity_Mods_Enabled to TRUE in config.yml.");
}
}
}

View File

@@ -246,8 +246,8 @@ public final class PartyManager {
* @param party The party to remove
*/
public static void disbandParty(Party party) {
for (String memberName : party.getMembers()) {
processPartyLeaving(UserManager.getPlayer(memberName));
for (Player member : party.getOnlineMembers()) {
processPartyLeaving(UserManager.getPlayer(member));
}
parties.remove(party);
@@ -315,10 +315,11 @@ public final class PartyManager {
public static void joinInvitedParty(McMMOPlayer mcMMOPlayer) {
Party invite = mcMMOPlayer.getPartyInvite();
// // Pretty sure this isn't possible
// if (!parties.contains(invite)) {
// parties.add(invite);
// }
// Check if the party still exists, it might have been disbanded
if (!parties.contains(invite)) {
mcMMOPlayer.getPlayer().sendMessage(LocaleLoader.getString("Party.Disband"));
return;
}
mcMMOPlayer.getPlayer().sendMessage(LocaleLoader.getString("Commands.Invite.Accepted", invite.getName()));
mcMMOPlayer.removePartyInvite();

View File

@@ -1,19 +0,0 @@
package com.gmail.nossr50.runnables;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.UpdateChecker;
/**
* Async task
*/
public class UpdateCheckerTask implements Runnable {
@Override
public void run() {
try {
mcMMO.p.updateCheckerCallback(UpdateChecker.updateAvailable());
}
catch (Exception e) {
mcMMO.p.updateCheckerCallback(false);
}
}
}

View File

@@ -15,6 +15,8 @@ public class KrakenAttackTask extends BukkitRunnable {
private Player player;
private Location location;
private final boolean GLOBAL_SOUNDS = AdvancedConfig.getInstance().getKrakenGlobalSoundsEnabled();
private final String DEFEAT_MESSAGE = AdvancedConfig.getInstance().getPlayerDefeatMessage();
private final String ESCAPE_MESSAGE = AdvancedConfig.getInstance().getPlayerEscapeMessage();
public KrakenAttackTask(Creature kraken, Player player) {
this.kraken = kraken;
@@ -56,7 +58,10 @@ public class KrakenAttackTask extends BukkitRunnable {
}
if (!kraken.isValid()) {
player.sendMessage(AdvancedConfig.getInstance().getPlayerDefeatMessage());
if (!DEFEAT_MESSAGE.isEmpty()) {
player.sendMessage(DEFEAT_MESSAGE);
}
player.resetPlayerWeather();
cancel();
}
@@ -65,7 +70,10 @@ public class KrakenAttackTask extends BukkitRunnable {
Location location = player.getLocation();
if (!location.getBlock().isLiquid() && AdvancedConfig.getInstance().getKrakenEscapeAllowed()) {
player.sendMessage(AdvancedConfig.getInstance().getPlayerEscapeMessage());
if (!ESCAPE_MESSAGE.isEmpty()) {
player.sendMessage(AdvancedConfig.getInstance().getPlayerEscapeMessage());
}
kraken.remove();
player.resetPlayerWeather();
cancel();

View File

@@ -56,7 +56,7 @@ public class AcrobaticsManager extends SkillManager {
}
// Why do we check respawn cooldown here?
if (System.currentTimeMillis() >= mcMMOPlayer.getRespawnATS() + Misc.PLAYER_RESPAWN_COOLDOWN_SECONDS) {
if (SkillUtils.cooldownExpired(mcMMOPlayer.getRespawnATS(), Misc.PLAYER_RESPAWN_COOLDOWN_SECONDS)) {
applyXpGain((float) (damage * Acrobatics.dodgeXpModifier));
}

View File

@@ -1,10 +1,12 @@
package com.gmail.nossr50.skills.axes;
import org.bukkit.Material;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.skills.AbilityType;
import com.gmail.nossr50.datatypes.skills.SkillType;
@@ -13,7 +15,6 @@ import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.skills.SkillManager;
import com.gmail.nossr50.util.ItemUtils;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.ModUtils;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.skills.CombatUtils;
@@ -97,9 +98,10 @@ public class AxesManager extends SkillManager {
for (ItemStack armor : target.getEquipment().getArmorContents()) {
if (ItemUtils.isArmor(armor) && Axes.impactChance > Misc.getRandom().nextInt(getActivationChance())) {
Material armorType = armor.getType();
double durabilityModifier = 1 / (armor.getEnchantmentLevel(Enchantment.DURABILITY) + 1); // Modifier to simulate the durability enchantment behavior
double modifiedDurabilityDamage = durabilityDamage * durabilityModifier;
short maxDurability = ModUtils.isCustomArmor(armor) ? ModUtils.getArmorFromItemStack(armor).getDurability() : armor.getType().getMaxDurability();
short maxDurability = mcMMO.getRepairableManager().isRepairable(armorType) ? mcMMO.getRepairableManager().getRepairable(armorType).getMaximumDurability() : armorType.getMaxDurability();
double maxDurabilityDamage = maxDurability * Axes.impactMaxDurabilityModifier;
armor.setDurability((short) (Math.min(modifiedDurabilityDamage, maxDurabilityDamage) + armor.getDurability()));

View File

@@ -18,6 +18,8 @@ public class ChildConfig extends AutoUpdateConfigLoader {
protected void loadKeys() {
config.setDefaults(YamlConfiguration.loadConfiguration(plugin.getResource("child.yml")));
FamilyTree.clearRegistrations(); // when reloading, need to clear statics
for (SkillType skill : SkillType.childSkills()) {
plugin.debug("Finding parents of " + skill.name());

View File

@@ -35,6 +35,10 @@ public class FamilyTree {
}
}
protected static void clearRegistrations() {
tree.clear();
}
protected static void enforceChildSkill(SkillType skill) {
if (!skill.isChildSkill()) {
throw new IllegalArgumentException(skill.name() + " is not a child skill!");

View File

@@ -103,7 +103,12 @@ public class FishingManager extends SkillManager {
world.strikeLightningEffect(location);
world.strikeLightningEffect(location);
world.strikeLightningEffect(location);
player.sendMessage(AdvancedConfig.getInstance().getPlayerUnleashMessage());
String unleashMessage = AdvancedConfig.getInstance().getPlayerUnleashMessage();
if (!unleashMessage.isEmpty()) {
player.sendMessage(unleashMessage);
}
if (AdvancedConfig.getInstance().getKrakenGlobalSoundsEnabled()) {
world.playSound(location, Sound.GHAST_SCREAM, Misc.GHAST_VOLUME, Misc.getGhastPitch());

View File

@@ -1,5 +1,7 @@
package com.gmail.nossr50.skills.mining;
import org.bukkit.Material;
import com.gmail.nossr50.config.AdvancedConfig;
import com.gmail.nossr50.config.Config;
@@ -81,7 +83,7 @@ public class BlastMining {
abstract protected int getDropMultiplier();
}
public static int detonatorID = Config.getInstance().getDetonatorItemID();
public static Material detonator = Config.getInstance().getDetonatorItem();
public final static int MAXIMUM_REMOTE_DETONATION_DISTANCE = 100;
}

View File

@@ -38,7 +38,7 @@ public class MiningManager extends SkillManager {
public boolean canDetonate() {
Player player = getPlayer();
return canUseBlastMining() && player.isSneaking() && player.getItemInHand().getTypeId() == BlastMining.detonatorID && Permissions.remoteDetonation(player);
return canUseBlastMining() && player.isSneaking() && player.getItemInHand().getType() == BlastMining.detonator && Permissions.remoteDetonation(player);
}
public boolean canUseBlastMining() {

View File

@@ -2,9 +2,12 @@ package com.gmail.nossr50.skills.repair;
import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.PlayerInventory;
import org.bukkit.inventory.Recipe;
import org.bukkit.inventory.ShapedRecipe;
import org.bukkit.inventory.ShapelessRecipe;
import org.bukkit.material.MaterialData;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.AdvancedConfig;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.locale.LocaleLoader;
@@ -19,14 +22,15 @@ public class Repair {
public static int salvageUnlockLevel = AdvancedConfig.getInstance().getSalvageUnlockLevel();
public static int salvageAnvilId = Config.getInstance().getSalvageAnvilId();
public static int repairAnvilId = Config.getInstance().getRepairAnvilId();
public static boolean anvilMessagesEnabled = Config.getInstance().getRepairAnvilMessagesEnabled();
public static Material salvageAnvilMaterial = Config.getInstance().getSalvageAnvilMaterial();
public static Material repairAnvilMaterial = Config.getInstance().getRepairAnvilMaterial();
public static boolean anvilMessagesEnabled = Config.getInstance().getRepairAnvilMessagesEnabled();
/**
* Checks if the item is salvageable.
*
* @param item Item to check
*
* @return true if the item is salvageable, false otherwise
*/
public static boolean isSalvageable(ItemStack item) {
@@ -41,89 +45,18 @@ public class Repair {
return false;
}
public static String getAnvilMessage(int blockId) {
if (blockId == repairAnvilId) {
public static String getAnvilMessage(Material type) {
if (type == repairAnvilMaterial) {
return LocaleLoader.getString("Repair.Listener.Anvil");
}
if (blockId == salvageAnvilId) {
if (type == salvageAnvilMaterial) {
return LocaleLoader.getString("Repair.Listener.Anvil2");
}
return "";
}
public static String[] getSpoutAnvilMessages(int blockId) {
if (blockId == repairAnvilId) {
return new String[] {LocaleLoader.getString("Repair.AnvilPlaced.Spout1"), LocaleLoader.getString("Repair.AnvilPlaced.Spout2")};
}
if (blockId == salvageAnvilId) {
return new String[] {"[mcMMO] Anvil Placed", "Right click to salvage!"};
}
return new String[] {"", ""};
}
/**
* Search the inventory for an item and return the index.
*
* @param inventory PlayerInventory to scan
* @param itemId Item id to look for
* @return index location where the item was found, or -1 if not found
*/
protected static int findInInventory(PlayerInventory inventory, int itemId) {
int location = inventory.first(itemId);
// VALIDATE
if (inventory.getItem(location).getTypeId() == itemId) {
return location;
}
return -1;
}
/**
* Search the inventory for an item and return the index.
*
* @param inventory PlayerInventory to scan
* @param itemId Item id to look for
* @param metadata Metadata to look for
* @return index location where the item was found, or -1 if not found
*/
protected static int findInInventory(PlayerInventory inventory, int itemId, byte metadata) {
int location = -1;
ItemStack[] contents = inventory.getContents();
for (int i = 0; i < contents.length; i++) {
ItemStack item = contents[i];
if (item == null) {
continue;
}
if (item.getData().equals(new MaterialData(itemId, metadata))) {
return i;
}
}
return location;
}
/**
* Decrease the amount of items in this slot by one
*
* @param inventory PlayerInventory to work in
* @param index Item index to decrement
*/
protected static void removeOneFrom(PlayerInventory inventory, int index) {
ItemStack item = inventory.getItem(index).clone();
item.setAmount(1);
inventory.removeItem(item);
}
protected static Material getSalvagedItem(ItemStack inHand) {
if (ItemUtils.isDiamondTool(inHand) || ItemUtils.isDiamondArmor(inHand)) {
return Material.DIAMOND;
@@ -152,29 +85,61 @@ public class Repair {
}
protected static int getSalvagedAmount(ItemStack inHand) {
if (ItemUtils.isPickaxe(inHand) || ItemUtils.isAxe(inHand) || inHand.getType() == Material.BOW || inHand.getType() == Material.BUCKET) {
return 3;
// Temporary workaround until they get their stuff fixed.
if (mcMMO.isMCPCEnabled()) {
if (ItemUtils.isPickaxe(inHand) || ItemUtils.isAxe(inHand) || ItemUtils.isBow(inHand) || inHand.getType() == Material.BUCKET) {
return 3;
}
else if (ItemUtils.isShovel(inHand) || inHand.getType() == Material.FLINT_AND_STEEL) {
return 1;
}
else if (ItemUtils.isSword(inHand) || ItemUtils.isHoe(inHand) || inHand.getType() == Material.CARROT_STICK || inHand.getType() == Material.FISHING_ROD || inHand.getType() == Material.SHEARS) {
return 2;
}
else if (ItemUtils.isHelmet(inHand)) {
return 5;
}
else if (ItemUtils.isChestplate(inHand)) {
return 8;
}
else if (ItemUtils.isLeggings(inHand)) {
return 7;
}
else if (ItemUtils.isBoots(inHand)) {
return 4;
}
else {
return 0;
}
}
else if (ItemUtils.isShovel(inHand) || inHand.getType() == Material.FLINT_AND_STEEL) {
return 1;
return getRepairAndSalvageQuantities(inHand, getSalvagedItem(inHand), (byte) -1);
}
public static int getRepairAndSalvageQuantities(ItemStack item) {
return getRepairAndSalvageQuantities(item, null, (byte) -1);
}
public static int getRepairAndSalvageQuantities(ItemStack item, Material repairMaterial, byte repairMetadata) {
int quantity = 0;
MaterialData repairData = repairMaterial != null ? new MaterialData(repairMaterial, repairMetadata) : null;
Recipe recipe = mcMMO.p.getServer().getRecipesFor(item).get(0);
if (recipe instanceof ShapelessRecipe) {
for (ItemStack ingredient : ((ShapelessRecipe) recipe).getIngredientList()) {
if (ingredient != null && (repairMaterial == null || ingredient.getType() == repairMaterial) && (repairMetadata == -1 || ingredient.getData() == repairData)) {
quantity += ingredient.getAmount();
}
}
}
else if (ItemUtils.isSword(inHand) || ItemUtils.isHoe(inHand) || inHand.getType() == Material.CARROT_STICK || inHand.getType() == Material.FISHING_ROD || inHand.getType() == Material.SHEARS) {
return 2;
}
else if (ItemUtils.isHelmet(inHand)) {
return 5;
}
else if (ItemUtils.isChestplate(inHand)) {
return 8;
}
else if (ItemUtils.isLeggings(inHand)) {
return 7;
}
else if (ItemUtils.isBoots(inHand)) {
return 4;
}
else {
return 0;
else if (recipe instanceof ShapedRecipe) {
for (ItemStack ingredient : ((ShapedRecipe) recipe).getIngredientMap().values()) {
if (ingredient != null && (repairMaterial == null || ingredient.getType() == repairMaterial) && (repairMetadata == -1 || ingredient.getData() == repairData)) {
quantity += ingredient.getAmount();
}
}
}
return quantity;
}
}

View File

@@ -10,6 +10,7 @@ import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.PlayerInventory;
import org.bukkit.material.MaterialData;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.Config;
@@ -25,7 +26,6 @@ import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.StringUtils;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.skills.SkillUtils;
import com.gmail.nossr50.util.spout.SpoutUtils;
public class RepairManager extends SkillManager {
public RepairManager(McMMOPlayer mcMMOPlayer) {
@@ -35,31 +35,24 @@ public class RepairManager extends SkillManager {
/**
* Handles notifications for placing an anvil.
*
* @param anvilId The item ID of the anvil block
* @param anvilType The {@link Material} of the anvil block
*/
public void placedAnvilCheck(int anvilId) {
public void placedAnvilCheck(Material anvilType) {
Player player = getPlayer();
if (mcMMOPlayer.getPlacedAnvil(anvilId)) {
if (mcMMOPlayer.getPlacedAnvil(anvilType)) {
return;
}
if (mcMMO.isSpoutEnabled()) {
SpoutUtils.sendRepairNotifications(player, anvilId);
}
else {
player.sendMessage(Repair.getAnvilMessage(anvilId));
}
player.sendMessage(Repair.getAnvilMessage(anvilType));
player.playSound(player.getLocation(), Sound.ANVIL_LAND, Misc.ANVIL_USE_VOLUME, Misc.ANVIL_USE_PITCH);
mcMMOPlayer.togglePlacedAnvil(anvilId);
mcMMOPlayer.togglePlacedAnvil(anvilType);
}
public void handleRepair(ItemStack item) {
Player player = getPlayer();
int itemId = item.getTypeId();
Repairable repairable = mcMMO.getRepairableManager().getRepairable(itemId);
Repairable repairable = mcMMO.getRepairableManager().getRepairable(item.getType());
// Permissions checks on material and item types
if (!repairable.getRepairItemType().getPermissions(player)) {
@@ -83,18 +76,16 @@ public class RepairManager extends SkillManager {
PlayerInventory inventory = player.getInventory();
int repairMaterialId = repairable.getRepairMaterialId();
Material repairMaterial = repairable.getRepairMaterial();
byte repairMaterialMetadata = repairable.getRepairMaterialMetadata();
ItemStack toRemove = new MaterialData(repairMaterial, repairMaterialMetadata).toItemStack(1);
// Check if they have the proper material to repair with
if (!inventory.contains(repairMaterialId)) {
String message = LocaleLoader.getString("Skills.NeedMore", StringUtils.getPrettyItemString(repairMaterialId));
if (!inventory.contains(repairMaterial)) {
String message = LocaleLoader.getString("Skills.NeedMore", StringUtils.getPrettyItemString(repairMaterial));
if (repairMaterialMetadata != (byte) -1) {
// TODO: Do something nicer than append the metadata as a :# ?
if (Repair.findInInventory(inventory, repairMaterialId, repairMaterialMetadata) == -1) {
message += ":" + repairMaterialMetadata;
}
if (repairMaterialMetadata != (byte) -1 && !inventory.containsAtLeast(toRemove, 1)) {
message += ":" + repairMaterialMetadata;
}
player.sendMessage(message);
@@ -123,24 +114,8 @@ public class RepairManager extends SkillManager {
int baseRepairAmount = repairable.getBaseRepairDurability(); // Did they send me daughters?
short newDurability = repairCalculate(startDurability, baseRepairAmount); // When I asked for sons?
// We're going to hold onto our repair item location
int repairItemLocation;
if (repairable.getRepairMaterialMetadata() == (byte) -1) {
repairItemLocation = Repair.findInInventory(inventory, repairMaterialId);
}
else {
// Special case for when the repairable has metadata that must be addressed
repairItemLocation = Repair.findInInventory(inventory, repairMaterialId, repairMaterialMetadata);
}
// This should never happen, but if it does we need to complain loudly about it.
if (repairItemLocation == -1) {
player.sendMessage(LocaleLoader.getString("Repair.Error"));
return;
}
// Call event
McMMOPlayerRepairCheckEvent event = new McMMOPlayerRepairCheckEvent(player, (short) (startDurability - newDurability), inventory.getItem(repairItemLocation), item);
McMMOPlayerRepairCheckEvent event = new McMMOPlayerRepairCheckEvent(player, (short) (startDurability - newDurability), toRemove, item);
mcMMO.p.getServer().getPluginManager().callEvent(event);
if (event.isCancelled()) {
@@ -153,7 +128,12 @@ public class RepairManager extends SkillManager {
}
// Remove the item
Repair.removeOneFrom(inventory, repairItemLocation);
if (repairMaterialMetadata == -1) {
toRemove = inventory.getItem(inventory.first(repairMaterial)).clone();
toRemove.setAmount(1);
}
inventory.removeItem(toRemove);
// Give out XP like candy
applyXpGain((float) ((getPercentageRepaired(startDurability, newDurability, repairable.getMaximumDurability()) * repairable.getXpMultiplier()) * ExperienceConfig.getInstance().getRepairXPBase() * ExperienceConfig.getInstance().getRepairXP(repairable.getRepairMaterialType())));
@@ -196,13 +176,12 @@ public class RepairManager extends SkillManager {
*
* @return true if the player has confirmed using an Anvil
*/
public boolean checkConfirmation(int anvilId, boolean actualize) {
public boolean checkConfirmation(Material anvilType, boolean actualize) {
Player player = getPlayer();
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
long lastUse = mcMMOPlayer.getLastAnvilUse(anvilId);
long lastUse = mcMMOPlayer.getLastAnvilUse(anvilType);
// Don't use SkillUtils.cooldownOver() here since that also accounts for the cooldown perks
if ((((lastUse + 3) * Misc.TIME_CONVERSION_FACTOR) >= System.currentTimeMillis()) || !Config.getInstance().getRepairConfirmRequired()) {
if (!SkillUtils.cooldownExpired(lastUse, 3) || !Config.getInstance().getRepairConfirmRequired()) {
return true;
}
@@ -210,12 +189,12 @@ public class RepairManager extends SkillManager {
return false;
}
mcMMOPlayer.actualizeLastAnvilUse(anvilId);
mcMMOPlayer.actualizeLastAnvilUse(anvilType);
if (anvilId == Repair.repairAnvilId) {
if (anvilType == Repair.repairAnvilMaterial) {
player.sendMessage(LocaleLoader.getString("Skills.ConfirmOrCancel", LocaleLoader.getString("Repair.Pretty.Name")));
}
else if (anvilId == Repair.salvageAnvilId) {
else if (anvilType == Repair.salvageAnvilMaterial) {
player.sendMessage(LocaleLoader.getString("Skills.ConfirmOrCancel", LocaleLoader.getString("Salvage.Pretty.Name")));
}

View File

@@ -1,5 +1,6 @@
package com.gmail.nossr50.skills.repair;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import com.gmail.nossr50.util.Permissions;
@@ -18,6 +19,7 @@ public enum RepairMaterialType {
* Get the base permissions associated with this RepairMaterialType.
*
* @param player The player to check the permissions for
*
* @return true if the player has permissions, false otherwise
*/
public boolean getPermissions(Player player) {
@@ -50,4 +52,33 @@ public enum RepairMaterialType {
return false;
}
}
public Material getDefaultRepairMaterial() {
switch (this) {
case STRING:
return Material.STRING;
case LEATHER:
return Material.LEATHER;
case WOOD:
return Material.WOOD;
case STONE:
return Material.COBBLESTONE;
case IRON:
return Material.IRON_INGOT;
case GOLD:
return Material.GOLD_INGOT;
case DIAMOND:
return Material.DIAMOND;
case OTHER:
default:
return null;
}
}
}

View File

@@ -1,19 +1,21 @@
package com.gmail.nossr50.skills.repair;
import org.bukkit.Material;
public interface Repairable {
/**
* Gets the item id of this repairable item
* Gets the type of this repairable item
*
* @return the id of this repairable
* @return the type of this repairable
*/
public int getItemId();
public Material getItemMaterial();
/**
* Gets the id of the material used to repair this item
*
* @return the id of the repair material
*/
public int getRepairMaterialId();
public Material getRepairMaterial();
/**
* Gets the metadata byte value of the material used to repair this item

View File

@@ -1,12 +1,14 @@
package com.gmail.nossr50.skills.repair;
import org.bukkit.Material;
public class RepairableFactory {
public static Repairable getRepairable(int itemId, int repairMaterialId, byte repairMetadata, int minimumQuantity, short maximumDurability) {
return getRepairable(itemId, repairMaterialId, repairMetadata, 0, minimumQuantity, maximumDurability, RepairItemType.OTHER, RepairMaterialType.OTHER, 1);
public static Repairable getRepairable(Material itemMaterial, Material repairMaterial, byte repairMetadata, int minimumQuantity, short maximumDurability) {
return getRepairable(itemMaterial, repairMaterial, repairMetadata, 0, minimumQuantity, maximumDurability, RepairItemType.OTHER, RepairMaterialType.OTHER, 1);
}
public static Repairable getRepairable(int itemId, int repairMaterialId, byte repairMetadata, int minimumLevel, int minimumQuantity, short maximumDurability, RepairItemType repairItemType, RepairMaterialType repairMaterialType, double xpMultiplier) {
public static Repairable getRepairable(Material itemMaterial, Material repairMaterial, byte repairMetadata, int minimumLevel, int minimumQuantity, short maximumDurability, RepairItemType repairItemType, RepairMaterialType repairMaterialType, double xpMultiplier) {
// TODO: Add in loading from config what type of repairable we want.
return new SimpleRepairable(itemId, repairMaterialId, repairMetadata, minimumLevel, minimumQuantity, maximumDurability, repairItemType, repairMaterialType, xpMultiplier);
return new SimpleRepairable(itemMaterial, repairMaterial, repairMetadata, minimumLevel, minimumQuantity, maximumDurability, repairItemType, repairMaterialType, xpMultiplier);
}
}

View File

@@ -2,6 +2,7 @@ package com.gmail.nossr50.skills.repair;
import java.util.List;
import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;
public interface RepairableManager {
@@ -22,24 +23,27 @@ public interface RepairableManager {
/**
* Checks if an item is repairable
*
* @param itemId id to check if repairable
* @param type Material to check if repairable
*
* @return true if repairable, false if not
*/
public boolean isRepairable(int itemId);
public boolean isRepairable(Material type);
/**
* Checks if an item is repairable
*
* @param itemStack Item to check if repairable
*
* @return true if repairable, false if not
*/
public boolean isRepairable(ItemStack itemStack);
/**
* Gets the repairable with this id
* Gets the repairable with this type
*
* @param type Material of the repairable to look for
*
* @param id Id of the repairable to look for
* @return the repairable, can be null
*/
public Repairable getRepairable(int id);
public Repairable getRepairable(Material type);
}

View File

@@ -1,16 +1,19 @@
package com.gmail.nossr50.skills.repair;
import org.bukkit.Material;
public class SimpleRepairable implements Repairable {
private final int itemId, repairMaterialId, minimumQuantity, minimumLevel;
private final Material itemMaterial, repairMaterial;
private final int minimumQuantity, minimumLevel;
private final short maximumDurability, baseRepairDurability;
private final byte repairMetadata;
private final RepairItemType repairItemType;
private final RepairMaterialType repairMaterialType;
private final double xpMultiplier;
protected SimpleRepairable(int itemId, int repairMaterialId, byte repairMetadata, int minimumLevel, int minimumQuantity, short maximumDurability, RepairItemType repairItemType, RepairMaterialType repairMaterialType, double xpMultiplier) {
this.itemId = itemId;
this.repairMaterialId = repairMaterialId;
protected SimpleRepairable(Material type, Material repairMaterial, byte repairMetadata, int minimumLevel, int minimumQuantity, short maximumDurability, RepairItemType repairItemType, RepairMaterialType repairMaterialType, double xpMultiplier) {
this.itemMaterial = type;
this.repairMaterial = repairMaterial;
this.repairMetadata = repairMetadata;
this.repairItemType = repairItemType;
this.repairMaterialType = repairMaterialType;
@@ -22,13 +25,13 @@ public class SimpleRepairable implements Repairable {
}
@Override
public int getItemId() {
return itemId;
public Material getItemMaterial() {
return itemMaterial;
}
@Override
public int getRepairMaterialId() {
return repairMaterialId;
public Material getRepairMaterial() {
return repairMaterial;
}
@Override

View File

@@ -3,23 +3,24 @@ package com.gmail.nossr50.skills.repair;
import java.util.HashMap;
import java.util.List;
import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;
public class SimpleRepairableManager implements RepairableManager {
private HashMap<Integer, Repairable> repairables;
private HashMap<Material, Repairable> repairables;
protected SimpleRepairableManager() {
this(55);
}
protected SimpleRepairableManager(int repairablesSize) {
this.repairables = new HashMap<Integer, Repairable>(repairablesSize);
this.repairables = new HashMap<Material, Repairable>(repairablesSize);
}
@Override
public void registerRepairable(Repairable repairable) {
Integer itemId = repairable.getItemId();
repairables.put(itemId, repairable);
Material item = repairable.getItemMaterial();
repairables.put(item, repairable);
}
@Override
@@ -30,17 +31,17 @@ public class SimpleRepairableManager implements RepairableManager {
}
@Override
public boolean isRepairable(int itemId) {
return repairables.containsKey(itemId);
public boolean isRepairable(Material type) {
return repairables.containsKey(type);
}
@Override
public boolean isRepairable(ItemStack itemStack) {
return isRepairable(itemStack.getTypeId());
return isRepairable(itemStack.getType());
}
@Override
public Repairable getRepairable(int id) {
return repairables.get(id);
public Repairable getRepairable(Material type) {
return repairables.get(type);
}
}

View File

@@ -4,13 +4,17 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import org.bukkit.Material;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.inventory.ItemStack;
import com.gmail.nossr50.config.ConfigLoader;
import com.gmail.nossr50.skills.repair.Repair;
import com.gmail.nossr50.skills.repair.RepairItemType;
import com.gmail.nossr50.skills.repair.RepairMaterialType;
import com.gmail.nossr50.skills.repair.Repairable;
import com.gmail.nossr50.skills.repair.RepairableFactory;
import com.gmail.nossr50.util.ItemUtils;
public class RepairConfig extends ConfigLoader {
private List<Repairable> repairables;
@@ -28,60 +32,120 @@ public class RepairConfig extends ConfigLoader {
Set<String> keys = section.getKeys(false);
for (String key : keys) {
if (config.contains("Repairables." + key + ".ItemId")) {
plugin.getLogger().warning("You are using an old version of the " + fileName + " file.");
plugin.getLogger().warning("You should delete your current file and allow a new one to generate.");
plugin.getLogger().warning("Repair will not work properly until you do.");
return;
}
// Validate all the things!
List<String> reason = new ArrayList<String>();
if (!config.contains("Repairables." + key + ".ItemId")) {
reason.add(key + " is missing ItemId");
// Item Material
Material itemMaterial = Material.matchMaterial(key);
if (itemMaterial == null) {
reason.add("Invalid material: " + key);
}
if (!config.contains("Repairables." + key + ".RepairMaterialId")) {
reason.add(key + " is missing RepairMaterialId");
}
if (!config.contains("Repairables." + key + ".MaximumDurability")) {
reason.add(key + " is missing MaximumDurability");
}
int itemId = config.getInt("Repairables." + key + ".ItemId", 0);
int repairMaterialId = config.getInt("Repairables." + key + ".RepairMaterialId", 0);
int maximumDurability = config.getInt("Repairables." + key + ".MaximumDurability", 0);
int repairMetadata = config.getInt("Repairables." + key + ".RepairMaterialMetadata", -1);
int minimumLevel = config.getInt("Repairables." + key + ".MinimumLevel", 0);
int minimumQuantity = config.getInt("Repairables." + key + ".MinimumQuantity", 2);
double xpMultiplier = config.getDouble("Repairables." + key + ".XpMultiplier", 1);
RepairItemType repairItemType = RepairItemType.OTHER;
// Repair Material Type
RepairMaterialType repairMaterialType = RepairMaterialType.OTHER;
String repairItemTypeString = config.getString("Repairables." + key + ".ItemType", "OTHER");
String repairMaterialTypeString = config.getString("Repairables." + key + ".MaterialType", "OTHER");
if (!config.contains("Repairables." + key + ".MaterialType") && itemMaterial != null) {
ItemStack repairItem = new ItemStack(itemMaterial);
if (ItemUtils.isWoodTool(repairItem)) {
repairMaterialType = RepairMaterialType.WOOD;
}
else if (ItemUtils.isStoneTool(repairItem)) {
repairMaterialType = RepairMaterialType.STONE;
}
else if (ItemUtils.isStringTool(repairItem)) {
repairMaterialType = RepairMaterialType.STRING;
}
else if (ItemUtils.isLeatherArmor(repairItem)) {
repairMaterialType = RepairMaterialType.LEATHER;
}
else if (ItemUtils.isIronArmor(repairItem) || ItemUtils.isIronTool(repairItem)) {
repairMaterialType = RepairMaterialType.IRON;
}
else if (ItemUtils.isGoldArmor(repairItem) || ItemUtils.isGoldTool(repairItem)) {
repairMaterialType = RepairMaterialType.GOLD;
}
else if (ItemUtils.isDiamondArmor(repairItem) || ItemUtils.isDiamondTool(repairItem)) {
repairMaterialType = RepairMaterialType.DIAMOND;
}
}
else {
try {
repairMaterialType = RepairMaterialType.valueOf(repairMaterialTypeString);
}
catch (IllegalArgumentException ex) {
reason.add(key + " has an invalid MaterialType of " + repairMaterialTypeString);
}
}
// Repair Material
String repairMaterialName = config.getString("Repairables." + key + ".RepairMaterial");
Material repairMaterial = (repairMaterialName == null ? repairMaterialType.getDefaultRepairMaterial() : Material.matchMaterial(repairMaterialName));
if (repairMaterial == null) {
reason.add(key + " has an invalid repair material: " + repairMaterialName);
}
// Maximum Durability
short maximumDurability = (itemMaterial != null ? itemMaterial.getMaxDurability() : (short) config.getInt("Repairables." + key + ".MaximumDurability"));
if (maximumDurability <= 0) {
reason.add("Maximum durability of " + key + " must be greater than 0!");
}
// Item Type
RepairItemType repairItemType = RepairItemType.OTHER;
String repairItemTypeString = config.getString("Repairables." + key + ".ItemType", "OTHER");
if (!config.contains("Repairables." + key + ".ItemType") && itemMaterial != null) {
ItemStack repairItem = new ItemStack(itemMaterial);
if (ItemUtils.isMinecraftTool(repairItem)) {
repairItemType = RepairItemType.TOOL;
}
else if (ItemUtils.isArmor(repairItem)) {
repairItemType = RepairItemType.ARMOR;
}
}
else {
try {
repairItemType = RepairItemType.valueOf(repairItemTypeString);
}
catch (IllegalArgumentException ex) {
reason.add(key + " has an invalid ItemType of " + repairItemTypeString);
}
}
byte repairMetadata = (byte) config.getInt("Repairables." + key + ".RepairMaterialMetadata", -1);
int minimumLevel = config.getInt("Repairables." + key + ".MinimumLevel");
double xpMultiplier = config.getDouble("Repairables." + key + ".XpMultiplier", 1);
if (minimumLevel < 0) {
reason.add(key + " has an invalid MinimumLevel of " + minimumLevel);
}
if (minimumQuantity < 0) {
reason.add(key + " has an invalid MinimumQuantity of " + minimumQuantity);
// Minimum Quantity
int minimumQuantity = (itemMaterial != null && repairMaterial != null ? Repair.getRepairAndSalvageQuantities(new ItemStack(itemMaterial), repairMaterial, repairMetadata) : config.getInt("Repairables." + key + ".MinimumQuantity"));
if (minimumQuantity <= 0 && itemMaterial != null) {
minimumQuantity = Repair.getRepairAndSalvageQuantities(new ItemStack(itemMaterial));
}
try {
repairItemType = RepairItemType.valueOf(repairItemTypeString);
}
catch (IllegalArgumentException ex) {
reason.add(key + " has an invalid ItemType of " + repairItemTypeString);
}
try {
repairMaterialType = RepairMaterialType.valueOf(repairMaterialTypeString);
}
catch (IllegalArgumentException ex) {
reason.add(key + " has an invalid MaterialType of " + repairMaterialTypeString);
if (minimumQuantity <= 0) {
reason.add("Minimum quantity of " + key + " must be greater than 0!");
}
if (noErrorsInRepairable(reason)) {
Repairable repairable = RepairableFactory.getRepairable(itemId, repairMaterialId, (byte) repairMetadata, minimumLevel, minimumQuantity, (short) maximumDurability, repairItemType, repairMaterialType, xpMultiplier);
Repairable repairable = RepairableFactory.getRepairable(itemMaterial, repairMaterial, repairMetadata, minimumLevel, minimumQuantity, maximumDurability, repairItemType, repairMaterialType, xpMultiplier);
repairables.add(repairable);
}
}

View File

@@ -69,6 +69,9 @@ public class Taming {
case WOLF:
return LocaleLoader.getString("Taming.Summon.Fail.Wolf");
case HORSE:
return LocaleLoader.getString("Taming.Summon.Fail.Horse");
default:
return "";

View File

@@ -5,6 +5,7 @@ import org.bukkit.entity.EntityType;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Ocelot;
import org.bukkit.entity.Player;
import org.bukkit.entity.Horse;
import org.bukkit.entity.Tameable;
import org.bukkit.entity.Wolf;
import org.bukkit.inventory.ItemStack;
@@ -224,7 +225,7 @@ public class TamingManager extends SkillManager {
switch (type) {
case OCELOT:
((Ocelot) entity).setCatType(Ocelot.Type.getType(1 + Misc.getRandom().nextInt(3)));
((Ocelot) entity).setCatType(Ocelot.Type.values()[1 + Misc.getRandom().nextInt(3)]);
break;
case WOLF:
@@ -232,6 +233,17 @@ public class TamingManager extends SkillManager {
entity.setHealth(entity.getMaxHealth());
break;
case HORSE:
Horse horse = (Horse) entity;
entity.setMaxHealth(15.0 + (Misc.getRandom().nextDouble() * 15));
entity.setHealth(entity.getMaxHealth());
horse.setColor(Horse.Color.values()[Misc.getRandom().nextInt(Horse.Color.values().length)]);
horse.setStyle(Horse.Style.values()[Misc.getRandom().nextInt(Horse.Style.values().length)]);
horse.setJumpStrength(Misc.getRandom().nextDouble() * 2);
//TODO: setSpeed, once available
break;
default:
break;
}

View File

@@ -229,7 +229,7 @@ public final class Woodcutting {
}
short finalDurability = (short) (inHand.getDurability() + durabilityLoss);
short maxDurability = ModUtils.isCustomTool(inHand) ? ModUtils.getToolFromItemStack(inHand).getDurability() : inHandMaterial.getMaxDurability();
short maxDurability = inHandMaterial.getMaxDurability();
boolean overMax = (finalDurability >= maxDurability);
inHand.setDurability(overMax ? maxDurability : finalDurability);

View File

@@ -5,9 +5,11 @@ import java.util.List;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.BlockFace;
import org.bukkit.block.BlockState;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.material.Tree;
import com.gmail.nossr50.datatypes.mods.CustomBlock;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
@@ -160,17 +162,20 @@ public class WoodcuttingManager extends SkillManager {
Misc.randomDropItem(blockState.getLocation(), ModUtils.getCustomBlock(blockState).getItemDrop(), 10);
}
else {
Tree tree = (Tree) blockState.getData();
tree.setDirection(BlockFace.UP);
switch (material) {
case LOG:
if (canGetDoubleDrops()) {
Woodcutting.checkForDoubleDrop(blockState);
}
xp += Woodcutting.getExperienceFromLog(blockState, ExperienceGainMethod.TREE_FELLER);
Misc.dropItem(blockState.getLocation(), blockState.getData().toItemStack(1));
Misc.dropItem(blockState.getLocation(), tree.toItemStack(1));
break;
case LEAVES:
Misc.randomDropItem(blockState.getLocation(), blockState.getData().toItemStack(1), 10);
Misc.randomDropItem(blockState.getLocation(), new ItemStack(Material.SAPLING, 1, tree.getSpecies().getData()), 10);
break;
default:

View File

@@ -318,9 +318,9 @@ public final class BlockUtils {
* @return true if the block is an mcMMO anvil, false otherwise
*/
public static boolean isMcMMOAnvil(BlockState blockState) {
int blockId = blockState.getTypeId();
Material type = blockState.getType();
return blockId == Repair.repairAnvilId || blockId == Repair.salvageAnvilId;
return type == Repair.repairAnvilMaterial || type == Repair.salvageAnvilMaterial;
}
/**

View File

@@ -142,7 +142,7 @@ public final class ChimaeraWing {
}
public static ItemStack getChimaeraWing(int amount) {
ItemStack itemStack = new ItemStack(Config.getInstance().getChimaeraItemId(), amount);
ItemStack itemStack = new ItemStack(Config.getInstance().getChimaeraItem(), amount);
ItemMeta itemMeta = itemStack.getItemMeta();
itemMeta.setDisplayName(ChatColor.GOLD + LocaleLoader.getString("Item.ChimaeraWing.Name"));
@@ -157,7 +157,7 @@ public final class ChimaeraWing {
}
public static ShapelessRecipe getChimaeraWingRecipe() {
Material ingredient = Material.getMaterial(Config.getInstance().getChimaeraItemId());
Material ingredient = Config.getInstance().getChimaeraItem();
int amount = Config.getInstance().getChimaeraRecipeCost();
if (amount < 1 || amount > 9) {
amount = 9;

View File

@@ -16,10 +16,6 @@ public final class HardcoreManager {
public static void invokeStatPenalty(Player player) {
double statLossPercentage = Config.getInstance().getHardcoreDeathStatPenaltyPercentage();
if (statLossPercentage <= 0 || statLossPercentage > 100) {
return;
}
McMMOPlayerDeathPenaltyEvent eventToFire = new McMMOPlayerDeathPenaltyEvent(player);
mcMMO.p.getServer().getPluginManager().callEvent(eventToFire);
@@ -49,10 +45,6 @@ public final class HardcoreManager {
public static void invokeVampirism(Player killer, Player victim) {
double vampirismStatLeechPercentage = Config.getInstance().getHardcoreVampirismStatLeechPercentage();
if (vampirismStatLeechPercentage <= 0 || vampirismStatLeechPercentage > 100) {
return;
}
McMMOPlayerDeathPenaltyEvent eventToFire = new McMMOPlayerDeathPenaltyEvent(victim);
mcMMO.p.getServer().getPluginManager().callEvent(eventToFire);

View File

@@ -7,10 +7,13 @@ import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Collections;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.List;
import java.util.Random;
import org.bukkit.ChatColor;
import org.bukkit.Color;
@@ -25,7 +28,8 @@ import org.bukkit.inventory.meta.FireworkMeta;
import com.gmail.nossr50.mcMMO;
public final class HolidayManager {
public static ArrayList<String> hasCelebrated;
private static ArrayList<String> hasCelebrated;
private static final Random rand = new Random();
private HolidayManager() {}
@@ -78,35 +82,87 @@ public final class HolidayManager {
// This gets called from /mcmmo command
public static void anniversaryCheck(final CommandSender sender) {
GregorianCalendar anniversaryStart = new GregorianCalendar(2014, Calendar.FEBRUARY, 3);
GregorianCalendar anniversaryEnd = new GregorianCalendar(2014, Calendar.FEBRUARY, 6);
GregorianCalendar day = new GregorianCalendar();
if (hasCelebrated == null) {
createAnniversaryFile();
}
if (hasCelebrated.contains(sender.getName())) {
return;
}
if (!getDateRange(day.getTime(), anniversaryStart.getTime(), anniversaryEnd.getTime())) {
return;
}
sender.sendMessage(ChatColor.BLUE + "Happy 3 Year Anniversary! In honor of all of");
sender.sendMessage(ChatColor.BLUE + "nossr50's work and all the devs, here's a firework show!");
if (sender instanceof Player) {
GregorianCalendar anniversaryStart = new GregorianCalendar(2013, Calendar.FEBRUARY, 3);
GregorianCalendar anniversaryEnd = new GregorianCalendar(2013, Calendar.FEBRUARY, 6);
GregorianCalendar day = new GregorianCalendar();
if (hasCelebrated == null) {
createAnniversaryFile();
}
if (hasCelebrated.contains(sender.getName())) {
return;
}
if (getDateRange(day.getTime(), anniversaryStart.getTime(), anniversaryEnd.getTime())) {
sender.sendMessage(ChatColor.BLUE + "Happy 2 Year Anniversary! In honor of all of");
sender.sendMessage(ChatColor.BLUE + "nossr50's work and all the devs, here's a firework show!");
final int firework_amount = 10;
for (int i = 0; i < firework_amount; i++) {
int delay = (int) (Math.random() * 3) + 4;
mcMMO.p.getServer().getScheduler().runTaskLater(mcMMO.p, new Runnable() {
@Override
public void run() {
spawnFireworks((Player) sender);
}
}, 20 * delay);
}
hasCelebrated.add(sender.getName());
final int firework_amount = 10;
for (int i = 0; i < firework_amount; i++) {
int delay = (int) (rand.nextDouble() * 3 * 20) + 4;
mcMMO.p.getServer().getScheduler().runTaskLater(mcMMO.p, new Runnable() {
@Override
public void run() {
spawnFireworks((Player) sender);
}
}, delay);
}
}
else {
/*
* Credit: http://www.geocities.com/spunk1111/
* (good luck finding that in 3 years heh)
* .''. . *''* :_\/_: .
* :_\/_: _\(/_ .:.*_\/_* : /\ : .'.:.'.
* .''.: /\ : /)\ ':'* /\ * : '..'. -=:o:=-
* :_\/_:'.:::. ' *''* * '.\'/.'_\(/_ '.':'.'
* : /\ : ::::: *_\/_* -= o =- /)\ '
* '..' ':::' * /\ * .'/.\'. ' *
* * *..* : *
* * * *
* * * *
*/
/*
* Color map
* AAAA D GGGG JJJJJJ K
* AAAAAA DDDDD EEEGGGGGG JJJJJJ KKKKKKK
* BBBBAAAAAA DDD EEEGGGGGG I JJJJJ KKKKKKK
* BBBBBBACCCCC D FFFF G IIIIIIIHHHHH KKKKKKK
* BBBBBB CCCCC FFFFFF IIIIIII HHH K
* BBBB CCCCC FFFFFF IIIIIII H k
* b FFFF I k
* b i k
* b i k
*/
String colorA = chatColorChoose();
String colorB = chatColorChoose();
String colorC = chatColorChoose();
String colorD = chatColorChoose();
String colorE = chatColorChoose();
String colorF = chatColorChoose();
String colorG = chatColorChoose();
String colorH = chatColorChoose();
String colorI = chatColorChoose();
String colorJ = chatColorChoose();
String colorK = chatColorChoose();
Object[] colorParams = new Object[]{colorA, colorB, colorC, colorD, colorE, colorF, colorG, colorH, colorI, colorJ, colorK};
sender.sendMessage(String.format(" %1$s.''. %4$s. %7$s*''* %10$s:_\\/_: %11$s.", colorParams));
sender.sendMessage(String.format(" %1$s:_\\/_: %4$s_\\(/_ %5$s.:.%7$s*_\\/_* %10$s: /\\ : %11$s.'.:.'.", colorParams));
sender.sendMessage(String.format(" %2$s.''.%1$s: /\\ : %4$s/)\\ %5$s':'%7$s* /\\ * %9$s: %10$s'..'. %11$s-=:o:=-", colorParams));
sender.sendMessage(String.format("%2$s:_\\/_:%1$s'%3$s.:::. %4$s' %6$s*''* %7$s* %9$s'.\\'/.'%8$s_\\(/_ %11$s'.':'.'", colorParams));
sender.sendMessage(String.format("%2$s: /\\ : %3$s::::: %6$s*_\\/_* %9$s-= o =-%8$s /)\\ %11$s'", colorParams));
sender.sendMessage(String.format(" %2$s'..' %3$s':::' %6$s* /\\ * %9$s.'/.\\'. %8$s' %11$s*", colorParams));
sender.sendMessage(String.format(" %2$s* %6$s*..* %9$s: %11$s*", colorParams));
sender.sendMessage(String.format(" %2$s* %9$s* %11$s*", colorParams));
sender.sendMessage(String.format(" %2$s* %9$s* %11$s*", colorParams));
}
hasCelebrated.add(sender.getName());
}
private static boolean getDateRange(Date date, Date start, Date end) {
@@ -114,8 +170,10 @@ public final class HolidayManager {
}
private static void spawnFireworks(Player player) {
int power = (int) (Math.random() * 3) + 1;
int type = (int) (Math.random() * 5) + 1;
int power = (int) (rand.nextDouble() * 3) + 1;
int type = (int) (rand.nextDouble() * 5) + 1;
double varX = rand.nextGaussian() * 3;
double varZ = rand.nextGaussian() * 3;
Type typen;
switch (type) {
@@ -139,43 +197,66 @@ public final class HolidayManager {
typen = Type.BALL;
}
Firework fireworks = (Firework) player.getWorld().spawnEntity(player.getLocation(), EntityType.FIREWORK);
Firework fireworks = (Firework) player.getWorld().spawnEntity(player.getLocation().add(varX, 0, varZ), EntityType.FIREWORK);
FireworkMeta fireworkmeta = fireworks.getFireworkMeta();
FireworkEffect effect = FireworkEffect.builder().flicker(Misc.getRandom().nextBoolean()).withColor(colorchoose()).withFade(colorchoose()).with(typen).trail(Misc.getRandom().nextBoolean()).build();
FireworkEffect effect = FireworkEffect.builder().flicker(rand.nextBoolean()).withColor(colorChoose()).withFade(colorChoose()).with(typen).trail(rand.nextBoolean()).build();
fireworkmeta.addEffect(effect);
fireworkmeta.setPower(power);
fireworks.setFireworkMeta(fireworkmeta);
}
private static List<Color> colorchoose() {
private static List<Color> colorChoose() {
// Thanks Zomis and Tejpbit for the help with this function!
Collections.shuffle(ALL_COLORS, rand);
int numberofcolors = Misc.getRandom().nextInt(17) + 1;
int numberOfColors = rand.nextInt(ALL_COLORS.size());
List<Color> choosenColors = ALL_COLORS.subList(0, numberOfColors);
List<Color> allcolors = new ArrayList<Color>();
allcolors.add(Color.AQUA);
allcolors.add(Color.BLACK);
allcolors.add(Color.BLUE);
allcolors.add(Color.FUCHSIA);
allcolors.add(Color.GRAY);
allcolors.add(Color.GREEN);
allcolors.add(Color.LIME);
allcolors.add(Color.MAROON);
allcolors.add(Color.NAVY);
allcolors.add(Color.OLIVE);
allcolors.add(Color.ORANGE);
allcolors.add(Color.PURPLE);
allcolors.add(Color.RED);
allcolors.add(Color.SILVER);
allcolors.add(Color.TEAL);
allcolors.add(Color.WHITE);
allcolors.add(Color.YELLOW);
return new ArrayList<Color>(choosenColors); // don't let caller modify ALL_COLORS
}
List<Color> choosencolors = new ArrayList<Color>();
private static String chatColorChoose() {
StringBuilder ret = new StringBuilder(ALL_CHAT_COLORS.get(rand.nextInt(ALL_CHAT_COLORS.size())).toString());
for (int i = 0; i < numberofcolors; i++) {
choosencolors.add(allcolors.remove(Misc.getRandom().nextInt(allcolors.size())));
for (ChatColor CHAT_FORMAT : CHAT_FORMATS) {
if (rand.nextInt(4) == 0) {
ret.append(CHAT_FORMAT);
}
}
return choosencolors;
return ret.toString();
}
private static final List<Color> ALL_COLORS;
private static final List<ChatColor> ALL_CHAT_COLORS;
private static final ChatColor[] CHAT_FORMATS = new ChatColor[]{ChatColor.BOLD, ChatColor.ITALIC, ChatColor.UNDERLINE, ChatColor.STRIKETHROUGH};
static {
ALL_COLORS = Arrays.asList(
Color.AQUA,
Color.BLACK,
Color.BLUE,
Color.FUCHSIA,
Color.GRAY,
Color.GREEN,
Color.LIME,
Color.MAROON,
Color.NAVY,
Color.OLIVE,
Color.ORANGE,
Color.PURPLE,
Color.RED,
Color.SILVER,
Color.TEAL,
Color.WHITE,
Color.YELLOW
);
ALL_CHAT_COLORS = new ArrayList<ChatColor>(16);
for (ChatColor c : ChatColor.values()) {
if (c.isColor()) {
ALL_CHAT_COLORS.add(c);
}
}
Collections.shuffle(ALL_CHAT_COLORS, rand);
}
}

View File

@@ -7,8 +7,6 @@ import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.material.Dye;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.api.SpoutToolsAPI;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.config.mods.CustomArmorConfig;
import com.gmail.nossr50.config.mods.CustomToolConfig;
@@ -16,6 +14,25 @@ import com.gmail.nossr50.config.party.ItemWeightConfig;
import com.gmail.nossr50.locale.LocaleLoader;
public class ItemUtils {
/**
* Checks if the item is a bow.
*
* @param item Item to check
* @return true if the item is a bow, false otherwise
*/
public static boolean isBow(ItemStack item) {
Material type = item.getType();
switch (type) {
case BOW:
return true;
default:
return (Config.getInstance().getToolModsEnabled() && CustomToolConfig.getInstance().isCustomBow(type));
}
}
/**
* Checks if the item is a sword.
*
@@ -23,7 +40,9 @@ public class ItemUtils {
* @return true if the item is a sword, false otherwise
*/
public static boolean isSword(ItemStack item) {
switch (item.getType()) {
Material type = item.getType();
switch (type) {
case DIAMOND_SWORD:
case GOLD_SWORD:
case IRON_SWORD:
@@ -32,7 +51,7 @@ public class ItemUtils {
return true;
default:
return (Config.getInstance().getToolModsEnabled() && CustomToolConfig.getInstance().customSwordIDs.contains(item.getTypeId())) || (mcMMO.isSpoutEnabled() && SpoutToolsAPI.spoutSwords.contains(item));
return (Config.getInstance().getToolModsEnabled() && CustomToolConfig.getInstance().isCustomSword(type));
}
}
@@ -43,7 +62,9 @@ public class ItemUtils {
* @return true if the item is a hoe, false otherwise
*/
public static boolean isHoe(ItemStack item) {
switch (item.getType()) {
Material type = item.getType();
switch (type) {
case DIAMOND_HOE:
case GOLD_HOE:
case IRON_HOE:
@@ -52,7 +73,7 @@ public class ItemUtils {
return true;
default:
return (Config.getInstance().getToolModsEnabled() && CustomToolConfig.getInstance().customHoeIDs.contains(item.getTypeId())) || (mcMMO.isSpoutEnabled() && SpoutToolsAPI.spoutHoes.contains(item));
return (Config.getInstance().getToolModsEnabled() && CustomToolConfig.getInstance().isCustomHoe(type));
}
}
@@ -63,7 +84,9 @@ public class ItemUtils {
* @return true if the item is a shovel, false otherwise
*/
public static boolean isShovel(ItemStack item) {
switch (item.getType()) {
Material type = item.getType();
switch (type) {
case DIAMOND_SPADE:
case GOLD_SPADE:
case IRON_SPADE:
@@ -72,7 +95,7 @@ public class ItemUtils {
return true;
default:
return (Config.getInstance().getToolModsEnabled() && CustomToolConfig.getInstance().customShovelIDs.contains(item.getTypeId())) || (mcMMO.isSpoutEnabled() && SpoutToolsAPI.spoutShovels.contains(item));
return (Config.getInstance().getToolModsEnabled() && CustomToolConfig.getInstance().isCustomShovel(type));
}
}
@@ -83,7 +106,9 @@ public class ItemUtils {
* @return true if the item is an axe, false otherwise
*/
public static boolean isAxe(ItemStack item) {
switch (item.getType()) {
Material type = item.getType();
switch (type) {
case DIAMOND_AXE:
case GOLD_AXE:
case IRON_AXE:
@@ -92,7 +117,7 @@ public class ItemUtils {
return true;
default:
return (Config.getInstance().getToolModsEnabled() && CustomToolConfig.getInstance().customAxeIDs.contains(item.getTypeId())) || (mcMMO.isSpoutEnabled() && SpoutToolsAPI.spoutAxes.contains(item));
return (Config.getInstance().getToolModsEnabled() && CustomToolConfig.getInstance().isCustomAxe(type));
}
}
@@ -103,7 +128,9 @@ public class ItemUtils {
* @return true if the item is a pickaxe, false otherwise
*/
public static boolean isPickaxe(ItemStack item) {
switch (item.getType()) {
Material type = item.getType();
switch (type) {
case DIAMOND_PICKAXE:
case GOLD_PICKAXE:
case IRON_PICKAXE:
@@ -112,7 +139,7 @@ public class ItemUtils {
return true;
default:
return (Config.getInstance().getToolModsEnabled() && CustomToolConfig.getInstance().customPickaxeIDs.contains(item.getTypeId())) || (mcMMO.isSpoutEnabled() && SpoutToolsAPI.spoutPickaxes.contains(item));
return (Config.getInstance().getToolModsEnabled() && CustomToolConfig.getInstance().isCustomPickaxe(type));
}
}
@@ -123,7 +150,9 @@ public class ItemUtils {
* @return true if the item is a helmet, false otherwise
*/
public static boolean isHelmet(ItemStack item) {
switch (item.getType()) {
Material type = item.getType();
switch (type) {
case DIAMOND_HELMET:
case GOLD_HELMET:
case IRON_HELMET:
@@ -132,7 +161,7 @@ public class ItemUtils {
return true;
default:
return Config.getInstance().getArmorModsEnabled() && CustomArmorConfig.getInstance().customHelmetIDs.contains(item.getTypeId());
return Config.getInstance().getArmorModsEnabled() && CustomArmorConfig.getInstance().isCustomHelmet(type);
}
}
@@ -143,7 +172,9 @@ public class ItemUtils {
* @return true if the item is a chestplate, false otherwise
*/
public static boolean isChestplate(ItemStack item) {
switch (item.getType()) {
Material type = item.getType();
switch (type) {
case DIAMOND_CHESTPLATE:
case GOLD_CHESTPLATE:
case IRON_CHESTPLATE:
@@ -152,7 +183,7 @@ public class ItemUtils {
return true;
default:
return Config.getInstance().getArmorModsEnabled() && CustomArmorConfig.getInstance().customChestplateIDs.contains(item.getTypeId());
return Config.getInstance().getArmorModsEnabled() && CustomArmorConfig.getInstance().isCustomChestplate(type);
}
}
@@ -163,7 +194,9 @@ public class ItemUtils {
* @return true if the item is a pair of pants, false otherwise
*/
public static boolean isLeggings(ItemStack item) {
switch (item.getType()) {
Material type = item.getType();
switch (type) {
case DIAMOND_LEGGINGS:
case GOLD_LEGGINGS:
case IRON_LEGGINGS:
@@ -172,7 +205,7 @@ public class ItemUtils {
return true;
default:
return Config.getInstance().getArmorModsEnabled() && CustomArmorConfig.getInstance().customLeggingIDs.contains(item.getTypeId());
return Config.getInstance().getArmorModsEnabled() && CustomArmorConfig.getInstance().isCustomLeggings(type);
}
}
@@ -183,7 +216,9 @@ public class ItemUtils {
* @return true if the item is a pair of boots, false otherwise
*/
public static boolean isBoots(ItemStack item) {
switch (item.getType()) {
Material type = item.getType();
switch (type) {
case DIAMOND_BOOTS:
case GOLD_BOOTS:
case IRON_BOOTS:
@@ -192,7 +227,7 @@ public class ItemUtils {
return true;
default:
return Config.getInstance().getArmorModsEnabled() && CustomArmorConfig.getInstance().customBootIDs.contains(item.getTypeId());
return Config.getInstance().getArmorModsEnabled() && CustomArmorConfig.getInstance().isCustomBoots(type);
}
}
@@ -453,12 +488,11 @@ public class ItemUtils {
case SHEARS:
case FISHING_ROD:
case CARROT_STICK:
case BOW:
case FLINT_AND_STEEL:
return true;
default:
return isArmor(item) || isSword(item) || isAxe(item) || isShovel(item) || isPickaxe(item);
return isArmor(item) || isSword(item) || isAxe(item) || isShovel(item) || isPickaxe(item) || isBow(item);
}
}

View File

@@ -8,6 +8,7 @@ import java.util.Random;
import org.bukkit.Chunk;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.OfflinePlayer;
import org.bukkit.block.Block;
import org.bukkit.block.BlockState;
import org.bukkit.block.Furnace;
@@ -21,12 +22,10 @@ import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.metadata.MetadataValue;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.spout.huds.McMMOHud;
import com.gmail.nossr50.events.items.McMMOItemSpawnEvent;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.spout.SpoutUtils;
public final class Misc {
private static Random random = new Random();
@@ -38,13 +37,15 @@ public final class Misc {
public static final double SKILL_MESSAGE_MAX_SENDING_DISTANCE = 10.0;
// Sound Pitches & Volumes from CB
public static final float ANVIL_USE_PITCH = 0.3F; // Not in CB directly, I went off the place sound values
public static final float ANVIL_USE_VOLUME = 1.0F; // Not in CB directly, I went off the place sound values
public static final float ANVIL_USE_PITCH = 0.3F; // Not in CB directly, I went off the place sound values
public static final float ANVIL_USE_VOLUME = 1.0F; // Not in CB directly, I went off the place sound values
public static final float FIZZ_VOLUME = 0.5F;
public static final float POP_VOLUME = 0.2F;
public static final float BAT_VOLUME = 1.0F;
public static final float BAT_PITCH = 0.6F;
public static final float GHAST_VOLUME = 1.0F;
public static final float LEVELUP_PITCH = 0.5F; // Reduced to differentiate between vanilla level-up
public static final float LEVELUP_VOLUME = 0.75F; // Use max volume always
private Misc() {};
@@ -182,22 +183,12 @@ public final class Misc {
}
public static void profileCleanup(String playerName) {
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(playerName);
Player player = mcMMOPlayer.getPlayer();
McMMOHud spoutHud = mcMMOPlayer.getProfile().getSpoutHud();
if (spoutHud != null) {
spoutHud.removeWidgets();
}
UserManager.remove(playerName);
if (player.isOnline()) {
UserManager.addUser(player);
Player player = mcMMO.p.getServer().getPlayerExact(playerName);
if (mcMMO.isSpoutEnabled()) {
SpoutUtils.reloadSpoutPlayer(player);
}
if (player != null) {
UserManager.addUser(player);
}
}
@@ -271,7 +262,9 @@ public final class Misc {
public static List<String> matchPlayer(String partialName) {
List<String> matchedPlayers = new ArrayList<String>();
for (String playerName : mcMMO.getDatabaseManager().getStoredUsers()) {
for (OfflinePlayer offlinePlayer : mcMMO.p.getServer().getOfflinePlayers()) {
String playerName = offlinePlayer.getName();
if (partialName.equalsIgnoreCase(playerName)) {
// Exact match
matchedPlayers.clear();
@@ -291,13 +284,23 @@ public final class Misc {
* Get a matched player name if one was found in the database.
*
* @param partialName Name to match
*
* @return Matched name or {@code partialName} if no match was found
*/
public static String getMatchedPlayerName(String partialName) {
List<String> matches = matchPlayer(partialName);
if (Config.getInstance().getMatchOfflinePlayers()) {
List<String> matches = matchPlayer(partialName);
if (matches.size() == 1) {
partialName = matches.get(0);
if (matches.size() == 1) {
partialName = matches.get(0);
}
}
else {
Player player = mcMMO.p.getServer().getPlayer(partialName);
if (player != null) {
partialName = player.getName();
}
}
return partialName;

View File

@@ -40,7 +40,7 @@ public final class MobHealthbarUtils {
* @param damage damage done by the attack triggering this
*/
public static void handleMobHealthbars(Player player, LivingEntity target, double damage) {
if (!Permissions.mobHealthDisplay(player)) {
if (mcMMO.isHealthBarPluginEnabled() || !Permissions.mobHealthDisplay(player)) {
return;
}

View File

@@ -1,39 +1,32 @@
package com.gmail.nossr50.util;
import java.io.File;
import org.bukkit.block.BlockState;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Entity;
import org.bukkit.inventory.ItemStack;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.config.mods.CustomArmorConfig;
import com.gmail.nossr50.config.mods.CustomBlockConfig;
import com.gmail.nossr50.config.mods.CustomEntityConfig;
import com.gmail.nossr50.config.mods.CustomToolConfig;
import com.gmail.nossr50.datatypes.mods.CustomBlock;
import com.gmail.nossr50.datatypes.mods.CustomEntity;
import com.gmail.nossr50.datatypes.mods.CustomItem;
import com.gmail.nossr50.datatypes.mods.CustomTool;
public final class ModUtils {
private static Config configInstance = Config.getInstance();
private static boolean customToolsEnabled = configInstance.getToolModsEnabled();
private static boolean customArmorEnabled = configInstance.getArmorModsEnabled();
private static boolean customBlocksEnabled = configInstance.getBlockModsEnabled();
private static boolean customEntitiesEnabled = configInstance.getEntityModsEnabled();
private ModUtils() {}
/**
* Get the custom armor associated with an item.
*
* @param item The item to check
* @return the armor if it exists, null otherwise
*/
public static CustomItem getArmorFromItemStack(ItemStack item) {
return CustomArmorConfig.getInstance().customArmor.get(item.getTypeId());
}
/**
* Get the custom tool associated with an item.
*
@@ -41,65 +34,37 @@ public final class ModUtils {
* @return the tool if it exists, null otherwise
*/
public static CustomTool getToolFromItemStack(ItemStack item) {
return CustomToolConfig.getInstance().customTools.get(item.getTypeId());
return CustomToolConfig.getInstance().getCustomTool(item.getType());
}
/**
* Get the custom entity associated with an entity.
*
* @param entity The entity to check
* @return the entity is if exists, null otherwise
*/
public static CustomEntity getCustomEntity(Entity entity) {
return CustomEntityConfig.getInstance().getCustomEntity(entity);
}
/**
* Get the custom block associated with an block.
*
* @param blockState The block to check
* @param blockState The BlockState of the bloc to check
* @return the block if it exists, null otherwise
*/
public static CustomBlock getCustomBlock(BlockState blockState) {
if (customBlocksEnabled) {
ItemStack item = blockState.getData().toItemStack(1);
if (CustomBlockConfig.getInstance().customItems.contains(item)) {
for (CustomBlock block : CustomBlockConfig.getInstance().customBlocks) {
if ((block.getItemID() == blockState.getTypeId()) && (block.getDataValue() == blockState.getRawData())) {
return block;
}
}
}
}
return null;
}
public static CustomEntity getCustomEntity(Entity entity) {
if (!CustomEntityConfig.getInstance().customEntityIds.contains(entity.getEntityId()) && !CustomEntityConfig.getInstance().customEntityTypes.contains(entity.getType())) {
return null;
}
for (CustomEntity customEntity : CustomEntityConfig.getInstance().customEntities) {
if ((customEntity.getEntityID() == entity.getEntityId()) && (customEntity.getEntityType() == entity.getType())) {
return customEntity;
}
}
return null;
return CustomBlockConfig.getInstance().getCustomBlock(blockState.getData());
}
/**
* Check if a custom block is a woodcutting block.
*
* @param blockState The BlockState of the block to check
* @return true if the block represents a log, false otherwise
* @return true if the block represents a custom woodcutting block, false otherwise
*/
public static boolean isCustomWoodcuttingBlock(BlockState blockState) {
if (customBlocksEnabled) {
ItemStack item = blockState.getData().toItemStack(1);
if (CustomBlockConfig.getInstance().customWoodcuttingBlocks.contains(item)) {
for (CustomBlock block : CustomBlockConfig.getInstance().customBlocks) {
if ((block.getItemID() == blockState.getTypeId()) && (block.getDataValue() == blockState.getRawData())) {
return true;
}
}
}
}
return false;
return customBlocksEnabled && CustomBlockConfig.getInstance().isCustomWoodcuttingBlock(blockState.getData());
}
/**
@@ -109,85 +74,37 @@ public final class ModUtils {
* @return true if the block represents an ability block, false otherwise
*/
public static boolean isCustomAbilityBlock(BlockState blockState) {
if (customBlocksEnabled) {
ItemStack item = blockState.getData().toItemStack(1);
if (CustomBlockConfig.getInstance().customAbilityBlocks.contains(item)) {
for (CustomBlock block : CustomBlockConfig.getInstance().customBlocks) {
if ((block.getItemID() == blockState.getTypeId()) && (block.getDataValue() == blockState.getRawData())) {
return true;
}
}
}
}
return false;
return customBlocksEnabled && CustomBlockConfig.getInstance().isCustomAbilityBlock(blockState.getData());
}
/**
* Check if a custom block is a mining block.
*
* @param blockState The BlockState of the block to check
* @return true if the block is custom, false otherwise
* @return true if the block represents a custom mining block, false otherwise
*/
public static boolean isCustomMiningBlock(BlockState blockState) {
if (customBlocksEnabled) {
ItemStack item = blockState.getData().toItemStack(1);
if (CustomBlockConfig.getInstance().customMiningBlocks.contains(item)) {
for (CustomBlock block : CustomBlockConfig.getInstance().customBlocks) {
if ((block.getItemID() == blockState.getTypeId()) && (block.getDataValue() == blockState.getRawData())) {
return true;
}
}
}
}
return false;
return customBlocksEnabled && CustomBlockConfig.getInstance().isCustomMiningBlock(blockState.getData());
}
/**
* Check if a custom block is an excavation block.
*
* @param blockState The BlockState of the block to check
* @return true if the block is custom, false otherwise
* @return true if the block represents a custom excavation block, false otherwise
*/
public static boolean isCustomExcavationBlock(BlockState blockState) {
if (customBlocksEnabled) {
ItemStack item = blockState.getData().toItemStack(1);
if (CustomBlockConfig.getInstance().customExcavationBlocks.contains(item)) {
for (CustomBlock block : CustomBlockConfig.getInstance().customBlocks) {
if ((block.getItemID() == blockState.getTypeId()) && (block.getDataValue() == blockState.getRawData())) {
return true;
}
}
}
}
return false;
return customBlocksEnabled && CustomBlockConfig.getInstance().isCustomExcavationBlock(blockState.getData());
}
/**
* Check if a custom block is an herbalism block.
*
* @param blockState The block to check
* @return true if the block is custom, false otherwise
* @param blockState The BlockState of the block to check
* @return true if the block represents a custom herbalism block, false otherwise
*/
public static boolean isCustomHerbalismBlock(BlockState blockState) {
if (customBlocksEnabled) {
ItemStack item = blockState.getData().toItemStack(1);
if (CustomBlockConfig.getInstance().customHerbalismBlocks.contains(item)) {
for (CustomBlock block : CustomBlockConfig.getInstance().customBlocks) {
if ((block.getItemID() == blockState.getTypeId()) && (block.getDataValue() == blockState.getRawData())) {
return true;
}
}
}
}
return false;
return customBlocksEnabled && CustomBlockConfig.getInstance().isCustomHerbalismBlock(blockState.getData());
}
/**
@@ -197,19 +114,7 @@ public final class ModUtils {
* @return true if the block represents leaves, false otherwise
*/
public static boolean isCustomLeafBlock(BlockState blockState) {
if (customBlocksEnabled) {
ItemStack item = blockState.getData().toItemStack(1);
if (CustomBlockConfig.getInstance().customLeaves.contains(item)) {
for (CustomBlock block : CustomBlockConfig.getInstance().customBlocks) {
if ((block.getItemID() == blockState.getTypeId()) && (block.getDataValue() == blockState.getRawData())) {
return true;
}
}
}
}
return false;
return customBlocksEnabled && CustomBlockConfig.getInstance().isCustomLeaf(blockState.getData());
}
/**
@@ -219,41 +124,17 @@ public final class ModUtils {
* @return true if the block represents a log, false otherwise
*/
public static boolean isCustomLogBlock(BlockState blockState) {
if (customBlocksEnabled) {
ItemStack item = blockState.getData().toItemStack(1);
if (CustomBlockConfig.getInstance().customLogs.contains(item)) {
for (CustomBlock block : CustomBlockConfig.getInstance().customBlocks) {
if ((block.getItemID() == blockState.getTypeId()) && (block.getDataValue() == blockState.getRawData())) {
return true;
}
}
}
}
return false;
return customBlocksEnabled && CustomBlockConfig.getInstance().isCustomLog(blockState.getData());
}
/**
* Check if a custom block is an ore block.
*
* @param blockState The block to check
* @param blockState The BlockState of the block to check
* @return true if the block represents an ore, false otherwise
*/
public static boolean isCustomOreBlock(BlockState blockState) {
if (customBlocksEnabled) {
ItemStack item = blockState.getData().toItemStack(1);
if (CustomBlockConfig.getInstance().customOres.contains(item)) {
for (CustomBlock block : CustomBlockConfig.getInstance().customBlocks) {
if ((block.getItemID() == blockState.getTypeId()) && (block.getDataValue() == blockState.getRawData())) {
return true;
}
}
}
}
return false;
return customBlocksEnabled && CustomBlockConfig.getInstance().isCustomOre(blockState.getData());
}
/**
@@ -263,33 +144,17 @@ public final class ModUtils {
* @return true if the item is a custom tool, false otherwise
*/
public static boolean isCustomTool(ItemStack item) {
if (customToolsEnabled && CustomToolConfig.getInstance().customTools.containsKey(item.getTypeId())) {
return true;
}
return false;
return customToolsEnabled && CustomToolConfig.getInstance().isCustomTool(item.getType());
}
/**
* Checks to see if an item is custom armor.
* Checks to see if an entity is a custom entity.
*
* @param item Item to check
* @return true if the item is custom armor, false otherwise
* @param entity Entity to check
* @return true if the entity is a custom entity, false otherwise
*/
public static boolean isCustomArmor(ItemStack item) {
if (customArmorEnabled && CustomArmorConfig.getInstance().customArmor.containsKey(item.getTypeId())) {
return true;
}
return false;
}
public static boolean isCustomEntity(Entity entity) {
if (customEntitiesEnabled && CustomEntityConfig.getInstance().customEntityIds.contains(entity.getEntityId())) {
return true;
}
return false;
return customEntitiesEnabled && CustomEntityConfig.getInstance().isCustomEntity(entity);
}
/**
@@ -302,4 +167,52 @@ public final class ModUtils {
//TODO: Finish this method
return false;
}
public static void addCustomEntity(Entity entity) {
if (!customEntitiesEnabled) {
return;
}
File entityFile = CustomEntityConfig.getInstance().getFile();
YamlConfiguration entitiesFile = YamlConfiguration.loadConfiguration(entityFile);
String entityName = entity.getType().toString();
String sanitizedEntityName = entityName.replace(".", "_");
if (entitiesFile.getKeys(false).contains(sanitizedEntityName)) {
return;
}
entitiesFile.set(sanitizedEntityName + ".XP_Multiplier", 1.0D);
entitiesFile.set(sanitizedEntityName + ".Tameable", false);
entitiesFile.set(sanitizedEntityName + ".Taming_XP", 0);
entitiesFile.set(sanitizedEntityName + ".CanBeSummoned", false);
entitiesFile.set(sanitizedEntityName + ".COTW_Material", "");
entitiesFile.set(sanitizedEntityName + ".COTW_Material_Data", 0);
entitiesFile.set(sanitizedEntityName + ".COTW_Material_Amount", 0);
String className = "";
try {
className = ((Class<?>) entity.getClass().getDeclaredField("entityClass").get(entity)).getName();
}
catch (Exception e) {
if (e instanceof NoSuchFieldException || e instanceof IllegalArgumentException || e instanceof IllegalAccessException) {
className = entity.getClass().getName();
}
else {
e.printStackTrace();
}
}
CustomEntityConfig.getInstance().addEntity(new CustomEntity(1.0D, false, 0, false, null, 0), className, entityName);
try {
entitiesFile.save(entityFile);
mcMMO.p.debug(entity.getType().toString() + " was added to the custom entities file!");
}
catch (Exception e) {
e.printStackTrace();
}
}
}

Some files were not shown because too many files have changed in this diff Show More