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

Compare commits

...

40 Commits

Author SHA1 Message Date
GJ
a48fb30edf New beta! 2013-05-21 12:20:50 -04:00
GJ
92ec04bd46 Better boolean handling. 2013-05-21 11:44:16 -04:00
GJ
0b6372a6ea Don't run these calculations twice. Also, pretty sure one of these was
bugged.
2013-05-21 11:41:39 -04:00
GJ
4f8b66f94d Clean up our block listener some. 2013-05-21 11:11:55 -04:00
GJ
0c52b3016c We've got these functions, might as well use them. 2013-05-21 10:02:09 -04:00
GJ
a2f80569e3 Fire McMMOPlayerLevelUp events for our experience commands, when
applicable. Fixes #921
2013-05-21 09:31:25 -04:00
GJ
87df536a1f Only check for kraken if you're actually fishing. 2013-05-21 09:14:54 -04:00
T00thpick1
12e70490d8 Cooldowns messages need to be affected by perks too 2013-05-20 22:35:34 -04:00
TfT_02
23b1518dc0 More formatting :) 2013-05-20 17:28:02 -04:00
T00thpick1
6dbf2e0d95 FishingTreasureEvent, FishingShakeEvent and MagicHunterEvent 2013-05-20 17:27:59 -04:00
GJ
60304e9643 Because Minecraft does stupid things with "/" in the chat.
Fixes #994
2013-05-20 08:56:02 -04:00
GJ
614557e2fa It'd be nice if Ice Fishing actually worked. 2013-05-20 08:07:39 -04:00
TfT_02
e312e95aed Refactor to a more descriptive name,
also fixes a small typo.
2013-05-20 10:55:17 +02:00
t00thpick1
2ee919b51f Update gravatar 2013-05-19 18:18:55 -03:00
T00thpick1
22f6ae858b Update inventories after chimera wing 2013-05-19 16:13:19 -04:00
T00thpick1
3c3b4af2c4 No salvaging chainmail - FIXES 1118 2013-05-19 12:55:18 -04:00
T00thpick1
feb0d1fe5d Things that should never happen, but are. 2013-05-18 22:15:32 -04:00
TfT_02
2d66b8ed12 Cleanup - fixing various formatting issues 2013-05-18 22:41:42 +02:00
TfT_02
483f348403 Fixed bug with Blast Mining where the Ability refreshed message was being send too early 2013-05-18 22:27:17 +02:00
TfT_02
a8a5100f58 Update the changelog
Also made a minor edit to a comment about the powerlevel display
2013-05-18 14:27:14 +02:00
TfT_02
1f9dc70bb1 I forgot to remove the setting from advanced.yml 2013-05-18 14:12:45 +02:00
TfT_02
7f1ef61657 Get rid of the SuccessModifier
There's no need for this modifier, because the user can define the
exact chance for Rolls and Gracefull Rolls in the config file. This
means that the ratio between the two is already configurable.
2013-05-18 14:12:07 +02:00
TfT_02
2e74c079b0 Set the enchant buff level to 1 if it's lower than 0
Prevents issue #1006 from happening again.

If a user wants to disable SuperBreaker, they should do this using
permissions and not by setting the Enchant Buff level to zero.
2013-05-18 11:37:40 +02:00
TfT_02
ce4295289a Changed powerlevel display setting to disabled by default.
Because scoreboards are being cached by Minecraft in scoreboard.dat it
is no user friendly to enabled this by default. Users will have to
manually delete this file in order to actually disable this.
Described in #1105
2013-05-18 11:27:17 +02:00
T00thpick1
7fde04851d Typo 2013-05-17 18:44:23 -04:00
riking
71d030e5ad Change rounding strategy to ceiling for mob healthbars 2013-05-17 00:19:59 -04:00
T00thpick1
b08649d0a4 Not much help if not static 2013-05-16 23:58:49 -04:00
T00thpick1
0a11a9a2c8 More methods for SkillType 2013-05-16 22:00:40 -04:00
T00thpick1
068f47b523 Option for any distance 2013-05-16 19:53:58 -04:00
T00thpick1
79aab57abc Configure the inspect distance 2013-05-16 19:31:12 -04:00
T00thpick1
2cf58f1b5b Why break when we can return? 2013-05-16 18:04:14 -04:00
T00thpick1
9678875b4b We do enjoy killing off orphans 2013-05-16 17:26:16 -04:00
GJ
d1a7ce827a Back to active development. Again. 2013-05-16 16:24:19 -04:00
GJ
9b2f4b7bde Because the old beta broke all the things. 2013-05-16 16:23:12 -04:00
GJ
24e5147a2a This was never an issue. 2013-05-16 16:13:53 -04:00
T00thpick1
0423a7831d Those were right the first time... 2013-05-16 15:55:25 -04:00
T00thpick1
feea22b3a4 Correctly order 2013-05-16 15:52:49 -04:00
T00thpick1
7f40a9f284 Explicitely state columns wanted to account for altered tables 2013-05-16 15:50:19 -04:00
GJ
bc706109e0 Fix issue with tables without party names. 2013-05-16 13:37:22 -04:00
GJ
a25bddba5e Back to active development. 2013-05-16 10:55:13 -04:00
52 changed files with 548 additions and 340 deletions

View File

@@ -6,7 +6,7 @@ Key:
= Fix
! Change
- Removal
Version 1.4.06-dev
+ Added "Ice Fishing" ability to Fishing
+ Added global scoreboards to track skill rankings (display using /mctop)
@@ -46,6 +46,8 @@ Version 1.4.06-dev
= Fixed bug with removing players from mySQL database
= Fixed bug with empty metadata lists and Smelting
= Fixed bug where Blast Mining would drop wrong items
= Fixed bug with Blast Mining where the Ability refreshed message was being send too early
= Fixed bug where the chance of a successful Gracefull Roll was twice as high as displayed
! Changed Spout notification tiers to be stored in SpoutConfig instead of AdvancedConfig
! Changed Berserk to add items to inventory rather than denying pickup
! Changed Call of the Wild, newly summoned pet's will have a custom name. (added permission node to disable this)

View File

@@ -29,7 +29,7 @@ mcMMO is currently developed by a team of individuals from all over the world.
(https://github.com/shatteredbeam)
[![TfT_02](http://www.gravatar.com/avatar/b8914f9970e1f6ffd5281ce4770e20a7.png)]
(https://github.com/TfT-02)
[![t00thpick1](http://www.gravatar.com/avatar/??.png)]
[![t00thpick1](http://www.gravatar.com/avatar/ee23c7794a0c40120c3474287c7bce06.png)]
(https://github.com/t00thpick1)
## Compiling

View File

@@ -2,7 +2,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.gmail.nossr50.mcMMO</groupId>
<artifactId>mcMMO</artifactId>
<version>1.4.06-beta3</version>
<version>1.4.06-beta5</version>
<name>mcMMO</name>
<url>https://github.com/mcMMO-Dev/mcMMO</url>
<issueManagement>

View File

@@ -138,7 +138,7 @@ public final class ChatAPI {
*
* @param playerName The name of the player to toggle party chat on.
*/
public static void toggleAdminChat(String playerName){
public static void toggleAdminChat(String playerName) {
UserManager.getPlayer(playerName).setAdminChat(!isUsingAdminChat(playerName));
}
}

View File

@@ -119,7 +119,7 @@ public final class ExperienceAPI {
throw new InvalidSkillException();
}
UserManager.getPlayer(player).applyXpGain(skill, (int) (XP / skill.getXpModifier() * Config.getInstance().getExperienceGainsGlobalMultiplier()));
UserManager.getPlayer(player).applyXpGain(skill, (int) (XP / skill.getXpModifier() * Config.getInstance().getExperienceGainsGlobalMultiplier()));
}
/**
@@ -506,11 +506,7 @@ public final class ExperienceAPI {
int powerLevel = 0;
PlayerProfile profile = getOfflineProfile(playerName);
for (SkillType type : SkillType.values()) {
if (type.isChildSkill()) {
continue;
}
for (SkillType type : SkillType.nonChildSkills()) {
powerLevel += profile.getSkillLevel(type);
}

View File

@@ -12,7 +12,7 @@ import com.gmail.nossr50.events.chat.McMMOPartyChatEvent;
import com.gmail.nossr50.locale.LocaleLoader;
public final class ChatManager {
public ChatManager () {}
public ChatManager() {}
public static void handleAdminChat(Plugin plugin, String playerName, String displayName, String message, boolean isAsync) {
McMMOAdminChatEvent chatEvent = new McMMOAdminChatEvent(plugin, playerName, displayName, message, isAsync);

View File

@@ -62,52 +62,52 @@ public class McmmoCommand implements CommandExecutor {
private void displayPartyCommands(CommandSender sender) {
if (Permissions.party(sender)) {
sender.sendMessage(LocaleLoader.getString("Commands.Party.Commands"));
sender.sendMessage("/party create <" + LocaleLoader.getString("Commands.Usage.PartyName") + "> " + LocaleLoader.getString("Commands.Party1"));
sender.sendMessage("/party join <" + LocaleLoader.getString("Commands.Usage.Player") + "> " + LocaleLoader.getString("Commands.Party2"));
sender.sendMessage("/party quit " + LocaleLoader.getString("Commands.Party.Quit"));
sender.sendMessage(" /party create <" + LocaleLoader.getString("Commands.Usage.PartyName") + "> " + LocaleLoader.getString("Commands.Party1"));
sender.sendMessage(" /party join <" + LocaleLoader.getString("Commands.Usage.Player") + "> " + LocaleLoader.getString("Commands.Party2"));
sender.sendMessage(" /party quit " + LocaleLoader.getString("Commands.Party.Quit"));
if (Permissions.partyChat(sender)) {
sender.sendMessage("/party chat " + LocaleLoader.getString("Commands.Party.Toggle"));
sender.sendMessage(" /party chat " + LocaleLoader.getString("Commands.Party.Toggle"));
}
sender.sendMessage("/party invite <" + LocaleLoader.getString("Commands.Usage.Player") + "> " + LocaleLoader.getString("Commands.Party.Invite"));
sender.sendMessage("/party accept " + LocaleLoader.getString("Commands.Party.Accept"));
sender.sendMessage(" /party invite <" + LocaleLoader.getString("Commands.Usage.Player") + "> " + LocaleLoader.getString("Commands.Party.Invite"));
sender.sendMessage(" /party accept " + LocaleLoader.getString("Commands.Party.Accept"));
if (Permissions.partySubcommand(sender, PartySubcommandType.TELEPORT)) {
sender.sendMessage("/party teleport " + LocaleLoader.getString("Commands.Party.Teleport"));
sender.sendMessage(" /party teleport " + LocaleLoader.getString("Commands.Party.Teleport"));
}
}
}
private void displayOtherCommands(CommandSender sender) {
sender.sendMessage(LocaleLoader.getString("Commands.Other"));
sender.sendMessage("/mcstats " + LocaleLoader.getString("Commands.Stats"));
sender.sendMessage("/mctop " + LocaleLoader.getString("Commands.Leaderboards"));
sender.sendMessage(" /mcstats " + LocaleLoader.getString("Commands.Stats"));
sender.sendMessage(" /mctop " + LocaleLoader.getString("Commands.Leaderboards"));
if (Permissions.skillreset(sender)) {
sender.sendMessage("/skillreset <skill|all> " + LocaleLoader.getString("Commands.Reset"));
sender.sendMessage(" /skillreset <skill|all> " + LocaleLoader.getString("Commands.Reset"));
}
if (Permissions.mcability(sender)) {
sender.sendMessage("/mcability " + LocaleLoader.getString("Commands.ToggleAbility"));
sender.sendMessage(" /mcability " + LocaleLoader.getString("Commands.ToggleAbility"));
}
if (Permissions.adminChat(sender)) {
sender.sendMessage("/adminchat " + LocaleLoader.getString("Commands.AdminToggle"));
sender.sendMessage(" /adminchat " + LocaleLoader.getString("Commands.AdminToggle"));
}
if (Permissions.inspect(sender)) {
sender.sendMessage("/inspect " + LocaleLoader.getString("Commands.Inspect"));
sender.sendMessage(" /inspect " + LocaleLoader.getString("Commands.Inspect"));
}
if (Permissions.mmoedit(sender)) {
sender.sendMessage("/mmoedit " + LocaleLoader.getString("Commands.mmoedit"));
sender.sendMessage(" /mmoedit " + LocaleLoader.getString("Commands.mmoedit"));
}
if (Permissions.mcgod(sender)) {
sender.sendMessage("/mcgod " + LocaleLoader.getString("Commands.mcgod"));
sender.sendMessage(" /mcgod " + LocaleLoader.getString("Commands.mcgod"));
}
sender.sendMessage(LocaleLoader.getString("Commands.SkillInfo"));
sender.sendMessage(" /<skill>" + LocaleLoader.getString("Commands.SkillInfo"));
}
}

View File

@@ -2,7 +2,9 @@ package com.gmail.nossr50.commands.experience;
import org.bukkit.command.CommandSender;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.events.experience.McMMOPlayerLevelUpEvent;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.skills.SkillUtils;
@@ -21,6 +23,10 @@ public class AddlevelsCommand extends ExperienceCommand {
@Override
protected void handleCommand(SkillType skill) {
profile.addLevels(skill, value);
if (player != null) {
mcMMO.p.getServer().getPluginManager().callEvent(new McMMOPlayerLevelUpEvent(player, skill, value));
}
}
@Override

View File

@@ -2,7 +2,9 @@ package com.gmail.nossr50.commands.experience;
import org.bukkit.command.CommandSender;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.events.experience.McMMOPlayerLevelUpEvent;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.skills.SkillUtils;
@@ -21,6 +23,10 @@ public class MmoeditCommand extends ExperienceCommand {
@Override
protected void handleCommand(SkillType skill) {
profile.modifySkill(skill, value);
if (player != null) {
mcMMO.p.getServer().getPluginManager().callEvent(new McMMOPlayerLevelUpEvent(player, skill, value - profile.getSkillLevel(skill)));
}
}
@Override

View File

@@ -3,8 +3,10 @@ package com.gmail.nossr50.commands.experience;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.datatypes.player.PlayerProfile;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.events.experience.McMMOPlayerLevelUpEvent;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.commands.CommandUtils;
@@ -84,13 +86,11 @@ public class SkillresetCommand extends ExperienceCommand {
@Override
protected boolean permissionsCheckSelf(CommandSender sender) {
// TODO Auto-generated method stub
return false;
}
@Override
protected boolean permissionsCheckOthers(CommandSender sender) {
// TODO Auto-generated method stub
return false;
}
@@ -102,6 +102,10 @@ public class SkillresetCommand extends ExperienceCommand {
}
profile.modifySkill(skill, 0);
if (player != null) {
mcMMO.p.getServer().getPluginManager().callEvent(new McMMOPlayerLevelUpEvent(player, skill, 0 - profile.getSkillLevel(skill)));
}
}
@Override

View File

@@ -55,11 +55,15 @@ public class PtpCommand implements TabExecutor {
Player player = mcMMOPlayer.getPlayer();
long recentlyHurt = mcMMOPlayer.getRecentlyHurt();
int recentlyhurt_cooldown = Config.getInstance().getPTPCommandRecentlyHurtCooldown();
int hurtCooldown = Config.getInstance().getPTPCommandRecentlyHurtCooldown();
if (!SkillUtils.cooldownOver(recentlyHurt * Misc.TIME_CONVERSION_FACTOR, recentlyhurt_cooldown, player)) {
player.sendMessage(LocaleLoader.getString("Item.Injured.Wait", SkillUtils.calculateTimeLeft(recentlyHurt * Misc.TIME_CONVERSION_FACTOR, recentlyhurt_cooldown, player)));
return true;
if (hurtCooldown > 0) {
int timeRemaining = SkillUtils.calculateTimeLeft(recentlyHurt * Misc.TIME_CONVERSION_FACTOR, hurtCooldown, player);
if (timeRemaining > 0) {
player.sendMessage(LocaleLoader.getString("Item.Injured.Wait", timeRemaining));
return true;
}
}
if (args[0].equalsIgnoreCase("accept")) {
@@ -74,9 +78,13 @@ public class PtpCommand implements TabExecutor {
int ptpCooldown = Config.getInstance().getPTPCommandCooldown();
long lastTeleport = mcMMOPlayer.getLastTeleport();
if (!SkillUtils.cooldownOver(lastTeleport * Misc.TIME_CONVERSION_FACTOR, ptpCooldown, player)) {
player.sendMessage(LocaleLoader.getString("Item.Generic.Wait", SkillUtils.calculateTimeLeft(lastTeleport * Misc.TIME_CONVERSION_FACTOR, ptpCooldown, player)));
return true;
if (ptpCooldown > 0) {
int timeRemaining = SkillUtils.calculateTimeLeft(lastTeleport * Misc.TIME_CONVERSION_FACTOR, ptpCooldown, player);
if (timeRemaining > 0) {
player.sendMessage(LocaleLoader.getString("Item.Generic.Wait", timeRemaining));
return true;
}
}
sendTeleportRequest(sender, player, args[0]);

View File

@@ -20,7 +20,10 @@ public class AdvancedConfig extends AutoUpdateConfigLoader {
/* GENERAL */
public int getAbilityLength() { return config.getInt("Skills.General.Ability_IncreaseLevel", 50); }
public int getEnchantBuff() { return config.getInt("Skills.General.Ability_EnchantBuff", 5); }
public int getEnchantBuff() {
int buff = config.getInt("Skills.General.Ability_EnchantBuff", 5);
return (buff <= 0) ? 1 : buff;
}
/* ACROBATICS */
public double getDodgeChanceMax() { return config.getDouble("Skills.Acrobatics.Dodge_ChanceMax", 20.0D); }
@@ -34,7 +37,6 @@ public class AdvancedConfig extends AutoUpdateConfigLoader {
public double getGracefulRollChanceMax() { return config.getDouble("Skills.Acrobatics.GracefulRoll_ChanceMax", 100.0D); }
public int getGracefulRollMaxBonusLevel() { return config.getInt("Skills.Acrobatics.GracefulRoll_MaxBonusLevel", 500); }
public int getGracefulRollDamageThreshold() { return config.getInt("Skills.Acrobatics.GracefulRoll_DamageThreshold", 14); }
public int getGracefulRollSuccessModifer() { return config.getInt("Skills.Acrobatics.GracefulRoll_SuccessModifier", 2); }
public int getDodgeXPModifier() { return config.getInt("Skills.Acrobatics.Dodge_XP_Modifier", 120); }
public int getRollXPModifier() { return config.getInt("Skills.Acrobatics.Roll_XP_Modifier", 80); }

View File

@@ -80,7 +80,7 @@ public class Config extends AutoUpdateConfigLoader {
public boolean getSkillScoreboardEnabled() { return config.getBoolean("Scoreboards.Skillname.Use", true); }
public int getSkillScoreboardTime() { return config.getInt("Scoreboards.Skillname.Display_Time", 10); }
public boolean getPowerLevelsEnabled() { return config.getBoolean("Scoreboards.Power_Level.Use", true); }
public boolean getPowerLevelsEnabled() { return config.getBoolean("Scoreboards.Power_Level.Use", false); }
/* Database Purging */
public int getPurgeInterval() { return config.getInt("Database_Purging.Purge_Interval", -1); }
@@ -172,6 +172,9 @@ public class Config extends AutoUpdateConfigLoader {
public boolean getPTPCommandConfirmRequired() { return config.getBoolean("Commands.ptp.Confirm_Required", true); }
public boolean getPTPCommandWorldPermissions() { return config.getBoolean("Commands.ptp.World_Based_Permissions", false); }
/* Inspect command distance */
public double getInspectDistance() { return config.getDouble("Commands.inspect.Max_Distance", 30); }
/*
* ABILITY SETTINGS
*/
@@ -294,5 +297,5 @@ public class Config extends AutoUpdateConfigLoader {
/* XP Formula Multiplier */
public int getFormulaMultiplierCurve() { return config.getInt("Experience.Formula.Curve_Modifier", 20); }
public double getForumulaMultiplier(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())); }
}

View File

@@ -57,7 +57,7 @@ public abstract class ConfigLoader {
OutputStream outputStream = null;
try {
outputStream = new FileOutputStream(configFile);
outputStream = new FileOutputStream(configFile);
int read;
byte[] bytes = new byte[1024];

View File

@@ -294,11 +294,7 @@ public final class FlatfileDatabaseManager {
Map<String, Integer> skills = new HashMap<String, Integer>();
for (SkillType skill : SkillType.values()) {
if (skill.isChildSkill()) {
continue;
}
for (SkillType skill : SkillType.nonChildSkills()) {
skills.put(skill.name(), getPlayerRank(playerName, playerStatHash.get(skill)));
}

View File

@@ -150,6 +150,8 @@ public final class SQLDatabaseManager {
checkDatabaseStructure(DatabaseUpdateType.BLAST_MINING);
checkDatabaseStructure(DatabaseUpdateType.INDEX);
checkDatabaseStructure(DatabaseUpdateType.MOB_HEALTHBARS);
checkDatabaseStructure(DatabaseUpdateType.PARTY_NAMES);
checkDatabaseStructure(DatabaseUpdateType.KILL_ORPHANS);
}
/**
@@ -170,7 +172,9 @@ public final class SQLDatabaseManager {
return true;
}
catch (SQLException ex) {
printErrors(ex);
if (!sql.equalsIgnoreCase("ALTER TABLE `" + tablePrefix + "users` DROP COLUMN `party` ;")) {
printErrors(ex);
}
return false;
}
finally {
@@ -411,11 +415,7 @@ public final class SQLDatabaseManager {
if (checkConnected()) {
try {
for (SkillType skillType : SkillType.values()) {
if (skillType.isChildSkill()) {
continue;
}
for (SkillType skillType : SkillType.nonChildSkills()) {
String skillName = skillType.name().toLowerCase();
String sql = "SELECT COUNT(*) AS rank FROM " + tablePrefix + "users JOIN " + tablePrefix + "skills ON user_id = id WHERE " + skillName + " > 0 " +
"AND " + skillName + " > (SELECT " + skillName + " FROM " + tablePrefix + "users JOIN " + tablePrefix + "skills ON user_id = id " +
@@ -560,12 +560,44 @@ public final class SQLDatabaseManager {
+ "ADD INDEX `idx_acrobatics` (`acrobatics`) USING BTREE, "
+ "ADD INDEX `idx_fishing` (`fishing`) USING BTREE;");
}
break;
return;
case MOB_HEALTHBARS:
sql = "SELECT * FROM `" + tablePrefix + "huds` ORDER BY `" + tablePrefix + "huds`.`mobhealthbar` ASC LIMIT 0 , 30";
break;
case PARTY_NAMES:
write("ALTER TABLE `" + tablePrefix + "users` DROP COLUMN `party` ;");
return;
case KILL_ORPHANS:
mcMMO.p.getLogger().info("Killing orphans");
write(
"DELETE FROM " + tablePrefix + "experience " +
"WHERE NOT EXISTS (SELECT * FROM " +
tablePrefix + "users u WHERE " +
tablePrefix + "experience.user_id = u.id);"
);
write(
"DELETE FROM " + tablePrefix + "huds " +
"WHERE NOT EXISTS (SELECT * FROM " +
tablePrefix + "users u WHERE " +
tablePrefix + "huds.user_id = u.id);"
);
write(
"DELETE FROM " + tablePrefix + "cooldowns " +
"WHERE NOT EXISTS (SELECT * FROM " +
tablePrefix + "users u WHERE " +
tablePrefix + "cooldowns.user_id = u.id);"
);
write(
"DELETE FROM " + tablePrefix + "skills " +
"WHERE NOT EXISTS (SELECT * FROM " +
tablePrefix + "users u WHERE " +
tablePrefix + "skills.user_id = u.id);"
);
return;
default:
break;
}

View File

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

View File

@@ -441,11 +441,7 @@ public class McMMOPlayer {
public int getPowerLevel() {
int powerLevel = 0;
for (SkillType type : SkillType.values()) {
if (type.isChildSkill()) {
continue;
}
for (SkillType type : SkillType.nonChildSkills()) {
if (Permissions.skillEnabled(player, type)) {
powerLevel += profile.getSkillLevel(type);
}
@@ -513,7 +509,7 @@ public class McMMOPlayer {
return;
}
if (!Permissions.skillEnabled(player, skillType)) {
return;
}

View File

@@ -49,11 +49,7 @@ public class PlayerProfile {
skillsDATS.put(abilityType, 0);
}
for (SkillType skillType : SkillType.values()) {
if (skillType.isChildSkill()) {
continue;
}
for (SkillType skillType : SkillType.nonChildSkills()) {
skills.put(skillType, 0);
skillsXp.put(skillType, 0F);
}
@@ -257,7 +253,7 @@ public class PlayerProfile {
* @return the Xp remaining until next level
*/
public int getXpToLevel(SkillType skillType) {
return 1020 + (skills.get(skillType) * Config.getInstance().getFormulaMultiplierCurve());
return 1020 + (skills.get(skillType) * Config.getInstance().getFormulaMultiplierCurve());
}
private int getChildSkillLevel(SkillType skillType) {
@@ -288,7 +284,13 @@ public class PlayerProfile {
String tablePrefix = Config.getInstance().getMySQLTablePrefix();
ArrayList<String> playerData = SQLDatabaseManager.read(
"SELECT * FROM " + tablePrefix + "users u " +
"SELECT " +
"u.id, " +
"s.taming, s.mining, s.repair, s.woodcutting, s.unarmed, s.herbalism, s.excavation, s.archery, s.swords, s.axes, s.acrobatics, s.fishing, " +
"e.taming, e.mining, e.repair, e.woodcutting, e.unarmed, e.herbalism, e.excavation, e.archery, e.swords, e.axes, e.acrobatics, e.fishing, " +
"c.taming, c.mining, c.repair, c.woodcutting, c.unarmed, c.herbalism, c.excavation, c.archery, c.swords, c.axes, c.acrobatics, c.blast_mining, " +
"h.hudtype, h.mobhealthbar " +
"FROM " + tablePrefix + "users u " +
"JOIN " + tablePrefix + "skills s ON (u.id = s.user_id) " +
"JOIN " + tablePrefix + "experience e ON (u.id = e.user_id) " +
"JOIN " + tablePrefix + "cooldowns c ON (u.id = c.user_id) " +
@@ -312,68 +314,81 @@ public class PlayerProfile {
// Re-read data
playerData = SQLDatabaseManager.read(
"SELECT * FROM " + tablePrefix + "users u " +
"SELECT " +
"u.id, " +
"s.taming, s.mining, s.repair, s.woodcutting, s.unarmed, s.herbalism, s.excavation, s.archery, s.swords, s.axes, s.acrobatics, s.fishing, " +
"e.taming, e.mining, e.repair, e.woodcutting, e.unarmed, e.herbalism, e.excavation, e.archery, e.swords, e.axes, e.acrobatics, e.fishing, " +
"c.taming, c.mining, c.repair, c.woodcutting, c.unarmed, c.herbalism, c.excavation, c.archery, c.swords, c.axes, c.acrobatics, c.blast_mining, " +
"h.hudtype, h.mobhealthbar " +
"FROM " + tablePrefix + "users u " +
"JOIN " + tablePrefix + "skills s ON (u.id = s.user_id) " +
"JOIN " + tablePrefix + "experience e ON (u.id = e.user_id) " +
"JOIN " + tablePrefix + "cooldowns c ON (u.id = c.user_id) " +
"JOIN " + tablePrefix + "huds h ON (u.id = h.user_id) " +
"WHERE u.user = '" + playerName + "'"
).get(1);
// Should never happen but just in case
if (playerData == null || playerData.size() == 0) {
return false;
}
}
// Remove from list the user_id's from various tables
playerData.remove(43);
playerData.remove(30);
playerData.remove(17);
playerData.remove(4);
userId = Integer.valueOf(playerData.get(0));
// UserName 1 - Already loaded
// LastLogin 2 - Doesn't need to be loaded
// PartyName 3 - Loaded elsewhere I believe
skills.put(SkillType.TAMING, Integer.valueOf(playerData.get(4)));
skills.put(SkillType.MINING, Integer.valueOf(playerData.get(5)));
skills.put(SkillType.REPAIR, Integer.valueOf(playerData.get(6)));
skills.put(SkillType.WOODCUTTING, Integer.valueOf(playerData.get(7)));
skills.put(SkillType.UNARMED, Integer.valueOf(playerData.get(8)));
skills.put(SkillType.HERBALISM, Integer.valueOf(playerData.get(9)));
skills.put(SkillType.EXCAVATION, Integer.valueOf(playerData.get(10)));
skills.put(SkillType.ARCHERY, Integer.valueOf(playerData.get(11)));
skills.put(SkillType.SWORDS, Integer.valueOf(playerData.get(12)));
skills.put(SkillType.AXES, Integer.valueOf(playerData.get(13)));
skills.put(SkillType.ACROBATICS, Integer.valueOf(playerData.get(14)));
skills.put(SkillType.FISHING, Integer.valueOf(playerData.get(15)));
skills.put(SkillType.TAMING, Integer.valueOf(playerData.get(1)));
skills.put(SkillType.MINING, Integer.valueOf(playerData.get(2)));
skills.put(SkillType.REPAIR, Integer.valueOf(playerData.get(3)));
skills.put(SkillType.WOODCUTTING, Integer.valueOf(playerData.get(4)));
skills.put(SkillType.UNARMED, Integer.valueOf(playerData.get(5)));
skills.put(SkillType.HERBALISM, Integer.valueOf(playerData.get(6)));
skills.put(SkillType.EXCAVATION, Integer.valueOf(playerData.get(7)));
skills.put(SkillType.ARCHERY, Integer.valueOf(playerData.get(8)));
skills.put(SkillType.SWORDS, Integer.valueOf(playerData.get(9)));
skills.put(SkillType.AXES, Integer.valueOf(playerData.get(10)));
skills.put(SkillType.ACROBATICS, Integer.valueOf(playerData.get(11)));
skills.put(SkillType.FISHING, Integer.valueOf(playerData.get(12)));
skillsXp.put(SkillType.TAMING, (float) Integer.valueOf(playerData.get(16)));
skillsXp.put(SkillType.MINING, (float) Integer.valueOf(playerData.get(17)));
skillsXp.put(SkillType.REPAIR, (float) Integer.valueOf(playerData.get(18)));
skillsXp.put(SkillType.WOODCUTTING, (float) Integer.valueOf(playerData.get(19)));
skillsXp.put(SkillType.UNARMED, (float) Integer.valueOf(playerData.get(20)));
skillsXp.put(SkillType.HERBALISM, (float) Integer.valueOf(playerData.get(21)));
skillsXp.put(SkillType.EXCAVATION, (float) Integer.valueOf(playerData.get(22)));
skillsXp.put(SkillType.ARCHERY, (float) Integer.valueOf(playerData.get(23)));
skillsXp.put(SkillType.SWORDS, (float) Integer.valueOf(playerData.get(24)));
skillsXp.put(SkillType.AXES, (float) Integer.valueOf(playerData.get(25)));
skillsXp.put(SkillType.ACROBATICS, (float) Integer.valueOf(playerData.get(26)));
skillsXp.put(SkillType.FISHING, (float) Integer.valueOf(playerData.get(27)));
skillsXp.put(SkillType.TAMING, (float) Integer.valueOf(playerData.get(13)));
skillsXp.put(SkillType.MINING, (float) Integer.valueOf(playerData.get(14)));
skillsXp.put(SkillType.REPAIR, (float) Integer.valueOf(playerData.get(15)));
skillsXp.put(SkillType.WOODCUTTING, (float) Integer.valueOf(playerData.get(16)));
skillsXp.put(SkillType.UNARMED, (float) Integer.valueOf(playerData.get(17)));
skillsXp.put(SkillType.HERBALISM, (float) Integer.valueOf(playerData.get(18)));
skillsXp.put(SkillType.EXCAVATION, (float) Integer.valueOf(playerData.get(19)));
skillsXp.put(SkillType.ARCHERY, (float) Integer.valueOf(playerData.get(20)));
skillsXp.put(SkillType.SWORDS, (float) Integer.valueOf(playerData.get(21)));
skillsXp.put(SkillType.AXES, (float) Integer.valueOf(playerData.get(22)));
skillsXp.put(SkillType.ACROBATICS, (float) Integer.valueOf(playerData.get(23)));
skillsXp.put(SkillType.FISHING, (float) Integer.valueOf(playerData.get(24)));
// Taming 28 - Unused
skillsDATS.put(AbilityType.SUPER_BREAKER, Integer.valueOf(playerData.get(29)));
skillsDATS.put(AbilityType.TREE_FELLER, Integer.valueOf(playerData.get(30)));
// Repair 31 - Unused
skillsDATS.put(AbilityType.BERSERK, Integer.valueOf(playerData.get(32)));
skillsDATS.put(AbilityType.GREEN_TERRA, Integer.valueOf(playerData.get(33)));
skillsDATS.put(AbilityType.GIGA_DRILL_BREAKER, Integer.valueOf(playerData.get(34)));
// Archery 35 - Unused
skillsDATS.put(AbilityType.SERRATED_STRIKES, Integer.valueOf(playerData.get(36)));
skillsDATS.put(AbilityType.SKULL_SPLITTER, Integer.valueOf(playerData.get(37)));
// Acrobatics 38 - Unused
skillsDATS.put(AbilityType.BLAST_MINING, Integer.valueOf(playerData.get(39)));
// Taming 25 - Unused
skillsDATS.put(AbilityType.SUPER_BREAKER, Integer.valueOf(playerData.get(26)));
// Repair 27 - Unused
skillsDATS.put(AbilityType.TREE_FELLER, Integer.valueOf(playerData.get(28)));
skillsDATS.put(AbilityType.BERSERK, Integer.valueOf(playerData.get(29)));
skillsDATS.put(AbilityType.GREEN_TERRA, Integer.valueOf(playerData.get(30)));
skillsDATS.put(AbilityType.GIGA_DRILL_BREAKER, Integer.valueOf(playerData.get(31)));
// Archery 32 - Unused
skillsDATS.put(AbilityType.SERRATED_STRIKES, Integer.valueOf(playerData.get(33)));
skillsDATS.put(AbilityType.SKULL_SPLITTER, Integer.valueOf(playerData.get(34)));
// Acrobatics 35 - Unused
skillsDATS.put(AbilityType.BLAST_MINING, Integer.valueOf(playerData.get(36)));
hudType = HudType.valueOf(playerData.get(40));
mobHealthbarType = MobHealthbarType.valueOf(playerData.get(41));
try {
hudType = HudType.valueOf(playerData.get(37));
}
catch (Exception e) {
// Shouldn't happen unless database is being tampered with
hudType = HudType.STANDARD;
}
try {
mobHealthbarType = MobHealthbarType.valueOf(playerData.get(38));
}
catch (Exception e) {
mobHealthbarType = Config.getInstance().getMobHealthbarDefault();
}
loaded = true;
return true;

View File

@@ -68,6 +68,13 @@ public enum AbilityType {
null),
LEAF_BLOWER(
null,
null,
null,
null,
null),
BLOCK_CRACKER(
null,
null,
null,
@@ -144,7 +151,6 @@ public enum AbilityType {
* @return true if the player has permissions, false otherwise
*/
public boolean getPermissions(Player player) {
switch (this) {
case BERSERK:
return Permissions.berserk(player);
@@ -152,6 +158,9 @@ public enum AbilityType {
case BLAST_MINING:
return Permissions.remoteDetonation(player);
case BLOCK_CRACKER:
return Permissions.blockCracker(player);
case GIGA_DRILL_BREAKER:
return Permissions.gigaDrillBreaker(player);
@@ -189,6 +198,9 @@ public enum AbilityType {
case BERSERK:
return (BlockUtils.affectedByGigaDrillBreaker(blockState) || blockState.getType() == Material.SNOW);
case BLOCK_CRACKER:
return BlockUtils.affectedByBlockCracker(blockState);
case GIGA_DRILL_BREAKER:
return BlockUtils.affectedByGigaDrillBreaker(blockState);

View File

@@ -108,7 +108,7 @@ public enum SkillType {
}
public double getXpModifier() {
return Config.getInstance().getForumulaMultiplier(this);
return Config.getInstance().getFormulaSkillModifier(this);
}
public static SkillType getSkill(String skillName) {
@@ -141,6 +141,25 @@ public enum SkillType {
}
}
public static SkillType[] nonChildSkills() {
return new SkillType[] {SkillType.ACROBATICS,
SkillType.ARCHERY,
SkillType.AXES,
SkillType.EXCAVATION,
SkillType.FISHING,
SkillType.HERBALISM,
SkillType.MINING,
SkillType.REPAIR,
SkillType.SWORDS,
SkillType.TAMING,
SkillType.UNARMED,
SkillType.WOODCUTTING };
}
public static SkillType[] childSkills() {
return new SkillType[] { SkillType.SMELTING };
}
public Color getRunescapeModeColor() {
return runescapeColor;
}
@@ -151,7 +170,7 @@ public enum SkillType {
return type;
}
}
return null;
}
}

View File

@@ -17,7 +17,7 @@ public class McMMOPlayerLevelUpEvent extends McMMOPlayerExperienceEvent {
public McMMOPlayerLevelUpEvent(Player player, SkillType skill, int levelsGained) {
super(player, skill);
this.setLevelsGained(levelsGained);
this.levelsGained = levelsGained;
}
/**

View File

@@ -14,7 +14,7 @@ public class McMMOPlayerAbilityDeactivateEvent extends McMMOPlayerSkillEvent {
super(player, skill);
this.ability = skill.getAbility();
}
public AbilityType getAbility() {
return ability;
}

View File

@@ -0,0 +1,45 @@
package com.gmail.nossr50.events.skills.fishing;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import org.bukkit.inventory.ItemStack;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.events.skills.McMMOPlayerSkillEvent;
public class McMMOPlayerFishingTreasureEvent extends McMMOPlayerSkillEvent implements Cancellable {
private boolean cancelled = false;
private ItemStack treasure;
private int xp;
public McMMOPlayerFishingTreasureEvent(Player player, ItemStack treasure, int xp) {
super(player, SkillType.FISHING);
this.treasure = treasure;
this.xp = xp;
}
public ItemStack getTreasure() {
return treasure;
}
public void setTreasure(ItemStack item) {
this.treasure = item;
}
public boolean isCancelled() {
return cancelled;
}
public void setCancelled(boolean newValue) {
this.cancelled = newValue;
}
public int getXp() {
return xp;
}
public void setXp(int xp) {
this.xp = xp;
}
}

View File

@@ -0,0 +1,21 @@
package com.gmail.nossr50.events.skills.fishing;
import java.util.Map;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
public class McMMOPlayerMagicHunterEvent extends McMMOPlayerFishingTreasureEvent {
private Map<Enchantment, Integer> enchants;
public McMMOPlayerMagicHunterEvent(Player player, ItemStack treasure, int xp, Map<Enchantment, Integer> enchants) {
super(player, treasure, xp);
this.enchants = enchants;
}
public Map<Enchantment, Integer> getEnchantments() {
return enchants;
}
}

View File

@@ -0,0 +1,36 @@
package com.gmail.nossr50.events.skills.fishing;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import org.bukkit.inventory.ItemStack;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.events.skills.McMMOPlayerSkillEvent;
public class McMMOPlayerShakeEvent extends McMMOPlayerSkillEvent implements Cancellable {
private boolean cancelled = false;
private ItemStack drop;
public McMMOPlayerShakeEvent(Player player, ItemStack drop) {
super(player, SkillType.FISHING);
this.drop = drop;
}
public boolean isCancelled() {
return cancelled;
}
public void setCancelled(boolean newValue) {
this.cancelled = newValue;
}
public ItemStack getDrop() {
return drop;
}
public void setDrop(ItemStack drop) {
this.drop = drop;
}
}

View File

@@ -28,14 +28,12 @@ import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.datatypes.skills.ToolType;
import com.gmail.nossr50.events.fake.FakeBlockBreakEvent;
import com.gmail.nossr50.events.fake.FakeBlockDamageEvent;
import com.gmail.nossr50.events.fake.FakePlayerAnimationEvent;
import com.gmail.nossr50.runnables.StickyPistonTrackerTask;
import com.gmail.nossr50.skills.excavation.ExcavationManager;
import com.gmail.nossr50.skills.herbalism.HerbalismManager;
import com.gmail.nossr50.skills.mining.MiningManager;
import com.gmail.nossr50.skills.repair.Repair;
import com.gmail.nossr50.skills.smelting.SmeltingManager;
import com.gmail.nossr50.skills.unarmed.UnarmedManager;
import com.gmail.nossr50.skills.woodcutting.WoodcuttingManager;
import com.gmail.nossr50.util.BlockUtils;
import com.gmail.nossr50.util.ItemUtils;
@@ -72,9 +70,11 @@ public class BlockListener implements Listener {
}
for (Block b : blocks) {
if (b.getRelative(direction).hasMetadata(mcMMO.blockMetadataKey)) {
mcMMO.getPlaceStore().setTrue(b.getRelative(direction));
b.getRelative(direction).removeMetadata(mcMMO.blockMetadataKey, plugin);
Block nextBlock = b.getRelative(direction);
if (nextBlock.hasMetadata(mcMMO.blockMetadataKey)) {
mcMMO.getPlaceStore().setTrue(nextBlock);
nextBlock.removeMetadata(mcMMO.blockMetadataKey, plugin);
}
}
}
@@ -106,15 +106,14 @@ public class BlockListener implements Listener {
}
BlockState blockState = event.getBlock().getState();
int blockId = blockState.getTypeId();
/* Check if the blocks placed should be monitored so they do not give out XP in the future */
if (BlockUtils.shouldBeWatched(blockState)) {
mcMMO.getPlaceStore().setTrue(blockState);
}
if (Repair.anvilMessagesEnabled && (blockId == Repair.repairAnvilId || blockId == Repair.salvageAnvilId)) {
UserManager.getPlayer(player).getRepairManager().placedAnvilCheck(blockId);
if (Repair.anvilMessagesEnabled && BlockUtils.isMcMMOAnvil(blockState)) {
UserManager.getPlayer(player).getRepairManager().placedAnvilCheck(blockState.getTypeId());
}
}
@@ -323,41 +322,31 @@ public class BlockListener implements Listener {
ItemStack heldItem = player.getItemInHand();
Block block = event.getBlock();
BlockState blockState = block.getState();
HerbalismManager herbalismManager = mcMMOPlayer.getHerbalismManager();
/*
* ABILITY TRIGGER CHECKS
*
* We don't need to check permissions here because they've already been checked for the ability to even activate.
*/
if (herbalismManager.canGreenTerraBlock(blockState)) {
if (herbalismManager.processGreenTerra(blockState)) {
if (mcMMOPlayer.getAbilityMode(AbilityType.GREEN_TERRA) && BlockUtils.canMakeMossy(blockState)) {
if (mcMMOPlayer.getHerbalismManager().processGreenTerra(blockState)) {
blockState.update(true);
}
}
else if (mcMMOPlayer.getAbilityMode(AbilityType.BERSERK)) {
else if (mcMMOPlayer.getAbilityMode(AbilityType.BERSERK) && heldItem.getType() == Material.AIR) {
if (SkillUtils.triggerCheck(player, block, AbilityType.BERSERK)) {
if (heldItem.getType() == Material.AIR) {
plugin.getServer().getPluginManager().callEvent(new FakePlayerAnimationEvent(player));
event.setInstaBreak(true);
player.playSound(block.getLocation(), Sound.ITEM_PICKUP, Misc.POP_VOLUME, Misc.getPopPitch());
}
event.setInstaBreak(true);
player.playSound(block.getLocation(), Sound.ITEM_PICKUP, Misc.POP_VOLUME, Misc.getPopPitch());
}
// Another perm check for the cracked blocks activation
else if (BlockUtils.affectedByBlockCracker(blockState)) {
UnarmedManager unarmedManager = mcMMOPlayer.getUnarmedManager();
if (unarmedManager.canUseBlockCracker() && SkillUtils.blockBreakSimulate(block, player, false) && unarmedManager.blockCrackerCheck(blockState)) {
else if (Permissions.blockCracker(player) && SkillUtils.triggerCheck(player, block, AbilityType.BLOCK_CRACKER)) {
if (mcMMOPlayer.getUnarmedManager().blockCrackerCheck(blockState)) {
blockState.update();
}
}
}
else if (BlockUtils.isLeaves(blockState)) {
if (mcMMOPlayer.getWoodcuttingManager().canUseLeafBlower(heldItem) && SkillUtils.blockBreakSimulate(block, player, true)) {
event.setInstaBreak(true);
player.playSound(blockState.getLocation(), Sound.ITEM_PICKUP, Misc.POP_VOLUME, Misc.getPopPitch());
}
else if (mcMMOPlayer.getWoodcuttingManager().canUseLeafBlower(heldItem) && SkillUtils.triggerCheck(player, block, AbilityType.LEAF_BLOWER)) {
event.setInstaBreak(true);
player.playSound(blockState.getLocation(), Sound.ITEM_PICKUP, Misc.POP_VOLUME, Misc.getPopPitch());
}
}
}

View File

@@ -180,10 +180,10 @@ public class PlayerListener implements Listener {
case FISHING:
if (!Permissions.krakenBypass(player)) {
event.setCancelled(fishingManager.exploitPrevention());
}
if (event.isCancelled()) {
return;
if (event.isCancelled()) {
return;
}
}
if (fishingManager.canMasterAngler()) {
@@ -209,7 +209,7 @@ public class PlayerListener implements Listener {
case IN_GROUND:
Fish hook = event.getHook();
Block block = hook.getLocation().getBlock();
Block block = event.getPlayer().getTargetBlock(null, 100);
if (fishingManager.canIceFish(block)) {
event.setCancelled(true);
@@ -355,7 +355,7 @@ public class PlayerListener implements Listener {
}
}
/* SALVAGE CHECKS */
else if (blockID == Repair.salvageAnvilId && Permissions.salvage(player) && Repair.isSalvageable(heldItem)) {
else if (blockID == Repair.salvageAnvilId && Permissions.salvage(player) && Repair.isSalvageable(heldItem) && !ItemUtils.isChainmailArmor(heldItem)) {
RepairManager repairManager = mcMMOPlayer.getRepairManager();
event.setCancelled(true);

View File

@@ -31,8 +31,8 @@ public class McrankCommandDisplayTask extends BukkitRunnable {
sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Heading"));
sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Player", playerName));
for (SkillType skill : SkillType.values()) {
if (skill.isChildSkill() || (player != null && !Permissions.skillEnabled(player, skill))) {
for (SkillType skill : SkillType.nonChildSkills()) {
if (player != null && !Permissions.skillEnabled(player, skill)) {
continue;
}

View File

@@ -28,8 +28,6 @@ public class ChimaeraWingWarmup extends BukkitRunnable {
private void checkChimaeraWingTeleport() {
Player player = mcMMOPlayer.getPlayer();
Location previousLocation = mcMMOPlayer.getTeleportCommenceLocation();
long recentlyHurt = mcMMOPlayer.getRecentlyHurt();
ItemStack inHand = player.getItemInHand();
mcMMOPlayer.setTeleportCommenceLocation(null);
@@ -38,16 +36,23 @@ public class ChimaeraWingWarmup extends BukkitRunnable {
return;
}
ItemStack inHand = player.getItemInHand();
if (!ItemUtils.isChimaeraWing(inHand) || inHand.getAmount() < Config.getInstance().getChimaeraUseCost()) {
player.sendMessage(LocaleLoader.getString("Skills.NeedMore", LocaleLoader.getString("Item.ChimaeraWing.Name")));
return;
}
int recentlyhurt_cooldown = Config.getInstance().getChimaeraRecentlyHurtCooldown();
long recentlyHurt = mcMMOPlayer.getRecentlyHurt();
int hurtCooldown = Config.getInstance().getChimaeraRecentlyHurtCooldown();
if (!SkillUtils.cooldownOver(recentlyHurt * Misc.TIME_CONVERSION_FACTOR, recentlyhurt_cooldown, player)) {
player.sendMessage(LocaleLoader.getString("Item.Injured.Wait", SkillUtils.calculateTimeLeft(recentlyHurt * Misc.TIME_CONVERSION_FACTOR, recentlyhurt_cooldown, player)));
return;
if (hurtCooldown > 0) {
int timeRemaining = SkillUtils.calculateTimeLeft(recentlyHurt * Misc.TIME_CONVERSION_FACTOR, hurtCooldown, player);
if (timeRemaining > 0) {
player.sendMessage(LocaleLoader.getString("Item.Injured.Wait", timeRemaining));
return;
}
}
ChimaeraWing.chimaeraExecuteTeleport();

View File

@@ -47,11 +47,15 @@ public class TeleportationWarmup extends BukkitRunnable {
return;
}
int recentlyhurt_cooldown = Config.getInstance().getPTPCommandRecentlyHurtCooldown();
int hurtCooldown = Config.getInstance().getPTPCommandRecentlyHurtCooldown();
if (!SkillUtils.cooldownOver(recentlyHurt * Misc.TIME_CONVERSION_FACTOR, recentlyhurt_cooldown, teleportingPlayer)) {
teleportingPlayer.sendMessage(LocaleLoader.getString("Item.Injured.Wait", SkillUtils.calculateTimeLeft(recentlyHurt * Misc.TIME_CONVERSION_FACTOR, recentlyhurt_cooldown, teleportingPlayer)));
return;
if (hurtCooldown > 0) {
int timeRemaining = SkillUtils.calculateTimeLeft(recentlyHurt * Misc.TIME_CONVERSION_FACTOR, hurtCooldown, teleportingPlayer);
if (timeRemaining > 0) {
teleportingPlayer.sendMessage(LocaleLoader.getString("Item.Injured.Wait", timeRemaining));
return;
}
}
PtpCommand.handlePartyTeleportEvent(teleportingPlayer, targetPlayer);

View File

@@ -11,6 +11,7 @@ import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.events.skills.abilities.McMMOPlayerAbilityDeactivateEvent;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.skills.ParticleEffectUtils;
import com.gmail.nossr50.util.skills.PerksUtils;
import com.gmail.nossr50.util.skills.SkillUtils;
public class AbilityDisableTask extends BukkitRunnable {
@@ -59,6 +60,6 @@ public class AbilityDisableTask extends BukkitRunnable {
}
SkillUtils.sendSkillMessage(player, ability.getAbilityPlayerOff(player));
new AbilityCooldownTask(mcMMOPlayer, ability).runTaskLaterAsynchronously(mcMMO.p, ability.getCooldown() * 20);
new AbilityCooldownTask(mcMMOPlayer, ability).runTaskLaterAsynchronously(mcMMO.p, PerksUtils.handleCooldownPerks(player, ability.getCooldown()) * 20);
}
}

View File

@@ -14,7 +14,6 @@ public final class Acrobatics {
public static int gracefulRollMaxBonusLevel = AdvancedConfig.getInstance().getGracefulRollMaxBonusLevel();
public static int gracefulRollThreshold = AdvancedConfig.getInstance().getGracefulRollDamageThreshold();
public static int gracefulRollSuccessModifier = AdvancedConfig.getInstance().getGracefulRollSuccessModifer();
public static double gracefulRollMaxChance = AdvancedConfig.getInstance().getGracefulRollChanceMax();
public static int dodgeXpModifier = AdvancedConfig.getInstance().getDodgeXPModifier();

View File

@@ -81,7 +81,7 @@ public class AcrobaticsManager extends SkillManager {
int modifiedDamage = Acrobatics.calculateModifiedRollDamage(damage, Acrobatics.rollThreshold);
if (!isFatal(modifiedDamage) && isSuccessfulRoll(Acrobatics.rollMaxChance, Acrobatics.rollMaxBonusLevel, 1)) {
if (!isFatal(modifiedDamage) && isSuccessfulRoll(Acrobatics.rollMaxChance, Acrobatics.rollMaxBonusLevel)) {
player.sendMessage(LocaleLoader.getString("Acrobatics.Roll.Text"));
applyXpGain(damage * Acrobatics.rollXpModifier);
@@ -103,7 +103,7 @@ public class AcrobaticsManager extends SkillManager {
private int gracefulRollCheck(int damage) {
int modifiedDamage = Acrobatics.calculateModifiedRollDamage(damage, Acrobatics.gracefulRollThreshold);
if (!isFatal(modifiedDamage) && isSuccessfulRoll(Acrobatics.gracefulRollMaxChance, Acrobatics.gracefulRollMaxBonusLevel, Acrobatics.gracefulRollSuccessModifier)) {
if (!isFatal(modifiedDamage) && isSuccessfulRoll(Acrobatics.gracefulRollMaxChance, Acrobatics.gracefulRollMaxBonusLevel)) {
getPlayer().sendMessage(LocaleLoader.getString("Acrobatics.Ability.Proc"));
applyXpGain(damage * Acrobatics.rollXpModifier);
@@ -116,8 +116,8 @@ public class AcrobaticsManager extends SkillManager {
return damage;
}
private boolean isSuccessfulRoll(double maxChance, int maxLevel, int successModifier) {
return ((maxChance / maxLevel) * Math.min(getSkillLevel(), maxLevel) * successModifier) > Misc.getRandom().nextInt(activationChance);
private boolean isSuccessfulRoll(double maxChance, int maxLevel) {
return (maxChance / maxLevel) * Math.min(getSkillLevel(), maxLevel) > Misc.getRandom().nextInt(activationChance);
}
private boolean isFatal(int damage) {

View File

@@ -19,44 +19,42 @@ public class ChildConfig extends AutoUpdateConfigLoader {
protected void loadKeys() {
config.setDefaults(YamlConfiguration.loadConfiguration(plugin.getResource("child.yml")));
for (SkillType skill : SkillType.values()) {
if (skill.isChildSkill()) {
plugin.debug("Finding parents of " + skill.name());
for (SkillType skill : SkillType.childSkills()) {
plugin.debug("Finding parents of " + skill.name());
List<String> parentNames = config.getStringList(StringUtils.getCapitalized(skill.name()));
EnumSet<SkillType> parentSkills = EnumSet.noneOf(SkillType.class);
boolean useDefaults = false; // If we had an error we back out and use defaults
List<String> parentNames = config.getStringList(StringUtils.getCapitalized(skill.name()));
EnumSet<SkillType> parentSkills = EnumSet.noneOf(SkillType.class);
boolean useDefaults = false; // If we had an error we back out and use defaults
for (String name : parentNames) {
try {
SkillType parentSkill = Enum.valueOf(SkillType.class, name.toUpperCase());
FamilyTree.enforceNotChildSkill(parentSkill);
parentSkills.add(parentSkill);
}
catch (IllegalArgumentException ex) {
plugin.getLogger().warning(name + " is not a valid skill type, or is a child skill!");
useDefaults = true;
break;
}
for (String name : parentNames) {
try {
SkillType parentSkill = SkillType.valueOf(name.toUpperCase());
FamilyTree.enforceNotChildSkill(parentSkill);
parentSkills.add(parentSkill);
}
if (useDefaults) {
parentSkills.clear();
for (String name : config.getDefaults().getStringList(StringUtils.getCapitalized(skill.name()))) {
/* We do less checks in here because it's from inside our jar.
* If they're dedicated enough to have modified it, they can have the errors it may produce.
* Alternatively, this can be used to allow child skills to be parent skills, provided there are no circular dependencies this is an advanced sort of configuration.
*/
parentSkills.add(SkillType.valueOf(name.toUpperCase()));
}
catch (IllegalArgumentException ex) {
plugin.getLogger().warning(name + " is not a valid skill type, or is a child skill!");
useDefaults = true;
break;
}
}
// Register them
for (SkillType parentSkill : parentSkills) {
plugin.debug("Registering " + parentSkill.name() + " as parent of " + skill.name());
FamilyTree.registerParent(skill, parentSkill);
if (useDefaults) {
parentSkills.clear();
for (String name : config.getDefaults().getStringList(StringUtils.getCapitalized(skill.name()))) {
/* We do less checks in here because it's from inside our jar.
* If they're dedicated enough to have modified it, they can have the errors it may produce.
* Alternatively, this can be used to allow child skills to be parent skills, provided there are no circular dependencies this is an advanced sort of configuration.
*/
parentSkills.add(SkillType.valueOf(name.toUpperCase()));
}
}
// Register them
for (SkillType parentSkill : parentSkills) {
plugin.debug("Registering " + parentSkill.name() + " as parent of " + skill.name());
FamilyTree.registerParent(skill, parentSkill);
}
}
FamilyTree.closeRegistration();

View File

@@ -2,7 +2,9 @@ package com.gmail.nossr50.skills.fishing;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.bukkit.ChatColor;
import org.bukkit.Location;
@@ -37,6 +39,9 @@ import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.datatypes.treasure.FishingTreasure;
import com.gmail.nossr50.datatypes.treasure.ShakeTreasure;
import com.gmail.nossr50.events.fake.FakePlayerFishEvent;
import com.gmail.nossr50.events.skills.fishing.McMMOPlayerFishingTreasureEvent;
import com.gmail.nossr50.events.skills.fishing.McMMOPlayerMagicHunterEvent;
import com.gmail.nossr50.events.skills.fishing.McMMOPlayerShakeEvent;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.runnables.skills.KrakenAttackTask;
import com.gmail.nossr50.skills.SkillManager;
@@ -138,12 +143,12 @@ public class FishingManager extends SkillManager {
}
public boolean exploitPrevention() {
if (!AdvancedConfig.getInstance().getKrakenEnabled()) {
if (!AdvancedConfig.getInstance().getKrakenEnabled() || !getPlayer().getTargetBlock(null, 100).isLiquid()) {
return false;
}
long currentTime = System.currentTimeMillis();
boolean hasFished = currentTime < fishingTimestamp + FISHING_COOLDOWN_SECONDS;
boolean hasFished = (currentTime < fishingTimestamp + FISHING_COOLDOWN_SECONDS);
fishingTries = hasFished ? fishingTries + 1 : Math.max(fishingTries - 1, 0);
fishingTimestamp = currentTime;
@@ -219,7 +224,7 @@ public class FishingManager extends SkillManager {
// Make a hole
block.setType(Material.STATIONARY_WATER);
for (int x = -1; x <= 1; x++) {
for (int x = -1; x <= 1; x++) {
for (int z = -1; z <= 1; z++) {
Block relative = block.getRelative(x, 0, z);
@@ -269,13 +274,43 @@ public class FishingManager extends SkillManager {
treasureXp = treasure.getXp();
ItemStack treasureDrop = treasure.getDrop().clone(); // Not cloning is bad, m'kay?
if (Permissions.magicHunter(player) && ItemUtils.isEnchantable(treasureDrop) && handleMagicHunter(treasureDrop)) {
player.sendMessage(LocaleLoader.getString("Fishing.MagicFound"));
McMMOPlayerFishingTreasureEvent event;
Map<Enchantment, Integer> enchants = new HashMap<Enchantment, Integer>();
if (Permissions.magicHunter(player) && ItemUtils.isEnchantable(treasureDrop)) {
enchants = handleMagicHunter(treasureDrop);
event = new McMMOPlayerMagicHunterEvent(player, treasureDrop, treasureXp, enchants);
}
else {
event = new McMMOPlayerFishingTreasureEvent(player, treasureDrop, treasureXp);
}
mcMMO.p.getServer().getPluginManager().callEvent(event);
treasureDrop = event.getTreasure();
treasureXp = event.getXp();
if (event.isCancelled()) {
treasureDrop = null;
treasureXp = 0;
}
// Drop the original catch at the feet of the player and set the treasure as the real catch
Misc.dropItem(player.getEyeLocation(), fishingCatch.getItemStack());
fishingCatch.setItemStack(treasureDrop);
if (treasureDrop != null) {
boolean enchanted = false;
if (!enchants.isEmpty()) {
treasureDrop.addUnsafeEnchantments(enchants);
enchanted = true;
}
if (enchanted) {
player.sendMessage(LocaleLoader.getString("Fishing.MagicFound"));
}
Misc.dropItem(player.getEyeLocation(), fishingCatch.getItemStack());
fishingCatch.setItemStack(treasureDrop);
}
}
applyXpGain(Config.getInstance().getFishingBaseXP() + treasureXp);
@@ -351,6 +386,14 @@ public class FishingManager extends SkillManager {
break;
}
McMMOPlayerShakeEvent event = new McMMOPlayerShakeEvent(getPlayer(), drop);
drop = event.getDrop();
if (event.isCancelled() || drop == null) {
return;
}
Misc.dropItem(target.getLocation(), drop);
CombatUtils.dealDamage(target, Math.max(target.getMaxHealth() / 4, 1)); // Make it so you can shake a mob no more than 4 times.
}
@@ -399,7 +442,7 @@ public class FishingManager extends SkillManager {
* @param treasureDrop The {@link ItemStack} to enchant
* @return true if the item has been enchanted
*/
private boolean handleMagicHunter(ItemStack treasureDrop) {
private Map<Enchantment, Integer> handleMagicHunter(ItemStack treasureDrop) {
Player player = getPlayer();
int activationChance = this.activationChance;
@@ -407,8 +450,10 @@ public class FishingManager extends SkillManager {
activationChance *= Fishing.STORM_MODIFIER;
}
Map<Enchantment, Integer> enchants = new HashMap<Enchantment, Integer>();
if (Misc.getRandom().nextInt(activationChance) > getLootTier() * AdvancedConfig.getInstance().getFishingMagicMultiplier()) {
return false;
return enchants;
}
List<Enchantment> possibleEnchantments = getPossibleEnchantments(treasureDrop);
@@ -416,7 +461,6 @@ public class FishingManager extends SkillManager {
// This make sure that the order isn't always the same, for example previously Unbreaking had a lot more chance to be used than any other enchant
Collections.shuffle(possibleEnchantments, Misc.getRandom());
boolean enchanted = false;
int specificChance = 1;
for (Enchantment possibleEnchantment : possibleEnchantments) {
@@ -424,13 +468,12 @@ public class FishingManager extends SkillManager {
continue;
}
treasureDrop.addEnchantment(possibleEnchantment, Math.max(Misc.getRandom().nextInt(possibleEnchantment.getMaxLevel()) + 1, possibleEnchantment.getStartLevel()));
enchants.put(possibleEnchantment, Math.max(Misc.getRandom().nextInt(possibleEnchantment.getMaxLevel()) + 1, possibleEnchantment.getStartLevel()));
specificChance++;
enchanted = true;
}
return enchanted;
return enchants;
}
private List<Enchantment> getPossibleEnchantments(ItemStack treasureDrop) {

View File

@@ -27,7 +27,7 @@ import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.skills.SkillUtils;
public class MiningManager extends SkillManager{
public class MiningManager extends SkillManager {
public MiningManager(McMMOPlayer mcMMOPlayer) {
super(mcMMOPlayer, SkillType.MINING);
}
@@ -109,7 +109,7 @@ public class MiningManager extends SkillManager{
getProfile().setSkillDATS(AbilityType.BLAST_MINING, System.currentTimeMillis());
mcMMOPlayer.setAbilityInformed(AbilityType.BLAST_MINING, false);
new AbilityCooldownTask(mcMMOPlayer, AbilityType.BLAST_MINING).runTaskLaterAsynchronously(mcMMO.p, AbilityType.BLAST_MINING.getCooldown());
new AbilityCooldownTask(mcMMOPlayer, AbilityType.BLAST_MINING).runTaskLaterAsynchronously(mcMMO.p, AbilityType.BLAST_MINING.getCooldown() * 20);
}
/**
@@ -287,9 +287,10 @@ public class MiningManager extends SkillManager{
long oldTime = profile.getSkillDATS(AbilityType.BLAST_MINING) * Misc.TIME_CONVERSION_FACTOR;
int cooldown = AbilityType.BLAST_MINING.getCooldown();
int timeRemaining = SkillUtils.calculateTimeLeft(oldTime, cooldown, player);
if (!SkillUtils.cooldownOver(oldTime, cooldown, player)) {
player.sendMessage(LocaleLoader.getString("Skills.TooTired", SkillUtils.calculateTimeLeft(oldTime, cooldown, player)));
if (timeRemaining > 0) {
player.sendMessage(LocaleLoader.getString("Skills.TooTired", timeRemaining));
return false;
}

View File

@@ -195,7 +195,7 @@ public class RepairManager extends SkillManager {
Player player = getPlayer();
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
long LastUse = mcMMOPlayer.getLastAnvilUse(anvilId);
long LastUse = mcMMOPlayer.getLastAnvilUse(anvilId);
// Don't use SkillUtils.cooldownOver() here since that also accounts for the cooldown perks
if ((((LastUse + 3) * Misc.TIME_CONVERSION_FACTOR) >= System.currentTimeMillis()) || !Config.getInstance().getRepairConfirmRequired()) {

View File

@@ -43,7 +43,7 @@ public class Unarmed {
ItemStack addStack = itemstack.clone();
if (dropAmount + itemAmount <= itemMax) {
if (dropAmount + itemAmount <= itemMax) {
drop.remove();
addStack.setAmount(dropAmount + itemAmount);
inventory.setItem(nextSlot, addStack);

View File

@@ -7,7 +7,7 @@ import org.bukkit.material.CocoaPlant;
import org.bukkit.material.CocoaPlant.CocoaPlantSize;
import org.bukkit.material.NetherWarts;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.skills.repair.Repair;
public final class BlockUtils {
private BlockUtils() {}
@@ -306,9 +306,9 @@ public final class BlockUtils {
* @param blockState The {@link BlockState} of the block to check
* @return true if the block is an mcMMO anvil, false otherwise
*/
private static boolean isMcMMOAnvil(BlockState blockState) {
public static boolean isMcMMOAnvil(BlockState blockState) {
int blockId = blockState.getTypeId();
return blockId == Config.getInstance().getRepairAnvilId() || blockId == Config.getInstance().getSalvageAnvilId();
return blockId == Repair.repairAnvilId || blockId == Repair.salvageAnvilId;
}
}

View File

@@ -35,9 +35,13 @@ public final class ChimaeraWing {
* @param player Player whose item usage to check
*/
public static void activationCheck(Player player) {
if (!Config.getInstance().getChimaeraEnabled()) {
return;
}
ItemStack inHand = player.getItemInHand();
if (!Config.getInstance().getChimaeraEnabled() || !ItemUtils.isChimaeraWing(inHand)) {
if (!ItemUtils.isChimaeraWing(inHand)) {
return;
}
@@ -48,36 +52,48 @@ public final class ChimaeraWing {
mcMMOPlayer = UserManager.getPlayer(player);
location = player.getLocation();
int amount = inHand.getAmount();
long recentlyHurt = mcMMOPlayer.getRecentlyHurt();
long lastTeleport = mcMMOPlayer.getLastTeleport();
if (mcMMOPlayer.getTeleportCommenceLocation() != null) {
return;
}
if (Config.getInstance().getChimaeraCooldown() > 0 && !SkillUtils.cooldownOver(lastTeleport * Misc.TIME_CONVERSION_FACTOR, Config.getInstance().getChimaeraCooldown(), player)) {
player.sendMessage(LocaleLoader.getString("Item.Generic.Wait", SkillUtils.calculateTimeLeft(lastTeleport * Misc.TIME_CONVERSION_FACTOR, Config.getInstance().getChimaeraCooldown(), player)));
return;
}
int recentlyhurt_cooldown = Config.getInstance().getChimaeraRecentlyHurtCooldown();
if (!SkillUtils.cooldownOver(recentlyHurt * Misc.TIME_CONVERSION_FACTOR, recentlyhurt_cooldown, player)) {
player.sendMessage(LocaleLoader.getString("Item.Injured.Wait", SkillUtils.calculateTimeLeft(recentlyHurt * Misc.TIME_CONVERSION_FACTOR, recentlyhurt_cooldown, player)));
return;
}
int amount = inHand.getAmount();
if (amount < Config.getInstance().getChimaeraUseCost()) {
player.sendMessage(LocaleLoader.getString("Skills.NeedMore", LocaleLoader.getString("Item.ChimaeraWing.Name")));
return;
}
long lastTeleport = mcMMOPlayer.getLastTeleport();
int cooldown = Config.getInstance().getChimaeraCooldown();
if (cooldown > 0 ) {
int timeRemaining = SkillUtils.calculateTimeLeft(lastTeleport * Misc.TIME_CONVERSION_FACTOR, cooldown, player);
if (timeRemaining > 0) {
player.sendMessage(LocaleLoader.getString("Item.Generic.Wait", timeRemaining));
return;
}
}
long recentlyHurt = mcMMOPlayer.getRecentlyHurt();
int hurtCooldown = Config.getInstance().getChimaeraRecentlyHurtCooldown();
if (hurtCooldown > 0) {
int timeRemaining = SkillUtils.calculateTimeLeft(recentlyHurt * Misc.TIME_CONVERSION_FACTOR, hurtCooldown, player);
if (timeRemaining > 0) {
player.sendMessage(LocaleLoader.getString("Item.Injured.Wait", timeRemaining));
return;
}
}
location = player.getLocation();
if (Config.getInstance().getChimaeraPreventUseUnderground()) {
if (location.getY() < player.getWorld().getHighestBlockYAt(location)) {
player.setItemInHand(new ItemStack(getChimaeraWing(amount - Config.getInstance().getChimaeraUseCost())));
player.sendMessage(LocaleLoader.getString("Item.ChimaeraWing.Fail"));
player.updateInventory();
player.setVelocity(new Vector(0, 0.5D, 0));
CombatUtils.dealDamage(player, Misc.getRandom().nextInt(player.getHealth() - 10));
mcMMOPlayer.actualizeLastTeleport();
@@ -115,6 +131,7 @@ public final class ChimaeraWing {
}
player.setItemInHand(new ItemStack(getChimaeraWing(player.getItemInHand().getAmount() - Config.getInstance().getChimaeraUseCost())));
player.updateInventory();
UserManager.getPlayer(player).actualizeLastTeleport();
if (Config.getInstance().getStatsTrackingEnabled()) {
MetricsManager.chimeraWingUsed();

View File

@@ -21,11 +21,7 @@ public final class HardcoreManager {
PlayerProfile playerProfile = UserManager.getPlayer(player).getProfile();
int totalLost = 0;
for (SkillType skillType : SkillType.values()) {
if (skillType.isChildSkill()) {
continue;
}
for (SkillType skillType : SkillType.nonChildSkills()) {
int playerSkillLevel = playerProfile.getSkillLevel(skillType);
if (playerSkillLevel <= 0) {
@@ -52,11 +48,7 @@ public final class HardcoreManager {
PlayerProfile victimProfile = UserManager.getPlayer(victim).getProfile();
int totalStolen = 0;
for (SkillType skillType : SkillType.values()) {
if (skillType.isChildSkill()) {
continue;
}
for (SkillType skillType : SkillType.nonChildSkills()) {
int killerSkillLevel = killerProfile.getSkillLevel(skillType);
int victimSkillLevel = victimProfile.getSkillLevel(skillType);

View File

@@ -660,6 +660,6 @@ public class ItemUtils {
}
ItemMeta itemMeta = item.getItemMeta();
return itemMeta.hasDisplayName() && itemMeta.getDisplayName().equals(ChatColor.GOLD + LocaleLoader.getString("Item.ChimaeraWing.Name"));
return itemMeta.hasDisplayName() && itemMeta.getDisplayName().equals(ChatColor.GOLD + LocaleLoader.getString("Item.ChimaeraWing.Name"));
}
}

View File

@@ -95,7 +95,7 @@ public final class Misc {
return false;
}
return first.distanceSquared(second) < (maxDistance * maxDistance);
return first.distanceSquared(second) < (maxDistance * maxDistance) || maxDistance == 0;
}
public static void dropItems(Location location, Collection<ItemStack> drops) {

View File

@@ -35,9 +35,9 @@ public final class MobHealthbarUtils {
/**
* Handle the creation of mob healthbars.
*
* @param profile The
* @param target
* @param damage
* @param player the attacking player
* @param target the targetted entity
* @param damage damage done by the attack triggering this
*/
public static void handleMobHealthbars(Player player, LivingEntity target, int damage) {
if (!Permissions.mobHealthDisplay(player)) {
@@ -132,7 +132,7 @@ public final class MobHealthbarUtils {
return null;
}
int coloredDisplay = (int) (fullDisplay * (healthPercentage / 100.0D));
int coloredDisplay = (int) Math.ceil(fullDisplay * (healthPercentage / 100.0D));
int grayDisplay = fullDisplay - coloredDisplay;
String healthbar = color + "";

View File

@@ -5,6 +5,7 @@ import java.util.List;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.player.PlayerProfile;
import com.gmail.nossr50.datatypes.skills.SkillType;
@@ -46,7 +47,7 @@ public final class CommandUtils {
}
public static boolean tooFar(CommandSender sender, Player target, boolean hasPermission) {
if (sender instanceof Player && !Misc.isNear(((Player) sender).getLocation(), target.getLocation(), 5.0) && !hasPermission) {
if (sender instanceof Player && !Misc.isNear(((Player) sender).getLocation(), target.getLocation(), Config.getInstance().getInspectDistance()) && !hasPermission) {
sender.sendMessage(LocaleLoader.getString("Inspect.TooFar"));
return true;
}

View File

@@ -182,8 +182,8 @@ public class ScoreboardManager {
PlayerProfile profile = mcMMOPlayer.getProfile();
Server server = mcMMO.p.getServer();
for (SkillType skill : SkillType.values()) {
if (skill.isChildSkill() || !Permissions.skillEnabled(player, skill)) {
for (SkillType skill : SkillType.nonChildSkills()) {
if (!Permissions.skillEnabled(player, skill)) {
continue;
}
@@ -201,8 +201,8 @@ public class ScoreboardManager {
Map<String, Integer> skills = Config.getInstance().getUseMySQL() ? SQLDatabaseManager.readSQLRank(playerName) : FlatfileDatabaseManager.getPlayerRanks(playerName);
for (SkillType skill : SkillType.values()) {
if (skill.isChildSkill() || !Permissions.skillEnabled(player, skill)) {
for (SkillType skill : SkillType.nonChildSkills()) {
if (!Permissions.skillEnabled(player, skill)) {
continue;
}
@@ -228,11 +228,7 @@ public class ScoreboardManager {
Map<String, Integer> skills = Config.getInstance().getUseMySQL() ? SQLDatabaseManager.readSQLRank(targetName) : FlatfileDatabaseManager.getPlayerRanks(targetName);
for (SkillType skill : SkillType.values()) {
if (skill.isChildSkill()) {
continue;
}
for (SkillType skill : SkillType.nonChildSkills()) {
rank = skills.get(skill.name());
if (rank != null) {
@@ -257,8 +253,8 @@ public class ScoreboardManager {
int powerLevel = 0;
int skillLevel;
for (SkillType skill : SkillType.values()) {
if (skill.isChildSkill() || !Permissions.skillEnabled(target, skill)) {
for (SkillType skill : SkillType.nonChildSkills()) {
if (!Permissions.skillEnabled(target, skill)) {
continue;
}
@@ -277,11 +273,7 @@ public class ScoreboardManager {
int powerLevel = 0;
int skillLevel;
for (SkillType skill : SkillType.values()) {
if (skill.isChildSkill()) {
continue;
}
for (SkillType skill : SkillType.nonChildSkills()) {
skillLevel = targetProfile.getSkillLevel(skill);
objective.getScore(server.getOfflinePlayer(SkillUtils.getSkillName(skill))).setScore(skillLevel);
powerLevel += skillLevel;

View File

@@ -55,25 +55,6 @@ public class SkillUtils {
return currentFoodLevel + foodChange;
}
/**
* Checks to see if the cooldown for an item or ability is expired.
*
* @param oldTime The time the ability or item was last used
* @param cooldown The amount of time that must pass between uses
* @param player The player whose cooldown is being checked
* @return true if the cooldown is over, false otherwise
*/
public static boolean cooldownOver(long oldTime, int cooldown, Player player) {
long currentTime = System.currentTimeMillis();
int adjustedCooldown = PerksUtils.handleCooldownPerks(player, cooldown);
if (currentTime - oldTime >= (adjustedCooldown * Misc.TIME_CONVERSION_FACTOR)) {
return true;
}
return false;
}
/**
* Calculate the time remaining until the cooldown expires.
*
@@ -96,15 +77,14 @@ public class SkillUtils {
return;
}
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
AbilityType ability = skill.getAbility();
ToolType tool = skill.getTool();
ItemStack inHand = player.getItemInHand();
if (ModUtils.isCustomTool(inHand) && !ModUtils.getToolFromItemStack(inHand).isAbilityEnabled()) {
return;
}
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
if (!mcMMOPlayer.getAbilityUse()) {
return;
}
@@ -116,6 +96,8 @@ public class SkillUtils {
}
PlayerProfile playerProfile = mcMMOPlayer.getProfile();
AbilityType ability = skill.getAbility();
ToolType tool = skill.getTool();
/*
* Woodcutting & Axes need to be treated differently.
@@ -123,8 +105,10 @@ public class SkillUtils {
*/
if (ability.getPermissions(player) && tool.inHand(inHand) && !mcMMOPlayer.getToolPreparationMode(tool)) {
if (skill != SkillType.WOODCUTTING && skill != SkillType.AXES) {
if (!mcMMOPlayer.getAbilityMode(ability) && !cooldownOver(playerProfile.getSkillDATS(ability) * Misc.TIME_CONVERSION_FACTOR, ability.getCooldown(), player)) {
player.sendMessage(LocaleLoader.getString("Skills.TooTired", calculateTimeLeft(playerProfile.getSkillDATS(ability) * Misc.TIME_CONVERSION_FACTOR, ability.getCooldown(), player)));
int timeRemaining = calculateTimeLeft(playerProfile.getSkillDATS(ability) * Misc.TIME_CONVERSION_FACTOR, ability.getCooldown(), player);
if (!mcMMOPlayer.getAbilityMode(ability) && timeRemaining > 0) {
player.sendMessage(LocaleLoader.getString("Skills.TooTired", timeRemaining));
return;
}
}
@@ -202,11 +186,7 @@ public class SkillUtils {
return isLocalizedSkill(skillName);
}
if (SkillType.getSkill(skillName) != null) {
return true;
}
return false;
return SkillType.getSkill(skillName) != null;
}
private static boolean isLocalizedSkill(String skillName) {
@@ -234,15 +214,11 @@ public class SkillUtils {
* @return true if the player has combat skills, false otherwise
*/
public static boolean hasCombatSkills(Player player) {
if (Permissions.skillEnabled(player, SkillType.AXES)
return Permissions.skillEnabled(player, SkillType.AXES)
|| Permissions.skillEnabled(player, SkillType.ARCHERY)
|| Permissions.skillEnabled(player, SkillType.SWORDS)
|| Permissions.skillEnabled(player, SkillType.TAMING)
|| Permissions.skillEnabled(player, SkillType.UNARMED)) {
return true;
}
return false;
|| Permissions.skillEnabled(player, SkillType.UNARMED);
}
/**
@@ -252,15 +228,11 @@ public class SkillUtils {
* @return true if the player has gathering skills, false otherwise
*/
public static boolean hasGatheringSkills(Player player) {
if (Permissions.skillEnabled(player, SkillType.EXCAVATION)
return Permissions.skillEnabled(player, SkillType.EXCAVATION)
|| Permissions.skillEnabled(player, SkillType.FISHING)
|| Permissions.skillEnabled(player, SkillType.HERBALISM)
|| Permissions.skillEnabled(player, SkillType.MINING)
|| Permissions.skillEnabled(player, SkillType.WOODCUTTING)) {
return true;
}
return false;
|| Permissions.skillEnabled(player, SkillType.WOODCUTTING);
}
/**
@@ -270,13 +242,9 @@ public class SkillUtils {
* @return true if the player has misc skills, false otherwise
*/
public static boolean hasMiscSkills(Player player) {
if (Permissions.skillEnabled(player, SkillType.ACROBATICS)
return Permissions.skillEnabled(player, SkillType.ACROBATICS)
|| Permissions.skillEnabled(player, SkillType.SMELTING)
|| Permissions.skillEnabled(player, SkillType.REPAIR)) {
return true;
}
return false;
|| Permissions.skillEnabled(player, SkillType.REPAIR);
}
/**
@@ -294,18 +262,20 @@ public class SkillUtils {
Player player = mcMMOPlayer.getPlayer();
PlayerProfile playerProfile = mcMMOPlayer.getProfile();
int timeRemaining = calculateTimeLeft(playerProfile.getSkillDATS(ability) * Misc.TIME_CONVERSION_FACTOR, ability.getCooldown(), player);
/*
* Axes and Woodcutting are odd because they share the same tool.
* We show them the too tired message when they take action.
*/
if (type == SkillType.WOODCUTTING || type == SkillType.AXES) {
if (!mcMMOPlayer.getAbilityMode(ability) && !cooldownOver(playerProfile.getSkillDATS(ability) * Misc.TIME_CONVERSION_FACTOR, ability.getCooldown(), player)) {
player.sendMessage(LocaleLoader.getString("Skills.TooTired", calculateTimeLeft(playerProfile.getSkillDATS(ability) * Misc.TIME_CONVERSION_FACTOR, ability.getCooldown(), player)));
if (!mcMMOPlayer.getAbilityMode(ability) && timeRemaining > 0) {
player.sendMessage(LocaleLoader.getString("Skills.TooTired", timeRemaining));
return;
}
}
if (!mcMMOPlayer.getAbilityMode(ability) && cooldownOver(playerProfile.getSkillDATS(ability), ability.getCooldown(), player)) {
if (!mcMMOPlayer.getAbilityMode(ability) && timeRemaining <= 0) {
McMMOPlayerAbilityActivateEvent event = new McMMOPlayerAbilityActivateEvent(player, type);
mcMMO.p.getServer().getPluginManager().callEvent(event);
@@ -347,6 +317,7 @@ public class SkillUtils {
switch (ability) {
case BERSERK:
case BLOCK_CRACKER:
case LEAF_BLOWER:
if (!ability.blockCheck(block.getState())) {
activate = false;
@@ -505,11 +476,7 @@ public class SkillUtils {
FakeBlockBreakEvent breakEvent = new FakeBlockBreakEvent(block, player);
pluginManger.callEvent(breakEvent);
if (!damageEvent.isCancelled() && !breakEvent.isCancelled()) {
return true;
}
return false;
return !damageEvent.isCancelled() && !breakEvent.isCancelled();
}
public static boolean activationSuccessful(Player player, SkillType skill, double maxChance, int maxLevel) {

View File

@@ -204,11 +204,7 @@ public class SpoutUtils {
}
// Standard XP Icons
for (SkillType skillType : SkillType.values()) {
if (skillType.isChildSkill()) {
continue;
}
for (SkillType skillType : SkillType.nonChildSkills()) {
String skillName = StringUtils.getCapitalized(skillType.toString());
files.add(writeFile(skillName + ".png", hudStandardDirectory));

View File

@@ -43,7 +43,6 @@ Skills:
GracefulRoll_ChanceMax: 100.0
GracefulRoll_MaxBonusLevel: 500
GracefulRoll_DamageThreshold: 14
GracefulRoll_SuccessModifier: 2
# Amount of experience for performing a dodge, roll or fall
Dodge_XP_Modifier: 120

View File

@@ -56,9 +56,9 @@ Scoreboards:
Skillname:
Use: true
Display_Time: 10
# Should mcMMO display power levels on scoreboards?
# Should mcMMO display power levels on scoreboards? (below player name-tags)
Power_Level:
Use: true
Use: false
Mob_Healthbar:
# Default display for mob health bars - HEARTS, BAR, or DISABLED
@@ -394,6 +394,8 @@ Experience:
Commands:
mcmmo:
Donate_Message: true
inspect:
Max_Distance: 30
ptp:
Cooldown: 120
Warmup: 5

View File

@@ -497,7 +497,7 @@ Commands.Reset.Single=[[GREEN]]Your {0} skill level has been reset successfully.
Commands.Reset=[[RED]]Reset a skill's level to 0
Commands.Skill.Invalid=[[RED]]That is not a valid skillname!
Commands.Skill.Leaderboard=[[YELLOW]]--mcMMO [[BLUE]]{0}[[YELLOW]] Leaderboard--
Commands.SkillInfo=/<skill> [[RED]]- View detailed information about a skill
Commands.SkillInfo=[[RED]]- View detailed information about a skill
Commands.Stats.Self=YOUR STATS
Commands.Stats=[[RED]]- View your mcMMO stats
Commands.ToggleAbility=[[RED]]- Toggle ability activation with right click
@@ -659,7 +659,7 @@ Skills.Parents = PARENTS
Skills.Stats=[[YELLOW]]{0}[[GREEN]]{1}[[DARK_AQUA]] XP([[GRAY]]{2}[[DARK_AQUA]]/[[GRAY]]{3}[[DARK_AQUA]])
Skills.TooTired=[[RED]]You are too tired to use that ability again. [[YELLOW]]({0}s)
Skills.Cancelled=[[RED]]{0} cancelled!
Skills.ConfirmOrCancel=[[GREEN]]Right-click again to confirm [[GOLD]]{0} [[GREEN]]. Left-click to cancel.
Skills.ConfirmOrCancel=[[GREEN]]Right-click again to confirm [[GOLD]]{0}[[GREEN]]. Left-click to cancel.
#STATISTICS
Stats.Header.Combat=[[GOLD]]-=COMBAT SKILLS=-