mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-24 06:06:45 +01:00
Squashed commit of the following:
commit cb3e057dee1f2b29838ab654a526baac1baab7d6 Author: NuclearW <incongruency@gmail.com> Date: Fri Mar 1 00:43:57 2013 -0500 1.4.00 release commit 4f9628d2e4cde31c8946e9a911ee6f10e1fb6b35 Author: NuclearW <incongruency@gmail.com> Date: Fri Mar 1 00:07:30 2013 -0500 \r -> \n commit b2ca22e0477c747143b0f08a28a096967ee6ffd7 Author: GJ <gjmcferrin@gmail.com> Date: Thu Feb 28 23:53:56 2013 -0500 Commented-out code shouldn't be done like that. commit 92f131712cc671e3e616c14a22e22769ef6d6d0b Author: GJ <gjmcferrin@gmail.com> Date: Thu Feb 28 23:45:36 2013 -0500 More things we missed. commit 408b03766f6261a03a862a1ab7f5835772feda4a Author: NuclearW <incongruency@gmail.com> Date: Thu Feb 28 23:20:13 2013 -0500 Format: util through spout and backup lib commit d6bd2c29bbb51bee3607247468cfe145d4f38c9e Author: GJ <gjmcferrin@gmail.com> Date: Thu Feb 28 22:50:08 2013 -0500 The things we missed the first time through... commit 393f0b889aa1b7011ee81ee7b15413d8824b8cfb Author: GJ <gjmcferrin@gmail.com> Date: Thu Feb 28 22:05:29 2013 -0500 Formatting: Skills commit c097a6e188a7b760dd1b4389ed81dca417146b16 Author: GJ <gjmcferrin@gmail.com> Date: Thu Feb 28 19:30:12 2013 -0500 Organize imports. commit 34c3e74be7eb5f983f21d969e30155c5d82c01c1 Author: GJ <gjmcferrin@gmail.com> Date: Thu Feb 28 19:09:45 2013 -0500 Fixed a missing fallthrough comment from ChatCommand commit b4a76c9f022a2fd98bdd8f083accfea03becfd71 Author: GJ <gjmcferrin@gmail.com> Date: Thu Feb 28 19:09:36 2013 -0500 Formatting: datatypes.* through events.* commit 3e57dd41d3265a7c8106c7eb026df926770a4d15 Author: NuclearW <incongruency@gmail.com> Date: Thu Feb 28 17:56:15 2013 -0500 Fix issue with bad rebase commit e8c8e06b2971555b7334e49128257e3af6f36892 Author: GJ <gjmcferrin@gmail.com> Date: Thu Feb 28 17:35:32 2013 -0500 Formatting: DatabaseManager, LeaderboardManager, DatabaseUpdateType, and PlayerStat commit 13ecf1cc41f377a12991e357ac10abdcda24d6de Author: NuclearW <incongruency@gmail.com> Date: Thu Feb 28 17:31:43 2013 -0500 Format: listeners.* through runnables.* commit 71686e3c0d96c2dcf25442b91703fadda1ea3bb0 Author: NuclearW <incongruency@gmail.com> Date: Thu Feb 28 17:13:57 2013 -0500 Format PartyLockCommand commit d50abed10bf94e1a88df3dc5cc07c259aea920ea Author: NuclearW <incongruency@gmail.com> Date: Thu Feb 28 16:54:08 2013 -0500 Format: base through config.* commit 7004823eeebbae5be7728bf9cafc3b04e57b64cf Author: NuclearW <incongruency@gmail.com> Date: Thu Feb 28 15:21:40 2013 -0500 Example of using spaces to align like things commit 534190cfe2481e466fe459d65628550458cc2993 Author: NuclearW <incongruency@gmail.com> Date: Thu Feb 28 15:12:19 2013 -0500 Capitalization commit 5b61d3ba4c8d81e6f358b0cf4f460abfe9798414 Author: NuclearW <incongruency@gmail.com> Date: Thu Feb 28 15:07:43 2013 -0500 Updated readme, added standards.md commit 5ec0df70fb82c527420a2f437f27f31bd758f884 Author: NuclearW <incongruency@gmail.com> Date: Thu Feb 28 14:42:16 2013 -0500 Markdown was here, Creole is a loser commit 70d557c59d086b6a5fb5e0e63c0c1d8eb4c8d19c Author: NuclearW <incongruency@gmail.com> Date: Thu Feb 28 13:46:24 2013 -0500 Move MCStats shading to .metrics.mcstats commit eb9d67e66b1659d6abd2397ecf403343cfeffdda Author: GJ <gjmcferrin@gmail.com> Date: Thu Feb 28 13:37:37 2013 -0500 Move ALL the packages! commit 8ffa9e7b75417b6c7f158613d4b4ffb783dcf2d0 Author: NuclearW <incongruency@gmail.com> Date: Thu Feb 28 12:37:12 2013 -0500 /r/n -> /n
This commit is contained in:
parent
13111a8d1b
commit
a542d6cf3e
4
.gitattributes
vendored
Normal file
4
.gitattributes
vendored
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
* text
|
||||||
|
|
||||||
|
*.png binary
|
||||||
|
*.wav binary
|
@ -7,7 +7,7 @@ Key:
|
|||||||
! Change
|
! Change
|
||||||
- Removal
|
- Removal
|
||||||
|
|
||||||
Version 1.4.00-dev
|
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.
|
||||||
|
@ -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.
|
4
pom.xml
4
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-dev5</version>
|
<version>1.4.00</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>
|
||||||
|
@ -2,43 +2,43 @@ 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.PlayerProfile;
|
||||||
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).getProfile().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).getProfile().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).getProfile().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).getProfile().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).getProfile().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).getProfile().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).getProfile().getAbilityMode(AbilityType.TREE_FELLER);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isAnyAbilityEnabled(Player player) {
|
public static boolean isAnyAbilityEnabled(Player player) {
|
||||||
PlayerProfile profile = Users.getPlayer(player).getProfile();
|
PlayerProfile profile = UserManager.getPlayer(player).getProfile();
|
||||||
|
|
||||||
for (AbilityType ability : AbilityType.values()) {
|
for (AbilityType ability : AbilityType.values()) {
|
||||||
if (profile.getAbilityMode(ability)) {
|
if (profile.getAbilityMode(ability)) {
|
||||||
|
@ -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>
|
||||||
@ -32,9 +20,9 @@ public final class ExperienceAPI {
|
|||||||
* @param XP The amount of XP to add
|
* @param XP The amount of XP to add
|
||||||
* @deprecated Use {@link #addRawXP(Player, String, int)} instead
|
* @deprecated Use {@link #addRawXP(Player, String, int)} instead
|
||||||
*/
|
*/
|
||||||
@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,7 @@ 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();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -261,7 +249,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 +262,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 +277,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 +290,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 +305,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 +318,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());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -2,11 +2,12 @@ package com.gmail.nossr50.api;
|
|||||||
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import com.gmail.nossr50.spout.SpoutConfig;
|
import com.gmail.nossr50.config.spout.SpoutConfig;
|
||||||
import com.gmail.nossr50.spout.huds.HudType;
|
import com.gmail.nossr50.datatypes.spout.huds.HudType;
|
||||||
import com.gmail.nossr50.util.Users;
|
import com.gmail.nossr50.util.player.UserManager;
|
||||||
|
|
||||||
public class SpoutHudAPI {
|
public class SpoutHudAPI {
|
||||||
|
private SpoutHudAPI() {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Disable the mcMMO XP bar for a player.
|
* Disable the mcMMO XP bar for a player.
|
||||||
@ -14,7 +15,7 @@ public class SpoutHudAPI {
|
|||||||
* This function is designed for API usage.
|
* This function is designed for API usage.
|
||||||
*/
|
*/
|
||||||
public static void disableXpBar(Player player) {
|
public static void disableXpBar(Player player) {
|
||||||
Users.getPlayer(player).getProfile().setHudType(HudType.DISABLED);
|
UserManager.getPlayer(player).getProfile().setHudType(HudType.DISABLED);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -5,14 +5,14 @@ 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>();
|
||||||
public static final List<ItemStack> spoutAxes = new ArrayList<ItemStack>();
|
public static final List<ItemStack> spoutAxes = new ArrayList<ItemStack>();
|
||||||
public static final List<ItemStack> spoutPickaxes = new ArrayList<ItemStack>();
|
public static final List<ItemStack> spoutPickaxes = new ArrayList<ItemStack>();
|
||||||
public static final List<ItemStack> spoutHoes = new ArrayList<ItemStack>();
|
public static final List<ItemStack> spoutHoes = new ArrayList<ItemStack>();
|
||||||
public static final List<ItemStack> spoutShovels = new ArrayList<ItemStack>();
|
public static final List<ItemStack> spoutShovels = new ArrayList<ItemStack>();
|
||||||
|
|
||||||
private SpoutToolsAPI() {}
|
private SpoutToolsAPI() {}
|
||||||
|
|
||||||
@ -26,28 +26,28 @@ public final class SpoutToolsAPI {
|
|||||||
*/
|
*/
|
||||||
public static void addCustomTool(ItemStack spoutTool, ToolType type) {
|
public static void addCustomTool(ItemStack spoutTool, ToolType type) {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case AXE:
|
case AXE:
|
||||||
spoutAxes.add(spoutTool);
|
spoutAxes.add(spoutTool);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case HOE:
|
case HOE:
|
||||||
spoutHoes.add(spoutTool);
|
spoutHoes.add(spoutTool);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PICKAXE:
|
case PICKAXE:
|
||||||
spoutPickaxes.add(spoutTool);
|
spoutPickaxes.add(spoutTool);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SHOVEL:
|
case SHOVEL:
|
||||||
spoutShovels.add(spoutTool);
|
spoutShovels.add(spoutTool);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SWORD:
|
case SWORD:
|
||||||
spoutSwords.add(spoutTool);
|
spoutSwords.add(spoutTool);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,10 +6,10 @@ 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 () {}
|
||||||
@ -22,10 +22,12 @@ public final class ChatManager {
|
|||||||
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();
|
||||||
|
|
||||||
@ -50,10 +52,12 @@ public final class ChatManager {
|
|||||||
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();
|
||||||
|
|
||||||
|
@ -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 {
|
||||||
@ -10,53 +10,53 @@ public enum ChatMode {
|
|||||||
private String enabledMessage;
|
private String enabledMessage;
|
||||||
private String disabledMessage;
|
private String disabledMessage;
|
||||||
|
|
||||||
private ChatMode (String enabledMessage, String disabledMessage) {
|
private ChatMode(String enabledMessage, String disabledMessage) {
|
||||||
this.enabledMessage = enabledMessage;
|
this.enabledMessage = enabledMessage;
|
||||||
this.disabledMessage = disabledMessage;
|
this.disabledMessage = disabledMessage;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isEnabled(McMMOPlayer mcMMOPlayer) {
|
public boolean isEnabled(McMMOPlayer mcMMOPlayer) {
|
||||||
switch (this) {
|
switch (this) {
|
||||||
case ADMIN:
|
case ADMIN:
|
||||||
return mcMMOPlayer.getAdminChatMode();
|
return mcMMOPlayer.getAdminChatMode();
|
||||||
|
|
||||||
case PARTY:
|
case PARTY:
|
||||||
return mcMMOPlayer.getPartyChatMode();
|
return mcMMOPlayer.getPartyChatMode();
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void disable(McMMOPlayer mcMMOPlayer) {
|
public void disable(McMMOPlayer mcMMOPlayer) {
|
||||||
switch (this) {
|
switch (this) {
|
||||||
case ADMIN:
|
case ADMIN:
|
||||||
mcMMOPlayer.setAdminChat(false);
|
mcMMOPlayer.setAdminChat(false);
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case PARTY:
|
case PARTY:
|
||||||
mcMMOPlayer.setPartyChat(false);
|
mcMMOPlayer.setPartyChat(false);
|
||||||
return;
|
return;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void enable(McMMOPlayer mcMMOPlayer) {
|
public void enable(McMMOPlayer mcMMOPlayer) {
|
||||||
switch (this) {
|
switch (this) {
|
||||||
case ADMIN:
|
case ADMIN:
|
||||||
mcMMOPlayer.setAdminChat(true);
|
mcMMOPlayer.setAdminChat(true);
|
||||||
mcMMOPlayer.setPartyChat(false);
|
mcMMOPlayer.setPartyChat(false);
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case PARTY:
|
case PARTY:
|
||||||
mcMMOPlayer.setPartyChat(true);
|
mcMMOPlayer.setPartyChat(true);
|
||||||
mcMMOPlayer.setAdminChat(false);
|
mcMMOPlayer.setAdminChat(false);
|
||||||
return;
|
return;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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 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 = UserManager.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 = UserManager.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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
89
src/main/java/com/gmail/nossr50/commands/McgodCommand.java
Normal file
89
src/main/java/com/gmail/nossr50/commands/McgodCommand.java
Normal file
@ -0,0 +1,89 @@
|
|||||||
|
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) {
|
||||||
|
PlayerProfile profile;
|
||||||
|
|
||||||
|
switch (args.length) {
|
||||||
|
case 0:
|
||||||
|
if (!Permissions.mcgod(sender)) {
|
||||||
|
sender.sendMessage(command.getPermissionMessage());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!(sender instanceof Player)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
profile = UserManager.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 = UserManager.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,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,55 +8,54 @@ 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)) {
|
||||||
sender.sendMessage(command.getPermissionMessage());
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
String description = LocaleLoader.getString("mcMMO.Description");
|
|
||||||
String[] mcSplit = description.split(",");
|
|
||||||
sender.sendMessage(mcSplit);
|
|
||||||
|
|
||||||
if (Config.getInstance().getDonateMessageEnabled()) {
|
|
||||||
if (mcMMO.spoutEnabled && sender instanceof SpoutPlayer) {
|
|
||||||
SpoutPlayer spoutPlayer = (SpoutPlayer) sender;
|
|
||||||
spoutPlayer.sendNotification(LocaleLoader.getString("Spout.Donate"), ChatColor.GREEN + "gjmcferrin@gmail.com", Material.DIAMOND);
|
|
||||||
}
|
|
||||||
|
|
||||||
sender.sendMessage(LocaleLoader.getString("MOTD.Donate"));
|
|
||||||
sender.sendMessage(ChatColor.GOLD + " - " + ChatColor.GREEN + "gjmcferrin@gmail.com" + ChatColor.GOLD + " Paypal");
|
|
||||||
}
|
|
||||||
|
|
||||||
sender.sendMessage(LocaleLoader.getString("MOTD.Version", mcMMO.p.getDescription().getVersion()));
|
|
||||||
return true;
|
|
||||||
|
|
||||||
case 1:
|
|
||||||
if (args[0].equalsIgnoreCase("?") || args[0].equalsIgnoreCase("help") || args[0].equalsIgnoreCase("commands")) {
|
|
||||||
if (!Permissions.mcmmoHelp(sender)) {
|
|
||||||
sender.sendMessage(command.getPermissionMessage());
|
sender.sendMessage(command.getPermissionMessage());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.mcc.Header"));
|
String description = LocaleLoader.getString("mcMMO.Description");
|
||||||
displayPartyCommands(sender);
|
String[] mcSplit = description.split(",");
|
||||||
displayOtherCommands(sender);
|
sender.sendMessage(mcSplit);
|
||||||
|
|
||||||
}
|
if (Config.getInstance().getDonateMessageEnabled()) {
|
||||||
return true;
|
if (mcMMO.spoutEnabled && sender instanceof SpoutPlayer) {
|
||||||
|
SpoutPlayer spoutPlayer = (SpoutPlayer) sender;
|
||||||
|
spoutPlayer.sendNotification(LocaleLoader.getString("Spout.Donate"), ChatColor.GREEN + "gjmcferrin@gmail.com", Material.DIAMOND);
|
||||||
|
}
|
||||||
|
|
||||||
default:
|
sender.sendMessage(LocaleLoader.getString("MOTD.Donate"));
|
||||||
return false;
|
sender.sendMessage(ChatColor.GOLD + " - " + ChatColor.GREEN + "gjmcferrin@gmail.com" + ChatColor.GOLD + " Paypal");
|
||||||
|
}
|
||||||
|
|
||||||
|
sender.sendMessage(LocaleLoader.getString("MOTD.Version", mcMMO.p.getDescription().getVersion()));
|
||||||
|
return true;
|
||||||
|
|
||||||
|
case 1:
|
||||||
|
if (args[0].equalsIgnoreCase("?") || args[0].equalsIgnoreCase("help") || args[0].equalsIgnoreCase("commands")) {
|
||||||
|
if (!Permissions.mcmmoHelp(sender)) {
|
||||||
|
sender.sendMessage(command.getPermissionMessage());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
sender.sendMessage(LocaleLoader.getString("Commands.mcc.Header"));
|
||||||
|
displayPartyCommands(sender);
|
||||||
|
displayOtherCommands(sender);
|
||||||
|
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -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.PlayerProfile;
|
||||||
|
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:
|
||||||
|
PlayerProfile profile = UserManager.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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -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) {
|
||||||
|
PlayerProfile profile;
|
||||||
|
|
||||||
|
switch (args.length) {
|
||||||
|
case 0:
|
||||||
|
if (!Permissions.mcrefresh(sender)) {
|
||||||
|
sender.sendMessage(command.getPermissionMessage());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!(sender instanceof Player)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
profile = UserManager.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 = UserManager.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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
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, 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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -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;
|
@ -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,38 +6,37 @@ 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;
|
||||||
protected ChatMode chatMode;
|
protected ChatMode chatMode;
|
||||||
|
|
||||||
public ChatCommand (ChatMode chatMode) {
|
public ChatCommand(ChatMode chatMode) {
|
||||||
this.chatMode = chatMode;
|
this.chatMode = chatMode;
|
||||||
}
|
}
|
||||||
|
|
||||||
@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 (!(sender instanceof Player)) {
|
if (!(sender instanceof Player)) {
|
||||||
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);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
enableChatMode(sender);
|
enableChatMode(sender);
|
||||||
}
|
}
|
||||||
|
|
||||||
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;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
handleChatSending(sender, args);
|
// Fallthrough
|
||||||
return true;
|
|
||||||
|
default:
|
||||||
|
handleChatSending(sender, args);
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,4 +1,4 @@
|
|||||||
package com.gmail.nossr50.database.commands;
|
package com.gmail.nossr50.commands.database;
|
||||||
|
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandExecutor;
|
import org.bukkit.command.CommandExecutor;
|
||||||
@ -7,10 +7,10 @@ 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.SQLConversionTask;
|
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
|
import com.gmail.nossr50.runnables.database.SQLConversionTask;
|
||||||
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 MmoupdateCommand implements CommandExecutor {
|
public class MmoupdateCommand implements CommandExecutor {
|
||||||
@Override
|
@Override
|
||||||
@ -21,20 +21,20 @@ public class MmoupdateCommand implements CommandExecutor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
switch (args.length) {
|
switch (args.length) {
|
||||||
case 0:
|
case 0:
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.mmoupdate.Start"));
|
sender.sendMessage(LocaleLoader.getString("Commands.mmoupdate.Start"));
|
||||||
Users.clearAll();
|
UserManager.clearAll();
|
||||||
convertToMySQL();
|
convertToMySQL();
|
||||||
|
|
||||||
for (Player player : mcMMO.p.getServer().getOnlinePlayers()) {
|
for (Player player : mcMMO.p.getServer().getOnlinePlayers()) {
|
||||||
Users.addUser(player);
|
UserManager.addUser(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.mmoupdate.Finish"));
|
sender.sendMessage(LocaleLoader.getString("Commands.mmoupdate.Finish"));
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -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,38 +1,37 @@
|
|||||||
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:
|
||||||
unprotectParty(sender, playerParty);
|
|
||||||
return true;
|
|
||||||
|
|
||||||
case 2:
|
|
||||||
if (args[1].equalsIgnoreCase("clear") || args[1].equalsIgnoreCase("reset")) {
|
|
||||||
unprotectParty(sender, playerParty);
|
unprotectParty(sender, playerParty);
|
||||||
return true;
|
return true;
|
||||||
}
|
|
||||||
|
|
||||||
protectParty(sender, playerParty, args[1]);
|
case 2:
|
||||||
return true;
|
if (args[1].equalsIgnoreCase("clear") || args[1].equalsIgnoreCase("reset")) {
|
||||||
|
unprotectParty(sender, playerParty);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
default:
|
protectParty(sender, playerParty, args[1]);
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "password", "[clear|reset]"));
|
return true;
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "password", "<" + LocaleLoader.getString("Commands.Usage.Password") + ">"));
|
|
||||||
return true;
|
default:
|
||||||
|
sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "password", "[clear|reset]"));
|
||||||
|
sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "password", "<" + LocaleLoader.getString("Commands.Usage.Password") + ">"));
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
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[1];
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
@ -24,24 +24,24 @@ 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);
|
||||||
}
|
}
|
||||||
else if (args[1].equalsIgnoreCase("equal") || args[1].equalsIgnoreCase("even") || args[1].equalsIgnoreCase("on") || args[1].equalsIgnoreCase("true")) {
|
else if (args[1].equalsIgnoreCase("equal") || args[1].equalsIgnoreCase("even") || args[1].equalsIgnoreCase("on") || args[1].equalsIgnoreCase("true")) {
|
||||||
handleChangingShareMode(ShareMode.EQUAL);
|
handleChangingShareMode(ShareMode.EQUAL);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "expshare", "[NONE | EQUAL]"));
|
sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "expshare", "[NONE | EQUAL]"));
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "expshare", "<NONE | EQUAL>"));
|
sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "expshare", "<NONE | EQUAL>"));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -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,12 +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.party.ShareHandler;
|
import com.gmail.nossr50.party.ShareHandler;
|
||||||
import com.gmail.nossr50.util.Users;
|
import com.gmail.nossr50.util.player.UserManager;
|
||||||
|
|
||||||
public class PartyInfoCommand implements CommandExecutor {
|
public class PartyInfoCommand implements CommandExecutor {
|
||||||
private Player player;
|
private Player player;
|
||||||
@ -22,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();
|
@ -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;
|
||||||
@ -24,31 +24,32 @@ public class PartyJoinCommand 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 2:
|
case 2:
|
||||||
case 3:
|
// Fallthrough
|
||||||
// Verify target exists and is in a different party than the player
|
case 3:
|
||||||
if (!canJoinParty(sender, args[1])) {
|
// Verify target exists and is in a different party than the player
|
||||||
|
if (!canJoinParty(sender, args[1])) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
String password = getPassword(args);
|
||||||
|
|
||||||
|
// Make sure party passwords match
|
||||||
|
if (!PartyManager.checkPartyPassword(player, targetParty, password)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Changing parties
|
||||||
|
if (!PartyManager.changeOrJoinParty(mcMMOPlayer, player, playerParty, targetParty.getName())) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
PartyManager.joinParty(player, mcMMOPlayer, targetParty, password);
|
||||||
return true;
|
return true;
|
||||||
}
|
|
||||||
|
|
||||||
String password = getPassword(args);
|
default:
|
||||||
|
sender.sendMessage(LocaleLoader.getString("Commands.Usage.3", "party", "join", "<" + LocaleLoader.getString("Commands.Usage.Player") + ">", "[" + LocaleLoader.getString("Commands.Usage.Password") + "]"));
|
||||||
// Make sure party passwords match
|
|
||||||
if (!PartyManager.checkPartyPassword(player, targetParty, password)) {
|
|
||||||
return true;
|
return true;
|
||||||
}
|
|
||||||
|
|
||||||
// Changing parties
|
|
||||||
if (!PartyManager.changeOrJoinParty(mcMMOPlayer, player, playerParty, targetParty.getName())) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
PartyManager.joinParty(player, mcMMOPlayer, targetParty, password);
|
|
||||||
return true;
|
|
||||||
|
|
||||||
default:
|
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.Usage.3", "party", "join", "<" + LocaleLoader.getString("Commands.Usage.Player") + ">", "[" + LocaleLoader.getString("Commands.Usage.Password") + "]"));
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -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,54 +1,54 @@
|
|||||||
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:
|
||||||
if (args[0].equalsIgnoreCase("lock")) {
|
if (args[0].equalsIgnoreCase("lock")) {
|
||||||
lockParty(sender, command);
|
lockParty(sender, command);
|
||||||
}
|
}
|
||||||
else if (args[0].equalsIgnoreCase("unlock")) {
|
else if (args[0].equalsIgnoreCase("unlock")) {
|
||||||
unlockParty(sender, command);
|
unlockParty(sender, command);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
case 2:
|
case 2:
|
||||||
if (!args[0].equalsIgnoreCase("lock")) {
|
if (!args[0].equalsIgnoreCase("lock")) {
|
||||||
|
sendUsageStrings(sender);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args[1].equalsIgnoreCase("on") || args[1].equalsIgnoreCase("true")) {
|
||||||
|
lockParty(sender, command);
|
||||||
|
}
|
||||||
|
else if (args[1].equalsIgnoreCase("off") || args[1].equalsIgnoreCase("false")) {
|
||||||
|
unlockParty(sender, command);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
sendUsageStrings(sender);
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
|
||||||
|
default:
|
||||||
sendUsageStrings(sender);
|
sendUsageStrings(sender);
|
||||||
return true;
|
return true;
|
||||||
}
|
|
||||||
|
|
||||||
if (args[1].equalsIgnoreCase("on") || args[1].equalsIgnoreCase("true")) {
|
|
||||||
lockParty(sender, command);
|
|
||||||
}
|
|
||||||
else if (args[1].equalsIgnoreCase("off") || args[1].equalsIgnoreCase("false")) {
|
|
||||||
unlockParty(sender, command);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
sendUsageStrings(sender);
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
|
|
||||||
default:
|
|
||||||
sendUsageStrings(sender);
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -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,
|
@ -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,16 +7,16 @@ 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.datatypes.player.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;
|
||||||
@ -28,54 +28,54 @@ public class PtpCommand 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 1:
|
case 1:
|
||||||
player = (Player) sender;
|
player = (Player) sender;
|
||||||
mcMMOPlayer = Users.getPlayer(player);
|
mcMMOPlayer = UserManager.getPlayer(player);
|
||||||
playerProfile = mcMMOPlayer.getProfile();
|
playerProfile = mcMMOPlayer.getProfile();
|
||||||
|
|
||||||
if (args[0].equalsIgnoreCase("toggle")) {
|
if (args[0].equalsIgnoreCase("toggle")) {
|
||||||
if (!Permissions.partyTeleportToggle(sender)) {
|
if (!Permissions.partyTeleportToggle(sender)) {
|
||||||
sender.sendMessage(command.getPermissionMessage());
|
sender.sendMessage(command.getPermissionMessage());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return togglePartyTeleportation();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args[0].equalsIgnoreCase("acceptany") || args[0].equalsIgnoreCase("acceptall")) {
|
||||||
|
if (!Permissions.partyTeleportAcceptAll(sender)) {
|
||||||
|
sender.sendMessage(command.getPermissionMessage());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return acceptAnyTeleportRequest();
|
||||||
|
}
|
||||||
|
|
||||||
|
int ptpCooldown = Config.getInstance().getPTPCommandCooldown();
|
||||||
|
|
||||||
|
if (playerProfile.getRecentlyHurt() + (ptpCooldown * Misc.TIME_CONVERSION_FACTOR) > System.currentTimeMillis()) {
|
||||||
|
player.sendMessage(LocaleLoader.getString("Party.Teleport.Hurt", ptpCooldown));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return togglePartyTeleportation();
|
if (args[0].equalsIgnoreCase("accept")) {
|
||||||
}
|
if (!Permissions.partyTeleportAccept(sender)) {
|
||||||
|
sender.sendMessage(command.getPermissionMessage());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
if (args[0].equalsIgnoreCase("acceptany") || args[0].equalsIgnoreCase("acceptall")) {
|
return acceptTeleportRequest();
|
||||||
if (!Permissions.partyTeleportAcceptAll(sender)) {
|
|
||||||
sender.sendMessage(command.getPermissionMessage());
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return acceptAnyTeleportRequest();
|
return sendTeleportRequest(args[0]);
|
||||||
}
|
|
||||||
|
|
||||||
int ptpCooldown = Config.getInstance().getPTPCommandCooldown();
|
default:
|
||||||
|
return false;
|
||||||
if (playerProfile.getRecentlyHurt() + (ptpCooldown * Misc.TIME_CONVERSION_FACTOR) > System.currentTimeMillis()) {
|
|
||||||
player.sendMessage(LocaleLoader.getString("Party.Teleport.Hurt", ptpCooldown));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (args[0].equalsIgnoreCase("accept")) {
|
|
||||||
if (!Permissions.partyTeleportAccept(sender)) {
|
|
||||||
sender.sendMessage(command.getPermissionMessage());
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return acceptTeleportRequest();
|
|
||||||
}
|
|
||||||
|
|
||||||
return sendTeleportRequest(args[0]);
|
|
||||||
|
|
||||||
default:
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -168,7 +168,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,7 +201,7 @@ 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);
|
@ -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
|
||||||
@ -20,68 +20,68 @@ public class InspectCommand implements CommandExecutor {
|
|||||||
PlayerProfile profile;
|
PlayerProfile profile;
|
||||||
|
|
||||||
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) {
|
||||||
profile = new PlayerProfile(args[0], false); //Temporary Profile
|
profile = new PlayerProfile(args[0], false); // Temporary Profile
|
||||||
|
|
||||||
if (!profile.isLoaded()) {
|
if (!profile.isLoaded()) {
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
|
sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: Why do we care if this is a player?
|
|
||||||
if (sender instanceof Player && !Permissions.inspectOffline(sender)) {
|
|
||||||
sender.sendMessage(LocaleLoader.getString("Inspect.Offline"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
sender.sendMessage(LocaleLoader.getString("Inspect.OfflineStats", args[0]));
|
|
||||||
|
|
||||||
sender.sendMessage(LocaleLoader.getString("Stats.Header.Gathering"));
|
|
||||||
sender.sendMessage(LocaleLoader.getString("Skills.Stats", LocaleLoader.getString("Excavation.Listener"), profile.getSkillLevel(SkillType.EXCAVATION), profile.getSkillXpLevel(SkillType.EXCAVATION), profile.getXpToLevel(SkillType.EXCAVATION)));
|
|
||||||
sender.sendMessage(LocaleLoader.getString("Skills.Stats", LocaleLoader.getString("Fishing.Listener"), profile.getSkillLevel(SkillType.FISHING), profile.getSkillXpLevel(SkillType.FISHING), profile.getXpToLevel(SkillType.FISHING)));
|
|
||||||
sender.sendMessage(LocaleLoader.getString("Skills.Stats", LocaleLoader.getString("Herbalism.Listener"), profile.getSkillLevel(SkillType.HERBALISM), profile.getSkillXpLevel(SkillType.HERBALISM), profile.getXpToLevel(SkillType.HERBALISM)));
|
|
||||||
sender.sendMessage(LocaleLoader.getString("Skills.Stats", LocaleLoader.getString("Mining.Listener"), profile.getSkillLevel(SkillType.MINING), profile.getSkillXpLevel(SkillType.MINING), profile.getXpToLevel(SkillType.MINING)));
|
|
||||||
sender.sendMessage(LocaleLoader.getString("Skills.Stats", LocaleLoader.getString("Woodcutting.Listener"), profile.getSkillLevel(SkillType.WOODCUTTING), profile.getSkillXpLevel(SkillType.WOODCUTTING), profile.getXpToLevel(SkillType.WOODCUTTING)));
|
|
||||||
|
|
||||||
sender.sendMessage(LocaleLoader.getString("Stats.Header.Combat"));
|
|
||||||
sender.sendMessage(LocaleLoader.getString("Skills.Stats", LocaleLoader.getString("Axes.Listener"), profile.getSkillLevel(SkillType.AXES), profile.getSkillXpLevel(SkillType.AXES), profile.getXpToLevel(SkillType.AXES)));
|
|
||||||
sender.sendMessage(LocaleLoader.getString("Skills.Stats", LocaleLoader.getString("Archery.Listener"), profile.getSkillLevel(SkillType.ARCHERY), profile.getSkillXpLevel(SkillType.ARCHERY), profile.getXpToLevel(SkillType.ARCHERY)));
|
|
||||||
sender.sendMessage(LocaleLoader.getString("Skills.Stats", LocaleLoader.getString("Swords.Listener"), profile.getSkillLevel(SkillType.SWORDS), profile.getSkillXpLevel(SkillType.SWORDS), profile.getXpToLevel(SkillType.SWORDS)));
|
|
||||||
sender.sendMessage(LocaleLoader.getString("Skills.Stats", LocaleLoader.getString("Taming.Listener"), profile.getSkillLevel(SkillType.TAMING), profile.getSkillXpLevel(SkillType.TAMING), profile.getXpToLevel(SkillType.TAMING)));
|
|
||||||
sender.sendMessage(LocaleLoader.getString("Skills.Stats", LocaleLoader.getString("Unarmed.Listener"), profile.getSkillLevel(SkillType.UNARMED), profile.getSkillXpLevel(SkillType.UNARMED), profile.getXpToLevel(SkillType.UNARMED)));
|
|
||||||
|
|
||||||
sender.sendMessage(LocaleLoader.getString("Stats.Header.Misc"));
|
|
||||||
sender.sendMessage(LocaleLoader.getString("Skills.Stats", LocaleLoader.getString("Acrobatics.Listener"), profile.getSkillLevel(SkillType.ACROBATICS), profile.getSkillXpLevel(SkillType.ACROBATICS), profile.getXpToLevel(SkillType.ACROBATICS)));
|
|
||||||
sender.sendMessage(LocaleLoader.getString("Skills.Stats", LocaleLoader.getString("Repair.Listener"), profile.getSkillLevel(SkillType.REPAIR), profile.getSkillXpLevel(SkillType.REPAIR), profile.getXpToLevel(SkillType.REPAIR)));
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
Player target = mcMMOPlayer.getPlayer();
|
|
||||||
|
|
||||||
if (sender instanceof Player) {
|
|
||||||
Player inspector = (Player) sender;
|
|
||||||
|
|
||||||
if (!Misc.isNear(inspector.getLocation(), target.getLocation(), 5.0) && !Permissions.inspectFar(inspector)) {
|
|
||||||
sender.sendMessage(LocaleLoader.getString("Inspect.TooFar"));
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Why do we care if this is a player?
|
||||||
|
if (sender instanceof Player && !Permissions.inspectOffline(sender)) {
|
||||||
|
sender.sendMessage(LocaleLoader.getString("Inspect.Offline"));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
sender.sendMessage(LocaleLoader.getString("Inspect.OfflineStats", args[0]));
|
||||||
|
|
||||||
|
sender.sendMessage(LocaleLoader.getString("Stats.Header.Gathering"));
|
||||||
|
sender.sendMessage(LocaleLoader.getString("Skills.Stats", LocaleLoader.getString("Excavation.Listener"), profile.getSkillLevel(SkillType.EXCAVATION), profile.getSkillXpLevel(SkillType.EXCAVATION), profile.getXpToLevel(SkillType.EXCAVATION)));
|
||||||
|
sender.sendMessage(LocaleLoader.getString("Skills.Stats", LocaleLoader.getString("Fishing.Listener"), profile.getSkillLevel(SkillType.FISHING), profile.getSkillXpLevel(SkillType.FISHING), profile.getXpToLevel(SkillType.FISHING)));
|
||||||
|
sender.sendMessage(LocaleLoader.getString("Skills.Stats", LocaleLoader.getString("Herbalism.Listener"), profile.getSkillLevel(SkillType.HERBALISM), profile.getSkillXpLevel(SkillType.HERBALISM), profile.getXpToLevel(SkillType.HERBALISM)));
|
||||||
|
sender.sendMessage(LocaleLoader.getString("Skills.Stats", LocaleLoader.getString("Mining.Listener"), profile.getSkillLevel(SkillType.MINING), profile.getSkillXpLevel(SkillType.MINING), profile.getXpToLevel(SkillType.MINING)));
|
||||||
|
sender.sendMessage(LocaleLoader.getString("Skills.Stats", LocaleLoader.getString("Woodcutting.Listener"), profile.getSkillLevel(SkillType.WOODCUTTING), profile.getSkillXpLevel(SkillType.WOODCUTTING), profile.getXpToLevel(SkillType.WOODCUTTING)));
|
||||||
|
|
||||||
|
sender.sendMessage(LocaleLoader.getString("Stats.Header.Combat"));
|
||||||
|
sender.sendMessage(LocaleLoader.getString("Skills.Stats", LocaleLoader.getString("Axes.Listener"), profile.getSkillLevel(SkillType.AXES), profile.getSkillXpLevel(SkillType.AXES), profile.getXpToLevel(SkillType.AXES)));
|
||||||
|
sender.sendMessage(LocaleLoader.getString("Skills.Stats", LocaleLoader.getString("Archery.Listener"), profile.getSkillLevel(SkillType.ARCHERY), profile.getSkillXpLevel(SkillType.ARCHERY), profile.getXpToLevel(SkillType.ARCHERY)));
|
||||||
|
sender.sendMessage(LocaleLoader.getString("Skills.Stats", LocaleLoader.getString("Swords.Listener"), profile.getSkillLevel(SkillType.SWORDS), profile.getSkillXpLevel(SkillType.SWORDS), profile.getXpToLevel(SkillType.SWORDS)));
|
||||||
|
sender.sendMessage(LocaleLoader.getString("Skills.Stats", LocaleLoader.getString("Taming.Listener"), profile.getSkillLevel(SkillType.TAMING), profile.getSkillXpLevel(SkillType.TAMING), profile.getXpToLevel(SkillType.TAMING)));
|
||||||
|
sender.sendMessage(LocaleLoader.getString("Skills.Stats", LocaleLoader.getString("Unarmed.Listener"), profile.getSkillLevel(SkillType.UNARMED), profile.getSkillXpLevel(SkillType.UNARMED), profile.getXpToLevel(SkillType.UNARMED)));
|
||||||
|
|
||||||
|
sender.sendMessage(LocaleLoader.getString("Stats.Header.Misc"));
|
||||||
|
sender.sendMessage(LocaleLoader.getString("Skills.Stats", LocaleLoader.getString("Acrobatics.Listener"), profile.getSkillLevel(SkillType.ACROBATICS), profile.getSkillXpLevel(SkillType.ACROBATICS), profile.getXpToLevel(SkillType.ACROBATICS)));
|
||||||
|
sender.sendMessage(LocaleLoader.getString("Skills.Stats", LocaleLoader.getString("Repair.Listener"), profile.getSkillLevel(SkillType.REPAIR), profile.getSkillXpLevel(SkillType.REPAIR), profile.getXpToLevel(SkillType.REPAIR)));
|
||||||
}
|
}
|
||||||
profile = mcMMOPlayer.getProfile();
|
else {
|
||||||
|
Player target = mcMMOPlayer.getPlayer();
|
||||||
|
|
||||||
sender.sendMessage(LocaleLoader.getString("Inspect.Stats", target.getName()));
|
if (sender instanceof Player) {
|
||||||
CommandHelper.printGatheringSkills(target, profile, sender);
|
Player inspector = (Player) sender;
|
||||||
CommandHelper.printCombatSkills(target, profile, sender);
|
|
||||||
CommandHelper.printMiscSkills(target, profile, sender);
|
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.PowerLevel", mcMMOPlayer.getPowerLevel()));
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
if (!Misc.isNear(inspector.getLocation(), target.getLocation(), 5.0) && !Permissions.inspectFar(inspector)) {
|
||||||
|
sender.sendMessage(LocaleLoader.getString("Inspect.TooFar"));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
profile = mcMMOPlayer.getProfile();
|
||||||
|
|
||||||
default:
|
sender.sendMessage(LocaleLoader.getString("Inspect.Stats", target.getName()));
|
||||||
return false;
|
CommandUtils.printGatheringSkills(target, profile, sender);
|
||||||
|
CommandUtils.printCombatSkills(target, profile, sender);
|
||||||
|
CommandUtils.printMiscSkills(target, profile, sender);
|
||||||
|
sender.sendMessage(LocaleLoader.getString("Commands.PowerLevel", mcMMOPlayer.getPowerLevel()));
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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,83 +8,83 @@ 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
|
||||||
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.mcrank(sender)) {
|
if (!Permissions.mcrank(sender)) {
|
||||||
sender.sendMessage(command.getPermissionMessage());
|
sender.sendMessage(command.getPermissionMessage());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(sender instanceof Player)) {
|
if (!(sender instanceof Player)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Config.getInstance().getUseMySQL()) {
|
||||||
|
sqlDisplay(sender, sender.getName());
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
LeaderboardManager.updateLeaderboards(); // Make sure the information is up to date
|
||||||
|
flatfileDisplay(sender, sender.getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
|
||||||
|
case 1:
|
||||||
|
if (!Permissions.mcrankOthers(sender)) {
|
||||||
|
sender.sendMessage(command.getPermissionMessage());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(args[0]);
|
||||||
|
|
||||||
|
if (mcMMOPlayer == null) {
|
||||||
|
PlayerProfile profile = new PlayerProfile(args[0], false); // Temporary Profile
|
||||||
|
|
||||||
|
if (!profile.isLoaded()) {
|
||||||
|
sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sender instanceof Player && !Permissions.mcrankOffline(sender)) {
|
||||||
|
sender.sendMessage(LocaleLoader.getString("Inspect.Offline"));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Player target = mcMMOPlayer.getPlayer();
|
||||||
|
|
||||||
|
if (sender instanceof Player && !Misc.isNear(((Player) sender).getLocation(), target.getLocation(), 5.0) && !Permissions.mcrankFar(sender)) {
|
||||||
|
sender.sendMessage(LocaleLoader.getString("Inspect.TooFar"));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Config.getInstance().getUseMySQL()) {
|
||||||
|
sqlDisplay(sender, args[0]);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
LeaderboardManager.updateLeaderboards(); // Make sure the information is up to date
|
||||||
|
flatfileDisplay(sender, args[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
|
||||||
|
default:
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
|
|
||||||
if (Config.getInstance().getUseMySQL()) {
|
|
||||||
sqlDisplay(sender, sender.getName());
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
Leaderboard.updateLeaderboards(); // Make sure the information is up to date
|
|
||||||
flatfileDisplay(sender, sender.getName());
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
|
|
||||||
case 1:
|
|
||||||
if (!Permissions.mcrankOthers(sender)) {
|
|
||||||
sender.sendMessage(command.getPermissionMessage());
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
McMMOPlayer mcMMOPlayer = Users.getPlayer(args[0]);
|
|
||||||
|
|
||||||
if (mcMMOPlayer == null) {
|
|
||||||
PlayerProfile profile = new PlayerProfile(args[0], false); //Temporary Profile
|
|
||||||
|
|
||||||
if (!profile.isLoaded()) {
|
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (sender instanceof Player && !Permissions.mcrankOffline(sender)) {
|
|
||||||
sender.sendMessage(LocaleLoader.getString("Inspect.Offline"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
Player target = mcMMOPlayer.getPlayer();
|
|
||||||
|
|
||||||
if (sender instanceof Player && !Misc.isNear(((Player) sender).getLocation(), target.getLocation(), 5.0) && !Permissions.mcrankFar(sender)) {
|
|
||||||
sender.sendMessage(LocaleLoader.getString("Inspect.TooFar"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Config.getInstance().getUseMySQL()) {
|
|
||||||
sqlDisplay(sender, args[0]);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
Leaderboard.updateLeaderboards(); // Make sure the information is up to date
|
|
||||||
flatfileDisplay(sender, args[0]);
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
|
|
||||||
default:
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -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,46 +5,46 @@ 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();
|
||||||
|
|
||||||
if (powerLevelCap != Integer.MAX_VALUE) {
|
if (powerLevelCap != Integer.MAX_VALUE) {
|
||||||
player.sendMessage(LocaleLoader.getString("Commands.PowerLevel.Capped", mcMMOPlayer.getPowerLevel(), powerLevelCap));
|
player.sendMessage(LocaleLoader.getString("Commands.PowerLevel.Capped", mcMMOPlayer.getPowerLevel(), powerLevelCap));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
player.sendMessage(LocaleLoader.getString("Commands.PowerLevel", mcMMOPlayer.getPowerLevel()));
|
player.sendMessage(LocaleLoader.getString("Commands.PowerLevel", mcMMOPlayer.getPowerLevel()));
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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
|
||||||
@ -22,39 +22,39 @@ public class MctopCommand implements CommandExecutor {
|
|||||||
boolean useMySQL = Config.getInstance().getUseMySQL();
|
boolean useMySQL = Config.getInstance().getUseMySQL();
|
||||||
|
|
||||||
switch (args.length) {
|
switch (args.length) {
|
||||||
case 0:
|
case 0:
|
||||||
display(1, "ALL", sender, useMySQL, command);
|
display(1, "ALL", sender, useMySQL, command);
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
case 1:
|
case 1:
|
||||||
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);
|
display(1, SkillType.getSkill(args[0]).toString(), sender, useMySQL, command);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
|
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
case 2:
|
case 2:
|
||||||
if (!StringUtils.isInt(args[1])) {
|
if (!StringUtils.isInt(args[1])) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (SkillUtils.isSkill(args[0])) {
|
||||||
|
display(Integer.parseInt(args[1]), SkillType.getSkill(args[0]).toString(), sender, useMySQL, command);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
|
||||||
|
default:
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
|
|
||||||
if (SkillTools.isSkill(args[0])) {
|
|
||||||
display(Integer.parseInt(args[1]), SkillType.getSkill(args[0]).toString(), sender, useMySQL, command);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
|
|
||||||
default:
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -78,9 +78,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 +110,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 {
|
||||||
@ -23,17 +23,17 @@ public class AcrobaticsCommand extends SkillCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void dataCalculations() {
|
protected void dataCalculations() {
|
||||||
//DODGE
|
// DODGE
|
||||||
String[] dodgeStrings = calculateAbilityDisplayValues(Acrobatics.dodgeMaxBonusLevel, Acrobatics.dodgeMaxChance);
|
String[] dodgeStrings = calculateAbilityDisplayValues(Acrobatics.dodgeMaxBonusLevel, Acrobatics.dodgeMaxChance);
|
||||||
dodgeChance = dodgeStrings[0];
|
dodgeChance = dodgeStrings[0];
|
||||||
dodgeChanceLucky = dodgeStrings[1];
|
dodgeChanceLucky = dodgeStrings[1];
|
||||||
|
|
||||||
//ROLL
|
// ROLL
|
||||||
String[] rollStrings = calculateAbilityDisplayValues(Acrobatics.rollMaxBonusLevel, Acrobatics.rollMaxChance);
|
String[] rollStrings = calculateAbilityDisplayValues(Acrobatics.rollMaxBonusLevel, Acrobatics.rollMaxChance);
|
||||||
rollChance = rollStrings[0];
|
rollChance = rollStrings[0];
|
||||||
rollChanceLucky = rollStrings[1];
|
rollChanceLucky = rollStrings[1];
|
||||||
|
|
||||||
//GRACEFUL ROLL
|
// GRACEFUL ROLL
|
||||||
String[] gracefulRollStrings = calculateAbilityDisplayValues(Acrobatics.gracefulRollMaxBonusLevel, Acrobatics.gracefulRollMaxChance);
|
String[] gracefulRollStrings = calculateAbilityDisplayValues(Acrobatics.gracefulRollMaxBonusLevel, Acrobatics.gracefulRollMaxChance);
|
||||||
gracefulRollChance = gracefulRollStrings[0];
|
gracefulRollChance = gracefulRollStrings[0];
|
||||||
gracefulRollChanceLucky = gracefulRollStrings[1];
|
gracefulRollChanceLucky = gracefulRollStrings[1];
|
@ -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 {
|
||||||
@ -22,7 +22,7 @@ public class ArcheryCommand extends SkillCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void dataCalculations() {
|
protected void dataCalculations() {
|
||||||
//SKILL SHOT
|
// SKILL SHOT
|
||||||
double bonus = (skillValue / Archery.skillShotIncreaseLevel) * Archery.skillShotIncreasePercentage;
|
double bonus = (skillValue / Archery.skillShotIncreaseLevel) * Archery.skillShotIncreasePercentage;
|
||||||
|
|
||||||
if (bonus > Archery.skillShotMaxBonusPercentage) {
|
if (bonus > Archery.skillShotMaxBonusPercentage) {
|
||||||
@ -32,12 +32,12 @@ public class ArcheryCommand extends SkillCommand {
|
|||||||
skillShotBonus = percent.format(bonus);
|
skillShotBonus = percent.format(bonus);
|
||||||
}
|
}
|
||||||
|
|
||||||
//DAZE
|
// DAZE
|
||||||
String[] dazeStrings = calculateAbilityDisplayValues(Archery.dazeMaxBonusLevel, Archery.dazeMaxBonus);
|
String[] dazeStrings = calculateAbilityDisplayValues(Archery.dazeMaxBonusLevel, Archery.dazeMaxBonus);
|
||||||
dazeChance = dazeStrings[0];
|
dazeChance = dazeStrings[0];
|
||||||
dazeChanceLucky = dazeStrings[1];
|
dazeChanceLucky = dazeStrings[1];
|
||||||
|
|
||||||
//RETRIEVE
|
// RETRIEVE
|
||||||
String[] retrieveStrings = calculateAbilityDisplayValues(Archery.retrieveMaxBonusLevel, Archery.retrieveMaxChance);
|
String[] retrieveStrings = calculateAbilityDisplayValues(Archery.retrieveMaxBonusLevel, Archery.retrieveMaxChance);
|
||||||
retrieveChance = retrieveStrings[0];
|
retrieveChance = retrieveStrings[0];
|
||||||
retrieveChanceLucky = retrieveStrings[1];
|
retrieveChanceLucky = retrieveStrings[1];
|
@ -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 {
|
||||||
@ -26,21 +26,21 @@ public class AxesCommand extends SkillCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void dataCalculations() {
|
protected void dataCalculations() {
|
||||||
//IMPACT
|
// IMPACT
|
||||||
impactDamage = String.valueOf(1 + (skillValue / Axes.impactIncreaseLevel));
|
impactDamage = String.valueOf(1 + (skillValue / Axes.impactIncreaseLevel));
|
||||||
greaterImpactDamage = String.valueOf(Axes.greaterImpactBonusDamage);
|
greaterImpactDamage = String.valueOf(Axes.greaterImpactBonusDamage);
|
||||||
|
|
||||||
//SKULL SPLITTER
|
// SKULL SPLITTER
|
||||||
String[] skullSplitterStrings = calculateLengthDisplayValues();
|
String[] skullSplitterStrings = calculateLengthDisplayValues();
|
||||||
skullSplitterLength = skullSplitterStrings[0];
|
skullSplitterLength = skullSplitterStrings[0];
|
||||||
skullSplitterLengthEndurance = skullSplitterStrings[1];
|
skullSplitterLengthEndurance = skullSplitterStrings[1];
|
||||||
|
|
||||||
//CRITICAL STRIKES
|
// CRITICAL STRIKES
|
||||||
String[] criticalStrikeStrings = calculateAbilityDisplayValues(Axes.criticalHitMaxBonusLevel, Axes.criticalHitMaxChance);
|
String[] criticalStrikeStrings = calculateAbilityDisplayValues(Axes.criticalHitMaxBonusLevel, Axes.criticalHitMaxChance);
|
||||||
critChance = criticalStrikeStrings[0];
|
critChance = criticalStrikeStrings[0];
|
||||||
critChanceLucky = criticalStrikeStrings[1];
|
critChanceLucky = criticalStrikeStrings[1];
|
||||||
|
|
||||||
//AXE MASTERY
|
// AXE MASTERY
|
||||||
if (skillValue >= Axes.bonusDamageMaxBonusLevel) {
|
if (skillValue >= Axes.bonusDamageMaxBonusLevel) {
|
||||||
bonusDamage = String.valueOf(Axes.bonusDamageMaxBonus);
|
bonusDamage = String.valueOf(Axes.bonusDamageMaxBonus);
|
||||||
}
|
}
|
@ -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 {
|
||||||
@ -18,7 +17,7 @@ public class ExcavationCommand extends SkillCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void dataCalculations() {
|
protected void dataCalculations() {
|
||||||
//GIGA DRILL BREAKER
|
// GIGA DRILL BREAKER
|
||||||
String gigaDrillStrings[] = calculateLengthDisplayValues();
|
String gigaDrillStrings[] = calculateLengthDisplayValues();
|
||||||
gigaDrillBreakerLength = gigaDrillStrings[0];
|
gigaDrillBreakerLength = gigaDrillStrings[0];
|
||||||
gigaDrillBreakerLengthEndurance = gigaDrillStrings[1];
|
gigaDrillBreakerLengthEndurance = gigaDrillStrings[1];
|
@ -1,10 +1,10 @@
|
|||||||
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.SkillManagerStore;
|
import com.gmail.nossr50.skills.SkillManagerStore;
|
||||||
import com.gmail.nossr50.skills.utilities.SkillType;
|
import com.gmail.nossr50.skills.fishing.Fishing;
|
||||||
import com.gmail.nossr50.util.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
|
|
||||||
public class FishingCommand extends SkillCommand {
|
public class FishingCommand extends SkillCommand {
|
||||||
@ -29,7 +29,7 @@ public class FishingCommand extends SkillCommand {
|
|||||||
protected void dataCalculations() {
|
protected void dataCalculations() {
|
||||||
lootTier = SkillManagerStore.getInstance().getFishingManager(player.getName()).getLootTier();
|
lootTier = SkillManagerStore.getInstance().getFishingManager(player.getName()).getLootTier();
|
||||||
|
|
||||||
//TREASURE HUNTER
|
// TREASURE HUNTER
|
||||||
double enchantChance = lootTier * AdvancedConfig.getInstance().getFishingMagicMultiplier();
|
double enchantChance = lootTier * AdvancedConfig.getInstance().getFishingMagicMultiplier();
|
||||||
|
|
||||||
if (player.getWorld().hasStorm()) {
|
if (player.getWorld().hasStorm()) {
|
||||||
@ -41,12 +41,12 @@ public class FishingCommand extends SkillCommand {
|
|||||||
magicChance = treasureHunterStrings[0];
|
magicChance = treasureHunterStrings[0];
|
||||||
magicChanceLucky = treasureHunterStrings[1];
|
magicChanceLucky = treasureHunterStrings[1];
|
||||||
|
|
||||||
//SHAKE
|
// SHAKE
|
||||||
String[] shakeStrings = calculateAbilityDisplayValues(SkillManagerStore.getInstance().getFishingManager(player.getName()).getShakeProbability());
|
String[] shakeStrings = calculateAbilityDisplayValues(SkillManagerStore.getInstance().getFishingManager(player.getName()).getShakeProbability());
|
||||||
shakeChance = shakeStrings[0];
|
shakeChance = shakeStrings[0];
|
||||||
shakeChanceLucky = shakeStrings[1];
|
shakeChanceLucky = shakeStrings[1];
|
||||||
|
|
||||||
//FISHERMAN'S DIET
|
// FISHERMAN'S DIET
|
||||||
fishermansDietRank = calculateRank(Fishing.fishermansDietMaxLevel, Fishing.fishermansDietRankLevel1);
|
fishermansDietRank = calculateRank(Fishing.fishermansDietMaxLevel, Fishing.fishermansDietRankLevel1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -97,7 +97,7 @@ public class FishingCommand extends SkillCommand {
|
|||||||
|
|
||||||
if (canMagicHunt) {
|
if (canMagicHunt) {
|
||||||
if (isLucky) {
|
if (isLucky) {
|
||||||
player.sendMessage(LocaleLoader.getString("Fishing.Enchant.Chance", magicChance) + chanceRaining + LocaleLoader.getString("Perks.lucky.bonus", magicChanceLucky));
|
player.sendMessage(LocaleLoader.getString("Fishing.Enchant.Chance", magicChance) + chanceRaining + LocaleLoader.getString("Perks.lucky.bonus", magicChanceLucky));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
player.sendMessage(LocaleLoader.getString("Fishing.Enchant.Chance", magicChance) + chanceRaining);
|
player.sendMessage(LocaleLoader.getString("Fishing.Enchant.Chance", magicChance) + chanceRaining);
|
@ -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 {
|
||||||
@ -36,32 +36,32 @@ public class HerbalismCommand extends SkillCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void dataCalculations() {
|
protected void dataCalculations() {
|
||||||
//GREEN TERRA
|
// GREEN TERRA
|
||||||
String[] greenTerraStrings = calculateLengthDisplayValues();
|
String[] greenTerraStrings = calculateLengthDisplayValues();
|
||||||
greenTerraLength = greenTerraStrings[0];
|
greenTerraLength = greenTerraStrings[0];
|
||||||
greenTerraLengthEndurance = greenTerraStrings[1];
|
greenTerraLengthEndurance = greenTerraStrings[1];
|
||||||
|
|
||||||
//FARMERS DIET
|
// FARMERS DIET
|
||||||
farmersDietRank = calculateRank(Herbalism.farmersDietMaxLevel, Herbalism.farmersDietRankLevel1);
|
farmersDietRank = calculateRank(Herbalism.farmersDietMaxLevel, Herbalism.farmersDietRankLevel1);
|
||||||
|
|
||||||
//GREEN THUMB
|
// GREEN THUMB
|
||||||
greenThumbStage = calculateRank(Herbalism.greenThumbStageMaxLevel, Herbalism.greenThumbStageChangeLevel);
|
greenThumbStage = calculateRank(Herbalism.greenThumbStageMaxLevel, Herbalism.greenThumbStageChangeLevel);
|
||||||
|
|
||||||
String[] greenThumbStrings = calculateAbilityDisplayValues(Herbalism.greenThumbMaxLevel, Herbalism.greenThumbMaxChance);
|
String[] greenThumbStrings = calculateAbilityDisplayValues(Herbalism.greenThumbMaxLevel, Herbalism.greenThumbMaxChance);
|
||||||
greenThumbChance = greenThumbStrings[0];
|
greenThumbChance = greenThumbStrings[0];
|
||||||
greenThumbChanceLucky = greenThumbStrings[1];
|
greenThumbChanceLucky = greenThumbStrings[1];
|
||||||
|
|
||||||
//DOUBLE DROPS
|
// DOUBLE DROPS
|
||||||
String[] doubleDropStrings = calculateAbilityDisplayValues(Herbalism.doubleDropsMaxLevel, Herbalism.doubleDropsMaxChance);
|
String[] doubleDropStrings = calculateAbilityDisplayValues(Herbalism.doubleDropsMaxLevel, Herbalism.doubleDropsMaxChance);
|
||||||
doubleDropChance = doubleDropStrings[0];
|
doubleDropChance = doubleDropStrings[0];
|
||||||
doubleDropChanceLucky = doubleDropStrings[1];
|
doubleDropChanceLucky = doubleDropStrings[1];
|
||||||
|
|
||||||
//HYLIAN LUCK
|
// HYLIAN LUCK
|
||||||
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
|
// SHROOM THUMB
|
||||||
String[] shroomThumbStrings = calculateAbilityDisplayValues(Herbalism.shroomThumbMaxLevel, Herbalism.shroomThumbMaxChance);
|
String[] shroomThumbStrings = calculateAbilityDisplayValues(Herbalism.shroomThumbMaxLevel, Herbalism.shroomThumbMaxChance);
|
||||||
shroomThumbChance = shroomThumbStrings[0];
|
shroomThumbChance = shroomThumbStrings[0];
|
||||||
shroomThumbChanceLucky = shroomThumbStrings[1];
|
shroomThumbChanceLucky = shroomThumbStrings[1];
|
||||||
@ -71,7 +71,7 @@ public class HerbalismCommand extends SkillCommand {
|
|||||||
protected void permissionsCheck() {
|
protected void permissionsCheck() {
|
||||||
hasHylianLuck = Permissions.hylianLuck(player);
|
hasHylianLuck = Permissions.hylianLuck(player);
|
||||||
canGreenTerra = Permissions.greenTerra(player);
|
canGreenTerra = Permissions.greenTerra(player);
|
||||||
canGreenThumbWheat = Permissions.greenThumbPlant(player, Material.CROPS); //TODO: This isn't really accurate - they could have perms for other crops but not wheat.
|
canGreenThumbWheat = Permissions.greenThumbPlant(player, Material.CROPS); // TODO: This isn't really accurate - they could have perms for other crops but not wheat.
|
||||||
canGreenThumbBlocks = (Permissions.greenThumbBlock(player, Material.DIRT) || Permissions.greenThumbBlock(player, Material.COBBLESTONE) || Permissions.greenThumbBlock(player, Material.COBBLE_WALL) || Permissions.greenThumbBlock(player, Material.SMOOTH_BRICK));
|
canGreenThumbBlocks = (Permissions.greenThumbBlock(player, Material.DIRT) || Permissions.greenThumbBlock(player, Material.COBBLESTONE) || Permissions.greenThumbBlock(player, Material.COBBLE_WALL) || Permissions.greenThumbBlock(player, Material.SMOOTH_BRICK));
|
||||||
canFarmersDiet = Permissions.farmersDiet(player);
|
canFarmersDiet = Permissions.farmersDiet(player);
|
||||||
canDoubleDrop = Permissions.doubleDrops(player, skill);
|
canDoubleDrop = Permissions.doubleDrops(player, skill);
|
@ -1,10 +1,11 @@
|
|||||||
package com.gmail.nossr50.skills.mining;
|
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.SkillManagerStore;
|
import com.gmail.nossr50.skills.SkillManagerStore;
|
||||||
import com.gmail.nossr50.skills.utilities.SkillType;
|
import com.gmail.nossr50.skills.mining.Mining;
|
||||||
|
import com.gmail.nossr50.skills.mining.MiningManager;
|
||||||
import com.gmail.nossr50.util.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
|
|
||||||
public class MiningCommand extends SkillCommand {
|
public class MiningCommand extends SkillCommand {
|
||||||
@ -33,17 +34,17 @@ public class MiningCommand extends SkillCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void dataCalculations() {
|
protected void dataCalculations() {
|
||||||
//SUPER BREAKER
|
// SUPER BREAKER
|
||||||
String[] superBreakerStrings = calculateLengthDisplayValues();
|
String[] superBreakerStrings = calculateLengthDisplayValues();
|
||||||
superBreakerLength = superBreakerStrings[0];
|
superBreakerLength = superBreakerStrings[0];
|
||||||
superBreakerLengthEndurance = superBreakerStrings[1];
|
superBreakerLengthEndurance = superBreakerStrings[1];
|
||||||
|
|
||||||
//DOUBLE DROPS
|
// DOUBLE DROPS
|
||||||
String[] doubleDropStrings = calculateAbilityDisplayValues(Mining.doubleDropsMaxLevel, Mining.doubleDropsMaxChance);
|
String[] doubleDropStrings = calculateAbilityDisplayValues(Mining.doubleDropsMaxLevel, Mining.doubleDropsMaxChance);
|
||||||
doubleDropChance = doubleDropStrings[0];
|
doubleDropChance = doubleDropStrings[0];
|
||||||
doubleDropChanceLucky = doubleDropStrings[1];
|
doubleDropChanceLucky = doubleDropStrings[1];
|
||||||
|
|
||||||
//BLAST MINING
|
// BLAST MINING
|
||||||
MiningManager miningManager = SkillManagerStore.getInstance().getMiningManager(player.getName());
|
MiningManager miningManager = SkillManagerStore.getInstance().getMiningManager(player.getName());
|
||||||
blastMiningRank = miningManager.getBlastMiningTier();
|
blastMiningRank = miningManager.getBlastMiningTier();
|
||||||
bonusTNTDrops = miningManager.getDropMultiplier();
|
bonusTNTDrops = miningManager.getDropMultiplier();
|
@ -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 {
|
||||||
@ -44,26 +46,26 @@ public class RepairCommand extends SkillCommand {
|
|||||||
Repairable ironRepairable = mcMMO.repairManager.getRepairable(Material.IRON_PICKAXE.getId());
|
Repairable ironRepairable = mcMMO.repairManager.getRepairable(Material.IRON_PICKAXE.getId());
|
||||||
Repairable stoneRepairable = mcMMO.repairManager.getRepairable(Material.STONE_PICKAXE.getId());
|
Repairable stoneRepairable = mcMMO.repairManager.getRepairable(Material.STONE_PICKAXE.getId());
|
||||||
|
|
||||||
//TODO: This isn't really accurate - if they don't have pickaxes loaded it doesn't always mean the repair level is 0
|
// TODO: This isn't really accurate - if they don't have pickaxes loaded it doesn't always mean the repair level is 0
|
||||||
diamondLevel = (diamondRepairable == null) ? 0 : diamondRepairable.getMinimumLevel();
|
diamondLevel = (diamondRepairable == null) ? 0 : diamondRepairable.getMinimumLevel();
|
||||||
goldLevel = (goldRepairable == null) ? 0 : goldRepairable.getMinimumLevel();
|
goldLevel = (goldRepairable == null) ? 0 : goldRepairable.getMinimumLevel();
|
||||||
ironLevel = (ironRepairable == null) ? 0 : ironRepairable.getMinimumLevel();
|
ironLevel = (ironRepairable == null) ? 0 : ironRepairable.getMinimumLevel();
|
||||||
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];
|
||||||
|
|
||||||
//ARCANE FORGING
|
// ARCANE FORGING
|
||||||
arcaneForgingRank = Repair.getArcaneForgingRank(profile);
|
arcaneForgingRank = Repair.getArcaneForgingRank(profile);
|
||||||
}
|
}
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
package com.gmail.nossr50.skills;
|
package com.gmail.nossr50.commands.skills;
|
||||||
|
|
||||||
import java.text.DecimalFormat;
|
import java.text.DecimalFormat;
|
||||||
|
|
||||||
@ -7,16 +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.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;
|
||||||
@ -38,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"));
|
||||||
@ -76,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) {
|
||||||
@ -141,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,10 +1,10 @@
|
|||||||
package com.gmail.nossr50.skills.smelting;
|
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.SkillManagerStore;
|
import com.gmail.nossr50.skills.SkillManagerStore;
|
||||||
import com.gmail.nossr50.skills.utilities.SkillType;
|
import com.gmail.nossr50.skills.smelting.Smelting;
|
||||||
import com.gmail.nossr50.util.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
|
|
||||||
public class SmeltingCommand extends SkillCommand {
|
public class SmeltingCommand extends SkillCommand {
|
||||||
@ -13,6 +13,7 @@ public class SmeltingCommand extends SkillCommand {
|
|||||||
private String secondSmeltChanceLucky;
|
private String secondSmeltChanceLucky;
|
||||||
private String fluxMiningChance;
|
private String fluxMiningChance;
|
||||||
private String fluxMiningChanceLucky;
|
private String fluxMiningChanceLucky;
|
||||||
|
|
||||||
private int vanillaXPModifier;
|
private int vanillaXPModifier;
|
||||||
|
|
||||||
private boolean canFuelEfficiency;
|
private boolean canFuelEfficiency;
|
||||||
@ -26,20 +27,20 @@ public class SmeltingCommand extends SkillCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void dataCalculations() {
|
protected void dataCalculations() {
|
||||||
//FUEL EFFICIENCY
|
// FUEL EFFICIENCY
|
||||||
burnTimeModifier = decimal.format(1 + ((skillValue / Smelting.burnModifierMaxLevel) * Smelting.burnTimeMultiplier));
|
burnTimeModifier = decimal.format(1 + ((skillValue / Smelting.burnModifierMaxLevel) * Smelting.burnTimeMultiplier));
|
||||||
|
|
||||||
//SECOND SMELT
|
// SECOND SMELT
|
||||||
String[] secondSmeltStrings = calculateAbilityDisplayValues(Smelting.secondSmeltMaxLevel, Smelting.secondSmeltMaxChance);
|
String[] secondSmeltStrings = calculateAbilityDisplayValues(Smelting.secondSmeltMaxLevel, Smelting.secondSmeltMaxChance);
|
||||||
secondSmeltChance = secondSmeltStrings[0];
|
secondSmeltChance = secondSmeltStrings[0];
|
||||||
secondSmeltChanceLucky = secondSmeltStrings[1];
|
secondSmeltChanceLucky = secondSmeltStrings[1];
|
||||||
|
|
||||||
//FLUX MINING
|
// FLUX MINING
|
||||||
String[] fluxMiningStrings = calculateAbilityDisplayValues(Smelting.fluxMiningChance);
|
String[] fluxMiningStrings = calculateAbilityDisplayValues(Smelting.fluxMiningChance);
|
||||||
fluxMiningChance = fluxMiningStrings[0];
|
fluxMiningChance = fluxMiningStrings[0];
|
||||||
fluxMiningChanceLucky = fluxMiningStrings[1];
|
fluxMiningChanceLucky = fluxMiningStrings[1];
|
||||||
|
|
||||||
//VANILLA XP BOOST
|
// VANILLA XP BOOST
|
||||||
vanillaXPModifier = SkillManagerStore.getInstance().getSmeltingManager(player.getName()).getVanillaXpMultiplier();
|
vanillaXPModifier = SkillManagerStore.getInstance().getSmeltingManager(player.getName()).getVanillaXpMultiplier();
|
||||||
}
|
}
|
||||||
|
|
@ -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 {
|
||||||
@ -24,12 +24,12 @@ public class SwordsCommand extends SkillCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void dataCalculations() {
|
protected void dataCalculations() {
|
||||||
//SERRATED STRIKES
|
// SERRATED STRIKES
|
||||||
String[] serratedStrikesStrings = calculateLengthDisplayValues();
|
String[] serratedStrikesStrings = calculateLengthDisplayValues();
|
||||||
serratedStrikesLength = serratedStrikesStrings[0];
|
serratedStrikesLength = serratedStrikesStrings[0];
|
||||||
serratedStrikesLengthEndurance = serratedStrikesStrings[1];
|
serratedStrikesLengthEndurance = serratedStrikesStrings[1];
|
||||||
|
|
||||||
//BLEED
|
// BLEED
|
||||||
if (skillValue >= Swords.bleedMaxBonusLevel) {
|
if (skillValue >= Swords.bleedMaxBonusLevel) {
|
||||||
bleedLength = String.valueOf(Swords.bleedMaxTicks);
|
bleedLength = String.valueOf(Swords.bleedMaxTicks);
|
||||||
}
|
}
|
||||||
@ -41,7 +41,7 @@ public class SwordsCommand extends SkillCommand {
|
|||||||
bleedChance = bleedStrings[0];
|
bleedChance = bleedStrings[0];
|
||||||
bleedChanceLucky = bleedStrings[1];
|
bleedChanceLucky = bleedStrings[1];
|
||||||
|
|
||||||
//COUNTER ATTACK
|
// COUNTER ATTACK
|
||||||
String[] counterAttackStrings = calculateAbilityDisplayValues(Swords.counterAttackMaxBonusLevel, Swords.counterAttackMaxChance);
|
String[] counterAttackStrings = calculateAbilityDisplayValues(Swords.counterAttackMaxBonusLevel, Swords.counterAttackMaxChance);
|
||||||
counterAttackChance = counterAttackStrings[0];
|
counterAttackChance = counterAttackStrings[0];
|
||||||
counterAttackChanceLucky = counterAttackStrings[1];
|
counterAttackChanceLucky = counterAttackStrings[1];
|
@ -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 {
|
@ -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 {
|
||||||
@ -28,22 +28,22 @@ public class UnarmedCommand extends SkillCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void dataCalculations() {
|
protected void dataCalculations() {
|
||||||
//BERSERK
|
// BERSERK
|
||||||
String[] berserkStrings = calculateLengthDisplayValues();
|
String[] berserkStrings = calculateLengthDisplayValues();
|
||||||
berserkLength = berserkStrings[0];
|
berserkLength = berserkStrings[0];
|
||||||
berserkLengthEndurance = berserkStrings[1];
|
berserkLengthEndurance = berserkStrings[1];
|
||||||
|
|
||||||
//DISARM
|
// DISARM
|
||||||
String[] disarmStrings = calculateAbilityDisplayValues(Unarmed.disarmMaxBonusLevel, Unarmed.disarmMaxChance);
|
String[] disarmStrings = calculateAbilityDisplayValues(Unarmed.disarmMaxBonusLevel, Unarmed.disarmMaxChance);
|
||||||
disarmChance = disarmStrings[0];
|
disarmChance = disarmStrings[0];
|
||||||
disarmChanceLucky = disarmStrings[1];
|
disarmChanceLucky = disarmStrings[1];
|
||||||
|
|
||||||
//DEFLECT
|
// DEFLECT
|
||||||
String[] deflectStrings = calculateAbilityDisplayValues(Unarmed.deflectMaxBonusLevel, Unarmed.deflectMaxChance);
|
String[] deflectStrings = calculateAbilityDisplayValues(Unarmed.deflectMaxBonusLevel, Unarmed.deflectMaxChance);
|
||||||
deflectChance = deflectStrings[0];
|
deflectChance = deflectStrings[0];
|
||||||
deflectChanceLucky = deflectStrings[1];
|
deflectChanceLucky = deflectStrings[1];
|
||||||
|
|
||||||
//IRON ARM
|
// IRON ARM
|
||||||
if (skillValue >= ((Unarmed.ironArmMaxBonusDamage - 3) * Unarmed.ironArmIncreaseLevel)) {
|
if (skillValue >= ((Unarmed.ironArmMaxBonusDamage - 3) * Unarmed.ironArmIncreaseLevel)) {
|
||||||
ironArmBonus = String.valueOf(Unarmed.ironArmMaxBonusDamage);
|
ironArmBonus = String.valueOf(Unarmed.ironArmMaxBonusDamage);
|
||||||
}
|
}
|
||||||
@ -51,7 +51,7 @@ public class UnarmedCommand extends SkillCommand {
|
|||||||
ironArmBonus = String.valueOf(3 + (skillValue / Unarmed.ironArmIncreaseLevel));
|
ironArmBonus = String.valueOf(3 + (skillValue / Unarmed.ironArmIncreaseLevel));
|
||||||
}
|
}
|
||||||
|
|
||||||
//IRON GRIP
|
// IRON GRIP
|
||||||
String[] ironGripStrings = calculateAbilityDisplayValues(Unarmed.ironGripMaxBonusLevel, Unarmed.ironGripMaxChance);
|
String[] ironGripStrings = calculateAbilityDisplayValues(Unarmed.ironGripMaxBonusLevel, Unarmed.ironGripMaxChance);
|
||||||
ironGripChance = ironGripStrings[0];
|
ironGripChance = ironGripStrings[0];
|
||||||
ironGripChanceLucky = ironGripStrings[1];
|
ironGripChanceLucky = ironGripStrings[1];
|
@ -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 {
|
||||||
@ -23,12 +23,12 @@ public class WoodcuttingCommand extends SkillCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void dataCalculations() {
|
protected void dataCalculations() {
|
||||||
//TREE FELLER
|
// TREE FELLER
|
||||||
String[] treeFellerStrings = calculateLengthDisplayValues();
|
String[] treeFellerStrings = calculateLengthDisplayValues();
|
||||||
treeFellerLength = treeFellerStrings[0];
|
treeFellerLength = treeFellerStrings[0];
|
||||||
treeFellerLengthEndurance = treeFellerStrings[1];
|
treeFellerLengthEndurance = treeFellerStrings[1];
|
||||||
|
|
||||||
//DOUBLE DROPS
|
// DOUBLE DROPS
|
||||||
String[] doubleDropStrings = calculateAbilityDisplayValues(Woodcutting.doubleDropsMaxLevel, Woodcutting.doubleDropsMaxChance);
|
String[] doubleDropStrings = calculateAbilityDisplayValues(Woodcutting.doubleDropsMaxLevel, Woodcutting.doubleDropsMaxChance);
|
||||||
doubleDropChance = doubleDropStrings[0];
|
doubleDropChance = doubleDropStrings[0];
|
||||||
doubleDropChanceLucky = doubleDropStrings[1];
|
doubleDropChanceLucky = doubleDropStrings[1];
|
||||||
@ -75,7 +75,7 @@ public class WoodcuttingCommand extends SkillCommand {
|
|||||||
int leafBlowerUnlockLevel = AdvancedConfig.getInstance().getLeafBlowUnlockLevel();
|
int leafBlowerUnlockLevel = AdvancedConfig.getInstance().getLeafBlowUnlockLevel();
|
||||||
|
|
||||||
if (skillValue < leafBlowerUnlockLevel) {
|
if (skillValue < leafBlowerUnlockLevel) {
|
||||||
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Woodcutting.Ability.Locked.0", leafBlowerUnlockLevel)));
|
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Woodcutting.Ability.Locked.0", leafBlowerUnlockLevel)));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template", LocaleLoader.getString("Woodcutting.Ability.0"), LocaleLoader.getString("Woodcutting.Ability.1")));
|
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template", LocaleLoader.getString("Woodcutting.Ability.0"), LocaleLoader.getString("Woodcutting.Ability.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) {
|
||||||
@ -37,17 +37,18 @@ public abstract class SpoutCommand implements CommandExecutor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
switch (args.length) {
|
switch (args.length) {
|
||||||
case 0:
|
case 0:
|
||||||
return noArguments(command, sender, args);
|
return noArguments(command, sender, args);
|
||||||
|
|
||||||
case 1:
|
case 1:
|
||||||
return oneArgument(command, sender, args);
|
return oneArgument(command, sender, args);
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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,7 +32,7 @@ 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;
|
||||||
}
|
}
|
||||||
@ -53,7 +53,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)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -12,7 +12,7 @@ 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;
|
||||||
|
|
||||||
import com.gmail.nossr50.util.metrics.MetricsManager;
|
import com.gmail.nossr50.metrics.MetricsManager;
|
||||||
|
|
||||||
public abstract class AutoUpdateConfigLoader extends ConfigLoader {
|
public abstract class AutoUpdateConfigLoader extends ConfigLoader {
|
||||||
public AutoUpdateConfigLoader(String relativePath, String fileName) {
|
public AutoUpdateConfigLoader(String relativePath, String fileName) {
|
||||||
@ -64,7 +64,7 @@ public abstract class AutoUpdateConfigLoader extends ConfigLoader {
|
|||||||
|
|
||||||
// Rip out Bukkit's attempt to save comments at the top of the file
|
// Rip out Bukkit's attempt to save comments at the top of the file
|
||||||
while (output.indexOf('#') != -1) {
|
while (output.indexOf('#') != -1) {
|
||||||
output = output.substring(output.indexOf('\n', 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
|
// Read the internal config to get comments, then put them in the new one
|
||||||
@ -81,7 +81,7 @@ public abstract class AutoUpdateConfigLoader extends ConfigLoader {
|
|||||||
}
|
}
|
||||||
else if (line.contains(":")) {
|
else if (line.contains(":")) {
|
||||||
line = line.substring(0, line.indexOf(":") + 1);
|
line = line.substring(0, line.indexOf(":") + 1);
|
||||||
if(!temp.isEmpty()) {
|
if (!temp.isEmpty()) {
|
||||||
comments.put(line, temp);
|
comments.put(line, temp);
|
||||||
temp = "";
|
temp = "";
|
||||||
}
|
}
|
||||||
|
@ -6,8 +6,8 @@ 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 AutoUpdateConfigLoader {
|
public class Config extends AutoUpdateConfigLoader {
|
||||||
|
@ -54,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,29 +9,31 @@ 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 CustomBlocksConfig extends ConfigLoader {
|
public class CustomBlockConfig extends ConfigLoader {
|
||||||
private static CustomBlocksConfig instance;
|
private static CustomBlockConfig instance;
|
||||||
public List<ItemStack> customExcavationBlocks = new ArrayList<ItemStack>();
|
|
||||||
public List<ItemStack> customHerbalismBlocks = new ArrayList<ItemStack>();
|
public List<ItemStack> customExcavationBlocks = new ArrayList<ItemStack>();
|
||||||
public List<ItemStack> customMiningBlocks = new ArrayList<ItemStack>();
|
public List<ItemStack> customHerbalismBlocks = new ArrayList<ItemStack>();
|
||||||
|
public List<ItemStack> customMiningBlocks = new ArrayList<ItemStack>();
|
||||||
public List<ItemStack> customWoodcuttingBlocks = new ArrayList<ItemStack>();
|
public List<ItemStack> customWoodcuttingBlocks = new ArrayList<ItemStack>();
|
||||||
public List<ItemStack> customOres = new ArrayList<ItemStack>();
|
public List<ItemStack> customOres = new ArrayList<ItemStack>();
|
||||||
public List<ItemStack> customLogs = new ArrayList<ItemStack>();
|
public List<ItemStack> customLogs = new ArrayList<ItemStack>();
|
||||||
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);
|
||||||
|
|
||||||
@ -105,7 +108,7 @@ public class CustomBlocksConfig extends ConfigLoader {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
customLeaves.add(blockItem);
|
customLeaves.add(blockItem);
|
||||||
block.setXpGain(0); //Leaves don't grant XP
|
block.setXpGain(0); // Leaves don't grant XP
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -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;
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -1,27 +1,25 @@
|
|||||||
package com.gmail.nossr50.config;
|
package com.gmail.nossr50.config.party;
|
||||||
|
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
|
|
||||||
|
import com.gmail.nossr50.config.ConfigLoader;
|
||||||
import com.gmail.nossr50.util.StringUtils;
|
import com.gmail.nossr50.util.StringUtils;
|
||||||
|
|
||||||
public class ItemWeightsConfig extends ConfigLoader {
|
public class ItemWeightConfig extends ConfigLoader {
|
||||||
private static ItemWeightsConfig instance;
|
private static ItemWeightConfig instance;
|
||||||
|
|
||||||
private ItemWeightsConfig() {
|
private ItemWeightConfig() {
|
||||||
super("itemweights.yml");
|
super("itemweights.yml");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ItemWeightsConfig getInstance() {
|
public static ItemWeightConfig getInstance() {
|
||||||
if (instance == null) {
|
if (instance == null) {
|
||||||
instance = new ItemWeightsConfig();
|
instance = new ItemWeightConfig();
|
||||||
}
|
}
|
||||||
|
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void loadKeys() {}
|
|
||||||
|
|
||||||
public int getItemWeight(Material material) {
|
public int getItemWeight(Material material) {
|
||||||
String materialName = StringUtils.getPrettyItemString(material).replace(" ", "_");
|
String materialName = StringUtils.getPrettyItemString(material).replace(" ", "_");
|
||||||
int itemWeight = config.getInt("Item_Weights.Default");
|
int itemWeight = config.getInt("Item_Weights.Default");
|
||||||
@ -31,4 +29,7 @@ public class ItemWeightsConfig extends ConfigLoader {
|
|||||||
}
|
}
|
||||||
return itemWeight;
|
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,35 +12,37 @@ 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> excavationFromGrass = new ArrayList<ExcavationTreasure>();
|
public List<ExcavationTreasure> excavationFromDirt = new ArrayList<ExcavationTreasure>();
|
||||||
public List<ExcavationTreasure> excavationFromSand = new ArrayList<ExcavationTreasure>();
|
public List<ExcavationTreasure> excavationFromGrass = new ArrayList<ExcavationTreasure>();
|
||||||
public List<ExcavationTreasure> excavationFromGravel = new ArrayList<ExcavationTreasure>();
|
public List<ExcavationTreasure> excavationFromSand = new ArrayList<ExcavationTreasure>();
|
||||||
public List<ExcavationTreasure> excavationFromClay = new ArrayList<ExcavationTreasure>();
|
public List<ExcavationTreasure> excavationFromGravel = new ArrayList<ExcavationTreasure>();
|
||||||
public List<ExcavationTreasure> excavationFromMycel = new ArrayList<ExcavationTreasure>();
|
public List<ExcavationTreasure> excavationFromClay = new ArrayList<ExcavationTreasure>();
|
||||||
|
public List<ExcavationTreasure> excavationFromMycel = new ArrayList<ExcavationTreasure>();
|
||||||
public List<ExcavationTreasure> excavationFromSoulSand = new ArrayList<ExcavationTreasure>();
|
public List<ExcavationTreasure> excavationFromSoulSand = new ArrayList<ExcavationTreasure>();
|
||||||
|
|
||||||
public List<HylianTreasure> hylianFromBushes = new ArrayList<HylianTreasure>();
|
public List<HylianTreasure> hylianFromBushes = new ArrayList<HylianTreasure>();
|
||||||
public List<HylianTreasure> hylianFromFlowers = new ArrayList<HylianTreasure>();
|
public List<HylianTreasure> hylianFromFlowers = new ArrayList<HylianTreasure>();
|
||||||
public List<HylianTreasure> hylianFromPots = new ArrayList<HylianTreasure>();
|
public List<HylianTreasure> hylianFromPots = new ArrayList<HylianTreasure>();
|
||||||
|
|
||||||
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;
|
||||||
@ -194,7 +196,7 @@ public class TreasuresConfig extends ConfigLoader {
|
|||||||
if (noErrorsInTreasure(reason) && hTreasure.getDropsFrom() == (byte) 0x0) {
|
if (noErrorsInTreasure(reason) && hTreasure.getDropsFrom() == (byte) 0x0) {
|
||||||
treasures.put(treasureName, eTreasure);
|
treasures.put(treasureName, eTreasure);
|
||||||
}
|
}
|
||||||
else if (noErrorsInTreasure(reason) && eTreasure.getDropsFrom() == (byte) 0x0){
|
else if (noErrorsInTreasure(reason) && eTreasure.getDropsFrom() == (byte) 0x0) {
|
||||||
treasures.put(treasureName, hTreasure);
|
treasures.put(treasureName, hTreasure);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -204,7 +206,7 @@ public class TreasuresConfig extends ConfigLoader {
|
|||||||
List<String> fishingTreasures = config.getStringList("Fishing.Treasure");
|
List<String> fishingTreasures = config.getStringList("Fishing.Treasure");
|
||||||
List<String> hylianTreasures = config.getStringList("Hylian_Luck.Treasure");
|
List<String> hylianTreasures = config.getStringList("Hylian_Luck.Treasure");
|
||||||
|
|
||||||
for (Entry<String,Treasure> nextEntry : treasures.entrySet()) {
|
for (Entry<String, Treasure> nextEntry : treasures.entrySet()) {
|
||||||
String treasureKey = nextEntry.getKey();
|
String treasureKey = nextEntry.getKey();
|
||||||
Treasure treasure = nextEntry.getValue();
|
Treasure treasure = nextEntry.getValue();
|
||||||
|
|
@ -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();
|
||||||
@ -32,7 +32,7 @@ public final class Database {
|
|||||||
private static final double SCALING_FACTOR = 40;
|
private static final double SCALING_FACTOR = 40;
|
||||||
|
|
||||||
// Minimum wait in nanoseconds (default 500ms)
|
// Minimum wait in nanoseconds (default 500ms)
|
||||||
private static final long MIN_WAIT = 500L*1000000L;
|
private static final long MIN_WAIT = 500L * 1000000L;
|
||||||
|
|
||||||
// Maximum time to wait between reconnects (default 5 minutes)
|
// Maximum time to wait between reconnects (default 5 minutes)
|
||||||
private static final long MAX_WAIT = 5L * 60L * 1000L * 1000000L;
|
private static final long MAX_WAIT = 5L * 60L * 1000L * 1000000L;
|
||||||
@ -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,108 +153,10 @@ 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);
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Check database structure for missing values.
|
|
||||||
*
|
|
||||||
* @param update Type of data to check updates for
|
|
||||||
*/
|
|
||||||
private static void checkDatabaseStructure(DatabaseUpdate update) {
|
|
||||||
String sql = null;
|
|
||||||
ResultSet resultSet = null;
|
|
||||||
HashMap<Integer, ArrayList<String>> rows = new HashMap<Integer, ArrayList<String>>();
|
|
||||||
|
|
||||||
switch (update) {
|
|
||||||
case BLAST_MINING:
|
|
||||||
sql = "SELECT * FROM `" + tablePrefix + "cooldowns` ORDER BY `" + tablePrefix + "cooldowns`.`blast_mining` ASC LIMIT 0 , 30";
|
|
||||||
break;
|
|
||||||
|
|
||||||
case CASCADE_DELETE:
|
|
||||||
write("ALTER TABLE `" + tablePrefix + "huds` ADD FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON DELETE CASCADE;");
|
|
||||||
write("ALTER TABLE `" + tablePrefix + "experience` ADD FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON DELETE CASCADE;");
|
|
||||||
write("ALTER TABLE `" + tablePrefix + "cooldowns` ADD FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON DELETE CASCADE;");
|
|
||||||
write("ALTER TABLE `" + tablePrefix + "skills` ADD FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON DELETE CASCADE;");
|
|
||||||
break;
|
|
||||||
|
|
||||||
case FISHING:
|
|
||||||
sql = "SELECT * FROM `" + tablePrefix + "experience` ORDER BY `" + tablePrefix + "experience`.`fishing` ASC LIMIT 0 , 30";
|
|
||||||
break;
|
|
||||||
|
|
||||||
case INDEX:
|
|
||||||
if (read("SHOW INDEX FROM " + tablePrefix + "skills").size() != 13 && checkConnected()) {
|
|
||||||
mcMMO.p.getLogger().info("Indexing tables, this may take a while on larger databases");
|
|
||||||
write("ALTER TABLE `" + tablePrefix + "skills` ADD INDEX `idx_taming` (`taming`) USING BTREE, "
|
|
||||||
+ "ADD INDEX `idx_mining` (`mining`) USING BTREE, "
|
|
||||||
+ "ADD INDEX `idx_woodcutting` (`woodcutting`) USING BTREE, "
|
|
||||||
+ "ADD INDEX `idx_repair` (`repair`) USING BTREE, "
|
|
||||||
+ "ADD INDEX `idx_unarmed` (`unarmed`) USING BTREE, "
|
|
||||||
+ "ADD INDEX `idx_herbalism` (`herbalism`) USING BTREE, "
|
|
||||||
+ "ADD INDEX `idx_excavation` (`excavation`) USING BTREE, "
|
|
||||||
+ "ADD INDEX `idx_archery` (`archery`) USING BTREE, "
|
|
||||||
+ "ADD INDEX `idx_swords` (`swords`) USING BTREE, "
|
|
||||||
+ "ADD INDEX `idx_axes` (`axes`) USING BTREE, "
|
|
||||||
+ "ADD INDEX `idx_acrobatics` (`acrobatics`) USING BTREE, "
|
|
||||||
+ "ADD INDEX `idx_fishing` (`fishing`) USING BTREE;");
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
PreparedStatement statement = null;
|
|
||||||
try {
|
|
||||||
if (!checkConnected()) return;
|
|
||||||
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) {
|
|
||||||
switch (update) {
|
|
||||||
case BLAST_MINING:
|
|
||||||
mcMMO.p.getLogger().info("Updating mcMMO MySQL tables for Blast Mining...");
|
|
||||||
write("ALTER TABLE `"+tablePrefix + "cooldowns` ADD `blast_mining` int(32) NOT NULL DEFAULT '0' ;");
|
|
||||||
break;
|
|
||||||
|
|
||||||
case FISHING:
|
|
||||||
mcMMO.p.getLogger().info("Updating mcMMO MySQL tables for Fishing...");
|
|
||||||
write("ALTER TABLE `"+tablePrefix + "skills` ADD `fishing` int(10) NOT NULL DEFAULT '0' ;");
|
|
||||||
write("ALTER TABLE `"+tablePrefix + "experience` ADD `fishing` int(10) NOT NULL DEFAULT '0' ;");
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
} finally {
|
|
||||||
if (resultSet != null) {
|
|
||||||
try {
|
|
||||||
resultSet.close();
|
|
||||||
} catch (SQLException e) {
|
|
||||||
// Ignore the error, we're leaving
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (statement != null) {
|
|
||||||
try {
|
|
||||||
statement.close();
|
|
||||||
} catch (SQLException e) {
|
|
||||||
// Ignore the error, we're leaving
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -258,29 +166,31 @@ public final class Database {
|
|||||||
* @return true if the query was successfully written, false otherwise.
|
* @return true if the query was successfully written, false otherwise.
|
||||||
*/
|
*/
|
||||||
public static boolean write(String sql) {
|
public static boolean write(String sql) {
|
||||||
if (checkConnected()) {
|
if (!checkConnected()) {
|
||||||
PreparedStatement statement = null;
|
return false;
|
||||||
try {
|
}
|
||||||
statement = connection.prepareStatement(sql);
|
|
||||||
statement.executeUpdate();
|
PreparedStatement statement = null;
|
||||||
return true;
|
try {
|
||||||
}
|
statement = connection.prepareStatement(sql);
|
||||||
catch (SQLException ex) {
|
statement.executeUpdate();
|
||||||
printErrors(ex);
|
return true;
|
||||||
return false;
|
}
|
||||||
} finally {
|
catch (SQLException ex) {
|
||||||
if (statement != null) {
|
printErrors(ex);
|
||||||
try {
|
return false;
|
||||||
statement.close();
|
}
|
||||||
} catch (SQLException e) {
|
finally {
|
||||||
printErrors(e);
|
if (statement != null) {
|
||||||
return false;
|
try {
|
||||||
}
|
statement.close();
|
||||||
|
}
|
||||||
|
catch (SQLException e) {
|
||||||
|
printErrors(e);
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -291,22 +201,23 @@ public final class Database {
|
|||||||
*/
|
*/
|
||||||
public static int update(String sql) {
|
public static int update(String sql) {
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
if (checkConnected()) {
|
if (checkConnected()) {
|
||||||
PreparedStatement statement = null;
|
PreparedStatement statement = null;
|
||||||
try {
|
try {
|
||||||
statement = connection.prepareStatement(sql);
|
statement = connection.prepareStatement(sql);
|
||||||
ret = statement.executeUpdate();
|
ret = statement.executeUpdate();
|
||||||
return ret;
|
}
|
||||||
} catch (SQLException ex) {
|
catch (SQLException ex) {
|
||||||
printErrors(ex);
|
printErrors(ex);
|
||||||
return 0;
|
}
|
||||||
} finally {
|
finally {
|
||||||
if (statement != null) {
|
if (statement != null) {
|
||||||
try {
|
try {
|
||||||
statement.close();
|
statement.close();
|
||||||
} catch (SQLException e) {
|
}
|
||||||
|
catch (SQLException e) {
|
||||||
printErrors(e);
|
printErrors(e);
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -322,12 +233,14 @@ public final class Database {
|
|||||||
* @return the value in the first row / first field
|
* @return the value in the first row / first field
|
||||||
*/
|
*/
|
||||||
public static int getInt(String sql) {
|
public static int getInt(String sql) {
|
||||||
ResultSet resultSet;
|
ResultSet resultSet = null;
|
||||||
int result = 0;
|
int result = 0;
|
||||||
|
|
||||||
if (checkConnected()) {
|
if (checkConnected()) {
|
||||||
|
PreparedStatement statement = null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
PreparedStatement statement = connection.prepareStatement(sql);
|
statement = connection.prepareStatement(sql);
|
||||||
resultSet = statement.executeQuery();
|
resultSet = statement.executeQuery();
|
||||||
|
|
||||||
if (resultSet.next()) {
|
if (resultSet.next()) {
|
||||||
@ -336,12 +249,20 @@ public final class Database {
|
|||||||
else {
|
else {
|
||||||
result = 0;
|
result = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
statement.close();
|
|
||||||
}
|
}
|
||||||
catch (SQLException ex) {
|
catch (SQLException ex) {
|
||||||
printErrors(ex);
|
printErrors(ex);
|
||||||
}
|
}
|
||||||
|
finally {
|
||||||
|
if (statement != null) {
|
||||||
|
try {
|
||||||
|
statement.close();
|
||||||
|
}
|
||||||
|
catch (SQLException e) {
|
||||||
|
printErrors(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
@ -375,7 +296,8 @@ public final class Database {
|
|||||||
if (exists) {
|
if (exists) {
|
||||||
try {
|
try {
|
||||||
isClosed = connection.isClosed();
|
isClosed = connection.isClosed();
|
||||||
} catch (SQLException e) {
|
}
|
||||||
|
catch (SQLException e) {
|
||||||
isClosed = true;
|
isClosed = true;
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
printErrors(e);
|
printErrors(e);
|
||||||
@ -384,9 +306,9 @@ public final class Database {
|
|||||||
if (!isClosed) {
|
if (!isClosed) {
|
||||||
try {
|
try {
|
||||||
isValid = connection.isValid(VALID_TIMEOUT);
|
isValid = connection.isValid(VALID_TIMEOUT);
|
||||||
} catch (SQLException e) {
|
}
|
||||||
// Don't print stack trace because it's valid to lose idle connections
|
catch (SQLException e) {
|
||||||
// to the server and have to restart them.
|
// Don't print stack trace because it's valid to lose idle connections to the server and have to restart them.
|
||||||
isValid = false;
|
isValid = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -404,7 +326,8 @@ public final class Database {
|
|||||||
if (exists && !isClosed) {
|
if (exists && !isClosed) {
|
||||||
try {
|
try {
|
||||||
connection.close();
|
connection.close();
|
||||||
} catch (SQLException ex) {
|
}
|
||||||
|
catch (SQLException ex) {
|
||||||
// This is a housekeeping exercise, ignore errors
|
// This is a housekeeping exercise, ignore errors
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -417,22 +340,21 @@ public final class Database {
|
|||||||
if (connection != null && !connection.isClosed()) {
|
if (connection != null && !connection.isClosed()) {
|
||||||
// Schedule a database save if we really had an outage
|
// Schedule a database save if we really had an outage
|
||||||
if (reconnectAttempt > 1) {
|
if (reconnectAttempt > 1) {
|
||||||
mcMMO.p.getServer().getScheduler().scheduleSyncDelayedTask(mcMMO.p, new SQLReconnect(), 5);
|
mcMMO.p.getServer().getScheduler().scheduleSyncDelayedTask(mcMMO.p, new SQLReconnectTask(), 5);
|
||||||
}
|
}
|
||||||
nextReconnectTimestamp = 0;
|
nextReconnectTimestamp = 0;
|
||||||
reconnectAttempt = 0;
|
reconnectAttempt = 0;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} catch (SQLException e) {
|
}
|
||||||
|
catch (SQLException e) {
|
||||||
// Failed to check isClosed, so presume connection is bad and attempt later
|
// Failed to check isClosed, so presume connection is bad and attempt later
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
printErrors(e);
|
printErrors(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
reconnectAttempt++;
|
reconnectAttempt++;
|
||||||
|
nextReconnectTimestamp = (long)(System.nanoTime() + Math.min(MAX_WAIT, (reconnectAttempt * SCALING_FACTOR * MIN_WAIT)));
|
||||||
nextReconnectTimestamp = (long)(System.nanoTime() + Math.min(MAX_WAIT, (reconnectAttempt*SCALING_FACTOR*MIN_WAIT)));
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -447,8 +369,10 @@ public final class Database {
|
|||||||
HashMap<Integer, ArrayList<String>> rows = new HashMap<Integer, ArrayList<String>>();
|
HashMap<Integer, ArrayList<String>> rows = new HashMap<Integer, ArrayList<String>>();
|
||||||
|
|
||||||
if (checkConnected()) {
|
if (checkConnected()) {
|
||||||
|
PreparedStatement statement = null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
PreparedStatement statement = connection.prepareStatement(sql);
|
statement = connection.prepareStatement(sql);
|
||||||
resultSet = statement.executeQuery();
|
resultSet = statement.executeQuery();
|
||||||
|
|
||||||
while (resultSet.next()) {
|
while (resultSet.next()) {
|
||||||
@ -460,12 +384,20 @@ public final class Database {
|
|||||||
|
|
||||||
rows.put(resultSet.getRow(), column);
|
rows.put(resultSet.getRow(), column);
|
||||||
}
|
}
|
||||||
|
|
||||||
statement.close();
|
|
||||||
}
|
}
|
||||||
catch (SQLException ex) {
|
catch (SQLException ex) {
|
||||||
printErrors(ex);
|
printErrors(ex);
|
||||||
}
|
}
|
||||||
|
finally {
|
||||||
|
if (statement != null) {
|
||||||
|
try {
|
||||||
|
statement.close();
|
||||||
|
}
|
||||||
|
catch (SQLException e) {
|
||||||
|
printErrors(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return rows;
|
return rows;
|
||||||
@ -477,12 +409,15 @@ public final class Database {
|
|||||||
|
|
||||||
if (checkConnected()) {
|
if (checkConnected()) {
|
||||||
try {
|
try {
|
||||||
for (SkillType skillType: SkillType.values()) {
|
for (SkillType skillType : SkillType.values()) {
|
||||||
if (skillType.isChildSkill()) {
|
if (skillType.isChildSkill()) {
|
||||||
continue;
|
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 + "')";
|
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);
|
PreparedStatement statement = connection.prepareStatement(sql);
|
||||||
resultSet = statement.executeQuery();
|
resultSet = statement.executeQuery();
|
||||||
@ -491,7 +426,9 @@ public final class Database {
|
|||||||
|
|
||||||
int rank = resultSet.getInt("rank");
|
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";
|
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);
|
statement = connection.prepareStatement(sql);
|
||||||
resultSet = statement.executeQuery();
|
resultSet = statement.executeQuery();
|
||||||
@ -506,7 +443,11 @@ public final class Database {
|
|||||||
statement.close();
|
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 + "')";
|
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);
|
PreparedStatement statement = connection.prepareStatement(sql);
|
||||||
resultSet = statement.executeQuery();
|
resultSet = statement.executeQuery();
|
||||||
@ -515,7 +456,12 @@ public final class Database {
|
|||||||
|
|
||||||
int rank = resultSet.getInt("rank");
|
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";
|
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);
|
statement = connection.prepareStatement(sql);
|
||||||
resultSet = statement.executeQuery();
|
resultSet = statement.executeQuery();
|
||||||
@ -539,14 +485,20 @@ public final class Database {
|
|||||||
|
|
||||||
public static void purgePowerlessSQL() {
|
public static void purgePowerlessSQL() {
|
||||||
mcMMO.p.getLogger().info("Purging powerless users...");
|
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");
|
HashMap<Integer, ArrayList<String>> usernames;
|
||||||
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)");
|
|
||||||
|
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;
|
int purgedUsers = 0;
|
||||||
for (int i = 1; i <= usernames.size(); i++) {
|
for (int i = 1; i <= usernames.size(); i++) {
|
||||||
String playerName = usernames.get(i).get(0);
|
String playerName = usernames.get(i).get(0);
|
||||||
|
|
||||||
if (playerName == null || Bukkit.getOfflinePlayer(playerName).isOnline()) {
|
if (playerName == null || mcMMO.p.getServer().getOfflinePlayer(playerName).isOnline()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -560,7 +512,7 @@ public final class Database {
|
|||||||
public static void purgeOldSQL() {
|
public static void purgeOldSQL() {
|
||||||
mcMMO.p.getLogger().info("Purging old users...");
|
mcMMO.p.getLogger().info("Purging old users...");
|
||||||
long currentTime = System.currentTimeMillis();
|
long currentTime = System.currentTimeMillis();
|
||||||
long purgeTime = 2630000000L * Config.getInstance().getOldUsersCutoff();
|
long purgeTime = ONE_MONTH * Config.getInstance().getOldUsersCutoff();
|
||||||
HashMap<Integer, ArrayList<String>> usernames = read("SELECT user FROM " + tablePrefix + "users WHERE ((" + currentTime + " - lastlogin*1000) > " + purgeTime + ")");
|
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)");
|
write("DELETE FROM " + tablePrefix + "users WHERE " + tablePrefix + "users.id IN (SELECT * FROM (SELECT id FROM " + tablePrefix + "users WHERE ((" + currentTime + " - lastlogin*1000) > " + purgeTime + ")) AS p)");
|
||||||
|
|
||||||
@ -579,32 +531,137 @@ public final class Database {
|
|||||||
mcMMO.p.getLogger().info("Purged " + purgedUsers + " users from the database.");
|
mcMMO.p.getLogger().info("Purged " + purgedUsers + " users from the database.");
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void printErrors(SQLException ex) {
|
|
||||||
mcMMO.p.getLogger().severe("SQLException: " + ex.getMessage());
|
|
||||||
mcMMO.p.getLogger().severe("SQLState: " + ex.getSQLState());
|
|
||||||
mcMMO.p.getLogger().severe("VendorError: " + ex.getErrorCode());
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void profileCleanup(String playerName) {
|
public static void profileCleanup(String playerName) {
|
||||||
McMMOPlayer mcmmoPlayer = Users.getPlayer(playerName);
|
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(playerName);
|
||||||
|
|
||||||
if (mcmmoPlayer != null) {
|
if (mcMMOPlayer != null) {
|
||||||
Player player = mcmmoPlayer.getPlayer();
|
Player player = mcMMOPlayer.getPlayer();
|
||||||
SpoutHud spoutHud = mcmmoPlayer.getProfile().getSpoutHud();
|
McMMOHud spoutHud = mcMMOPlayer.getProfile().getSpoutHud();
|
||||||
|
|
||||||
if (spoutHud != null) {
|
if (spoutHud != null) {
|
||||||
spoutHud.removeWidgets();
|
spoutHud.removeWidgets();
|
||||||
}
|
}
|
||||||
|
|
||||||
Users.remove(playerName);
|
UserManager.remove(playerName);
|
||||||
|
|
||||||
if (player.isOnline()) {
|
if (player.isOnline()) {
|
||||||
Users.addUser(player);
|
UserManager.addUser(player);
|
||||||
|
|
||||||
if (mcMMO.spoutEnabled) {
|
if (mcMMO.spoutEnabled) {
|
||||||
SpoutTools.reloadSpoutPlayer(player);
|
SpoutUtils.reloadSpoutPlayer(player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check database structure for missing values.
|
||||||
|
*
|
||||||
|
* @param update Type of data to check updates for
|
||||||
|
*/
|
||||||
|
private static void checkDatabaseStructure(DatabaseUpdateType update) {
|
||||||
|
String sql = null;
|
||||||
|
ResultSet resultSet = null;
|
||||||
|
HashMap<Integer, ArrayList<String>> rows = new HashMap<Integer, ArrayList<String>>();
|
||||||
|
|
||||||
|
switch (update) {
|
||||||
|
case BLAST_MINING:
|
||||||
|
sql = "SELECT * FROM `" + tablePrefix + "cooldowns` ORDER BY `" + tablePrefix + "cooldowns`.`blast_mining` ASC LIMIT 0 , 30";
|
||||||
|
break;
|
||||||
|
|
||||||
|
case CASCADE_DELETE:
|
||||||
|
write("ALTER TABLE `" + tablePrefix + "huds` ADD FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON DELETE CASCADE;");
|
||||||
|
write("ALTER TABLE `" + tablePrefix + "experience` ADD FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON DELETE CASCADE;");
|
||||||
|
write("ALTER TABLE `" + tablePrefix + "cooldowns` ADD FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON DELETE CASCADE;");
|
||||||
|
write("ALTER TABLE `" + tablePrefix + "skills` ADD FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON DELETE CASCADE;");
|
||||||
|
break;
|
||||||
|
|
||||||
|
case FISHING:
|
||||||
|
sql = "SELECT * FROM `" + tablePrefix + "experience` ORDER BY `" + tablePrefix + "experience`.`fishing` ASC LIMIT 0 , 30";
|
||||||
|
break;
|
||||||
|
|
||||||
|
case INDEX:
|
||||||
|
if (read("SHOW INDEX FROM " + tablePrefix + "skills").size() != 13 && checkConnected()) {
|
||||||
|
mcMMO.p.getLogger().info("Indexing tables, this may take a while on larger databases");
|
||||||
|
write("ALTER TABLE `" + tablePrefix + "skills` ADD INDEX `idx_taming` (`taming`) USING BTREE, "
|
||||||
|
+ "ADD INDEX `idx_mining` (`mining`) USING BTREE, "
|
||||||
|
+ "ADD INDEX `idx_woodcutting` (`woodcutting`) USING BTREE, "
|
||||||
|
+ "ADD INDEX `idx_repair` (`repair`) USING BTREE, "
|
||||||
|
+ "ADD INDEX `idx_unarmed` (`unarmed`) USING BTREE, "
|
||||||
|
+ "ADD INDEX `idx_herbalism` (`herbalism`) USING BTREE, "
|
||||||
|
+ "ADD INDEX `idx_excavation` (`excavation`) USING BTREE, "
|
||||||
|
+ "ADD INDEX `idx_archery` (`archery`) USING BTREE, "
|
||||||
|
+ "ADD INDEX `idx_swords` (`swords`) USING BTREE, "
|
||||||
|
+ "ADD INDEX `idx_axes` (`axes`) USING BTREE, "
|
||||||
|
+ "ADD INDEX `idx_acrobatics` (`acrobatics`) USING BTREE, "
|
||||||
|
+ "ADD INDEX `idx_fishing` (`fishing`) USING BTREE;");
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
PreparedStatement statement = null;
|
||||||
|
try {
|
||||||
|
if (!checkConnected()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
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) {
|
||||||
|
switch (update) {
|
||||||
|
case BLAST_MINING:
|
||||||
|
mcMMO.p.getLogger().info("Updating mcMMO MySQL tables for Blast Mining...");
|
||||||
|
write("ALTER TABLE `"+tablePrefix + "cooldowns` ADD `blast_mining` int(32) NOT NULL DEFAULT '0' ;");
|
||||||
|
break;
|
||||||
|
|
||||||
|
case FISHING:
|
||||||
|
mcMMO.p.getLogger().info("Updating mcMMO MySQL tables for Fishing...");
|
||||||
|
write("ALTER TABLE `"+tablePrefix + "skills` ADD `fishing` int(10) NOT NULL DEFAULT '0' ;");
|
||||||
|
write("ALTER TABLE `"+tablePrefix + "experience` ADD `fishing` int(10) NOT NULL DEFAULT '0' ;");
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
if (resultSet != null) {
|
||||||
|
try {
|
||||||
|
resultSet.close();
|
||||||
|
}
|
||||||
|
catch (SQLException e) {
|
||||||
|
// Ignore the error, we're leaving
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (statement != null) {
|
||||||
|
try {
|
||||||
|
statement.close();
|
||||||
|
}
|
||||||
|
catch (SQLException e) {
|
||||||
|
// Ignore the error, we're leaving
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void printErrors(SQLException ex) {
|
||||||
|
mcMMO.p.getLogger().severe("SQLException: " + ex.getMessage());
|
||||||
|
mcMMO.p.getLogger().severe("SQLState: " + ex.getSQLState());
|
||||||
|
mcMMO.p.getLogger().severe("VendorError: " + ex.getErrorCode());
|
||||||
|
}
|
||||||
}
|
}
|
@ -1,8 +0,0 @@
|
|||||||
package com.gmail.nossr50.database;
|
|
||||||
|
|
||||||
public enum DatabaseUpdate {
|
|
||||||
FISHING,
|
|
||||||
BLAST_MINING,
|
|
||||||
CASCADE_DELETE,
|
|
||||||
INDEX;
|
|
||||||
}
|
|
@ -10,48 +10,49 @@ 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
|
||||||
|
|
||||||
//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>();
|
||||||
|
List<PlayerStat> herbalism = new ArrayList<PlayerStat>();
|
||||||
|
List<PlayerStat> excavation = new ArrayList<PlayerStat>();
|
||||||
|
List<PlayerStat> acrobatics = new ArrayList<PlayerStat>();
|
||||||
|
List<PlayerStat> repair = new ArrayList<PlayerStat>();
|
||||||
|
List<PlayerStat> swords = new ArrayList<PlayerStat>();
|
||||||
|
List<PlayerStat> axes = new ArrayList<PlayerStat>();
|
||||||
|
List<PlayerStat> archery = new ArrayList<PlayerStat>();
|
||||||
|
List<PlayerStat> unarmed = new ArrayList<PlayerStat>();
|
||||||
|
List<PlayerStat> taming = new ArrayList<PlayerStat>();
|
||||||
|
List<PlayerStat> fishing = new ArrayList<PlayerStat>();
|
||||||
|
List<PlayerStat> powerLevels = new ArrayList<PlayerStat>();
|
||||||
|
|
||||||
mining = new ArrayList<PlayerStat>();
|
// Read from the FlatFile database and fill our arrays with information
|
||||||
woodcutting = new ArrayList<PlayerStat>();
|
|
||||||
herbalism = new ArrayList<PlayerStat>();
|
|
||||||
excavation = new ArrayList<PlayerStat>();
|
|
||||||
acrobatics = new ArrayList<PlayerStat>();
|
|
||||||
repair = new ArrayList<PlayerStat>();
|
|
||||||
swords = new ArrayList<PlayerStat>();
|
|
||||||
axes = new ArrayList<PlayerStat>();
|
|
||||||
archery = new ArrayList<PlayerStat>();
|
|
||||||
unarmed = 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
|
|
||||||
try {
|
try {
|
||||||
FileReader file = new FileReader(mcMMO.getUsersFilePath());
|
FileReader file = new FileReader(mcMMO.getUsersFilePath());
|
||||||
BufferedReader in = new BufferedReader(file);
|
BufferedReader in = new BufferedReader(file);
|
||||||
@ -64,7 +65,7 @@ public final class Leaderboard {
|
|||||||
String p = character[0];
|
String p = character[0];
|
||||||
int powerLevel = 0;
|
int powerLevel = 0;
|
||||||
|
|
||||||
//Prevent the same player from being added multiple times (I'd like to note that this shouldn't happen...)
|
// Prevent the same player from being added multiple times (I'd like to note that this shouldn't happen...)
|
||||||
if (players.contains(p)) {
|
if (players.contains(p)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -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,19 +249,13 @@ public final class Leaderboard {
|
|||||||
currentPos++;
|
currentPos++;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
return new int[] {0, 0};
|
return new int[] {0, 0};
|
||||||
}
|
}
|
||||||
|
|
||||||
return new int[] {0, 0};
|
return new int[] {0, 0};
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class SkillComparator implements Comparator<PlayerStat> {
|
|
||||||
@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) {
|
||||||
boolean worked = false;
|
boolean worked = false;
|
||||||
|
|
||||||
@ -274,18 +271,18 @@ 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");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
mcMMO.p.getLogger().info("User found, removing...");
|
mcMMO.p.getLogger().info("User found, removing...");
|
||||||
worked = true;
|
worked = true;
|
||||||
continue; //Skip the player
|
continue; // Skip the player
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
out = new FileWriter(usersFilePath); //Write out the new file
|
out = new FileWriter(usersFilePath); // Write out the new file
|
||||||
out.write(writer.toString());
|
out.write(writer.toString());
|
||||||
}
|
}
|
||||||
catch (Exception e) {
|
catch (Exception e) {
|
||||||
@ -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) {
|
||||||
@ -361,7 +357,7 @@ public final class Leaderboard {
|
|||||||
else {
|
else {
|
||||||
mcMMO.p.getLogger().info("User found, removing...");
|
mcMMO.p.getLogger().info("User found, removing...");
|
||||||
removedPlayers++;
|
removedPlayers++;
|
||||||
continue; //Skip the player
|
continue; // Skip the player
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -369,7 +365,7 @@ public final class Leaderboard {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
out = new FileWriter(usersFilePath); //Write out the new file
|
out = new FileWriter(usersFilePath); // Write out the new file
|
||||||
out.write(writer.toString());
|
out.write(writer.toString());
|
||||||
}
|
}
|
||||||
catch (Exception e) {
|
catch (Exception e) {
|
||||||
@ -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,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;
|
|
||||||
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()) {
|
|
||||||
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,51 +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;
|
|
||||||
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 (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,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
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -0,0 +1,8 @@
|
|||||||
|
package com.gmail.nossr50.datatypes.database;
|
||||||
|
|
||||||
|
public enum DatabaseUpdateType {
|
||||||
|
FISHING,
|
||||||
|
BLAST_MINING,
|
||||||
|
CASCADE_DELETE,
|
||||||
|
INDEX;
|
||||||
|
}
|
@ -1,4 +1,4 @@
|
|||||||
package com.gmail.nossr50.database;
|
package com.gmail.nossr50.datatypes.database;
|
||||||
|
|
||||||
public class PlayerStat {
|
public class PlayerStat {
|
||||||
public String name;
|
public String name;
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user