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

Compare commits

...

88 Commits

Author SHA1 Message Date
t00thpick1
8f1801bc4d To capfan - My biggest fan 2015-11-29 22:22:32 -05:00
t00thpick1
9718123292 Catchup the changelog 2015-11-12 19:19:57 -05:00
t00thpick1
420559efec Append to existing lore when crafting Flux Pickaxes. Fixes #2557 2015-11-12 19:13:27 -05:00
t00thpick1
f4b6d7845e Add config option to auto-truncate player skill levels that exceed the configured max level. Adds #2512
Also removes a good bit of magic numbering from FlatFileDatabaseManager
2015-11-12 19:10:30 -05:00
t00thpick1
b966529487 Merge pull request #2709 from JamieSinn/master
Strip colours from party chat when logging to console.
2015-11-12 17:43:34 -05:00
JamieSinn
9c7b83a52e Strip colours from party chat when logging to console. 2015-11-12 16:06:43 -05:00
t00thpick1
ac9447d439 This is actually not correct. 2015-11-04 16:31:30 -05:00
t00thpick1
a5bcc3ce58 Correctly identify tree species. Fixes #2667 2015-11-04 16:06:28 -05:00
t00thpick1
a020890244 Remove hardcoded nerf to treefeller. Fixes #2666 2015-11-04 15:53:38 -05:00
t00thpick1
616200f20f Fix compile 2015-11-04 15:48:42 -05:00
t00thpick1
1f9c3759e7 Merge pull request #2441 from wolfdate25/patch-2
Update locale_ko.properties.  Hope this is right, I cannot read it personally.
2015-11-04 15:46:55 -05:00
t00thpick1
9fb72cfea8 Merge pull request #2648 from EvilOlaf/patch-2
Update locale_de.properties
2015-11-04 15:46:13 -05:00
t00thpick1
dd84abe927 Merge pull request #2647 from EvilOlaf/patch-1
Missing bracket
2015-11-04 15:45:11 -05:00
t00thpick1
aaa69adb0c Merge pull request #2663 from MinelinkNetwork/fix-child-skill-level
Remove hardcoded limit for parent skill levels when calculating child…
2015-11-04 15:45:00 -05:00
t00thpick1
982ee13631 Merge pull request #2697 from SilverCory/master
Monitor falling blocks.
2015-11-04 15:44:45 -05:00
t00thpick1
8927e16b1f Fix skillreset argument validation. Fixes #2651 2015-11-04 15:43:07 -05:00
t00thpick1
dd01504111 Treat nether portal spawned mobs as spawner mobs. Fixes #2662 2015-11-04 15:37:17 -05:00
t00thpick1
50e727d591 Fix salvaging to return more than 1 item. Fixes #2627 2015-11-04 15:35:22 -05:00
t00thpick1
f84e98d836 Simulate block break for flux mining. Fixes #2668 2015-11-04 15:27:03 -05:00
t00thpick1
7e92905618 Comments so I don't forget why I did it like this again 2015-11-04 13:48:29 -05:00
t00thpick1
9b24dd306c Actually use Hylian Treasure config values. Fixes #2688 2015-11-04 13:35:25 -05:00
t00thpick1
aa796266a7 Don't remember what this is for, but it was in my repo so its probably important 2015-11-04 13:26:47 -05:00
Cory Redmond
a783d0dfc8 Monitor falling blocks. 2015-10-04 21:39:22 +01:00
Byteflux
5f21efb1cd Remove hardcoded limit for parent skill levels when calculating child skill level 2015-08-16 00:35:22 -07:00
Very Evil Olaf
8e2b8f111f Update locale_de.properties
Add missing space
`Fixen` can not be used in this context. `Reparatur` is slightly better.
2015-08-03 16:53:48 +02:00
Very Evil Olaf
08766a0ff7 Missing bracket 2015-08-03 15:17:52 +02:00
t00thpick1
5b19e2e9d2 Snapshot again for realz 2015-07-28 17:49:36 -04:00
t00thpick1
bef28583f3 Fix missed compile error. Re-release 1.5.03 2015-07-28 17:48:24 -04:00
t00thpick1
eff53d90ab We need to preserve block data with our double drops for silk touch. Fixes #2625 2015-07-25 22:30:22 -04:00
t00thpick1
2aade8b7ff Remove no longer needed DualSupport classes, we crossed that road long ago. 2015-07-25 22:29:19 -04:00
t00thpick1
de0ac51b3d This should ignore absorption damage for allied players. Fixes #2618 2015-07-25 21:59:10 -04:00
t00thpick1
b161a907a7 back to development 2015-07-25 16:53:38 -04:00
t00thpick1
397ec929aa Bump version for release 2015-07-25 16:52:26 -04:00
t00thpick1
f108de9ba2 Incorrect config key. 2015-07-25 16:32:44 -04:00
t00thpick1
e3a139f7bd Update website link 2015-07-18 11:51:53 -04:00
t00thpick1
90f8132030 Merge pull request #2540 from xion87/patch-2
Update locale_it.properties
2015-07-18 11:25:45 -04:00
t00thpick1
60d89c15e6 Merge pull request #2551 from lol768/patch-1
Escape apostrophes in localised strings
2015-07-18 11:24:59 -04:00
t00thpick1
58a0287be7 Merge pull request #2583 from lumis31/patch-1
Update locale_de.properties
2015-07-18 11:24:19 -04:00
t00thpick1
ac3b28da8b Merge pull request #2614 from ThundrRok/master
Fix for custom potions being missed in potion stage calculation. #2386
2015-07-18 11:22:48 -04:00
t00thpick1
12cb1e4161 Offload slightly more calculations to the async loading thread. kinda Fixes #2591 2015-07-18 11:18:42 -04:00
t00thpick1
4e013b44d8 Support offline player experience editing 2015-07-18 10:50:38 -04:00
t00thpick1
9934ab972e Clean up SQLDatabaseManager 2015-07-18 10:48:40 -04:00
t00thpick1
30adac5e63 Properly restore state when errors occur during uuid update 2015-07-18 10:41:55 -04:00
Stephen Jenkins
d3d7c254f4 Fix for custom potions being missed in potion stage calculation. #2386 2015-07-10 18:04:53 -04:00
t00thpick1
93ad040936 Syntax is important 2015-06-20 15:11:18 -04:00
t00thpick1
bfeac43f12 NULL uuids in flatfile should not be wiped as duplicates. Fixes #2594 2015-06-20 13:04:03 -04:00
t00thpick1
4388430491 When an older user no longer has a username that a new user now has, we will update the old entry to be _INVALID_OLD_USERNAME_, however we no longer strictly enforce name uniqueness, so people altering their DB's need to tweek with caution. Invalid old users will not display in the leaderboards. Fixes #2503 2015-06-20 12:57:01 -04:00
t00thpick1
b4e21a7817 Due to the unstable and volatile nature of pistons in the current versions of mc, we cannot reliably guarentee that we can track the position of blocks being moved by pistons, and therefore will no longer track piston moved blocks in the blockstore with 100% accuracy, and will instead just not refresh the potentially empty new blocks. This will not have any effect on regular usage of the plugin aside from 100% preventing any mcMMO related piston dupe bugs. Fixes #2565, #2582 2015-06-11 21:31:20 -04:00
t00thpick1
4fe41fe416 Check Item Type, not Material Type a second time. Fixes #2584 2015-06-11 21:15:40 -04:00
t00thpick1
d8184fb298 Properly calculate diff times for old user purge. Fixes #2541 2015-06-11 18:12:22 -04:00
lumis31
78dec51ad4 Update locale_de.properties
Major updates to the locale_de including:

Most important: added translations to ALL ABILITIES DESCRIPTIONS in german

Additionally:
-Adding a translation for the Alchemy skill
-Addition of translations for fishing
-removed salvage form repair
-added horses and holy hound to taming
->full translation to german except parties
For more changes please see the changelog at the beginnig of the file. No changes have been made to the existing translations except if the information was out of date due to the recent update to Minecraft 1.8. All translations are socially acceptable (usable for children).
2015-06-09 00:10:53 +02:00
lol768
de38826897 Escape apostrophes
"The java.text.MessageFormat class uses the apostrophe (\u0027) as an escape character. Consequently, you need to write two consecutive apostrophes in your translation if you wish to display a single apostrophe"
2015-04-25 22:59:33 +01:00
xion87
f63e793006 Update locale_it.properties
Fixed italian locale for use bow skill command
2015-04-21 09:46:51 +02:00
TfT_02
ecfdd75e36 This should be SNAPSHOT 2015-04-05 20:27:39 +02:00
TfT_02
90b31a29f5 We can simplify this!
Didn’t realize there was a event.getBlocks() method for
BlockPistonRetractEvent as well.
2015-03-22 14:49:51 +01:00
TfT_02
cfa0daefc5 Fix the issues with sticky pistons and slime blocks
This is a fix for issues #2419 and #2494
2015-03-21 19:24:06 +01:00
t00thpick1
4aeda6e9e8 Still not fully on track with the original event, but as we want them to see the potions we create, we can't be fully correct. However, correcting the behavior to decrement the ingredient after the event shouldn't harm anything. Fixes #2486 2015-03-18 16:23:07 -04:00
t00thpick1
4f1f10333f Use notification settings for critical hits Fixes #2498 2015-03-18 16:09:15 -04:00
t00thpick1
342c37a02c Merge pull request #2426 from zreed/master
Empty constructors don't take arguments  Sure why not.
2015-03-18 15:31:44 -04:00
t00thpick1
e347bc1c9e Short data, Fixed #1909 2015-03-18 15:28:57 -04:00
t00thpick1
42116f4467 Include license in builds 2015-03-18 03:56:46 -04:00
t00thpick1
7ce72bafb0 Merge pull request #2489 from isokissa3/master
Fixed duplication Bug #2489 
Tentatively pulling this as I assume its valid.
2015-03-18 03:51:35 -04:00
isokissa3
f76771f0a8 Fixed duplication bug #2419 (Correct fix) 2015-03-11 14:31:56 +02:00
isokissa3
6c29da94f3 Fixed duplication Bug #2419 2015-03-11 11:36:51 +02:00
t00thpick1
981523789e Add Debug and change a line 2015-03-09 14:20:52 -04:00
t00thpick1
d9aacfa059 Back to dev 2015-03-02 15:15:08 -05:00
t00thpick1
5efc5289f7 Version bump release 2015-03-02 15:14:16 -05:00
t00thpick1
1f68f4e654 More debug for rare cases where things don't work. 2015-02-23 20:37:03 -05:00
TfT_02
5670e6696a Archery distance XP bonus cannot exceed indefinitely anymore
Fixes #2465
2015-02-21 09:42:22 +01:00
t00thpick1
ca6dc5195d Properly convert SQL to Flatfile when UUIDs are null 2015-02-16 23:12:50 -05:00
t00thpick1
30ebe318e0 Since apparently we magically can no longer compile without these. 2015-02-16 22:13:32 -05:00
t00thpick1
a1c3f0d651 WHERE'S HARVEY DENT 2015-02-16 21:43:51 -05:00
t00thpick1
347e03d75e When did this break? It was working before. 2015-02-16 12:09:00 -05:00
t00thpick1
8543382bde We want answers for the issues. 2015-02-15 22:03:58 -05:00
t00thpick1
4f1004472c Possibly fix berserk bug 2015-02-15 22:03:58 -05:00
t00thpick1
7aee829b94 Merge pull request #2456 from ulumulu1510/patch-1
Resolve duplication Bug #2419
2015-02-15 12:34:08 -05:00
Benjamin
98701104d8 Resolve duplication Bug #2419
https://github.com/mcMMO-Dev/mcMMO/issues/2419
2015-02-11 20:17:08 +01:00
t00thpick1
7a14e61762 Fix flatfile UUID conversion I think. Fixes #2225, #2411 2015-01-31 14:38:49 -05:00
wolfwork
f42f5c31ed Update locale_ko.properties 2015-01-31 15:10:15 +09:00
t00thpick1
342662c944 Round 3: DeathMatch 2015-01-25 23:28:30 -05:00
t00thpick1
50088fe0bd Round 2 2015-01-25 23:04:02 -05:00
t00thpick1
687f87a748 No more opening inventories with ability tools. Fixes #2416 2015-01-25 22:55:18 -05:00
zreed
6815c66a0e Empty constructors don't take arguments 2015-01-22 07:14:14 -05:00
TfT_02
385fe1bb05 Added option for XP gained by killing bred animals
Fixes #2402
2015-01-10 12:31:13 +01:00
t00thpick1
eddadcc179 Properly allow searches by name without UUID 2015-01-01 23:56:30 -05:00
mjkaufer
9426f44cdd Added isUnarmed Method
Checks if the player is not holding a tool, as opposed to checking if
the player is holding air. This means that attacking with something such
as a dirt block would count as unarmed.
2014-12-29 16:31:18 +01:00
TfT_02
af7ff3df58 Make Archery distance multiplier configurable
Add #2385
2014-12-24 11:00:43 +01:00
TfT_02
7c0cc8794f Whoops, should've incremented these 2014-12-23 18:49:26 +01:00
53 changed files with 2414 additions and 1596 deletions

View File

@@ -7,12 +7,48 @@ Key:
! Change ! Change
- Removal - Removal
Version 1.5.02-dev Version 1.5.04-SNAPSHOT
+ Added option to config.yml to truncate existing player skill levels that exceed the skill level cap
+ Falling blocks persist mcMMO natural data
= Woodcutting double drops correctly identify acacia and dark oak logs
= Skill Reset command now correctly identifies arguments
= Hylian Treasure config options are now actually used
= Child skills now use parent skills configured skill caps properly
! Flux mining now simulates a block break event for other plugins to act upon
! Zombie Pigmen spawned from nether portals are now considered spawner mobs
! Flux Pickaxe lore now appends to existing lore as opposed to replacing it
! Party chat no longer displays colors when logged in server console
- Treefeller no longer lowers exp for big trees
Version 1.5.03
= Fixed bug where absorption hearts could be attacked by allied players
= Fixed bug where new forms of stone would drop the wrong type when mined with Silk Touch
= Fixed bug where blocks would not get tracked correctly when using sticky pistons and slime blocks in certain situations
= Fixed bug where config value for Daze damage was ignored
= Fixed UUID updater to not lose data on errors
= Fixed bug where uuid update could result in large amounts of user data being deleted
= Fixed bug where custom potions were missed in potion stage calculation
= Fixed piston dupe bugs permanently
= Fixed bug involving user name changes
= Fixed old user purge to properly calculate months
= Fixed bug where Repair would incorrectly check items
= Fixed bug where apostrophes in locale files would not read correctly
= Fixed bug where treasure data was limited to 255 instead of Short.MAX_VALUE
! Moved more user loading calculations to async loading thread to reduce lag on login
Version 1.5.02
+ Added option to config.yml for Chimaera Wings to stop using bed spawn points + Added option to config.yml for Chimaera Wings to stop using bed spawn points
+ Added option to config.yml to let non-tools in hand count as unarmed
+ Added option to experience.yml to control XP gained by killing bred animals
+ Added support for 1.8 mobs and features
= Fixed bug where no Mining XP was granted when Flux Mining was successful = Fixed bug where no Mining XP was granted when Flux Mining was successful
= Fixed bug with UUID conversions in Flatfile
= Fixed a couple Dupe bugs that were introduced recently
= Fixed bug where MobHealthbarTypes were not saved between server restarts = Fixed bug where MobHealthbarTypes were not saved between server restarts
! Changed Flux Mining mechanics. In order to use the ability, you need to infuse a pickaxe with furnace powers first. ! Changed Flux Mining mechanics. In order to use the ability, you need to infuse a pickaxe with furnace powers first.
! Scoreboard tips are only shown a couple of times to the player, instead of once per login session ! Scoreboard tips are only shown a couple of times to the player, instead of once per login session
! Changed Archery distance multiplier to be configurable
! Archery distance XP bonus cannot exceed indefinitely anymore
Version 1.5.01 Version 1.5.01
+ Added new child skill; Salvage + Added new child skill; Salvage

10
pom.xml
View File

@@ -2,7 +2,7 @@
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>com.gmail.nossr50.mcMMO</groupId> <groupId>com.gmail.nossr50.mcMMO</groupId>
<artifactId>mcMMO</artifactId> <artifactId>mcMMO</artifactId>
<version>1.5.02-SNAPSHOT</version> <version>1.5.04-SNAPSHOT</version>
<name>mcMMO</name> <name>mcMMO</name>
<url>https://github.com/mcMMO-Dev/mcMMO</url> <url>https://github.com/mcMMO-Dev/mcMMO</url>
<issueManagement> <issueManagement>
@@ -38,6 +38,14 @@
<include>*.yml</include> <include>*.yml</include>
</includes> </includes>
</resource> </resource>
<resource>
<targetPath>.</targetPath>
<filtering>true</filtering>
<directory>${basedir}</directory>
<includes>
<include>LICENSE</include>
</includes>
</resource>
</resources> </resources>
<plugins> <plugins>
<plugin> <plugin>

View File

@@ -2,7 +2,9 @@ package com.gmail.nossr50.commands.experience;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.UUID;
import org.bukkit.OfflinePlayer;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.command.TabExecutor; import org.bukkit.command.TabExecutor;
@@ -16,7 +18,6 @@ import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.commands.CommandUtils; import com.gmail.nossr50.util.commands.CommandUtils;
import com.gmail.nossr50.util.player.UserManager; import com.gmail.nossr50.util.player.UserManager;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
public abstract class ExperienceCommand implements TabExecutor { public abstract class ExperienceCommand implements TabExecutor {
@@ -71,7 +72,12 @@ public abstract class ExperienceCommand implements TabExecutor {
// If the mcMMOPlayer doesn't exist, create a temporary profile and check if it's present in the database. If it's not, abort the process. // If the mcMMOPlayer doesn't exist, create a temporary profile and check if it's present in the database. If it's not, abort the process.
if (mcMMOPlayer == null) { if (mcMMOPlayer == null) {
PlayerProfile profile = mcMMO.getDatabaseManager().loadPlayerProfile(playerName, false); UUID uuid = null;
OfflinePlayer player = mcMMO.p.getServer().getOfflinePlayer(playerName);
if (player != null) {
uuid = player.getUniqueId();
}
PlayerProfile profile = mcMMO.getDatabaseManager().loadPlayerProfile(playerName, uuid, false);
if (CommandUtils.unloadedProfile(sender, profile)) { if (CommandUtils.unloadedProfile(sender, profile)) {
return true; return true;

View File

@@ -2,7 +2,9 @@ package com.gmail.nossr50.commands.experience;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.UUID;
import org.bukkit.OfflinePlayer;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.command.TabExecutor; import org.bukkit.command.TabExecutor;
@@ -19,7 +21,6 @@ import com.gmail.nossr50.util.EventUtils;
import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.commands.CommandUtils; import com.gmail.nossr50.util.commands.CommandUtils;
import com.gmail.nossr50.util.player.UserManager; import com.gmail.nossr50.util.player.UserManager;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
/** /**
@@ -29,6 +30,7 @@ import com.google.common.collect.ImmutableList;
public class SkillresetCommand implements TabExecutor { public class SkillresetCommand implements TabExecutor {
@Override @Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
SkillType skill;
switch (args.length) { switch (args.length) {
case 1: case 1:
if (CommandUtils.noConsoleUsage(sender)) { if (CommandUtils.noConsoleUsage(sender)) {
@@ -44,7 +46,14 @@ public class SkillresetCommand implements TabExecutor {
return true; return true;
} }
editValues((Player) sender, UserManager.getPlayer(sender.getName()).getProfile(), SkillType.getSkill(args[0])); if (args[0].equalsIgnoreCase("all")) {
skill = null;
}
else {
skill = SkillType.getSkill(args[1]);
}
editValues((Player) sender, UserManager.getPlayer(sender.getName()).getProfile(), skill);
return true; return true;
case 2: case 2:
@@ -57,7 +66,6 @@ public class SkillresetCommand implements TabExecutor {
return true; return true;
} }
SkillType skill;
if (args[1].equalsIgnoreCase("all")) { if (args[1].equalsIgnoreCase("all")) {
skill = null; skill = null;
} }
@@ -70,7 +78,12 @@ public class SkillresetCommand implements TabExecutor {
// If the mcMMOPlayer doesn't exist, create a temporary profile and check if it's present in the database. If it's not, abort the process. // If the mcMMOPlayer doesn't exist, create a temporary profile and check if it's present in the database. If it's not, abort the process.
if (mcMMOPlayer == null) { if (mcMMOPlayer == null) {
PlayerProfile profile = mcMMO.getDatabaseManager().loadPlayerProfile(playerName, false); UUID uuid = null;
OfflinePlayer player = mcMMO.p.getServer().getOfflinePlayer(playerName);
if (player != null) {
uuid = player.getUniqueId();
}
PlayerProfile profile = mcMMO.getDatabaseManager().loadPlayerProfile(playerName, uuid, false);
if (CommandUtils.unloadedProfile(sender, profile)) { if (CommandUtils.unloadedProfile(sender, profile)) {
return true; return true;
@@ -134,7 +147,7 @@ public class SkillresetCommand implements TabExecutor {
} }
private boolean validateArguments(CommandSender sender, String skillName) { private boolean validateArguments(CommandSender sender, String skillName) {
return !(CommandUtils.isInvalidSkill(sender, skillName) && !skillName.equalsIgnoreCase("all")); return skillName.equalsIgnoreCase("all") || !CommandUtils.isInvalidSkill(sender, skillName);
} }
protected static void handleSenderMessage(CommandSender sender, String playerName, SkillType skill) { protected static void handleSenderMessage(CommandSender sender, String playerName, SkillType skill) {

View File

@@ -498,6 +498,7 @@ public class Config extends AutoUpdateConfigLoader {
/* Unarmed */ /* Unarmed */
public boolean getUnarmedBlockCrackerSmoothbrickToCracked() { return config.getBoolean("Skills.Unarmed.Block_Cracker.SmoothBrick_To_CrackedBrick", true); } public boolean getUnarmedBlockCrackerSmoothbrickToCracked() { return config.getBoolean("Skills.Unarmed.Block_Cracker.SmoothBrick_To_CrackedBrick", true); }
public boolean getUnarmedItemPickupDisabled() { return config.getBoolean("Skills.Unarmed.Item_Pickup_Disabled_Full_Inventory", true); } public boolean getUnarmedItemPickupDisabled() { return config.getBoolean("Skills.Unarmed.Item_Pickup_Disabled_Full_Inventory", true); }
public boolean getUnarmedItemsAsUnarmed() { return config.getBoolean("Skills.Unarmed.Items_As_Unarmed", false); }
/* Taming */ /* Taming */
public Material getTamingCOTWMaterial(EntityType type) { return Material.matchMaterial(config.getString("Skills.Taming.Call_Of_The_Wild." + StringUtils.getPrettyEntityTypeString(type) + ".Item_Material")); } public Material getTamingCOTWMaterial(EntityType type) { return Material.matchMaterial(config.getString("Skills.Taming.Call_Of_The_Wild." + StringUtils.getPrettyEntityTypeString(type) + ".Item_Material")); }
@@ -527,6 +528,8 @@ public class Config extends AutoUpdateConfigLoader {
return (cap <= 0) ? Integer.MAX_VALUE : cap; return (cap <= 0) ? Integer.MAX_VALUE : cap;
} }
public boolean getTruncateSkills() { return config.getBoolean("General.TruncateSkills", false); }
/* PVP & PVE Settings */ /* PVP & PVE Settings */
public boolean getPVPEnabled(SkillType skill) { return config.getBoolean("Skills." + StringUtils.getCapitalized(skill.toString()) + ".Enabled_For_PVP", true); } public boolean getPVPEnabled(SkillType skill) { return config.getBoolean("Skills." + StringUtils.getCapitalized(skill.toString()) + ".Enabled_For_PVP", true); }
public boolean getPVEEnabled(SkillType skill) { return config.getBoolean("Skills." + StringUtils.getCapitalized(skill.toString()) + ".Enabled_For_PVE", true); } public boolean getPVEEnabled(SkillType skill) { return config.getBoolean("Skills." + StringUtils.getCapitalized(skill.toString()) + ".Enabled_For_PVE", true); }

View File

@@ -72,6 +72,11 @@ public class ExperienceConfig extends AutoUpdateConfigLoader {
reason.add("Experience_Formula.Mobspawners.Multiplier should be at least 0!"); reason.add("Experience_Formula.Mobspawners.Multiplier should be at least 0!");
} }
/* Bred Mob modifier */
if (getBredMobXpMultiplier() < 0) {
reason.add("Experience_Formula.Breeding.Multiplier should be at least 0!");
}
/* Conversion */ /* Conversion */
if (getExpModifier() <= 0) { if (getExpModifier() <= 0) {
reason.add("Conversion.Exp_Modifier should be greater than 0!"); reason.add("Conversion.Exp_Modifier should be greater than 0!");
@@ -88,6 +93,11 @@ public class ExperienceConfig extends AutoUpdateConfigLoader {
} }
} }
/* Archery */
if (getArcheryDistanceMultiplier() < 0) {
reason.add("Experience.Archery.Distance_Multiplier should be at least 0!");
}
/* Combat XP Multipliers */ /* Combat XP Multipliers */
if (getAnimalsXP() < 0) { if (getAnimalsXP() < 0) {
reason.add("Experience.Combat.Multiplier.Animals should be at least 0!"); reason.add("Experience.Combat.Multiplier.Animals should be at least 0!");
@@ -172,6 +182,7 @@ public class ExperienceConfig extends AutoUpdateConfigLoader {
/* Spawned Mob modifier */ /* Spawned Mob modifier */
public double getSpawnedMobXpMultiplier() { return config.getDouble("Experience_Formula.Mobspawners.Multiplier", 0.0); } public double getSpawnedMobXpMultiplier() { return config.getDouble("Experience_Formula.Mobspawners.Multiplier", 0.0); }
public double getBredMobXpMultiplier() { return config.getDouble("Experience_Formula.Breeding.Multiplier", 1.0); }
/* Skill modifiers */ /* Skill modifiers */
public double getFormulaSkillModifier(SkillType skill) { return config.getDouble("Experience_Formula.Modifier." + StringUtils.getCapitalized(skill.toString())); } public double getFormulaSkillModifier(SkillType skill) { return config.getDouble("Experience_Formula.Modifier." + StringUtils.getCapitalized(skill.toString())); }
@@ -213,6 +224,9 @@ public class ExperienceConfig extends AutoUpdateConfigLoader {
/* Alchemy */ /* Alchemy */
public double getPotionXP(PotionStage stage) { return config.getDouble("Experience.Alchemy.Potion_Stage_" + stage.toNumerical(), 10D); } public double getPotionXP(PotionStage stage) { return config.getDouble("Experience.Alchemy.Potion_Stage_" + stage.toNumerical(), 10D); }
/* Archery */
public double getArcheryDistanceMultiplier() { return config.getDouble("Experience.Archery.Distance_Multiplier", 0.025); }
/* Excavation */ /* Excavation */
public int getDirtAndSandXp(MaterialData data) { public int getDirtAndSandXp(MaterialData data) {
Material type = data.getItemType(); Material type = data.getItemType();

View File

@@ -186,7 +186,7 @@ public class TreasureConfig extends ConfigLoader {
} }
int amount = config.getInt(type + "." + treasureName + ".Amount"); int amount = config.getInt(type + "." + treasureName + ".Amount");
short data = (treasureInfo.length == 2) ? Byte.valueOf(treasureInfo[1]) : (short) config.getInt(type + "." + treasureName + ".Data"); short data = (treasureInfo.length == 2) ? Short.parseShort(treasureInfo[1]) : (short) config.getInt(type + "." + treasureName + ".Data");
if (material == null) { if (material == null) {
reason.add("Invalid material: " + materialName); reason.add("Invalid material: " + materialName);

View File

@@ -11,8 +11,8 @@ import com.gmail.nossr50.datatypes.player.PlayerProfile;
import com.gmail.nossr50.datatypes.skills.SkillType; import com.gmail.nossr50.datatypes.skills.SkillType;
public interface DatabaseManager { public interface DatabaseManager {
// One month in seconds // One month in milliseconds
public final long PURGE_TIME = 2630000L * Config.getInstance().getOldUsersCutoff(); public final long PURGE_TIME = 2630000000L * Config.getInstance().getOldUsersCutoff();
// During convertUsers, how often to output a status // During convertUsers, how often to output a status
public final int progressInterval = 200; public final int progressInterval = 200;

View File

@@ -44,7 +44,7 @@ public class DatabaseManagerFactory {
*/ */
public static void setCustomDatabaseManagerClass(Class<? extends DatabaseManager> clazz) { public static void setCustomDatabaseManagerClass(Class<? extends DatabaseManager> clazz) {
try { try {
clazz.getConstructor((Class<?>) null); clazz.getConstructor();
customManager = clazz; customManager = clazz;
} }
catch (Throwable e) { catch (Throwable e) {
@@ -78,10 +78,10 @@ public class DatabaseManagerFactory {
} }
public static DatabaseManager createDefaultCustomDatabaseManager() throws Throwable { public static DatabaseManager createDefaultCustomDatabaseManager() throws Throwable {
return customManager.getConstructor((Class<?>) null).newInstance((Object[]) null); return customManager.getConstructor().newInstance();
} }
public static DatabaseManager createCustomDatabaseManager(Class<? extends DatabaseManager> clazz) throws Throwable { public static DatabaseManager createCustomDatabaseManager(Class<? extends DatabaseManager> clazz) throws Throwable {
return clazz.getConstructor((Class<?>) null).newInstance((Object[]) null); return clazz.getConstructor().newInstance();
} }
} }

View File

@@ -7,6 +7,7 @@ import java.io.FileReader;
import java.io.FileWriter; import java.io.FileWriter;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
import java.util.Comparator; import java.util.Comparator;
import java.util.EnumMap; import java.util.EnumMap;
@@ -138,7 +139,7 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
while ((line = in.readLine()) != null) { while ((line = in.readLine()) != null) {
String[] character = line.split(":"); String[] character = line.split(":");
String name = character[0]; String name = character[USERNAME];
long lastPlayed = 0; long lastPlayed = 0;
boolean rewrite = false; boolean rewrite = false;
try { try {
@@ -213,7 +214,7 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
while ((line = in.readLine()) != null) { while ((line = in.readLine()) != null) {
// Write out the same file but when we get to the player we want to remove, we skip his line. // Write out the same file but when we get to the player we want to remove, we skip his line.
if (!worked && line.split(":")[0].equalsIgnoreCase(playerName)) { if (!worked && line.split(":")[USERNAME].equalsIgnoreCase(playerName)) {
mcMMO.p.getLogger().info("User found, removing..."); mcMMO.p.getLogger().info("User found, removing...");
worked = true; worked = true;
continue; // Skip the player continue; // Skip the player
@@ -272,7 +273,7 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
while ((line = in.readLine()) != null) { while ((line = in.readLine()) != null) {
// Read the line in and copy it to the output if it's not the player we want to edit // Read the line in and copy it to the output if it's not the player we want to edit
String[] character = line.split(":"); String[] character = line.split(":");
if (!character[41].equalsIgnoreCase(uuid.toString()) && !character[0].equalsIgnoreCase(playerName)) { if (!(uuid != null && character[UUID_INDEX].equalsIgnoreCase(uuid.toString())) && !character[USERNAME].equalsIgnoreCase(playerName)) {
writer.append(line).append("\r\n"); writer.append(line).append("\r\n");
} }
else { else {
@@ -319,7 +320,7 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
writer.append(mobHealthbarType == null ? Config.getInstance().getMobHealthbarDefault().toString() : mobHealthbarType.toString()).append(":"); writer.append(mobHealthbarType == null ? Config.getInstance().getMobHealthbarDefault().toString() : mobHealthbarType.toString()).append(":");
writer.append(profile.getSkillLevel(SkillType.ALCHEMY)).append(":"); writer.append(profile.getSkillLevel(SkillType.ALCHEMY)).append(":");
writer.append(profile.getSkillXpLevel(SkillType.ALCHEMY)).append(":"); writer.append(profile.getSkillXpLevel(SkillType.ALCHEMY)).append(":");
writer.append(uuid.toString()).append(":"); writer.append(uuid != null ? uuid.toString() : "NULL").append(":");
writer.append(profile.getScoreboardTipsShown()).append(":"); writer.append(profile.getScoreboardTipsShown()).append(":");
writer.append("\r\n"); writer.append("\r\n");
} }
@@ -473,20 +474,20 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
// Compare names because we don't have a valid uuid for that player even // Compare names because we don't have a valid uuid for that player even
// if input uuid is not null // if input uuid is not null
if (character[41].equalsIgnoreCase("NULL")) { if (character[UUID_INDEX].equalsIgnoreCase("NULL")) {
if (!character[0].equalsIgnoreCase(playerName)) { if (!character[USERNAME].equalsIgnoreCase(playerName)) {
continue; continue;
} }
} }
// If input uuid is not null then we should compare uuids // If input uuid is not null then we should compare uuids
else if ((uuid != null && !character[41].equalsIgnoreCase(uuid.toString())) || (uuid == null && !character[0].equalsIgnoreCase(playerName))) { else if ((uuid != null && !character[UUID_INDEX].equalsIgnoreCase(uuid.toString())) || (uuid == null && !character[USERNAME].equalsIgnoreCase(playerName))) {
continue; continue;
} }
// Update playerName in database after name change // Update playerName in database after name change
if (!character[0].equalsIgnoreCase(playerName)) { if (!character[USERNAME].equalsIgnoreCase(playerName)) {
mcMMO.p.debug("Name change detected: " + character[0] + " => " + playerName); mcMMO.p.debug("Name change detected: " + character[USERNAME] + " => " + playerName);
character[0] = playerName; character[USERNAME] = playerName;
} }
return loadFromLine(character); return loadFromLine(character);
@@ -572,6 +573,7 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
public boolean saveUserUUID(String userName, UUID uuid) { public boolean saveUserUUID(String userName, UUID uuid) {
boolean worked = false; boolean worked = false;
int i = 0;
BufferedReader in = null; BufferedReader in = null;
FileWriter out = null; FileWriter out = null;
String usersFilePath = mcMMO.getUsersFilePath(); String usersFilePath = mcMMO.getUsersFilePath();
@@ -584,17 +586,18 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
while ((line = in.readLine()) != null) { while ((line = in.readLine()) != null) {
String[] character = line.split(":"); String[] character = line.split(":");
if (!worked && character[0].equalsIgnoreCase(userName)) { if (!worked && character[USERNAME].equalsIgnoreCase(userName)) {
if (character.length < 42) { if (character.length < 42) {
mcMMO.p.getLogger().severe("Could not update UUID for " + userName + "!"); mcMMO.p.getLogger().severe("Could not update UUID for " + userName + "!");
mcMMO.p.getLogger().severe("Database entry is invalid."); mcMMO.p.getLogger().severe("Database entry is invalid.");
break; continue;
} }
line = line.replace(character[41], uuid.toString()); line = line.replace(character[UUID_INDEX], uuid.toString());
worked = true; worked = true;
} }
i++;
writer.append(line).append("\r\n"); writer.append(line).append("\r\n");
} }
@@ -605,6 +608,7 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
mcMMO.p.getLogger().severe("Exception while reading " + usersFilePath + " (Are you sure you formatted it correctly?)" + e.toString()); mcMMO.p.getLogger().severe("Exception while reading " + usersFilePath + " (Are you sure you formatted it correctly?)" + e.toString());
} }
finally { finally {
mcMMO.p.getLogger().info(i + " entries written while saving UUID for " + userName);
if (in != null) { if (in != null) {
try { try {
in.close(); in.close();
@@ -631,6 +635,7 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
BufferedReader in = null; BufferedReader in = null;
FileWriter out = null; FileWriter out = null;
String usersFilePath = mcMMO.getUsersFilePath(); String usersFilePath = mcMMO.getUsersFilePath();
int i = 0;
synchronized (fileWritingLock) { synchronized (fileWritingLock) {
try { try {
@@ -638,19 +643,20 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
StringBuilder writer = new StringBuilder(); StringBuilder writer = new StringBuilder();
String line; String line;
while (((line = in.readLine()) != null) && !fetchedUUIDs.isEmpty()) { while (((line = in.readLine()) != null)) {
String[] character = line.split(":"); String[] character = line.split(":");
if (fetchedUUIDs.containsKey(character[0])) { if (!fetchedUUIDs.isEmpty() && fetchedUUIDs.containsKey(character[USERNAME])) {
if (character.length < 42) { if (character.length < 42) {
mcMMO.p.getLogger().severe("Could not update UUID for " + character[0] + "!"); mcMMO.p.getLogger().severe("Could not update UUID for " + character[USERNAME] + "!");
mcMMO.p.getLogger().severe("Database entry is invalid."); mcMMO.p.getLogger().severe("Database entry is invalid.");
continue; continue;
} }
character[41] = fetchedUUIDs.remove(character[0]).toString(); character[UUID_INDEX] = fetchedUUIDs.remove(character[USERNAME]).toString();
line = new StringBuilder(org.apache.commons.lang.StringUtils.join(character, ":")).append(":").toString(); line = new StringBuilder(org.apache.commons.lang.StringUtils.join(character, ":")).append(":").toString();
} }
i++;
writer.append(line).append("\r\n"); writer.append(line).append("\r\n");
} }
@@ -661,6 +667,7 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
mcMMO.p.getLogger().severe("Exception while reading " + usersFilePath + " (Are you sure you formatted it correctly?)" + e.toString()); mcMMO.p.getLogger().severe("Exception while reading " + usersFilePath + " (Are you sure you formatted it correctly?)" + e.toString());
} }
finally { finally {
mcMMO.p.getLogger().info(i + " entries written while saving UUID batch");
if (in != null) { if (in != null) {
try { try {
in.close(); in.close();
@@ -696,7 +703,7 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
while ((line = in.readLine()) != null) { while ((line = in.readLine()) != null) {
String[] character = line.split(":"); String[] character = line.split(":");
users.add(character[0]); users.add(character[USERNAME]);
} }
} }
catch (Exception e) { catch (Exception e) {
@@ -754,7 +761,7 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
while ((line = in.readLine()) != null) { while ((line = in.readLine()) != null) {
String[] data = line.split(":"); String[] data = line.split(":");
playerName = data[0]; playerName = data[USERNAME];
int powerLevel = 0; int powerLevel = 0;
Map<SkillType, Integer> skills = getSkillMapFromLine(data); Map<SkillType, Integer> skills = getSkillMapFromLine(data);
@@ -850,15 +857,20 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
if (line.charAt(line.length() - 1) != ':') { if (line.charAt(line.length() - 1) != ':') {
line = line.concat(":"); line = line.concat(":");
} }
boolean updated = false;
String[] character = line.split(":"); String[] character = line.split(":");
// Prevent the same username from being present multiple times // Prevent the same username from being present multiple times
if (!usernames.add(character[0])) { if (!usernames.add(character[USERNAME])) {
continue; character[USERNAME] = "_INVALID_OLD_USERNAME_'";
updated = true;
if (character.length < UUID_INDEX + 1 || character[UUID_INDEX].equals("NULL")) {
continue;
}
} }
// Prevent the same player from being present multiple times // Prevent the same player from being present multiple times
if (character.length == 42 && (!character[41].isEmpty() && !players.add(character[41]))) { if (character.length >= 42 && (!character[UUID_INDEX].isEmpty() && !character[UUID_INDEX].equals("NULL") && !players.add(character[UUID_INDEX]))) {
continue; continue;
} }
@@ -870,39 +882,54 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
String oldVersion = null; String oldVersion = null;
if (character.length <= 33) { if (character.length > 33 && !character[33].isEmpty()) {
// Introduction of HUDType
// Version 1.1.06
// commit 78f79213cdd7190cd11ae54526f3b4ea42078e8a
line = line.concat(" :");
character = line.split(":");
oldVersion = "1.1.06";
}
if (!character[33].isEmpty()) {
// Removal of Spout Support // Removal of Spout Support
// Version 1.4.07-dev2 // Version 1.4.07-dev2
// commit 7bac0e2ca5143bce84dc160617fed97f0b1cb968 // commit 7bac0e2ca5143bce84dc160617fed97f0b1cb968
line = line.replace(character[33], ""); character[33] = "";
if (oldVersion == null) { if (oldVersion == null) {
oldVersion = "1.4.07"; oldVersion = "1.4.07";
} }
updated = true;
}
if (Config.getInstance().getTruncateSkills()) {
for (SkillType skill : SkillType.NON_CHILD_SKILLS) {
int index = getSkillIndex(skill);
if (index >= character.length) {
continue;
}
int cap = Config.getInstance().getLevelCap(skill);
if (Integer.valueOf(character[index]) > cap) {
mcMMO.p.getLogger().warning("Truncating " + skill.getName() + " to configured max level for player " + character[USERNAME]);
character[index] = cap + "";
updated = true;
}
}
} }
// If they're valid, rewrite them to the file. // If they're valid, rewrite them to the file.
if (character.length == 42) { if (!updated && character.length == 43) {
writer.append(line).append("\r\n"); writer.append(line).append("\r\n");
continue; continue;
} }
StringBuilder newLine = new StringBuilder(line); if (character.length <= 33) {
// Introduction of HUDType
// Version 1.1.06
// commit 78f79213cdd7190cd11ae54526f3b4ea42078e8a
character = Arrays.copyOf(character, character.length + 1);
character[character.length - 1] = "";
oldVersion = "1.1.06";
}
if (character.length <= 35) { if (character.length <= 35) {
// Introduction of Fishing // Introduction of Fishing
// Version 1.2.00 // Version 1.2.00
// commit a814b57311bc7734661109f0e77fc8bab3a0bd29 // commit a814b57311bc7734661109f0e77fc8bab3a0bd29
newLine.append(0).append(":"); character = Arrays.copyOf(character, character.length + 2);
newLine.append(0).append(":"); character[character.length - 1] = "0";
character[character.length - 2] = "0";
if (oldVersion == null) { if (oldVersion == null) {
oldVersion = "1.2.00"; oldVersion = "1.2.00";
} }
@@ -911,7 +938,8 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
// Introduction of Blast Mining cooldowns // Introduction of Blast Mining cooldowns
// Version 1.3.00-dev // Version 1.3.00-dev
// commit fadbaf429d6b4764b8f1ad0efaa524a090e82ef5 // commit fadbaf429d6b4764b8f1ad0efaa524a090e82ef5
newLine.append(0).append(":"); character = Arrays.copyOf(character, character.length + 1);
character[character.length - 1] = "0";
if (oldVersion == null) { if (oldVersion == null) {
oldVersion = "1.3.00"; oldVersion = "1.3.00";
} }
@@ -921,7 +949,8 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
// Version 1.4.00-dev // Version 1.4.00-dev
// commmit 3f6c07ba6aaf44e388cc3b882cac3d8f51d0ac28 // commmit 3f6c07ba6aaf44e388cc3b882cac3d8f51d0ac28
// XXX Cannot create an OfflinePlayer at startup, use 0 and fix in purge // XXX Cannot create an OfflinePlayer at startup, use 0 and fix in purge
newLine.append("0").append(":"); character = Arrays.copyOf(character, character.length + 1);
character[character.length - 1] = "0";
if (oldVersion == null) { if (oldVersion == null) {
oldVersion = "1.4.00"; oldVersion = "1.4.00";
} }
@@ -930,7 +959,8 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
// Addition of mob healthbars // Addition of mob healthbars
// Version 1.4.06 // Version 1.4.06
// commit da29185b7dc7e0d992754bba555576d48fa08aa6 // commit da29185b7dc7e0d992754bba555576d48fa08aa6
newLine.append(Config.getInstance().getMobHealthbarDefault().toString()).append(":"); character = Arrays.copyOf(character, character.length + 1);
character[character.length - 1] = Config.getInstance().getMobHealthbarDefault().toString();
if (oldVersion == null) { if (oldVersion == null) {
oldVersion = "1.4.06"; oldVersion = "1.4.06";
} }
@@ -938,8 +968,9 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
if (character.length <= 39) { if (character.length <= 39) {
// Addition of Alchemy // Addition of Alchemy
// Version 1.4.08 // Version 1.4.08
newLine.append("0").append(":"); character = Arrays.copyOf(character, character.length + 2);
newLine.append("0").append(":"); character[character.length - 1] = "0";
character[character.length - 2] = "0";
if (oldVersion == null) { if (oldVersion == null) {
oldVersion = "1.4.08"; oldVersion = "1.4.08";
} }
@@ -948,7 +979,8 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
// Addition of UUIDs // Addition of UUIDs
// Version 1.5.01 // Version 1.5.01
// Add a value because otherwise it gets removed // Add a value because otherwise it gets removed
newLine.append("NULL:"); character = Arrays.copyOf(character, character.length + 1);
character[character.length - 1] = "NULL";
if (oldVersion == null) { if (oldVersion == null) {
oldVersion = "1.5.01"; oldVersion = "1.5.01";
} }
@@ -956,61 +988,66 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
if (character.length <= 42) { if (character.length <= 42) {
// Addition of scoreboard tips auto disable // Addition of scoreboard tips auto disable
// Version 1.5.02 // Version 1.5.02
newLine.append("0").append(":"); character = Arrays.copyOf(character, character.length + 1);
character[character.length - 1] = "0";
if (oldVersion == null) { if (oldVersion == null) {
oldVersion = "1.5.02"; oldVersion = "1.5.02";
} }
} }
// Remove any blanks that shouldn't be there, and validate the other fields
String[] newCharacter = newLine.toString().split(":");
boolean corrupted = false; boolean corrupted = false;
for (int i = 0; i < newCharacter.length; i++) { for (int i = 0; i < character.length; i++) {
if (newCharacter[i].isEmpty() && !(i == 2 || i == 3 || i == 23 || i == 33 || i == 41)) { if (character[i].isEmpty() && !(i == 2 || i == 3 || i == 23 || i == 33 || i == 41)) {
corrupted = true; corrupted = true;
if (i == 37) {
if (newCharacter.length != 42) { character[i] = String.valueOf(System.currentTimeMillis() / Misc.TIME_CONVERSION_FACTOR);
newCharacter = (String[]) ArrayUtils.remove(newCharacter, i); }
else if (i == 38) {
character[i] = Config.getInstance().getMobHealthbarDefault().toString();
} }
else { else {
if (i == 37) { character[i] = "0";
newCharacter[i] = String.valueOf(System.currentTimeMillis() / Misc.TIME_CONVERSION_FACTOR);
}
else if (i == 38) {
newCharacter[i] = Config.getInstance().getMobHealthbarDefault().toString();
}
else {
newCharacter[i] = "0";
}
} }
} }
if (StringUtils.isInt(newCharacter[i]) && i == 38) { if (StringUtils.isInt(character[i]) && i == 38) {
corrupted = true; corrupted = true;
newCharacter[i] = Config.getInstance().getMobHealthbarDefault().toString(); character[i] = Config.getInstance().getMobHealthbarDefault().toString();
} }
if (!StringUtils.isInt(newCharacter[i]) && !(i == 0 || i == 2 || i == 3 || i == 23 || i == 33 || i == 38 || i == 41)) { if (!StringUtils.isInt(character[i]) && !(i == 0 || i == 2 || i == 3 || i == 23 || i == 33 || i == 38 || i == 41)) {
corrupted = true; corrupted = true;
newCharacter[i] = "0"; character[i] = "0";
} }
} }
if (corrupted) { if (corrupted) {
mcMMO.p.debug("Updating corrupted database line for player " + newCharacter[0]); mcMMO.p.debug("Updating corrupted database line for player " + character[USERNAME]);
} }
if (oldVersion != null) { if (oldVersion != null) {
mcMMO.p.debug("Updating database line from before version " + oldVersion + " for player " + character[0]); mcMMO.p.debug("Updating database line from before version " + oldVersion + " for player " + character[USERNAME]);
} }
if (corrupted || oldVersion != null) { updated |= corrupted;
newLine = new StringBuilder(org.apache.commons.lang.StringUtils.join(newCharacter, ":")); updated |= oldVersion != null;
newLine = newLine.append(":");
if (Config.getInstance().getTruncateSkills()) {
Map<SkillType, Integer> skills = getSkillMapFromLine(character);
for (SkillType skill : SkillType.NON_CHILD_SKILLS) {
int cap = Config.getInstance().getLevelCap(skill);
if (skills.get(skill) > cap) {
updated = true;
}
}
} }
writer.append(newLine).append("\r\n"); if (updated) {
line = new StringBuilder(org.apache.commons.lang.StringUtils.join(character, ":")).append(":").toString();
}
writer.append(line).append("\r\n");
} }
// Write the new file // Write the new file
@@ -1100,35 +1137,35 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
// TODO on updates, put new values in a try{} ? // TODO on updates, put new values in a try{} ?
skillsXp.put(SkillType.TAMING, (float) Integer.valueOf(character[25])); skillsXp.put(SkillType.TAMING, (float) Integer.valueOf(character[EXP_TAMING]));
skillsXp.put(SkillType.MINING, (float) Integer.valueOf(character[4])); skillsXp.put(SkillType.MINING, (float) Integer.valueOf(character[EXP_MINING]));
skillsXp.put(SkillType.REPAIR, (float) Integer.valueOf(character[15])); skillsXp.put(SkillType.REPAIR, (float) Integer.valueOf(character[EXP_REPAIR]));
skillsXp.put(SkillType.WOODCUTTING, (float) Integer.valueOf(character[6])); skillsXp.put(SkillType.WOODCUTTING, (float) Integer.valueOf(character[EXP_WOODCUTTING]));
skillsXp.put(SkillType.UNARMED, (float) Integer.valueOf(character[16])); skillsXp.put(SkillType.UNARMED, (float) Integer.valueOf(character[EXP_UNARMED]));
skillsXp.put(SkillType.HERBALISM, (float) Integer.valueOf(character[17])); skillsXp.put(SkillType.HERBALISM, (float) Integer.valueOf(character[EXP_HERBALISM]));
skillsXp.put(SkillType.EXCAVATION, (float) Integer.valueOf(character[18])); skillsXp.put(SkillType.EXCAVATION, (float) Integer.valueOf(character[EXP_EXCAVATION]));
skillsXp.put(SkillType.ARCHERY, (float) Integer.valueOf(character[19])); skillsXp.put(SkillType.ARCHERY, (float) Integer.valueOf(character[EXP_ARCHERY]));
skillsXp.put(SkillType.SWORDS, (float) Integer.valueOf(character[20])); skillsXp.put(SkillType.SWORDS, (float) Integer.valueOf(character[EXP_SWORDS]));
skillsXp.put(SkillType.AXES, (float) Integer.valueOf(character[21])); skillsXp.put(SkillType.AXES, (float) Integer.valueOf(character[EXP_AXES]));
skillsXp.put(SkillType.ACROBATICS, (float) Integer.valueOf(character[22])); skillsXp.put(SkillType.ACROBATICS, (float) Integer.valueOf(character[EXP_ACROBATICS]));
skillsXp.put(SkillType.FISHING, (float) Integer.valueOf(character[35])); skillsXp.put(SkillType.FISHING, (float) Integer.valueOf(character[EXP_FISHING]));
skillsXp.put(SkillType.ALCHEMY, (float) Integer.valueOf(character[40])); skillsXp.put(SkillType.ALCHEMY, (float) Integer.valueOf(character[EXP_ALCHEMY]));
// Taming - Unused // Taming - Unused
skillsDATS.put(AbilityType.SUPER_BREAKER, Integer.valueOf(character[32])); skillsDATS.put(AbilityType.SUPER_BREAKER, Integer.valueOf(character[COOLDOWN_SUPER_BREAKER]));
// Repair - Unused // Repair - Unused
skillsDATS.put(AbilityType.TREE_FELLER, Integer.valueOf(character[28])); skillsDATS.put(AbilityType.TREE_FELLER, Integer.valueOf(character[COOLDOWN_TREE_FELLER]));
skillsDATS.put(AbilityType.BERSERK, Integer.valueOf(character[26])); skillsDATS.put(AbilityType.BERSERK, Integer.valueOf(character[COOLDOWN_BERSERK]));
skillsDATS.put(AbilityType.GREEN_TERRA, Integer.valueOf(character[29])); skillsDATS.put(AbilityType.GREEN_TERRA, Integer.valueOf(character[COOLDOWN_GREEN_TERRA]));
skillsDATS.put(AbilityType.GIGA_DRILL_BREAKER, Integer.valueOf(character[27])); skillsDATS.put(AbilityType.GIGA_DRILL_BREAKER, Integer.valueOf(character[COOLDOWN_GIGA_DRILL_BREAKER]));
// Archery - Unused // Archery - Unused
skillsDATS.put(AbilityType.SERRATED_STRIKES, Integer.valueOf(character[30])); skillsDATS.put(AbilityType.SERRATED_STRIKES, Integer.valueOf(character[COOLDOWN_SERRATED_STRIKES]));
skillsDATS.put(AbilityType.SKULL_SPLITTER, Integer.valueOf(character[31])); skillsDATS.put(AbilityType.SKULL_SPLITTER, Integer.valueOf(character[COOLDOWN_SKULL_SPLITTER]));
// Acrobatics - Unused // Acrobatics - Unused
skillsDATS.put(AbilityType.BLAST_MINING, Integer.valueOf(character[36])); skillsDATS.put(AbilityType.BLAST_MINING, Integer.valueOf(character[COOLDOWN_BLAST_MINING]));
try { try {
mobHealthbarType = MobHealthbarType.valueOf(character[38]); mobHealthbarType = MobHealthbarType.valueOf(character[HEALTHBAR]);
} }
catch (Exception e) { catch (Exception e) {
mobHealthbarType = Config.getInstance().getMobHealthbarDefault(); mobHealthbarType = Config.getInstance().getMobHealthbarDefault();
@@ -1136,37 +1173,38 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
UUID uuid; UUID uuid;
try { try {
uuid = UUID.fromString(character[41]); uuid = UUID.fromString(character[UUID_INDEX]);
} }
catch (Exception e) { catch (Exception e) {
uuid = null; uuid = null;
} }
try { try {
scoreboardTipsShown = Integer.valueOf(character[41]); scoreboardTipsShown = Integer.valueOf(character[SCOREBOARD_TIPS]);
} }
catch (Exception e) { catch (Exception e) {
scoreboardTipsShown = 0; scoreboardTipsShown = 0;
} }
return new PlayerProfile(character[0], uuid, skills, skillsXp, skillsDATS, mobHealthbarType, scoreboardTipsShown); return new PlayerProfile(character[USERNAME], uuid, skills, skillsXp, skillsDATS, mobHealthbarType, scoreboardTipsShown);
} }
private Map<SkillType, Integer> getSkillMapFromLine(String[] character) { private Map<SkillType, Integer> getSkillMapFromLine(String[] character) {
Map<SkillType, Integer> skills = new EnumMap<SkillType, Integer>(SkillType.class); // Skill & Level Map<SkillType, Integer> skills = new EnumMap<SkillType, Integer>(SkillType.class); // Skill & Level
skills.put(SkillType.TAMING, Integer.valueOf(character[24])); skills.put(SkillType.TAMING, Integer.valueOf(character[SKILLS_TAMING]));
skills.put(SkillType.MINING, Integer.valueOf(character[1])); skills.put(SkillType.MINING, Integer.valueOf(character[SKILLS_MINING]));
skills.put(SkillType.REPAIR, Integer.valueOf(character[7])); skills.put(SkillType.REPAIR, Integer.valueOf(character[SKILLS_REPAIR]));
skills.put(SkillType.WOODCUTTING, Integer.valueOf(character[5])); skills.put(SkillType.WOODCUTTING, Integer.valueOf(character[SKILLS_WOODCUTTING]));
skills.put(SkillType.UNARMED, Integer.valueOf(character[8])); skills.put(SkillType.UNARMED, Integer.valueOf(character[SKILLS_UNARMED]));
skills.put(SkillType.HERBALISM, Integer.valueOf(character[9])); skills.put(SkillType.HERBALISM, Integer.valueOf(character[SKILLS_HERBALISM]));
skills.put(SkillType.EXCAVATION, Integer.valueOf(character[10])); skills.put(SkillType.EXCAVATION, Integer.valueOf(character[SKILLS_EXCAVATION]));
skills.put(SkillType.ARCHERY, Integer.valueOf(character[11])); skills.put(SkillType.ARCHERY, Integer.valueOf(character[SKILLS_ARCHERY]));
skills.put(SkillType.SWORDS, Integer.valueOf(character[12])); skills.put(SkillType.SWORDS, Integer.valueOf(character[SKILLS_SWORDS]));
skills.put(SkillType.AXES, Integer.valueOf(character[13])); skills.put(SkillType.AXES, Integer.valueOf(character[SKILLS_AXES]));
skills.put(SkillType.ACROBATICS, Integer.valueOf(character[14])); skills.put(SkillType.ACROBATICS, Integer.valueOf(character[SKILLS_ACROBATICS]));
skills.put(SkillType.FISHING, Integer.valueOf(character[34])); skills.put(SkillType.FISHING, Integer.valueOf(character[SKILLS_FISHING]));
skills.put(SkillType.ALCHEMY, Integer.valueOf(character[39])); skills.put(SkillType.ALCHEMY, Integer.valueOf(character[SKILLS_ALCHEMY]));
return skills; return skills;
} }
@@ -1177,4 +1215,78 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
@Override @Override
public void onDisable() { } public void onDisable() { }
private int getSkillIndex(SkillType skill) {
switch (skill) {
case ACROBATICS:
return SKILLS_ACROBATICS;
case ALCHEMY:
return SKILLS_ALCHEMY;
case ARCHERY:
return SKILLS_ARCHERY;
case AXES:
return SKILLS_AXES;
case EXCAVATION:
return SKILLS_EXCAVATION;
case FISHING:
return SKILLS_FISHING;
case HERBALISM:
return SKILLS_HERBALISM;
case MINING:
return SKILLS_MINING;
case REPAIR:
return SKILLS_REPAIR;
case SWORDS:
return SKILLS_SWORDS;
case TAMING:
return SKILLS_TAMING;
case UNARMED:
return SKILLS_UNARMED;
case WOODCUTTING:
return SKILLS_WOODCUTTING;
default:
throw new RuntimeException("Primary Skills only");
}
}
public static int USERNAME = 0;
public static int SKILLS_MINING = 1;
public static int EXP_MINING = 4;
public static int SKILLS_WOODCUTTING = 5;
public static int EXP_WOODCUTTING = 6;
public static int SKILLS_REPAIR = 7;
public static int SKILLS_UNARMED = 8;
public static int SKILLS_HERBALISM = 9;
public static int SKILLS_EXCAVATION = 10;
public static int SKILLS_ARCHERY = 11;
public static int SKILLS_SWORDS = 12;
public static int SKILLS_AXES = 13;
public static int SKILLS_ACROBATICS = 14;
public static int EXP_REPAIR = 15;
public static int EXP_UNARMED = 16;
public static int EXP_HERBALISM = 17;
public static int EXP_EXCAVATION = 18;
public static int EXP_ARCHERY = 19;
public static int EXP_SWORDS = 20;
public static int EXP_AXES = 21;
public static int EXP_ACROBATICS = 22;
public static int SKILLS_TAMING = 24;
public static int EXP_TAMING = 25;
public static int COOLDOWN_BERSERK = 26;
public static int COOLDOWN_GIGA_DRILL_BREAKER = 27;
public static int COOLDOWN_TREE_FELLER = 28;
public static int COOLDOWN_GREEN_TERRA = 29;
public static int COOLDOWN_SERRATED_STRIKES = 30;
public static int COOLDOWN_SKULL_SPLITTER = 31;
public static int COOLDOWN_SUPER_BREAKER = 32;
public static int SKILLS_FISHING = 34;
public static int EXP_FISHING = 35;
public static int COOLDOWN_BLAST_MINING = 36;
public static int LAST_LOGIN = 37;
public static int HEALTHBAR = 38;
public static int SKILLS_ALCHEMY = 39;
public static int EXP_ALCHEMY = 40;
public static int UUID_INDEX = 41;
public static int SCOREBOARD_TIPS = 42;
} }

View File

@@ -133,22 +133,8 @@ public final class SQLDatabaseManager implements DatabaseManager {
printErrors(ex); printErrors(ex);
} }
finally { finally {
if (statement != null) { tryClose(statement);
try { tryClose(connection);
statement.close();
}
catch (SQLException e) {
// Ignore
}
}
if (connection != null) {
try {
connection.close();
}
catch (SQLException e) {
// Ignore
}
}
massUpdateLock.unlock(); massUpdateLock.unlock();
} }
@@ -157,7 +143,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
public void purgeOldUsers() { public void purgeOldUsers() {
massUpdateLock.lock(); massUpdateLock.lock();
mcMMO.p.getLogger().info("Purging inactive users older than " + (PURGE_TIME / 2630000L) + " months..."); mcMMO.p.getLogger().info("Purging inactive users older than " + (PURGE_TIME / 2630000000L) + " months...");
Connection connection = null; Connection connection = null;
Statement statement = null; Statement statement = null;
@@ -178,22 +164,8 @@ public final class SQLDatabaseManager implements DatabaseManager {
printErrors(ex); printErrors(ex);
} }
finally { finally {
if (statement != null) { tryClose(statement);
try { tryClose(connection);
statement.close();
}
catch (SQLException e) {
// Ignore
}
}
if (connection != null) {
try {
connection.close();
}
catch (SQLException e) {
// Ignore
}
}
massUpdateLock.unlock(); massUpdateLock.unlock();
} }
@@ -223,22 +195,8 @@ public final class SQLDatabaseManager implements DatabaseManager {
printErrors(ex); printErrors(ex);
} }
finally { finally {
if (statement != null) { tryClose(statement);
try { tryClose(connection);
statement.close();
}
catch (SQLException e) {
// Ignore
}
}
if (connection != null) {
try {
connection.close();
}
catch (SQLException e) {
// Ignore
}
}
} }
if (success) { if (success) {
@@ -261,6 +219,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
if (id == -1) { if (id == -1) {
id = newUser(connection, profile.getPlayerName(), profile.getUniqueId()); id = newUser(connection, profile.getPlayerName(), profile.getUniqueId());
if (id == -1) { if (id == -1) {
mcMMO.p.getLogger().severe("Failed to create new account for " + profile.getPlayerName());
return false; return false;
} }
} }
@@ -269,6 +228,10 @@ public final class SQLDatabaseManager implements DatabaseManager {
statement.setInt(1, id); statement.setInt(1, id);
success &= (statement.executeUpdate() != 0); success &= (statement.executeUpdate() != 0);
statement.close(); statement.close();
if (!success) {
mcMMO.p.getLogger().severe("Failed to update last login for " + profile.getPlayerName());
return false;
}
statement = connection.prepareStatement("UPDATE " + tablePrefix + "skills SET " statement = connection.prepareStatement("UPDATE " + tablePrefix + "skills SET "
+ " taming = ?, mining = ?, repair = ?, woodcutting = ?" + " taming = ?, mining = ?, repair = ?, woodcutting = ?"
@@ -291,6 +254,10 @@ public final class SQLDatabaseManager implements DatabaseManager {
statement.setInt(14, id); statement.setInt(14, id);
success &= (statement.executeUpdate() != 0); success &= (statement.executeUpdate() != 0);
statement.close(); statement.close();
if (!success) {
mcMMO.p.getLogger().severe("Failed to update skills for " + profile.getPlayerName());
return false;
}
statement = connection.prepareStatement("UPDATE " + tablePrefix + "experience SET " statement = connection.prepareStatement("UPDATE " + tablePrefix + "experience SET "
+ " taming = ?, mining = ?, repair = ?, woodcutting = ?" + " taming = ?, mining = ?, repair = ?, woodcutting = ?"
@@ -313,6 +280,10 @@ public final class SQLDatabaseManager implements DatabaseManager {
statement.setInt(14, id); statement.setInt(14, id);
success &= (statement.executeUpdate() != 0); success &= (statement.executeUpdate() != 0);
statement.close(); statement.close();
if (!success) {
mcMMO.p.getLogger().severe("Failed to update experience for " + profile.getPlayerName());
return false;
}
statement = connection.prepareStatement("UPDATE " + tablePrefix + "cooldowns SET " statement = connection.prepareStatement("UPDATE " + tablePrefix + "cooldowns SET "
+ " mining = ?, woodcutting = ?, unarmed = ?" + " mining = ?, woodcutting = ?, unarmed = ?"
@@ -329,6 +300,10 @@ public final class SQLDatabaseManager implements DatabaseManager {
statement.setInt(9, id); statement.setInt(9, id);
success = (statement.executeUpdate() != 0); success = (statement.executeUpdate() != 0);
statement.close(); statement.close();
if (!success) {
mcMMO.p.getLogger().severe("Failed to update cooldowns for " + profile.getPlayerName());
return false;
}
statement = connection.prepareStatement("UPDATE " + tablePrefix + "huds SET mobhealthbar = ?, scoreboardtips = ? WHERE user_id = ?"); statement = connection.prepareStatement("UPDATE " + tablePrefix + "huds SET mobhealthbar = ?, scoreboardtips = ? WHERE user_id = ?");
statement.setString(1, profile.getMobHealthbarType() == null ? Config.getInstance().getMobHealthbarDefault().name() : profile.getMobHealthbarType().name()); statement.setString(1, profile.getMobHealthbarType() == null ? Config.getInstance().getMobHealthbarDefault().name() : profile.getMobHealthbarType().name());
@@ -336,27 +311,17 @@ public final class SQLDatabaseManager implements DatabaseManager {
statement.setInt(3, id); statement.setInt(3, id);
success = (statement.executeUpdate() != 0); success = (statement.executeUpdate() != 0);
statement.close(); statement.close();
if (!success) {
mcMMO.p.getLogger().severe("Failed to update hud settings for " + profile.getPlayerName());
return false;
}
} }
catch (SQLException ex) { catch (SQLException ex) {
printErrors(ex); printErrors(ex);
} }
finally { finally {
if (statement != null) { tryClose(statement);
try { tryClose(connection);
statement.close();
}
catch (SQLException e) {
// Ignore
}
}
if (connection != null) {
try {
connection.close();
}
catch (SQLException e) {
// Ignore
}
}
} }
return success; return success;
@@ -372,7 +337,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
try { try {
connection = getConnection(PoolIdentifier.MISC); connection = getConnection(PoolIdentifier.MISC);
statement = connection.prepareStatement("SELECT " + query + ", user, NOW() FROM " + tablePrefix + "users JOIN " + tablePrefix + "skills ON (user_id = id) WHERE " + query + " > 0 ORDER BY " + query + " DESC, user LIMIT ?, ?"); statement = connection.prepareStatement("SELECT " + query + ", user, NOW() FROM " + tablePrefix + "users JOIN " + tablePrefix + "skills ON (user_id = id) WHERE " + query + " > 0 AND NOT user = '\\_INVALID\\_OLD\\_USERNAME\\_' ORDER BY " + query + " DESC, user LIMIT ?, ?");
statement.setInt(1, (pageNumber * statsPerPage) - statsPerPage); statement.setInt(1, (pageNumber * statsPerPage) - statsPerPage);
statement.setInt(2, statsPerPage); statement.setInt(2, statsPerPage);
resultSet = statement.executeQuery(); resultSet = statement.executeQuery();
@@ -391,30 +356,9 @@ public final class SQLDatabaseManager implements DatabaseManager {
printErrors(ex); printErrors(ex);
} }
finally { finally {
if (resultSet != null) { tryClose(resultSet);
try { tryClose(statement);
resultSet.close(); tryClose(connection);
}
catch (SQLException e) {
// Ignore
}
}
if (statement != null) {
try {
statement.close();
}
catch (SQLException e) {
// Ignore
}
}
if (connection != null) {
try {
connection.close();
}
catch (SQLException e) {
// Ignore
}
}
} }
return stats; return stats;
@@ -431,6 +375,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
connection = getConnection(PoolIdentifier.MISC); connection = getConnection(PoolIdentifier.MISC);
for (SkillType skillType : SkillType.NON_CHILD_SKILLS) { for (SkillType skillType : SkillType.NON_CHILD_SKILLS) {
String skillName = skillType.name().toLowerCase(); String skillName = skillType.name().toLowerCase();
// Get count of all users with higher skill level than player
String sql = "SELECT COUNT(*) AS rank FROM " + tablePrefix + "users JOIN " + tablePrefix + "skills ON user_id = id WHERE " + skillName + " > 0 " + String sql = "SELECT COUNT(*) AS rank FROM " + tablePrefix + "users JOIN " + tablePrefix + "skills ON user_id = id WHERE " + skillName + " > 0 " +
"AND " + skillName + " > (SELECT " + skillName + " FROM " + tablePrefix + "users JOIN " + tablePrefix + "skills ON user_id = id " + "AND " + skillName + " > (SELECT " + skillName + " FROM " + tablePrefix + "users JOIN " + tablePrefix + "skills ON user_id = id " +
"WHERE user = ?)"; "WHERE user = ?)";
@@ -443,6 +388,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
int rank = resultSet.getInt("rank"); int rank = resultSet.getInt("rank");
// Ties are settled by alphabetical order
sql = "SELECT user, " + skillName + " FROM " + tablePrefix + "users JOIN " + tablePrefix + "skills ON user_id = id WHERE " + skillName + " > 0 " + sql = "SELECT user, " + skillName + " FROM " + tablePrefix + "users JOIN " + tablePrefix + "skills ON user_id = id WHERE " + skillName + " > 0 " +
"AND " + skillName + " = (SELECT " + skillName + " FROM " + tablePrefix + "users JOIN " + tablePrefix + "skills ON user_id = id " + "AND " + skillName + " = (SELECT " + skillName + " FROM " + tablePrefix + "users JOIN " + tablePrefix + "skills ON user_id = id " +
"WHERE user = '" + playerName + "') ORDER BY user"; "WHERE user = '" + playerName + "') ORDER BY user";
@@ -506,30 +452,9 @@ public final class SQLDatabaseManager implements DatabaseManager {
printErrors(ex); printErrors(ex);
} }
finally { finally {
if (resultSet != null) { tryClose(resultSet);
try { tryClose(statement);
resultSet.close(); tryClose(connection);
}
catch (SQLException e) {
// Ignore
}
}
if (statement != null) {
try {
statement.close();
}
catch (SQLException e) {
// Ignore
}
}
if (connection != null) {
try {
connection.close();
}
catch (SQLException e) {
// Ignore
}
}
} }
return skills; return skills;
@@ -546,14 +471,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
printErrors(ex); printErrors(ex);
} }
finally { finally {
if (connection != null) { tryClose(connection);
try {
connection.close();
}
catch (SQLException e) {
// Ignore
}
}
} }
} }
@@ -562,14 +480,23 @@ public final class SQLDatabaseManager implements DatabaseManager {
PreparedStatement statement = null; PreparedStatement statement = null;
try { try {
statement = connection.prepareStatement(
"UPDATE `" + tablePrefix + "users` "
+ "SET user = ? "
+ "WHERE user = ?");
statement.setString(1, "_INVALID_OLD_USERNAME_");
statement.setString(2, playerName);
statement.executeUpdate();
statement.close();
statement = connection.prepareStatement("INSERT INTO " + tablePrefix + "users (user, uuid, lastlogin) VALUES (?, ?, UNIX_TIMESTAMP())", Statement.RETURN_GENERATED_KEYS); statement = connection.prepareStatement("INSERT INTO " + tablePrefix + "users (user, uuid, lastlogin) VALUES (?, ?, UNIX_TIMESTAMP())", Statement.RETURN_GENERATED_KEYS);
statement.setString(1, playerName); statement.setString(1, playerName);
statement.setString(2, uuid.toString()); statement.setString(2, uuid != null ? uuid.toString() : null);
statement.executeUpdate(); statement.executeUpdate();
resultSet = statement.getGeneratedKeys(); resultSet = statement.getGeneratedKeys();
if (!resultSet.next()) { if (!resultSet.next()) {
mcMMO.p.getLogger().severe("Unable to create new user account in DB");
return -1; return -1;
} }
@@ -580,22 +507,8 @@ public final class SQLDatabaseManager implements DatabaseManager {
printErrors(ex); printErrors(ex);
} }
finally { finally {
if (resultSet != null) { tryClose(resultSet);
try { tryClose(statement);
resultSet.close();
}
catch (SQLException e) {
// Ignore
}
}
if (statement != null) {
try {
statement.close();
}
catch (SQLException e) {
// Ignore
}
}
} }
return -1; return -1;
} }
@@ -642,7 +555,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, s.alchemy, " + "s.taming, s.mining, s.repair, s.woodcutting, s.unarmed, s.herbalism, s.excavation, s.archery, s.swords, s.axes, s.acrobatics, s.fishing, s.alchemy, "
+ "e.taming, e.mining, e.repair, e.woodcutting, e.unarmed, e.herbalism, e.excavation, e.archery, e.swords, e.axes, e.acrobatics, e.fishing, e.alchemy, " + "e.taming, e.mining, e.repair, e.woodcutting, e.unarmed, e.herbalism, e.excavation, e.archery, e.swords, e.axes, e.acrobatics, e.fishing, e.alchemy, "
+ "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, " + "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.mobhealthbar, h.scoreboardtips, u.uuid " + "h.mobhealthbar, h.scoreboardtips, u.uuid, u.user "
+ "FROM " + tablePrefix + "users u " + "FROM " + tablePrefix + "users u "
+ "JOIN " + tablePrefix + "skills s ON (u.id = s.user_id) " + "JOIN " + tablePrefix + "skills s ON (u.id = s.user_id) "
+ "JOIN " + tablePrefix + "experience e ON (u.id = e.user_id) " + "JOIN " + tablePrefix + "experience e ON (u.id = e.user_id) "
@@ -656,10 +569,19 @@ public final class SQLDatabaseManager implements DatabaseManager {
if (resultSet.next()) { if (resultSet.next()) {
try { try {
PlayerProfile profile = loadFromResult(playerName, resultSet); PlayerProfile profile = loadFromResult(playerName, resultSet);
String name = resultSet.getString(42); // TODO: Magic Number, make sure it stays updated
resultSet.close(); resultSet.close();
statement.close(); statement.close();
if (!playerName.isEmpty() && !profile.getPlayerName().isEmpty()) { if (!playerName.isEmpty() && !playerName.equals(name)) {
statement = connection.prepareStatement(
"UPDATE `" + tablePrefix + "users` "
+ "SET user = ? "
+ "WHERE user = ?");
statement.setString(1, "_INVALID_OLD_USERNAME_");
statement.setString(2, name);
statement.executeUpdate();
statement.close();
statement = connection.prepareStatement( statement = connection.prepareStatement(
"UPDATE `" + tablePrefix + "users` " "UPDATE `" + tablePrefix + "users` "
+ "SET user = ?, uuid = ? " + "SET user = ?, uuid = ? "
@@ -674,6 +596,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
return profile; return profile;
} }
catch (SQLException e) { catch (SQLException e) {
printErrors(e);
} }
} }
resultSet.close(); resultSet.close();
@@ -682,30 +605,9 @@ public final class SQLDatabaseManager implements DatabaseManager {
printErrors(ex); printErrors(ex);
} }
finally { finally {
if (resultSet != null) { tryClose(resultSet);
try { tryClose(statement);
resultSet.close(); tryClose(connection);
}
catch (SQLException e) {
// Ignore
}
}
if (statement != null) {
try {
statement.close();
}
catch (SQLException e) {
// Ignore
}
}
if (connection != null) {
try {
connection.close();
}
catch (SQLException e) {
// Ignore
}
}
} }
// Problem, nothing was returned // Problem, nothing was returned
@@ -750,6 +652,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
resultSet.close(); resultSet.close();
} }
catch (SQLException e) { catch (SQLException e) {
printErrors(e);
// Ignore // Ignore
} }
convertedUsers++; convertedUsers++;
@@ -760,30 +663,9 @@ public final class SQLDatabaseManager implements DatabaseManager {
printErrors(e); printErrors(e);
} }
finally { finally {
if (resultSet != null) { tryClose(resultSet);
try { tryClose(statement);
resultSet.close(); tryClose(connection);
}
catch (SQLException e) {
// Ignore
}
}
if (statement != null) {
try {
statement.close();
}
catch (SQLException e) {
// Ignore
}
}
if (connection != null) {
try {
connection.close();
}
catch (SQLException e) {
// Ignore
}
}
} }
} }
@@ -807,22 +689,8 @@ public final class SQLDatabaseManager implements DatabaseManager {
return false; return false;
} }
finally { finally {
if (statement != null) { tryClose(statement);
try { tryClose(connection);
statement.close();
}
catch (SQLException e) {
// Ignore
}
}
if (connection != null) {
try {
connection.close();
}
catch (SQLException e) {
// Ignore
}
}
} }
} }
@@ -861,22 +729,8 @@ public final class SQLDatabaseManager implements DatabaseManager {
return false; return false;
} }
finally { finally {
if (statement != null) { tryClose(statement);
try { tryClose(connection);
statement.close();
}
catch (SQLException e) {
// Ignore
}
}
if (connection != null) {
try {
connection.close();
}
catch (SQLException e) {
// Ignore
}
}
} }
} }
@@ -899,30 +753,9 @@ public final class SQLDatabaseManager implements DatabaseManager {
printErrors(e); printErrors(e);
} }
finally { finally {
if (resultSet != null) { tryClose(resultSet);
try { tryClose(statement);
resultSet.close(); tryClose(connection);
}
catch (SQLException e) {
// Ignore
}
}
if (statement != null) {
try {
statement.close();
}
catch (SQLException e) {
// Ignore
}
}
if (connection != null) {
try {
connection.close();
}
catch (SQLException e) {
// Ignore
}
}
} }
return users; return users;
@@ -954,11 +787,11 @@ public final class SQLDatabaseManager implements DatabaseManager {
+ "`uuid` varchar(36) NULL DEFAULT NULL," + "`uuid` varchar(36) NULL DEFAULT NULL,"
+ "`lastlogin` int(32) unsigned NOT NULL," + "`lastlogin` int(32) unsigned NOT NULL,"
+ "PRIMARY KEY (`id`)," + "PRIMARY KEY (`id`),"
+ "UNIQUE KEY `user` (`user`)," + "INDEX(`user`(20) ASC),"
+ "UNIQUE KEY `uuid` (`uuid`)) DEFAULT CHARSET=latin1 AUTO_INCREMENT=1;"); + "UNIQUE KEY `uuid` (`uuid`)) DEFAULT CHARSET=latin1 AUTO_INCREMENT=1;");
createStatement.close(); tryClose(createStatement);
} }
resultSet.close(); tryClose(resultSet);
statement.setString(1, Config.getInstance().getMySQLDatabaseName()); statement.setString(1, Config.getInstance().getMySQLDatabaseName());
statement.setString(2, tablePrefix + "huds"); statement.setString(2, tablePrefix + "huds");
resultSet = statement.executeQuery(); resultSet = statement.executeQuery();
@@ -970,9 +803,9 @@ public final class SQLDatabaseManager implements DatabaseManager {
+ "`scoreboardtips` int(10) NOT NULL DEFAULT '0'," + "`scoreboardtips` int(10) NOT NULL DEFAULT '0',"
+ "PRIMARY KEY (`user_id`)) " + "PRIMARY KEY (`user_id`)) "
+ "DEFAULT CHARSET=latin1;"); + "DEFAULT CHARSET=latin1;");
createStatement.close(); tryClose(createStatement);
} }
resultSet.close(); tryClose(resultSet);
statement.setString(1, Config.getInstance().getMySQLDatabaseName()); statement.setString(1, Config.getInstance().getMySQLDatabaseName());
statement.setString(2, tablePrefix + "cooldowns"); statement.setString(2, tablePrefix + "cooldowns");
resultSet = statement.executeQuery(); resultSet = statement.executeQuery();
@@ -994,9 +827,9 @@ public final class SQLDatabaseManager implements DatabaseManager {
+ "`blast_mining` int(32) unsigned NOT NULL DEFAULT '0'," + "`blast_mining` int(32) unsigned NOT NULL DEFAULT '0',"
+ "PRIMARY KEY (`user_id`)) " + "PRIMARY KEY (`user_id`)) "
+ "DEFAULT CHARSET=latin1;"); + "DEFAULT CHARSET=latin1;");
createStatement.close(); tryClose(createStatement);
} }
resultSet.close(); tryClose(resultSet);
statement.setString(1, Config.getInstance().getMySQLDatabaseName()); statement.setString(1, Config.getInstance().getMySQLDatabaseName());
statement.setString(2, tablePrefix + "skills"); statement.setString(2, tablePrefix + "skills");
resultSet = statement.executeQuery(); resultSet = statement.executeQuery();
@@ -1019,9 +852,9 @@ public final class SQLDatabaseManager implements DatabaseManager {
+ "`alchemy` int(10) unsigned NOT NULL DEFAULT '0'," + "`alchemy` int(10) unsigned NOT NULL DEFAULT '0',"
+ "PRIMARY KEY (`user_id`)) " + "PRIMARY KEY (`user_id`)) "
+ "DEFAULT CHARSET=latin1;"); + "DEFAULT CHARSET=latin1;");
createStatement.close(); tryClose(createStatement);
} }
resultSet.close(); tryClose(resultSet);
statement.setString(1, Config.getInstance().getMySQLDatabaseName()); statement.setString(1, Config.getInstance().getMySQLDatabaseName());
statement.setString(2, tablePrefix + "experience"); statement.setString(2, tablePrefix + "experience");
resultSet = statement.executeQuery(); resultSet = statement.executeQuery();
@@ -1044,15 +877,26 @@ public final class SQLDatabaseManager implements DatabaseManager {
+ "`alchemy` int(10) unsigned NOT NULL DEFAULT '0'," + "`alchemy` int(10) unsigned NOT NULL DEFAULT '0',"
+ "PRIMARY KEY (`user_id`)) " + "PRIMARY KEY (`user_id`)) "
+ "DEFAULT CHARSET=latin1;"); + "DEFAULT CHARSET=latin1;");
createStatement.close(); tryClose(createStatement);
} }
resultSet.close(); tryClose(resultSet);
statement.close(); tryClose(statement);
for (UpgradeType updateType : UpgradeType.values()) { for (UpgradeType updateType : UpgradeType.values()) {
checkDatabaseStructure(connection, updateType); checkDatabaseStructure(connection, updateType);
} }
if (Config.getInstance().getTruncateSkills()) {
for (SkillType skill : SkillType.NON_CHILD_SKILLS) {
int cap = Config.getInstance().getLevelCap(skill);
if (cap != Integer.MAX_VALUE) {
statement = connection.prepareStatement("UPDATE `" + tablePrefix + "skills` SET `" + skill.name().toLowerCase() + "` = " + cap + " WHERE `" + skill.name().toLowerCase() + "` > " + cap);
statement.executeUpdate();
tryClose(statement);
}
}
}
mcMMO.p.getLogger().info("Killing orphans"); mcMMO.p.getLogger().info("Killing orphans");
createStatement = connection.createStatement(); createStatement = connection.createStatement();
createStatement.executeUpdate("DELETE FROM `" + tablePrefix + "experience` WHERE NOT EXISTS (SELECT * FROM `" + tablePrefix + "users` `u` WHERE `" + tablePrefix + "experience`.`user_id` = `u`.`id`)"); createStatement.executeUpdate("DELETE FROM `" + tablePrefix + "experience` WHERE NOT EXISTS (SELECT * FROM `" + tablePrefix + "users` `u` WHERE `" + tablePrefix + "experience`.`user_id` = `u`.`id`)");
@@ -1064,38 +908,10 @@ public final class SQLDatabaseManager implements DatabaseManager {
printErrors(ex); printErrors(ex);
} }
finally { finally {
if (resultSet != null) { tryClose(resultSet);
try { tryClose(statement);
resultSet.close(); tryClose(createStatement);
} tryClose(connection);
catch (SQLException e) {
// Ignore
}
}
if (statement != null) {
try {
statement.close();
}
catch (SQLException e) {
// Ignore
}
}
if (createStatement != null) {
try {
createStatement.close();
}
catch (SQLException e) {
// Ignore
}
}
if (connection != null) {
try {
connection.close();
}
catch (SQLException e) {
// Ignore
}
}
} }
} }
@@ -1172,6 +988,10 @@ public final class SQLDatabaseManager implements DatabaseManager {
checkUpgradeAddScoreboardTips(statement); checkUpgradeAddScoreboardTips(statement);
return; return;
case DROP_NAME_UNIQUENESS:
checkNameUniqueness(statement);
return;
default: default:
break; break;
@@ -1183,14 +1003,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
printErrors(ex); printErrors(ex);
} }
finally { finally {
if (statement != null) { tryClose(statement);
try {
statement.close();
}
catch (SQLException e) {
// Ignore
}
}
} }
} }
@@ -1224,14 +1037,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
printErrors(ex); printErrors(ex);
} }
finally { finally {
if (statement != null) { tryClose(statement);
try {
statement.close();
}
catch (SQLException e) {
// Ignore
}
}
} }
} }
@@ -1326,6 +1132,27 @@ public final class SQLDatabaseManager implements DatabaseManager {
return DatabaseType.SQL; return DatabaseType.SQL;
} }
private void checkNameUniqueness(final Statement statement) throws SQLException {
ResultSet resultSet = null;
try {
resultSet = statement.executeQuery("SHOW INDEXES "
+ "FROM `" + tablePrefix + "users` "
+ "WHERE Column_name='user' "
+ " AND NOT Non_unique");
if (!resultSet.next()) {
return;
}
resultSet.close();
mcMMO.p.getLogger().info("Updating mcMMO MySQL tables to drop name uniqueness...");
statement.execute("ALTER TABLE `" + tablePrefix + "users` "
+ "DROP INDEX `user`,"
+ "ADD INDEX `user` (`user`(20) ASC)");
} catch (SQLException ex) {
} finally {
tryClose(resultSet);
}
}
private void checkUpgradeAddAlchemy(final Statement statement) throws SQLException { private void checkUpgradeAddAlchemy(final Statement statement) throws SQLException {
try { try {
statement.executeQuery("SELECT `alchemy` FROM `" + tablePrefix + "skills` LIMIT 1"); statement.executeQuery("SELECT `alchemy` FROM `" + tablePrefix + "skills` LIMIT 1");
@@ -1404,14 +1231,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
printErrors(ex); printErrors(ex);
} }
finally { finally {
if (resultSet != null) { tryClose(resultSet);
try {
resultSet.close();
}
catch (SQLException e) {
// Ignore
}
}
} }
} }
@@ -1441,14 +1261,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
printErrors(ex); printErrors(ex);
} }
finally { finally {
if (resultSet != null) { tryClose(resultSet);
try {
resultSet.close();
}
catch (SQLException e) {
// Ignore
}
}
} }
new GetUUIDUpdatesRequired().runTaskLaterAsynchronously(mcMMO.p, 100); // wait until after first purge new GetUUIDUpdatesRequired().runTaskLaterAsynchronously(mcMMO.p, 100); // wait until after first purge
@@ -1473,27 +1286,9 @@ public final class SQLDatabaseManager implements DatabaseManager {
} catch (SQLException ex) { } catch (SQLException ex) {
printErrors(ex); printErrors(ex);
} finally { } finally {
if (resultSet != null) { tryClose(resultSet);
try { tryClose(statement);
resultSet.close(); tryClose(connection);
} catch (SQLException e) {
// Ignore
}
}
if (statement != null) {
try {
statement.close();
} catch (SQLException e) {
// Ignore
}
}
if (connection != null) {
try {
connection.close();
} catch (SQLException e) {
// Ignore
}
}
} }
if (!names.isEmpty()) { if (!names.isEmpty()) {
@@ -1530,14 +1325,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
printErrors(ex); printErrors(ex);
} }
finally { finally {
if (resultSet != null) { tryClose(resultSet);
try {
resultSet.close();
}
catch (SQLException e) {
// Ignore
}
}
} }
} }
@@ -1566,19 +1354,12 @@ public final class SQLDatabaseManager implements DatabaseManager {
printErrors(ex); printErrors(ex);
} }
finally { finally {
if (resultSet != null) { tryClose(resultSet);
try {
resultSet.close();
}
catch (SQLException e) {
// Ignore
}
}
} }
} }
private int getUserID(final Connection connection, final String playerName, final UUID uuid) { private int getUserID(final Connection connection, final String playerName, final UUID uuid) {
if (cachedUserIDs.containsKey(uuid)) { if (uuid != null && cachedUserIDs.containsKey(uuid)) {
return cachedUserIDs.get(uuid); return cachedUserIDs.get(uuid);
} }
@@ -1587,14 +1368,16 @@ public final class SQLDatabaseManager implements DatabaseManager {
try { try {
statement = connection.prepareStatement("SELECT id, user FROM " + tablePrefix + "users WHERE uuid = ? OR (uuid IS NULL AND user = ?)"); statement = connection.prepareStatement("SELECT id, user FROM " + tablePrefix + "users WHERE uuid = ? OR (uuid IS NULL AND user = ?)");
statement.setString(1, uuid.toString()); statement.setString(1, uuid == null ? null : uuid.toString());
statement.setString(2, playerName); statement.setString(2, playerName);
resultSet = statement.executeQuery(); resultSet = statement.executeQuery();
if (resultSet.next()) { if (resultSet.next()) {
int id = resultSet.getInt("id"); int id = resultSet.getInt("id");
cachedUserIDs.put(uuid, id); if (uuid != null) {
cachedUserIDs.put(uuid, id);
}
return id; return id;
} }
@@ -1603,26 +1386,23 @@ public final class SQLDatabaseManager implements DatabaseManager {
printErrors(ex); printErrors(ex);
} }
finally { finally {
if (resultSet != null) { tryClose(resultSet);
try { tryClose(statement);
resultSet.close();
}
catch (SQLException e) {
// Ignore
}
}
if (statement != null) {
try {
statement.close();
}
catch (SQLException e) {
// Ignore
}
}
} }
return -1; return -1;
} }
private void tryClose(AutoCloseable closeable) {
if (closeable != null) {
try {
closeable.close();
}
catch (Exception e) {
// Ignore
}
}
}
@Override @Override
public void onDisable() { public void onDisable() {

View File

@@ -10,5 +10,6 @@ public enum UpgradeType {
ADD_ALCHEMY, ADD_ALCHEMY,
ADD_UUIDS, ADD_UUIDS,
ADD_UUIDS_PARTY, ADD_UUIDS_PARTY,
ADD_SCOREBOARD_TIPS; ADD_SCOREBOARD_TIPS,
DROP_NAME_UNIQUENESS;
} }

View File

@@ -101,12 +101,6 @@ public class McMMOPlayer {
this.player = player; this.player = player;
playerMetadata = new FixedMetadataValue(mcMMO.p, playerName); playerMetadata = new FixedMetadataValue(mcMMO.p, playerName);
this.profile = profile; this.profile = profile;
party = PartyManager.getPlayerParty(playerName, uuid);
ptpRecord = new PartyTeleportRecord();
if (inParty()) {
loginParty();
}
if (profile.getUniqueId() == null) { if (profile.getUniqueId() == null) {
profile.setUniqueId(uuid); profile.setUniqueId(uuid);
@@ -532,6 +526,15 @@ public class McMMOPlayer {
* Party Stuff * Party Stuff
*/ */
public void setupPartyData() {
party = PartyManager.getPlayerParty(player.getName(), player.getUniqueId());
ptpRecord = new PartyTeleportRecord();
if (inParty()) {
loginParty();
}
}
public void setPartyInvite(Party invite) { public void setPartyInvite(Party invite) {
this.invite = invite; this.invite = invite;
} }

View File

@@ -355,7 +355,7 @@ public class PlayerProfile {
int sum = 0; int sum = 0;
for (SkillType parent : parents) { for (SkillType parent : parents) {
sum += Math.min(getSkillLevel(parent), 1000); sum += Math.min(getSkillLevel(parent), parent.getMaxLevel());
} }
return sum / parents.size(); return sum / parents.size();

View File

@@ -1,6 +1,9 @@
package com.gmail.nossr50.datatypes.skills.alchemy; package com.gmail.nossr50.datatypes.skills.alchemy;
import java.util.List;
import org.bukkit.potion.Potion; import org.bukkit.potion.Potion;
import org.bukkit.potion.PotionEffect;
public enum PotionStage { public enum PotionStage {
FIVE(5), FIVE(5),
@@ -44,17 +47,27 @@ public enum PotionStage {
public static PotionStage getPotionStage(AlchemyPotion alchemyPotion) { public static PotionStage getPotionStage(AlchemyPotion alchemyPotion) {
Potion potion = alchemyPotion.toPotion(1); Potion potion = alchemyPotion.toPotion(1);
List<PotionEffect> effects = alchemyPotion.getEffects();
int stage = 1; int stage = 1;
// Check if potion isn't awkward or mundane // Check if potion isn't awkward or mundane
if (potion.getType() != null) { // Check for custom effects added by mcMMO
if (potion.getType() != null || !effects.isEmpty()) {
stage++; stage++;
} }
// Check if potion has a glowstone dust amplifier // Check if potion has a glowstone dust amplifier
// Else check if the potion has a custom effect with an amplifier added by mcMMO
if (potion.getLevel() > 1) { if (potion.getLevel() > 1) {
stage++; stage++;
}else if(!effects.isEmpty()){
for (PotionEffect effect : effects){
if(effect.getAmplifier() > 0){
stage++;
break;
}
}
} }
// Check if potion has a redstone dust amplifier // Check if potion has a redstone dust amplifier

View File

@@ -11,6 +11,7 @@ import org.bukkit.block.BlockFace;
import org.bukkit.block.BlockState; import org.bukkit.block.BlockState;
import org.bukkit.block.BrewingStand; import org.bukkit.block.BrewingStand;
import org.bukkit.enchantments.Enchantment; import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
@@ -20,6 +21,7 @@ import org.bukkit.event.block.BlockDamageEvent;
import org.bukkit.event.block.BlockPistonExtendEvent; import org.bukkit.event.block.BlockPistonExtendEvent;
import org.bukkit.event.block.BlockPistonRetractEvent; import org.bukkit.event.block.BlockPistonRetractEvent;
import org.bukkit.event.block.BlockPlaceEvent; import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.entity.EntityChangeBlockEvent;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
@@ -49,6 +51,8 @@ import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.player.UserManager; import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.skills.SkillUtils; import com.gmail.nossr50.util.skills.SkillUtils;
import org.bukkit.metadata.FixedMetadataValue;
import org.bukkit.metadata.MetadataValue;
public class BlockListener implements Listener { public class BlockListener implements Listener {
private final mcMMO plugin; private final mcMMO plugin;
@@ -64,10 +68,6 @@ public class BlockListener implements Listener {
*/ */
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onBlockPistonExtend(BlockPistonExtendEvent event) { public void onBlockPistonExtend(BlockPistonExtendEvent event) {
if (!EventUtils.shouldProcessEvent(event.getBlock(), true)) {
return;
}
BlockFace direction = event.getDirection(); BlockFace direction = event.getDirection();
Block futureEmptyBlock = event.getBlock().getRelative(direction); // Block that would be air after piston is finished Block futureEmptyBlock = event.getBlock().getRelative(direction); // Block that would be air after piston is finished
@@ -79,12 +79,14 @@ public class BlockListener implements Listener {
for (Block b : blocks) { for (Block b : blocks) {
if (BlockUtils.shouldBeWatched(b.getState()) && mcMMO.getPlaceStore().isTrue(b)) { if (BlockUtils.shouldBeWatched(b.getState()) && mcMMO.getPlaceStore().isTrue(b)) {
b.getRelative(direction).setMetadata(mcMMO.blockMetadataKey, mcMMO.metadataValue); Block nextBlock = b.getRelative(direction);
mcMMO.getPlaceStore().setTrue(nextBlock);
//b.getRelative(direction).setMetadata(mcMMO.blockMetadataKey, mcMMO.metadataValue);
} }
} }
// Needed because blocks sometimes don't move when two pistons push towards each other // Needed because blocks sometimes don't move when two pistons push towards each other
new PistonTrackerTask(blocks, direction, futureEmptyBlock).runTaskLater(plugin, 2); //new PistonTrackerTask(blocks, direction, futureEmptyBlock).runTaskLater(plugin, 2);
} }
/** /**
@@ -94,18 +96,64 @@ public class BlockListener implements Listener {
*/ */
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onBlockPistonRetract(BlockPistonRetractEvent event) { public void onBlockPistonRetract(BlockPistonRetractEvent event) {
if (!EventUtils.shouldProcessEvent(event.getBlock(), false)) { // event.isSticky() always returns false
// if (!event.isSticky()){
// return;
// }
// Sticky piston return PISTON_MOVING_PIECE and normal piston PISTON_BASE
if (event.getBlock().getType() != Material.PISTON_MOVING_PIECE) {
return; return;
} }
if (!event.isSticky()) { // Get opposite direction so we get correct block
BlockFace direction = event.getDirection().getOppositeFace();
Block movedBlock = event.getBlock().getRelative(direction);
mcMMO.getPlaceStore().setTrue(movedBlock);
// If we're pulling a slime block, it might have something attached to it!
if (movedBlock.getRelative(direction).getState().getType() == Material.SLIME_BLOCK) {
for (Block block : event.getBlocks()) {
movedBlock = block.getRelative(direction);
mcMMO.getPlaceStore().setTrue(movedBlock);
// // Treat the slime blocks as if it is the sticky piston itself, because pulling
// // a slime block with a sticky piston is effectively the same as moving a sticky piston.
// new StickyPistonTrackerTask(direction, event.getBlock(), block).runTaskLater(plugin, 2);
}
return; return;
} }
Block movedBlock = event.getRetractLocation().getBlock();
// Needed only because under some circumstances Minecraft doesn't move the block // Needed only because under some circumstances Minecraft doesn't move the block
new StickyPistonTrackerTask(event.getDirection(), event.getBlock(), movedBlock).runTaskLater(plugin, 2); //new StickyPistonTrackerTask(direction, event.getBlock(), movedBlock).runTaskLater(plugin, 2);
}
/**
* Monitor falling blocks.
*
* @param event The event to watch
*/
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onFallingBlock(EntityChangeBlockEvent event) {
if (BlockUtils.shouldBeWatched(event.getBlock().getState()) && event.getEntityType().equals(EntityType.FALLING_BLOCK)) {
if (event.getTo().equals(Material.AIR) && mcMMO.getPlaceStore().isTrue(event.getBlock())) {
event.getEntity().setMetadata("mcMMOBlockFall", new FixedMetadataValue( plugin, event.getBlock().getLocation()));
} else {
List<MetadataValue> values = event.getEntity().getMetadata( "mcMMOBlockFall" );
if (!values.isEmpty()) {
if (values.get(0).value() == null) return;
Block spawn = ((org.bukkit.Location) values.get(0).value()).getBlock();
mcMMO.getPlaceStore().setTrue( event.getBlock() );
mcMMO.getPlaceStore().setFalse( spawn );
}
}
}
} }
/** /**

View File

@@ -23,6 +23,7 @@ import org.bukkit.event.entity.EntityChangeBlockEvent;
import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.event.entity.EntityDamageEvent.DamageModifier;
import org.bukkit.event.entity.EntityDeathEvent; import org.bukkit.event.entity.EntityDeathEvent;
import org.bukkit.event.entity.EntityExplodeEvent; import org.bukkit.event.entity.EntityExplodeEvent;
import org.bukkit.event.entity.EntityShootBowEvent; import org.bukkit.event.entity.EntityShootBowEvent;
@@ -104,13 +105,15 @@ public class EntityListener implements Listener {
/** /**
* Monitor EntityChangeBlock events. * Monitor EntityChangeBlock events.
* *
* @param event The event to watch * @param event
* The event to watch
*/ */
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onEntityChangeBlock(EntityChangeBlockEvent event) { public void onEntityChangeBlock(EntityChangeBlockEvent event) {
Block block = event.getBlock(); Block block = event.getBlock();
// When the event is fired for the falling block that changes back to a normal block // When the event is fired for the falling block that changes back to a
// normal block
// event.getBlock().getType() returns AIR // event.getBlock().getType() returns AIR
if (!BlockUtils.shouldBeWatched(block.getState()) && block.getType() != Material.AIR) { if (!BlockUtils.shouldBeWatched(block.getState()) && block.getType() != Material.AIR) {
return; return;
@@ -142,7 +145,8 @@ public class EntityListener implements Listener {
/** /**
* Handle EntityDamageByEntity events that involve modifying the event. * Handle EntityDamageByEntity events that involve modifying the event.
* *
* @param event The event to watch * @param event
* The event to watch
*/ */
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onEntityDamageByEntity(EntityDamageByEntityEvent event) { public void onEntityDamageByEntity(EntityDamageByEntityEvent event) {
@@ -151,12 +155,24 @@ public class EntityListener implements Listener {
} }
double damage = event.getFinalDamage(); double damage = event.getFinalDamage();
Entity defender = event.getEntity();
Entity attacker = event.getDamager();
if (damage <= 0) { if (damage <= 0) {
if (defender instanceof Player && attacker instanceof Player) {
Player defendingPlayer = (Player) defender;
Player attackingPlayer = (Player) attacker;
if (event.getDamage(DamageModifier.ABSORPTION) > 0) {
if ((PartyManager.inSameParty(defendingPlayer, attackingPlayer) || PartyManager.areAllies(defendingPlayer, attackingPlayer)) && !(Permissions.friendlyFire(attackingPlayer) && Permissions.friendlyFire(defendingPlayer))) {
event.setCancelled(true);
return;
}
}
}
return; return;
} }
Entity defender = event.getEntity();
if (defender.hasMetadata(mcMMO.customDamageKey)) { if (defender.hasMetadata(mcMMO.customDamageKey)) {
defender.removeMetadata(mcMMO.customDamageKey, plugin); defender.removeMetadata(mcMMO.customDamageKey, plugin);
@@ -173,7 +189,7 @@ public class EntityListener implements Listener {
return; return;
} }
Entity attacker = event.getDamager();
if (Misc.isNPCEntity(attacker)) { if (Misc.isNPCEntity(attacker)) {
return; return;
@@ -207,7 +223,8 @@ public class EntityListener implements Listener {
return; return;
} }
// We want to make sure we're not gaining XP or applying abilities when we hit ourselves // We want to make sure we're not gaining XP or applying abilities
// when we hit ourselves
if (defendingPlayer.equals(attackingPlayer)) { if (defendingPlayer.equals(attackingPlayer)) {
return; return;
} }
@@ -225,7 +242,8 @@ public class EntityListener implements Listener {
/** /**
* Handle EntityDamage events that involve modifying the event. * Handle EntityDamage events that involve modifying the event.
* *
* @param event The event to modify * @param event
* The event to modify
*/ */
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onEntityDamage(EntityDamageEvent event) { public void onEntityDamage(EntityDamageEvent event) {
@@ -371,7 +389,8 @@ public class EntityListener implements Listener {
/** /**
* Monitor EntityDeath events. * Monitor EntityDeath events.
* *
* @param event The event to watch * @param event
* The event to watch
*/ */
@EventHandler(priority = EventPriority.LOWEST) @EventHandler(priority = EventPriority.LOWEST)
public void onEntityDeathLowest(EntityDeathEvent event) { public void onEntityDeathLowest(EntityDeathEvent event) {
@@ -395,7 +414,8 @@ public class EntityListener implements Listener {
/** /**
* Monitor EntityDeath events. * Monitor EntityDeath events.
* *
* @param event The event to watch * @param event
* The event to watch
*/ */
@EventHandler(priority = EventPriority.MONITOR) @EventHandler(priority = EventPriority.MONITOR)
public void onEntityDeath(EntityDeathEvent event) { public void onEntityDeath(EntityDeathEvent event) {
@@ -412,23 +432,30 @@ public class EntityListener implements Listener {
/** /**
* Monitor CreatureSpawn events. * Monitor CreatureSpawn events.
* *
* @param event The event to watch * @param event
* The event to watch
*/ */
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onCreatureSpawn(CreatureSpawnEvent event) { public void onCreatureSpawn(CreatureSpawnEvent event) {
LivingEntity entity = event.getEntity();
switch (event.getSpawnReason()) { switch (event.getSpawnReason()) {
case NETHER_PORTAL:
case SPAWNER: case SPAWNER:
case SPAWNER_EGG: case SPAWNER_EGG:
LivingEntity entity = event.getEntity();
Entity passenger = entity.getPassenger();
entity.setMetadata(mcMMO.entityMetadataKey, mcMMO.metadataValue); entity.setMetadata(mcMMO.entityMetadataKey, mcMMO.metadataValue);
Entity passenger = entity.getPassenger();
if (passenger != null) { if (passenger != null) {
passenger.setMetadata(mcMMO.entityMetadataKey, mcMMO.metadataValue); passenger.setMetadata(mcMMO.entityMetadataKey, mcMMO.metadataValue);
} }
return; return;
case BREEDING:
entity.setMetadata(mcMMO.bredMetadataKey, mcMMO.metadataValue);
return;
default: default:
return; return;
} }
@@ -437,7 +464,8 @@ public class EntityListener implements Listener {
/** /**
* Handle ExplosionPrime events that involve modifying the event. * Handle ExplosionPrime events that involve modifying the event.
* *
* @param event The event to modify * @param event
* The event to modify
*/ */
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onExplosionPrime(ExplosionPrimeEvent event) { public void onExplosionPrime(ExplosionPrimeEvent event) {
@@ -447,7 +475,8 @@ public class EntityListener implements Listener {
return; return;
} }
// We can make this assumption because we (should) be the only ones using this exact metadata // We can make this assumption because we (should) be the only ones
// using this exact metadata
Player player = plugin.getServer().getPlayerExact(entity.getMetadata(mcMMO.tntMetadataKey).get(0).asString()); Player player = plugin.getServer().getPlayerExact(entity.getMetadata(mcMMO.tntMetadataKey).get(0).asString());
if (!UserManager.hasPlayerDataKey(player)) { if (!UserManager.hasPlayerDataKey(player)) {
@@ -464,7 +493,8 @@ public class EntityListener implements Listener {
/** /**
* Handle EntityExplode events that involve modifying the event. * Handle EntityExplode events that involve modifying the event.
* *
* @param event The event to modify * @param event
* The event to modify
*/ */
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onEnitityExplode(EntityExplodeEvent event) { public void onEnitityExplode(EntityExplodeEvent event) {
@@ -474,7 +504,8 @@ public class EntityListener implements Listener {
return; return;
} }
// We can make this assumption because we (should) be the only ones using this exact metadata // We can make this assumption because we (should) be the only ones
// using this exact metadata
Player player = plugin.getServer().getPlayerExact(entity.getMetadata(mcMMO.tntMetadataKey).get(0).asString()); Player player = plugin.getServer().getPlayerExact(entity.getMetadata(mcMMO.tntMetadataKey).get(0).asString());
if (!UserManager.hasPlayerDataKey(player)) { if (!UserManager.hasPlayerDataKey(player)) {
@@ -492,7 +523,8 @@ public class EntityListener implements Listener {
/** /**
* Handle EntityExplode events that involve modifying the event. * Handle EntityExplode events that involve modifying the event.
* *
* @param event The event to modify * @param event
* The event to modify
*/ */
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onEntityExplodeMonitor(EntityExplodeEvent event) { public void onEntityExplodeMonitor(EntityExplodeEvent event) {
@@ -508,7 +540,8 @@ public class EntityListener implements Listener {
/** /**
* Handle FoodLevelChange events that involve modifying the event. * Handle FoodLevelChange events that involve modifying the event.
* *
* @param event The event to modify * @param event
* The event to modify
*/ */
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onFoodLevelChange(FoodLevelChangeEvent event) { public void onFoodLevelChange(FoodLevelChangeEvent event) {
@@ -533,39 +566,59 @@ public class EntityListener implements Listener {
} }
/* /*
* Some foods have 3 ranks * Some foods have 3 ranks Some foods have 5 ranks The number of ranks
* Some foods have 5 ranks * is based on how 'common' the item is We can adjust this quite easily
* The number of ranks is based on how 'common' the item is * if we find something is giving too much of a bonus
* We can adjust this quite easily if we find something is giving too much of a bonus
*/ */
switch (player.getItemInHand().getType()) { switch (player.getItemInHand().getType()) {
case BAKED_POTATO: /* RESTORES 3 HUNGER - RESTORES 5 1/2 HUNGER @ 1000 */ case BAKED_POTATO: /*
case BREAD: /* RESTORES 2 1/2 HUNGER - RESTORES 5 HUNGER @ 1000 */ * RESTORES 3 HUNGER - RESTORES 5 1/2 HUNGER @
case CARROT_ITEM: /* RESTORES 2 HUNGER - RESTORES 4 1/2 HUNGER @ 1000 */ * 1000
case GOLDEN_CARROT: /* RESTORES 3 HUNGER - RESTORES 5 1/2 HUNGER @ 1000 */ */
case MUSHROOM_SOUP: /* RESTORES 4 HUNGER - RESTORES 6 1/2 HUNGER @ 1000 */ case BREAD: /* RESTORES 2 1/2 HUNGER - RESTORES 5 HUNGER @ 1000 */
case PUMPKIN_PIE: /* RESTORES 4 HUNGER - RESTORES 6 1/2 HUNGER @ 1000 */ case CARROT_ITEM: /*
* RESTORES 2 HUNGER - RESTORES 4 1/2 HUNGER @
* 1000
*/
case GOLDEN_CARROT: /*
* RESTORES 3 HUNGER - RESTORES 5 1/2 HUNGER @
* 1000
*/
case MUSHROOM_SOUP: /*
* RESTORES 4 HUNGER - RESTORES 6 1/2 HUNGER @
* 1000
*/
case PUMPKIN_PIE: /*
* RESTORES 4 HUNGER - RESTORES 6 1/2 HUNGER @
* 1000
*/
if (Permissions.secondaryAbilityEnabled(player, SecondaryAbility.FARMERS_DIET)) { if (Permissions.secondaryAbilityEnabled(player, SecondaryAbility.FARMERS_DIET)) {
event.setFoodLevel(UserManager.getPlayer(player).getHerbalismManager().farmersDiet(Herbalism.farmersDietRankLevel1, newFoodLevel)); event.setFoodLevel(UserManager.getPlayer(player).getHerbalismManager().farmersDiet(Herbalism.farmersDietRankLevel1, newFoodLevel));
} }
return; return;
case COOKIE: /* RESTORES 1/2 HUNGER - RESTORES 2 HUNGER @ 1000 */ case COOKIE: /* RESTORES 1/2 HUNGER - RESTORES 2 HUNGER @ 1000 */
case MELON: /* RESTORES 1 HUNGER - RESTORES 2 1/2 HUNGER @ 1000 */ case MELON: /* RESTORES 1 HUNGER - RESTORES 2 1/2 HUNGER @ 1000 */
case POISONOUS_POTATO: /* RESTORES 1 HUNGER - RESTORES 2 1/2 HUNGER @ 1000 */ case POISONOUS_POTATO: /*
case POTATO_ITEM: /* RESTORES 1/2 HUNGER - RESTORES 2 HUNGER @ 1000 */ * RESTORES 1 HUNGER - RESTORES 2 1/2 HUNGER
* @ 1000
*/
case POTATO_ITEM: /* RESTORES 1/2 HUNGER - RESTORES 2 HUNGER @ 1000 */
if (Permissions.secondaryAbilityEnabled(player, SecondaryAbility.FARMERS_DIET)) { if (Permissions.secondaryAbilityEnabled(player, SecondaryAbility.FARMERS_DIET)) {
event.setFoodLevel(UserManager.getPlayer(player).getHerbalismManager().farmersDiet(Herbalism.farmersDietRankLevel2, newFoodLevel)); event.setFoodLevel(UserManager.getPlayer(player).getHerbalismManager().farmersDiet(Herbalism.farmersDietRankLevel2, newFoodLevel));
} }
return; return;
case COOKED_FISH: /* RESTORES 2 1/2 HUNGER - RESTORES 5 HUNGER @ 1000 */ case COOKED_FISH: /*
* RESTORES 2 1/2 HUNGER - RESTORES 5 HUNGER @
* 1000
*/
if (Permissions.secondaryAbilityEnabled(player, SecondaryAbility.FISHERMANS_DIET)) { if (Permissions.secondaryAbilityEnabled(player, SecondaryAbility.FISHERMANS_DIET)) {
event.setFoodLevel(UserManager.getPlayer(player).getFishingManager().handleFishermanDiet(Fishing.fishermansDietRankLevel1, newFoodLevel)); event.setFoodLevel(UserManager.getPlayer(player).getFishingManager().handleFishermanDiet(Fishing.fishermansDietRankLevel1, newFoodLevel));
} }
return; return;
case RAW_FISH: /* RESTORES 1 HUNGER - RESTORES 2 1/2 HUNGER @ 1000 */ case RAW_FISH: /* RESTORES 1 HUNGER - RESTORES 2 1/2 HUNGER @ 1000 */
if (Permissions.secondaryAbilityEnabled(player, SecondaryAbility.FISHERMANS_DIET)) { if (Permissions.secondaryAbilityEnabled(player, SecondaryAbility.FISHERMANS_DIET)) {
event.setFoodLevel(UserManager.getPlayer(player).getFishingManager().handleFishermanDiet(Fishing.fishermansDietRankLevel2, newFoodLevel)); event.setFoodLevel(UserManager.getPlayer(player).getFishingManager().handleFishermanDiet(Fishing.fishermansDietRankLevel2, newFoodLevel));
} }
@@ -579,7 +632,8 @@ public class EntityListener implements Listener {
/** /**
* Monitor EntityTame events. * Monitor EntityTame events.
* *
* @param event The event to watch * @param event
* The event to watch
*/ */
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onEntityTame(EntityTameEvent event) { public void onEntityTame(EntityTameEvent event) {
@@ -601,7 +655,8 @@ public class EntityListener implements Listener {
/** /**
* Handle EntityTarget events. * Handle EntityTarget events.
* *
* @param event The event to process * @param event
* The event to process
*/ */
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onEntityTarget(EntityTargetEvent event) { public void onEntityTarget(EntityTargetEvent event) {
@@ -619,7 +674,8 @@ public class EntityListener implements Listener {
return; return;
} }
// isFriendlyPet ensures that the Tameable is: Tamed, owned by a player, and the owner is in the same party // isFriendlyPet ensures that the Tameable is: Tamed, owned by a player,
// and the owner is in the same party
// So we can make some assumptions here, about our casting and our check // So we can make some assumptions here, about our casting and our check
if (!(Permissions.friendlyFire(player) && Permissions.friendlyFire((Player) tameable.getOwner()))) { if (!(Permissions.friendlyFire(player) && Permissions.friendlyFire((Player) tameable.getOwner()))) {
event.setCancelled(true); event.setCancelled(true);
@@ -627,9 +683,11 @@ public class EntityListener implements Listener {
} }
/** /**
* Handle PotionSplash events in order to fix broken Splash Potion of Saturation. * Handle PotionSplash events in order to fix broken Splash Potion of
* Saturation.
* *
* @param event The event to process * @param event
* The event to process
*/ */
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPotionSplash(PotionSplashEvent event) { public void onPotionSplash(PotionSplashEvent event) {

View File

@@ -17,6 +17,7 @@ import org.bukkit.event.inventory.CraftItemEvent;
import org.bukkit.event.inventory.FurnaceBurnEvent; import org.bukkit.event.inventory.FurnaceBurnEvent;
import org.bukkit.event.inventory.FurnaceExtractEvent; import org.bukkit.event.inventory.FurnaceExtractEvent;
import org.bukkit.event.inventory.FurnaceSmeltEvent; import org.bukkit.event.inventory.FurnaceSmeltEvent;
import org.bukkit.event.inventory.InventoryAction;
import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.inventory.InventoryCloseEvent; import org.bukkit.event.inventory.InventoryCloseEvent;
import org.bukkit.event.inventory.InventoryDragEvent; import org.bukkit.event.inventory.InventoryDragEvent;
@@ -313,6 +314,14 @@ public class InventoryListener implements Listener {
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onInventoryClickEvent(InventoryClickEvent event) { public void onInventoryClickEvent(InventoryClickEvent event) {
SkillUtils.removeAbilityBuff(event.getCurrentItem()); SkillUtils.removeAbilityBuff(event.getCurrentItem());
if (event.getAction() == InventoryAction.HOTBAR_SWAP) {
SkillUtils.removeAbilityBuff(event.getWhoClicked().getInventory().getItem(event.getHotbarButton()));
}
}
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onInventoryOpenEvent(InventoryOpenEvent event) {
SkillUtils.removeAbilityBuff(event.getPlayer().getItemInHand());
} }
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)

View File

@@ -1,5 +1,7 @@
package com.gmail.nossr50.listeners; package com.gmail.nossr50.listeners;
import java.util.HashSet;
import org.bukkit.GameMode; import org.bukkit.GameMode;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.Sound; import org.bukkit.Sound;
@@ -236,7 +238,7 @@ public class PlayerListener implements Listener {
return; return;
case IN_GROUND: case IN_GROUND:
Block block = player.getTargetBlock(null, 100); Block block = player.getTargetBlock((HashSet<Byte>) null, 100);
if (fishingManager.canIceFish(block)) { if (fishingManager.canIceFish(block)) {
event.setCancelled(true); event.setCancelled(true);

View File

@@ -57,7 +57,7 @@ public final class LocaleLoader {
public static String formatString(String string, Object... messageArguments) { public static String formatString(String string, Object... messageArguments) {
if (messageArguments != null) { if (messageArguments != null) {
MessageFormat formatter = new MessageFormat(""); MessageFormat formatter = new MessageFormat("");
formatter.applyPattern(string); formatter.applyPattern(string.replace("'", "''"));
string = formatter.format(messageArguments); string = formatter.format(messageArguments);
} }

View File

@@ -119,8 +119,8 @@ public class mcMMO extends JavaPlugin {
public final static String disarmedItemKey = "mcMMO: Disarmed Item"; public final static String disarmedItemKey = "mcMMO: Disarmed Item";
public final static String playerDataKey = "mcMMO: Player Data"; public final static String playerDataKey = "mcMMO: Player Data";
public final static String greenThumbDataKey = "mcMMO: Green Thumb"; public final static String greenThumbDataKey = "mcMMO: Green Thumb";
public final static String pistonDataKey = "mcMMO: Piston State";
public final static String databaseCommandKey = "mcMMO: Processing Database Command"; public final static String databaseCommandKey = "mcMMO: Processing Database Command";
public final static String bredMetadataKey = "mcMMO: Bred Animal";
public static FixedMetadataValue metadataValue; public static FixedMetadataValue metadataValue;

View File

@@ -20,7 +20,7 @@ public class StickyPistonTrackerTask extends BukkitRunnable {
@Override @Override
public void run() { public void run() {
if (!mcMMO.getPlaceStore().isTrue(movedBlock)) { if (!mcMMO.getPlaceStore().isTrue(movedBlock.getRelative(direction))) {
return; return;
} }
@@ -30,7 +30,7 @@ public class StickyPistonTrackerTask extends BukkitRunnable {
} }
// The sticky piston actually pulled the block so move the PlaceStore data // The sticky piston actually pulled the block so move the PlaceStore data
mcMMO.getPlaceStore().setFalse(movedBlock); mcMMO.getPlaceStore().setFalse(movedBlock.getRelative(direction));
mcMMO.getPlaceStore().setTrue(block.getRelative(direction)); mcMMO.getPlaceStore().setTrue(movedBlock);
} }
} }

View File

@@ -70,6 +70,7 @@ public class UUIDUpdateAsyncTask extends BukkitRunnable {
catch (Exception e) { catch (Exception e) {
// Handle 429 // Handle 429
if (e.getMessage().contains("429")) { if (e.getMessage().contains("429")) {
size += userNamesSection.size();
try { try {
Thread.sleep(LIMIT_PERIOD); Thread.sleep(LIMIT_PERIOD);
} catch (InterruptedException ex) { } catch (InterruptedException ex) {

View File

@@ -1,16 +1,15 @@
package com.gmail.nossr50.runnables.party; package com.gmail.nossr50.runnables.party;
import java.util.regex.Matcher; import com.gmail.nossr50.config.Config;
import java.util.regex.Pattern; import com.gmail.nossr50.datatypes.party.Party;
import com.gmail.nossr50.locale.LocaleLoader;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin; import org.bukkit.plugin.Plugin;
import org.bukkit.scheduler.BukkitRunnable; import org.bukkit.scheduler.BukkitRunnable;
import com.gmail.nossr50.config.Config; import java.util.regex.Matcher;
import com.gmail.nossr50.datatypes.party.Party; import java.util.regex.Pattern;
import com.gmail.nossr50.locale.LocaleLoader;
public class PartyChatTask extends BukkitRunnable { public class PartyChatTask extends BukkitRunnable {
private Plugin plugin; private Plugin plugin;
@@ -46,6 +45,6 @@ public class PartyChatTask extends BukkitRunnable {
} }
} }
plugin.getServer().getConsoleSender().sendMessage("[mcMMO] [P]<" + party.getName() + ">" + message); plugin.getServer().getConsoleSender().sendMessage(ChatColor.stripColor("[mcMMO] [P]<" + party.getName() + ">" + message));
} }
} }

View File

@@ -44,7 +44,7 @@ public class PlayerProfileLoadingTask extends BukkitRunnable {
PlayerProfile profile = mcMMO.getDatabaseManager().loadPlayerProfile(player.getName(), player.getUniqueId(), true); PlayerProfile profile = mcMMO.getDatabaseManager().loadPlayerProfile(player.getName(), player.getUniqueId(), true);
// If successful, schedule the apply // If successful, schedule the apply
if (profile.isLoaded()) { if (profile.isLoaded()) {
new ApplySuccessfulProfile(profile).runTask(mcMMO.p); new ApplySuccessfulProfile(new McMMOPlayer(player, profile)).runTask(mcMMO.p);
return; return;
} }
@@ -59,10 +59,10 @@ public class PlayerProfileLoadingTask extends BukkitRunnable {
} }
private class ApplySuccessfulProfile extends BukkitRunnable { private class ApplySuccessfulProfile extends BukkitRunnable {
private final PlayerProfile profile; private final McMMOPlayer mcMMOPlayer;
private ApplySuccessfulProfile(PlayerProfile profile) { private ApplySuccessfulProfile(McMMOPlayer mcMMOPlayer) {
this.profile = profile; this.mcMMOPlayer = mcMMOPlayer;
} }
// Synchronized task // Synchronized task
@@ -74,7 +74,7 @@ public class PlayerProfileLoadingTask extends BukkitRunnable {
return; return;
} }
McMMOPlayer mcMMOPlayer = new McMMOPlayer(player, profile); mcMMOPlayer.setupPartyData();
UserManager.track(mcMMOPlayer); UserManager.track(mcMMOPlayer);
mcMMOPlayer.actualizeRespawnATS(); mcMMOPlayer.actualizeRespawnATS();
ScoreboardManager.setupPlayer(player); ScoreboardManager.setupPlayer(player);

View File

@@ -56,23 +56,29 @@ public final class AlchemyPotionBrewer {
return item == null || item.getType() == Material.AIR || item.getAmount() == 0; return item == null || item.getType() == Material.AIR || item.getAmount() == 0;
} }
private static boolean removeIngredient(BrewerInventory inventory, Player player) { private static void removeIngredient(BrewerInventory inventory, Player player) {
ItemStack ingredient = inventory.getIngredient() == null ? null : inventory.getIngredient().clone(); ItemStack ingredient = inventory.getIngredient() == null ? null : inventory.getIngredient().clone();
if (isEmpty(ingredient) || !isValidIngredient(player, ingredient)) { if (isEmpty(ingredient) || !isValidIngredient(player, ingredient)) {
return false; return;
} }
else if (ingredient.getAmount() <= 1) { else if (ingredient.getAmount() <= 1) {
inventory.setIngredient(null); inventory.setIngredient(null);
return true; return;
} }
else { else {
ingredient.setAmount(ingredient.getAmount() - 1); ingredient.setAmount(ingredient.getAmount() - 1);
inventory.setIngredient(ingredient); inventory.setIngredient(ingredient);
return true; return;
} }
} }
private static boolean hasIngredient(BrewerInventory inventory, Player player) {
ItemStack ingredient = inventory.getIngredient() == null ? null : inventory.getIngredient().clone();
return !isEmpty(ingredient) && isValidIngredient(player, ingredient);
}
public static boolean isValidIngredient(Player player, ItemStack item) { public static boolean isValidIngredient(Player player, ItemStack item) {
if (isEmpty(item)) { if (isEmpty(item)) {
return false; return false;
@@ -99,7 +105,7 @@ public final class AlchemyPotionBrewer {
BrewerInventory inventory = ((BrewingStand) brewingStand).getInventory(); BrewerInventory inventory = ((BrewingStand) brewingStand).getInventory();
ItemStack ingredient = inventory.getIngredient() == null ? null : inventory.getIngredient().clone(); ItemStack ingredient = inventory.getIngredient() == null ? null : inventory.getIngredient().clone();
if (!removeIngredient(inventory, player)) { if (!hasIngredient(inventory, player)) {
return; return;
} }
@@ -129,6 +135,8 @@ public final class AlchemyPotionBrewer {
return; return;
} }
removeIngredient(inventory, player);
for (AlchemyPotion input : inputList) { for (AlchemyPotion input : inputList) {
AlchemyPotion output = PotionConfig.getInstance().getPotion(input.getChildDataValue(ingredient)); AlchemyPotion output = PotionConfig.getInstance().getPotion(input.getChildDataValue(ingredient));

View File

@@ -9,6 +9,7 @@ import org.bukkit.entity.LivingEntity;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import com.gmail.nossr50.config.AdvancedConfig; import com.gmail.nossr50.config.AdvancedConfig;
import com.gmail.nossr50.config.experience.ExperienceConfig;
import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.Misc;
public class Archery { public class Archery {
@@ -21,7 +22,7 @@ public class Archery {
public static double dazeBonusDamage = AdvancedConfig.getInstance().getDazeBonusDamage(); public static double dazeBonusDamage = AdvancedConfig.getInstance().getDazeBonusDamage();
public static final double DISTANCE_XP_MULTIPLIER = 0.025; public static final double DISTANCE_XP_MULTIPLIER = ExperienceConfig.getInstance().getArcheryDistanceMultiplier();
protected static void incrementTrackerValue(LivingEntity livingEntity) { protected static void incrementTrackerValue(LivingEntity livingEntity) {
for (TrackedEntity trackedEntity : trackedEntities) { for (TrackedEntity trackedEntity : trackedEntities) {

View File

@@ -49,7 +49,7 @@ public class ArcheryManager extends SkillManager {
return; return;
} }
applyXpGain((int) (firedLocation.distanceSquared(targetLocation) * Archery.DISTANCE_XP_MULTIPLIER), getXPGainReason(target, damager)); applyXpGain((int) (Math.min(firedLocation.distanceSquared(targetLocation), 2500) * Archery.DISTANCE_XP_MULTIPLIER), getXPGainReason(target, damager));
} }
/** /**

View File

@@ -74,10 +74,16 @@ public class AxesManager extends SkillManager {
Player player = getPlayer(); Player player = getPlayer();
player.sendMessage(LocaleLoader.getString("Axes.Combat.CriticalHit")); if (mcMMOPlayer.useChatNotifications()) {
player.sendMessage(LocaleLoader.getString("Axes.Combat.CriticalHit"));
}
if (target instanceof Player) { if (target instanceof Player) {
((Player) target).sendMessage(LocaleLoader.getString("Axes.Combat.CritStruck")); Player defender = (Player) target;
if (UserManager.getPlayer(defender).useChatNotifications()) {
defender.sendMessage(LocaleLoader.getString("Axes.Combat.CritStruck"));
}
damage = (damage * Axes.criticalHitPVPModifier) - damage; damage = (damage * Axes.criticalHitPVPModifier) - damage;
} }

View File

@@ -3,6 +3,7 @@ package com.gmail.nossr50.skills.fishing;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@@ -105,7 +106,7 @@ public class FishingManager extends SkillManager {
vehicle.remove(); vehicle.remove();
} }
player.teleport(player.getTargetBlock(null, 100).getLocation(), TeleportCause.PLUGIN); player.teleport(player.getTargetBlock((HashSet<Byte>) null, 100).getLocation(), TeleportCause.PLUGIN);
String unleashMessage = AdvancedConfig.getInstance().getPlayerUnleashMessage(); String unleashMessage = AdvancedConfig.getInstance().getPlayerUnleashMessage();
@@ -168,7 +169,7 @@ public class FishingManager extends SkillManager {
return false; return false;
} }
Block targetBlock = getPlayer().getTargetBlock(BlockUtils.getTransparentBlocks(), 100); Block targetBlock = getPlayer().getTargetBlock((HashSet<Byte>) BlockUtils.getTransparentBlocks(), 100);
if (!targetBlock.isLiquid()) { if (!targetBlock.isLiquid()) {
return false; return false;

View File

@@ -4,6 +4,7 @@ import java.util.Collection;
import java.util.List; import java.util.List;
import org.bukkit.CropState; import org.bukkit.CropState;
import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.NetherWartsState; import org.bukkit.NetherWartsState;
import org.bukkit.block.BlockState; import org.bukkit.block.BlockState;
@@ -235,15 +236,24 @@ public class HerbalismManager extends SkillManager {
Player player = getPlayer(); Player player = getPlayer();
if (treasures.isEmpty() || !EventUtils.simulateBlockBreak(blockState.getBlock(), player, false)) { if (treasures.isEmpty()) {
return false; return false;
} }
int skillLevel = getSkillLevel();
Location location = blockState.getLocation();
blockState.setType(Material.AIR); for (HylianTreasure treasure : treasures) {
if (skillLevel >= treasure.getDropLevel() && SkillUtils.treasureDropSuccessful(getPlayer(), treasure.getDropChance(), activationChance)) {
Misc.dropItem(blockState.getLocation(), treasures.get(Misc.getRandom().nextInt(treasures.size())).getDrop()); if (!EventUtils.simulateBlockBreak(blockState.getBlock(), player, false)) {
player.sendMessage(LocaleLoader.getString("Herbalism.HylianLuck")); return false;
return true; }
blockState.setType(Material.AIR);
Misc.dropItem(location, treasure.getDrop());
player.sendMessage(LocaleLoader.getString("Herbalism.HylianLuck"));
return true;
}
}
return false;
} }
/** /**

View File

@@ -64,7 +64,8 @@ public class Mining {
case QUARTZ_ORE: case QUARTZ_ORE:
case REDSTONE_ORE: case REDSTONE_ORE:
case STONE: case STONE:
Misc.dropItem(blockState.getLocation(), new ItemStack(blockType)); case PRISMARINE:
Misc.dropItem(blockState.getLocation(), blockState.getData().toItemStack(1));
return; return;
default: default:

View File

@@ -1,6 +1,7 @@
package com.gmail.nossr50.skills.mining; package com.gmail.nossr50.skills.mining;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashSet;
import java.util.List; import java.util.List;
import org.bukkit.Material; import org.bukkit.Material;
@@ -93,7 +94,7 @@ public class MiningManager extends SkillManager {
*/ */
public void remoteDetonation() { public void remoteDetonation() {
Player player = getPlayer(); Player player = getPlayer();
Block targetBlock = player.getTargetBlock(BlockUtils.getTransparentBlocks(), BlastMining.MAXIMUM_REMOTE_DETONATION_DISTANCE); Block targetBlock = player.getTargetBlock((HashSet<Byte>) BlockUtils.getTransparentBlocks(), BlastMining.MAXIMUM_REMOTE_DETONATION_DISTANCE);
if (targetBlock.getType() != Material.TNT || !EventUtils.simulateBlockBreak(targetBlock, player, true) || !blastMiningCooldownOver()) { if (targetBlock.getType() != Material.TNT || !EventUtils.simulateBlockBreak(targetBlock, player, true) || !blastMiningCooldownOver()) {
return; return;

View File

@@ -67,7 +67,7 @@ public class RepairManager extends SkillManager {
return; return;
} }
if (!Permissions.repairMaterialType(player, repairable.getRepairMaterialType())) { if (!Permissions.repairItemType(player, repairable.getRepairItemType())) {
player.sendMessage(LocaleLoader.getString("mcMMO.NoPermission")); player.sendMessage(LocaleLoader.getString("mcMMO.NoPermission"));
return; return;
} }

View File

@@ -25,6 +25,7 @@ import com.gmail.nossr50.skills.SkillManager;
import com.gmail.nossr50.skills.mining.Mining; import com.gmail.nossr50.skills.mining.Mining;
import com.gmail.nossr50.skills.smelting.Smelting.Tier; import com.gmail.nossr50.skills.smelting.Smelting.Tier;
import com.gmail.nossr50.util.BlockUtils; import com.gmail.nossr50.util.BlockUtils;
import com.gmail.nossr50.util.EventUtils;
import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.skills.ParticleEffectUtils; import com.gmail.nossr50.util.skills.ParticleEffectUtils;
@@ -73,6 +74,10 @@ public class SmeltingManager extends SkillManager {
if (item == null) { if (item == null) {
return false; return false;
} }
if (!EventUtils.simulateBlockBreak(blockState.getBlock(), player, true)) {
return false;
}
// We need to distribute Mining XP here, because the block break event gets cancelled // We need to distribute Mining XP here, because the block break event gets cancelled
applyXpGain(Mining.getBlockXp(blockState), XPGainReason.PVE); applyXpGain(Mining.getBlockXp(blockState), XPGainReason.PVE);
@@ -100,7 +105,7 @@ public class SmeltingManager extends SkillManager {
ItemMeta itemMeta = itemStack.getItemMeta(); ItemMeta itemMeta = itemStack.getItemMeta();
itemMeta.setDisplayName(ChatColor.GOLD + LocaleLoader.getString("Item.FluxPickaxe.Name")); itemMeta.setDisplayName(ChatColor.GOLD + LocaleLoader.getString("Item.FluxPickaxe.Name"));
List<String> itemLore = new ArrayList<String>(); List<String> itemLore = itemMeta.hasLore() ? itemMeta.getLore() : new ArrayList<String>();
itemLore.add("mcMMO Item"); itemLore.add("mcMMO Item");
itemLore.add(LocaleLoader.getString("Item.FluxPickaxe.Lore.1")); itemLore.add(LocaleLoader.getString("Item.FluxPickaxe.Lore.1"));
itemLore.add(LocaleLoader.getString("Item.FluxPickaxe.Lore.2", Smelting.fluxMiningUnlockLevel)); itemLore.add(LocaleLoader.getString("Item.FluxPickaxe.Lore.2", Smelting.fluxMiningUnlockLevel));

View File

@@ -71,7 +71,14 @@ public class Unarmed {
} }
// Inventory is full - cancel the item pickup // Inventory is full - cancel the item pickup
return false; if (dropStack.getAmount() == dropAmount) {
return false;
} else {
drop.remove();
dropStack.setAmount(dropAmount);
((Item) drop.getWorld().dropItem(drop.getLocation(), dropStack)).setPickupDelay(0);
return true;
}
} }
else if (firstEmpty != -1) { else if (firstEmpty != -1) {
drop.remove(); drop.remove();

View File

@@ -19,6 +19,7 @@ import com.gmail.nossr50.datatypes.skills.ToolType;
import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.skills.SkillManager; import com.gmail.nossr50.skills.SkillManager;
import com.gmail.nossr50.util.EventUtils; import com.gmail.nossr50.util.EventUtils;
import com.gmail.nossr50.util.ItemUtils;
import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.player.UserManager; import com.gmail.nossr50.util.player.UserManager;
@@ -48,7 +49,7 @@ public class UnarmedManager extends SkillManager {
public boolean canDeflect() { public boolean canDeflect() {
Player player = getPlayer(); Player player = getPlayer();
return player.getItemInHand().getType() == Material.AIR && Permissions.secondaryAbilityEnabled(getPlayer(), SecondaryAbility.DEFLECT); return ItemUtils.isUnarmed(player.getItemInHand()) && Permissions.secondaryAbilityEnabled(getPlayer(), SecondaryAbility.DEFLECT);
} }
public boolean canUseBlockCracker() { public boolean canUseBlockCracker() {

View File

@@ -62,13 +62,7 @@ public final class Woodcutting {
species = ((Tree) blockState.getData()).getSpecies(); species = ((Tree) blockState.getData()).getSpecies();
} }
int xp = ExperienceConfig.getInstance().getWoodcuttingTreeXP(species); return ExperienceConfig.getInstance().getWoodcuttingTreeXP(species);
if (species == TreeSpecies.JUNGLE && experienceGainMethod == ExperienceGainMethod.TREE_FELLER) {
xp *= 0.5;
}
return xp;
} }
/** /**
@@ -86,6 +80,15 @@ public final class Woodcutting {
if (blockState.getData() instanceof Tree) { if (blockState.getData() instanceof Tree) {
species = ((Tree) blockState.getData()).getSpecies(); species = ((Tree) blockState.getData()).getSpecies();
} }
if (blockState.getType() == Material.LOG_2) {
byte data = blockState.getRawData();
if ((data & 1) != 0) {
species = TreeSpecies.ACACIA;
}
if ((data & 2) != 0) {
species = TreeSpecies.DARK_OAK;
}
}
if (Config.getInstance().getWoodcuttingDoubleDropsEnabled(species)) { if (Config.getInstance().getWoodcuttingDoubleDropsEnabled(species)) {
Misc.dropItems(blockState.getLocation(), blockState.getBlock().getDrops()); Misc.dropItems(blockState.getLocation(), blockState.getBlock().getDrops());

View File

@@ -15,7 +15,6 @@ import org.bukkit.material.SmoothBrick;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.skills.repair.Repair; import com.gmail.nossr50.skills.repair.Repair;
import com.gmail.nossr50.skills.salvage.Salvage; import com.gmail.nossr50.skills.salvage.Salvage;
import com.gmail.nossr50.util.temp.DualSupport;
public final class BlockUtils { public final class BlockUtils {
private BlockUtils() {} private BlockUtils() {}
@@ -65,10 +64,21 @@ public final class BlockUtils {
case HOPPER: case HOPPER:
case TRAPPED_CHEST: case TRAPPED_CHEST:
case IRON_DOOR: case IRON_DOOR:
case IRON_TRAPDOOR:
case ACACIA_DOOR:
case SPRUCE_DOOR:
case BIRCH_DOOR:
case JUNGLE_DOOR:
case DARK_OAK_DOOR:
case ACACIA_FENCE:
case DARK_OAK_FENCE:
case BIRCH_FENCE:
case JUNGLE_FENCE:
case ARMOR_STAND:
return false; return false;
default: default:
return DualSupport.canActivateAbilities(blockState) && !isMcMMOAnvil(blockState) && !mcMMO.getModManager().isCustomAbilityBlock(blockState); return !isMcMMOAnvil(blockState) && !mcMMO.getModManager().isCustomAbilityBlock(blockState);
} }
} }
@@ -163,10 +173,12 @@ public final class BlockUtils {
case SANDSTONE: case SANDSTONE:
case STAINED_CLAY: case STAINED_CLAY:
case STONE: case STONE:
case PRISMARINE:
case RED_SANDSTONE:
return true; return true;
default: default:
return DualSupport.affectedBySuperBreaker(blockState) || isOre(blockState) || mcMMO.getModManager().isCustomMiningBlock(blockState); return isOre(blockState) || mcMMO.getModManager().isCustomMiningBlock(blockState);
} }
} }

View File

@@ -9,7 +9,6 @@ import org.bukkit.entity.Fish;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.player.PlayerFishEvent; import org.bukkit.event.player.PlayerFishEvent;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.metadata.FixedMetadataValue;
import org.bukkit.plugin.PluginManager; import org.bukkit.plugin.PluginManager;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
@@ -280,26 +279,4 @@ public class EventUtils {
return event; return event;
} }
/**
* There is a bug in CraftBukkit that causes piston events to
* fire multiple times. Check this method to see if the piston event
* should be processed.
*
* @param block Block object of the piston block
* @param isExtendEvent should be true when called from BlockPistonExtendEvent
*
* @return true if the PistonEvent should be processed, false otherwise
*/
public static boolean shouldProcessEvent(Block block, boolean isExtendEvent) {
String pistonAction = isExtendEvent ? "EXTEND" : "RETRACT";
String lastAction = block.hasMetadata(mcMMO.pistonDataKey) ? block.getMetadata(mcMMO.pistonDataKey).get(0).asString() : "";
if (!lastAction.equals(pistonAction)) {
block.setMetadata(mcMMO.pistonDataKey, new FixedMetadataValue(mcMMO.p, pistonAction));
return true;
}
return false;
}
} }

View File

@@ -13,6 +13,7 @@ import org.bukkit.material.Dye;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.party.ItemWeightConfig; import com.gmail.nossr50.config.party.ItemWeightConfig;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.locale.LocaleLoader;
public final class ItemUtils { public final class ItemUtils {
@@ -146,6 +147,20 @@ public final class ItemUtils {
} }
} }
/**
* Checks if the item counts as unarmed.
*
* @param item Item to check
* @return true if the item counts as unarmed, false otherwise
*/
public static boolean isUnarmed(ItemStack item) {
if (Config.getInstance().getUnarmedItemsAsUnarmed()) {
return !isMinecraftTool(item);
}
return item.getType() == Material.AIR;
}
/** /**
* Checks if the item is a helmet. * Checks if the item is a helmet.
* *

View File

@@ -293,8 +293,8 @@ public class HashChunkManager implements ChunkManager {
return false; return false;
} }
int cx = x / 16; int cx = x >> 4;
int cz = z / 16; int cz = z >> 4;
String key = world.getName() + "," + cx + "," + cz; String key = world.getName() + "," + cx + "," + cz;
if (!store.containsKey(key)) { if (!store.containsKey(key)) {
@@ -336,8 +336,8 @@ public class HashChunkManager implements ChunkManager {
return; return;
} }
int cx = x / 16; int cx = x >> 4;
int cz = z / 16; int cz = z >> 4;
int ix = Math.abs(x) % 16; int ix = Math.abs(x) % 16;
int iz = Math.abs(z) % 16; int iz = Math.abs(z) % 16;
@@ -382,8 +382,8 @@ public class HashChunkManager implements ChunkManager {
return; return;
} }
int cx = x / 16; int cx = x >> 4;
int cz = z / 16; int cz = z >> 4;
int ix = Math.abs(x) % 16; int ix = Math.abs(x) % 16;
int iz = Math.abs(z) % 16; int iz = Math.abs(z) % 16;

View File

@@ -340,7 +340,7 @@ public class ScoreboardManager {
} }
for (String playerName : dirtyPowerLevels) { for (String playerName : dirtyPowerLevels) {
McMMOPlayer mcMMOPlayer = UserManager.getOfflinePlayer(playerName); McMMOPlayer mcMMOPlayer = UserManager.getPlayer(playerName);
if (mcMMOPlayer == null) { if (mcMMOPlayer == null) {
continue; continue;

View File

@@ -48,7 +48,6 @@ import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.MobHealthbarUtils; import com.gmail.nossr50.util.MobHealthbarUtils;
import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.player.UserManager; import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.temp.CompatableGuardianXP;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
public final class CombatUtils { public final class CombatUtils {
@@ -251,7 +250,7 @@ public final class CombatUtils {
processAxeCombat(target, player, event); processAxeCombat(target, player, event);
} }
} }
else if (heldItem.getType() == Material.AIR) { else if (ItemUtils.isUnarmed(heldItem)) {
if (!SkillType.UNARMED.shouldProcess(target)) { if (!SkillType.UNARMED.shouldProcess(target)) {
return; return;
} }
@@ -467,6 +466,7 @@ public final class CombatUtils {
switch (type) { switch (type) {
case BAT: case BAT:
case SQUID: case SQUID:
case RABBIT:
baseXP = ExperienceConfig.getInstance().getAnimalsXP(); baseXP = ExperienceConfig.getInstance().getAnimalsXP();
break; break;
@@ -506,19 +506,15 @@ public final class CombatUtils {
} }
break; break;
default: case GUARDIAN:
if (type.name().equals("RABBIT")) { if (((Guardian) target).isElder()) {
baseXP = ExperienceConfig.getInstance().getAnimalsXP(); baseXP = ExperienceConfig.getInstance().getElderGuardianXP();
break; } else {
}
if (type.name().equals("ENDERMITE")) {
baseXP = ExperienceConfig.getInstance().getCombatXP(type); baseXP = ExperienceConfig.getInstance().getCombatXP(type);
break;
}
if (type.name().equals("GUARDIAN")) {
baseXP = CompatableGuardianXP.get(target);
break;
} }
break;
default:
baseXP = 1.0; baseXP = 1.0;
mcMMO.getModManager().addCustomEntity(target); mcMMO.getModManager().addCustomEntity(target);
break; break;
@@ -529,6 +525,10 @@ public final class CombatUtils {
baseXP *= ExperienceConfig.getInstance().getSpawnedMobXpMultiplier(); baseXP *= ExperienceConfig.getInstance().getSpawnedMobXpMultiplier();
} }
if (target.hasMetadata(mcMMO.bredMetadataKey)) {
baseXP *= ExperienceConfig.getInstance().getBredMobXpMultiplier();
}
xpGainReason = XPGainReason.PVE; xpGainReason = XPGainReason.PVE;
baseXP *= 10; baseXP *= 10;

View File

@@ -1,17 +0,0 @@
package com.gmail.nossr50.util.temp;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Guardian;
import com.gmail.nossr50.config.experience.ExperienceConfig;
public class CompatableGuardianXP {
public static double get(Entity target) {
if (((Guardian) target).isElder()) {
return ExperienceConfig.getInstance().getElderGuardianXP();
} else {
return ExperienceConfig.getInstance().getCombatXP(EntityType.GUARDIAN);
}
}
}

View File

@@ -1,19 +0,0 @@
package com.gmail.nossr50.util.temp;
import org.bukkit.block.BlockState;
public class DualSupport {
public static boolean canActivateAbilities(BlockState blockState) {
String mat = blockState.getType().name();
return !mat.equals("IRON_TRAPDOOR") && !mat.equals("ACACIA_DOOR") && !mat.equals("SPRUCE_DOOR") && !mat.equals("BIRCH_DOOR")
&& !mat.equals("JUNGLE_DOOR") && !mat.equals("DARK_OAK_DOOR") && !mat.equals("ACACIA_FENCE") && !mat.equals("DARK_OAK_FENCE")
&& !mat.equals("BIRCH_FENCE") && !mat.equals("JUNGLE_FENCE") && !mat.equals("ARMOR_STAND");
}
public static boolean affectedBySuperBreaker(BlockState blockState) {
String mat = blockState.getType().name();
return mat.equals("PRISMARINE") || mat.equals("RED_SANDSTONE");
}
}

View File

@@ -90,7 +90,7 @@ Skills:
# Modifier: Extra damage for arrows that cause a daze (2 damage = 1 heart) # Modifier: Extra damage for arrows that cause a daze (2 damage = 1 heart)
ChanceMax: 50.0 ChanceMax: 50.0
MaxBonusLevel: 1000 MaxBonusLevel: 1000
Modifier: 4.0 BonusDamage: 4.0
Retrieve: Retrieve:
# ChanceMax: Maximum chance of retrieving arrows when on <MaxBonusLevel> or higher # ChanceMax: Maximum chance of retrieving arrows when on <MaxBonusLevel> or higher

View File

@@ -20,6 +20,8 @@ General:
Update_Check: true Update_Check: true
Prefer_Beta: false Prefer_Beta: false
Power_Level_Cap: 0 Power_Level_Cap: 0
# Should mcMMO truncate levels if you lower your max level cap for a skillname
TruncateSkills: false
# Should mcMMO print out debug messages? # Should mcMMO print out debug messages?
Verbose_Logging: false Verbose_Logging: false
# Should mcMMO over-write configs to update, or make new ones ending in .new? # Should mcMMO over-write configs to update, or make new ones ending in .new?
@@ -395,6 +397,8 @@ Skills:
# When using Unarmed, picked up items will automatically get moved to a free slot instead of going in the slot # When using Unarmed, picked up items will automatically get moved to a free slot instead of going in the slot
# of your hand. Should item pickup be disabled when your entire inventory - except for your hand - is full? # of your hand. Should item pickup be disabled when your entire inventory - except for your hand - is full?
Item_Pickup_Disabled_Full_Inventory: true Item_Pickup_Disabled_Full_Inventory: true
# Any attacks made without a tool, i.e. with one's open hand, a block, etc., will count as unarmed.
Items_As_Unarmed: false
Woodcutting: Woodcutting:
Tree_Feller_Sounds: true Tree_Feller_Sounds: true
Level_Cap: 0 Level_Cap: 0

View File

@@ -37,6 +37,8 @@ Experience_Formula:
# Experience gained from mobs not naturally spawned will get multiplied by this value. 0 by default. # Experience gained from mobs not naturally spawned will get multiplied by this value. 0 by default.
Mobspawners: Mobspawners:
Multiplier: 0 Multiplier: 0
Breeding:
Multiplier: 1.0
# Experience gained will get divided by these values. 1.0 by default, 2.0 means two times less XP gained. # Experience gained will get divided by these values. 1.0 by default, 2.0 means two times less XP gained.
Modifier: Modifier:
@@ -116,6 +118,8 @@ Experience:
Potion_Stage_3: 60 Potion_Stage_3: 60
Potion_Stage_4: 120 Potion_Stage_4: 120
Potion_Stage_5: 0 Potion_Stage_5: 0
Archery:
Distance_Multiplier: 0.025
Fishing: Fishing:
Raw_Fish: 800 Raw_Fish: 800
Raw_Salmon: 800 Raw_Salmon: 800

File diff suppressed because it is too large Load Diff

View File

@@ -22,9 +22,9 @@ Archery.Effect.2=Stordire (Giocatori)
Archery.Effect.3=Disorienta i nemici e infligge {0} Danni Archery.Effect.3=Disorienta i nemici e infligge {0} Danni
Archery.Effect.4=Recupero Frecce Archery.Effect.4=Recupero Frecce
Archery.Effect.5=Probabilit\u00e0 di recuperare frecce dai cadaveri Archery.Effect.5=Probabilit\u00e0 di recuperare frecce dai cadaveri
Archery.Listener=Tiro con l\'Arco: Archery.Listener=Arco:
Archery.SkillName=TIRO CON L\'ARCO Archery.SkillName=ARCO
Archery.Skillup=[[YELLOW]]L\'abilit\u00e0 Tiro con l\'Arco \u00e8 aumentata di {0}. Total ({1}) Archery.Skillup=[[YELLOW]]L\'abilit\u00e0 Arco \u00e8 aumentata di {0}. Total ({1})
Axes.Ability.Bonus.0=Maestria con l\'Ascia Axes.Ability.Bonus.0=Maestria con l\'Ascia
Axes.Ability.Bonus.1={0} Danni Bonus Axes.Ability.Bonus.1={0} Danni Bonus
Axes.Ability.Bonus.2=Sfonda Armature Axes.Ability.Bonus.2=Sfonda Armature

File diff suppressed because it is too large Load Diff

View File

@@ -12,8 +12,7 @@ description: >
author: nossr50 author: nossr50
authors: [GJ, NuclearW, bm01, Glitchfinder, TfT_02, t00thpick1, Riking] authors: [GJ, NuclearW, bm01, Glitchfinder, TfT_02, t00thpick1, Riking]
website: http://dev.bukkit.org/server-mods/mcmmo/ website: www.spigotmc.org/resources/mcmmo.2445/
main: com.gmail.nossr50.mcMMO main: com.gmail.nossr50.mcMMO
softdepend: [CombatTag, HealthBar] softdepend: [CombatTag, HealthBar]
load: STARTUP load: STARTUP