mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-29 08:36:45 +01:00
commit
1c9d852b83
4
.gitattributes
vendored
Normal file
4
.gitattributes
vendored
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
* text
|
||||||
|
|
||||||
|
*.png binary
|
||||||
|
*.wav binary
|
@ -7,7 +7,32 @@ Key:
|
|||||||
! Change
|
! Change
|
||||||
- Removal
|
- Removal
|
||||||
|
|
||||||
Version 1.4.00-dev
|
Version 1.4.03-dev
|
||||||
|
= Fixed bug where players were unable to salvage leather armor
|
||||||
|
|
||||||
|
Version 1.4.02
|
||||||
|
+ Added API to get the skill and power level caps.
|
||||||
|
= Fixed bug where Deflect was calculated based on the attacker, not the defender
|
||||||
|
= Fixed bug where some skills weren't registering as unlocked until one level later
|
||||||
|
= Fixed bug where the PTP cooldown was being read improperly
|
||||||
|
= Fixed bug where /ptp <accept|toggle|acceptall> where broken
|
||||||
|
= Fixed ClassCastException relating to counter-attack with Swords
|
||||||
|
= Fixed issue with some skill activations not activating enough or activating too much
|
||||||
|
|
||||||
|
Version 1.4.01
|
||||||
|
= Fixed bug where trying to use /mctop or /xplock with the Smelting child skill caused NPEs
|
||||||
|
= Fixed bug where /mctop and /mcrank wouldn't show overall power levels for servers using Flatfile
|
||||||
|
= Fixed bug where Smelting would throw consistent errors due to offline players
|
||||||
|
= Fixed bug where repairing an mcMMO ability-buffed item with mcMMO repair could take the enchant but leave the lore tag
|
||||||
|
= Fixed bug where using '/party chat message...' would result in the first word of the message being printed repeatedly
|
||||||
|
= Fixed bug where the wrong flag was being set when taking damage
|
||||||
|
= Fixed bug where the PTP cooldown was set improperly
|
||||||
|
= Fixed bug where ptp permissions weren't being handled properly
|
||||||
|
= Fixed bug where Beast Lore wouldn't work
|
||||||
|
= Fixed bug where Chimaera Wing would always teleport to spawn, even when the player had a valid bed spawn location
|
||||||
|
= Updated locale files
|
||||||
|
|
||||||
|
Version 1.4.00
|
||||||
+ Added new Child Skill - Smelting!
|
+ Added new Child Skill - Smelting!
|
||||||
+ Added a version check, admins will get notified when a new version is available!
|
+ Added a version check, admins will get notified when a new version is available!
|
||||||
+ Added new cancellable McMMOPlayerDisarmEvent for Citizens compatibility - fires whenever a player is disarmed.
|
+ Added new cancellable McMMOPlayerDisarmEvent for Citizens compatibility - fires whenever a player is disarmed.
|
||||||
@ -36,6 +61,14 @@ Version 1.4.00-dev
|
|||||||
+ Added config option to disable automatic zip backups.
|
+ Added config option to disable automatic zip backups.
|
||||||
+ Added particle effects for many abilities.
|
+ Added particle effects for many abilities.
|
||||||
+ Added '/mcnotify' command to toggle ability notifications on/off
|
+ Added '/mcnotify' command to toggle ability notifications on/off
|
||||||
|
+ Added ability for config files to automatically update with new keys, and prune out old ones
|
||||||
|
+ Added config option to make .new config files instead over writing over old ones when updating
|
||||||
|
+ Added "Holy Hound" ability to Taming
|
||||||
|
+ Added "Shroom Thumb" ability to Herbalism
|
||||||
|
+ Added child.yml config file to choose parents for child skills
|
||||||
|
+ Added '/party itemshare <NONE | EQUAL | RANDOM>' command to choose party item share mode
|
||||||
|
+ Added '/party itemshare <loot | mining | herbalism | woodcutting> <true | false>' command to control items that are shared
|
||||||
|
+ Added itemweights.yml file to determine which items are more valuable for party itemshare
|
||||||
= Fixed Green Thumb on wheat not working properly at rank 4
|
= Fixed Green Thumb on wheat not working properly at rank 4
|
||||||
= Fixed Green Thumb and Green Terra consuming twice the amount of seed needed
|
= Fixed Green Thumb and Green Terra consuming twice the amount of seed needed
|
||||||
= Fixed Green Terra not also checking Green Thumb permissions
|
= Fixed Green Terra not also checking Green Thumb permissions
|
||||||
@ -70,6 +103,8 @@ Version 1.4.00-dev
|
|||||||
= Fixed a bug where a new party leader wasn't appointed, after the previous party leader left
|
= Fixed a bug where a new party leader wasn't appointed, after the previous party leader left
|
||||||
= Fixed a bug where Disarm and Deflect had wrong values
|
= Fixed a bug where Disarm and Deflect had wrong values
|
||||||
= Fixed Magic Hunter (Fishing ability) favoring certain enchants
|
= Fixed Magic Hunter (Fishing ability) favoring certain enchants
|
||||||
|
! Changed our custom chat events to be async
|
||||||
|
! Changed some config value key names regarding double drops and XP - make sure you copy any custom values to your new config after updating.
|
||||||
! Changed Green Terra blocks to be determined via permissions instead of the config file
|
! Changed Green Terra blocks to be determined via permissions instead of the config file
|
||||||
! Config files are now backed up even when running in SQL mode
|
! Config files are now backed up even when running in SQL mode
|
||||||
! Changed /p and /a to use /partychat and /adminchat as the default command name. The use of /p, /pc, /a, and /ac is still supported.
|
! Changed /p and /a to use /partychat and /adminchat as the default command name. The use of /p, /pc, /a, and /ac is still supported.
|
||||||
|
@ -1,28 +0,0 @@
|
|||||||
== mcMMO
|
|
||||||
**The RPG lovers mod**
|
|
||||||
|
|
||||||
=== Dev builds
|
|
||||||
http://ci.mcmmo.info Download the latest dev build of mcMMO here.
|
|
||||||
|
|
||||||
=== Brief Description
|
|
||||||
mcMMO takes core Minecraft game mechanics and expands them to add an extensive RPG experience, the goal of the project has always been a quality RPG experience. Everything in mcMMO is carefully thought out and is constantly improving. mcMMO adds eleven skills to train in and level in, while also offering a high level of customization for server admins. There are countless features, including custom sounds, graphical elements, and more added when running mcMMO in conjunction with Spout. I carefully read feedback and evaluate the mechanics of mcMMO in every update to provide an ever-evolving experience.
|
|
||||||
|
|
||||||
If you want an original RPG experience like no other mod out there, mcMMO is for you.
|
|
||||||
|
|
||||||
=== About the Developer
|
|
||||||
I've always wanted to make games and in the last year I decided to take a swing at developing Minecraft mods as a platform to teach myself programming, the biggest project I have made to date is mcMMO. I went from knowing nothing about Java to what I know now purely from modding Minecraft, and I plan to move onto game development in the not so distant future.
|
|
||||||
|
|
||||||
I take design very seriously, I am not the kind of person who can be satisfied giving a project anything less than my all. As you will see reflected in the quality of the mods I make, I take great care in my work.
|
|
||||||
|
|
||||||
Hearing that people enjoy mcMMO and seeing the daily youtube videos about my mod has become a joy, I really can't believe how popular my mod has gotten!
|
|
||||||
|
|
||||||
=== Compiling
|
|
||||||
|
|
||||||
Required Libraries:
|
|
||||||
* Spout API
|
|
||||||
* JUnit
|
|
||||||
|
|
||||||
Required to Run:
|
|
||||||
* Bukkit
|
|
||||||
|
|
||||||
http://dev.bukkit.org/server-mods/mcmmo for more up to date information.
|
|
47
README.md
Normal file
47
README.md
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
# mcMMO
|
||||||
|
## The RPG lovers mod
|
||||||
|
|
||||||
|
### Dev builds
|
||||||
|
Our latest development builds are available [here](http://ci.mcmmo.info).
|
||||||
|
|
||||||
|
### Brief Description
|
||||||
|
mcMMO takes core Minecraft game mechanics and expands them to add an extensive RPG experience, the goal of the project has always been a quality RPG experience. Everything in mcMMO is carefully thought out and is constantly improving. mcMMO adds eleven skills to train in and level in, while also offering a high level of customization for server admins. There are countless features, including custom sounds, graphical elements, and more added when running mcMMO in conjunction with Spout. I carefully read feedback and evaluate the mechanics of mcMMO in every update to provide an ever-evolving experience.
|
||||||
|
|
||||||
|
If you want an original RPG experience like no other mod out there, mcMMO is for you.
|
||||||
|
|
||||||
|
## About the Team
|
||||||
|
|
||||||
|
mcMMO is currently developed by a team of individuals from all over the world.
|
||||||
|
### Glorious Leader
|
||||||
|
[![gmcferrin](http://www.gravatar.com/avatar/b64c52daf25d206b27650788b5813b7b.png)]
|
||||||
|
(https://github.com/gmcferrin)
|
||||||
|
|
||||||
|
### Developers
|
||||||
|
[![bm01](http://www.gravatar.com/avatar/ec8146f5358177f12e9a252271bbc391.png)]
|
||||||
|
(https://github.com/bm01)
|
||||||
|
[![Glitchfinder](http://www.gravatar.com/avatar/5aa4cce22f72ae9c002ecec30f061d00.png)]
|
||||||
|
(https://github.com/Glitchfinder)
|
||||||
|
[![nossr50](http://www.gravatar.com/avatar/f2ee41eedfd645fb4a3a2c8f6cb1b18c.png)]
|
||||||
|
(https://github.com/nossr50)
|
||||||
|
[![NuclearW](http://www.gravatar.com/avatar/90926bdcf1c8a75918df5ea5fa801ce6.png)]
|
||||||
|
(https://github.com/NuclearW)
|
||||||
|
[![shatteredbeam](http://www.gravatar.com/avatar/cad3b5d7d39cf5387afb87f494389610.png)]
|
||||||
|
(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)]
|
||||||
|
(https://github.com/t00thpick1)
|
||||||
|
|
||||||
|
## Compiling
|
||||||
|
|
||||||
|
mcMMO uses Maven 3 to manage dependancies, packaging, and shading of necessary classes; Maven 3 is required to compile mcMMO.
|
||||||
|
|
||||||
|
The typical command used to build mcMMO is: mvn clean package install
|
||||||
|
|
||||||
|
Required Libraries:
|
||||||
|
* Spout API
|
||||||
|
* JUnit
|
||||||
|
* Metrics
|
||||||
|
* Bukkit
|
||||||
|
|
||||||
|
http://dev.bukkit.org/server-mods/mcmmo for more up to date information.
|
19
pom.xml
19
pom.xml
@ -2,7 +2,7 @@
|
|||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>com.gmail.nossr50.mcMMO</groupId>
|
<groupId>com.gmail.nossr50.mcMMO</groupId>
|
||||||
<artifactId>mcMMO</artifactId>
|
<artifactId>mcMMO</artifactId>
|
||||||
<version>1.4.00-dev4</version>
|
<version>1.4.03-dev1</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>
|
||||||
@ -105,7 +105,7 @@
|
|||||||
<relocations>
|
<relocations>
|
||||||
<relocation>
|
<relocation>
|
||||||
<pattern>com.turt2live.metrics</pattern>
|
<pattern>com.turt2live.metrics</pattern>
|
||||||
<shadedPattern>com.gmail.nossr50.util.mcstats</shadedPattern>
|
<shadedPattern>com.gmail.nossr50.metrics.mcstats</shadedPattern>
|
||||||
</relocation>
|
</relocation>
|
||||||
</relocations>
|
</relocations>
|
||||||
</configuration>
|
</configuration>
|
||||||
@ -129,29 +129,14 @@
|
|||||||
</build>
|
</build>
|
||||||
<repositories>
|
<repositories>
|
||||||
<repository>
|
<repository>
|
||||||
<snapshots>
|
|
||||||
<enabled>true</enabled>
|
|
||||||
<updatePolicy>always</updatePolicy>
|
|
||||||
<checksumPolicy>fail</checksumPolicy>
|
|
||||||
</snapshots>
|
|
||||||
<id>bukkit-repo</id>
|
<id>bukkit-repo</id>
|
||||||
<url>http://repo.bukkit.org/content/groups/public/</url>
|
<url>http://repo.bukkit.org/content/groups/public/</url>
|
||||||
</repository>
|
</repository>
|
||||||
<repository>
|
<repository>
|
||||||
<snapshots>
|
|
||||||
<enabled>true</enabled>
|
|
||||||
<updatePolicy>always</updatePolicy>
|
|
||||||
<checksumPolicy>fail</checksumPolicy>
|
|
||||||
</snapshots>
|
|
||||||
<id>spout-repo</id>
|
<id>spout-repo</id>
|
||||||
<url>http://nexus.spout.org/content/groups/public/</url>
|
<url>http://nexus.spout.org/content/groups/public/</url>
|
||||||
</repository>
|
</repository>
|
||||||
<repository>
|
<repository>
|
||||||
<snapshots>
|
|
||||||
<enabled>true</enabled>
|
|
||||||
<updatePolicy>always</updatePolicy>
|
|
||||||
<checksumPolicy>fail</checksumPolicy>
|
|
||||||
</snapshots>
|
|
||||||
<id>Plugin MetricsExtension</id>
|
<id>Plugin MetricsExtension</id>
|
||||||
<url>http://repo.turt2live.com</url>
|
<url>http://repo.turt2live.com</url>
|
||||||
</repository>
|
</repository>
|
||||||
|
@ -2,46 +2,46 @@ package com.gmail.nossr50.api;
|
|||||||
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||||
import com.gmail.nossr50.skills.utilities.AbilityType;
|
import com.gmail.nossr50.datatypes.skills.AbilityType;
|
||||||
import com.gmail.nossr50.util.Users;
|
import com.gmail.nossr50.util.player.UserManager;
|
||||||
|
|
||||||
public final class AbilityAPI {
|
public final class AbilityAPI {
|
||||||
private AbilityAPI() {}
|
private AbilityAPI() {}
|
||||||
|
|
||||||
public static boolean berserkEnabled(Player player) {
|
public static boolean berserkEnabled(Player player) {
|
||||||
return Users.getPlayer(player).getProfile().getAbilityMode(AbilityType.BERSERK);
|
return UserManager.getPlayer(player).getAbilityMode(AbilityType.BERSERK);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean gigaDrillBreakerEnabled(Player player) {
|
public static boolean gigaDrillBreakerEnabled(Player player) {
|
||||||
return Users.getPlayer(player).getProfile().getAbilityMode(AbilityType.GIGA_DRILL_BREAKER);
|
return UserManager.getPlayer(player).getAbilityMode(AbilityType.GIGA_DRILL_BREAKER);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean greenTerraEnabled(Player player) {
|
public static boolean greenTerraEnabled(Player player) {
|
||||||
return Users.getPlayer(player).getProfile().getAbilityMode(AbilityType.GREEN_TERRA);
|
return UserManager.getPlayer(player).getAbilityMode(AbilityType.GREEN_TERRA);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean serratedStrikesEnabled(Player player) {
|
public static boolean serratedStrikesEnabled(Player player) {
|
||||||
return Users.getPlayer(player).getProfile().getAbilityMode(AbilityType.SERRATED_STRIKES);
|
return UserManager.getPlayer(player).getAbilityMode(AbilityType.SERRATED_STRIKES);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean skullSplitterEnabled(Player player) {
|
public static boolean skullSplitterEnabled(Player player) {
|
||||||
return Users.getPlayer(player).getProfile().getAbilityMode(AbilityType.SKULL_SPLITTER);
|
return UserManager.getPlayer(player).getAbilityMode(AbilityType.SKULL_SPLITTER);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean superBreakerEnabled(Player player) {
|
public static boolean superBreakerEnabled(Player player) {
|
||||||
return Users.getPlayer(player).getProfile().getAbilityMode(AbilityType.SUPER_BREAKER);
|
return UserManager.getPlayer(player).getAbilityMode(AbilityType.SUPER_BREAKER);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean treeFellerEnabled(Player player) {
|
public static boolean treeFellerEnabled(Player player) {
|
||||||
return Users.getPlayer(player).getProfile().getAbilityMode(AbilityType.TREE_FELLER);
|
return UserManager.getPlayer(player).getAbilityMode(AbilityType.TREE_FELLER);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isAnyAbilityEnabled(Player player) {
|
public static boolean isAnyAbilityEnabled(Player player) {
|
||||||
PlayerProfile profile = Users.getPlayer(player).getProfile();
|
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
|
||||||
|
|
||||||
for (AbilityType ability : AbilityType.values()) {
|
for (AbilityType ability : AbilityType.values()) {
|
||||||
if (profile.getAbilityMode(ability)) {
|
if (mcMMOPlayer.getAbilityMode(ability)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,7 @@ import org.bukkit.plugin.Plugin;
|
|||||||
|
|
||||||
import com.gmail.nossr50.chat.ChatManager;
|
import com.gmail.nossr50.chat.ChatManager;
|
||||||
import com.gmail.nossr50.party.PartyManager;
|
import com.gmail.nossr50.party.PartyManager;
|
||||||
import com.gmail.nossr50.util.Users;
|
import com.gmail.nossr50.util.player.UserManager;
|
||||||
|
|
||||||
public final class ChatAPI {
|
public final class ChatAPI {
|
||||||
private ChatAPI() {}
|
private ChatAPI() {}
|
||||||
@ -104,7 +104,7 @@ public final class ChatAPI {
|
|||||||
* @return true if the player is using party chat, false otherwise
|
* @return true if the player is using party chat, false otherwise
|
||||||
*/
|
*/
|
||||||
public static boolean isUsingPartyChat(Player player) {
|
public static boolean isUsingPartyChat(Player player) {
|
||||||
return Users.getPlayer(player).getPartyChatMode();
|
return UserManager.getPlayer(player).getPartyChatMode();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -114,7 +114,7 @@ public final class ChatAPI {
|
|||||||
* @return true if the player is using party chat, false otherwise
|
* @return true if the player is using party chat, false otherwise
|
||||||
*/
|
*/
|
||||||
public static boolean isUsingPartyChat(String playerName) {
|
public static boolean isUsingPartyChat(String playerName) {
|
||||||
return Users.getPlayer(playerName).getPartyChatMode();
|
return UserManager.getPlayer(playerName).getPartyChatMode();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -124,7 +124,7 @@ public final class ChatAPI {
|
|||||||
* @return true if the player is using admin chat, false otherwise
|
* @return true if the player is using admin chat, false otherwise
|
||||||
*/
|
*/
|
||||||
public static boolean isUsingAdminChat(Player player) {
|
public static boolean isUsingAdminChat(Player player) {
|
||||||
return Users.getPlayer(player).getAdminChatMode();
|
return UserManager.getPlayer(player).getAdminChatMode();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -134,6 +134,6 @@ public final class ChatAPI {
|
|||||||
* @return true if the player is using admin chat, false otherwise
|
* @return true if the player is using admin chat, false otherwise
|
||||||
*/
|
*/
|
||||||
public static boolean isUsingAdminChat(String playerName) {
|
public static boolean isUsingAdminChat(String playerName) {
|
||||||
return Users.getPlayer(playerName).getAdminChatMode();
|
return UserManager.getPlayer(playerName).getAdminChatMode();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,25 +3,13 @@ package com.gmail.nossr50.api;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import com.gmail.nossr50.config.Config;
|
import com.gmail.nossr50.config.Config;
|
||||||
import com.gmail.nossr50.skills.utilities.SkillTools;
|
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||||
import com.gmail.nossr50.skills.utilities.SkillType;
|
import com.gmail.nossr50.util.player.UserManager;
|
||||||
import com.gmail.nossr50.util.Users;
|
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||||
|
|
||||||
public final class ExperienceAPI {
|
public final class ExperienceAPI {
|
||||||
private ExperienceAPI() {}
|
private ExperienceAPI() {}
|
||||||
|
|
||||||
/**
|
|
||||||
* Check the XP of a player. This should be called after giving XP to process level-ups.
|
|
||||||
*
|
|
||||||
* @param player The player to check
|
|
||||||
* @param skillType The skill to check
|
|
||||||
* @deprecated Calling this function is no longer needed and should be avoided
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
private static void checkXP(Player player, SkillType skillType) {
|
|
||||||
SkillTools.xpCheckSkill(skillType, player, Users.getProfile(player));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds raw XP to the player.
|
* Adds raw XP to the player.
|
||||||
* </br>
|
* </br>
|
||||||
@ -34,7 +22,7 @@ public final class ExperienceAPI {
|
|||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public static void addRawXP(Player player, SkillType skillType, int XP) {
|
public static void addRawXP(Player player, SkillType skillType, int XP) {
|
||||||
Users.getPlayer(player).applyXpGain(skillType, XP);
|
UserManager.getPlayer(player).applyXpGain(skillType, XP);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -47,7 +35,7 @@ public final class ExperienceAPI {
|
|||||||
* @param XP The amount of XP to add
|
* @param XP The amount of XP to add
|
||||||
*/
|
*/
|
||||||
public static void addRawXP(Player player, String skillType, int XP) {
|
public static void addRawXP(Player player, String skillType, int XP) {
|
||||||
Users.getPlayer(player).applyXpGain(SkillType.getSkill(skillType), XP);
|
UserManager.getPlayer(player).applyXpGain(SkillType.getSkill(skillType), XP);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -62,7 +50,7 @@ public final class ExperienceAPI {
|
|||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public static void addMultipliedXP(Player player, SkillType skillType, int XP) {
|
public static void addMultipliedXP(Player player, SkillType skillType, int XP) {
|
||||||
Users.getPlayer(player).applyXpGain(skillType, (int) (XP * Config.getInstance().getExperienceGainsGlobalMultiplier()));
|
UserManager.getPlayer(player).applyXpGain(skillType, (int) (XP * Config.getInstance().getExperienceGainsGlobalMultiplier()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -75,7 +63,7 @@ public final class ExperienceAPI {
|
|||||||
* @param XP The amount of XP to add
|
* @param XP The amount of XP to add
|
||||||
*/
|
*/
|
||||||
public static void addMultipliedXP(Player player, String skillType, int XP) {
|
public static void addMultipliedXP(Player player, String skillType, int XP) {
|
||||||
Users.getPlayer(player).applyXpGain(SkillType.getSkill(skillType), (int) (XP * Config.getInstance().getExperienceGainsGlobalMultiplier()));
|
UserManager.getPlayer(player).applyXpGain(SkillType.getSkill(skillType), (int) (XP * Config.getInstance().getExperienceGainsGlobalMultiplier()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -90,7 +78,7 @@ public final class ExperienceAPI {
|
|||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public static void addXP(Player player, SkillType skillType, int XP) {
|
public static void addXP(Player player, SkillType skillType, int XP) {
|
||||||
Users.getPlayer(player).beginXpGain(skillType, XP);
|
UserManager.getPlayer(player).beginXpGain(skillType, XP);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -103,7 +91,7 @@ public final class ExperienceAPI {
|
|||||||
* @param XP The amount of XP to add
|
* @param XP The amount of XP to add
|
||||||
*/
|
*/
|
||||||
public static void addXP(Player player, String skillType, int XP) {
|
public static void addXP(Player player, String skillType, int XP) {
|
||||||
Users.getPlayer(player).beginXpGain(SkillType.getSkill(skillType), XP);
|
UserManager.getPlayer(player).beginXpGain(SkillType.getSkill(skillType), XP);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -118,7 +106,7 @@ public final class ExperienceAPI {
|
|||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public static int getXP(Player player, SkillType skillType) {
|
public static int getXP(Player player, SkillType skillType) {
|
||||||
return Users.getPlayer(player).getProfile().getSkillXpLevel(skillType);
|
return UserManager.getPlayer(player).getProfile().getSkillXpLevel(skillType);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -131,7 +119,7 @@ public final class ExperienceAPI {
|
|||||||
* @return the amount of XP in a given skill
|
* @return the amount of XP in a given skill
|
||||||
*/
|
*/
|
||||||
public static int getXP(Player player, String skillType) {
|
public static int getXP(Player player, String skillType) {
|
||||||
return Users.getPlayer(player).getProfile().getSkillXpLevel(SkillType.getSkill(skillType));
|
return UserManager.getPlayer(player).getProfile().getSkillXpLevel(SkillType.getSkill(skillType));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -146,7 +134,7 @@ public final class ExperienceAPI {
|
|||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public static int getXPToNextLevel(Player player, SkillType skillType) {
|
public static int getXPToNextLevel(Player player, SkillType skillType) {
|
||||||
return Users.getPlayer(player).getProfile().getXpToLevel(skillType);
|
return UserManager.getPlayer(player).getProfile().getXpToLevel(skillType);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -159,7 +147,7 @@ public final class ExperienceAPI {
|
|||||||
* @return the amount of XP left before leveling up a specifc skill
|
* @return the amount of XP left before leveling up a specifc skill
|
||||||
*/
|
*/
|
||||||
public static int getXPToNextLevel(Player player, String skillType) {
|
public static int getXPToNextLevel(Player player, String skillType) {
|
||||||
return Users.getPlayer(player).getProfile().getXpToLevel(SkillType.getSkill(skillType));
|
return UserManager.getPlayer(player).getProfile().getXpToLevel(SkillType.getSkill(skillType));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -174,7 +162,7 @@ public final class ExperienceAPI {
|
|||||||
* @deprecated Use addLevel(Player, SKillType, int) instead
|
* @deprecated Use addLevel(Player, SKillType, int) instead
|
||||||
*/
|
*/
|
||||||
public static void addLevel(Player player, SkillType skillType, int levels, boolean notify) {
|
public static void addLevel(Player player, SkillType skillType, int levels, boolean notify) {
|
||||||
Users.getProfile(player).addLevels(skillType, levels);
|
UserManager.getProfile(player).addLevels(skillType, levels);
|
||||||
|
|
||||||
if (notify) {
|
if (notify) {
|
||||||
checkXP(player, skillType);
|
checkXP(player, skillType);
|
||||||
@ -193,7 +181,7 @@ public final class ExperienceAPI {
|
|||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public static void addLevel(Player player, SkillType skillType, int levels) {
|
public static void addLevel(Player player, SkillType skillType, int levels) {
|
||||||
Users.getPlayer(player).getProfile().addLevels(skillType, levels);
|
UserManager.getPlayer(player).getProfile().addLevels(skillType, levels);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -206,7 +194,7 @@ public final class ExperienceAPI {
|
|||||||
* @param levels Number of levels to add
|
* @param levels Number of levels to add
|
||||||
*/
|
*/
|
||||||
public static void addLevel(Player player, String skillType, int levels) {
|
public static void addLevel(Player player, String skillType, int levels) {
|
||||||
Users.getPlayer(player).getProfile().addLevels(SkillType.getSkill(skillType), levels);
|
UserManager.getPlayer(player).getProfile().addLevels(SkillType.getSkill(skillType), levels);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -221,7 +209,7 @@ public final class ExperienceAPI {
|
|||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public static int getLevel(Player player, SkillType skillType) {
|
public static int getLevel(Player player, SkillType skillType) {
|
||||||
return Users.getPlayer(player).getProfile().getSkillLevel(skillType);
|
return UserManager.getPlayer(player).getProfile().getSkillLevel(skillType);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -234,7 +222,7 @@ public final class ExperienceAPI {
|
|||||||
* @return the level of a given skill
|
* @return the level of a given skill
|
||||||
*/
|
*/
|
||||||
public static int getLevel(Player player, String skillType) {
|
public static int getLevel(Player player, String skillType) {
|
||||||
return Users.getPlayer(player).getProfile().getSkillLevel(SkillType.getSkill(skillType));
|
return UserManager.getPlayer(player).getProfile().getSkillLevel(SkillType.getSkill(skillType));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -246,7 +234,30 @@ public final class ExperienceAPI {
|
|||||||
* @return the power level of the player
|
* @return the power level of the player
|
||||||
*/
|
*/
|
||||||
public static int getPowerLevel(Player player) {
|
public static int getPowerLevel(Player player) {
|
||||||
return Users.getPlayer(player).getPowerLevel();
|
return UserManager.getPlayer(player).getPowerLevel();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the level cap of a specific skill.
|
||||||
|
* </br>
|
||||||
|
* This function is designed for API usage.
|
||||||
|
*
|
||||||
|
* @param skillType The skill to get the level cap for
|
||||||
|
* @return the level cap of a given skill
|
||||||
|
*/
|
||||||
|
public static int getLevelCap(String skillType) {
|
||||||
|
return Config.getInstance().getLevelCap(SkillType.getSkill(skillType));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the power level cap.
|
||||||
|
* </br>
|
||||||
|
* This function is designed for API usage.
|
||||||
|
*
|
||||||
|
* @return the power level cap of a given skill
|
||||||
|
*/
|
||||||
|
public static int getPowerLevelCap() {
|
||||||
|
return Config.getInstance().getPowerLevelCap();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -261,7 +272,7 @@ public final class ExperienceAPI {
|
|||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public static void setLevel(Player player, SkillType skillType, int skillLevel) {
|
public static void setLevel(Player player, SkillType skillType, int skillLevel) {
|
||||||
Users.getPlayer(player).getProfile().modifySkill(skillType, skillLevel);
|
UserManager.getPlayer(player).getProfile().modifySkill(skillType, skillLevel);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -274,7 +285,7 @@ public final class ExperienceAPI {
|
|||||||
* @param skillLevel The value to set the level to
|
* @param skillLevel The value to set the level to
|
||||||
*/
|
*/
|
||||||
public static void setLevel(Player player, String skillType, int skillLevel) {
|
public static void setLevel(Player player, String skillType, int skillLevel) {
|
||||||
Users.getPlayer(player).getProfile().modifySkill(SkillType.getSkill(skillType), skillLevel);
|
UserManager.getPlayer(player).getProfile().modifySkill(SkillType.getSkill(skillType), skillLevel);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -289,7 +300,7 @@ public final class ExperienceAPI {
|
|||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public static void setXP(Player player, SkillType skillType, int newValue) {
|
public static void setXP(Player player, SkillType skillType, int newValue) {
|
||||||
Users.getPlayer(player).getProfile().setSkillXpLevel(skillType, newValue);
|
UserManager.getPlayer(player).getProfile().setSkillXpLevel(skillType, newValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -302,7 +313,7 @@ public final class ExperienceAPI {
|
|||||||
* @param newValue The value to set the XP to
|
* @param newValue The value to set the XP to
|
||||||
*/
|
*/
|
||||||
public static void setXP(Player player, String skillType, int newValue) {
|
public static void setXP(Player player, String skillType, int newValue) {
|
||||||
Users.getPlayer(player).getProfile().setSkillXpLevel(SkillType.getSkill(skillType), newValue);
|
UserManager.getPlayer(player).getProfile().setSkillXpLevel(SkillType.getSkill(skillType), newValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -317,7 +328,7 @@ public final class ExperienceAPI {
|
|||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public static void removeXP(Player player, SkillType skillType, int xp) {
|
public static void removeXP(Player player, SkillType skillType, int xp) {
|
||||||
Users.getPlayer(player).getProfile().removeXp(skillType, xp);
|
UserManager.getPlayer(player).getProfile().removeXp(skillType, xp);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -330,6 +341,18 @@ public final class ExperienceAPI {
|
|||||||
* @param xp The amount of XP to remove
|
* @param xp The amount of XP to remove
|
||||||
*/
|
*/
|
||||||
public static void removeXP(Player player, String skillType, int xp) {
|
public static void removeXP(Player player, String skillType, int xp) {
|
||||||
Users.getPlayer(player).getProfile().removeXp(SkillType.getSkill(skillType), xp);
|
UserManager.getPlayer(player).getProfile().removeXp(SkillType.getSkill(skillType), xp);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check the XP of a player. This should be called after giving XP to process level-ups.
|
||||||
|
*
|
||||||
|
* @param player The player to check
|
||||||
|
* @param skillType The skill to check
|
||||||
|
* @deprecated Calling this function is no longer needed and should be avoided
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
private static void checkXP(Player player, SkillType skillType) {
|
||||||
|
SkillUtils.xpCheckSkill(skillType, player, UserManager.getProfile(player));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,9 +6,9 @@ import java.util.List;
|
|||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import com.gmail.nossr50.party.Party;
|
import com.gmail.nossr50.datatypes.party.Party;
|
||||||
import com.gmail.nossr50.party.PartyManager;
|
import com.gmail.nossr50.party.PartyManager;
|
||||||
import com.gmail.nossr50.util.Users;
|
import com.gmail.nossr50.util.player.UserManager;
|
||||||
|
|
||||||
public final class PartyAPI {
|
public final class PartyAPI {
|
||||||
private PartyAPI() {}
|
private PartyAPI() {}
|
||||||
@ -22,7 +22,7 @@ public final class PartyAPI {
|
|||||||
* @return the name of the player's party
|
* @return the name of the player's party
|
||||||
*/
|
*/
|
||||||
public static String getPartyName(Player player) {
|
public static String getPartyName(Player player) {
|
||||||
return Users.getPlayer(player).getParty().getName();
|
return UserManager.getPlayer(player).getParty().getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -34,7 +34,7 @@ public final class PartyAPI {
|
|||||||
* @return true if the player is in a party, false otherwise
|
* @return true if the player is in a party, false otherwise
|
||||||
*/
|
*/
|
||||||
public static boolean inParty(Player player) {
|
public static boolean inParty(Player player) {
|
||||||
return Users.getPlayer(player).inParty();
|
return UserManager.getPlayer(player).inParty();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -78,7 +78,7 @@ public final class PartyAPI {
|
|||||||
party.setLeader(player.getName());
|
party.setLeader(player.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
PartyManager.addToParty(player, Users.getPlayer(player), party);
|
PartyManager.addToParty(player, UserManager.getPlayer(player), party);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -89,7 +89,7 @@ public final class PartyAPI {
|
|||||||
* @param player The player to remove
|
* @param player The player to remove
|
||||||
*/
|
*/
|
||||||
public static void removeFromParty(Player player) {
|
public static void removeFromParty(Player player) {
|
||||||
PartyManager.removeFromParty(player, Users.getPlayer(player).getParty());
|
PartyManager.removeFromParty(player, UserManager.getPlayer(player).getParty());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
29
src/main/java/com/gmail/nossr50/api/SpoutHudAPI.java
Normal file
29
src/main/java/com/gmail/nossr50/api/SpoutHudAPI.java
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
package com.gmail.nossr50.api;
|
||||||
|
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import com.gmail.nossr50.config.spout.SpoutConfig;
|
||||||
|
import com.gmail.nossr50.datatypes.spout.huds.HudType;
|
||||||
|
import com.gmail.nossr50.util.player.UserManager;
|
||||||
|
|
||||||
|
public class SpoutHudAPI {
|
||||||
|
private SpoutHudAPI() {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Disable the mcMMO XP bar for a player.
|
||||||
|
* </br>
|
||||||
|
* This function is designed for API usage.
|
||||||
|
*/
|
||||||
|
public static void disableXpBar(Player player) {
|
||||||
|
UserManager.getPlayer(player).getProfile().setHudType(HudType.DISABLED);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Disable the mcMMO XP bar for the server.
|
||||||
|
* </br>
|
||||||
|
* This function is designed for API usage.
|
||||||
|
*/
|
||||||
|
public static void disableXpBar() {
|
||||||
|
SpoutConfig.getInstance().setXPBarEnabled(false);
|
||||||
|
}
|
||||||
|
}
|
@ -5,7 +5,7 @@ import java.util.List;
|
|||||||
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
import com.gmail.nossr50.skills.utilities.ToolType;
|
import com.gmail.nossr50.datatypes.skills.ToolType;
|
||||||
|
|
||||||
public final class SpoutToolsAPI {
|
public final class SpoutToolsAPI {
|
||||||
public static final List<ItemStack> spoutSwords = new ArrayList<ItemStack>();
|
public static final List<ItemStack> spoutSwords = new ArrayList<ItemStack>();
|
||||||
|
@ -6,26 +6,28 @@ import org.bukkit.plugin.Plugin;
|
|||||||
|
|
||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.gmail.nossr50.config.Config;
|
import com.gmail.nossr50.config.Config;
|
||||||
|
import com.gmail.nossr50.datatypes.party.Party;
|
||||||
import com.gmail.nossr50.events.chat.McMMOAdminChatEvent;
|
import com.gmail.nossr50.events.chat.McMMOAdminChatEvent;
|
||||||
import com.gmail.nossr50.events.chat.McMMOPartyChatEvent;
|
import com.gmail.nossr50.events.chat.McMMOPartyChatEvent;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.party.Party;
|
|
||||||
|
|
||||||
public final class ChatManager {
|
public final class ChatManager {
|
||||||
public ChatManager () {}
|
public ChatManager () {}
|
||||||
|
|
||||||
public static void handleAdminChat(Plugin plugin, String playerName, String displayName, String message) {
|
public static void handleAdminChat(Plugin plugin, String playerName, String displayName, String message, boolean isAsync) {
|
||||||
McMMOAdminChatEvent chatEvent = new McMMOAdminChatEvent(plugin, playerName, displayName, message);
|
McMMOAdminChatEvent chatEvent = new McMMOAdminChatEvent(plugin, playerName, displayName, message, isAsync);
|
||||||
mcMMO.p.getServer().getPluginManager().callEvent(chatEvent);
|
mcMMO.p.getServer().getPluginManager().callEvent(chatEvent);
|
||||||
|
|
||||||
if (chatEvent.isCancelled()) {
|
if (chatEvent.isCancelled()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(Config.getInstance().getAdminDisplayNames())
|
if (Config.getInstance().getAdminDisplayNames()) {
|
||||||
displayName = chatEvent.getDisplayName();
|
displayName = chatEvent.getDisplayName();
|
||||||
else
|
}
|
||||||
|
else {
|
||||||
displayName = chatEvent.getSender();
|
displayName = chatEvent.getSender();
|
||||||
|
}
|
||||||
|
|
||||||
String adminMessage = chatEvent.getMessage();
|
String adminMessage = chatEvent.getMessage();
|
||||||
|
|
||||||
@ -36,20 +38,26 @@ public final class ChatManager {
|
|||||||
handleAdminChat(plugin, senderName, senderName, message);
|
handleAdminChat(plugin, senderName, senderName, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void handlePartyChat(Plugin plugin, Party party, String playerName, String displayName, String message) {
|
public static void handleAdminChat(Plugin plugin, String playerName, String displayName, String message) {
|
||||||
|
handleAdminChat(plugin, playerName, displayName, message, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void handlePartyChat(Plugin plugin, Party party, String playerName, String displayName, String message, boolean isAsync) {
|
||||||
String partyName = party.getName();
|
String partyName = party.getName();
|
||||||
|
|
||||||
McMMOPartyChatEvent chatEvent = new McMMOPartyChatEvent(plugin, playerName, displayName, partyName, message);
|
McMMOPartyChatEvent chatEvent = new McMMOPartyChatEvent(plugin, playerName, displayName, partyName, message, isAsync);
|
||||||
mcMMO.p.getServer().getPluginManager().callEvent(chatEvent);
|
mcMMO.p.getServer().getPluginManager().callEvent(chatEvent);
|
||||||
|
|
||||||
if (chatEvent.isCancelled()) {
|
if (chatEvent.isCancelled()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(Config.getInstance().getPartyDisplayNames())
|
if (Config.getInstance().getPartyDisplayNames()) {
|
||||||
displayName = chatEvent.getDisplayName();
|
displayName = chatEvent.getDisplayName();
|
||||||
else
|
}
|
||||||
|
else {
|
||||||
displayName = chatEvent.getSender();
|
displayName = chatEvent.getSender();
|
||||||
|
}
|
||||||
|
|
||||||
String partyMessage = chatEvent.getMessage();
|
String partyMessage = chatEvent.getMessage();
|
||||||
|
|
||||||
@ -63,4 +71,8 @@ public final class ChatManager {
|
|||||||
public static void handlePartyChat(Plugin plugin, Party party, String senderName, String message) {
|
public static void handlePartyChat(Plugin plugin, Party party, String senderName, String message) {
|
||||||
handlePartyChat(plugin, party, senderName, senderName, message);
|
handlePartyChat(plugin, party, senderName, senderName, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void handlePartyChat(Plugin plugin, Party party, String playerName, String displayName, String message) {
|
||||||
|
handlePartyChat(plugin, party, playerName, displayName, message, false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package com.gmail.nossr50.chat;
|
package com.gmail.nossr50.chat;
|
||||||
|
|
||||||
import com.gmail.nossr50.datatypes.McMMOPlayer;
|
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
|
|
||||||
public enum ChatMode {
|
public enum ChatMode {
|
||||||
|
@ -0,0 +1,79 @@
|
|||||||
|
package com.gmail.nossr50.commands;
|
||||||
|
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandExecutor;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||||
|
import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
||||||
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
|
import com.gmail.nossr50.util.Permissions;
|
||||||
|
import com.gmail.nossr50.util.player.UserManager;
|
||||||
|
|
||||||
|
public class McabilityCommand implements CommandExecutor {
|
||||||
|
@Override
|
||||||
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
|
McMMOPlayer mcMMOPlayer;
|
||||||
|
|
||||||
|
switch (args.length) {
|
||||||
|
case 0:
|
||||||
|
if (!Permissions.mcability(sender)) {
|
||||||
|
sender.sendMessage(command.getPermissionMessage());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
mcMMOPlayer = UserManager.getPlayer((Player) sender);
|
||||||
|
|
||||||
|
if (mcMMOPlayer.getAbilityUse()) {
|
||||||
|
sender.sendMessage(LocaleLoader.getString("Commands.Ability.Off"));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
sender.sendMessage(LocaleLoader.getString("Commands.Ability.On"));
|
||||||
|
}
|
||||||
|
|
||||||
|
mcMMOPlayer.toggleAbilityUse();
|
||||||
|
return true;
|
||||||
|
|
||||||
|
case 1:
|
||||||
|
if (!Permissions.mcabilityOthers(sender)) {
|
||||||
|
sender.sendMessage(command.getPermissionMessage());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
mcMMOPlayer = UserManager.getPlayer(args[0]);
|
||||||
|
|
||||||
|
if (mcMMOPlayer == null) {
|
||||||
|
PlayerProfile playerProfile = new PlayerProfile(args[0], false);
|
||||||
|
|
||||||
|
if (!playerProfile.isLoaded()) {
|
||||||
|
sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
sender.sendMessage(LocaleLoader.getString("Commands.Offline"));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
Player player = mcMMOPlayer.getPlayer();
|
||||||
|
|
||||||
|
if (!player.isOnline()) {
|
||||||
|
sender.sendMessage(LocaleLoader.getString("Commands.Offline"));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mcMMOPlayer.getAbilityUse()) {
|
||||||
|
player.sendMessage(LocaleLoader.getString("Commands.Ability.Off"));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
player.sendMessage(LocaleLoader.getString("Commands.Ability.On"));
|
||||||
|
}
|
||||||
|
|
||||||
|
mcMMOPlayer.toggleAbilityUse();
|
||||||
|
return true;
|
||||||
|
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
88
src/main/java/com/gmail/nossr50/commands/McgodCommand.java
Normal file
88
src/main/java/com/gmail/nossr50/commands/McgodCommand.java
Normal file
@ -0,0 +1,88 @@
|
|||||||
|
package com.gmail.nossr50.commands;
|
||||||
|
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandExecutor;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||||
|
import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
||||||
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
|
import com.gmail.nossr50.util.Permissions;
|
||||||
|
import com.gmail.nossr50.util.player.UserManager;
|
||||||
|
|
||||||
|
public class McgodCommand implements CommandExecutor {
|
||||||
|
@Override
|
||||||
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
|
McMMOPlayer mcMMOPlayer;
|
||||||
|
|
||||||
|
switch (args.length) {
|
||||||
|
case 0:
|
||||||
|
if (!Permissions.mcgod(sender)) {
|
||||||
|
sender.sendMessage(command.getPermissionMessage());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!(sender instanceof Player)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
mcMMOPlayer = UserManager.getPlayer((Player) sender);
|
||||||
|
|
||||||
|
if (mcMMOPlayer == null) {
|
||||||
|
sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mcMMOPlayer.getGodMode()) {
|
||||||
|
sender.sendMessage(LocaleLoader.getString("Commands.GodMode.Disabled"));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
sender.sendMessage(LocaleLoader.getString("Commands.GodMode.Enabled"));
|
||||||
|
}
|
||||||
|
|
||||||
|
mcMMOPlayer.toggleGodMode();
|
||||||
|
return true;
|
||||||
|
|
||||||
|
case 1:
|
||||||
|
if (!Permissions.mcgodOthers(sender)) {
|
||||||
|
sender.sendMessage(command.getPermissionMessage());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
mcMMOPlayer = UserManager.getPlayer(args[0]);
|
||||||
|
|
||||||
|
if (mcMMOPlayer == null) {
|
||||||
|
PlayerProfile playerProfile = new PlayerProfile(args[0], false);
|
||||||
|
|
||||||
|
if (!playerProfile.isLoaded()) {
|
||||||
|
sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
sender.sendMessage(LocaleLoader.getString("Commands.Offline"));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
Player player = mcMMOPlayer.getPlayer();
|
||||||
|
|
||||||
|
if (!player.isOnline()) {
|
||||||
|
sender.sendMessage(LocaleLoader.getString("Commands.Offline"));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mcMMOPlayer.getGodMode()) {
|
||||||
|
player.sendMessage(LocaleLoader.getString("Commands.GodMode.Disabled"));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
player.sendMessage(LocaleLoader.getString("Commands.GodMode.Enabled"));
|
||||||
|
}
|
||||||
|
|
||||||
|
mcMMOPlayer.toggleGodMode();
|
||||||
|
return true;
|
||||||
|
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,4 +1,4 @@
|
|||||||
package com.gmail.nossr50.commands.player;
|
package com.gmail.nossr50.commands;
|
||||||
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
@ -8,15 +8,14 @@ import org.bukkit.command.CommandSender;
|
|||||||
import org.getspout.spoutapi.player.SpoutPlayer;
|
import org.getspout.spoutapi.player.SpoutPlayer;
|
||||||
|
|
||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
|
import com.gmail.nossr50.commands.party.PartySubcommandType;
|
||||||
import com.gmail.nossr50.config.Config;
|
import com.gmail.nossr50.config.Config;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.party.commands.PartySubcommandType;
|
|
||||||
import com.gmail.nossr50.util.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
|
|
||||||
public class McmmoCommand implements CommandExecutor {
|
public class McmmoCommand implements CommandExecutor {
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
|
|
||||||
switch (args.length) {
|
switch (args.length) {
|
||||||
case 0:
|
case 0:
|
||||||
if (!Permissions.mcmmoDescription(sender)) {
|
if (!Permissions.mcmmoDescription(sender)) {
|
@ -0,0 +1,33 @@
|
|||||||
|
package com.gmail.nossr50.commands;
|
||||||
|
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandExecutor;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||||
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
|
import com.gmail.nossr50.util.player.UserManager;
|
||||||
|
|
||||||
|
public class McnotifyCommand implements CommandExecutor {
|
||||||
|
@Override
|
||||||
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
|
switch (args.length) {
|
||||||
|
case 0:
|
||||||
|
McMMOPlayer mcMMOPlayer = UserManager.getPlayer((Player) sender);
|
||||||
|
|
||||||
|
if (mcMMOPlayer.useChatNotifications()) {
|
||||||
|
sender.sendMessage(LocaleLoader.getString("Commands.Notifications.Off"));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
sender.sendMessage(LocaleLoader.getString("Commands.Notifications.On"));
|
||||||
|
}
|
||||||
|
|
||||||
|
mcMMOPlayer.toggleChatNotifications();
|
||||||
|
return true;
|
||||||
|
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,80 @@
|
|||||||
|
package com.gmail.nossr50.commands;
|
||||||
|
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandExecutor;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||||
|
import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
||||||
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
|
import com.gmail.nossr50.util.Permissions;
|
||||||
|
import com.gmail.nossr50.util.player.UserManager;
|
||||||
|
|
||||||
|
public class McrefreshCommand implements CommandExecutor {
|
||||||
|
@Override
|
||||||
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
|
McMMOPlayer mcMMOPlayer;
|
||||||
|
|
||||||
|
switch (args.length) {
|
||||||
|
case 0:
|
||||||
|
if (!Permissions.mcrefresh(sender)) {
|
||||||
|
sender.sendMessage(command.getPermissionMessage());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!(sender instanceof Player)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
mcMMOPlayer = UserManager.getPlayer(sender.getName());
|
||||||
|
|
||||||
|
mcMMOPlayer.setRecentlyHurt(0);
|
||||||
|
mcMMOPlayer.getProfile().resetCooldowns();
|
||||||
|
mcMMOPlayer.resetToolPrepMode();
|
||||||
|
mcMMOPlayer.resetAbilityMode();
|
||||||
|
|
||||||
|
sender.sendMessage(LocaleLoader.getString("Ability.Generic.Refresh"));
|
||||||
|
return true;
|
||||||
|
|
||||||
|
case 1:
|
||||||
|
if (!Permissions.mcrefreshOthers(sender)) {
|
||||||
|
sender.sendMessage(command.getPermissionMessage());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
mcMMOPlayer = UserManager.getPlayer(args[0]);
|
||||||
|
|
||||||
|
if (mcMMOPlayer == null) {
|
||||||
|
PlayerProfile playerProfile = new PlayerProfile(args[0], false);
|
||||||
|
|
||||||
|
if (!playerProfile.isLoaded()) {
|
||||||
|
sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
sender.sendMessage(LocaleLoader.getString("Commands.Offline"));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
Player player = mcMMOPlayer.getPlayer();
|
||||||
|
|
||||||
|
if (!player.isOnline()) {
|
||||||
|
sender.sendMessage(LocaleLoader.getString("Commands.Offline"));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
mcMMOPlayer.setRecentlyHurt(0);
|
||||||
|
mcMMOPlayer.getProfile().resetCooldowns();
|
||||||
|
mcMMOPlayer.resetToolPrepMode();
|
||||||
|
mcMMOPlayer.resetAbilityMode();
|
||||||
|
|
||||||
|
player.sendMessage(LocaleLoader.getString("Ability.Generic.Refresh"));
|
||||||
|
sender.sendMessage(LocaleLoader.getString("Commands.mcrefresh.Success", args[0]));
|
||||||
|
return true;
|
||||||
|
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
69
src/main/java/com/gmail/nossr50/commands/XprateCommand.java
Normal file
69
src/main/java/com/gmail/nossr50/commands/XprateCommand.java
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
package com.gmail.nossr50.commands;
|
||||||
|
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandExecutor;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
|
import com.gmail.nossr50.mcMMO;
|
||||||
|
import com.gmail.nossr50.config.Config;
|
||||||
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
|
import com.gmail.nossr50.util.Permissions;
|
||||||
|
import com.gmail.nossr50.util.StringUtils;
|
||||||
|
|
||||||
|
public class XprateCommand implements CommandExecutor {
|
||||||
|
private static double originalRate = Config.getInstance().getExperienceGainsGlobalMultiplier();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
|
switch (args.length) {
|
||||||
|
case 1:
|
||||||
|
if (!args[0].equalsIgnoreCase("reset")) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!Permissions.xprateReset(sender)) {
|
||||||
|
sender.sendMessage(command.getPermissionMessage());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mcMMO.p.isXPEventEnabled()) {
|
||||||
|
mcMMO.p.getServer().broadcastMessage(LocaleLoader.getString("Commands.xprate.over"));
|
||||||
|
mcMMO.p.toggleXpEventEnabled();
|
||||||
|
}
|
||||||
|
|
||||||
|
Config.getInstance().setExperienceGainsGlobalMultiplier(originalRate);
|
||||||
|
return true;
|
||||||
|
|
||||||
|
case 2:
|
||||||
|
if (!StringUtils.isInt(args[0])) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!Permissions.xprateSet(sender)) {
|
||||||
|
sender.sendMessage(command.getPermissionMessage());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!args[1].equalsIgnoreCase("true") && !args[1].equalsIgnoreCase("false")) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
mcMMO.p.setXPEventEnabled(Boolean.valueOf(args[1]));
|
||||||
|
int newXpRate = Integer.parseInt(args[0]);
|
||||||
|
Config.getInstance().setExperienceGainsGlobalMultiplier(newXpRate);
|
||||||
|
|
||||||
|
if (mcMMO.p.isXPEventEnabled()) {
|
||||||
|
mcMMO.p.getServer().broadcastMessage(LocaleLoader.getString("Commands.xprate.started.0"));
|
||||||
|
mcMMO.p.getServer().broadcastMessage(LocaleLoader.getString("Commands.xprate.started.1", newXpRate));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
sender.sendMessage(LocaleLoader.getString("Commands.xprate.modified", newXpRate));
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,154 +0,0 @@
|
|||||||
package com.gmail.nossr50.commands.admin;
|
|
||||||
|
|
||||||
import org.bukkit.command.Command;
|
|
||||||
import org.bukkit.command.CommandExecutor;
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
import com.gmail.nossr50.datatypes.McMMOPlayer;
|
|
||||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
|
||||||
import com.gmail.nossr50.skills.utilities.SkillTools;
|
|
||||||
import com.gmail.nossr50.skills.utilities.SkillType;
|
|
||||||
import com.gmail.nossr50.util.Permissions;
|
|
||||||
import com.gmail.nossr50.util.StringUtils;
|
|
||||||
import com.gmail.nossr50.util.Users;
|
|
||||||
|
|
||||||
public class AddlevelsCommand implements CommandExecutor{
|
|
||||||
@Override
|
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
|
||||||
PlayerProfile profile;
|
|
||||||
int levels;
|
|
||||||
boolean allSkills = false;
|
|
||||||
SkillType skill = null;
|
|
||||||
|
|
||||||
switch (args.length) {
|
|
||||||
case 2:
|
|
||||||
if (!Permissions.addlevels(sender)) {
|
|
||||||
sender.sendMessage(command.getPermissionMessage());
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!(sender instanceof Player)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (args[0].equalsIgnoreCase("all")) {
|
|
||||||
allSkills = true;
|
|
||||||
}
|
|
||||||
else if (!SkillTools.isSkill(args[0])) {
|
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!StringUtils.isInt(args[1])) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
levels = Integer.parseInt(args[1]);
|
|
||||||
profile = Users.getPlayer((Player) sender).getProfile();
|
|
||||||
|
|
||||||
if (allSkills) {
|
|
||||||
for (SkillType skillType : SkillType.values()) {
|
|
||||||
if (skillType.isChildSkill()) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
profile.addLevels(skillType, levels);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
skill = SkillType.getSkill(args[0]);
|
|
||||||
profile.addLevels(skill, levels);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (allSkills) {
|
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardAll.1", levels));
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardSkill.1", levels, SkillTools.getSkillName(skill)));
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
|
|
||||||
case 3:
|
|
||||||
if (!Permissions.addlevelsOthers(sender)) {
|
|
||||||
sender.sendMessage(command.getPermissionMessage());
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (args[1].equalsIgnoreCase("all")) {
|
|
||||||
allSkills = true;
|
|
||||||
}
|
|
||||||
else if (!SkillTools.isSkill(args[1])) {
|
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!StringUtils.isInt(args[2])) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
McMMOPlayer mcMMOPlayer = Users.getPlayer(args[0]);
|
|
||||||
levels = Integer.parseInt(args[2]);
|
|
||||||
|
|
||||||
// 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) {
|
|
||||||
profile = new PlayerProfile(args[0], false);
|
|
||||||
|
|
||||||
if (!profile.isLoaded()) {
|
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (allSkills) {
|
|
||||||
for (SkillType skillType : SkillType.values()) {
|
|
||||||
if (skillType.isChildSkill()) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
profile.addLevels(skillType, levels);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
skill = SkillType.getSkill(args[1]);
|
|
||||||
profile.addLevels(skill, levels);
|
|
||||||
}
|
|
||||||
|
|
||||||
profile.save(); // Since this is a temporary profile, we save it here.
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
profile = mcMMOPlayer.getProfile();
|
|
||||||
|
|
||||||
if (allSkills) {
|
|
||||||
for (SkillType skillType : SkillType.values()) {
|
|
||||||
if (skillType.isChildSkill()) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
profile.addLevels(skillType, levels);
|
|
||||||
}
|
|
||||||
|
|
||||||
mcMMOPlayer.getPlayer().sendMessage(LocaleLoader.getString("Commands.addlevels.AwardAll.1", levels));
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
skill = SkillType.getSkill(args[1]);
|
|
||||||
profile.addLevels(skill, levels);
|
|
||||||
mcMMOPlayer.getPlayer().sendMessage(LocaleLoader.getString("Commands.addlevels.AwardSkill.1", levels, SkillTools.getSkillName(skill)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (allSkills) {
|
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardAll.2", args[0]));
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardSkill.2", SkillTools.getSkillName(skill), args[0]));
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
|
|
||||||
default:
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,151 +0,0 @@
|
|||||||
package com.gmail.nossr50.commands.admin;
|
|
||||||
|
|
||||||
import org.bukkit.command.Command;
|
|
||||||
import org.bukkit.command.CommandExecutor;
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import com.gmail.nossr50.datatypes.McMMOPlayer;
|
|
||||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
|
||||||
import com.gmail.nossr50.skills.utilities.SkillTools;
|
|
||||||
import com.gmail.nossr50.skills.utilities.SkillType;
|
|
||||||
import com.gmail.nossr50.util.Permissions;
|
|
||||||
import com.gmail.nossr50.util.StringUtils;
|
|
||||||
import com.gmail.nossr50.util.Users;
|
|
||||||
|
|
||||||
public class AddxpCommand implements CommandExecutor {
|
|
||||||
@Override
|
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
|
||||||
int xp;
|
|
||||||
McMMOPlayer mcMMOPlayer;
|
|
||||||
PlayerProfile profile;
|
|
||||||
boolean allSkills = false;
|
|
||||||
SkillType skill = null;
|
|
||||||
|
|
||||||
switch (args.length) {
|
|
||||||
case 2:
|
|
||||||
if (!Permissions.addxp(sender)) {
|
|
||||||
sender.sendMessage(command.getPermissionMessage());
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!(sender instanceof Player)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (args[0].equalsIgnoreCase("all")) {
|
|
||||||
allSkills = true;
|
|
||||||
}
|
|
||||||
else if (!SkillTools.isSkill(args[0])) {
|
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!StringUtils.isInt(args[1])) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
xp = Integer.parseInt(args[1]);
|
|
||||||
mcMMOPlayer = Users.getPlayer((Player) sender);
|
|
||||||
profile = mcMMOPlayer.getProfile();
|
|
||||||
|
|
||||||
if (allSkills) {
|
|
||||||
for (SkillType skillType : SkillType.values()) {
|
|
||||||
if (skillType.isChildSkill()) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
mcMMOPlayer.applyXpGain(skillType, xp);
|
|
||||||
}
|
|
||||||
|
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.addxp.AwardAll", xp));
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
skill = SkillType.getSkill(args[0]);
|
|
||||||
|
|
||||||
mcMMOPlayer.applyXpGain(skill, xp);
|
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.addxp.AwardSkill", xp, SkillTools.getSkillName(skill)));
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
|
|
||||||
case 3:
|
|
||||||
if (!Permissions.addxpOthers(sender)) {
|
|
||||||
sender.sendMessage(command.getPermissionMessage());
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (args[1].equalsIgnoreCase("all")) {
|
|
||||||
allSkills = true;
|
|
||||||
}
|
|
||||||
else if (!SkillTools.isSkill(args[1])) {
|
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!StringUtils.isInt(args[2])) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
mcMMOPlayer = Users.getPlayer(args[0]);
|
|
||||||
xp = Integer.parseInt(args[2]);
|
|
||||||
|
|
||||||
// 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) {
|
|
||||||
profile = new PlayerProfile(args[0], false);
|
|
||||||
|
|
||||||
if (!profile.isLoaded()) {
|
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: Currently the offline player doesn't level up automatically
|
|
||||||
if (allSkills) {
|
|
||||||
for (SkillType skillType : SkillType.values()) {
|
|
||||||
if (skillType.isChildSkill()) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
profile.setSkillXpLevel(skillType, xp);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
skill = SkillType.getSkill(args[1]);
|
|
||||||
profile.setSkillXpLevel(skill, xp);
|
|
||||||
}
|
|
||||||
|
|
||||||
profile.save(); // Since this is a temporary profile, we save it here.
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
if (allSkills) {
|
|
||||||
for (SkillType skillType : SkillType.values()) {
|
|
||||||
if (skillType.isChildSkill()) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
mcMMOPlayer.applyXpGain(skillType, xp);
|
|
||||||
}
|
|
||||||
|
|
||||||
mcMMOPlayer.getPlayer().sendMessage(LocaleLoader.getString("Commands.addxp.AwardAll", xp));
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
skill = SkillType.getSkill(args[1]);
|
|
||||||
mcMMOPlayer.applyXpGain(skill, xp);
|
|
||||||
mcMMOPlayer.getPlayer().sendMessage(LocaleLoader.getString("Commands.addxp.AwardSkill", xp, SkillTools.getSkillName(skill)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (allSkills) {
|
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardAll.2", args[0]));
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardSkill.2", SkillTools.getSkillName(skill), args[0]));
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
|
|
||||||
default:
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,86 +0,0 @@
|
|||||||
package com.gmail.nossr50.commands.admin;
|
|
||||||
|
|
||||||
import java.text.DecimalFormat;
|
|
||||||
|
|
||||||
import org.bukkit.command.Command;
|
|
||||||
import org.bukkit.command.CommandExecutor;
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
|
|
||||||
import com.gmail.nossr50.mcMMO;
|
|
||||||
import com.gmail.nossr50.config.Config;
|
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
|
||||||
import com.gmail.nossr50.util.Permissions;
|
|
||||||
import com.gmail.nossr50.util.StringUtils;
|
|
||||||
|
|
||||||
public class HardcoreCommand implements CommandExecutor{
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
|
||||||
switch (args.length) {
|
|
||||||
case 0:
|
|
||||||
if (!Permissions.hardcoreToggle(sender)) {
|
|
||||||
sender.sendMessage(command.getPermissionMessage());
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Config.getInstance().getHardcoreEnabled()) {
|
|
||||||
disableHardcore();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
enableHardcore();
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
|
|
||||||
case 1:
|
|
||||||
if (args[0].equalsIgnoreCase("on") || args[0].equalsIgnoreCase("true") || args[0].equalsIgnoreCase("enabled")) {
|
|
||||||
if (!Permissions.hardcoreToggle(sender)) {
|
|
||||||
sender.sendMessage(command.getPermissionMessage());
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
enableHardcore();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (args[0].equalsIgnoreCase("off") || args[0].equalsIgnoreCase("false") || args[0].equalsIgnoreCase("disabled")) {
|
|
||||||
if (!Permissions.hardcoreToggle(sender)) {
|
|
||||||
sender.sendMessage(command.getPermissionMessage());
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
disableHardcore();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!StringUtils.isDouble(args[0])) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!Permissions.hardcoreModify(sender)) {
|
|
||||||
sender.sendMessage(command.getPermissionMessage());
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
DecimalFormat percent = new DecimalFormat("##0.00%");
|
|
||||||
double newPercent = Double.parseDouble(args[0]);
|
|
||||||
|
|
||||||
Config.getInstance().setHardcoreDeathStatPenaltyPercentage(newPercent);
|
|
||||||
sender.sendMessage(LocaleLoader.getString("Hardcore.PercentageChanged", percent.format(newPercent / 100D)));
|
|
||||||
return true;
|
|
||||||
|
|
||||||
default:
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void disableHardcore() {
|
|
||||||
Config.getInstance().setHardcoreEnabled(false);
|
|
||||||
mcMMO.p.getServer().broadcastMessage(LocaleLoader.getString("Hardcore.Disabled"));
|
|
||||||
}
|
|
||||||
|
|
||||||
private void enableHardcore() {
|
|
||||||
Config.getInstance().setHardcoreEnabled(true);
|
|
||||||
mcMMO.p.getServer().broadcastMessage(LocaleLoader.getString("Hardcore.Enabled"));
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,89 +0,0 @@
|
|||||||
package com.gmail.nossr50.commands.admin;
|
|
||||||
|
|
||||||
import org.bukkit.command.Command;
|
|
||||||
import org.bukkit.command.CommandExecutor;
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
import com.gmail.nossr50.datatypes.McMMOPlayer;
|
|
||||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
|
||||||
import com.gmail.nossr50.util.Permissions;
|
|
||||||
import com.gmail.nossr50.util.Users;
|
|
||||||
|
|
||||||
public class McgodCommand implements CommandExecutor {
|
|
||||||
@Override
|
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
|
||||||
PlayerProfile profile;
|
|
||||||
|
|
||||||
switch (args.length) {
|
|
||||||
case 0:
|
|
||||||
if (!Permissions.mcgod(sender)) {
|
|
||||||
sender.sendMessage(command.getPermissionMessage());
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!(sender instanceof Player)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
profile = Users.getPlayer((Player) sender).getProfile();
|
|
||||||
|
|
||||||
if (profile == null) {
|
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (profile.getGodMode()) {
|
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.GodMode.Disabled"));
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.GodMode.Enabled"));
|
|
||||||
}
|
|
||||||
|
|
||||||
profile.toggleGodMode();
|
|
||||||
return true;
|
|
||||||
|
|
||||||
case 1:
|
|
||||||
if (!Permissions.mcgodOthers(sender)) {
|
|
||||||
sender.sendMessage(command.getPermissionMessage());
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
McMMOPlayer mcMMOPlayer = Users.getPlayer(args[0]);
|
|
||||||
|
|
||||||
if (mcMMOPlayer == null) {
|
|
||||||
profile = new PlayerProfile(args[0], false);
|
|
||||||
|
|
||||||
if (!profile.isLoaded()) {
|
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.Offline"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
profile = mcMMOPlayer.getProfile();
|
|
||||||
Player player = mcMMOPlayer.getPlayer();
|
|
||||||
|
|
||||||
if (!player.isOnline()) {
|
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.Offline"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (profile.getGodMode()) {
|
|
||||||
player.sendMessage(LocaleLoader.getString("Commands.GodMode.Disabled"));
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
player.sendMessage(LocaleLoader.getString("Commands.GodMode.Enabled"));
|
|
||||||
}
|
|
||||||
|
|
||||||
profile.toggleGodMode();
|
|
||||||
return true;
|
|
||||||
|
|
||||||
default:
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,80 +0,0 @@
|
|||||||
package com.gmail.nossr50.commands.admin;
|
|
||||||
|
|
||||||
import org.bukkit.command.Command;
|
|
||||||
import org.bukkit.command.CommandExecutor;
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
import com.gmail.nossr50.datatypes.McMMOPlayer;
|
|
||||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
|
||||||
import com.gmail.nossr50.util.Permissions;
|
|
||||||
import com.gmail.nossr50.util.Users;
|
|
||||||
|
|
||||||
public class McrefreshCommand implements CommandExecutor {
|
|
||||||
@Override
|
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
|
||||||
PlayerProfile profile;
|
|
||||||
|
|
||||||
switch (args.length) {
|
|
||||||
case 0:
|
|
||||||
if (!Permissions.mcrefresh(sender)) {
|
|
||||||
sender.sendMessage(command.getPermissionMessage());
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!(sender instanceof Player)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
profile = Users.getPlayer(sender.getName()).getProfile();
|
|
||||||
|
|
||||||
profile.setRecentlyHurt(0);
|
|
||||||
profile.resetCooldowns();
|
|
||||||
profile.resetToolPrepMode();
|
|
||||||
profile.resetAbilityMode();
|
|
||||||
|
|
||||||
sender.sendMessage(LocaleLoader.getString("Ability.Generic.Refresh"));
|
|
||||||
return true;
|
|
||||||
|
|
||||||
case 1:
|
|
||||||
if (!Permissions.mcrefreshOthers(sender)) {
|
|
||||||
sender.sendMessage(command.getPermissionMessage());
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
McMMOPlayer mcMMOPlayer = Users.getPlayer(args[0]);
|
|
||||||
|
|
||||||
if (mcMMOPlayer == null) {
|
|
||||||
profile = new PlayerProfile(args[0], false);
|
|
||||||
|
|
||||||
if (!profile.isLoaded()) {
|
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.Offline"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
profile = mcMMOPlayer.getProfile();
|
|
||||||
Player player = mcMMOPlayer.getPlayer();
|
|
||||||
|
|
||||||
if (!player.isOnline()) {
|
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.Offline"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
profile.setRecentlyHurt(0);
|
|
||||||
profile.resetCooldowns();
|
|
||||||
profile.resetToolPrepMode();
|
|
||||||
profile.resetAbilityMode();
|
|
||||||
|
|
||||||
player.sendMessage(LocaleLoader.getString("Ability.Generic.Refresh"));
|
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.mcrefresh.Success", args[0]));
|
|
||||||
return true;
|
|
||||||
|
|
||||||
default:
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,150 +0,0 @@
|
|||||||
package com.gmail.nossr50.commands.admin;
|
|
||||||
|
|
||||||
import org.bukkit.command.Command;
|
|
||||||
import org.bukkit.command.CommandExecutor;
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
import com.gmail.nossr50.datatypes.McMMOPlayer;
|
|
||||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
|
||||||
import com.gmail.nossr50.skills.utilities.SkillTools;
|
|
||||||
import com.gmail.nossr50.skills.utilities.SkillType;
|
|
||||||
import com.gmail.nossr50.util.Permissions;
|
|
||||||
import com.gmail.nossr50.util.StringUtils;
|
|
||||||
import com.gmail.nossr50.util.Users;
|
|
||||||
|
|
||||||
public class MmoeditCommand implements CommandExecutor {
|
|
||||||
@Override
|
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
|
||||||
PlayerProfile profile;
|
|
||||||
int newValue;
|
|
||||||
boolean allSkills = false;
|
|
||||||
SkillType skill = null;
|
|
||||||
|
|
||||||
switch (args.length) {
|
|
||||||
case 2:
|
|
||||||
if (!Permissions.mmoedit(sender)) {
|
|
||||||
sender.sendMessage(command.getPermissionMessage());
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!(sender instanceof Player)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (args[0].equalsIgnoreCase("all")) {
|
|
||||||
allSkills = true;
|
|
||||||
}
|
|
||||||
else if (!SkillTools.isSkill(args[0])) {
|
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!StringUtils.isInt(args[1])) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
newValue = Integer.parseInt(args[1]);
|
|
||||||
profile = Users.getPlayer((Player) sender).getProfile();
|
|
||||||
|
|
||||||
if (allSkills) {
|
|
||||||
for (SkillType skillType : SkillType.values()) {
|
|
||||||
if (skillType.isChildSkill()) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
profile.modifySkill(skillType, newValue);
|
|
||||||
}
|
|
||||||
|
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.mmoedit.AllSkills.1", newValue));
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
skill = SkillType.getSkill(args[0]);
|
|
||||||
profile.modifySkill(skill, newValue);
|
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.mmoedit.Modified.1", SkillTools.getSkillName(skill), newValue));
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
|
|
||||||
case 3:
|
|
||||||
if (!Permissions.mmoeditOthers(sender)) {
|
|
||||||
sender.sendMessage(command.getPermissionMessage());
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (args[1].equalsIgnoreCase("all")) {
|
|
||||||
allSkills = true;
|
|
||||||
}
|
|
||||||
else if (!SkillTools.isSkill(args[1])) {
|
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!StringUtils.isInt(args[2])) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
newValue = Integer.parseInt(args[2]);
|
|
||||||
McMMOPlayer mcMMOPlayer = Users.getPlayer(args[0]);
|
|
||||||
|
|
||||||
// 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) {
|
|
||||||
profile = new PlayerProfile(args[0], false);
|
|
||||||
|
|
||||||
if (!profile.isLoaded()) {
|
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (allSkills) {
|
|
||||||
for (SkillType skillType : SkillType.values()) {
|
|
||||||
if (skillType.isChildSkill()) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
profile.modifySkill(skillType, newValue);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
skill = SkillType.getSkill(args[1]);
|
|
||||||
profile.modifySkill(skill, newValue);
|
|
||||||
}
|
|
||||||
|
|
||||||
profile.save(); // Since this is a temporary profile, we save it here.
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
profile = mcMMOPlayer.getProfile();
|
|
||||||
|
|
||||||
if (allSkills) {
|
|
||||||
for (SkillType skillType : SkillType.values()) {
|
|
||||||
if (skillType.isChildSkill()) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
profile.modifySkill(skillType, newValue);
|
|
||||||
}
|
|
||||||
|
|
||||||
mcMMOPlayer.getPlayer().sendMessage(LocaleLoader.getString("Commands.mmoedit.AllSkills.1", newValue));
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
skill = SkillType.getSkill(args[1]);
|
|
||||||
profile.modifySkill(skill, newValue);
|
|
||||||
mcMMOPlayer.getPlayer().sendMessage(LocaleLoader.getString("Commands.mmoedit.Modified.1", SkillTools.getSkillName(skill), newValue));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (allSkills) {
|
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardAll.2", args[0]));
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.mmoedit.Modified.2", SkillTools.getSkillName(skill), args[0]));
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
|
|
||||||
default:
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,169 +0,0 @@
|
|||||||
package com.gmail.nossr50.commands.admin;
|
|
||||||
|
|
||||||
import org.bukkit.command.Command;
|
|
||||||
import org.bukkit.command.CommandExecutor;
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
import com.gmail.nossr50.datatypes.McMMOPlayer;
|
|
||||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
|
||||||
import com.gmail.nossr50.skills.utilities.SkillTools;
|
|
||||||
import com.gmail.nossr50.skills.utilities.SkillType;
|
|
||||||
import com.gmail.nossr50.util.Permissions;
|
|
||||||
import com.gmail.nossr50.util.Users;
|
|
||||||
|
|
||||||
public class SkillresetCommand implements CommandExecutor {
|
|
||||||
@Override
|
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
|
||||||
PlayerProfile profile;
|
|
||||||
boolean allSkills = false;
|
|
||||||
SkillType skill = null;
|
|
||||||
String skillName = "";
|
|
||||||
|
|
||||||
switch (args.length) {
|
|
||||||
case 1:
|
|
||||||
if (!Permissions.skillreset(sender)) {
|
|
||||||
sender.sendMessage(command.getPermissionMessage());
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!(sender instanceof Player)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (args[0].equalsIgnoreCase("all")) {
|
|
||||||
allSkills = true;
|
|
||||||
}
|
|
||||||
else if (!SkillTools.isSkill(args[0])) {
|
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
profile = Users.getPlayer((Player) sender).getProfile();
|
|
||||||
|
|
||||||
if (allSkills) {
|
|
||||||
for (SkillType skillType : SkillType.values()) {
|
|
||||||
if (skillType.isChildSkill()) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!Permissions.skillreset(sender, skillType)) {
|
|
||||||
sender.sendMessage(command.getPermissionMessage());
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
profile.modifySkill(skillType, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.Reset.All"));
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
skill = SkillType.getSkill(args[0]);
|
|
||||||
skillName = SkillTools.getSkillName(skill);
|
|
||||||
|
|
||||||
if (!Permissions.skillreset(sender, skill)) {
|
|
||||||
sender.sendMessage(command.getPermissionMessage());
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
profile.modifySkill(skill, 0);
|
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.Reset.Single", skillName));
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
|
|
||||||
case 2:
|
|
||||||
if (!Permissions.skillresetOthers(sender)) {
|
|
||||||
sender.sendMessage(command.getPermissionMessage());
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (args[1].equalsIgnoreCase("all")) {
|
|
||||||
allSkills = true;
|
|
||||||
}
|
|
||||||
else if (!SkillTools.isSkill(args[1])) {
|
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!allSkills) {
|
|
||||||
skill = SkillType.getSkill(args[1]);
|
|
||||||
skillName = SkillTools.getSkillName(skill);
|
|
||||||
|
|
||||||
if (!Permissions.skillresetOthers(sender, skill)) {
|
|
||||||
sender.sendMessage(command.getPermissionMessage());
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
McMMOPlayer mcMMOPlayer = Users.getPlayer(args[0]);
|
|
||||||
|
|
||||||
// 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) {
|
|
||||||
profile = new PlayerProfile(args[0], false);
|
|
||||||
|
|
||||||
if (!profile.isLoaded()) {
|
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (allSkills) {
|
|
||||||
for (SkillType skillType : SkillType.values()) {
|
|
||||||
if (skillType.isChildSkill()) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!Permissions.skillresetOthers(sender, skill)) {
|
|
||||||
sender.sendMessage(command.getPermissionMessage());
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
profile.modifySkill(skillType, 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
profile.modifySkill(skill, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
profile.save(); // Since this is a temporary profile, we save it here.
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
profile = mcMMOPlayer.getProfile();
|
|
||||||
|
|
||||||
if (allSkills) {
|
|
||||||
for (SkillType skillType : SkillType.values()) {
|
|
||||||
if (skillType.isChildSkill()) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!Permissions.skillresetOthers(sender, skill)) {
|
|
||||||
sender.sendMessage(command.getPermissionMessage());
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
profile.modifySkill(skillType, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
mcMMOPlayer.getPlayer().sendMessage(LocaleLoader.getString("Commands.Reset.All"));
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
profile.modifySkill(skill, 0);
|
|
||||||
mcMMOPlayer.getPlayer().sendMessage(LocaleLoader.getString("Commands.Reset.Single", skillName));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (allSkills) {
|
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardAll.2", args[0]));
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.mmoedit.Modified.2", skillName, args[0]));
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
|
|
||||||
default:
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,91 +0,0 @@
|
|||||||
package com.gmail.nossr50.commands.admin;
|
|
||||||
|
|
||||||
import java.text.DecimalFormat;
|
|
||||||
|
|
||||||
import org.bukkit.command.Command;
|
|
||||||
import org.bukkit.command.CommandExecutor;
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
|
|
||||||
import com.gmail.nossr50.mcMMO;
|
|
||||||
import com.gmail.nossr50.config.Config;
|
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
|
||||||
import com.gmail.nossr50.util.Permissions;
|
|
||||||
import com.gmail.nossr50.util.StringUtils;
|
|
||||||
|
|
||||||
public class VampirismCommand implements CommandExecutor {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
|
||||||
if (!Config.getInstance().getHardcoreEnabled()) {
|
|
||||||
sender.sendMessage(LocaleLoader.getString("Hardcore.Disabled"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (args.length) {
|
|
||||||
case 0:
|
|
||||||
if (!Permissions.vampirismToggle(sender)) {
|
|
||||||
sender.sendMessage(command.getPermissionMessage());
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Config.getInstance().getHardcoreVampirismEnabled()) {
|
|
||||||
disableVampirism();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
enableVampirism();
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
|
|
||||||
case 1:
|
|
||||||
if (args[0].equalsIgnoreCase("on") || args[0].equalsIgnoreCase("true") || args[0].equalsIgnoreCase("enabled")) {
|
|
||||||
if (!Permissions.vampirismToggle(sender)) {
|
|
||||||
sender.sendMessage(command.getPermissionMessage());
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
enableVampirism();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (args[0].equalsIgnoreCase("off") || args[0].equalsIgnoreCase("false") || args[0].equalsIgnoreCase("disabled")) {
|
|
||||||
if (!Permissions.vampirismToggle(sender)) {
|
|
||||||
sender.sendMessage(command.getPermissionMessage());
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
disableVampirism();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!StringUtils.isDouble(args[0])) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!Permissions.vampirismModify(sender)) {
|
|
||||||
sender.sendMessage(command.getPermissionMessage());
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
DecimalFormat percent = new DecimalFormat("##0.00%");
|
|
||||||
double newPercent = Double.parseDouble(args[0]);
|
|
||||||
|
|
||||||
Config.getInstance().setHardcoreVampirismStatLeechPercentage(newPercent);
|
|
||||||
sender.sendMessage(LocaleLoader.getString("Vampirism.PercentageChanged", percent.format(newPercent / 100D)));
|
|
||||||
return true;
|
|
||||||
|
|
||||||
default:
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void disableVampirism() {
|
|
||||||
Config.getInstance().setHardcoreVampirismEnabled(false);
|
|
||||||
mcMMO.p.getServer().broadcastMessage(LocaleLoader.getString("Vampirism.Disabled"));
|
|
||||||
}
|
|
||||||
|
|
||||||
private void enableVampirism() {
|
|
||||||
Config.getInstance().setHardcoreVampirismEnabled(true);
|
|
||||||
mcMMO.p.getServer().broadcastMessage(LocaleLoader.getString("Vampirism.Enabled"));
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,69 +0,0 @@
|
|||||||
package com.gmail.nossr50.commands.admin;
|
|
||||||
|
|
||||||
import org.bukkit.command.Command;
|
|
||||||
import org.bukkit.command.CommandExecutor;
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
|
|
||||||
import com.gmail.nossr50.mcMMO;
|
|
||||||
import com.gmail.nossr50.config.Config;
|
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
|
||||||
import com.gmail.nossr50.util.Permissions;
|
|
||||||
import com.gmail.nossr50.util.StringUtils;
|
|
||||||
|
|
||||||
public class XprateCommand implements CommandExecutor {
|
|
||||||
private static double originalRate = Config.getInstance().getExperienceGainsGlobalMultiplier();
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
|
||||||
switch (args.length) {
|
|
||||||
case 1:
|
|
||||||
if (!args[0].equalsIgnoreCase("reset")) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!Permissions.xprateReset(sender)) {
|
|
||||||
sender.sendMessage(command.getPermissionMessage());
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mcMMO.p.isXPEventEnabled()) {
|
|
||||||
mcMMO.p.getServer().broadcastMessage(LocaleLoader.getString("Commands.xprate.over"));
|
|
||||||
mcMMO.p.toggleXpEventEnabled();
|
|
||||||
}
|
|
||||||
|
|
||||||
Config.getInstance().setExperienceGainsGlobalMultiplier(originalRate);
|
|
||||||
return true;
|
|
||||||
|
|
||||||
case 2:
|
|
||||||
if (!StringUtils.isInt(args[0])) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!Permissions.xprateSet(sender)) {
|
|
||||||
sender.sendMessage(command.getPermissionMessage());
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!args[1].equalsIgnoreCase("true") && !args[1].equalsIgnoreCase("false")) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
mcMMO.p.setXPEventEnabled(Boolean.valueOf(args[1]));
|
|
||||||
int newXpRate = Integer.parseInt(args[0]);
|
|
||||||
Config.getInstance().setExperienceGainsGlobalMultiplier(newXpRate);
|
|
||||||
|
|
||||||
if (mcMMO.p.isXPEventEnabled()) {
|
|
||||||
mcMMO.p.getServer().broadcastMessage(LocaleLoader.getString("Commands.xprate.started.0"));
|
|
||||||
mcMMO.p.getServer().broadcastMessage(LocaleLoader.getString("Commands.xprate.started.1", newXpRate));
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.xprate.modified", newXpRate));
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
|
|
||||||
default:
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,4 +1,4 @@
|
|||||||
package com.gmail.nossr50.chat.commands;
|
package com.gmail.nossr50.commands.chat;
|
||||||
|
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -15,14 +15,12 @@ public class AdminChatCommand extends ChatCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void handleChatSending(CommandSender sender, String[] args) {
|
protected void handleChatSending(CommandSender sender, String[] args) {
|
||||||
String message = buildChatMessage(args, 0);
|
|
||||||
|
|
||||||
if (sender instanceof Player) {
|
if (sender instanceof Player) {
|
||||||
Player player = (Player) sender;
|
Player player = (Player) sender;
|
||||||
ChatManager.handleAdminChat(mcMMO.p, player.getName(), player.getDisplayName(), message);
|
ChatManager.handleAdminChat(mcMMO.p, player.getName(), player.getDisplayName(), buildChatMessage(args, 0));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
ChatManager.handleAdminChat(mcMMO.p, LocaleLoader.getString("Commands.Chat.Console"), message);
|
ChatManager.handleAdminChat(mcMMO.p, LocaleLoader.getString("Commands.Chat.Console"), buildChatMessage(args, 0));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,4 +1,4 @@
|
|||||||
package com.gmail.nossr50.chat.commands;
|
package com.gmail.nossr50.commands.chat;
|
||||||
|
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandExecutor;
|
import org.bukkit.command.CommandExecutor;
|
||||||
@ -6,8 +6,8 @@ import org.bukkit.command.CommandSender;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import com.gmail.nossr50.chat.ChatMode;
|
import com.gmail.nossr50.chat.ChatMode;
|
||||||
import com.gmail.nossr50.datatypes.McMMOPlayer;
|
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||||
import com.gmail.nossr50.util.Users;
|
import com.gmail.nossr50.util.player.UserManager;
|
||||||
|
|
||||||
public abstract class ChatCommand implements CommandExecutor {
|
public abstract class ChatCommand implements CommandExecutor {
|
||||||
protected McMMOPlayer mcMMOPlayer;
|
protected McMMOPlayer mcMMOPlayer;
|
||||||
@ -25,7 +25,7 @@ public abstract class ChatCommand implements CommandExecutor {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
mcMMOPlayer = Users.getPlayer((Player) sender);
|
mcMMOPlayer = UserManager.getPlayer((Player) sender);
|
||||||
|
|
||||||
if (chatMode.isEnabled(mcMMOPlayer)) {
|
if (chatMode.isEnabled(mcMMOPlayer)) {
|
||||||
disableChatMode(sender);
|
disableChatMode(sender);
|
||||||
@ -36,8 +36,7 @@ public abstract class ChatCommand implements CommandExecutor {
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
default:
|
case 1:
|
||||||
if (args.length == 1) {
|
|
||||||
if (args[0].equalsIgnoreCase("on")) {
|
if (args[0].equalsIgnoreCase("on")) {
|
||||||
if (!(sender instanceof Player)) {
|
if (!(sender instanceof Player)) {
|
||||||
return false;
|
return false;
|
||||||
@ -55,23 +54,15 @@ public abstract class ChatCommand implements CommandExecutor {
|
|||||||
disableChatMode(sender);
|
disableChatMode(sender);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
// Fallthrough
|
||||||
|
|
||||||
|
default:
|
||||||
handleChatSending(sender, args);
|
handleChatSending(sender, args);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void enableChatMode(CommandSender sender) {
|
|
||||||
chatMode.enable(mcMMOPlayer);
|
|
||||||
sender.sendMessage(chatMode.getEnabledMessage());
|
|
||||||
}
|
|
||||||
|
|
||||||
private void disableChatMode(CommandSender sender) {
|
|
||||||
chatMode.disable(mcMMOPlayer);
|
|
||||||
sender.sendMessage(chatMode.getDisabledMessage());
|
|
||||||
}
|
|
||||||
|
|
||||||
protected String buildChatMessage(String[] args, int index) {
|
protected String buildChatMessage(String[] args, int index) {
|
||||||
StringBuilder builder = new StringBuilder();
|
StringBuilder builder = new StringBuilder();
|
||||||
builder.append(args[index]);
|
builder.append(args[index]);
|
||||||
@ -85,4 +76,14 @@ public abstract class ChatCommand implements CommandExecutor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected abstract void handleChatSending(CommandSender sender, String[] args);
|
protected abstract void handleChatSending(CommandSender sender, String[] args);
|
||||||
|
|
||||||
|
private void enableChatMode(CommandSender sender) {
|
||||||
|
chatMode.enable(mcMMOPlayer);
|
||||||
|
sender.sendMessage(chatMode.getEnabledMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void disableChatMode(CommandSender sender) {
|
||||||
|
chatMode.disable(mcMMOPlayer);
|
||||||
|
sender.sendMessage(chatMode.getDisabledMessage());
|
||||||
|
}
|
||||||
}
|
}
|
@ -1,4 +1,4 @@
|
|||||||
package com.gmail.nossr50.chat.commands;
|
package com.gmail.nossr50.commands.chat;
|
||||||
|
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -6,10 +6,10 @@ import org.bukkit.entity.Player;
|
|||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.gmail.nossr50.chat.ChatManager;
|
import com.gmail.nossr50.chat.ChatManager;
|
||||||
import com.gmail.nossr50.chat.ChatMode;
|
import com.gmail.nossr50.chat.ChatMode;
|
||||||
|
import com.gmail.nossr50.datatypes.party.Party;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.party.Party;
|
|
||||||
import com.gmail.nossr50.party.PartyManager;
|
import com.gmail.nossr50.party.PartyManager;
|
||||||
import com.gmail.nossr50.util.Users;
|
import com.gmail.nossr50.util.player.UserManager;
|
||||||
|
|
||||||
public class PartyChatCommand extends ChatCommand {
|
public class PartyChatCommand extends ChatCommand {
|
||||||
public PartyChatCommand() {
|
public PartyChatCommand() {
|
||||||
@ -20,7 +20,7 @@ public class PartyChatCommand extends ChatCommand {
|
|||||||
protected void handleChatSending(CommandSender sender, String[] args) {
|
protected void handleChatSending(CommandSender sender, String[] args) {
|
||||||
if (sender instanceof Player) {
|
if (sender instanceof Player) {
|
||||||
Player player = (Player) sender;
|
Player player = (Player) sender;
|
||||||
Party party = Users.getPlayer(player).getParty();
|
Party party = UserManager.getPlayer(player).getParty();
|
||||||
|
|
||||||
if (party == null) {
|
if (party == null) {
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.Party.None"));
|
sender.sendMessage(LocaleLoader.getString("Commands.Party.None"));
|
@ -0,0 +1,45 @@
|
|||||||
|
package com.gmail.nossr50.commands.database;
|
||||||
|
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandExecutor;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
|
import com.gmail.nossr50.config.Config;
|
||||||
|
import com.gmail.nossr50.database.DatabaseManager;
|
||||||
|
import com.gmail.nossr50.database.LeaderboardManager;
|
||||||
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
|
import com.gmail.nossr50.util.Permissions;
|
||||||
|
|
||||||
|
public class McpurgeCommand implements CommandExecutor {
|
||||||
|
@Override
|
||||||
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
|
if (!Permissions.mcpurge(sender)) {
|
||||||
|
sender.sendMessage(command.getPermissionMessage());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (args.length) {
|
||||||
|
case 0:
|
||||||
|
if (Config.getInstance().getUseMySQL()) {
|
||||||
|
DatabaseManager.purgePowerlessSQL();
|
||||||
|
|
||||||
|
if (Config.getInstance().getOldUsersCutoff() != -1) {
|
||||||
|
DatabaseManager.purgeOldSQL();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
LeaderboardManager.purgePowerlessFlatfile();
|
||||||
|
|
||||||
|
if (Config.getInstance().getOldUsersCutoff() != -1) {
|
||||||
|
LeaderboardManager.purgeOldFlatfile();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
sender.sendMessage(LocaleLoader.getString("Commands.mcpurge.Success"));
|
||||||
|
return true;
|
||||||
|
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,51 @@
|
|||||||
|
package com.gmail.nossr50.commands.database;
|
||||||
|
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandExecutor;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
|
import com.gmail.nossr50.config.Config;
|
||||||
|
import com.gmail.nossr50.database.DatabaseManager;
|
||||||
|
import com.gmail.nossr50.database.LeaderboardManager;
|
||||||
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
|
import com.gmail.nossr50.util.Permissions;
|
||||||
|
|
||||||
|
public class McremoveCommand implements CommandExecutor {
|
||||||
|
@Override
|
||||||
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
|
if (!Permissions.mcremove(sender)) {
|
||||||
|
sender.sendMessage(command.getPermissionMessage());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (args.length) {
|
||||||
|
case 1:
|
||||||
|
/* MySQL */
|
||||||
|
if (Config.getInstance().getUseMySQL()) {
|
||||||
|
String tablePrefix = Config.getInstance().getMySQLTablePrefix();
|
||||||
|
|
||||||
|
if (DatabaseManager.update("DELETE FROM " + tablePrefix + "users WHERE " + tablePrefix + "users.user = '" + args[0] + "'") != 0) {
|
||||||
|
DatabaseManager.profileCleanup(args[0]);
|
||||||
|
sender.sendMessage(LocaleLoader.getString("Commands.mcremove.Success", args[0]));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (LeaderboardManager.removeFlatFileUser(args[0])) {
|
||||||
|
DatabaseManager.profileCleanup(args[0]);
|
||||||
|
sender.sendMessage(LocaleLoader.getString("Commands.mcremove.Success", args[0]));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,51 @@
|
|||||||
|
package com.gmail.nossr50.commands.database;
|
||||||
|
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandExecutor;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import com.gmail.nossr50.mcMMO;
|
||||||
|
import com.gmail.nossr50.config.Config;
|
||||||
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
|
import com.gmail.nossr50.runnables.database.SQLConversionTask;
|
||||||
|
import com.gmail.nossr50.util.Permissions;
|
||||||
|
import com.gmail.nossr50.util.player.UserManager;
|
||||||
|
|
||||||
|
public class MmoupdateCommand implements CommandExecutor {
|
||||||
|
@Override
|
||||||
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
|
if (!Permissions.mmoupdate(sender)) {
|
||||||
|
sender.sendMessage(command.getPermissionMessage());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (args.length) {
|
||||||
|
case 0:
|
||||||
|
sender.sendMessage(LocaleLoader.getString("Commands.mmoupdate.Start"));
|
||||||
|
UserManager.clearAll();
|
||||||
|
convertToMySQL();
|
||||||
|
|
||||||
|
for (Player player : mcMMO.p.getServer().getOnlinePlayers()) {
|
||||||
|
UserManager.addUser(player);
|
||||||
|
}
|
||||||
|
|
||||||
|
sender.sendMessage(LocaleLoader.getString("Commands.mmoupdate.Finish"));
|
||||||
|
return true;
|
||||||
|
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert FlatFile data to MySQL data.
|
||||||
|
*/
|
||||||
|
private void convertToMySQL() {
|
||||||
|
if (!Config.getInstance().getUseMySQL()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
mcMMO.p.getServer().getScheduler().runTaskLaterAsynchronously(mcMMO.p, new SQLConversionTask(), 1);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,154 @@
|
|||||||
|
package com.gmail.nossr50.commands.experience;
|
||||||
|
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandExecutor;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||||
|
import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
||||||
|
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||||
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
|
import com.gmail.nossr50.util.Permissions;
|
||||||
|
import com.gmail.nossr50.util.StringUtils;
|
||||||
|
import com.gmail.nossr50.util.player.UserManager;
|
||||||
|
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||||
|
|
||||||
|
public class AddlevelsCommand implements CommandExecutor {
|
||||||
|
@Override
|
||||||
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
|
PlayerProfile profile;
|
||||||
|
int levels;
|
||||||
|
boolean allSkills = false;
|
||||||
|
SkillType skill = null;
|
||||||
|
|
||||||
|
switch (args.length) {
|
||||||
|
case 2:
|
||||||
|
if (!Permissions.addlevels(sender)) {
|
||||||
|
sender.sendMessage(command.getPermissionMessage());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!(sender instanceof Player)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args[0].equalsIgnoreCase("all")) {
|
||||||
|
allSkills = true;
|
||||||
|
}
|
||||||
|
else if (!SkillUtils.isSkill(args[0])) {
|
||||||
|
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!StringUtils.isInt(args[1])) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
levels = Integer.parseInt(args[1]);
|
||||||
|
profile = UserManager.getPlayer((Player) sender).getProfile();
|
||||||
|
|
||||||
|
if (allSkills) {
|
||||||
|
for (SkillType skillType : SkillType.values()) {
|
||||||
|
if (skillType.isChildSkill()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
profile.addLevels(skillType, levels);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
skill = SkillType.getSkill(args[0]);
|
||||||
|
profile.addLevels(skill, levels);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (allSkills) {
|
||||||
|
sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardAll.1", levels));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardSkill.1", levels, SkillUtils.getSkillName(skill)));
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
|
||||||
|
case 3:
|
||||||
|
if (!Permissions.addlevelsOthers(sender)) {
|
||||||
|
sender.sendMessage(command.getPermissionMessage());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args[1].equalsIgnoreCase("all")) {
|
||||||
|
allSkills = true;
|
||||||
|
}
|
||||||
|
else if (!SkillUtils.isSkill(args[1])) {
|
||||||
|
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!StringUtils.isInt(args[2])) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(args[0]);
|
||||||
|
levels = Integer.parseInt(args[2]);
|
||||||
|
|
||||||
|
// 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) {
|
||||||
|
profile = new PlayerProfile(args[0], false);
|
||||||
|
|
||||||
|
if (!profile.isLoaded()) {
|
||||||
|
sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (allSkills) {
|
||||||
|
for (SkillType skillType : SkillType.values()) {
|
||||||
|
if (skillType.isChildSkill()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
profile.addLevels(skillType, levels);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
skill = SkillType.getSkill(args[1]);
|
||||||
|
profile.addLevels(skill, levels);
|
||||||
|
}
|
||||||
|
|
||||||
|
profile.save(); // Since this is a temporary profile, we save it here.
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
profile = mcMMOPlayer.getProfile();
|
||||||
|
|
||||||
|
if (allSkills) {
|
||||||
|
for (SkillType skillType : SkillType.values()) {
|
||||||
|
if (skillType.isChildSkill()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
profile.addLevels(skillType, levels);
|
||||||
|
}
|
||||||
|
|
||||||
|
mcMMOPlayer.getPlayer().sendMessage(LocaleLoader.getString("Commands.addlevels.AwardAll.1", levels));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
skill = SkillType.getSkill(args[1]);
|
||||||
|
profile.addLevels(skill, levels);
|
||||||
|
mcMMOPlayer.getPlayer().sendMessage(LocaleLoader.getString("Commands.addlevels.AwardSkill.1", levels, SkillUtils.getSkillName(skill)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (allSkills) {
|
||||||
|
sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardAll.2", args[0]));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardSkill.2", SkillUtils.getSkillName(skill), args[0]));
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,152 @@
|
|||||||
|
package com.gmail.nossr50.commands.experience;
|
||||||
|
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandExecutor;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||||
|
import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
||||||
|
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||||
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
|
import com.gmail.nossr50.util.Permissions;
|
||||||
|
import com.gmail.nossr50.util.StringUtils;
|
||||||
|
import com.gmail.nossr50.util.player.UserManager;
|
||||||
|
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||||
|
|
||||||
|
public class AddxpCommand implements CommandExecutor {
|
||||||
|
@Override
|
||||||
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
|
int xp;
|
||||||
|
McMMOPlayer mcMMOPlayer;
|
||||||
|
PlayerProfile profile;
|
||||||
|
boolean allSkills = false;
|
||||||
|
SkillType skill = null;
|
||||||
|
|
||||||
|
switch (args.length) {
|
||||||
|
case 2:
|
||||||
|
if (!Permissions.addxp(sender)) {
|
||||||
|
sender.sendMessage(command.getPermissionMessage());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!(sender instanceof Player)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args[0].equalsIgnoreCase("all")) {
|
||||||
|
allSkills = true;
|
||||||
|
}
|
||||||
|
else if (!SkillUtils.isSkill(args[0])) {
|
||||||
|
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!StringUtils.isInt(args[1])) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
xp = Integer.parseInt(args[1]);
|
||||||
|
mcMMOPlayer = UserManager.getPlayer((Player) sender);
|
||||||
|
profile = mcMMOPlayer.getProfile();
|
||||||
|
|
||||||
|
if (allSkills) {
|
||||||
|
for (SkillType skillType : SkillType.values()) {
|
||||||
|
if (skillType.isChildSkill()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
mcMMOPlayer.applyXpGain(skillType, xp);
|
||||||
|
}
|
||||||
|
|
||||||
|
sender.sendMessage(LocaleLoader.getString("Commands.addxp.AwardAll", xp));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
skill = SkillType.getSkill(args[0]);
|
||||||
|
|
||||||
|
mcMMOPlayer.applyXpGain(skill, xp);
|
||||||
|
sender.sendMessage(LocaleLoader.getString("Commands.addxp.AwardSkill", xp, SkillUtils.getSkillName(skill)));
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
|
||||||
|
case 3:
|
||||||
|
if (!Permissions.addxpOthers(sender)) {
|
||||||
|
sender.sendMessage(command.getPermissionMessage());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args[1].equalsIgnoreCase("all")) {
|
||||||
|
allSkills = true;
|
||||||
|
}
|
||||||
|
else if (!SkillUtils.isSkill(args[1])) {
|
||||||
|
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!StringUtils.isInt(args[2])) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
mcMMOPlayer = UserManager.getPlayer(args[0]);
|
||||||
|
xp = Integer.parseInt(args[2]);
|
||||||
|
|
||||||
|
// 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) {
|
||||||
|
profile = new PlayerProfile(args[0], false);
|
||||||
|
|
||||||
|
if (!profile.isLoaded()) {
|
||||||
|
sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: Currently the offline player doesn't level up automatically
|
||||||
|
if (allSkills) {
|
||||||
|
for (SkillType skillType : SkillType.values()) {
|
||||||
|
if (skillType.isChildSkill()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
profile.setSkillXpLevel(skillType, xp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
skill = SkillType.getSkill(args[1]);
|
||||||
|
profile.setSkillXpLevel(skill, xp);
|
||||||
|
}
|
||||||
|
|
||||||
|
profile.save(); // Since this is a temporary profile, we save it here.
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (allSkills) {
|
||||||
|
for (SkillType skillType : SkillType.values()) {
|
||||||
|
if (skillType.isChildSkill()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
mcMMOPlayer.applyXpGain(skillType, xp);
|
||||||
|
}
|
||||||
|
|
||||||
|
mcMMOPlayer.getPlayer().sendMessage(LocaleLoader.getString("Commands.addxp.AwardAll", xp));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
skill = SkillType.getSkill(args[1]);
|
||||||
|
mcMMOPlayer.applyXpGain(skill, xp);
|
||||||
|
mcMMOPlayer.getPlayer().sendMessage(LocaleLoader.getString("Commands.addxp.AwardSkill", xp, SkillUtils.getSkillName(skill)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (allSkills) {
|
||||||
|
sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardAll.2", args[0]));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardSkill.2", SkillUtils.getSkillName(skill), args[0]));
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,150 @@
|
|||||||
|
package com.gmail.nossr50.commands.experience;
|
||||||
|
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandExecutor;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||||
|
import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
||||||
|
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||||
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
|
import com.gmail.nossr50.util.Permissions;
|
||||||
|
import com.gmail.nossr50.util.StringUtils;
|
||||||
|
import com.gmail.nossr50.util.player.UserManager;
|
||||||
|
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||||
|
|
||||||
|
public class MmoeditCommand implements CommandExecutor {
|
||||||
|
@Override
|
||||||
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
|
PlayerProfile profile;
|
||||||
|
int newValue;
|
||||||
|
boolean allSkills = false;
|
||||||
|
SkillType skill = null;
|
||||||
|
|
||||||
|
switch (args.length) {
|
||||||
|
case 2:
|
||||||
|
if (!Permissions.mmoedit(sender)) {
|
||||||
|
sender.sendMessage(command.getPermissionMessage());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!(sender instanceof Player)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args[0].equalsIgnoreCase("all")) {
|
||||||
|
allSkills = true;
|
||||||
|
}
|
||||||
|
else if (!SkillUtils.isSkill(args[0])) {
|
||||||
|
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!StringUtils.isInt(args[1])) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
newValue = Integer.parseInt(args[1]);
|
||||||
|
profile = UserManager.getPlayer((Player) sender).getProfile();
|
||||||
|
|
||||||
|
if (allSkills) {
|
||||||
|
for (SkillType skillType : SkillType.values()) {
|
||||||
|
if (skillType.isChildSkill()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
profile.modifySkill(skillType, newValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
sender.sendMessage(LocaleLoader.getString("Commands.mmoedit.AllSkills.1", newValue));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
skill = SkillType.getSkill(args[0]);
|
||||||
|
profile.modifySkill(skill, newValue);
|
||||||
|
sender.sendMessage(LocaleLoader.getString("Commands.mmoedit.Modified.1", SkillUtils.getSkillName(skill), newValue));
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
|
||||||
|
case 3:
|
||||||
|
if (!Permissions.mmoeditOthers(sender)) {
|
||||||
|
sender.sendMessage(command.getPermissionMessage());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args[1].equalsIgnoreCase("all")) {
|
||||||
|
allSkills = true;
|
||||||
|
}
|
||||||
|
else if (!SkillUtils.isSkill(args[1])) {
|
||||||
|
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!StringUtils.isInt(args[2])) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
newValue = Integer.parseInt(args[2]);
|
||||||
|
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(args[0]);
|
||||||
|
|
||||||
|
// 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) {
|
||||||
|
profile = new PlayerProfile(args[0], false);
|
||||||
|
|
||||||
|
if (!profile.isLoaded()) {
|
||||||
|
sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (allSkills) {
|
||||||
|
for (SkillType skillType : SkillType.values()) {
|
||||||
|
if (skillType.isChildSkill()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
profile.modifySkill(skillType, newValue);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
skill = SkillType.getSkill(args[1]);
|
||||||
|
profile.modifySkill(skill, newValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
profile.save(); // Since this is a temporary profile, we save it here.
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
profile = mcMMOPlayer.getProfile();
|
||||||
|
|
||||||
|
if (allSkills) {
|
||||||
|
for (SkillType skillType : SkillType.values()) {
|
||||||
|
if (skillType.isChildSkill()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
profile.modifySkill(skillType, newValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
mcMMOPlayer.getPlayer().sendMessage(LocaleLoader.getString("Commands.mmoedit.AllSkills.1", newValue));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
skill = SkillType.getSkill(args[1]);
|
||||||
|
profile.modifySkill(skill, newValue);
|
||||||
|
mcMMOPlayer.getPlayer().sendMessage(LocaleLoader.getString("Commands.mmoedit.Modified.1", SkillUtils.getSkillName(skill), newValue));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (allSkills) {
|
||||||
|
sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardAll.2", args[0]));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
sender.sendMessage(LocaleLoader.getString("Commands.mmoedit.Modified.2", SkillUtils.getSkillName(skill), args[0]));
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,169 @@
|
|||||||
|
package com.gmail.nossr50.commands.experience;
|
||||||
|
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandExecutor;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||||
|
import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
||||||
|
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||||
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
|
import com.gmail.nossr50.util.Permissions;
|
||||||
|
import com.gmail.nossr50.util.player.UserManager;
|
||||||
|
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||||
|
|
||||||
|
public class SkillresetCommand implements CommandExecutor {
|
||||||
|
@Override
|
||||||
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
|
PlayerProfile profile;
|
||||||
|
boolean allSkills = false;
|
||||||
|
SkillType skill = null;
|
||||||
|
String skillName = "";
|
||||||
|
|
||||||
|
switch (args.length) {
|
||||||
|
case 1:
|
||||||
|
if (!Permissions.skillreset(sender)) {
|
||||||
|
sender.sendMessage(command.getPermissionMessage());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!(sender instanceof Player)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args[0].equalsIgnoreCase("all")) {
|
||||||
|
allSkills = true;
|
||||||
|
}
|
||||||
|
else if (!SkillUtils.isSkill(args[0])) {
|
||||||
|
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
profile = UserManager.getPlayer((Player) sender).getProfile();
|
||||||
|
|
||||||
|
if (allSkills) {
|
||||||
|
for (SkillType skillType : SkillType.values()) {
|
||||||
|
if (skillType.isChildSkill()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!Permissions.skillreset(sender, skillType)) {
|
||||||
|
sender.sendMessage(command.getPermissionMessage());
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
profile.modifySkill(skillType, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
sender.sendMessage(LocaleLoader.getString("Commands.Reset.All"));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
skill = SkillType.getSkill(args[0]);
|
||||||
|
skillName = SkillUtils.getSkillName(skill);
|
||||||
|
|
||||||
|
if (!Permissions.skillreset(sender, skill)) {
|
||||||
|
sender.sendMessage(command.getPermissionMessage());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
profile.modifySkill(skill, 0);
|
||||||
|
sender.sendMessage(LocaleLoader.getString("Commands.Reset.Single", skillName));
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
|
||||||
|
case 2:
|
||||||
|
if (!Permissions.skillresetOthers(sender)) {
|
||||||
|
sender.sendMessage(command.getPermissionMessage());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args[1].equalsIgnoreCase("all")) {
|
||||||
|
allSkills = true;
|
||||||
|
}
|
||||||
|
else if (!SkillUtils.isSkill(args[1])) {
|
||||||
|
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!allSkills) {
|
||||||
|
skill = SkillType.getSkill(args[1]);
|
||||||
|
skillName = SkillUtils.getSkillName(skill);
|
||||||
|
|
||||||
|
if (!Permissions.skillresetOthers(sender, skill)) {
|
||||||
|
sender.sendMessage(command.getPermissionMessage());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(args[0]);
|
||||||
|
|
||||||
|
// 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) {
|
||||||
|
profile = new PlayerProfile(args[0], false);
|
||||||
|
|
||||||
|
if (!profile.isLoaded()) {
|
||||||
|
sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (allSkills) {
|
||||||
|
for (SkillType skillType : SkillType.values()) {
|
||||||
|
if (skillType.isChildSkill()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!Permissions.skillresetOthers(sender, skill)) {
|
||||||
|
sender.sendMessage(command.getPermissionMessage());
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
profile.modifySkill(skillType, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
profile.modifySkill(skill, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
profile.save(); // Since this is a temporary profile, we save it here.
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
profile = mcMMOPlayer.getProfile();
|
||||||
|
|
||||||
|
if (allSkills) {
|
||||||
|
for (SkillType skillType : SkillType.values()) {
|
||||||
|
if (skillType.isChildSkill()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!Permissions.skillresetOthers(sender, skillType)) {
|
||||||
|
sender.sendMessage(command.getPermissionMessage());
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
profile.modifySkill(skillType, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
mcMMOPlayer.getPlayer().sendMessage(LocaleLoader.getString("Commands.Reset.All"));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
profile.modifySkill(skill, 0);
|
||||||
|
mcMMOPlayer.getPlayer().sendMessage(LocaleLoader.getString("Commands.Reset.Single", skillName));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (allSkills) {
|
||||||
|
sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardAll.2", args[0]));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
sender.sendMessage(LocaleLoader.getString("Commands.mmoedit.Modified.2", skillName, args[0]));
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,85 @@
|
|||||||
|
package com.gmail.nossr50.commands.hardcore;
|
||||||
|
|
||||||
|
import java.text.DecimalFormat;
|
||||||
|
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandExecutor;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
|
import com.gmail.nossr50.mcMMO;
|
||||||
|
import com.gmail.nossr50.config.Config;
|
||||||
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
|
import com.gmail.nossr50.util.Permissions;
|
||||||
|
import com.gmail.nossr50.util.StringUtils;
|
||||||
|
|
||||||
|
public class HardcoreCommand implements CommandExecutor {
|
||||||
|
@Override
|
||||||
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
|
switch (args.length) {
|
||||||
|
case 0:
|
||||||
|
if (!Permissions.hardcoreToggle(sender)) {
|
||||||
|
sender.sendMessage(command.getPermissionMessage());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Config.getInstance().getHardcoreEnabled()) {
|
||||||
|
disableHardcore();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
enableHardcore();
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
|
||||||
|
case 1:
|
||||||
|
if (args[0].equalsIgnoreCase("on") || args[0].equalsIgnoreCase("true") || args[0].equalsIgnoreCase("enabled")) {
|
||||||
|
if (!Permissions.hardcoreToggle(sender)) {
|
||||||
|
sender.sendMessage(command.getPermissionMessage());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
enableHardcore();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args[0].equalsIgnoreCase("off") || args[0].equalsIgnoreCase("false") || args[0].equalsIgnoreCase("disabled")) {
|
||||||
|
if (!Permissions.hardcoreToggle(sender)) {
|
||||||
|
sender.sendMessage(command.getPermissionMessage());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
disableHardcore();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!StringUtils.isDouble(args[0])) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!Permissions.hardcoreModify(sender)) {
|
||||||
|
sender.sendMessage(command.getPermissionMessage());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
DecimalFormat percent = new DecimalFormat("##0.00%");
|
||||||
|
double newPercent = Double.parseDouble(args[0]);
|
||||||
|
|
||||||
|
Config.getInstance().setHardcoreDeathStatPenaltyPercentage(newPercent);
|
||||||
|
sender.sendMessage(LocaleLoader.getString("Hardcore.PercentageChanged", percent.format(newPercent / 100D)));
|
||||||
|
return true;
|
||||||
|
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void disableHardcore() {
|
||||||
|
Config.getInstance().setHardcoreEnabled(false);
|
||||||
|
mcMMO.p.getServer().broadcastMessage(LocaleLoader.getString("Hardcore.Disabled"));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void enableHardcore() {
|
||||||
|
Config.getInstance().setHardcoreEnabled(true);
|
||||||
|
mcMMO.p.getServer().broadcastMessage(LocaleLoader.getString("Hardcore.Enabled"));
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,90 @@
|
|||||||
|
package com.gmail.nossr50.commands.hardcore;
|
||||||
|
|
||||||
|
import java.text.DecimalFormat;
|
||||||
|
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandExecutor;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
|
import com.gmail.nossr50.mcMMO;
|
||||||
|
import com.gmail.nossr50.config.Config;
|
||||||
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
|
import com.gmail.nossr50.util.Permissions;
|
||||||
|
import com.gmail.nossr50.util.StringUtils;
|
||||||
|
|
||||||
|
public class VampirismCommand implements CommandExecutor {
|
||||||
|
@Override
|
||||||
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
|
if (!Config.getInstance().getHardcoreEnabled()) {
|
||||||
|
sender.sendMessage(LocaleLoader.getString("Hardcore.Disabled"));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (args.length) {
|
||||||
|
case 0:
|
||||||
|
if (!Permissions.vampirismToggle(sender)) {
|
||||||
|
sender.sendMessage(command.getPermissionMessage());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Config.getInstance().getHardcoreVampirismEnabled()) {
|
||||||
|
disableVampirism();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
enableVampirism();
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
|
||||||
|
case 1:
|
||||||
|
if (args[0].equalsIgnoreCase("on") || args[0].equalsIgnoreCase("true") || args[0].equalsIgnoreCase("enabled")) {
|
||||||
|
if (!Permissions.vampirismToggle(sender)) {
|
||||||
|
sender.sendMessage(command.getPermissionMessage());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
enableVampirism();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args[0].equalsIgnoreCase("off") || args[0].equalsIgnoreCase("false") || args[0].equalsIgnoreCase("disabled")) {
|
||||||
|
if (!Permissions.vampirismToggle(sender)) {
|
||||||
|
sender.sendMessage(command.getPermissionMessage());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
disableVampirism();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!StringUtils.isDouble(args[0])) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!Permissions.vampirismModify(sender)) {
|
||||||
|
sender.sendMessage(command.getPermissionMessage());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
DecimalFormat percent = new DecimalFormat("##0.00%");
|
||||||
|
double newPercent = Double.parseDouble(args[0]);
|
||||||
|
|
||||||
|
Config.getInstance().setHardcoreVampirismStatLeechPercentage(newPercent);
|
||||||
|
sender.sendMessage(LocaleLoader.getString("Vampirism.PercentageChanged", percent.format(newPercent / 100D)));
|
||||||
|
return true;
|
||||||
|
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void disableVampirism() {
|
||||||
|
Config.getInstance().setHardcoreVampirismEnabled(false);
|
||||||
|
mcMMO.p.getServer().broadcastMessage(LocaleLoader.getString("Vampirism.Disabled"));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void enableVampirism() {
|
||||||
|
Config.getInstance().setHardcoreVampirismEnabled(true);
|
||||||
|
mcMMO.p.getServer().broadcastMessage(LocaleLoader.getString("Vampirism.Enabled"));
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,42 @@
|
|||||||
|
package com.gmail.nossr50.commands.party;
|
||||||
|
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandExecutor;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||||
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
|
import com.gmail.nossr50.party.PartyManager;
|
||||||
|
import com.gmail.nossr50.util.player.UserManager;
|
||||||
|
|
||||||
|
public class PartyAcceptCommand implements CommandExecutor {
|
||||||
|
private McMMOPlayer mcMMOPlayer;
|
||||||
|
private Player player;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
|
switch (args.length) {
|
||||||
|
case 1:
|
||||||
|
player = (Player) sender;
|
||||||
|
mcMMOPlayer = UserManager.getPlayer(player);
|
||||||
|
|
||||||
|
if (!mcMMOPlayer.hasPartyInvite()) {
|
||||||
|
sender.sendMessage(LocaleLoader.getString("mcMMO.NoInvites"));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Changing parties
|
||||||
|
if (!PartyManager.changeOrJoinParty(mcMMOPlayer, player, mcMMOPlayer.getParty(), mcMMOPlayer.getPartyInvite().getName())) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
PartyManager.joinInvitedParty(player, mcMMOPlayer);
|
||||||
|
return true;
|
||||||
|
|
||||||
|
default:
|
||||||
|
sender.sendMessage(LocaleLoader.getString("Commands.Usage.1", "party", "accept"));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,34 @@
|
|||||||
|
package com.gmail.nossr50.commands.party;
|
||||||
|
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandExecutor;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import com.gmail.nossr50.mcMMO;
|
||||||
|
import com.gmail.nossr50.datatypes.party.Party;
|
||||||
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
|
import com.gmail.nossr50.party.PartyManager;
|
||||||
|
import com.gmail.nossr50.util.player.UserManager;
|
||||||
|
|
||||||
|
public class PartyChangeOwnerCommand implements CommandExecutor {
|
||||||
|
@Override
|
||||||
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
|
switch (args.length) {
|
||||||
|
case 2:
|
||||||
|
Party playerParty = UserManager.getPlayer((Player) sender).getParty();
|
||||||
|
|
||||||
|
if (!playerParty.getMembers().contains(mcMMO.p.getServer().getOfflinePlayer(args[1]))) {
|
||||||
|
sender.sendMessage(LocaleLoader.getString("Party.NotInYourParty", args[1]));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
PartyManager.setPartyLeader(args[1], playerParty);
|
||||||
|
return true;
|
||||||
|
|
||||||
|
default:
|
||||||
|
sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "owner", "<" + LocaleLoader.getString("Commands.Usage.Player") + ">"));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,19 +1,18 @@
|
|||||||
package com.gmail.nossr50.party.commands;
|
package com.gmail.nossr50.commands.party;
|
||||||
|
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandExecutor;
|
import org.bukkit.command.CommandExecutor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import com.gmail.nossr50.datatypes.party.Party;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.party.Party;
|
import com.gmail.nossr50.util.player.UserManager;
|
||||||
import com.gmail.nossr50.util.Users;
|
|
||||||
|
|
||||||
public class PartyChangePasswordCommand implements CommandExecutor {
|
public class PartyChangePasswordCommand implements CommandExecutor {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
Party playerParty = Users.getPlayer((Player) sender).getParty();
|
Party playerParty = UserManager.getPlayer((Player) sender).getParty();
|
||||||
|
|
||||||
switch (args.length) {
|
switch (args.length) {
|
||||||
case 1:
|
case 1:
|
154
src/main/java/com/gmail/nossr50/commands/party/PartyCommand.java
Normal file
154
src/main/java/com/gmail/nossr50/commands/party/PartyCommand.java
Normal file
@ -0,0 +1,154 @@
|
|||||||
|
package com.gmail.nossr50.commands.party;
|
||||||
|
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandExecutor;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import com.gmail.nossr50.commands.chat.PartyChatCommand;
|
||||||
|
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||||
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
|
import com.gmail.nossr50.util.Permissions;
|
||||||
|
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||||
|
import com.gmail.nossr50.util.player.UserManager;
|
||||||
|
|
||||||
|
public class PartyCommand implements CommandExecutor {
|
||||||
|
private McMMOPlayer mcMMOPlayer;
|
||||||
|
private Player player;
|
||||||
|
|
||||||
|
private CommandExecutor partyJoinCommand = new PartyJoinCommand();
|
||||||
|
private CommandExecutor partyAcceptCommand = new PartyAcceptCommand();
|
||||||
|
private CommandExecutor partyCreateCommand = new PartyCreateCommand();
|
||||||
|
private CommandExecutor partyQuitCommand = new PartyQuitCommand();
|
||||||
|
private CommandExecutor partyExpShareCommand = new PartyExpShareCommand();
|
||||||
|
private CommandExecutor partyItemShareCommand = new PartyItemShareCommand();
|
||||||
|
private CommandExecutor partyInviteCommand = new PartyInviteCommand();
|
||||||
|
private CommandExecutor partyKickCommand = new PartyKickCommand();
|
||||||
|
private CommandExecutor partyDisbandCommand = new PartyDisbandCommand();
|
||||||
|
private CommandExecutor partyChangeOwnerCommand = new PartyChangeOwnerCommand();
|
||||||
|
private CommandExecutor partyLockCommand = new PartyLockCommand();
|
||||||
|
private CommandExecutor partyChangePasswordCommand = new PartyChangePasswordCommand();
|
||||||
|
private CommandExecutor partyRenameCommand = new PartyRenameCommand();
|
||||||
|
private CommandExecutor partyInfoCommand = new PartyInfoCommand();
|
||||||
|
private CommandExecutor partyHelpCommand = new PartyHelpCommand();
|
||||||
|
private CommandExecutor partyTeleportCommand = new PtpCommand();
|
||||||
|
private CommandExecutor partyChatCommand = new PartyChatCommand();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
|
if (CommandUtils.noConsoleUsage(sender)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!Permissions.party(sender)) {
|
||||||
|
sender.sendMessage(command.getPermissionMessage());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
player = (Player) sender;
|
||||||
|
mcMMOPlayer = UserManager.getPlayer(player);
|
||||||
|
|
||||||
|
if (args.length < 1) {
|
||||||
|
if (!mcMMOPlayer.inParty()) {
|
||||||
|
sender.sendMessage(LocaleLoader.getString("Commands.Party.None"));
|
||||||
|
return printUsage();
|
||||||
|
}
|
||||||
|
|
||||||
|
return partyInfoCommand.onCommand(sender, command, label, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
PartySubcommandType subcommand = PartySubcommandType.getSubcommand(args[0]);
|
||||||
|
|
||||||
|
if (subcommand == null) {
|
||||||
|
return printUsage();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Can't use this for lock/unlock since they're handled by the same command
|
||||||
|
if (subcommand != PartySubcommandType.LOCK && subcommand != PartySubcommandType.UNLOCK && !Permissions.partySubcommand(sender, subcommand)) {
|
||||||
|
sender.sendMessage(command.getPermissionMessage());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (subcommand) {
|
||||||
|
case JOIN:
|
||||||
|
return partyJoinCommand.onCommand(sender, command, label, args);
|
||||||
|
case ACCEPT:
|
||||||
|
return partyAcceptCommand.onCommand(sender, command, label, args);
|
||||||
|
case CREATE:
|
||||||
|
return partyCreateCommand.onCommand(sender, command, label, args);
|
||||||
|
case HELP:
|
||||||
|
return partyHelpCommand.onCommand(sender, command, label, args);
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Party member commands
|
||||||
|
if (!mcMMOPlayer.inParty()) {
|
||||||
|
sender.sendMessage(LocaleLoader.getString("Commands.Party.None"));
|
||||||
|
return printUsage();
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (subcommand) {
|
||||||
|
case INFO:
|
||||||
|
return partyInfoCommand.onCommand(sender, command, label, args);
|
||||||
|
case QUIT:
|
||||||
|
return partyQuitCommand.onCommand(sender, command, label, args);
|
||||||
|
case INVITE:
|
||||||
|
return partyInviteCommand.onCommand(sender, command, label, args);
|
||||||
|
case TELEPORT:
|
||||||
|
return partyTeleportCommand.onCommand(sender, command, label, extractArgs(args));
|
||||||
|
case CHAT:
|
||||||
|
return partyChatCommand.onCommand(sender, command, label, extractArgs(args));
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Party leader commands
|
||||||
|
if (!mcMMOPlayer.getParty().getLeader().equals(player.getName())) {
|
||||||
|
sender.sendMessage(LocaleLoader.getString("Party.NotOwner"));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (subcommand) {
|
||||||
|
case EXPSHARE:
|
||||||
|
return partyExpShareCommand.onCommand(sender, command, label, args);
|
||||||
|
case ITEMSHARE:
|
||||||
|
return partyItemShareCommand.onCommand(sender, command, label, args);
|
||||||
|
case KICK:
|
||||||
|
return partyKickCommand.onCommand(sender, command, label, args);
|
||||||
|
case DISBAND:
|
||||||
|
return partyDisbandCommand.onCommand(sender, command, label, args);
|
||||||
|
case OWNER:
|
||||||
|
return partyChangeOwnerCommand.onCommand(sender, command, label, args);
|
||||||
|
case LOCK:
|
||||||
|
// Fallthrough
|
||||||
|
case UNLOCK:
|
||||||
|
return partyLockCommand.onCommand(sender, command, label, args);
|
||||||
|
case PASSWORD:
|
||||||
|
return partyChangePasswordCommand.onCommand(sender, command, label, args);
|
||||||
|
case RENAME:
|
||||||
|
return partyRenameCommand.onCommand(sender, command, label, args);
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean printUsage() {
|
||||||
|
player.sendMessage(LocaleLoader.getString("Party.Help.0", "/party join"));
|
||||||
|
player.sendMessage(LocaleLoader.getString("Party.Help.1", "/party create"));
|
||||||
|
player.sendMessage(LocaleLoader.getString("Party.Help.2", "/party ?"));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String[] extractArgs(String[] args) {
|
||||||
|
String[] newArgs = new String[args.length - 1];
|
||||||
|
|
||||||
|
for (int i = 1; i < args.length; i++) {
|
||||||
|
newArgs[i - 1] = args[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
return newArgs;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,56 @@
|
|||||||
|
package com.gmail.nossr50.commands.party;
|
||||||
|
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandExecutor;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import com.gmail.nossr50.datatypes.party.Party;
|
||||||
|
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||||
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
|
import com.gmail.nossr50.party.PartyManager;
|
||||||
|
import com.gmail.nossr50.util.player.UserManager;
|
||||||
|
|
||||||
|
public class PartyCreateCommand implements CommandExecutor {
|
||||||
|
private McMMOPlayer mcMMOPlayer;
|
||||||
|
private Player player;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
|
switch (args.length) {
|
||||||
|
case 2:
|
||||||
|
// Fallthrough
|
||||||
|
case 3:
|
||||||
|
Party newParty = PartyManager.getParty(args[1]);
|
||||||
|
|
||||||
|
// Check to see if the party exists, and if it does cancel creating a new party
|
||||||
|
if (newParty != null) {
|
||||||
|
sender.sendMessage(LocaleLoader.getString("Commands.Party.AlreadyExists", args[1]));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
player = (Player) sender;
|
||||||
|
mcMMOPlayer = UserManager.getPlayer(player);
|
||||||
|
|
||||||
|
// Changing parties
|
||||||
|
if (!PartyManager.changeOrJoinParty(mcMMOPlayer, player, mcMMOPlayer.getParty(), args[1])) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
PartyManager.createParty(player, mcMMOPlayer, args[1], getPassword(args));
|
||||||
|
return true;
|
||||||
|
|
||||||
|
default:
|
||||||
|
sender.sendMessage(LocaleLoader.getString("Commands.Usage.3", "party", "create", "<" + LocaleLoader.getString("Commands.Usage.PartyName") + ">", "[" + LocaleLoader.getString("Commands.Usage.Password") + "]"));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getPassword(String[] args) {
|
||||||
|
if (args.length == 3) {
|
||||||
|
return args[2];
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,37 @@
|
|||||||
|
package com.gmail.nossr50.commands.party;
|
||||||
|
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandExecutor;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import com.gmail.nossr50.datatypes.party.Party;
|
||||||
|
import com.gmail.nossr50.events.party.McMMOPartyChangeEvent.EventReason;
|
||||||
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
|
import com.gmail.nossr50.party.PartyManager;
|
||||||
|
import com.gmail.nossr50.util.player.UserManager;
|
||||||
|
|
||||||
|
public class PartyDisbandCommand implements CommandExecutor {
|
||||||
|
@Override
|
||||||
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
|
switch (args.length) {
|
||||||
|
case 1:
|
||||||
|
Party playerParty = UserManager.getPlayer((Player) sender).getParty();
|
||||||
|
|
||||||
|
for (Player member : playerParty.getOnlineMembers()) {
|
||||||
|
if (!PartyManager.handlePartyChangeEvent(member, playerParty.getName(), null, EventReason.KICKED_FROM_PARTY)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
member.sendMessage(LocaleLoader.getString("Party.Disband"));
|
||||||
|
}
|
||||||
|
|
||||||
|
PartyManager.disbandParty(playerParty);
|
||||||
|
return true;
|
||||||
|
|
||||||
|
default:
|
||||||
|
sender.sendMessage(LocaleLoader.getString("Commands.Usage.1", "party", "disband"));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,4 +1,4 @@
|
|||||||
package com.gmail.nossr50.party.commands;
|
package com.gmail.nossr50.commands.party;
|
||||||
|
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandExecutor;
|
import org.bukkit.command.CommandExecutor;
|
||||||
@ -6,12 +6,12 @@ import org.bukkit.command.CommandSender;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import com.gmail.nossr50.config.Config;
|
import com.gmail.nossr50.config.Config;
|
||||||
|
import com.gmail.nossr50.datatypes.party.Party;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.party.Party;
|
|
||||||
import com.gmail.nossr50.party.ShareHandler;
|
import com.gmail.nossr50.party.ShareHandler;
|
||||||
import com.gmail.nossr50.party.ShareHandler.ShareMode;
|
import com.gmail.nossr50.party.ShareHandler.ShareMode;
|
||||||
import com.gmail.nossr50.util.StringUtils;
|
import com.gmail.nossr50.util.StringUtils;
|
||||||
import com.gmail.nossr50.util.Users;
|
import com.gmail.nossr50.util.player.UserManager;
|
||||||
|
|
||||||
public class PartyExpShareCommand implements CommandExecutor {
|
public class PartyExpShareCommand implements CommandExecutor {
|
||||||
private Party playerParty;
|
private Party playerParty;
|
||||||
@ -25,7 +25,7 @@ public class PartyExpShareCommand implements CommandExecutor {
|
|||||||
|
|
||||||
switch (args.length) {
|
switch (args.length) {
|
||||||
case 2:
|
case 2:
|
||||||
playerParty = Users.getPlayer((Player) sender).getParty();
|
playerParty = UserManager.getPlayer((Player) sender).getParty();
|
||||||
|
|
||||||
if (args[1].equalsIgnoreCase("none") || args[1].equalsIgnoreCase("off") || args[1].equalsIgnoreCase("false")) {
|
if (args[1].equalsIgnoreCase("none") || args[1].equalsIgnoreCase("off") || args[1].equalsIgnoreCase("false")) {
|
||||||
handleChangingShareMode(ShareMode.NONE);
|
handleChangingShareMode(ShareMode.NONE);
|
@ -0,0 +1,30 @@
|
|||||||
|
package com.gmail.nossr50.commands.party;
|
||||||
|
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandExecutor;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
|
|
||||||
|
public class PartyHelpCommand implements CommandExecutor {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
|
switch (args.length) {
|
||||||
|
case 1:
|
||||||
|
sender.sendMessage(LocaleLoader.getString("Party.Help.3", "/party join", "/party quit"));
|
||||||
|
sender.sendMessage(LocaleLoader.getString("Party.Help.1", "/party create"));
|
||||||
|
sender.sendMessage(LocaleLoader.getString("Party.Help.4", "/party <lock|unlock>"));
|
||||||
|
sender.sendMessage(LocaleLoader.getString("Party.Help.5", "/party password"));
|
||||||
|
sender.sendMessage(LocaleLoader.getString("Party.Help.6", "/party kick"));
|
||||||
|
sender.sendMessage(LocaleLoader.getString("Party.Help.7", "/party leader"));
|
||||||
|
sender.sendMessage(LocaleLoader.getString("Party.Help.8", "/party disband"));
|
||||||
|
return true;
|
||||||
|
|
||||||
|
default:
|
||||||
|
sender.sendMessage(LocaleLoader.getString("Commands.Usage.1", "party", "help"));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,4 +1,4 @@
|
|||||||
package com.gmail.nossr50.party.commands;
|
package com.gmail.nossr50.commands.party;
|
||||||
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
@ -8,11 +8,12 @@ import org.bukkit.command.CommandSender;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import com.gmail.nossr50.config.Config;
|
import com.gmail.nossr50.config.Config;
|
||||||
import com.gmail.nossr50.datatypes.McMMOPlayer;
|
import com.gmail.nossr50.datatypes.party.Party;
|
||||||
|
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.party.Party;
|
|
||||||
import com.gmail.nossr50.party.PartyManager;
|
import com.gmail.nossr50.party.PartyManager;
|
||||||
import com.gmail.nossr50.util.Users;
|
import com.gmail.nossr50.party.ShareHandler;
|
||||||
|
import com.gmail.nossr50.util.player.UserManager;
|
||||||
|
|
||||||
public class PartyInfoCommand implements CommandExecutor {
|
public class PartyInfoCommand implements CommandExecutor {
|
||||||
private Player player;
|
private Player player;
|
||||||
@ -21,7 +22,7 @@ public class PartyInfoCommand implements CommandExecutor {
|
|||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
player = (Player) sender;
|
player = (Player) sender;
|
||||||
McMMOPlayer mcMMOPlayer = Users.getPlayer(player);
|
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
|
||||||
playerParty = mcMMOPlayer.getParty();
|
playerParty = mcMMOPlayer.getParty();
|
||||||
|
|
||||||
displayPartyHeader();
|
displayPartyHeader();
|
||||||
@ -51,6 +52,7 @@ public class PartyInfoCommand implements CommandExecutor {
|
|||||||
private void displayShareModeInfo() {
|
private void displayShareModeInfo() {
|
||||||
boolean xpShareEnabled = Config.getInstance().getExpShareEnabled();
|
boolean xpShareEnabled = Config.getInstance().getExpShareEnabled();
|
||||||
boolean itemShareEnabled = Config.getInstance().getItemShareEnabled();
|
boolean itemShareEnabled = Config.getInstance().getItemShareEnabled();
|
||||||
|
boolean itemSharingActive = playerParty.getItemShareMode() != ShareHandler.ShareMode.NONE;
|
||||||
|
|
||||||
if (!xpShareEnabled && !itemShareEnabled) {
|
if (!xpShareEnabled && !itemShareEnabled) {
|
||||||
return;
|
return;
|
||||||
@ -73,6 +75,9 @@ public class PartyInfoCommand implements CommandExecutor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
player.sendMessage(LocaleLoader.getString("Commands.Party.ShareMode") + expShareInfo + separator + itemShareInfo);
|
player.sendMessage(LocaleLoader.getString("Commands.Party.ShareMode") + expShareInfo + separator + itemShareInfo);
|
||||||
|
if (itemSharingActive) {
|
||||||
|
player.sendMessage(LocaleLoader.getString("Commands.Party.ItemShareCategories", playerParty.getItemShareCategories()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void displayPartyHeader() {
|
private void displayPartyHeader() {
|
@ -0,0 +1,72 @@
|
|||||||
|
package com.gmail.nossr50.commands.party;
|
||||||
|
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandExecutor;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import com.gmail.nossr50.mcMMO;
|
||||||
|
import com.gmail.nossr50.datatypes.party.Party;
|
||||||
|
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||||
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
|
import com.gmail.nossr50.party.PartyManager;
|
||||||
|
import com.gmail.nossr50.util.player.UserManager;
|
||||||
|
|
||||||
|
public class PartyInviteCommand implements CommandExecutor {
|
||||||
|
private McMMOPlayer mcMMOTarget;
|
||||||
|
private Player target;
|
||||||
|
|
||||||
|
private McMMOPlayer mcMMOPlayer;
|
||||||
|
private Player player;
|
||||||
|
private Party playerParty;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
|
switch (args.length) {
|
||||||
|
case 2:
|
||||||
|
if (!mcMMO.p.getServer().getOfflinePlayer(args[1]).isOnline()) {
|
||||||
|
sender.sendMessage(LocaleLoader.getString("Party.NotOnline", args[1]));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
mcMMOTarget = UserManager.getPlayer(args[1]);
|
||||||
|
|
||||||
|
if (mcMMOTarget == null) {
|
||||||
|
sender.sendMessage(LocaleLoader.getString("Party.Player.Invalid"));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
target = mcMMOTarget.getPlayer();
|
||||||
|
mcMMOPlayer = UserManager.getPlayer((Player) sender);
|
||||||
|
player = mcMMOPlayer.getPlayer();
|
||||||
|
|
||||||
|
if (player.equals(target)) {
|
||||||
|
sender.sendMessage(LocaleLoader.getString("Party.Invite.Self"));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (PartyManager.inSameParty(player, target)) {
|
||||||
|
sender.sendMessage(LocaleLoader.getString("Party.Player.InSameParty", target.getName()));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
playerParty = mcMMOPlayer.getParty();
|
||||||
|
|
||||||
|
if (!PartyManager.canInvite(player, playerParty)) {
|
||||||
|
player.sendMessage(LocaleLoader.getString("Party.Locked"));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
mcMMOTarget.setPartyInvite(playerParty);
|
||||||
|
|
||||||
|
sender.sendMessage(LocaleLoader.getString("Commands.Invite.Success"));
|
||||||
|
target.sendMessage(LocaleLoader.getString("Commands.Party.Invite.0", playerParty.getName(), player.getName()));
|
||||||
|
target.sendMessage(LocaleLoader.getString("Commands.Party.Invite.1"));
|
||||||
|
return true;
|
||||||
|
|
||||||
|
default:
|
||||||
|
sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "invite", "<" + LocaleLoader.getString("Commands.Usage.Player") + ">"));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,101 @@
|
|||||||
|
package com.gmail.nossr50.commands.party;
|
||||||
|
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandExecutor;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import com.gmail.nossr50.config.Config;
|
||||||
|
import com.gmail.nossr50.datatypes.party.Party;
|
||||||
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
|
import com.gmail.nossr50.party.ShareHandler;
|
||||||
|
import com.gmail.nossr50.party.ShareHandler.ShareMode;
|
||||||
|
import com.gmail.nossr50.util.StringUtils;
|
||||||
|
import com.gmail.nossr50.util.player.UserManager;
|
||||||
|
|
||||||
|
public class PartyItemShareCommand implements CommandExecutor {
|
||||||
|
private Party playerParty;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
|
if (!Config.getInstance().getItemShareEnabled()) {
|
||||||
|
sender.sendMessage(LocaleLoader.getString("Party.ItemShare.Disabled"));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (args.length) {
|
||||||
|
case 2:
|
||||||
|
playerParty = UserManager.getPlayer((Player) sender).getParty();
|
||||||
|
|
||||||
|
if (args[1].equalsIgnoreCase("none") || args[1].equalsIgnoreCase("off") || args[1].equalsIgnoreCase("false")) {
|
||||||
|
handleChangingShareMode(ShareMode.NONE);
|
||||||
|
}
|
||||||
|
else if (args[1].equalsIgnoreCase("equal") || args[1].equalsIgnoreCase("even")) {
|
||||||
|
handleChangingShareMode(ShareMode.EQUAL);
|
||||||
|
}
|
||||||
|
else if (args[1].equalsIgnoreCase("random")) {
|
||||||
|
handleChangingShareMode(ShareMode.RANDOM);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "itemshare", "<NONE | EQUAL | RANDOM>"));
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
|
||||||
|
case 3:
|
||||||
|
playerParty = UserManager.getPlayer((Player) sender).getParty();
|
||||||
|
boolean toggle = false;
|
||||||
|
|
||||||
|
if (args[2].equalsIgnoreCase("true") || args[2].equalsIgnoreCase("on") || args[2].equalsIgnoreCase("enabled")) {
|
||||||
|
toggle = true;
|
||||||
|
}
|
||||||
|
else if (args[2].equalsIgnoreCase("false") || args[2].equalsIgnoreCase("off") || args[2].equalsIgnoreCase("disabled")) {
|
||||||
|
toggle = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args[1].equalsIgnoreCase("loot")) {
|
||||||
|
playerParty.setSharingLootDrops(toggle);
|
||||||
|
}
|
||||||
|
else if (args[1].equalsIgnoreCase("mining")) {
|
||||||
|
playerParty.setSharingMiningDrops(toggle);
|
||||||
|
}
|
||||||
|
else if (args[1].equalsIgnoreCase("herbalism")) {
|
||||||
|
playerParty.setSharingHerbalismDrops(toggle);
|
||||||
|
}
|
||||||
|
else if (args[1].equalsIgnoreCase("woodcutting")) {
|
||||||
|
playerParty.setSharingWoodcuttingDrops(toggle);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "itemshare", "<loot | mining | herbalism | woodcutting> <true | false>"));
|
||||||
|
}
|
||||||
|
|
||||||
|
notifyToggleItemShareCategory(args, toggle);
|
||||||
|
return true;
|
||||||
|
|
||||||
|
default:
|
||||||
|
sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "itemshare", "<NONE | EQUAL | RANDOM>"));
|
||||||
|
sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "itemshare", "<loot | mining | herbalism | woodcutting> <true | false>"));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void handleChangingShareMode(ShareHandler.ShareMode mode) {
|
||||||
|
playerParty.setItemShareMode(mode);
|
||||||
|
|
||||||
|
for (Player member : playerParty.getOnlineMembers()) {
|
||||||
|
member.sendMessage(LocaleLoader.getString("Commands.Party.SetSharing", LocaleLoader.getString("Party.ShareType.Item"), LocaleLoader.getString("Party.ShareMode." + StringUtils.getCapitalized(mode.toString()))));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void notifyToggleItemShareCategory(String[] args, boolean toggle) {
|
||||||
|
String state = "disabled";
|
||||||
|
|
||||||
|
if (toggle) {
|
||||||
|
state = "enabled";
|
||||||
|
}
|
||||||
|
|
||||||
|
for (Player member : playerParty.getOnlineMembers()) {
|
||||||
|
member.sendMessage(LocaleLoader.getString("Commands.Party.ToggleShareCategory", StringUtils.getCapitalized(args[1]), state));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,4 +1,4 @@
|
|||||||
package com.gmail.nossr50.party.commands;
|
package com.gmail.nossr50.commands.party;
|
||||||
|
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandExecutor;
|
import org.bukkit.command.CommandExecutor;
|
||||||
@ -6,11 +6,11 @@ import org.bukkit.command.CommandSender;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.gmail.nossr50.datatypes.McMMOPlayer;
|
import com.gmail.nossr50.datatypes.party.Party;
|
||||||
|
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.party.Party;
|
|
||||||
import com.gmail.nossr50.party.PartyManager;
|
import com.gmail.nossr50.party.PartyManager;
|
||||||
import com.gmail.nossr50.util.Users;
|
import com.gmail.nossr50.util.player.UserManager;
|
||||||
|
|
||||||
public class PartyJoinCommand implements CommandExecutor {
|
public class PartyJoinCommand implements CommandExecutor {
|
||||||
private McMMOPlayer mcMMOTarget;
|
private McMMOPlayer mcMMOTarget;
|
||||||
@ -25,6 +25,7 @@ public class PartyJoinCommand implements CommandExecutor {
|
|||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
switch (args.length) {
|
switch (args.length) {
|
||||||
case 2:
|
case 2:
|
||||||
|
// Fallthrough
|
||||||
case 3:
|
case 3:
|
||||||
// Verify target exists and is in a different party than the player
|
// Verify target exists and is in a different party than the player
|
||||||
if (!canJoinParty(sender, args[1])) {
|
if (!canJoinParty(sender, args[1])) {
|
||||||
@ -66,7 +67,7 @@ public class PartyJoinCommand implements CommandExecutor {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
mcMMOTarget = Users.getPlayer(targetName);
|
mcMMOTarget = UserManager.getPlayer(targetName);
|
||||||
|
|
||||||
if (mcMMOTarget == null) {
|
if (mcMMOTarget == null) {
|
||||||
sender.sendMessage(LocaleLoader.getString("Party.Player.Invalid"));
|
sender.sendMessage(LocaleLoader.getString("Party.Player.Invalid"));
|
||||||
@ -81,7 +82,7 @@ public class PartyJoinCommand implements CommandExecutor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
player = (Player) sender;
|
player = (Player) sender;
|
||||||
mcMMOPlayer = Users.getPlayer(player);
|
mcMMOPlayer = UserManager.getPlayer(player);
|
||||||
playerParty = mcMMOPlayer.getParty();
|
playerParty = mcMMOPlayer.getParty();
|
||||||
targetParty = mcMMOTarget.getParty();
|
targetParty = mcMMOTarget.getParty();
|
||||||
|
|
@ -0,0 +1,49 @@
|
|||||||
|
package com.gmail.nossr50.commands.party;
|
||||||
|
|
||||||
|
import org.bukkit.OfflinePlayer;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandExecutor;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import com.gmail.nossr50.mcMMO;
|
||||||
|
import com.gmail.nossr50.datatypes.party.Party;
|
||||||
|
import com.gmail.nossr50.events.party.McMMOPartyChangeEvent.EventReason;
|
||||||
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
|
import com.gmail.nossr50.party.PartyManager;
|
||||||
|
import com.gmail.nossr50.util.player.UserManager;
|
||||||
|
|
||||||
|
public class PartyKickCommand implements CommandExecutor {
|
||||||
|
@Override
|
||||||
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
|
switch (args.length) {
|
||||||
|
case 2:
|
||||||
|
Party playerParty = UserManager.getPlayer((Player) sender).getParty();
|
||||||
|
|
||||||
|
OfflinePlayer target = mcMMO.p.getServer().getOfflinePlayer(args[1]);
|
||||||
|
|
||||||
|
if (!playerParty.getMembers().contains(target)) {
|
||||||
|
sender.sendMessage(LocaleLoader.getString("Party.NotInYourParty", args[1]));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (target.isOnline()) {
|
||||||
|
Player onlineTarget = target.getPlayer();
|
||||||
|
String partyName = playerParty.getName();
|
||||||
|
|
||||||
|
if (!PartyManager.handlePartyChangeEvent(onlineTarget, partyName, null, EventReason.KICKED_FROM_PARTY)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
onlineTarget.sendMessage(LocaleLoader.getString("Commands.Party.Kick", partyName));
|
||||||
|
}
|
||||||
|
|
||||||
|
PartyManager.removeFromParty(target, playerParty);
|
||||||
|
return true;
|
||||||
|
|
||||||
|
default:
|
||||||
|
sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "kick", "<" + LocaleLoader.getString("Commands.Usage.Player") + ">"));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,21 +1,21 @@
|
|||||||
package com.gmail.nossr50.party.commands;
|
package com.gmail.nossr50.commands.party;
|
||||||
|
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandExecutor;
|
import org.bukkit.command.CommandExecutor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import com.gmail.nossr50.datatypes.party.Party;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.party.Party;
|
|
||||||
import com.gmail.nossr50.util.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
import com.gmail.nossr50.util.Users;
|
import com.gmail.nossr50.util.player.UserManager;
|
||||||
|
|
||||||
public class PartyLockCommand implements CommandExecutor {
|
public class PartyLockCommand implements CommandExecutor {
|
||||||
private Party playerParty;
|
private Party playerParty;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
playerParty = Users.getPlayer((Player) sender).getParty();
|
playerParty = UserManager.getPlayer((Player) sender).getParty();
|
||||||
|
|
||||||
switch (args.length) {
|
switch (args.length) {
|
||||||
case 1:
|
case 1:
|
@ -0,0 +1,38 @@
|
|||||||
|
package com.gmail.nossr50.commands.party;
|
||||||
|
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandExecutor;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import com.gmail.nossr50.datatypes.party.Party;
|
||||||
|
import com.gmail.nossr50.events.party.McMMOPartyChangeEvent.EventReason;
|
||||||
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
|
import com.gmail.nossr50.party.PartyManager;
|
||||||
|
import com.gmail.nossr50.util.player.UserManager;
|
||||||
|
|
||||||
|
public class PartyQuitCommand implements CommandExecutor {
|
||||||
|
private Player player;
|
||||||
|
private Party playerParty;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
|
switch (args.length) {
|
||||||
|
case 1:
|
||||||
|
player = (Player) sender;
|
||||||
|
playerParty = UserManager.getPlayer(player).getParty();
|
||||||
|
|
||||||
|
if (!PartyManager.handlePartyChangeEvent(player, playerParty.getName(), null, EventReason.LEFT_PARTY)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
PartyManager.removeFromParty(player, playerParty);
|
||||||
|
sender.sendMessage(LocaleLoader.getString("Commands.Party.Leave"));
|
||||||
|
return true;
|
||||||
|
|
||||||
|
default:
|
||||||
|
sender.sendMessage(LocaleLoader.getString("Commands.Usage.1", "party", "[quit|q|leave]"));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,58 @@
|
|||||||
|
package com.gmail.nossr50.commands.party;
|
||||||
|
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandExecutor;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import com.gmail.nossr50.datatypes.party.Party;
|
||||||
|
import com.gmail.nossr50.events.party.McMMOPartyChangeEvent.EventReason;
|
||||||
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
|
import com.gmail.nossr50.party.PartyManager;
|
||||||
|
import com.gmail.nossr50.util.player.UserManager;
|
||||||
|
|
||||||
|
public class PartyRenameCommand implements CommandExecutor {
|
||||||
|
@Override
|
||||||
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
|
Party playerParty = UserManager.getPlayer((Player) sender).getParty();
|
||||||
|
String leaderName = playerParty.getLeader();
|
||||||
|
|
||||||
|
switch (args.length) {
|
||||||
|
case 2:
|
||||||
|
String newPartyName = args[1];
|
||||||
|
|
||||||
|
// This is to prevent party leaders from spamming other players with the rename message
|
||||||
|
if (playerParty.getName().equalsIgnoreCase(newPartyName)) {
|
||||||
|
sender.sendMessage(LocaleLoader.getString("Party.Rename.Same"));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
Party newParty = PartyManager.getParty(newPartyName);
|
||||||
|
|
||||||
|
// Check to see if the party exists, and if it does cancel renaming the party
|
||||||
|
if (newParty != null) {
|
||||||
|
sender.sendMessage(LocaleLoader.getString("Commands.Party.AlreadyExists", newPartyName));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (Player member : playerParty.getOnlineMembers()) {
|
||||||
|
if (!PartyManager.handlePartyChangeEvent(member, playerParty.getName(), newPartyName, EventReason.CHANGED_PARTIES)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!member.getName().equals(leaderName)) {
|
||||||
|
member.sendMessage(LocaleLoader.getString("Party.InformedOnNameChange", leaderName, newPartyName));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
playerParty.setName(newPartyName);
|
||||||
|
|
||||||
|
sender.sendMessage(LocaleLoader.getString("Commands.Party.Rename", newPartyName));
|
||||||
|
return true;
|
||||||
|
|
||||||
|
default:
|
||||||
|
sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "rename", "<" + LocaleLoader.getString("Commands.Usage.PartyName") + ">"));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,4 +1,4 @@
|
|||||||
package com.gmail.nossr50.party.commands;
|
package com.gmail.nossr50.commands.party;
|
||||||
|
|
||||||
public enum PartySubcommandType {
|
public enum PartySubcommandType {
|
||||||
JOIN,
|
JOIN,
|
||||||
@ -33,6 +33,9 @@ public enum PartySubcommandType {
|
|||||||
else if (commandName.equalsIgnoreCase("q") || commandName.equalsIgnoreCase("leave")) {
|
else if (commandName.equalsIgnoreCase("q") || commandName.equalsIgnoreCase("leave")) {
|
||||||
return QUIT;
|
return QUIT;
|
||||||
}
|
}
|
||||||
|
else if (commandName.equalsIgnoreCase("leader")) {
|
||||||
|
return OWNER;
|
||||||
|
}
|
||||||
else if (commandName.equalsIgnoreCase("xpshare") || commandName.equalsIgnoreCase("shareexp") || commandName.equalsIgnoreCase("sharexp")) {
|
else if (commandName.equalsIgnoreCase("xpshare") || commandName.equalsIgnoreCase("shareexp") || commandName.equalsIgnoreCase("sharexp")) {
|
||||||
return EXPSHARE;
|
return EXPSHARE;
|
||||||
}
|
}
|
@ -1,4 +1,4 @@
|
|||||||
package com.gmail.nossr50.party.commands;
|
package com.gmail.nossr50.commands.party;
|
||||||
|
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
@ -7,36 +7,33 @@ import org.bukkit.command.CommandSender;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.gmail.nossr50.commands.CommandHelper;
|
|
||||||
import com.gmail.nossr50.config.Config;
|
import com.gmail.nossr50.config.Config;
|
||||||
import com.gmail.nossr50.datatypes.McMMOPlayer;
|
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
|
||||||
import com.gmail.nossr50.events.party.McMMOPartyTeleportEvent;
|
import com.gmail.nossr50.events.party.McMMOPartyTeleportEvent;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.party.PartyManager;
|
import com.gmail.nossr50.party.PartyManager;
|
||||||
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.Users;
|
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||||
|
import com.gmail.nossr50.util.player.UserManager;
|
||||||
|
|
||||||
public class PtpCommand implements CommandExecutor {
|
public class PtpCommand implements CommandExecutor {
|
||||||
private Player player;
|
private Player player;
|
||||||
private McMMOPlayer mcMMOPlayer;
|
private McMMOPlayer mcMMOPlayer;
|
||||||
private PlayerProfile playerProfile;
|
|
||||||
|
|
||||||
private Player target;
|
private Player target;
|
||||||
private McMMOPlayer mcMMOTarget;
|
private McMMOPlayer mcMMOTarget;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
if (CommandHelper.noConsoleUsage(sender)) {
|
if (CommandUtils.noConsoleUsage(sender)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (args.length) {
|
switch (args.length) {
|
||||||
case 1:
|
case 1:
|
||||||
player = (Player) sender;
|
player = (Player) sender;
|
||||||
mcMMOPlayer = Users.getPlayer(player);
|
mcMMOPlayer = UserManager.getPlayer(player);
|
||||||
playerProfile = mcMMOPlayer.getProfile();
|
|
||||||
|
|
||||||
if (args[0].equalsIgnoreCase("toggle")) {
|
if (args[0].equalsIgnoreCase("toggle")) {
|
||||||
if (!Permissions.partyTeleportToggle(sender)) {
|
if (!Permissions.partyTeleportToggle(sender)) {
|
||||||
@ -57,8 +54,9 @@ public class PtpCommand implements CommandExecutor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int ptpCooldown = Config.getInstance().getPTPCommandCooldown();
|
int ptpCooldown = Config.getInstance().getPTPCommandCooldown();
|
||||||
|
long recentlyHurt = UserManager.getPlayer(player).getRecentlyHurt();
|
||||||
|
|
||||||
if (playerProfile.getRecentlyHurt() + (ptpCooldown * Misc.TIME_CONVERSION_FACTOR) > System.currentTimeMillis()) {
|
if ((recentlyHurt * Misc.TIME_CONVERSION_FACTOR + ptpCooldown * Misc.TIME_CONVERSION_FACTOR) > System.currentTimeMillis()) {
|
||||||
player.sendMessage(LocaleLoader.getString("Party.Teleport.Hurt", ptpCooldown));
|
player.sendMessage(LocaleLoader.getString("Party.Teleport.Hurt", ptpCooldown));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -93,6 +91,7 @@ public class PtpCommand implements CommandExecutor {
|
|||||||
player.sendMessage(LocaleLoader.getString("Commands.Invite.Success"));
|
player.sendMessage(LocaleLoader.getString("Commands.Invite.Success"));
|
||||||
|
|
||||||
int ptpRequestExpire = Config.getInstance().getPTPCommandTimeout();
|
int ptpRequestExpire = Config.getInstance().getPTPCommandTimeout();
|
||||||
|
|
||||||
target.sendMessage(LocaleLoader.getString("Commands.ptp.Request1", player.getName()));
|
target.sendMessage(LocaleLoader.getString("Commands.ptp.Request1", player.getName()));
|
||||||
target.sendMessage(LocaleLoader.getString("Commands.ptp.Request2", ptpRequestExpire));
|
target.sendMessage(LocaleLoader.getString("Commands.ptp.Request2", ptpRequestExpire));
|
||||||
return true;
|
return true;
|
||||||
@ -113,9 +112,9 @@ public class PtpCommand implements CommandExecutor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
target = mcMMOPlayer.getPtpRequest();
|
target = mcMMOPlayer.getPtpRequest();
|
||||||
|
mcMMOPlayer.removePtpRequest();
|
||||||
|
|
||||||
if (!canTeleport(target.getName())) {
|
if (!canTeleport(target.getName())) {
|
||||||
mcMMOPlayer.removePtpRequest();
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -168,7 +167,7 @@ public class PtpCommand implements CommandExecutor {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
mcMMOTarget = Users.getPlayer(targetName);
|
mcMMOTarget = UserManager.getPlayer(targetName);
|
||||||
|
|
||||||
if (mcMMOTarget == null) {
|
if (mcMMOTarget == null) {
|
||||||
player.sendMessage(LocaleLoader.getString("Party.Player.Invalid"));
|
player.sendMessage(LocaleLoader.getString("Party.Player.Invalid"));
|
||||||
@ -201,9 +200,9 @@ public class PtpCommand implements CommandExecutor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean handlePartyTeleportEvent(Player player, Player target) {
|
private boolean handlePartyTeleportEvent(Player player, Player target) {
|
||||||
McMMOPlayer mcMMOPlayer= Users.getPlayer(player);
|
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
|
||||||
|
|
||||||
McMMOPartyTeleportEvent event = new McMMOPartyTeleportEvent(player, target, mcMMOPlayer.getParty().getName());
|
McMMOPartyTeleportEvent event = new McMMOPartyTeleportEvent(player, target, mcMMOPlayer.getParty().getName());
|
||||||
|
|
||||||
mcMMO.p.getServer().getPluginManager().callEvent(event);
|
mcMMO.p.getServer().getPluginManager().callEvent(event);
|
||||||
|
|
||||||
if (event.isCancelled()) {
|
if (event.isCancelled()) {
|
||||||
@ -213,7 +212,7 @@ public class PtpCommand implements CommandExecutor {
|
|||||||
player.teleport(target);
|
player.teleport(target);
|
||||||
player.sendMessage(LocaleLoader.getString("Party.Teleport.Player", target.getName()));
|
player.sendMessage(LocaleLoader.getString("Party.Teleport.Player", target.getName()));
|
||||||
target.sendMessage(LocaleLoader.getString("Party.Teleport.Target", player.getName()));
|
target.sendMessage(LocaleLoader.getString("Party.Teleport.Target", player.getName()));
|
||||||
mcMMOPlayer.getProfile().setRecentlyHurt(System.currentTimeMillis());
|
mcMMOPlayer.actualizeRecentlyHurt();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -5,14 +5,14 @@ import org.bukkit.command.CommandExecutor;
|
|||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import com.gmail.nossr50.commands.CommandHelper;
|
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||||
import com.gmail.nossr50.datatypes.McMMOPlayer;
|
import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
||||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.skills.utilities.SkillType;
|
|
||||||
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.Users;
|
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||||
|
import com.gmail.nossr50.util.player.UserManager;
|
||||||
|
|
||||||
public class InspectCommand implements CommandExecutor {
|
public class InspectCommand implements CommandExecutor {
|
||||||
@Override
|
@Override
|
||||||
@ -21,7 +21,7 @@ public class InspectCommand implements CommandExecutor {
|
|||||||
|
|
||||||
switch (args.length) {
|
switch (args.length) {
|
||||||
case 1:
|
case 1:
|
||||||
McMMOPlayer mcMMOPlayer = Users.getPlayer(args[0]);
|
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(args[0]);
|
||||||
|
|
||||||
// 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) {
|
||||||
@ -72,9 +72,9 @@ public class InspectCommand implements CommandExecutor {
|
|||||||
profile = mcMMOPlayer.getProfile();
|
profile = mcMMOPlayer.getProfile();
|
||||||
|
|
||||||
sender.sendMessage(LocaleLoader.getString("Inspect.Stats", target.getName()));
|
sender.sendMessage(LocaleLoader.getString("Inspect.Stats", target.getName()));
|
||||||
CommandHelper.printGatheringSkills(target, profile, sender);
|
CommandUtils.printGatheringSkills(target, profile, sender);
|
||||||
CommandHelper.printCombatSkills(target, profile, sender);
|
CommandUtils.printCombatSkills(target, profile, sender);
|
||||||
CommandHelper.printMiscSkills(target, profile, sender);
|
CommandUtils.printMiscSkills(target, profile, sender);
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.PowerLevel", mcMMOPlayer.getPowerLevel()));
|
sender.sendMessage(LocaleLoader.getString("Commands.PowerLevel", mcMMOPlayer.getPowerLevel()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,80 +0,0 @@
|
|||||||
package com.gmail.nossr50.commands.player;
|
|
||||||
|
|
||||||
import org.bukkit.command.Command;
|
|
||||||
import org.bukkit.command.CommandExecutor;
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
import com.gmail.nossr50.datatypes.McMMOPlayer;
|
|
||||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
|
||||||
import com.gmail.nossr50.util.Permissions;
|
|
||||||
import com.gmail.nossr50.util.Users;
|
|
||||||
|
|
||||||
public class McabilityCommand implements CommandExecutor {
|
|
||||||
@Override
|
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
|
||||||
PlayerProfile profile;
|
|
||||||
|
|
||||||
switch (args.length) {
|
|
||||||
case 0:
|
|
||||||
if (!Permissions.mcability(sender)) {
|
|
||||||
sender.sendMessage(command.getPermissionMessage());
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
profile = Users.getPlayer((Player) sender).getProfile();
|
|
||||||
|
|
||||||
if (profile.getAbilityUse()) {
|
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.Ability.Off"));
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.Ability.On"));
|
|
||||||
}
|
|
||||||
|
|
||||||
profile.toggleAbilityUse();
|
|
||||||
return true;
|
|
||||||
|
|
||||||
case 1:
|
|
||||||
if (!Permissions.mcabilityOthers(sender)) {
|
|
||||||
sender.sendMessage(command.getPermissionMessage());
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
McMMOPlayer mcMMOPlayer = Users.getPlayer(args[0]);
|
|
||||||
|
|
||||||
if (mcMMOPlayer == null) {
|
|
||||||
profile = new PlayerProfile(args[0], false);
|
|
||||||
|
|
||||||
if (!profile.isLoaded()) {
|
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.Offline"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
Player player = mcMMOPlayer.getPlayer();
|
|
||||||
profile = mcMMOPlayer.getProfile();
|
|
||||||
|
|
||||||
if (!player.isOnline()) {
|
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.Offline"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (profile.getAbilityUse()) {
|
|
||||||
player.sendMessage(LocaleLoader.getString("Commands.Ability.Off"));
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
player.sendMessage(LocaleLoader.getString("Commands.Ability.On"));
|
|
||||||
}
|
|
||||||
|
|
||||||
profile.toggleAbilityUse();
|
|
||||||
return true;
|
|
||||||
|
|
||||||
default:
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,34 +0,0 @@
|
|||||||
package com.gmail.nossr50.commands.player;
|
|
||||||
|
|
||||||
import org.bukkit.command.Command;
|
|
||||||
import org.bukkit.command.CommandExecutor;
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
|
||||||
import com.gmail.nossr50.util.Users;
|
|
||||||
|
|
||||||
public class McnotifyCommand implements CommandExecutor {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
|
||||||
switch (args.length) {
|
|
||||||
case 0:
|
|
||||||
PlayerProfile profile = Users.getPlayer((Player) sender).getProfile();
|
|
||||||
|
|
||||||
if (profile.useChatNotifications()) {
|
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.Notifications.Off"));
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.Notifications.On"));
|
|
||||||
}
|
|
||||||
|
|
||||||
profile.toggleChatNotifications();
|
|
||||||
return true;
|
|
||||||
|
|
||||||
default:
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -8,16 +8,16 @@ import org.bukkit.entity.Player;
|
|||||||
|
|
||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.gmail.nossr50.config.Config;
|
import com.gmail.nossr50.config.Config;
|
||||||
import com.gmail.nossr50.database.Leaderboard;
|
import com.gmail.nossr50.database.LeaderboardManager;
|
||||||
import com.gmail.nossr50.datatypes.McMMOPlayer;
|
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
||||||
|
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.runnables.McRankAsync;
|
import com.gmail.nossr50.runnables.commands.McrankCommandAsyncTask;
|
||||||
import com.gmail.nossr50.skills.utilities.SkillTools;
|
|
||||||
import com.gmail.nossr50.skills.utilities.SkillType;
|
|
||||||
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.Users;
|
import com.gmail.nossr50.util.player.UserManager;
|
||||||
|
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||||
|
|
||||||
public class McrankCommand implements CommandExecutor {
|
public class McrankCommand implements CommandExecutor {
|
||||||
@Override
|
@Override
|
||||||
@ -37,7 +37,7 @@ public class McrankCommand implements CommandExecutor {
|
|||||||
sqlDisplay(sender, sender.getName());
|
sqlDisplay(sender, sender.getName());
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Leaderboard.updateLeaderboards(); // Make sure the information is up to date
|
LeaderboardManager.updateLeaderboards(); // Make sure the information is up to date
|
||||||
flatfileDisplay(sender, sender.getName());
|
flatfileDisplay(sender, sender.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -49,7 +49,7 @@ public class McrankCommand implements CommandExecutor {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
McMMOPlayer mcMMOPlayer = Users.getPlayer(args[0]);
|
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(args[0]);
|
||||||
|
|
||||||
if (mcMMOPlayer == null) {
|
if (mcMMOPlayer == null) {
|
||||||
PlayerProfile profile = new PlayerProfile(args[0], false); // Temporary Profile
|
PlayerProfile profile = new PlayerProfile(args[0], false); // Temporary Profile
|
||||||
@ -77,7 +77,7 @@ public class McrankCommand implements CommandExecutor {
|
|||||||
sqlDisplay(sender, args[0]);
|
sqlDisplay(sender, args[0]);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Leaderboard.updateLeaderboards(); // Make sure the information is up to date
|
LeaderboardManager.updateLeaderboards(); // Make sure the information is up to date
|
||||||
flatfileDisplay(sender, args[0]);
|
flatfileDisplay(sender, args[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -93,22 +93,22 @@ public class McrankCommand implements CommandExecutor {
|
|||||||
sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Player", playerName));
|
sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Player", playerName));
|
||||||
|
|
||||||
for (SkillType skillType : SkillType.values()) {
|
for (SkillType skillType : SkillType.values()) {
|
||||||
int[] rankInts = Leaderboard.getPlayerRank(playerName, skillType);
|
int[] rankInts = LeaderboardManager.getPlayerRank(playerName, skillType);
|
||||||
|
|
||||||
if (skillType.isChildSkill()) {
|
if (skillType.isChildSkill()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rankInts[1] == 0) {
|
if (rankInts[1] == 0) {
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Skill", SkillTools.getSkillName(skillType), LocaleLoader.getString("Commands.mcrank.Unranked"))); // Don't bother showing ranking for players without skills
|
sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Skill", SkillUtils.getSkillName(skillType), LocaleLoader.getString("Commands.mcrank.Unranked"))); // Don't bother showing ranking for players without skills
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Skill", SkillTools.getSkillName(skillType), rankInts[0]));
|
sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Skill", SkillUtils.getSkillName(skillType), rankInts[0]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Show the powerlevel ranking
|
// Show the powerlevel ranking
|
||||||
int[] rankInts = Leaderboard.getPlayerRank(playerName);
|
int[] rankInts = LeaderboardManager.getPlayerRank(playerName);
|
||||||
|
|
||||||
if (rankInts[1] == 0) {
|
if (rankInts[1] == 0) {
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Overall", LocaleLoader.getString("Commands.mcrank.Unranked"))); // Don't bother showing ranking for players without skills
|
sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Overall", LocaleLoader.getString("Commands.mcrank.Unranked"))); // Don't bother showing ranking for players without skills
|
||||||
@ -119,6 +119,6 @@ public class McrankCommand implements CommandExecutor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void sqlDisplay(CommandSender sender, String playerName) {
|
private void sqlDisplay(CommandSender sender, String playerName) {
|
||||||
Bukkit.getScheduler().runTaskAsynchronously(mcMMO.p, new McRankAsync(playerName, sender));
|
Bukkit.getScheduler().runTaskAsynchronously(mcMMO.p, new McrankCommandAsyncTask(playerName, sender));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,32 +5,32 @@ import org.bukkit.command.CommandExecutor;
|
|||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import com.gmail.nossr50.commands.CommandHelper;
|
|
||||||
import com.gmail.nossr50.config.Config;
|
import com.gmail.nossr50.config.Config;
|
||||||
import com.gmail.nossr50.datatypes.McMMOPlayer;
|
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.util.Users;
|
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||||
|
import com.gmail.nossr50.util.player.UserManager;
|
||||||
|
|
||||||
public class McstatsCommand implements CommandExecutor {
|
public class McstatsCommand implements CommandExecutor {
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
if (CommandHelper.noConsoleUsage(sender)) {
|
if (CommandUtils.noConsoleUsage(sender)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (args.length) {
|
switch (args.length) {
|
||||||
case 0:
|
case 0:
|
||||||
Player player = (Player) sender;
|
Player player = (Player) sender;
|
||||||
McMMOPlayer mcMMOPlayer = Users.getPlayer(player);
|
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
|
||||||
PlayerProfile profile = mcMMOPlayer.getProfile();
|
PlayerProfile profile = mcMMOPlayer.getProfile();
|
||||||
|
|
||||||
player.sendMessage(LocaleLoader.getString("Stats.Own.Stats"));
|
player.sendMessage(LocaleLoader.getString("Stats.Own.Stats"));
|
||||||
player.sendMessage(LocaleLoader.getString("mcMMO.NoSkillNote"));
|
player.sendMessage(LocaleLoader.getString("mcMMO.NoSkillNote"));
|
||||||
|
|
||||||
CommandHelper.printGatheringSkills(player, profile);
|
CommandUtils.printGatheringSkills(player, profile);
|
||||||
CommandHelper.printCombatSkills(player, profile);
|
CommandUtils.printCombatSkills(player, profile);
|
||||||
CommandHelper.printMiscSkills(player, profile);
|
CommandUtils.printMiscSkills(player, profile);
|
||||||
|
|
||||||
int powerLevelCap = Config.getInstance().getPowerLevelCap();
|
int powerLevelCap = Config.getInstance().getPowerLevelCap();
|
||||||
|
|
||||||
|
@ -8,13 +8,13 @@ import org.bukkit.command.CommandSender;
|
|||||||
|
|
||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.gmail.nossr50.config.Config;
|
import com.gmail.nossr50.config.Config;
|
||||||
import com.gmail.nossr50.database.Leaderboard;
|
import com.gmail.nossr50.database.LeaderboardManager;
|
||||||
|
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.runnables.McTopAsync;
|
import com.gmail.nossr50.runnables.commands.MctopCommandAsyncTask;
|
||||||
import com.gmail.nossr50.skills.utilities.SkillTools;
|
|
||||||
import com.gmail.nossr50.skills.utilities.SkillType;
|
|
||||||
import com.gmail.nossr50.util.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
import com.gmail.nossr50.util.StringUtils;
|
import com.gmail.nossr50.util.StringUtils;
|
||||||
|
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||||
|
|
||||||
public class MctopCommand implements CommandExecutor {
|
public class MctopCommand implements CommandExecutor {
|
||||||
@Override
|
@Override
|
||||||
@ -30,8 +30,15 @@ public class MctopCommand implements CommandExecutor {
|
|||||||
if (StringUtils.isInt(args[0])) {
|
if (StringUtils.isInt(args[0])) {
|
||||||
display(Integer.parseInt(args[0]), "ALL", sender, useMySQL, command);
|
display(Integer.parseInt(args[0]), "ALL", sender, useMySQL, command);
|
||||||
}
|
}
|
||||||
else if (SkillTools.isSkill(args[0])) {
|
else if (SkillUtils.isSkill(args[0])) {
|
||||||
display(1, SkillType.getSkill(args[0]).toString(), sender, useMySQL, command);
|
SkillType skill = SkillType.getSkill(args[0]);
|
||||||
|
|
||||||
|
if (skill.isChildSkill()) {
|
||||||
|
sender.sendMessage("Child skills are not yet supported by this command."); // TODO: Localize this
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
display(1, skill.toString(), sender, useMySQL, command);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
|
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
|
||||||
@ -44,8 +51,15 @@ public class MctopCommand implements CommandExecutor {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (SkillTools.isSkill(args[0])) {
|
if (SkillUtils.isSkill(args[0])) {
|
||||||
display(Integer.parseInt(args[1]), SkillType.getSkill(args[0]).toString(), sender, useMySQL, command);
|
SkillType skill = SkillType.getSkill(args[0]);
|
||||||
|
|
||||||
|
if (skill.isChildSkill()) {
|
||||||
|
sender.sendMessage("Child skills are not yet supported by this command."); // TODO: Localize this
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
display(Integer.parseInt(args[1]), skill.toString(), sender, useMySQL, command);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
|
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
|
||||||
@ -78,9 +92,9 @@ public class MctopCommand implements CommandExecutor {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Leaderboard.updateLeaderboards(); //Make sure we have the latest information
|
LeaderboardManager.updateLeaderboards(); // Make sure we have the latest information
|
||||||
|
|
||||||
String[] info = Leaderboard.retrieveInfo(skill, page);
|
String[] info = LeaderboardManager.retrieveInfo(skill, page);
|
||||||
|
|
||||||
if (skill.equalsIgnoreCase("all")) {
|
if (skill.equalsIgnoreCase("all")) {
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.PowerLevel.Leaderboard"));
|
sender.sendMessage(LocaleLoader.getString("Commands.PowerLevel.Leaderboard"));
|
||||||
@ -110,6 +124,6 @@ public class MctopCommand implements CommandExecutor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void sqlDisplay(int page, String query, CommandSender sender, Command command) {
|
private void sqlDisplay(int page, String query, CommandSender sender, Command command) {
|
||||||
Bukkit.getScheduler().runTaskAsynchronously(mcMMO.p, new McTopAsync(page, query, sender, command));
|
Bukkit.getScheduler().runTaskAsynchronously(mcMMO.p, new MctopCommandAsyncTask(page, query, sender, command));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
package com.gmail.nossr50.skills.acrobatics;
|
package com.gmail.nossr50.commands.skills;
|
||||||
|
|
||||||
|
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.skills.SkillCommand;
|
import com.gmail.nossr50.skills.acrobatics.Acrobatics;
|
||||||
import com.gmail.nossr50.skills.utilities.SkillType;
|
|
||||||
import com.gmail.nossr50.util.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
|
|
||||||
public class AcrobaticsCommand extends SkillCommand {
|
public class AcrobaticsCommand extends SkillCommand {
|
@ -1,8 +1,8 @@
|
|||||||
package com.gmail.nossr50.skills.archery;
|
package com.gmail.nossr50.commands.skills;
|
||||||
|
|
||||||
|
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.skills.SkillCommand;
|
import com.gmail.nossr50.skills.archery.Archery;
|
||||||
import com.gmail.nossr50.skills.utilities.SkillType;
|
|
||||||
import com.gmail.nossr50.util.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
|
|
||||||
public class ArcheryCommand extends SkillCommand {
|
public class ArcheryCommand extends SkillCommand {
|
@ -1,8 +1,8 @@
|
|||||||
package com.gmail.nossr50.skills.axes;
|
package com.gmail.nossr50.commands.skills;
|
||||||
|
|
||||||
|
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.skills.SkillCommand;
|
import com.gmail.nossr50.skills.axes.Axes;
|
||||||
import com.gmail.nossr50.skills.utilities.SkillType;
|
|
||||||
import com.gmail.nossr50.util.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
|
|
||||||
public class AxesCommand extends SkillCommand {
|
public class AxesCommand extends SkillCommand {
|
@ -1,8 +1,7 @@
|
|||||||
package com.gmail.nossr50.skills.excavation;
|
package com.gmail.nossr50.commands.skills;
|
||||||
|
|
||||||
|
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.skills.SkillCommand;
|
|
||||||
import com.gmail.nossr50.skills.utilities.SkillType;
|
|
||||||
import com.gmail.nossr50.util.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
|
|
||||||
public class ExcavationCommand extends SkillCommand {
|
public class ExcavationCommand extends SkillCommand {
|
@ -1,10 +1,11 @@
|
|||||||
package com.gmail.nossr50.skills.fishing;
|
package com.gmail.nossr50.commands.skills;
|
||||||
|
|
||||||
import com.gmail.nossr50.config.AdvancedConfig;
|
import com.gmail.nossr50.config.AdvancedConfig;
|
||||||
|
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.skills.SkillCommand;
|
import com.gmail.nossr50.skills.fishing.Fishing;
|
||||||
import com.gmail.nossr50.skills.utilities.SkillType;
|
|
||||||
import com.gmail.nossr50.util.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
|
import com.gmail.nossr50.util.player.UserManager;
|
||||||
|
|
||||||
public class FishingCommand extends SkillCommand {
|
public class FishingCommand extends SkillCommand {
|
||||||
private int lootTier;
|
private int lootTier;
|
||||||
@ -26,7 +27,7 @@ public class FishingCommand extends SkillCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void dataCalculations() {
|
protected void dataCalculations() {
|
||||||
lootTier = Fishing.getLootTier((int) skillValue);
|
lootTier = UserManager.getPlayer(player).getFishingManager().getLootTier();
|
||||||
|
|
||||||
// TREASURE HUNTER
|
// TREASURE HUNTER
|
||||||
double enchantChance = lootTier * AdvancedConfig.getInstance().getFishingMagicMultiplier();
|
double enchantChance = lootTier * AdvancedConfig.getInstance().getFishingMagicMultiplier();
|
||||||
@ -41,7 +42,7 @@ public class FishingCommand extends SkillCommand {
|
|||||||
magicChanceLucky = treasureHunterStrings[1];
|
magicChanceLucky = treasureHunterStrings[1];
|
||||||
|
|
||||||
// SHAKE
|
// SHAKE
|
||||||
String[] shakeStrings = calculateAbilityDisplayValues(ShakeMob.getShakeProbability((int) skillValue));
|
String[] shakeStrings = calculateAbilityDisplayValues(UserManager.getPlayer(player).getFishingManager().getShakeProbability());
|
||||||
shakeChance = shakeStrings[0];
|
shakeChance = shakeStrings[0];
|
||||||
shakeChanceLucky = shakeStrings[1];
|
shakeChanceLucky = shakeStrings[1];
|
||||||
|
|
@ -1,10 +1,10 @@
|
|||||||
package com.gmail.nossr50.skills.herbalism;
|
package com.gmail.nossr50.commands.skills;
|
||||||
|
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
|
|
||||||
|
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.skills.SkillCommand;
|
import com.gmail.nossr50.skills.herbalism.Herbalism;
|
||||||
import com.gmail.nossr50.skills.utilities.SkillType;
|
|
||||||
import com.gmail.nossr50.util.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
|
|
||||||
public class HerbalismCommand extends SkillCommand {
|
public class HerbalismCommand extends SkillCommand {
|
||||||
@ -18,6 +18,8 @@ public class HerbalismCommand extends SkillCommand {
|
|||||||
private String doubleDropChanceLucky;
|
private String doubleDropChanceLucky;
|
||||||
private String hylianLuckChance;
|
private String hylianLuckChance;
|
||||||
private String hylianLuckChanceLucky;
|
private String hylianLuckChanceLucky;
|
||||||
|
private String shroomThumbChance;
|
||||||
|
private String shroomThumbChanceLucky;
|
||||||
|
|
||||||
private boolean hasHylianLuck;
|
private boolean hasHylianLuck;
|
||||||
private boolean canGreenTerra;
|
private boolean canGreenTerra;
|
||||||
@ -25,6 +27,7 @@ public class HerbalismCommand extends SkillCommand {
|
|||||||
private boolean canGreenThumbBlocks;
|
private boolean canGreenThumbBlocks;
|
||||||
private boolean canFarmersDiet;
|
private boolean canFarmersDiet;
|
||||||
private boolean canDoubleDrop;
|
private boolean canDoubleDrop;
|
||||||
|
private boolean canShroomThumb;
|
||||||
private boolean doubleDropsDisabled;
|
private boolean doubleDropsDisabled;
|
||||||
|
|
||||||
public HerbalismCommand() {
|
public HerbalismCommand() {
|
||||||
@ -57,6 +60,11 @@ public class HerbalismCommand extends SkillCommand {
|
|||||||
String[] hylianLuckStrings = calculateAbilityDisplayValues(Herbalism.hylianLuckMaxLevel, Herbalism.hylianLuckMaxChance);
|
String[] hylianLuckStrings = calculateAbilityDisplayValues(Herbalism.hylianLuckMaxLevel, Herbalism.hylianLuckMaxChance);
|
||||||
hylianLuckChance = hylianLuckStrings[0];
|
hylianLuckChance = hylianLuckStrings[0];
|
||||||
hylianLuckChanceLucky = hylianLuckStrings[1];
|
hylianLuckChanceLucky = hylianLuckStrings[1];
|
||||||
|
|
||||||
|
// SHROOM THUMB
|
||||||
|
String[] shroomThumbStrings = calculateAbilityDisplayValues(Herbalism.shroomThumbMaxLevel, Herbalism.shroomThumbMaxChance);
|
||||||
|
shroomThumbChance = shroomThumbStrings[0];
|
||||||
|
shroomThumbChanceLucky = shroomThumbStrings[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -68,11 +76,12 @@ public class HerbalismCommand extends SkillCommand {
|
|||||||
canFarmersDiet = Permissions.farmersDiet(player);
|
canFarmersDiet = Permissions.farmersDiet(player);
|
||||||
canDoubleDrop = Permissions.doubleDrops(player, skill);
|
canDoubleDrop = Permissions.doubleDrops(player, skill);
|
||||||
doubleDropsDisabled = skill.getDoubleDropsDisabled();
|
doubleDropsDisabled = skill.getDoubleDropsDisabled();
|
||||||
|
canShroomThumb = Permissions.shroomThumb(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean effectsHeaderPermissions() {
|
protected boolean effectsHeaderPermissions() {
|
||||||
return canGreenTerra || (canDoubleDrop && !doubleDropsDisabled) || canFarmersDiet || canGreenThumbBlocks || canGreenThumbWheat;
|
return canGreenTerra || (canDoubleDrop && !doubleDropsDisabled) || canFarmersDiet || canGreenThumbBlocks || canGreenThumbWheat || canShroomThumb;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -99,6 +108,10 @@ public class HerbalismCommand extends SkillCommand {
|
|||||||
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Herbalism.Effect.10"), LocaleLoader.getString("Herbalism.Effect.11")));
|
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Herbalism.Effect.10"), LocaleLoader.getString("Herbalism.Effect.11")));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (canShroomThumb) {
|
||||||
|
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Herbalism.Effect.12"), LocaleLoader.getString("Herbalism.Effect.13")));
|
||||||
|
}
|
||||||
|
|
||||||
if (canDoubleDrop && !doubleDropsDisabled) {
|
if (canDoubleDrop && !doubleDropsDisabled) {
|
||||||
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Herbalism.Effect.8"), LocaleLoader.getString("Herbalism.Effect.9")));
|
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Herbalism.Effect.8"), LocaleLoader.getString("Herbalism.Effect.9")));
|
||||||
}
|
}
|
||||||
@ -106,7 +119,7 @@ public class HerbalismCommand extends SkillCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean statsHeaderPermissions() {
|
protected boolean statsHeaderPermissions() {
|
||||||
return canGreenTerra || (canDoubleDrop && !doubleDropsDisabled) || canFarmersDiet || canGreenThumbBlocks || canGreenThumbWheat;
|
return canGreenTerra || (canDoubleDrop && !doubleDropsDisabled) || canFarmersDiet || canGreenThumbBlocks || canGreenThumbWheat || canShroomThumb;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -145,6 +158,16 @@ public class HerbalismCommand extends SkillCommand {
|
|||||||
player.sendMessage(LocaleLoader.getString("Herbalism.Ability.HylianLuck", hylianLuckChance));
|
player.sendMessage(LocaleLoader.getString("Herbalism.Ability.HylianLuck", hylianLuckChance));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (canShroomThumb) {
|
||||||
|
if (isLucky) {
|
||||||
|
player.sendMessage(LocaleLoader.getString("Herbalism.Ability.ShroomThumb.Chance", shroomThumbChance) + LocaleLoader.getString("Perks.lucky.bonus", shroomThumbChanceLucky));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
player.sendMessage(LocaleLoader.getString("Herbalism.Ability.ShroomThumb.Chance", shroomThumbChance));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (canDoubleDrop && !doubleDropsDisabled) {
|
if (canDoubleDrop && !doubleDropsDisabled) {
|
||||||
if (isLucky) {
|
if (isLucky) {
|
||||||
player.sendMessage(LocaleLoader.getString("Herbalism.Ability.DoubleDropChance", doubleDropChance) + LocaleLoader.getString("Perks.lucky.bonus", doubleDropChanceLucky));
|
player.sendMessage(LocaleLoader.getString("Herbalism.Ability.DoubleDropChance", doubleDropChance) + LocaleLoader.getString("Perks.lucky.bonus", doubleDropChanceLucky));
|
@ -1,17 +1,24 @@
|
|||||||
package com.gmail.nossr50.skills.mining;
|
package com.gmail.nossr50.commands.skills;
|
||||||
|
|
||||||
|
import com.gmail.nossr50.config.AdvancedConfig;
|
||||||
|
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.skills.SkillCommand;
|
import com.gmail.nossr50.skills.mining.Mining;
|
||||||
import com.gmail.nossr50.skills.utilities.SkillType;
|
import com.gmail.nossr50.skills.mining.MiningManager;
|
||||||
import com.gmail.nossr50.util.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
|
import com.gmail.nossr50.util.player.UserManager;
|
||||||
|
|
||||||
public class MiningCommand extends SkillCommand {
|
public class MiningCommand extends SkillCommand {
|
||||||
private String doubleDropChance;
|
private String doubleDropChance;
|
||||||
private String doubleDropChanceLucky;
|
private String doubleDropChanceLucky;
|
||||||
private String superBreakerLength;
|
private String superBreakerLength;
|
||||||
private String superBreakerLengthEndurance;
|
private String superBreakerLengthEndurance;
|
||||||
private String blastMiningRank;
|
|
||||||
private String blastRadiusIncrease;
|
private int blastMiningRank;
|
||||||
|
private int bonusTNTDrops;
|
||||||
|
private double blastRadiusIncrease;
|
||||||
|
private String oreBonus;
|
||||||
|
private String debrisReduction;
|
||||||
private String blastDamageDecrease;
|
private String blastDamageDecrease;
|
||||||
|
|
||||||
private boolean canSuperBreaker;
|
private boolean canSuperBreaker;
|
||||||
@ -38,51 +45,13 @@ public class MiningCommand extends SkillCommand {
|
|||||||
doubleDropChanceLucky = doubleDropStrings[1];
|
doubleDropChanceLucky = doubleDropStrings[1];
|
||||||
|
|
||||||
// BLAST MINING
|
// BLAST MINING
|
||||||
if (skillValue >= BlastMining.rank8) {
|
MiningManager miningManager = UserManager.getPlayer(player).getMiningManager();
|
||||||
blastMiningRank = "8";
|
blastMiningRank = miningManager.getBlastMiningTier();
|
||||||
blastDamageDecrease = "100.00%";
|
bonusTNTDrops = miningManager.getDropMultiplier();
|
||||||
blastRadiusIncrease = "4";
|
oreBonus = percent.format(miningManager.getOreBonus() / 30.0D); // Base received in TNT is 30%
|
||||||
}
|
debrisReduction = percent.format(miningManager.getDebrisReduction() / 30.0D); // Base received in TNT is 30%
|
||||||
else if (skillValue >= BlastMining.rank7) {
|
blastDamageDecrease = percent.format(miningManager.getBlastDamageModifier() / 100.0D);
|
||||||
blastMiningRank = "7";
|
blastRadiusIncrease = miningManager.getBlastRadiusModifier();
|
||||||
blastDamageDecrease = "50.00%";
|
|
||||||
blastRadiusIncrease = "3";
|
|
||||||
}
|
|
||||||
else if (skillValue >= BlastMining.rank6) {
|
|
||||||
blastMiningRank = "6";
|
|
||||||
blastDamageDecrease = "50.00%";
|
|
||||||
blastRadiusIncrease = "3";
|
|
||||||
}
|
|
||||||
else if (skillValue >= BlastMining.rank5) {
|
|
||||||
blastMiningRank = "5";
|
|
||||||
blastDamageDecrease = "25.00%";
|
|
||||||
blastRadiusIncrease = "2";
|
|
||||||
}
|
|
||||||
else if (skillValue >= BlastMining.rank4) {
|
|
||||||
blastMiningRank = "4";
|
|
||||||
blastDamageDecrease = "25.00%";
|
|
||||||
blastRadiusIncrease = "2";
|
|
||||||
}
|
|
||||||
else if (skillValue >= BlastMining.rank3) {
|
|
||||||
blastMiningRank = "3";
|
|
||||||
blastDamageDecrease = "0.00%";
|
|
||||||
blastRadiusIncrease = "1";
|
|
||||||
}
|
|
||||||
else if (skillValue >= BlastMining.rank2) {
|
|
||||||
blastMiningRank = "2";
|
|
||||||
blastDamageDecrease = "0.00%";
|
|
||||||
blastRadiusIncrease = "1";
|
|
||||||
}
|
|
||||||
else if (skillValue >= BlastMining.rank1) {
|
|
||||||
blastMiningRank = "1";
|
|
||||||
blastDamageDecrease = "0.00%";
|
|
||||||
blastRadiusIncrease = "0";
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
blastMiningRank = "0";
|
|
||||||
blastDamageDecrease = "0.00%";
|
|
||||||
blastRadiusIncrease = "0";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -151,17 +120,17 @@ public class MiningCommand extends SkillCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (canBlast) {
|
if (canBlast) {
|
||||||
if (skillValue < BlastMining.rank1) {
|
if (skillValue < AdvancedConfig.getInstance().getBlastMiningRank1()) {
|
||||||
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Mining.Ability.Locked.0", BlastMining.rank1)));
|
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Mining.Ability.Locked.0", AdvancedConfig.getInstance().getBlastMiningRank1())));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
player.sendMessage(LocaleLoader.getString("Mining.Blast.Rank", blastMiningRank, LocaleLoader.getString("Mining.Blast.Effect." + (Integer.parseInt(blastMiningRank) - 1))));
|
player.sendMessage(LocaleLoader.getString("Mining.Blast.Rank", blastMiningRank, LocaleLoader.getString("Mining.Blast.Effect", oreBonus, debrisReduction, bonusTNTDrops)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (canBiggerBombs) {
|
if (canBiggerBombs) {
|
||||||
if (skillValue < BlastMining.rank2) {
|
if (skillValue < AdvancedConfig.getInstance().getBlastMiningRank2()) {
|
||||||
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Mining.Ability.Locked.1", BlastMining.rank2)));
|
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Mining.Ability.Locked.1", AdvancedConfig.getInstance().getBlastMiningRank2())));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
player.sendMessage(LocaleLoader.getString("Mining.Blast.Radius.Increase", blastRadiusIncrease));
|
player.sendMessage(LocaleLoader.getString("Mining.Blast.Radius.Increase", blastRadiusIncrease));
|
||||||
@ -169,8 +138,8 @@ public class MiningCommand extends SkillCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (canDemoExpert) {
|
if (canDemoExpert) {
|
||||||
if (skillValue < BlastMining.rank4) {
|
if (skillValue < AdvancedConfig.getInstance().getBlastMiningRank4()) {
|
||||||
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Mining.Ability.Locked.2", BlastMining.rank4)));
|
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Mining.Ability.Locked.2", AdvancedConfig.getInstance().getBlastMiningRank4())));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
player.sendMessage(LocaleLoader.getString("Mining.Effect.Decrease", blastDamageDecrease));
|
player.sendMessage(LocaleLoader.getString("Mining.Effect.Decrease", blastDamageDecrease));
|
@ -1,11 +1,13 @@
|
|||||||
package com.gmail.nossr50.skills.repair;
|
package com.gmail.nossr50.commands.skills;
|
||||||
|
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
|
|
||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
|
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.skills.SkillCommand;
|
import com.gmail.nossr50.skills.repair.Repair;
|
||||||
import com.gmail.nossr50.skills.utilities.SkillType;
|
import com.gmail.nossr50.skills.repair.Repairable;
|
||||||
|
import com.gmail.nossr50.skills.repair.Salvage;
|
||||||
import com.gmail.nossr50.util.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
|
|
||||||
public class RepairCommand extends SkillCommand {
|
public class RepairCommand extends SkillCommand {
|
||||||
@ -51,15 +53,15 @@ public class RepairCommand extends SkillCommand {
|
|||||||
stoneLevel = (stoneRepairable == null) ? 0 : stoneRepairable.getMinimumLevel();
|
stoneLevel = (stoneRepairable == null) ? 0 : stoneRepairable.getMinimumLevel();
|
||||||
|
|
||||||
// REPAIR MASTERY
|
// REPAIR MASTERY
|
||||||
if (skillValue >= Repair.REPAIR_MASTERY_MAX_BONUS_LEVEL) {
|
if (skillValue >= Repair.repairMasteryMaxBonusLevel) {
|
||||||
repairMasteryBonus = percent.format(Repair.REPAIR_MASTERY_CHANCE_MAX / 100D);
|
repairMasteryBonus = percent.format(Repair.repairMasteryMaxBonus / 100D);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
repairMasteryBonus = percent.format((( Repair.REPAIR_MASTERY_CHANCE_MAX / Repair.REPAIR_MASTERY_MAX_BONUS_LEVEL) * skillValue) / 100D);
|
repairMasteryBonus = percent.format(((Repair.repairMasteryMaxBonus / Repair.repairMasteryMaxBonusLevel) * skillValue) / 100D);
|
||||||
}
|
}
|
||||||
|
|
||||||
// SUPER REPAIR
|
// SUPER REPAIR
|
||||||
String[] superRepairStrings = calculateAbilityDisplayValues(Repair.SUPER_REPAIR_MAX_BONUS_LEVEL, Repair.SUPER_REPAIR_CHANCE_MAX);
|
String[] superRepairStrings = calculateAbilityDisplayValues(Repair.superRepairMaxBonusLevel, Repair.superRepairMaxChance);
|
||||||
superRepairChance = superRepairStrings[0];
|
superRepairChance = superRepairStrings[0];
|
||||||
superRepairChanceLucky = superRepairStrings[1];
|
superRepairChanceLucky = superRepairStrings[1];
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
package com.gmail.nossr50.skills;
|
package com.gmail.nossr50.commands.skills;
|
||||||
|
|
||||||
import java.text.DecimalFormat;
|
import java.text.DecimalFormat;
|
||||||
|
|
||||||
@ -7,15 +7,16 @@ import org.bukkit.command.CommandExecutor;
|
|||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import com.gmail.nossr50.commands.CommandHelper;
|
import com.gmail.nossr50.config.AdvancedConfig;
|
||||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
||||||
|
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.skills.utilities.PerksUtils;
|
|
||||||
import com.gmail.nossr50.skills.utilities.SkillTools;
|
|
||||||
import com.gmail.nossr50.skills.utilities.SkillType;
|
|
||||||
import com.gmail.nossr50.util.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
import com.gmail.nossr50.util.StringUtils;
|
import com.gmail.nossr50.util.StringUtils;
|
||||||
import com.gmail.nossr50.util.Users;
|
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||||
|
import com.gmail.nossr50.util.player.UserManager;
|
||||||
|
import com.gmail.nossr50.util.skills.PerksUtils;
|
||||||
|
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||||
|
|
||||||
public abstract class SkillCommand implements CommandExecutor {
|
public abstract class SkillCommand implements CommandExecutor {
|
||||||
protected SkillType skill;
|
protected SkillType skill;
|
||||||
@ -37,12 +38,12 @@ public abstract class SkillCommand implements CommandExecutor {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
if (CommandHelper.noConsoleUsage(sender)) {
|
if (CommandUtils.noConsoleUsage(sender)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
player = (Player) sender;
|
player = (Player) sender;
|
||||||
profile = Users.getPlayer(player).getProfile();
|
profile = UserManager.getPlayer(player).getProfile();
|
||||||
|
|
||||||
if (profile == null) {
|
if (profile == null) {
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
|
sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
|
||||||
@ -75,7 +76,7 @@ public abstract class SkillCommand implements CommandExecutor {
|
|||||||
|
|
||||||
statsDisplay();
|
statsDisplay();
|
||||||
|
|
||||||
return SkillGuide.grabGuidePageForSkill(skill, player, args);
|
return SkillGuideCommand.grabGuidePageForSkill(skill, player, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String calculateRank(int maxLevel, int rankChangeLevel) {
|
protected String calculateRank(int maxLevel, int rankChangeLevel) {
|
||||||
@ -125,7 +126,7 @@ public abstract class SkillCommand implements CommandExecutor {
|
|||||||
|
|
||||||
protected String[] calculateLengthDisplayValues() {
|
protected String[] calculateLengthDisplayValues() {
|
||||||
int maxLength = skill.getAbility().getMaxTicks();
|
int maxLength = skill.getAbility().getMaxTicks();
|
||||||
int length = 2 + (int) (skillValue / SkillTools.abilityLengthIncreaseLevel);
|
int length = 2 + (int) (skillValue / AdvancedConfig.getInstance().getAbilityLength());
|
||||||
int enduranceLength = PerksUtils.handleActivationPerks(player, length, maxLength);
|
int enduranceLength = PerksUtils.handleActivationPerks(player, length, maxLength);
|
||||||
|
|
||||||
if (maxLength != 0) {
|
if (maxLength != 0) {
|
||||||
@ -140,7 +141,7 @@ public abstract class SkillCommand implements CommandExecutor {
|
|||||||
protected void luckyEffectsDisplay() {
|
protected void luckyEffectsDisplay() {
|
||||||
if (isLucky) {
|
if (isLucky) {
|
||||||
String perkPrefix = LocaleLoader.getString("MOTD.PerksPrefix");
|
String perkPrefix = LocaleLoader.getString("MOTD.PerksPrefix");
|
||||||
player.sendMessage(perkPrefix + LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Perks.lucky.name"), LocaleLoader.getString("Perks.lucky.desc", SkillTools.getSkillName(skill))));
|
player.sendMessage(perkPrefix + LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Perks.lucky.name"), LocaleLoader.getString("Perks.lucky.desc", SkillUtils.getSkillName(skill))));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -0,0 +1,107 @@
|
|||||||
|
package com.gmail.nossr50.commands.skills;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||||
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
|
import com.gmail.nossr50.util.StringUtils;
|
||||||
|
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||||
|
|
||||||
|
public final class SkillGuideCommand {
|
||||||
|
private SkillGuideCommand() {}
|
||||||
|
|
||||||
|
public static int getTotalPageNumber(String address) {
|
||||||
|
String[] addressSplit = LocaleLoader.getString(address).split("\n");
|
||||||
|
|
||||||
|
if (addressSplit.length <= 8) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (addressSplit.length / 8) + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ArrayList<String> grabPageContents(String header, String address, int pagenum) {
|
||||||
|
int pageIndexStart = 0;
|
||||||
|
|
||||||
|
// Determine what string to start at
|
||||||
|
if (pagenum > 1) {
|
||||||
|
pageIndexStart = 8 * (pagenum - 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
ArrayList<String> allStrings = new ArrayList<String>();
|
||||||
|
String split[] = LocaleLoader.getString(address).split("\n");
|
||||||
|
|
||||||
|
allStrings.add(LocaleLoader.getString("Guides.Header", header));
|
||||||
|
|
||||||
|
// Add targeted strings
|
||||||
|
while (allStrings.size() < 9) {
|
||||||
|
if (pageIndexStart + allStrings.size() > split.length) {
|
||||||
|
allStrings.add("");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
allStrings.add(split[pageIndexStart + allStrings.size() - 1]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
allStrings.add("Page " + pagenum + " of " + getTotalPageNumber(address));
|
||||||
|
return allStrings;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void clearChat(Player player) {
|
||||||
|
player.sendMessage("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"); // Dear god why?
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean grabGuidePageForSkill(SkillType skilltype, Player player, String[] args) {
|
||||||
|
String skillName = skilltype.toString();
|
||||||
|
String capitalized = StringUtils.getCapitalized(skillName);
|
||||||
|
String localized = SkillUtils.getSkillName(skilltype);
|
||||||
|
player.sendMessage(LocaleLoader.getString("Guides.Available", localized, localized.toLowerCase()));
|
||||||
|
|
||||||
|
String address = "Guides." + capitalized;
|
||||||
|
|
||||||
|
switch (args.length) {
|
||||||
|
case 0:
|
||||||
|
// We have to specify this, otherwise we get the usage string every time we call /skillname...
|
||||||
|
return true;
|
||||||
|
|
||||||
|
case 1:
|
||||||
|
if (!args[0].equals("?")) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
SkillGuideCommand.clearChat(player);
|
||||||
|
|
||||||
|
for (String target : SkillGuideCommand.grabPageContents(localized, address, 1)) {
|
||||||
|
player.sendMessage(target);
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
|
||||||
|
case 2:
|
||||||
|
int totalPages = SkillGuideCommand.getTotalPageNumber(address);
|
||||||
|
|
||||||
|
if (!StringUtils.isInt(args[1])) {
|
||||||
|
player.sendMessage(LocaleLoader.getString("Guides.Page.Invalid"));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Integer.parseInt(args[1]) > totalPages) {
|
||||||
|
player.sendMessage(LocaleLoader.getString("Guides.Page.OutOfRange", totalPages));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
SkillGuideCommand.clearChat(player);
|
||||||
|
|
||||||
|
for (String target : SkillGuideCommand.grabPageContents(localized, address, Integer.parseInt(args[1]))) {
|
||||||
|
player.sendMessage(target);
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,9 +1,11 @@
|
|||||||
package com.gmail.nossr50.skills.smelting;
|
package com.gmail.nossr50.commands.skills;
|
||||||
|
|
||||||
|
import com.gmail.nossr50.config.AdvancedConfig;
|
||||||
|
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.skills.SkillCommand;
|
import com.gmail.nossr50.skills.smelting.Smelting;
|
||||||
import com.gmail.nossr50.skills.utilities.SkillType;
|
|
||||||
import com.gmail.nossr50.util.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
|
import com.gmail.nossr50.util.player.UserManager;
|
||||||
|
|
||||||
public class SmeltingCommand extends SkillCommand {
|
public class SmeltingCommand extends SkillCommand {
|
||||||
private String burnTimeModifier;
|
private String burnTimeModifier;
|
||||||
@ -11,7 +13,8 @@ public class SmeltingCommand extends SkillCommand {
|
|||||||
private String secondSmeltChanceLucky;
|
private String secondSmeltChanceLucky;
|
||||||
private String fluxMiningChance;
|
private String fluxMiningChance;
|
||||||
private String fluxMiningChanceLucky;
|
private String fluxMiningChanceLucky;
|
||||||
private String vanillaXPModifier;
|
|
||||||
|
private int vanillaXPModifier;
|
||||||
|
|
||||||
private boolean canFuelEfficiency;
|
private boolean canFuelEfficiency;
|
||||||
private boolean canSecondSmelt;
|
private boolean canSecondSmelt;
|
||||||
@ -38,21 +41,7 @@ public class SmeltingCommand extends SkillCommand {
|
|||||||
fluxMiningChanceLucky = fluxMiningStrings[1];
|
fluxMiningChanceLucky = fluxMiningStrings[1];
|
||||||
|
|
||||||
// VANILLA XP BOOST
|
// VANILLA XP BOOST
|
||||||
if (skillValue >= Smelting.vanillaXPBoostRank5Level) {
|
vanillaXPModifier = UserManager.getPlayer(player).getSmeltingManager().getVanillaXpMultiplier();
|
||||||
vanillaXPModifier = String.valueOf(Smelting.vanillaXPBoostRank5Multiplier);
|
|
||||||
}
|
|
||||||
else if (skillValue >= Smelting.vanillaXPBoostRank4Level) {
|
|
||||||
vanillaXPModifier = String.valueOf(Smelting.vanillaXPBoostRank4Multiplier);
|
|
||||||
}
|
|
||||||
else if (skillValue >= Smelting.vanillaXPBoostRank3Level) {
|
|
||||||
vanillaXPModifier = String.valueOf(Smelting.vanillaXPBoostRank3Multiplier);
|
|
||||||
}
|
|
||||||
else if (skillValue >= Smelting.vanillaXPBoostRank2Level) {
|
|
||||||
vanillaXPModifier = String.valueOf(Smelting.vanillaXPBoostRank2Multiplier);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
vanillaXPModifier = String.valueOf(Smelting.vanillaXPBoostRank1Multiplier);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -110,8 +99,8 @@ public class SmeltingCommand extends SkillCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (canVanillaXPBoost) {
|
if (canVanillaXPBoost) {
|
||||||
if (skillValue < Smelting.vanillaXPBoostRank1Level) {
|
if (skillValue < AdvancedConfig.getInstance().getSmeltingVanillaXPBoostRank1Level()) {
|
||||||
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Smelting.Ability.Locked.0", Smelting.vanillaXPBoostRank1Level)));
|
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Smelting.Ability.Locked.0", AdvancedConfig.getInstance().getSmeltingVanillaXPBoostRank1Level())));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
player.sendMessage(LocaleLoader.getString("Smelting.Ability.VanillaXPBoost", vanillaXPModifier));
|
player.sendMessage(LocaleLoader.getString("Smelting.Ability.VanillaXPBoost", vanillaXPModifier));
|
@ -1,8 +1,8 @@
|
|||||||
package com.gmail.nossr50.skills.swords;
|
package com.gmail.nossr50.commands.skills;
|
||||||
|
|
||||||
|
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.skills.SkillCommand;
|
import com.gmail.nossr50.skills.swords.Swords;
|
||||||
import com.gmail.nossr50.skills.utilities.SkillType;
|
|
||||||
import com.gmail.nossr50.util.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
|
|
||||||
public class SwordsCommand extends SkillCommand {
|
public class SwordsCommand extends SkillCommand {
|
@ -1,9 +1,9 @@
|
|||||||
package com.gmail.nossr50.skills.taming;
|
package com.gmail.nossr50.commands.skills;
|
||||||
|
|
||||||
import com.gmail.nossr50.config.Config;
|
import com.gmail.nossr50.config.Config;
|
||||||
|
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.skills.SkillCommand;
|
import com.gmail.nossr50.skills.taming.Taming;
|
||||||
import com.gmail.nossr50.skills.utilities.SkillType;
|
|
||||||
import com.gmail.nossr50.util.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
|
|
||||||
public class TamingCommand extends SkillCommand {
|
public class TamingCommand extends SkillCommand {
|
||||||
@ -18,6 +18,7 @@ public class TamingCommand extends SkillCommand {
|
|||||||
private boolean canShockProof;
|
private boolean canShockProof;
|
||||||
private boolean canCallWild;
|
private boolean canCallWild;
|
||||||
private boolean canFastFood;
|
private boolean canFastFood;
|
||||||
|
private boolean canHolyHound;
|
||||||
|
|
||||||
public TamingCommand() {
|
public TamingCommand() {
|
||||||
super(SkillType.TAMING);
|
super(SkillType.TAMING);
|
||||||
@ -40,11 +41,12 @@ public class TamingCommand extends SkillCommand {
|
|||||||
canSharpenedClaws = Permissions.sharpenedClaws(player);
|
canSharpenedClaws = Permissions.sharpenedClaws(player);
|
||||||
canShockProof = Permissions.shockProof(player);
|
canShockProof = Permissions.shockProof(player);
|
||||||
canThickFur = Permissions.thickFur(player);
|
canThickFur = Permissions.thickFur(player);
|
||||||
|
canHolyHound = Permissions.holyHound(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean effectsHeaderPermissions() {
|
protected boolean effectsHeaderPermissions() {
|
||||||
return canBeastLore || canCallWild || canEnvironmentallyAware || canFastFood || canGore || canSharpenedClaws || canShockProof || canThickFur;
|
return canBeastLore || canCallWild || canEnvironmentallyAware || canFastFood || canGore || canSharpenedClaws || canShockProof || canThickFur || canHolyHound;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -79,6 +81,10 @@ public class TamingCommand extends SkillCommand {
|
|||||||
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Taming.Effect.16"), LocaleLoader.getString("Taming.Effect.17")));
|
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Taming.Effect.16"), LocaleLoader.getString("Taming.Effect.17")));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (canHolyHound) {
|
||||||
|
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Taming.Effect.18"), LocaleLoader.getString("Taming.Effect.19")));
|
||||||
|
}
|
||||||
|
|
||||||
if (canCallWild) {
|
if (canCallWild) {
|
||||||
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Taming.Effect.12"), LocaleLoader.getString("Taming.Effect.13")));
|
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Taming.Effect.12"), LocaleLoader.getString("Taming.Effect.13")));
|
||||||
player.sendMessage(LocaleLoader.getString("Taming.Effect.14", Config.getInstance().getTamingCOTWOcelotCost()));
|
player.sendMessage(LocaleLoader.getString("Taming.Effect.14", Config.getInstance().getTamingCOTWOcelotCost()));
|
||||||
@ -88,7 +94,7 @@ public class TamingCommand extends SkillCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean statsHeaderPermissions() {
|
protected boolean statsHeaderPermissions() {
|
||||||
return canEnvironmentallyAware || canFastFood || canGore || canSharpenedClaws || canShockProof || canThickFur;
|
return canEnvironmentallyAware || canFastFood || canGore || canSharpenedClaws || canShockProof || canThickFur || canHolyHound;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -120,6 +126,15 @@ public class TamingCommand extends SkillCommand {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (canHolyHound) {
|
||||||
|
if (skillValue < Taming.holyHoundUnlockLevel) {
|
||||||
|
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Taming.Ability.Locked.5", Taming.holyHoundUnlockLevel)));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template", LocaleLoader.getString("Taming.Ability.Bonus.10"), LocaleLoader.getString("Taming.Ability.Bonus.11")));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (canShockProof) {
|
if (canShockProof) {
|
||||||
if (skillValue < Taming.shockProofUnlockLevel) {
|
if (skillValue < Taming.shockProofUnlockLevel) {
|
||||||
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Taming.Ability.Locked.2", Taming.shockProofUnlockLevel)));
|
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Taming.Ability.Locked.2", Taming.shockProofUnlockLevel)));
|
@ -1,8 +1,8 @@
|
|||||||
package com.gmail.nossr50.skills.unarmed;
|
package com.gmail.nossr50.commands.skills;
|
||||||
|
|
||||||
|
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.skills.SkillCommand;
|
import com.gmail.nossr50.skills.unarmed.Unarmed;
|
||||||
import com.gmail.nossr50.skills.utilities.SkillType;
|
|
||||||
import com.gmail.nossr50.util.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
|
|
||||||
public class UnarmedCommand extends SkillCommand {
|
public class UnarmedCommand extends SkillCommand {
|
@ -1,9 +1,9 @@
|
|||||||
package com.gmail.nossr50.skills.woodcutting;
|
package com.gmail.nossr50.commands.skills;
|
||||||
|
|
||||||
import com.gmail.nossr50.config.AdvancedConfig;
|
import com.gmail.nossr50.config.AdvancedConfig;
|
||||||
|
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.skills.SkillCommand;
|
import com.gmail.nossr50.skills.woodcutting.Woodcutting;
|
||||||
import com.gmail.nossr50.skills.utilities.SkillType;
|
|
||||||
import com.gmail.nossr50.util.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
|
|
||||||
public class WoodcuttingCommand extends SkillCommand {
|
public class WoodcuttingCommand extends SkillCommand {
|
||||||
@ -29,8 +29,7 @@ public class WoodcuttingCommand extends SkillCommand {
|
|||||||
treeFellerLengthEndurance = treeFellerStrings[1];
|
treeFellerLengthEndurance = treeFellerStrings[1];
|
||||||
|
|
||||||
// DOUBLE DROPS
|
// DOUBLE DROPS
|
||||||
AdvancedConfig advancedConfig = AdvancedConfig.getInstance();
|
String[] doubleDropStrings = calculateAbilityDisplayValues(Woodcutting.doubleDropsMaxLevel, Woodcutting.doubleDropsMaxChance);
|
||||||
String[] doubleDropStrings = calculateAbilityDisplayValues(advancedConfig.getWoodcuttingDoubleDropMaxLevel(), advancedConfig.getWoodcuttingDoubleDropChance());
|
|
||||||
doubleDropChance = doubleDropStrings[0];
|
doubleDropChance = doubleDropStrings[0];
|
||||||
doubleDropChanceLucky = doubleDropStrings[1];
|
doubleDropChanceLucky = doubleDropStrings[1];
|
||||||
}
|
}
|
@ -1,10 +1,10 @@
|
|||||||
package com.gmail.nossr50.spout.commands;
|
package com.gmail.nossr50.commands.spout;
|
||||||
|
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
|
import com.gmail.nossr50.datatypes.spout.huds.HudType;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.spout.huds.HudType;
|
|
||||||
|
|
||||||
public class MchudCommand extends SpoutCommand {
|
public class MchudCommand extends SpoutCommand {
|
||||||
@Override
|
@Override
|
@ -1,4 +1,4 @@
|
|||||||
package com.gmail.nossr50.spout.commands;
|
package com.gmail.nossr50.commands.spout;
|
||||||
|
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandExecutor;
|
import org.bukkit.command.CommandExecutor;
|
||||||
@ -6,20 +6,20 @@ import org.bukkit.command.CommandSender;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.gmail.nossr50.commands.CommandHelper;
|
import com.gmail.nossr50.config.spout.SpoutConfig;
|
||||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
||||||
|
import com.gmail.nossr50.datatypes.spout.huds.McMMOHud;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.spout.SpoutConfig;
|
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||||
import com.gmail.nossr50.spout.huds.SpoutHud;
|
import com.gmail.nossr50.util.player.UserManager;
|
||||||
import com.gmail.nossr50.util.Users;
|
|
||||||
|
|
||||||
public abstract class SpoutCommand implements CommandExecutor {
|
public abstract class SpoutCommand implements CommandExecutor {
|
||||||
protected PlayerProfile playerProfile;
|
protected PlayerProfile playerProfile;
|
||||||
protected SpoutHud spoutHud;
|
protected McMMOHud spoutHud;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
if (CommandHelper.noConsoleUsage(sender)) {
|
if (CommandUtils.noConsoleUsage(sender)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -28,7 +28,7 @@ public abstract class SpoutCommand implements CommandExecutor {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
playerProfile = Users.getPlayer((Player) sender).getProfile();
|
playerProfile = UserManager.getPlayer((Player) sender).getProfile();
|
||||||
spoutHud = playerProfile.getSpoutHud();
|
spoutHud = playerProfile.getSpoutHud();
|
||||||
|
|
||||||
if (spoutHud == null) {
|
if (spoutHud == null) {
|
||||||
@ -49,5 +49,6 @@ public abstract class SpoutCommand implements CommandExecutor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected abstract boolean noArguments(Command command, CommandSender sender, String[] args);
|
protected abstract boolean noArguments(Command command, CommandSender sender, String[] args);
|
||||||
|
|
||||||
protected abstract boolean oneArgument(Command command, CommandSender sender, String[] args);
|
protected abstract boolean oneArgument(Command command, CommandSender sender, String[] args);
|
||||||
}
|
}
|
@ -1,12 +1,12 @@
|
|||||||
package com.gmail.nossr50.spout.commands;
|
package com.gmail.nossr50.commands.spout;
|
||||||
|
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
|
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.skills.utilities.SkillTools;
|
|
||||||
import com.gmail.nossr50.skills.utilities.SkillType;
|
|
||||||
import com.gmail.nossr50.util.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
|
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||||
|
|
||||||
public class XplockCommand extends SpoutCommand {
|
public class XplockCommand extends SpoutCommand {
|
||||||
@Override
|
@Override
|
||||||
@ -32,13 +32,18 @@ public class XplockCommand extends SpoutCommand {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!SkillTools.isSkill(args[0])) {
|
if (!SkillUtils.isSkill(args[0])) {
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
|
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
SkillType skill = SkillType.getSkill(args[0]);
|
SkillType skill = SkillType.getSkill(args[0]);
|
||||||
|
|
||||||
|
if (skill.isChildSkill()) {
|
||||||
|
sender.sendMessage("Child skills are not yet supported by this command."); // TODO: Localize this
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
if (!Permissions.xplock(sender, skill)) {
|
if (!Permissions.xplock(sender, skill)) {
|
||||||
sender.sendMessage(command.getPermissionMessage());
|
sender.sendMessage(command.getPermissionMessage());
|
||||||
return true;
|
return true;
|
||||||
@ -53,7 +58,7 @@ public class XplockCommand extends SpoutCommand {
|
|||||||
spoutHud.setXpBarLocked(true);
|
spoutHud.setXpBarLocked(true);
|
||||||
spoutHud.setSkillLock(skill);
|
spoutHud.setSkillLock(skill);
|
||||||
spoutHud.updateXpBar();
|
spoutHud.updateXpBar();
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.xplock.locked", SkillTools.getSkillName(skill)));
|
sender.sendMessage(LocaleLoader.getString("Commands.xplock.locked", SkillUtils.getSkillName(skill)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,11 +1,10 @@
|
|||||||
package com.gmail.nossr50.config;
|
package com.gmail.nossr50.config;
|
||||||
|
|
||||||
public class AdvancedConfig extends ConfigLoader {
|
public class AdvancedConfig extends AutoUpdateConfigLoader {
|
||||||
private static AdvancedConfig instance;
|
private static AdvancedConfig instance;
|
||||||
|
|
||||||
private AdvancedConfig() {
|
private AdvancedConfig() {
|
||||||
super("advanced.yml");
|
super("advanced.yml");
|
||||||
loadKeys();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static AdvancedConfig getInstance() {
|
public static AdvancedConfig getInstance() {
|
||||||
@ -17,21 +16,24 @@ public class AdvancedConfig extends ConfigLoader {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void loadKeys() {
|
protected void loadKeys() {}
|
||||||
// TODO Do we need to use this?
|
|
||||||
}
|
|
||||||
/* GENERAL */
|
/* GENERAL */
|
||||||
public int getAbilityLength() { return config.getInt("Skills.General.Ability_IncreaseLevel", 50); }
|
public int getAbilityLength() { return config.getInt("Skills.General.Ability_IncreaseLevel", 50); }
|
||||||
|
|
||||||
/* ACROBATICS */
|
/* ACROBATICS */
|
||||||
public double getDodgeChanceMax() { return config.getDouble("Skills.Acrobatics.Dodge_ChanceMax", 20.0D); }
|
public double getDodgeChanceMax() { return config.getDouble("Skills.Acrobatics.Dodge_ChanceMax", 20.0D); }
|
||||||
public int getDodgeMaxBonusLevel() { return config.getInt("Skills.Acrobatics.Dodge_MaxBonusLevel", 800); }
|
public int getDodgeMaxBonusLevel() { return config.getInt("Skills.Acrobatics.Dodge_MaxBonusLevel", 800); }
|
||||||
|
public int getDodgeDamageModifier() { return config.getInt("Skills.Acrobatics.Dodge_DamageModifer", 2); }
|
||||||
|
|
||||||
public double getRollChanceMax() { return config.getDouble("Skills.Acrobatics.Roll_ChanceMax", 100.0D); }
|
public double getRollChanceMax() { return config.getDouble("Skills.Acrobatics.Roll_ChanceMax", 100.0D); }
|
||||||
public int getRollMaxBonusLevel() { return config.getInt("Skills.Acrobatics.Roll_MaxBonusLevel", 1000); }
|
public int getRollMaxBonusLevel() { return config.getInt("Skills.Acrobatics.Roll_MaxBonusLevel", 1000); }
|
||||||
|
public int getRollDamageThreshold() { return config.getInt("Skills.Acrobatics.Roll_DamageThreshold", 7); }
|
||||||
|
|
||||||
public double getGracefulRollChanceMax() { return config.getDouble("Skills.Acrobatics.GracefulRoll_ChanceMax", 100.0D); }
|
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 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 getDodgeXPModifier() { return config.getInt("Skills.Acrobatics.Dodge_XP_Modifier", 120); }
|
||||||
public int getRollXPModifier() { return config.getInt("Skills.Acrobatics.Roll_XP_Modifier", 80); }
|
public int getRollXPModifier() { return config.getInt("Skills.Acrobatics.Roll_XP_Modifier", 80); }
|
||||||
@ -63,6 +65,7 @@ public class AdvancedConfig extends ConfigLoader {
|
|||||||
public int getGreaterImpactBonusDamage() { return config.getInt("Skills.Axes.GreaterImpact_BonusDamage", 2); }
|
public int getGreaterImpactBonusDamage() { return config.getInt("Skills.Axes.GreaterImpact_BonusDamage", 2); }
|
||||||
|
|
||||||
public int getArmorImpactIncreaseLevel() { return config.getInt("Skills.Axes.ArmorImpact_IncreaseLevel", 50); }
|
public int getArmorImpactIncreaseLevel() { return config.getInt("Skills.Axes.ArmorImpact_IncreaseLevel", 50); }
|
||||||
|
public double getImpactChance() { return config.getDouble("Skills.Axes.ArmorImpact_Chance", 25.0D); }
|
||||||
public double getArmorImpactMaxDurabilityDamage() { return config.getDouble("Skills.Axes.ArmorImpact_MaxPercentageDurabilityDamage", 20.0D); }
|
public double getArmorImpactMaxDurabilityDamage() { return config.getDouble("Skills.Axes.ArmorImpact_MaxPercentageDurabilityDamage", 20.0D); }
|
||||||
|
|
||||||
public int getSkullSplitterModifier() { return config.getInt("Skills.Axes.SkullSplitter_DamagerModifier", 2); }
|
public int getSkullSplitterModifier() { return config.getInt("Skills.Axes.SkullSplitter_DamagerModifier", 2); }
|
||||||
@ -107,7 +110,10 @@ public class AdvancedConfig extends ConfigLoader {
|
|||||||
public int getHerbalismDoubleDropsMaxLevel() { return config.getInt("Skills.Herbalism.DoubleDrops_MaxBonusLevel", 1000); }
|
public int getHerbalismDoubleDropsMaxLevel() { return config.getInt("Skills.Herbalism.DoubleDrops_MaxBonusLevel", 1000); }
|
||||||
|
|
||||||
public double getHylianLuckChanceMax() { return config.getDouble("Skills.Herbalism.HylianLuck_ChanceMax", 10.0D); }
|
public double getHylianLuckChanceMax() { return config.getDouble("Skills.Herbalism.HylianLuck_ChanceMax", 10.0D); }
|
||||||
public int getHylianLucksMaxLevel() { return config.getInt("Skills.Herbalism.HylianLuck_MaxBonusLevel", 1000); }
|
public int getHylianLuckMaxLevel() { return config.getInt("Skills.Herbalism.HylianLuck_MaxBonusLevel", 1000); }
|
||||||
|
|
||||||
|
public double getShroomThumbChanceMax() { return config.getDouble("Skills.Herbalism.ShroomThumb_ChanceMax", 50.0D); }
|
||||||
|
public int getShroomThumbMaxLevel() { return config.getInt("Skills.Herbalism.ShroomThumb_MaxBonusLevel", 1500); }
|
||||||
|
|
||||||
/* MINING */
|
/* MINING */
|
||||||
public double getMiningDoubleDropChance() { return config.getDouble("Skills.Mining.DoubleDrops_ChanceMax", 100.0D); }
|
public double getMiningDoubleDropChance() { return config.getDouble("Skills.Mining.DoubleDrops_ChanceMax", 100.0D); }
|
||||||
@ -122,6 +128,51 @@ public class AdvancedConfig extends ConfigLoader {
|
|||||||
public int getBlastMiningRank7() { return config.getInt("Skills.Mining.BlastMining_Rank7", 875); }
|
public int getBlastMiningRank7() { return config.getInt("Skills.Mining.BlastMining_Rank7", 875); }
|
||||||
public int getBlastMiningRank8() { return config.getInt("Skills.Mining.BlastMining_Rank8", 1000); }
|
public int getBlastMiningRank8() { return config.getInt("Skills.Mining.BlastMining_Rank8", 1000); }
|
||||||
|
|
||||||
|
public double getBlastDamageDecreaseRank1() { return config.getDouble("Skills.Mining.BlastDamageDecrease_Rank1", 0.0D); }
|
||||||
|
public double getBlastDamageDecreaseRank2() { return config.getDouble("Skills.Mining.BlastDamageDecrease_Rank2", 0.0D); }
|
||||||
|
public double getBlastDamageDecreaseRank3() { return config.getDouble("Skills.Mining.BlastDamageDecrease_Rank3", 0.0D); }
|
||||||
|
public double getBlastDamageDecreaseRank4() { return config.getDouble("Skills.Mining.BlastDamageDecrease_Rank4", 25.0D); }
|
||||||
|
public double getBlastDamageDecreaseRank5() { return config.getDouble("Skills.Mining.BlastDamageDecrease_Rank5", 25.0D); }
|
||||||
|
public double getBlastDamageDecreaseRank6() { return config.getDouble("Skills.Mining.BlastDamageDecrease_Rank6", 50.0D); }
|
||||||
|
public double getBlastDamageDecreaseRank7() { return config.getDouble("Skills.Mining.BlastDamageDecrease_Rank7", 50.0D); }
|
||||||
|
public double getBlastDamageDecreaseRank8() { return config.getDouble("Skills.Mining.BlastDamageDecrease_Rank8", 100.0D); }
|
||||||
|
|
||||||
|
public double getOreBonusRank1() { return config.getDouble("Skills.Mining.OreBonus_Rank1", 35.0D); }
|
||||||
|
public double getOreBonusRank2() { return config.getDouble("Skills.Mining.OreBonus_Rank2", 40.0D); }
|
||||||
|
public double getOreBonusRank3() { return config.getDouble("Skills.Mining.OreBonus_Rank3", 45.0D); }
|
||||||
|
public double getOreBonusRank4() { return config.getDouble("Skills.Mining.OreBonus_Rank4", 50.0D); }
|
||||||
|
public double getOreBonusRank5() { return config.getDouble("Skills.Mining.OreBonus_Rank5", 55.0D); }
|
||||||
|
public double getOreBonusRank6() { return config.getDouble("Skills.Mining.OreBonus_Rank6", 60.0D); }
|
||||||
|
public double getOreBonusRank7() { return config.getDouble("Skills.Mining.OreBonus_Rank7", 65.0D); }
|
||||||
|
public double getOreBonusRank8() { return config.getDouble("Skills.Mining.OreBonus_Rank8", 70.0D); }
|
||||||
|
|
||||||
|
public double getDebrisReductionRank1() { return config.getDouble("Skills.Mining.DebrisReduction_Rank1", 10.0D); }
|
||||||
|
public double getDebrisReductionRank2() { return config.getDouble("Skills.Mining.DebrisReduction_Rank2", 20.0D); }
|
||||||
|
public double getDebrisReductionRank3() { return config.getDouble("Skills.Mining.DebrisReduction_Rank3", 30.0D); }
|
||||||
|
public double getDebrisReductionRank4() { return config.getDouble("Skills.Mining.DebrisReduction_Rank4", 30.0D); }
|
||||||
|
public double getDebrisReductionRank5() { return config.getDouble("Skills.Mining.DebrisReduction_Rank5", 30.0D); }
|
||||||
|
public double getDebrisReductionRank6() { return config.getDouble("Skills.Mining.DebrisReduction_Rank6", 30.0D); }
|
||||||
|
public double getDebrisReductionRank7() { return config.getDouble("Skills.Mining.DebrisReduction_Rank7", 30.0D); }
|
||||||
|
public double getDebrisReductionRank8() { return config.getDouble("Skills.Mining.DebrisReduction_Rank8", 30.0D); }
|
||||||
|
|
||||||
|
public int getDropMultiplierRank1() { return config.getInt("Skills.Mining.DropMultiplier_Rank1", 1); }
|
||||||
|
public int getDropMultiplierRank2() { return config.getInt("Skills.Mining.DropMultiplier_Rank2", 1); }
|
||||||
|
public int getDropMultiplierRank3() { return config.getInt("Skills.Mining.DropMultiplier_Rank3", 1); }
|
||||||
|
public int getDropMultiplierRank4() { return config.getInt("Skills.Mining.DropMultiplier_Rank4", 1); }
|
||||||
|
public int getDropMultiplierRank5() { return config.getInt("Skills.Mining.DropMultiplier_Rank5", 2); }
|
||||||
|
public int getDropMultiplierRank6() { return config.getInt("Skills.Mining.DropMultiplier_Rank6", 2); }
|
||||||
|
public int getDropMultiplierRank7() { return config.getInt("Skills.Mining.DropMultiplier_Rank7", 3); }
|
||||||
|
public int getDropMultiplierRank8() { return config.getInt("Skills.Mining.DropMultiplier_Rank8", 3); }
|
||||||
|
|
||||||
|
public double getBlastRadiusModifierRank1() { return config.getDouble("Skills.Mining.BlastRadiusModifier_Rank1", 1.0); }
|
||||||
|
public double getBlastRadiusModifierRank2() { return config.getDouble("Skills.Mining.BlastRadiusModifier_Rank2", 1.0); }
|
||||||
|
public double getBlastRadiusModifierRank3() { return config.getDouble("Skills.Mining.BlastRadiusModifier_Rank3", 2.0); }
|
||||||
|
public double getBlastRadiusModifierRank4() { return config.getDouble("Skills.Mining.BlastRadiusModifier_Rank4", 2.0); }
|
||||||
|
public double getBlastRadiusModifierRank5() { return config.getDouble("Skills.Mining.BlastRadiusModifier_Rank5", 3.0); }
|
||||||
|
public double getBlastRadiusModifierRank6() { return config.getDouble("Skills.Mining.BlastRadiusModifier_Rank6", 3.0); }
|
||||||
|
public double getBlastRadiusModifierRank7() { return config.getDouble("Skills.Mining.BlastRadiusModifier_Rank7", 4.0); }
|
||||||
|
public double getBlastRadiusModifierRank8() { return config.getDouble("Skills.Mining.BlastRadiusModifier_Rank8", 4.0); }
|
||||||
|
|
||||||
/* REPAIR */
|
/* REPAIR */
|
||||||
public double getRepairMasteryMaxBonus() { return config.getDouble("Skills.Repair.RepairMastery_MaxBonusPercentage", 200.0D); }
|
public double getRepairMasteryMaxBonus() { return config.getDouble("Skills.Repair.RepairMastery_MaxBonusPercentage", 200.0D); }
|
||||||
public int getRepairMasteryMaxLevel() { return config.getInt("Skills.Repair.RepairMastery_MaxBonusLevel", 1000); }
|
public int getRepairMasteryMaxLevel() { return config.getInt("Skills.Repair.RepairMastery_MaxBonusLevel", 1000); }
|
||||||
@ -193,6 +244,8 @@ public class AdvancedConfig extends ConfigLoader {
|
|||||||
public int getThickFurUnlock() { return config.getInt("Skills.Taming.ThickFur_UnlockLevel", 250); }
|
public int getThickFurUnlock() { return config.getInt("Skills.Taming.ThickFur_UnlockLevel", 250); }
|
||||||
public int getThickFurModifier() { return config.getInt("Skills.Taming.ThickFur_Modifier", 2); }
|
public int getThickFurModifier() { return config.getInt("Skills.Taming.ThickFur_Modifier", 2); }
|
||||||
|
|
||||||
|
public int getHolyHoundUnlock() {return config.getInt("Skills.Taming.HolyHound_UnlockLevel", 375); }
|
||||||
|
|
||||||
public int getShockProofUnlock() { return config.getInt("Skills.Taming.ShockProof_UnlockLevel", 500); }
|
public int getShockProofUnlock() { return config.getInt("Skills.Taming.ShockProof_UnlockLevel", 500); }
|
||||||
public int getShockProofModifier() { return config.getInt("Skills.Taming.ShockProof_Modifier", 6); }
|
public int getShockProofModifier() { return config.getInt("Skills.Taming.ShockProof_Modifier", 6); }
|
||||||
|
|
||||||
|
@ -0,0 +1,128 @@
|
|||||||
|
package com.gmail.nossr50.config;
|
||||||
|
|
||||||
|
import java.io.BufferedReader;
|
||||||
|
import java.io.BufferedWriter;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileWriter;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
|
|
||||||
|
import com.gmail.nossr50.metrics.MetricsManager;
|
||||||
|
|
||||||
|
public abstract class AutoUpdateConfigLoader extends ConfigLoader {
|
||||||
|
public AutoUpdateConfigLoader(String relativePath, String fileName) {
|
||||||
|
super(relativePath, fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
public AutoUpdateConfigLoader(String fileName) {
|
||||||
|
super(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void loadFile() {
|
||||||
|
super.loadFile();
|
||||||
|
FileConfiguration internalConfig = YamlConfiguration.loadConfiguration(plugin.getResource(fileName));
|
||||||
|
|
||||||
|
Set<String> configKeys = config.getKeys(true);
|
||||||
|
Set<String> internalConfigKeys = internalConfig.getKeys(true);
|
||||||
|
|
||||||
|
boolean needSave = false;
|
||||||
|
|
||||||
|
Set<String> oldKeys = new HashSet<String>(configKeys);
|
||||||
|
oldKeys.removeAll(internalConfigKeys);
|
||||||
|
|
||||||
|
Set<String> newKeys = new HashSet<String>(internalConfigKeys);
|
||||||
|
newKeys.removeAll(configKeys);
|
||||||
|
|
||||||
|
// Don't need a re-save if we have old keys sticking around?
|
||||||
|
// Would be less saving, but less... correct?
|
||||||
|
if (!newKeys.isEmpty() || !oldKeys.isEmpty()) {
|
||||||
|
needSave = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (String key : oldKeys) {
|
||||||
|
plugin.debug("Removing unused key: " + key);
|
||||||
|
config.set(key, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (String key : newKeys) {
|
||||||
|
plugin.debug("Adding new key: " + key + " = " + internalConfig.get(key));
|
||||||
|
config.set(key, internalConfig.get(key));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (needSave) {
|
||||||
|
// Get Bukkit's version of an acceptable config with new keys, and no old keys
|
||||||
|
String output = config.saveToString();
|
||||||
|
|
||||||
|
// Convert to the superior 4 space indentation
|
||||||
|
output = output.replace(" ", " ");
|
||||||
|
|
||||||
|
// Rip out Bukkit's attempt to save comments at the top of the file
|
||||||
|
while (output.indexOf('#') != -1) {
|
||||||
|
output = output.substring(output.indexOf('\n', output.indexOf('#')) + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Read the internal config to get comments, then put them in the new one
|
||||||
|
try {
|
||||||
|
// Read internal
|
||||||
|
BufferedReader reader = new BufferedReader(new InputStreamReader(plugin.getResource(fileName)));
|
||||||
|
HashMap<String, String> comments = new HashMap<String, String>();
|
||||||
|
String temp = "";
|
||||||
|
|
||||||
|
String line;
|
||||||
|
while ((line = reader.readLine()) != null) {
|
||||||
|
if (line.contains("#")) {
|
||||||
|
temp += line + "\n";
|
||||||
|
}
|
||||||
|
else if (line.contains(":")) {
|
||||||
|
line = line.substring(0, line.indexOf(":") + 1);
|
||||||
|
if (!temp.isEmpty()) {
|
||||||
|
comments.put(line, temp);
|
||||||
|
temp = "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Dump to the new one
|
||||||
|
for (String key : comments.keySet()) {
|
||||||
|
if (output.indexOf(key) != -1) {
|
||||||
|
output = output.substring(0, output.indexOf(key)) + comments.get(key) + output.substring(output.indexOf(key));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Save it
|
||||||
|
try {
|
||||||
|
String saveName = fileName;
|
||||||
|
// At this stage we cannot guarantee that Config has been loaded, so we do the check directly here
|
||||||
|
if (!plugin.getConfig().getBoolean("General.Config_Update_Overwrite", true)) {
|
||||||
|
saveName += ".new";
|
||||||
|
}
|
||||||
|
|
||||||
|
BufferedWriter writer = new BufferedWriter(new FileWriter(new File(plugin.getDataFolder(), saveName)));
|
||||||
|
writer.write(output);
|
||||||
|
writer.flush();
|
||||||
|
writer.close();
|
||||||
|
}
|
||||||
|
catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
for (String key : configKeys) {
|
||||||
|
if (!config.isConfigurationSection(key) && !config.get(key).equals(internalConfig.get(key))) {
|
||||||
|
MetricsManager.customConfig();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -6,16 +6,15 @@ import org.bukkit.Material;
|
|||||||
import org.bukkit.configuration.ConfigurationSection;
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
|
|
||||||
import com.gmail.nossr50.skills.utilities.AbilityType;
|
import com.gmail.nossr50.datatypes.skills.AbilityType;
|
||||||
import com.gmail.nossr50.skills.utilities.SkillType;
|
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||||
import com.gmail.nossr50.util.StringUtils;
|
import com.gmail.nossr50.util.StringUtils;
|
||||||
|
|
||||||
public class Config extends ConfigLoader {
|
public class Config extends AutoUpdateConfigLoader {
|
||||||
private static Config instance;
|
private static Config instance;
|
||||||
|
|
||||||
private Config() {
|
private Config() {
|
||||||
super("config.yml");
|
super("config.yml");
|
||||||
loadKeys();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Config getInstance() {
|
public static Config getInstance() {
|
||||||
@ -44,6 +43,8 @@ public class Config extends ConfigLoader {
|
|||||||
public boolean getEventCallbackEnabled() { return config.getBoolean("General.Event_Callback", true); }
|
public boolean getEventCallbackEnabled() { return config.getBoolean("General.Event_Callback", true); }
|
||||||
public boolean getBackupsEnabled() { return config.getBoolean("General.Generate_Backups", true); }
|
public boolean getBackupsEnabled() { return config.getBoolean("General.Generate_Backups", true); }
|
||||||
public boolean getVerboseLoggingEnabled() { return config.getBoolean("General.Verbose_Logging", false); }
|
public boolean getVerboseLoggingEnabled() { return config.getBoolean("General.Verbose_Logging", false); }
|
||||||
|
public boolean getConfigOverwriteEnabled() { return config.getBoolean("General.Config_Update_Overwrite", true); }
|
||||||
|
|
||||||
public boolean getPartyDisplayNames() { return config.getBoolean("Commands.p.Use_Display_Names", true); }
|
public boolean getPartyDisplayNames() { return config.getBoolean("Commands.p.Use_Display_Names", true); }
|
||||||
public boolean getAdminDisplayNames() { return config.getBoolean("Commands.a.Use_Display_Names", true); }
|
public boolean getAdminDisplayNames() { return config.getBoolean("Commands.a.Use_Display_Names", true); }
|
||||||
|
|
||||||
@ -104,6 +105,13 @@ public class Config extends ConfigLoader {
|
|||||||
public int getChimaeraItemId() { return config.getInt("Items.Chimaera_Wing.Item_ID", 288); }
|
public int getChimaeraItemId() { return config.getInt("Items.Chimaera_Wing.Item_ID", 288); }
|
||||||
public boolean getChimaeraEnabled() { return config.getBoolean("Items.Chimaera_Wing.Enabled", true); }
|
public boolean getChimaeraEnabled() { return config.getBoolean("Items.Chimaera_Wing.Enabled", true); }
|
||||||
|
|
||||||
|
/* Particles */
|
||||||
|
public boolean getAbilityActivationEffectEnabled() { return config.getBoolean("Particles.Ability_Activation", true); }
|
||||||
|
public boolean getAbilityDeactivationEffectEnabled() { return config.getBoolean("Particles.Ability_Deactivation", true); }
|
||||||
|
public boolean getDodgeEffectEnabled() { return config.getBoolean("Particles.Dodge", true); }
|
||||||
|
public boolean getBleedEffectEnabled() { return config.getBoolean("Particles.Bleed", true); }
|
||||||
|
public boolean getGreaterImpactEffectEnabled() { return config.getBoolean("Particles.Greater_Impact", true); }
|
||||||
|
|
||||||
/* PARTY SETTINGS */
|
/* PARTY SETTINGS */
|
||||||
public int getAutoPartyKickInterval() { return config.getInt("Party.AutoKick_Interval", 12); }
|
public int getAutoPartyKickInterval() { return config.getInt("Party.AutoKick_Interval", 12); }
|
||||||
public int getAutoPartyKickTime() { return config.getInt("Party.Old_Party_Member_Cutoff", 7); }
|
public int getAutoPartyKickTime() { return config.getInt("Party.Old_Party_Member_Cutoff", 7); }
|
||||||
|
@ -1,16 +1,9 @@
|
|||||||
package com.gmail.nossr50.config;
|
package com.gmail.nossr50.config;
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
|
||||||
import java.io.BufferedWriter;
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
import java.io.FileWriter;
|
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.InputStreamReader;
|
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import org.bukkit.configuration.file.FileConfiguration;
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
@ -45,90 +38,6 @@ public abstract class ConfigLoader {
|
|||||||
}
|
}
|
||||||
|
|
||||||
config = YamlConfiguration.loadConfiguration(configFile);
|
config = YamlConfiguration.loadConfiguration(configFile);
|
||||||
FileConfiguration internalConfig = YamlConfiguration.loadConfiguration(plugin.getResource(fileName));
|
|
||||||
|
|
||||||
Set<String> configKeys = config.getKeys(true);
|
|
||||||
Set<String> internalConfigKeys = internalConfig.getKeys(true);
|
|
||||||
|
|
||||||
boolean needSave = false;
|
|
||||||
|
|
||||||
Set<String> oldKeys = new HashSet<String>(configKeys);
|
|
||||||
oldKeys.removeAll(internalConfigKeys);
|
|
||||||
|
|
||||||
Set<String> newKeys = new HashSet<String>(internalConfigKeys);
|
|
||||||
newKeys.removeAll(configKeys);
|
|
||||||
|
|
||||||
// Don't need a re-save if we have old keys sticking around?
|
|
||||||
// Would be less saving, but less... correct?
|
|
||||||
if (!newKeys.isEmpty() || !oldKeys.isEmpty()) {
|
|
||||||
needSave = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (String key : oldKeys) {
|
|
||||||
plugin.debug("Removing unused key: " + key);
|
|
||||||
config.set(key, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (String key : newKeys) {
|
|
||||||
plugin.debug("Adding new key: " + key + " = " + internalConfig.get(key));
|
|
||||||
config.set(key, internalConfig.get(key));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (needSave) {
|
|
||||||
// Get Bukkit's version of an acceptable config with new keys, and no old keys
|
|
||||||
String output = config.saveToString();
|
|
||||||
|
|
||||||
// Convert to the superior 4 space indentation
|
|
||||||
output = output.replace(" ", " ");
|
|
||||||
|
|
||||||
// Rip out Bukkit's attempt to save comments at the top of the file
|
|
||||||
while (output.indexOf('#') != -1) {
|
|
||||||
output = output.substring(output.indexOf('\n', output.indexOf('#'))+1);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Read the internal config to get comments, then put them in the new one
|
|
||||||
try {
|
|
||||||
// Read internal
|
|
||||||
BufferedReader reader = new BufferedReader(new InputStreamReader(plugin.getResource(fileName)));
|
|
||||||
HashMap<String, String> comments = new HashMap<String, String>();
|
|
||||||
String temp = "";
|
|
||||||
|
|
||||||
String line;
|
|
||||||
while ((line = reader.readLine()) != null) {
|
|
||||||
if (line.contains("#")) {
|
|
||||||
temp += line + "\n";
|
|
||||||
}
|
|
||||||
else if (line.contains(":")) {
|
|
||||||
line = line.substring(0, line.indexOf(":") + 1);
|
|
||||||
if(!temp.isEmpty()) {
|
|
||||||
comments.put(line, temp);
|
|
||||||
temp = "";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Dump to the new one
|
|
||||||
for (String key : comments.keySet()) {
|
|
||||||
if (output.indexOf(key) != -1) {
|
|
||||||
output = output.substring(0, output.indexOf(key)) + comments.get(key) + output.substring(output.indexOf(key));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Save it
|
|
||||||
try {
|
|
||||||
BufferedWriter writer = new BufferedWriter(new FileWriter(new File(plugin.getDataFolder(), fileName)));
|
|
||||||
writer.write(output);
|
|
||||||
writer.flush();
|
|
||||||
writer.close();
|
|
||||||
}
|
|
||||||
catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract void loadKeys();
|
protected abstract void loadKeys();
|
||||||
@ -145,7 +54,8 @@ public abstract class ConfigLoader {
|
|||||||
if (inputStream != null) {
|
if (inputStream != null) {
|
||||||
try {
|
try {
|
||||||
copyStreamToFile(inputStream, configFile);
|
copyStreamToFile(inputStream, configFile);
|
||||||
} catch (Exception e) {
|
}
|
||||||
|
catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package com.gmail.nossr50.mods.config;
|
package com.gmail.nossr50.config.mods;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@ -8,18 +8,21 @@ import java.util.Set;
|
|||||||
import org.bukkit.configuration.ConfigurationSection;
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
|
|
||||||
import com.gmail.nossr50.config.ConfigLoader;
|
import com.gmail.nossr50.config.ConfigLoader;
|
||||||
import com.gmail.nossr50.mods.datatypes.CustomItem;
|
import com.gmail.nossr50.datatypes.mods.CustomItem;
|
||||||
import com.gmail.nossr50.skills.repair.Repairable;
|
import com.gmail.nossr50.skills.repair.Repairable;
|
||||||
import com.gmail.nossr50.skills.repair.RepairableFactory;
|
import com.gmail.nossr50.skills.repair.RepairableFactory;
|
||||||
|
|
||||||
public class CustomArmorConfig extends ConfigLoader {
|
public class CustomArmorConfig extends ConfigLoader {
|
||||||
private static CustomArmorConfig instance;
|
private static CustomArmorConfig instance;
|
||||||
|
|
||||||
private List<Repairable> repairables;
|
private List<Repairable> repairables;
|
||||||
|
|
||||||
public List<Integer> customBootIDs = new ArrayList<Integer>();
|
public List<Integer> customBootIDs = new ArrayList<Integer>();
|
||||||
public List<Integer> customChestplateIDs = new ArrayList<Integer>();
|
public List<Integer> customChestplateIDs = new ArrayList<Integer>();
|
||||||
public List<Integer> customHelmetIDs = new ArrayList<Integer>();
|
public List<Integer> customHelmetIDs = new ArrayList<Integer>();
|
||||||
public List<Integer> customLeggingIDs = new ArrayList<Integer>();
|
public List<Integer> customLeggingIDs = new ArrayList<Integer>();
|
||||||
public List<Integer> customIDs = new ArrayList<Integer>();
|
public List<Integer> customIDs = new ArrayList<Integer>();
|
||||||
|
|
||||||
public List<CustomItem> customArmorList = new ArrayList<CustomItem>();
|
public List<CustomItem> customArmorList = new ArrayList<CustomItem>();
|
||||||
public HashMap<Integer, CustomItem> customArmor = new HashMap<Integer, CustomItem>();
|
public HashMap<Integer, CustomItem> customArmor = new HashMap<Integer, CustomItem>();
|
||||||
|
|
||||||
@ -36,6 +39,14 @@ public class CustomArmorConfig extends ConfigLoader{
|
|||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<Repairable> getLoadedRepairables() {
|
||||||
|
if (repairables == null) {
|
||||||
|
return new ArrayList<Repairable>();
|
||||||
|
}
|
||||||
|
|
||||||
|
return repairables;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void loadKeys() {
|
protected void loadKeys() {
|
||||||
repairables = new ArrayList<Repairable>();
|
repairables = new ArrayList<Repairable>();
|
||||||
@ -49,8 +60,9 @@ public class CustomArmorConfig extends ConfigLoader{
|
|||||||
private void loadArmor(String armorType, List<Integer> idList) {
|
private void loadArmor(String armorType, List<Integer> idList) {
|
||||||
ConfigurationSection armorSection = config.getConfigurationSection(armorType);
|
ConfigurationSection armorSection = config.getConfigurationSection(armorType);
|
||||||
|
|
||||||
if (armorSection == null)
|
if (armorSection == null) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
Set<String> armorConfigSet = armorSection.getKeys(false);
|
Set<String> armorConfigSet = armorSection.getKeys(false);
|
||||||
|
|
||||||
@ -86,9 +98,4 @@ public class CustomArmorConfig extends ConfigLoader{
|
|||||||
customArmor.put(id, armor);
|
customArmor.put(id, armor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Repairable> getLoadedRepairables() {
|
|
||||||
if (repairables == null) return new ArrayList<Repairable>();
|
|
||||||
return repairables;
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -1,4 +1,4 @@
|
|||||||
package com.gmail.nossr50.mods.config;
|
package com.gmail.nossr50.config.mods;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -9,10 +9,11 @@ import org.bukkit.inventory.ItemStack;
|
|||||||
import org.bukkit.material.MaterialData;
|
import org.bukkit.material.MaterialData;
|
||||||
|
|
||||||
import com.gmail.nossr50.config.ConfigLoader;
|
import com.gmail.nossr50.config.ConfigLoader;
|
||||||
import com.gmail.nossr50.mods.datatypes.CustomBlock;
|
import com.gmail.nossr50.datatypes.mods.CustomBlock;
|
||||||
|
|
||||||
|
public class CustomBlockConfig extends ConfigLoader {
|
||||||
|
private static CustomBlockConfig instance;
|
||||||
|
|
||||||
public class CustomBlocksConfig extends ConfigLoader {
|
|
||||||
private static CustomBlocksConfig instance;
|
|
||||||
public List<ItemStack> customExcavationBlocks = new ArrayList<ItemStack>();
|
public List<ItemStack> customExcavationBlocks = new ArrayList<ItemStack>();
|
||||||
public List<ItemStack> customHerbalismBlocks = new ArrayList<ItemStack>();
|
public List<ItemStack> customHerbalismBlocks = new ArrayList<ItemStack>();
|
||||||
public List<ItemStack> customMiningBlocks = new ArrayList<ItemStack>();
|
public List<ItemStack> customMiningBlocks = new ArrayList<ItemStack>();
|
||||||
@ -22,16 +23,17 @@ public class CustomBlocksConfig extends ConfigLoader {
|
|||||||
public List<ItemStack> customLeaves = new ArrayList<ItemStack>();
|
public List<ItemStack> customLeaves = new ArrayList<ItemStack>();
|
||||||
public List<ItemStack> customAbilityBlocks = new ArrayList<ItemStack>();
|
public List<ItemStack> customAbilityBlocks = new ArrayList<ItemStack>();
|
||||||
public List<ItemStack> customItems = new ArrayList<ItemStack>();
|
public List<ItemStack> customItems = new ArrayList<ItemStack>();
|
||||||
|
|
||||||
public List<CustomBlock> customBlocks = new ArrayList<CustomBlock>();
|
public List<CustomBlock> customBlocks = new ArrayList<CustomBlock>();
|
||||||
|
|
||||||
public CustomBlocksConfig() {
|
public CustomBlockConfig() {
|
||||||
super("ModConfigs", "blocks.yml");
|
super("ModConfigs", "blocks.yml");
|
||||||
loadKeys();
|
loadKeys();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static CustomBlocksConfig getInstance() {
|
public static CustomBlockConfig getInstance() {
|
||||||
if (instance == null) {
|
if (instance == null) {
|
||||||
instance = new CustomBlocksConfig();
|
instance = new CustomBlockConfig();
|
||||||
}
|
}
|
||||||
|
|
||||||
return instance;
|
return instance;
|
||||||
@ -49,8 +51,9 @@ public class CustomBlocksConfig extends ConfigLoader {
|
|||||||
private void loadBlocks(String skillType, List<ItemStack> blockList) {
|
private void loadBlocks(String skillType, List<ItemStack> blockList) {
|
||||||
ConfigurationSection skillSection = config.getConfigurationSection(skillType);
|
ConfigurationSection skillSection = config.getConfigurationSection(skillType);
|
||||||
|
|
||||||
if (skillSection == null)
|
if (skillSection == null) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
Set<String> skillConfigSet = skillSection.getKeys(false);
|
Set<String> skillConfigSet = skillSection.getKeys(false);
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
package com.gmail.nossr50.mods.config;
|
package com.gmail.nossr50.config.mods;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -9,14 +9,16 @@ import org.bukkit.entity.EntityType;
|
|||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
import com.gmail.nossr50.config.ConfigLoader;
|
import com.gmail.nossr50.config.ConfigLoader;
|
||||||
import com.gmail.nossr50.mods.datatypes.CustomEntity;
|
import com.gmail.nossr50.datatypes.mods.CustomEntity;
|
||||||
|
|
||||||
public class CustomEntityConfig extends ConfigLoader {
|
public class CustomEntityConfig extends ConfigLoader {
|
||||||
private static CustomEntityConfig instance;
|
private static CustomEntityConfig instance;
|
||||||
|
|
||||||
public List<Integer> customEntityIds = new ArrayList<Integer>();
|
public List<Integer> customEntityIds = new ArrayList<Integer>();
|
||||||
public List<Integer> customHostileEntityIds = new ArrayList<Integer>();
|
public List<Integer> customHostileEntityIds = new ArrayList<Integer>();
|
||||||
public List<Integer> customNeutralEntityIds = new ArrayList<Integer>();
|
public List<Integer> customNeutralEntityIds = new ArrayList<Integer>();
|
||||||
public List<Integer> customPassiveEntityIds = new ArrayList<Integer>();
|
public List<Integer> customPassiveEntityIds = new ArrayList<Integer>();
|
||||||
|
|
||||||
public List<EntityType> customEntityTypes = new ArrayList<EntityType>();
|
public List<EntityType> customEntityTypes = new ArrayList<EntityType>();
|
||||||
public List<CustomEntity> customEntities = new ArrayList<CustomEntity>();
|
public List<CustomEntity> customEntities = new ArrayList<CustomEntity>();
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
package com.gmail.nossr50.mods.config;
|
package com.gmail.nossr50.config.mods;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@ -8,12 +8,12 @@ import java.util.Set;
|
|||||||
import org.bukkit.configuration.ConfigurationSection;
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
|
|
||||||
import com.gmail.nossr50.config.ConfigLoader;
|
import com.gmail.nossr50.config.ConfigLoader;
|
||||||
import com.gmail.nossr50.mods.datatypes.CustomTool;
|
import com.gmail.nossr50.datatypes.mods.CustomTool;
|
||||||
import com.gmail.nossr50.skills.repair.Repairable;
|
import com.gmail.nossr50.skills.repair.Repairable;
|
||||||
import com.gmail.nossr50.skills.repair.RepairableFactory;
|
import com.gmail.nossr50.skills.repair.RepairableFactory;
|
||||||
|
|
||||||
public class CustomToolsConfig extends ConfigLoader {
|
public class CustomToolConfig extends ConfigLoader {
|
||||||
private static CustomToolsConfig instance;
|
private static CustomToolConfig instance;
|
||||||
private List<Repairable> repairables;
|
private List<Repairable> repairables;
|
||||||
public List<Integer> customAxeIDs = new ArrayList<Integer>();
|
public List<Integer> customAxeIDs = new ArrayList<Integer>();
|
||||||
public List<Integer> customBowIDs = new ArrayList<Integer>();
|
public List<Integer> customBowIDs = new ArrayList<Integer>();
|
||||||
@ -25,19 +25,27 @@ public class CustomToolsConfig extends ConfigLoader {
|
|||||||
public List<CustomTool> customToolList = new ArrayList<CustomTool>();
|
public List<CustomTool> customToolList = new ArrayList<CustomTool>();
|
||||||
public HashMap<Integer, CustomTool> customTools = new HashMap<Integer, CustomTool>();
|
public HashMap<Integer, CustomTool> customTools = new HashMap<Integer, CustomTool>();
|
||||||
|
|
||||||
private CustomToolsConfig() {
|
private CustomToolConfig() {
|
||||||
super("ModConfigs", "tools.yml");
|
super("ModConfigs", "tools.yml");
|
||||||
loadKeys();
|
loadKeys();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static CustomToolsConfig getInstance() {
|
public static CustomToolConfig getInstance() {
|
||||||
if (instance == null) {
|
if (instance == null) {
|
||||||
instance = new CustomToolsConfig();
|
instance = new CustomToolConfig();
|
||||||
}
|
}
|
||||||
|
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<Repairable> getLoadedRepairables() {
|
||||||
|
if (repairables == null) {
|
||||||
|
return new ArrayList<Repairable>();
|
||||||
|
}
|
||||||
|
|
||||||
|
return repairables;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void loadKeys() {
|
protected void loadKeys() {
|
||||||
repairables = new ArrayList<Repairable>();
|
repairables = new ArrayList<Repairable>();
|
||||||
@ -53,8 +61,9 @@ public class CustomToolsConfig extends ConfigLoader {
|
|||||||
private void loadTool(String toolType, List<Integer> idList) {
|
private void loadTool(String toolType, List<Integer> idList) {
|
||||||
ConfigurationSection toolSection = config.getConfigurationSection(toolType);
|
ConfigurationSection toolSection = config.getConfigurationSection(toolType);
|
||||||
|
|
||||||
if (toolSection == null)
|
if (toolSection == null) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
Set<String> toolConfigSet = toolSection.getKeys(false);
|
Set<String> toolConfigSet = toolSection.getKeys(false);
|
||||||
|
|
||||||
@ -93,9 +102,4 @@ public class CustomToolsConfig extends ConfigLoader {
|
|||||||
customTools.put(id, tool);
|
customTools.put(id, tool);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Repairable> getLoadedRepairables() {
|
|
||||||
if (repairables == null) return new ArrayList<Repairable>();
|
|
||||||
return repairables;
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -0,0 +1,35 @@
|
|||||||
|
package com.gmail.nossr50.config.party;
|
||||||
|
|
||||||
|
import org.bukkit.Material;
|
||||||
|
|
||||||
|
import com.gmail.nossr50.config.ConfigLoader;
|
||||||
|
import com.gmail.nossr50.util.StringUtils;
|
||||||
|
|
||||||
|
public class ItemWeightConfig extends ConfigLoader {
|
||||||
|
private static ItemWeightConfig instance;
|
||||||
|
|
||||||
|
private ItemWeightConfig() {
|
||||||
|
super("itemweights.yml");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ItemWeightConfig getInstance() {
|
||||||
|
if (instance == null) {
|
||||||
|
instance = new ItemWeightConfig();
|
||||||
|
}
|
||||||
|
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getItemWeight(Material material) {
|
||||||
|
String materialName = StringUtils.getPrettyItemString(material).replace(" ", "_");
|
||||||
|
int itemWeight = config.getInt("Item_Weights.Default");
|
||||||
|
|
||||||
|
if (config.getInt("Item_Weights." + materialName) > 0) {
|
||||||
|
itemWeight = config.getInt("Item_Weights." + materialName);
|
||||||
|
}
|
||||||
|
return itemWeight;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void loadKeys() {}
|
||||||
|
}
|
@ -0,0 +1,65 @@
|
|||||||
|
package com.gmail.nossr50.config.spout;
|
||||||
|
|
||||||
|
import com.gmail.nossr50.config.ConfigLoader;
|
||||||
|
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||||
|
import com.gmail.nossr50.datatypes.spout.huds.HudType;
|
||||||
|
|
||||||
|
public class SpoutConfig extends ConfigLoader {
|
||||||
|
private static SpoutConfig instance;
|
||||||
|
public HudType defaultHudType;
|
||||||
|
|
||||||
|
private SpoutConfig() {
|
||||||
|
super("spout.yml");
|
||||||
|
loadKeys();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static SpoutConfig getInstance() {
|
||||||
|
if (instance == null) {
|
||||||
|
instance = new SpoutConfig();
|
||||||
|
}
|
||||||
|
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void loadKeys() {
|
||||||
|
// Setup default HUD
|
||||||
|
String temp = config.getString("Spout.HUD.Default", "STANDARD");
|
||||||
|
|
||||||
|
for (HudType hudType : HudType.values()) {
|
||||||
|
if (hudType.toString().equalsIgnoreCase(temp)) {
|
||||||
|
defaultHudType = hudType;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (defaultHudType == null) {
|
||||||
|
defaultHudType = HudType.STANDARD;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean getShowPowerLevel() { return config.getBoolean("HUD.Show_Power_Level", true); }
|
||||||
|
public String getMenuKey() { return config.getString("Menu.Key", "KEY_M"); }
|
||||||
|
|
||||||
|
/* XP Bar */
|
||||||
|
public boolean getXPBarEnabled() { return config.getBoolean("XP.Bar.Enabled", true); }
|
||||||
|
public void setXPBarEnabled(boolean enabled) { config.set("XP.Bar.Enabled", enabled); }
|
||||||
|
|
||||||
|
public boolean getXPBarIconEnabled() { return config.getBoolean("XP.Icon.Enabled", true); }
|
||||||
|
public int getXPBarXPosition() { return config.getInt("XP.Bar.X_POS", 95); }
|
||||||
|
public int getXPBarYPosition() { return config.getInt("XP.Bar.Y_POS", 6); }
|
||||||
|
public int getXPIconXPosition() { return config.getInt("XP.Icon.X_POS", 78); }
|
||||||
|
public int getXPIconYPosition() { return config.getInt("XP.Icon.Y_POS", 2); }
|
||||||
|
|
||||||
|
/* HUD Colors */
|
||||||
|
public double getRetroHUDXPBorderRed() { return config.getDouble("HUD.Retro.Colors.Border.RED", 0.0); }
|
||||||
|
public double getRetroHUDXPBorderGreen() { return config.getDouble("HUD.Retro.Colors.Border.GREEN", 0.0); }
|
||||||
|
public double getRetroHUDXPBorderBlue() { return config.getDouble("HUD.Retro.Colors.Border.BLUE", 0.0); }
|
||||||
|
public double getRetroHUDXPBackgroundRed() { return config.getDouble("HUD.Retro.Colors.Background.RED", 0.75); }
|
||||||
|
public double getRetroHUDXPBackgroundGreen() { return config.getDouble("HUD.Retro.Colors.Background.GREEN", 0.75); }
|
||||||
|
public double getRetroHUDXPBackgroundBlue() { return config.getDouble("HUD.Retro.Colors.Background.BLUE", 0.75); }
|
||||||
|
|
||||||
|
public double getRetroHUDRed(SkillType skill) { return config.getDouble("HUD.Retro.Colors." + skill.toString().toLowerCase() +".RED", 0.3); }
|
||||||
|
public double getRetroHUDGreen(SkillType skill) { return config.getDouble("HUD.Retro.Colors." + skill.toString().toLowerCase() +".RED", 0.3); }
|
||||||
|
public double getRetroHUDBlue(SkillType skill) { return config.getDouble("HUD.Retro.Colors." + skill.toString().toLowerCase() +".RED", 0.3); }
|
||||||
|
}
|
@ -1,4 +1,4 @@
|
|||||||
package com.gmail.nossr50.config;
|
package com.gmail.nossr50.config.treasure;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@ -12,13 +12,15 @@ import org.bukkit.configuration.ConfigurationSection;
|
|||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.material.MaterialData;
|
import org.bukkit.material.MaterialData;
|
||||||
|
|
||||||
|
import com.gmail.nossr50.config.ConfigLoader;
|
||||||
import com.gmail.nossr50.datatypes.treasure.ExcavationTreasure;
|
import com.gmail.nossr50.datatypes.treasure.ExcavationTreasure;
|
||||||
import com.gmail.nossr50.datatypes.treasure.FishingTreasure;
|
import com.gmail.nossr50.datatypes.treasure.FishingTreasure;
|
||||||
import com.gmail.nossr50.datatypes.treasure.HylianTreasure;
|
import com.gmail.nossr50.datatypes.treasure.HylianTreasure;
|
||||||
import com.gmail.nossr50.datatypes.treasure.Treasure;
|
import com.gmail.nossr50.datatypes.treasure.Treasure;
|
||||||
|
|
||||||
public class TreasuresConfig extends ConfigLoader {
|
public class TreasureConfig extends ConfigLoader {
|
||||||
private static TreasuresConfig instance;
|
private static TreasureConfig instance;
|
||||||
|
|
||||||
public List<ExcavationTreasure> excavationFromDirt = new ArrayList<ExcavationTreasure>();
|
public List<ExcavationTreasure> excavationFromDirt = new ArrayList<ExcavationTreasure>();
|
||||||
public List<ExcavationTreasure> excavationFromGrass = new ArrayList<ExcavationTreasure>();
|
public List<ExcavationTreasure> excavationFromGrass = new ArrayList<ExcavationTreasure>();
|
||||||
public List<ExcavationTreasure> excavationFromSand = new ArrayList<ExcavationTreasure>();
|
public List<ExcavationTreasure> excavationFromSand = new ArrayList<ExcavationTreasure>();
|
||||||
@ -33,14 +35,14 @@ public class TreasuresConfig extends ConfigLoader {
|
|||||||
|
|
||||||
public List<FishingTreasure> fishingRewards = new ArrayList<FishingTreasure>();
|
public List<FishingTreasure> fishingRewards = new ArrayList<FishingTreasure>();
|
||||||
|
|
||||||
private TreasuresConfig() {
|
private TreasureConfig() {
|
||||||
super("treasures.yml");
|
super("treasures.yml");
|
||||||
loadKeys();
|
loadKeys();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static TreasuresConfig getInstance() {
|
public static TreasureConfig getInstance() {
|
||||||
if (instance == null) {
|
if (instance == null) {
|
||||||
instance = new TreasuresConfig();
|
instance = new TreasureConfig();
|
||||||
}
|
}
|
||||||
|
|
||||||
return instance;
|
return instance;
|
||||||
@ -50,6 +52,11 @@ public class TreasuresConfig extends ConfigLoader {
|
|||||||
protected void loadKeys() {
|
protected void loadKeys() {
|
||||||
Map<String, Treasure> treasures = new HashMap<String, Treasure>();
|
Map<String, Treasure> treasures = new HashMap<String, Treasure>();
|
||||||
ConfigurationSection treasureSection = config.getConfigurationSection("Treasures");
|
ConfigurationSection treasureSection = config.getConfigurationSection("Treasures");
|
||||||
|
|
||||||
|
if (treasureSection == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
Set<String> treasureConfigSet = treasureSection.getKeys(false);
|
Set<String> treasureConfigSet = treasureSection.getKeys(false);
|
||||||
|
|
||||||
for (String treasureName : treasureConfigSet) {
|
for (String treasureName : treasureConfigSet) {
|
||||||
@ -209,14 +216,14 @@ public class TreasuresConfig extends ConfigLoader {
|
|||||||
Treasure treasure = nextEntry.getValue();
|
Treasure treasure = nextEntry.getValue();
|
||||||
|
|
||||||
if (treasure instanceof FishingTreasure) {
|
if (treasure instanceof FishingTreasure) {
|
||||||
if (!fishingTreasures.contains(treasureKey)) {
|
if (fishingTreasures == null || !fishingTreasures.contains(treasureKey)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
fishingRewards.add((FishingTreasure) treasure);
|
fishingRewards.add((FishingTreasure) treasure);
|
||||||
}
|
}
|
||||||
else if (treasure instanceof HylianTreasure) {
|
else if (treasure instanceof HylianTreasure) {
|
||||||
if (!hylianTreasures.contains(treasureKey)) {
|
if (hylianTreasures == null || !hylianTreasures.contains(treasureKey)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -235,7 +242,7 @@ public class TreasuresConfig extends ConfigLoader {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (treasure instanceof ExcavationTreasure) {
|
else if (treasure instanceof ExcavationTreasure) {
|
||||||
if (!excavationTreasures.contains(treasureKey)) {
|
if (excavationTreasures == null || !excavationTreasures.contains(treasureKey)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
@ -10,19 +10,19 @@ import java.util.HashMap;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.gmail.nossr50.config.Config;
|
import com.gmail.nossr50.config.Config;
|
||||||
import com.gmail.nossr50.database.runnables.SQLReconnect;
|
import com.gmail.nossr50.datatypes.database.DatabaseUpdateType;
|
||||||
import com.gmail.nossr50.datatypes.McMMOPlayer;
|
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||||
import com.gmail.nossr50.skills.utilities.SkillType;
|
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||||
import com.gmail.nossr50.spout.SpoutTools;
|
import com.gmail.nossr50.datatypes.spout.huds.McMMOHud;
|
||||||
import com.gmail.nossr50.spout.huds.SpoutHud;
|
import com.gmail.nossr50.runnables.database.SQLReconnectTask;
|
||||||
import com.gmail.nossr50.util.Users;
|
import com.gmail.nossr50.util.player.UserManager;
|
||||||
|
import com.gmail.nossr50.util.spout.SpoutUtils;
|
||||||
|
|
||||||
public final class Database {
|
public final class DatabaseManager {
|
||||||
private static String connectionString;
|
private static String connectionString;
|
||||||
|
|
||||||
private static String tablePrefix = Config.getInstance().getMySQLTablePrefix();
|
private static String tablePrefix = Config.getInstance().getMySQLTablePrefix();
|
||||||
@ -43,10 +43,12 @@ public final class Database {
|
|||||||
// When next to try connecting to Database in nanoseconds
|
// When next to try connecting to Database in nanoseconds
|
||||||
private static long nextReconnectTimestamp = 0L;
|
private static long nextReconnectTimestamp = 0L;
|
||||||
|
|
||||||
// How many connection attemtps have failed
|
// How many connection attempts have failed
|
||||||
private static int reconnectAttempt = 0;
|
private static int reconnectAttempt = 0;
|
||||||
|
|
||||||
private Database() {}
|
private static final long ONE_MONTH = 2630000000L;
|
||||||
|
|
||||||
|
private DatabaseManager() {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Attempt to connect to the mySQL database.
|
* Attempt to connect to the mySQL database.
|
||||||
@ -68,13 +70,17 @@ public final class Database {
|
|||||||
connection = DriverManager.getConnection(connectionString, connectionProperties);
|
connection = DriverManager.getConnection(connectionString, connectionProperties);
|
||||||
|
|
||||||
mcMMO.p.getLogger().info("Connection to MySQL was a success!");
|
mcMMO.p.getLogger().info("Connection to MySQL was a success!");
|
||||||
} catch (SQLException ex) {
|
}
|
||||||
|
catch (SQLException ex) {
|
||||||
connection = null;
|
connection = null;
|
||||||
|
|
||||||
if (reconnectAttempt == 0 || reconnectAttempt >= 11) {
|
if (reconnectAttempt == 0 || reconnectAttempt >= 11) {
|
||||||
mcMMO.p.getLogger().info("Connection to MySQL failed!");
|
mcMMO.p.getLogger().info("Connection to MySQL failed!");
|
||||||
}
|
}
|
||||||
} catch (ClassNotFoundException ex) {
|
}
|
||||||
|
catch (ClassNotFoundException ex) {
|
||||||
connection = null;
|
connection = null;
|
||||||
|
|
||||||
if (reconnectAttempt == 0 || reconnectAttempt >= 11) {
|
if (reconnectAttempt == 0 || reconnectAttempt >= 11) {
|
||||||
mcMMO.p.getLogger().info("MySQL database driver not found!");
|
mcMMO.p.getLogger().info("MySQL database driver not found!");
|
||||||
}
|
}
|
||||||
@ -147,10 +153,405 @@ public final class Database {
|
|||||||
+ "FOREIGN KEY (`user_id`) REFERENCES `" + tablePrefix + "users` (`id`) "
|
+ "FOREIGN KEY (`user_id`) REFERENCES `" + tablePrefix + "users` (`id`) "
|
||||||
+ "ON DELETE CASCADE) ENGINE=MyISAM DEFAULT CHARSET=latin1;");
|
+ "ON DELETE CASCADE) ENGINE=MyISAM DEFAULT CHARSET=latin1;");
|
||||||
|
|
||||||
checkDatabaseStructure(DatabaseUpdate.FISHING);
|
checkDatabaseStructure(DatabaseUpdateType.FISHING);
|
||||||
checkDatabaseStructure(DatabaseUpdate.BLAST_MINING);
|
checkDatabaseStructure(DatabaseUpdateType.BLAST_MINING);
|
||||||
checkDatabaseStructure(DatabaseUpdate.CASCADE_DELETE);
|
checkDatabaseStructure(DatabaseUpdateType.CASCADE_DELETE);
|
||||||
checkDatabaseStructure(DatabaseUpdate.INDEX);
|
checkDatabaseStructure(DatabaseUpdateType.INDEX);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Attempt to write the SQL query.
|
||||||
|
*
|
||||||
|
* @param sql Query to write.
|
||||||
|
* @return true if the query was successfully written, false otherwise.
|
||||||
|
*/
|
||||||
|
public static boolean write(String sql) {
|
||||||
|
if (!checkConnected()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
PreparedStatement statement = null;
|
||||||
|
try {
|
||||||
|
statement = connection.prepareStatement(sql);
|
||||||
|
statement.executeUpdate();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
catch (SQLException ex) {
|
||||||
|
printErrors(ex);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
if (statement != null) {
|
||||||
|
try {
|
||||||
|
statement.close();
|
||||||
|
}
|
||||||
|
catch (SQLException e) {
|
||||||
|
printErrors(e);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the number of rows affected by either a DELETE or UPDATE query
|
||||||
|
*
|
||||||
|
* @param sql SQL query to execute
|
||||||
|
* @return the number of rows affected
|
||||||
|
*/
|
||||||
|
public static int update(String sql) {
|
||||||
|
int ret = 0;
|
||||||
|
|
||||||
|
if (checkConnected()) {
|
||||||
|
PreparedStatement statement = null;
|
||||||
|
try {
|
||||||
|
statement = connection.prepareStatement(sql);
|
||||||
|
ret = statement.executeUpdate();
|
||||||
|
}
|
||||||
|
catch (SQLException ex) {
|
||||||
|
printErrors(ex);
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
if (statement != null) {
|
||||||
|
try {
|
||||||
|
statement.close();
|
||||||
|
}
|
||||||
|
catch (SQLException e) {
|
||||||
|
printErrors(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the Integer. Only return first row / first field.
|
||||||
|
*
|
||||||
|
* @param sql SQL query to execute
|
||||||
|
* @return the value in the first row / first field
|
||||||
|
*/
|
||||||
|
public static int getInt(String sql) {
|
||||||
|
ResultSet resultSet = null;
|
||||||
|
int result = 0;
|
||||||
|
|
||||||
|
if (checkConnected()) {
|
||||||
|
PreparedStatement statement = null;
|
||||||
|
|
||||||
|
try {
|
||||||
|
statement = connection.prepareStatement(sql);
|
||||||
|
resultSet = statement.executeQuery();
|
||||||
|
|
||||||
|
if (resultSet.next()) {
|
||||||
|
result = resultSet.getInt(1);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
result = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (SQLException ex) {
|
||||||
|
printErrors(ex);
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
if (statement != null) {
|
||||||
|
try {
|
||||||
|
statement.close();
|
||||||
|
}
|
||||||
|
catch (SQLException e) {
|
||||||
|
printErrors(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check connection status and re-establish if dead or stale.
|
||||||
|
*
|
||||||
|
* If the very first immediate attempt fails, further attempts
|
||||||
|
* will be made in progressively larger intervals up to MAX_WAIT
|
||||||
|
* intervals.
|
||||||
|
*
|
||||||
|
* This allows for MySQL to time out idle connections as needed by
|
||||||
|
* server operator, without affecting McMMO, while still providing
|
||||||
|
* protection against a database outage taking down Bukkit's tick
|
||||||
|
* processing loop due to attemping a database connection each
|
||||||
|
* time McMMO needs the database.
|
||||||
|
*
|
||||||
|
* @return the boolean value for whether or not we are connected
|
||||||
|
*/
|
||||||
|
public static boolean checkConnected() {
|
||||||
|
boolean isClosed = true;
|
||||||
|
boolean isValid = false;
|
||||||
|
boolean exists = (connection != null);
|
||||||
|
|
||||||
|
// If we're waiting for server to recover then leave early
|
||||||
|
if (nextReconnectTimestamp > 0 && nextReconnectTimestamp > System.nanoTime()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (exists) {
|
||||||
|
try {
|
||||||
|
isClosed = connection.isClosed();
|
||||||
|
}
|
||||||
|
catch (SQLException e) {
|
||||||
|
isClosed = true;
|
||||||
|
e.printStackTrace();
|
||||||
|
printErrors(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isClosed) {
|
||||||
|
try {
|
||||||
|
isValid = connection.isValid(VALID_TIMEOUT);
|
||||||
|
}
|
||||||
|
catch (SQLException e) {
|
||||||
|
// Don't print stack trace because it's valid to lose idle connections to the server and have to restart them.
|
||||||
|
isValid = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Leave if all ok
|
||||||
|
if (exists && !isClosed && isValid) {
|
||||||
|
// Housekeeping
|
||||||
|
nextReconnectTimestamp = 0;
|
||||||
|
reconnectAttempt = 0;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Cleanup after ourselves for GC and MySQL's sake
|
||||||
|
if (exists && !isClosed) {
|
||||||
|
try {
|
||||||
|
connection.close();
|
||||||
|
}
|
||||||
|
catch (SQLException ex) {
|
||||||
|
// This is a housekeeping exercise, ignore errors
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Try to connect again
|
||||||
|
connect();
|
||||||
|
|
||||||
|
// Leave if connection is good
|
||||||
|
try {
|
||||||
|
if (connection != null && !connection.isClosed()) {
|
||||||
|
// Schedule a database save if we really had an outage
|
||||||
|
if (reconnectAttempt > 1) {
|
||||||
|
mcMMO.p.getServer().getScheduler().scheduleSyncDelayedTask(mcMMO.p, new SQLReconnectTask(), 5);
|
||||||
|
}
|
||||||
|
nextReconnectTimestamp = 0;
|
||||||
|
reconnectAttempt = 0;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (SQLException e) {
|
||||||
|
// Failed to check isClosed, so presume connection is bad and attempt later
|
||||||
|
e.printStackTrace();
|
||||||
|
printErrors(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
reconnectAttempt++;
|
||||||
|
nextReconnectTimestamp = (long)(System.nanoTime() + Math.min(MAX_WAIT, (reconnectAttempt * SCALING_FACTOR * MIN_WAIT)));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Read SQL query.
|
||||||
|
*
|
||||||
|
* @param sql SQL query to read
|
||||||
|
* @return the rows in this SQL query
|
||||||
|
*/
|
||||||
|
public static HashMap<Integer, ArrayList<String>> read(String sql) {
|
||||||
|
ResultSet resultSet;
|
||||||
|
HashMap<Integer, ArrayList<String>> rows = new HashMap<Integer, ArrayList<String>>();
|
||||||
|
|
||||||
|
if (checkConnected()) {
|
||||||
|
PreparedStatement statement = null;
|
||||||
|
|
||||||
|
try {
|
||||||
|
statement = connection.prepareStatement(sql);
|
||||||
|
resultSet = statement.executeQuery();
|
||||||
|
|
||||||
|
while (resultSet.next()) {
|
||||||
|
ArrayList<String> column = new ArrayList<String>();
|
||||||
|
|
||||||
|
for (int i = 1; i <= resultSet.getMetaData().getColumnCount(); i++) {
|
||||||
|
column.add(resultSet.getString(i));
|
||||||
|
}
|
||||||
|
|
||||||
|
rows.put(resultSet.getRow(), column);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (SQLException ex) {
|
||||||
|
printErrors(ex);
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
if (statement != null) {
|
||||||
|
try {
|
||||||
|
statement.close();
|
||||||
|
}
|
||||||
|
catch (SQLException e) {
|
||||||
|
printErrors(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return rows;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Map<String, Integer> readSQLRank(String playerName) {
|
||||||
|
ResultSet resultSet;
|
||||||
|
Map<String, Integer> skills = new HashMap<String, Integer>();
|
||||||
|
|
||||||
|
if (checkConnected()) {
|
||||||
|
try {
|
||||||
|
for (SkillType skillType : SkillType.values()) {
|
||||||
|
if (skillType.isChildSkill()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
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 " +
|
||||||
|
"WHERE user = '" + playerName + "')";
|
||||||
|
|
||||||
|
PreparedStatement statement = connection.prepareStatement(sql);
|
||||||
|
resultSet = statement.executeQuery();
|
||||||
|
|
||||||
|
resultSet.next();
|
||||||
|
|
||||||
|
int rank = resultSet.getInt("rank");
|
||||||
|
|
||||||
|
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 " +
|
||||||
|
"WHERE user = '" + playerName + "') ORDER BY user";
|
||||||
|
|
||||||
|
statement = connection.prepareStatement(sql);
|
||||||
|
resultSet = statement.executeQuery();
|
||||||
|
|
||||||
|
while (resultSet.next()) {
|
||||||
|
if (resultSet.getString("user").equalsIgnoreCase(playerName)) {
|
||||||
|
skills.put(skillType.name(), rank + resultSet.getRow());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
statement.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
String sql = "SELECT COUNT(*) AS rank FROM " + tablePrefix + "users JOIN " + tablePrefix + "skills ON user_id = id " +
|
||||||
|
"WHERE taming+mining+woodcutting+repair+unarmed+herbalism+excavation+archery+swords+axes+acrobatics+fishing > 0 " +
|
||||||
|
"AND taming+mining+woodcutting+repair+unarmed+herbalism+excavation+archery+swords+axes+acrobatics+fishing > " +
|
||||||
|
"(SELECT taming+mining+woodcutting+repair+unarmed+herbalism+excavation+archery+swords+axes+acrobatics+fishing " +
|
||||||
|
"FROM " + tablePrefix + "users JOIN " + tablePrefix + "skills ON user_id = id WHERE user = '" + playerName + "')";
|
||||||
|
|
||||||
|
PreparedStatement statement = connection.prepareStatement(sql);
|
||||||
|
resultSet = statement.executeQuery();
|
||||||
|
|
||||||
|
resultSet.next();
|
||||||
|
|
||||||
|
int rank = resultSet.getInt("rank");
|
||||||
|
|
||||||
|
sql = "SELECT user, taming+mining+woodcutting+repair+unarmed+herbalism+excavation+archery+swords+axes+acrobatics+fishing " +
|
||||||
|
"FROM " + tablePrefix + "users JOIN " + tablePrefix + "skills ON user_id = id " +
|
||||||
|
"WHERE taming+mining+woodcutting+repair+unarmed+herbalism+excavation+archery+swords+axes+acrobatics+fishing > 0 " +
|
||||||
|
"AND taming+mining+woodcutting+repair+unarmed+herbalism+excavation+archery+swords+axes+acrobatics+fishing = " +
|
||||||
|
"(SELECT taming+mining+woodcutting+repair+unarmed+herbalism+excavation+archery+swords+axes+acrobatics+fishing " +
|
||||||
|
"FROM " + tablePrefix + "users JOIN " + tablePrefix + "skills ON user_id = id WHERE user = '" + playerName + "') ORDER BY user";
|
||||||
|
|
||||||
|
statement = connection.prepareStatement(sql);
|
||||||
|
resultSet = statement.executeQuery();
|
||||||
|
|
||||||
|
while (resultSet.next()) {
|
||||||
|
if (resultSet.getString("user").equalsIgnoreCase(playerName)) {
|
||||||
|
skills.put("ALL", rank + resultSet.getRow());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
statement.close();
|
||||||
|
}
|
||||||
|
catch (SQLException ex) {
|
||||||
|
printErrors(ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return skills;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void purgePowerlessSQL() {
|
||||||
|
mcMMO.p.getLogger().info("Purging powerless users...");
|
||||||
|
HashMap<Integer, ArrayList<String>> usernames;
|
||||||
|
|
||||||
|
usernames = read("SELECT u.user FROM " + tablePrefix + "skills AS s, " + tablePrefix + "users AS u " + "WHERE s.user_id = u.id AND " +
|
||||||
|
"(s.taming+s.mining+s.woodcutting+s.repair+s.unarmed+s.herbalism+s.excavation+s.archery+s.swords+s.axes+s.acrobatics+s.fishing) = 0");
|
||||||
|
|
||||||
|
write("DELETE FROM " + tablePrefix + "users WHERE " + tablePrefix + "users.id IN (SELECT * FROM " +
|
||||||
|
"(SELECT u.id FROM " + tablePrefix + "skills AS s, " + tablePrefix + "users AS u " + "WHERE s.user_id = u.id " +
|
||||||
|
"AND (s.taming+s.mining+s.woodcutting+s.repair+s.unarmed+s.herbalism+s.excavation+s.archery+s.swords+s.axes+s.acrobatics+s.fishing) = 0) AS p)");
|
||||||
|
|
||||||
|
int purgedUsers = 0;
|
||||||
|
for (int i = 1; i <= usernames.size(); i++) {
|
||||||
|
String playerName = usernames.get(i).get(0);
|
||||||
|
|
||||||
|
if (playerName == null || mcMMO.p.getServer().getOfflinePlayer(playerName).isOnline()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
profileCleanup(playerName);
|
||||||
|
purgedUsers++;
|
||||||
|
}
|
||||||
|
|
||||||
|
mcMMO.p.getLogger().info("Purged " + purgedUsers + " users from the database.");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void purgeOldSQL() {
|
||||||
|
mcMMO.p.getLogger().info("Purging old users...");
|
||||||
|
long currentTime = System.currentTimeMillis();
|
||||||
|
long purgeTime = ONE_MONTH * Config.getInstance().getOldUsersCutoff();
|
||||||
|
HashMap<Integer, ArrayList<String>> usernames = read("SELECT user FROM " + tablePrefix + "users WHERE ((" + currentTime + " - lastlogin*1000) > " + purgeTime + ")");
|
||||||
|
write("DELETE FROM " + tablePrefix + "users WHERE " + tablePrefix + "users.id IN (SELECT * FROM (SELECT id FROM " + tablePrefix + "users WHERE ((" + currentTime + " - lastlogin*1000) > " + purgeTime + ")) AS p)");
|
||||||
|
|
||||||
|
int purgedUsers = 0;
|
||||||
|
for (int i = 1; i <= usernames.size(); i++) {
|
||||||
|
String playerName = usernames.get(i).get(0);
|
||||||
|
|
||||||
|
if (playerName == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
profileCleanup(playerName);
|
||||||
|
purgedUsers++;
|
||||||
|
}
|
||||||
|
|
||||||
|
mcMMO.p.getLogger().info("Purged " + purgedUsers + " users from the database.");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void profileCleanup(String playerName) {
|
||||||
|
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(playerName);
|
||||||
|
|
||||||
|
if (mcMMOPlayer != null) {
|
||||||
|
Player player = mcMMOPlayer.getPlayer();
|
||||||
|
McMMOHud spoutHud = mcMMOPlayer.getProfile().getSpoutHud();
|
||||||
|
|
||||||
|
if (spoutHud != null) {
|
||||||
|
spoutHud.removeWidgets();
|
||||||
|
}
|
||||||
|
|
||||||
|
UserManager.remove(playerName);
|
||||||
|
|
||||||
|
if (player.isOnline()) {
|
||||||
|
UserManager.addUser(player);
|
||||||
|
|
||||||
|
if (mcMMO.spoutEnabled) {
|
||||||
|
SpoutUtils.reloadSpoutPlayer(player);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -158,7 +559,7 @@ public final class Database {
|
|||||||
*
|
*
|
||||||
* @param update Type of data to check updates for
|
* @param update Type of data to check updates for
|
||||||
*/
|
*/
|
||||||
private static void checkDatabaseStructure(DatabaseUpdate update) {
|
private static void checkDatabaseStructure(DatabaseUpdateType update) {
|
||||||
String sql = null;
|
String sql = null;
|
||||||
ResultSet resultSet = null;
|
ResultSet resultSet = null;
|
||||||
HashMap<Integer, ArrayList<String>> rows = new HashMap<Integer, ArrayList<String>>();
|
HashMap<Integer, ArrayList<String>> rows = new HashMap<Integer, ArrayList<String>>();
|
||||||
@ -203,7 +604,10 @@ public final class Database {
|
|||||||
|
|
||||||
PreparedStatement statement = null;
|
PreparedStatement statement = null;
|
||||||
try {
|
try {
|
||||||
if (!checkConnected()) return;
|
if (!checkConnected()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
statement = connection.prepareStatement(sql);
|
statement = connection.prepareStatement(sql);
|
||||||
resultSet = statement.executeQuery();
|
resultSet = statement.executeQuery();
|
||||||
|
|
||||||
@ -233,378 +637,31 @@ public final class Database {
|
|||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} finally {
|
}
|
||||||
|
finally {
|
||||||
if (resultSet != null) {
|
if (resultSet != null) {
|
||||||
try {
|
try {
|
||||||
resultSet.close();
|
resultSet.close();
|
||||||
} catch (SQLException e) {
|
}
|
||||||
|
catch (SQLException e) {
|
||||||
// Ignore the error, we're leaving
|
// Ignore the error, we're leaving
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (statement != null) {
|
if (statement != null) {
|
||||||
try {
|
try {
|
||||||
statement.close();
|
statement.close();
|
||||||
} catch (SQLException e) {
|
}
|
||||||
|
catch (SQLException e) {
|
||||||
// Ignore the error, we're leaving
|
// Ignore the error, we're leaving
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Attempt to write the SQL query.
|
|
||||||
*
|
|
||||||
* @param sql Query to write.
|
|
||||||
* @return true if the query was successfully written, false otherwise.
|
|
||||||
*/
|
|
||||||
public static boolean write(String sql) {
|
|
||||||
if (checkConnected()) {
|
|
||||||
PreparedStatement statement = null;
|
|
||||||
try {
|
|
||||||
statement = connection.prepareStatement(sql);
|
|
||||||
statement.executeUpdate();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
catch (SQLException ex) {
|
|
||||||
printErrors(ex);
|
|
||||||
return false;
|
|
||||||
} finally {
|
|
||||||
if (statement != null) {
|
|
||||||
try {
|
|
||||||
statement.close();
|
|
||||||
} catch (SQLException e) {
|
|
||||||
printErrors(e);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the number of rows affected by either a DELETE or UPDATE query
|
|
||||||
*
|
|
||||||
* @param sql SQL query to execute
|
|
||||||
* @return the number of rows affected
|
|
||||||
*/
|
|
||||||
public static int update(String sql) {
|
|
||||||
int ret = 0;
|
|
||||||
if (checkConnected()) {
|
|
||||||
PreparedStatement statement = null;
|
|
||||||
try {
|
|
||||||
statement = connection.prepareStatement(sql);
|
|
||||||
ret = statement.executeUpdate();
|
|
||||||
return ret;
|
|
||||||
} catch (SQLException ex) {
|
|
||||||
printErrors(ex);
|
|
||||||
return 0;
|
|
||||||
} finally {
|
|
||||||
if (statement != null) {
|
|
||||||
try {
|
|
||||||
statement.close();
|
|
||||||
} catch (SQLException e) {
|
|
||||||
printErrors(e);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the Integer. Only return first row / first field.
|
|
||||||
*
|
|
||||||
* @param sql SQL query to execute
|
|
||||||
* @return the value in the first row / first field
|
|
||||||
*/
|
|
||||||
public static int getInt(String sql) {
|
|
||||||
ResultSet resultSet;
|
|
||||||
int result = 0;
|
|
||||||
|
|
||||||
if (checkConnected()) {
|
|
||||||
try {
|
|
||||||
PreparedStatement statement = connection.prepareStatement(sql);
|
|
||||||
resultSet = statement.executeQuery();
|
|
||||||
|
|
||||||
if (resultSet.next()) {
|
|
||||||
result = resultSet.getInt(1);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
result = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
statement.close();
|
|
||||||
}
|
|
||||||
catch (SQLException ex) {
|
|
||||||
printErrors(ex);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Check connection status and re-establish if dead or stale.
|
|
||||||
*
|
|
||||||
* If the very first immediate attempt fails, further attempts
|
|
||||||
* will be made in progressively larger intervals up to MAX_WAIT
|
|
||||||
* intervals.
|
|
||||||
*
|
|
||||||
* This allows for MySQL to time out idle connections as needed by
|
|
||||||
* server operator, without affecting McMMO, while still providing
|
|
||||||
* protection against a database outage taking down Bukkit's tick
|
|
||||||
* processing loop due to attemping a database connection each
|
|
||||||
* time McMMO needs the database.
|
|
||||||
*
|
|
||||||
* @return the boolean value for whether or not we are connected
|
|
||||||
*/
|
|
||||||
public static boolean checkConnected() {
|
|
||||||
boolean isClosed = true;
|
|
||||||
boolean isValid = false;
|
|
||||||
boolean exists = (connection != null);
|
|
||||||
|
|
||||||
// If we're waiting for server to recover then leave early
|
|
||||||
if (nextReconnectTimestamp > 0 && nextReconnectTimestamp > System.nanoTime()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (exists) {
|
|
||||||
try {
|
|
||||||
isClosed = connection.isClosed();
|
|
||||||
} catch (SQLException e) {
|
|
||||||
isClosed = true;
|
|
||||||
e.printStackTrace();
|
|
||||||
printErrors(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!isClosed) {
|
|
||||||
try {
|
|
||||||
isValid = connection.isValid(VALID_TIMEOUT);
|
|
||||||
} catch (SQLException e) {
|
|
||||||
// Don't print stack trace because it's valid to lose idle connections
|
|
||||||
// to the server and have to restart them.
|
|
||||||
isValid = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Leave if all ok
|
|
||||||
if (exists && !isClosed && isValid) {
|
|
||||||
// Housekeeping
|
|
||||||
nextReconnectTimestamp = 0;
|
|
||||||
reconnectAttempt = 0;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Cleanup after ourselves for GC and MySQL's sake
|
|
||||||
if (exists && !isClosed) {
|
|
||||||
try {
|
|
||||||
connection.close();
|
|
||||||
} catch (SQLException ex) {
|
|
||||||
// This is a housekeeping exercise, ignore errors
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Try to connect again
|
|
||||||
connect();
|
|
||||||
|
|
||||||
// Leave if connection is good
|
|
||||||
try {
|
|
||||||
if (connection != null && !connection.isClosed()) {
|
|
||||||
// Schedule a database save if we really had an outage
|
|
||||||
if (reconnectAttempt > 1) {
|
|
||||||
mcMMO.p.getServer().getScheduler().scheduleSyncDelayedTask(mcMMO.p, new SQLReconnect(), 5);
|
|
||||||
}
|
|
||||||
nextReconnectTimestamp = 0;
|
|
||||||
reconnectAttempt = 0;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
} catch (SQLException e) {
|
|
||||||
// Failed to check isClosed, so presume connection is bad and attempt later
|
|
||||||
e.printStackTrace();
|
|
||||||
printErrors(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
reconnectAttempt++;
|
|
||||||
|
|
||||||
nextReconnectTimestamp = (long)(System.nanoTime() + Math.min(MAX_WAIT, (reconnectAttempt*SCALING_FACTOR*MIN_WAIT)));
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Read SQL query.
|
|
||||||
*
|
|
||||||
* @param sql SQL query to read
|
|
||||||
* @return the rows in this SQL query
|
|
||||||
*/
|
|
||||||
public static HashMap<Integer, ArrayList<String>> read(String sql) {
|
|
||||||
ResultSet resultSet;
|
|
||||||
HashMap<Integer, ArrayList<String>> rows = new HashMap<Integer, ArrayList<String>>();
|
|
||||||
|
|
||||||
if (checkConnected()) {
|
|
||||||
try {
|
|
||||||
PreparedStatement statement = connection.prepareStatement(sql);
|
|
||||||
resultSet = statement.executeQuery();
|
|
||||||
|
|
||||||
while (resultSet.next()) {
|
|
||||||
ArrayList<String> column = new ArrayList<String>();
|
|
||||||
|
|
||||||
for (int i = 1; i <= resultSet.getMetaData().getColumnCount(); i++) {
|
|
||||||
column.add(resultSet.getString(i));
|
|
||||||
}
|
|
||||||
|
|
||||||
rows.put(resultSet.getRow(), column);
|
|
||||||
}
|
|
||||||
|
|
||||||
statement.close();
|
|
||||||
}
|
|
||||||
catch (SQLException ex) {
|
|
||||||
printErrors(ex);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return rows;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Map<String, Integer> readSQLRank(String playerName) {
|
|
||||||
ResultSet resultSet;
|
|
||||||
Map<String, Integer> skills = new HashMap<String, Integer>();
|
|
||||||
|
|
||||||
if (checkConnected()) {
|
|
||||||
try {
|
|
||||||
for (SkillType skillType: SkillType.values()) {
|
|
||||||
if (skillType.isChildSkill()) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
String sql = "SELECT COUNT(*) AS rank FROM " + tablePrefix + "users JOIN " + tablePrefix + "skills ON user_id = id WHERE " + skillType.name().toLowerCase() + " > 0 AND " + skillType.name().toLowerCase() + " > (SELECT " + skillType.name().toLowerCase() + " FROM " + tablePrefix + "users JOIN " + tablePrefix + "skills ON user_id = id WHERE user = '" + playerName + "')";
|
|
||||||
|
|
||||||
PreparedStatement statement = connection.prepareStatement(sql);
|
|
||||||
resultSet = statement.executeQuery();
|
|
||||||
|
|
||||||
resultSet.next();
|
|
||||||
|
|
||||||
int rank = resultSet.getInt("rank");
|
|
||||||
|
|
||||||
sql = "SELECT user, " + skillType.name().toLowerCase() + " FROM " + tablePrefix + "users JOIN " + tablePrefix + "skills ON user_id = id WHERE " + skillType.name().toLowerCase() + " > 0 AND " + skillType.name().toLowerCase() + " = (SELECT " + skillType.name().toLowerCase() + " FROM " + tablePrefix + "users JOIN " + tablePrefix + "skills ON user_id = id WHERE user = '" + playerName + "') ORDER BY user";
|
|
||||||
|
|
||||||
statement = connection.prepareStatement(sql);
|
|
||||||
resultSet = statement.executeQuery();
|
|
||||||
|
|
||||||
while (resultSet.next()) {
|
|
||||||
if (resultSet.getString("user").equalsIgnoreCase(playerName)) {
|
|
||||||
skills.put(skillType.name(), rank + resultSet.getRow());
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
statement.close();
|
|
||||||
}
|
|
||||||
|
|
||||||
String sql = "SELECT COUNT(*) AS rank FROM " + tablePrefix + "users JOIN " + tablePrefix + "skills ON user_id = id WHERE taming+mining+woodcutting+repair+unarmed+herbalism+excavation+archery+swords+axes+acrobatics+fishing > 0 AND taming+mining+woodcutting+repair+unarmed+herbalism+excavation+archery+swords+axes+acrobatics+fishing > (SELECT taming+mining+woodcutting+repair+unarmed+herbalism+excavation+archery+swords+axes+acrobatics+fishing FROM " + tablePrefix + "users JOIN " + tablePrefix + "skills ON user_id = id WHERE user = '" + playerName + "')";
|
|
||||||
|
|
||||||
PreparedStatement statement = connection.prepareStatement(sql);
|
|
||||||
resultSet = statement.executeQuery();
|
|
||||||
|
|
||||||
resultSet.next();
|
|
||||||
|
|
||||||
int rank = resultSet.getInt("rank");
|
|
||||||
|
|
||||||
sql = "SELECT user, taming+mining+woodcutting+repair+unarmed+herbalism+excavation+archery+swords+axes+acrobatics+fishing FROM " + tablePrefix + "users JOIN " + tablePrefix + "skills ON user_id = id WHERE taming+mining+woodcutting+repair+unarmed+herbalism+excavation+archery+swords+axes+acrobatics+fishing > 0 AND taming+mining+woodcutting+repair+unarmed+herbalism+excavation+archery+swords+axes+acrobatics+fishing = (SELECT taming+mining+woodcutting+repair+unarmed+herbalism+excavation+archery+swords+axes+acrobatics+fishing FROM " + tablePrefix + "users JOIN " + tablePrefix + "skills ON user_id = id WHERE user = '" + playerName + "') ORDER BY user";
|
|
||||||
|
|
||||||
statement = connection.prepareStatement(sql);
|
|
||||||
resultSet = statement.executeQuery();
|
|
||||||
|
|
||||||
while (resultSet.next()) {
|
|
||||||
if (resultSet.getString("user").equalsIgnoreCase(playerName)) {
|
|
||||||
skills.put("ALL", rank + resultSet.getRow());
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
statement.close();
|
|
||||||
}
|
|
||||||
catch (SQLException ex) {
|
|
||||||
printErrors(ex);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return skills;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void purgePowerlessSQL() {
|
|
||||||
mcMMO.p.getLogger().info("Purging powerless users...");
|
|
||||||
HashMap<Integer, ArrayList<String>> usernames = read("SELECT u.user FROM " + tablePrefix + "skills AS s, " + tablePrefix + "users AS u WHERE s.user_id = u.id AND (s.taming+s.mining+s.woodcutting+s.repair+s.unarmed+s.herbalism+s.excavation+s.archery+s.swords+s.axes+s.acrobatics+s.fishing) = 0");
|
|
||||||
write("DELETE FROM " + tablePrefix + "users WHERE " + tablePrefix + "users.id IN (SELECT * FROM (SELECT u.id FROM " + tablePrefix + "skills AS s, " + tablePrefix + "users AS u WHERE s.user_id = u.id AND (s.taming+s.mining+s.woodcutting+s.repair+s.unarmed+s.herbalism+s.excavation+s.archery+s.swords+s.axes+s.acrobatics+s.fishing) = 0) AS p)");
|
|
||||||
|
|
||||||
int purgedUsers = 0;
|
|
||||||
for (int i = 1; i <= usernames.size(); i++) {
|
|
||||||
String playerName = usernames.get(i).get(0);
|
|
||||||
|
|
||||||
if (playerName == null || Bukkit.getOfflinePlayer(playerName).isOnline()) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
profileCleanup(playerName);
|
|
||||||
purgedUsers++;
|
|
||||||
}
|
|
||||||
|
|
||||||
mcMMO.p.getLogger().info("Purged " + purgedUsers + " users from the database.");
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void purgeOldSQL() {
|
|
||||||
mcMMO.p.getLogger().info("Purging old users...");
|
|
||||||
long currentTime = System.currentTimeMillis();
|
|
||||||
long purgeTime = 2630000000L * Config.getInstance().getOldUsersCutoff();
|
|
||||||
HashMap<Integer, ArrayList<String>> usernames = read("SELECT user FROM " + tablePrefix + "users WHERE ((" + currentTime + " - lastlogin*1000) > " + purgeTime + ")");
|
|
||||||
write("DELETE FROM " + tablePrefix + "users WHERE " + tablePrefix + "users.id IN (SELECT * FROM (SELECT id FROM " + tablePrefix + "users WHERE ((" + currentTime + " - lastlogin*1000) > " + purgeTime + ")) AS p)");
|
|
||||||
|
|
||||||
int purgedUsers = 0;
|
|
||||||
for (int i = 1; i <= usernames.size(); i++) {
|
|
||||||
String playerName = usernames.get(i).get(0);
|
|
||||||
|
|
||||||
if (playerName == null) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
profileCleanup(playerName);
|
|
||||||
purgedUsers++;
|
|
||||||
}
|
|
||||||
|
|
||||||
mcMMO.p.getLogger().info("Purged " + purgedUsers + " users from the database.");
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void printErrors(SQLException ex) {
|
private static void printErrors(SQLException ex) {
|
||||||
mcMMO.p.getLogger().severe("SQLException: " + ex.getMessage());
|
mcMMO.p.getLogger().severe("SQLException: " + ex.getMessage());
|
||||||
mcMMO.p.getLogger().severe("SQLState: " + ex.getSQLState());
|
mcMMO.p.getLogger().severe("SQLState: " + ex.getSQLState());
|
||||||
mcMMO.p.getLogger().severe("VendorError: " + ex.getErrorCode());
|
mcMMO.p.getLogger().severe("VendorError: " + ex.getErrorCode());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void profileCleanup(String playerName) {
|
|
||||||
McMMOPlayer mcmmoPlayer = Users.getPlayer(playerName);
|
|
||||||
|
|
||||||
if (mcmmoPlayer != null) {
|
|
||||||
Player player = mcmmoPlayer.getPlayer();
|
|
||||||
SpoutHud spoutHud = mcmmoPlayer.getProfile().getSpoutHud();
|
|
||||||
|
|
||||||
if (spoutHud != null) {
|
|
||||||
spoutHud.removeWidgets();
|
|
||||||
}
|
|
||||||
|
|
||||||
Users.remove(playerName);
|
|
||||||
|
|
||||||
if (player.isOnline()) {
|
|
||||||
Users.addUser(player);
|
|
||||||
|
|
||||||
if (mcMMO.spoutEnabled) {
|
|
||||||
SpoutTools.reloadSpoutPlayer(player);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -1,8 +0,0 @@
|
|||||||
package com.gmail.nossr50.database;
|
|
||||||
|
|
||||||
public enum DatabaseUpdate {
|
|
||||||
FISHING,
|
|
||||||
BLAST_MINING,
|
|
||||||
CASCADE_DELETE,
|
|
||||||
INDEX;
|
|
||||||
}
|
|
@ -10,46 +10,47 @@ import java.util.Comparator;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
|
|
||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.gmail.nossr50.config.Config;
|
import com.gmail.nossr50.config.Config;
|
||||||
import com.gmail.nossr50.skills.utilities.SkillType;
|
import com.gmail.nossr50.datatypes.database.PlayerStat;
|
||||||
|
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||||
import com.gmail.nossr50.util.StringUtils;
|
import com.gmail.nossr50.util.StringUtils;
|
||||||
|
|
||||||
public final class Leaderboard {
|
public final class LeaderboardManager {
|
||||||
private static HashMap<SkillType, List<PlayerStat>> playerStatHash = new HashMap<SkillType, List<PlayerStat>>();
|
private static HashMap<SkillType, List<PlayerStat>> playerStatHash = new HashMap<SkillType, List<PlayerStat>>();
|
||||||
private static List<PlayerStat> powerLevels = new ArrayList<PlayerStat>();
|
private static List<PlayerStat> powerLevels = new ArrayList<PlayerStat>();
|
||||||
private static long lastUpdate = 0;
|
private static long lastUpdate = 0;
|
||||||
|
|
||||||
private Leaderboard() {}
|
private static final long UPDATE_WAIT_TIME = 600000L; // 10 minutes
|
||||||
|
private static final long ONE_MONTH = 2630000000L;
|
||||||
|
|
||||||
|
private LeaderboardManager() {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update the leader boards.
|
* Update the leader boards.
|
||||||
*/
|
*/
|
||||||
public static void updateLeaderboards() {
|
public static void updateLeaderboards() {
|
||||||
if(System.currentTimeMillis() < lastUpdate + 600000) {
|
// Only update FFS leaderboards every 10 minutes.. this puts a lot of strain on the server (depending on the size of the database) and should not be done frequently
|
||||||
return; //Only update FFS leaderboards every 10 minutes.. this puts a lot of strain on the server (depending on the size of the database) and should not be done frequently
|
if (System.currentTimeMillis() < lastUpdate + UPDATE_WAIT_TIME) {
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
lastUpdate = System.currentTimeMillis(); // Log when the last update was run
|
lastUpdate = System.currentTimeMillis(); // Log when the last update was run
|
||||||
|
powerLevels.clear(); // Clear old values from the power levels
|
||||||
|
|
||||||
// Initialize lists
|
// Initialize lists
|
||||||
List<PlayerStat> mining, woodcutting, herbalism, excavation, acrobatics, repair, swords, axes, archery, unarmed, taming, fishing;
|
List<PlayerStat> mining = new ArrayList<PlayerStat>();
|
||||||
|
List<PlayerStat> woodcutting = new ArrayList<PlayerStat>();
|
||||||
mining = new ArrayList<PlayerStat>();
|
List<PlayerStat> herbalism = new ArrayList<PlayerStat>();
|
||||||
woodcutting = new ArrayList<PlayerStat>();
|
List<PlayerStat> excavation = new ArrayList<PlayerStat>();
|
||||||
herbalism = new ArrayList<PlayerStat>();
|
List<PlayerStat> acrobatics = new ArrayList<PlayerStat>();
|
||||||
excavation = new ArrayList<PlayerStat>();
|
List<PlayerStat> repair = new ArrayList<PlayerStat>();
|
||||||
acrobatics = new ArrayList<PlayerStat>();
|
List<PlayerStat> swords = new ArrayList<PlayerStat>();
|
||||||
repair = new ArrayList<PlayerStat>();
|
List<PlayerStat> axes = new ArrayList<PlayerStat>();
|
||||||
swords = new ArrayList<PlayerStat>();
|
List<PlayerStat> archery = new ArrayList<PlayerStat>();
|
||||||
axes = new ArrayList<PlayerStat>();
|
List<PlayerStat> unarmed = new ArrayList<PlayerStat>();
|
||||||
archery = new ArrayList<PlayerStat>();
|
List<PlayerStat> taming = new ArrayList<PlayerStat>();
|
||||||
unarmed = new ArrayList<PlayerStat>();
|
List<PlayerStat> fishing = new ArrayList<PlayerStat>();
|
||||||
taming = new ArrayList<PlayerStat>();
|
|
||||||
fishing = new ArrayList<PlayerStat>();
|
|
||||||
powerLevels = new ArrayList<PlayerStat>();
|
|
||||||
|
|
||||||
// Read from the FlatFile database and fill our arrays with information
|
// Read from the FlatFile database and fill our arrays with information
|
||||||
try {
|
try {
|
||||||
@ -136,10 +137,11 @@ public final class Leaderboard {
|
|||||||
in.close();
|
in.close();
|
||||||
}
|
}
|
||||||
catch (Exception e) {
|
catch (Exception e) {
|
||||||
mcMMO.p.getLogger().severe(("Exception while reading " + mcMMO.getUsersFilePath() + " (Are you sure you formatted it correctly?)" + e.toString()));
|
mcMMO.p.getLogger().severe("Exception while reading " + mcMMO.getUsersFilePath() + " (Are you sure you formatted it correctly?)" + e.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
SkillComparator c = new SkillComparator();
|
SkillComparator c = new SkillComparator();
|
||||||
|
|
||||||
Collections.sort(mining, c);
|
Collections.sort(mining, c);
|
||||||
Collections.sort(woodcutting, c);
|
Collections.sort(woodcutting, c);
|
||||||
Collections.sort(repair, c);
|
Collections.sort(repair, c);
|
||||||
@ -227,6 +229,7 @@ public final class Leaderboard {
|
|||||||
currentPos++;
|
currentPos++;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
return new int[] {0, 0};
|
return new int[] {0, 0};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -246,17 +249,11 @@ public final class Leaderboard {
|
|||||||
currentPos++;
|
currentPos++;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
return new int[] {0, 0};
|
|
||||||
}
|
|
||||||
|
|
||||||
return new int[] {0, 0};
|
return new int[] {0, 0};
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class SkillComparator implements Comparator<PlayerStat> {
|
return new int[] {0, 0};
|
||||||
@Override
|
|
||||||
public int compare(PlayerStat o1, PlayerStat o2) {
|
|
||||||
return (o2.statVal - o1.statVal);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean removeFlatFileUser(String playerName) {
|
public static boolean removeFlatFileUser(String playerName) {
|
||||||
@ -274,7 +271,7 @@ public final class Leaderboard {
|
|||||||
|
|
||||||
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 (!line.split(":")[0].equalsIgnoreCase(playerName)) {
|
if (!line.split(":")[0].equalsIgnoreCase(playerName)) {
|
||||||
writer.append(line).append("\r\n");
|
writer.append(line).append("\r\n");
|
||||||
}
|
}
|
||||||
@ -314,13 +311,12 @@ public final class Leaderboard {
|
|||||||
return worked;
|
return worked;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static void purgePowerlessFlatfile() {
|
public static void purgePowerlessFlatfile() {
|
||||||
mcMMO.p.getLogger().info("Purging powerless users...");
|
mcMMO.p.getLogger().info("Purging powerless users...");
|
||||||
|
|
||||||
int purgedUsers = 0;
|
int purgedUsers = 0;
|
||||||
for (PlayerStat stat : powerLevels) {
|
for (PlayerStat stat : powerLevels) {
|
||||||
if (stat.statVal == 0 && removeFlatFileUser(stat.name) && !Bukkit.getOfflinePlayer(stat.name).isOnline()) {
|
if (stat.statVal == 0 && removeFlatFileUser(stat.name) && !mcMMO.p.getServer().getOfflinePlayer(stat.name).isOnline()) {
|
||||||
purgedUsers++;
|
purgedUsers++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -337,7 +333,7 @@ public final class Leaderboard {
|
|||||||
private static int removeOldFlatfileUsers() {
|
private static int removeOldFlatfileUsers() {
|
||||||
int removedPlayers = 0;
|
int removedPlayers = 0;
|
||||||
long currentTime = System.currentTimeMillis();
|
long currentTime = System.currentTimeMillis();
|
||||||
long purgeTime = 2630000000L * Config.getInstance().getOldUsersCutoff();
|
long purgeTime = ONE_MONTH * Config.getInstance().getOldUsersCutoff();
|
||||||
|
|
||||||
BufferedReader in = null;
|
BufferedReader in = null;
|
||||||
FileWriter out = null;
|
FileWriter out = null;
|
||||||
@ -351,7 +347,7 @@ public final class Leaderboard {
|
|||||||
|
|
||||||
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.
|
||||||
String[] splitLine = line.split(":");
|
String[] splitLine = line.split(":");
|
||||||
|
|
||||||
if (splitLine.length > 37) {
|
if (splitLine.length > 37) {
|
||||||
@ -398,4 +394,10 @@ public final class Leaderboard {
|
|||||||
return removedPlayers;
|
return removedPlayers;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static class SkillComparator implements Comparator<PlayerStat> {
|
||||||
|
@Override
|
||||||
|
public int compare(PlayerStat o1, PlayerStat o2) {
|
||||||
|
return (o2.statVal - o1.statVal);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
@ -1,39 +0,0 @@
|
|||||||
package com.gmail.nossr50.database.commands;
|
|
||||||
|
|
||||||
import org.bukkit.command.Command;
|
|
||||||
import org.bukkit.command.CommandExecutor;
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
|
|
||||||
import com.gmail.nossr50.config.Config;
|
|
||||||
import com.gmail.nossr50.database.Database;
|
|
||||||
import com.gmail.nossr50.database.Leaderboard;
|
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
|
||||||
|
|
||||||
public class McpurgeCommand implements CommandExecutor{
|
|
||||||
@Override
|
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
|
||||||
switch (args.length) {
|
|
||||||
case 0:
|
|
||||||
if (Config.getInstance().getUseMySQL()) {
|
|
||||||
Database.purgePowerlessSQL();
|
|
||||||
|
|
||||||
if (Config.getInstance().getOldUsersCutoff() != -1) {
|
|
||||||
Database.purgeOldSQL();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
Leaderboard.purgePowerlessFlatfile();
|
|
||||||
|
|
||||||
if (Config.getInstance().getOldUsersCutoff() != -1) {
|
|
||||||
Leaderboard.purgeOldFlatfile();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.mcpurge.Success"));
|
|
||||||
return true;
|
|
||||||
|
|
||||||
default:
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,45 +0,0 @@
|
|||||||
package com.gmail.nossr50.database.commands;
|
|
||||||
|
|
||||||
import org.bukkit.command.Command;
|
|
||||||
import org.bukkit.command.CommandExecutor;
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
|
|
||||||
import com.gmail.nossr50.config.Config;
|
|
||||||
import com.gmail.nossr50.database.Database;
|
|
||||||
import com.gmail.nossr50.database.Leaderboard;
|
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
|
||||||
|
|
||||||
public class McremoveCommand implements CommandExecutor {
|
|
||||||
@Override
|
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
|
||||||
switch (args.length) {
|
|
||||||
case 1:
|
|
||||||
/* MySQL */
|
|
||||||
if (Config.getInstance().getUseMySQL()) {
|
|
||||||
String tablePrefix = Config.getInstance().getMySQLTablePrefix();
|
|
||||||
|
|
||||||
if (Database.update("DELETE FROM " + tablePrefix + "users WHERE " + tablePrefix + "users.user = '" + args[0] + "'") != 0) {
|
|
||||||
Database.profileCleanup(args[0]);
|
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.mcremove.Success", args[0]));
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
if (Leaderboard.removeFlatFileUser(args[0])) {
|
|
||||||
Database.profileCleanup(args[0]);
|
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.mcremove.Success", args[0]));
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
|
|
||||||
default:
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,45 +0,0 @@
|
|||||||
package com.gmail.nossr50.database.commands;
|
|
||||||
|
|
||||||
import org.bukkit.command.Command;
|
|
||||||
import org.bukkit.command.CommandExecutor;
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
import com.gmail.nossr50.mcMMO;
|
|
||||||
import com.gmail.nossr50.config.Config;
|
|
||||||
import com.gmail.nossr50.database.runnables.SQLConversionTask;
|
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
|
||||||
import com.gmail.nossr50.util.Users;
|
|
||||||
|
|
||||||
public class MmoupdateCommand implements CommandExecutor {
|
|
||||||
@Override
|
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
|
||||||
switch (args.length) {
|
|
||||||
case 0:
|
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.mmoupdate.Start"));
|
|
||||||
Users.clearAll();
|
|
||||||
convertToMySQL();
|
|
||||||
|
|
||||||
for (Player player : mcMMO.p.getServer().getOnlinePlayers()) {
|
|
||||||
Users.addUser(player);
|
|
||||||
}
|
|
||||||
|
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.mmoupdate.Finish"));
|
|
||||||
return true;
|
|
||||||
|
|
||||||
default:
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Convert FlatFile data to MySQL data.
|
|
||||||
*/
|
|
||||||
private void convertToMySQL() {
|
|
||||||
if (!Config.getInstance().getUseMySQL()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
mcMMO.p.getServer().getScheduler().runTaskLaterAsynchronously(mcMMO.p, new SQLConversionTask(), 1);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,21 +0,0 @@
|
|||||||
package com.gmail.nossr50.database.runnables;
|
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
import com.gmail.nossr50.mcMMO;
|
|
||||||
import com.gmail.nossr50.database.Database;
|
|
||||||
import com.gmail.nossr50.util.Users;
|
|
||||||
|
|
||||||
public class SQLReconnect implements Runnable {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
if (Database.checkConnected()) {
|
|
||||||
Users.saveAll(); //Save all profiles
|
|
||||||
Users.clearAll(); //Clear the profiles
|
|
||||||
|
|
||||||
for (Player player : mcMMO.p.getServer().getOnlinePlayers()) {
|
|
||||||
Users.addUser(player); //Add in new profiles, forcing them to 'load' again from MySQL
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user