1
0
mirror of https://github.com/mcMMO-Dev/mcMMO.git synced 2026-02-20 02:33:15 +01:00

Compare commits

...

101 Commits

Author SHA1 Message Date
nossr50
701daadff5 Getting 1.3.05 ready for release. 2012-04-03 18:31:35 -07:00
nossr50
7442d1c4a5 Fixed bug with mmoedit and offline users 2012-04-03 17:39:55 -07:00
nossr50
f247545fc4 Added 'Skill Shot' to Archery. Updated Archery command. 2012-04-03 14:36:55 -07:00
nossr50
e8817ec9ea Merge branch 'master' of github.com:mcMMO-Dev/mcMMO 2012-04-03 14:13:57 -07:00
nossr50
44d2466422 Updates to /mcmmo links & description 2012-04-03 14:13:34 -07:00
GJ
eb7a0143da More work on commands. 2012-04-03 16:13:16 -04:00
GJ
069e656cde Let's try this. 2012-04-03 15:50:22 -04:00
GJ
f1aa3f5c68 Fix for dupe exploit with Blast Mining 2012-04-03 15:33:57 -04:00
GJ
acc3d7610b More command updates. 2012-04-03 15:33:20 -04:00
nossr50
b2565bedd3 Redundant redundancy :D 2012-04-03 12:30:11 -07:00
nossr50
80c36ca846 Fix for inspect command throwing errors when players are in different
worlds
2012-04-03 12:05:39 -07:00
GJ
00e5e75092 Cleanup of AddXP command 2012-04-03 12:43:53 -04:00
GJ
c8b30b6714 Added permissions nodes for repairing wood, bows, and leather. 2012-04-03 12:34:59 -04:00
nossr50
2c4418e6e6 Merge branch 'master' of github.com:mcMMO-Dev/mcMMO 2012-04-03 08:51:53 -07:00
GJ
d0e7e1bbb5 Added check for mobs spawning from Spawner Eggs to deny XP from
spawners.
2012-04-03 11:51:49 -04:00
nossr50
70ce762b5a Removing unused imports 2012-04-03 08:51:34 -07:00
nossr50
e879153df7 Some updates. 2012-04-03 08:49:14 -07:00
GJ
c9db9566cb Cleanup of the AddLevels command. 2012-04-03 11:39:59 -04:00
nossr50
a1283bfc0f Make titles update on levelup 2012-04-03 07:08:37 -07:00
nossr50
378de09ccd Fancy formatting for power levels titles 2012-04-03 07:03:42 -07:00
GJ
20febbc3bc Made power level display also include player name. 2012-04-03 09:27:17 -04:00
GJ
3b0ba43e94 Added config value to enable/disable power level display w/ Spout 2012-04-03 02:52:04 -04:00
GJ
c189a6b489 Removing debug code. 2012-04-03 01:17:25 -04:00
GJ
2082c479f1 Debug testing for BlockBreak errors with Spout. 2012-04-03 00:56:05 -04:00
GJ
b70e868b5c *CLEANUP* - Party.java 2012-04-03 00:06:30 -04:00
GJ
24a50346db ACTUALLY made a power level cap. 2012-04-02 16:46:48 -04:00
GJ
b84a03082e Added ability to cap overall power level. 2012-04-02 13:45:49 -04:00
nossr50
e40e10da61 Some WIP work on Archery, most noteably a damage boost per 50 skill lvl 2012-04-02 04:41:04 -07:00
GJ
6a858dace7 Fixed calculating party bonus XP when players are in different
worlds throwing errors.
2012-04-01 16:30:16 -04:00
GJ
b0fbaa71bf Runnables cleanup 2012-04-01 00:11:57 -04:00
GJ
18a2b686c1 Events cleanup. 2012-03-31 22:20:35 -04:00
GJ
a2f23bd056 More cleanup. Done with Datatypes. Lack Events, Runnables, and...
Commands.
2012-03-31 19:00:41 -04:00
GJ
bb5a9826bc Assorted cleanup. 2012-03-31 18:19:24 -04:00
GJ
9904eb0b0d Assorted cleanup. 2012-03-31 16:40:06 -04:00
GJ
f89f215813 Unfixing my fix. Sorry for not properly checking that before I pulled
it.
2012-03-31 15:39:09 -04:00
GJ
d01bd487f7 *CLEAANUP* - SkillType.java 2012-03-31 15:37:57 -04:00
Grant
3be31dbf90 Merge pull request #195 from fletchto99/master
Static player profile
2012-03-31 09:51:46 -07:00
Fletch to 99
bb1bce879f Update src/main/java/com/gmail/nossr50/mcMMO.java 2012-03-31 12:38:41 -03:00
GJ
dd6082c8a1 Add ability to fire level-up event & notification with ExperienceAPI 2012-03-30 01:01:48 -04:00
GJ
be6d208b8b Changelog update 2012-03-29 23:09:32 -04:00
GJ
f547523c3e Heh, API functions shouldn't be static... 2012-03-29 23:08:51 -04:00
GJ
7de19f8087 Another typo fix with permissions 2012-03-29 22:35:44 -04:00
nossr50
dfdf8b881e Updated changelog. 2012-03-29 18:47:02 -07:00
nossr50
da6755f703 I always forget to add the new file ;_; 2012-03-29 18:44:30 -07:00
nossr50
602bde7bc5 A fix for Spout disabling itself 2012-03-29 18:43:53 -07:00
GJ
e9d1297c17 Fixed bug where Skull Splitter & Serrated Strikes could be used without
permissions.
2012-03-29 18:38:59 -04:00
GJ
8bbee7fe06 Moved some stuff around, added a few functions to PartyAPI 2012-03-29 16:13:43 -04:00
GJ
8b4c86c8ba Fixed some issues with calculating drop chances. 2012-03-29 15:23:12 -04:00
GJ
6c1ee24101 Tweaked some stuff with adding XP, added an ExperienceAPI class. 2012-03-29 14:24:41 -04:00
GJ
26ed6aa840 Fixed issue where adding XP via command without specifying a player
didn't trigger level-ups.
2012-03-29 12:03:29 -04:00
GJ
ef3802f7c2 Fixed bug with non-Spout users trying to update the XP Bar. 2012-03-29 10:44:37 -04:00
GJ
3c9e38d7ad Helps to include the new file. 2012-03-29 10:05:04 -04:00
GJ
2e4aeca0df Moved Party API functions to their own file. 2012-03-29 10:04:48 -04:00
GJ
fd6bf931fc Changed naming for Repair events to be more consistent 2012-03-29 01:41:43 -04:00
GJ
751b795417 Changed bypass node for Arcane Forging to not default to true for OPs 2012-03-29 01:36:51 -04:00
nossr50
8b07b189d4 Fixed XP Bar 2012-03-28 19:45:34 -07:00
GJ
6c6fb117ea Fixed bug where wolves spawned with Call of the Wild only had 8 health 2012-03-28 22:24:32 -04:00
GJ
6fffe10c32 Fixed bug with repairing wooden tools. 2012-03-28 15:53:55 -04:00
GJ
a2d5b97467 Changed Woodcutting durability calulations to ignore leaves and include
abilityDurabiltyLoss
2012-03-28 14:37:17 -04:00
GJ
1cda446063 Back to active development. (1.3.05-dev) 2012-03-28 02:14:11 -04:00
GJ
a5af583a29 Fixed typos in the Party help display 2012-03-28 01:42:42 -04:00
nossr50
4d4638feea Updated POM 2012-03-27 22:33:42 -07:00
GJ
ef3d76fb9f Fixed bug where you could TP to dead players 2012-03-27 23:04:00 -04:00
GJ
5e12979f09 Fix my fix for the BlockBreak event changes (reverted). 2012-03-27 22:54:56 -04:00
GJ
cd64b60ece Fix for some API functions not being callable. 2012-03-27 22:51:12 -04:00
GJ
13951e5806 Fixed NPE due to McMMOPartyChangeEvent. 2012-03-27 19:47:20 -04:00
GJ
6cfc8c7a52 Fixed bug with gaining infinite levels. (Oops.) 2012-03-27 17:12:38 -04:00
GJ
fd6610f966 Added McMMOPartyChangeEvent for API usage - fires whenever a player
joins or leaves a party
2012-03-27 17:09:23 -04:00
GJ
aaa63a7f5d Added McMMOPartyTeleportEvent for API usage - fires before a successful
teleportation would occur.
2012-03-27 15:57:37 -04:00
GJ
f786c4db50 Fixed typo in PlayerProfile that was causing NPEs 2012-03-27 15:32:51 -04:00
GJ
87a0c0b0b6 Changelog update. 2012-03-27 14:52:34 -04:00
GJ
8cfae368c3 ACTUALLY fixed issue with Disarm never working. 2012-03-27 14:52:09 -04:00
GJ
f19b8a88d5 Fixed issue with Disarm never working. 2012-03-27 14:48:36 -04:00
GJ
ac384c5d95 More cleanup on PlayerProfile.java 2012-03-27 14:41:19 -04:00
GJ
83c326fb39 Fixed a rather "critial" typo. 2012-03-27 13:34:28 -04:00
GJ
be31d03733 Fixed typo. 2012-03-27 12:32:42 -04:00
GJ
0fcba5f1ee Fixed spacing issue with /mcc command 2012-03-27 08:51:17 -04:00
GJ
d1041c30db Fixed IllegalArguementException in Fishing when the result stack didn't
have a max durability.
2012-03-27 07:51:30 -04:00
GJ
1642c61b7f Cleanup on PlayerProfile - down to 1228 lines now. :D 2012-03-27 02:33:35 -04:00
GJ
2ff5f2eb46 Rearranged event package structure. 2012-03-27 01:09:28 -04:00
GJ
af4ba976d9 Added McMMOPlayerRepairCheckEvent for API usage - fires before repair
process begins, can be cancelled.
2012-03-27 00:56:31 -04:00
GJ
3fc5a167a4 Added ability to get skill level from McMMOPlayerSkill events 2012-03-27 00:18:04 -04:00
GJ
933449f16b Added ability to get skill level from McMMOPlayerExperience events. 2012-03-27 00:14:20 -04:00
GJ
dd170ec7ef Fixed issue with repair event not returning the proper repair amount. 2012-03-26 23:58:48 -04:00
GJ
2d3b01ba34 Assorted event updates. Created new McMMOPlayerRepairEvent for when a
repair is completed.
2012-03-26 23:01:51 -04:00
GJ
6a8737547f Updates to PlayerProfile.java 2012-03-26 17:31:26 -04:00
nossr50
ae8997b4f3 HUDmmo.java cleanup (formatting stuff, comment removal) 2012-03-26 14:24:11 -07:00
GJ
65e3384a96 Prep for mcLocale update. 2012-03-26 16:17:35 -04:00
GJ
945fb5ed55 Random update. :D 2012-03-26 11:04:17 -04:00
GJ
ca2949dcaf Changelog update 2012-03-26 10:03:56 -04:00
GJ
7b22c6232d Fixed summoned ocelots never changing skins. (Thanks Xackery!) 2012-03-26 10:03:05 -04:00
GJ
3ec5894249 Generic cleanup. 2012-03-26 09:06:48 -04:00
GJ
77462888ff Moved anvil placement handling into Repair.java 2012-03-25 16:26:40 -04:00
GJ
0ee05687d9 Removed old block place workaround code. 2012-03-25 16:13:29 -04:00
GJ
d8dbce7cc9 Updates to Italian locale file. 2012-03-24 23:17:14 -04:00
GJ
adea5a5674 Fixed Green Terra & Super Breaker awarding 4x drops at high levels. 2012-03-24 00:58:46 -04:00
GJ
443b4a193c Fixed Shake dropping bonemeal from Squids.
Stupid DyeColor enum...
2012-03-23 22:30:56 -04:00
nossr50
46c31e1abb Trying to fix formatting... 2012-03-23 12:37:13 -07:00
nossr50
46cdfe992f Version is now 1.3.04-dev modified comments/changelog 2012-03-23 12:34:23 -07:00
nossr50
752cc88270 Merge branch 'master' of github.com:mcMMO-Dev/mcMMO 2012-03-23 12:30:55 -07:00
nossr50
d1f13ddec0 Made MySQL reload all profiles on reconnect, modified
RemoveProfileFromMemoryTask
2012-03-23 12:30:27 -07:00
118 changed files with 4397 additions and 3534 deletions

View File

@@ -6,7 +6,40 @@ Key:
= Fix
! Change
- Removal
Version 1.3.05
+ Added Skill Shot to Archery which increases damage dealt by 10% every 50 skill levels (caps at 200%)
+ Added ExperienceAPI and PartyAPI classes for developer use
+ Added ability to cap overall power level
+ Added showing powerlevel below a persons name if you run Spout (optional)
= Fixed errors when Spout would disable itself after start-up
= Fixed XP bar not updating when XP was gained
= Fixed bug with repairing wooden tools
= Fixed bug where spawned wolves only had 8 health.
= Fixed bug where rare Treasures from Excavation were dropping too often
= Fixed bug where Skull Splitter & Serrated Strikes could be used without permissions.
= Fixed bug where API functions were set to static
= Fixed bug where mmoedit threw errors when modifying an offline user
! Changed Tree Feller to account for ability durability loss but not leaves.
! Changed bypass node for Arcane Forging to not default to true for OPs
- Removed Ignition from Archery
- Removed McMMOPlayerRepairEvent - was basically a duplicate of McMMOPlayerRepairCheck but couldn't be cancelled.
Version 1.3.04
+ Added McMMOPlayerRepairEvent for API usage - fires after completion of a repair.
+ Added McMMOPlayerRepairCheckEvent for API usage - fires before repair process begins, can be cancelled.
+ Added ability to get skill level from McMMOPlayerExperience events
+ Added McMMOPartyTeleportEvent for API usage - fires before a successful teleportation would occur.
+ Added McMMOPartyChangeEvent for API usage - fires whenever a player joins or leaves a party
= Fixed Shake ability dropping bonemeal instead of ink for squids.
= Fixed Green Terra & Super Breaker awarding 4x drops at high levels.
= Fixed summoned ocelots never changing skins.
= Fixed bug with Disarm not working
= Fixed some API functions not being visible
= Fixed bug where /ptp worked on dead party members
! Changed MySQL to reload all player information on reconnection
! Changed event package structure - be sure to update these if you're using the API in your plugin
Version 1.3.03
+ Added Ocelots to Taming XP tables
+ Added ability to summon Ocelots with Call of the Wild

View File

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

View File

@@ -16,10 +16,12 @@ import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.inventory.ItemStack;
import com.gmail.nossr50.config.LoadProperties;
import com.gmail.nossr50.datatypes.AbilityType;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.events.FakeEntityDamageByEntityEvent;
import com.gmail.nossr50.events.FakeEntityDamageEvent;
import com.gmail.nossr50.datatypes.ToolType;
import com.gmail.nossr50.events.fake.FakeEntityDamageByEntityEvent;
import com.gmail.nossr50.events.fake.FakeEntityDamageEvent;
import com.gmail.nossr50.locale.mcLocale;
import com.gmail.nossr50.party.Party;
import com.gmail.nossr50.runnables.GainXp;
@@ -63,7 +65,7 @@ public class Combat {
Swords.bleedCheck(attacker, target, plugin);
}
if (PPa.getSerratedStrikesMode()) {
if (PPa.getAbilityMode(AbilityType.SERRATED_STRIKES) && mcPermissions.getInstance().serratedStrikes(attacker)) {
applyAbilityAoE(attacker, target, event.getDamage(), plugin, SkillType.SWORDS);
}
@@ -81,8 +83,8 @@ public class Combat {
if (mcPermissions.getInstance().impact(attacker)) {
Axes.impact(attacker, target, event);
}
if (PPa.getSkullSplitterMode()) {
if (PPa.getAbilityMode(AbilityType.SKULL_SPLIITER) && mcPermissions.getInstance().skullSplitter(attacker)) {
applyAbilityAoE(attacker, target, event.getDamage(), plugin, SkillType.AXES);
}
@@ -93,7 +95,7 @@ public class Combat {
Unarmed.unarmedBonus(PPa, event);
}
if (PPa.getBerserkMode() && mcPermissions.getInstance().berserk(attacker)) {
if (PPa.getAbilityMode(AbilityType.BERSERK) && mcPermissions.getInstance().berserk(attacker)) {
event.setDamage((int) (event.getDamage() * 1.5));
}
@@ -155,13 +157,13 @@ public class Combat {
public static void combatAbilityChecks(Player attacker) {
PlayerProfile PPa = Users.getProfile(attacker);
if (PPa.getAxePreparationMode()) {
if (PPa.getToolPreparationMode(ToolType.AXE)) {
Skills.abilityCheck(attacker, SkillType.AXES);
}
else if (PPa.getSwordsPreparationMode()) {
else if (PPa.getToolPreparationMode(ToolType.SWORD)) {
Skills.abilityCheck(attacker, SkillType.SWORDS);
}
else if (PPa.getFistsPreparationMode()) {
else if (PPa.getToolPreparationMode(ToolType.FISTS)) {
Skills.abilityCheck(attacker, SkillType.UNARMED);
}
}
@@ -191,14 +193,26 @@ public class Combat {
int damage = event.getDamage();
if (mcPermissions.getInstance().archery(attacker) && damage > 0) {
/*Archery needs a damage bonus to be viable in PVP*/
int skillLvl = Users.getProfile(attacker).getSkillLevel(SkillType.ARCHERY);
double dmgBonusPercent = ((skillLvl / 50) * 0.1D);
/* Cap maximum bonus at 200% */
if(dmgBonusPercent > 2)
dmgBonusPercent = 2;
/* Every 100 skill levels Archery gains 20% damage bonus, set that here */
//TODO: Work in progress for balancing out Archery, will work on it more later...
//System.out.println("DEBUG 0: "+event.getDamage());
int archeryBonus = (int)(event.getDamage() * dmgBonusPercent);
event.setDamage(event.getDamage() + archeryBonus);
//System.out.println("DEBUG 1: "+event.getDamage());
if (mcPermissions.getInstance().trackArrows(attacker)) {
Archery.trackArrows(pluginx, target, PPa);
}
if (mcPermissions.getInstance().ignition(attacker)) {
Archery.ignitionCheck(target, attacker);
}
startGainXp(attacker, PPa, target, SkillType.ARCHERY, pluginx);
if (target instanceof Player) {

View File

@@ -10,9 +10,11 @@ import java.util.ArrayList;
import java.util.Properties;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import com.gmail.nossr50.config.LoadProperties;
import com.gmail.nossr50.datatypes.DatabaseUpdate;
import com.gmail.nossr50.datatypes.PlayerProfile;
public class Database {
@@ -253,6 +255,15 @@ public class Database {
public void run() {
if (!isConnected()) {
connect();
if(isConnected()) {
for(PlayerProfile x : Users.players.values()) {
x.save(); //Save all profiles
}
Users.players.clear(); //Clear the profiles
for(Player x : Bukkit.getOnlinePlayers()) {
Users.addUser(x); //Add in new profiles, forcing them to 'load' again from MySQL
}
}
}
}
}, 20*60);

View File

@@ -5,6 +5,7 @@ import java.io.FileWriter;
import java.io.IOException;
import java.util.HashMap;
import org.bukkit.OfflinePlayer;
import org.bukkit.entity.Player;
import com.gmail.nossr50.datatypes.PlayerProfile;
@@ -93,13 +94,7 @@ public class Users {
* @return the player's profile
*/
public static PlayerProfile getProfile(Player player) {
if(players.get(player.getName().toLowerCase()) != null) {
return players.get(player.getName().toLowerCase());
}
else {
players.put(player.getName().toLowerCase(), new PlayerProfile(player.getName()));
return players.get(player.getName().toLowerCase());
}
return getProfile(player.getName());
}
/**
@@ -109,7 +104,7 @@ public class Users {
* @return the player's profile
*/
public static PlayerProfile getProfile(String playerName) {
if(players.get(playerName.toLowerCase()) != null) {
if (players.get(playerName.toLowerCase()) != null) {
return players.get(playerName.toLowerCase());
}
else {
@@ -118,6 +113,16 @@ public class Users {
}
}
/**
* Get the profile of an offline player.
*
* @param player The player whose profile to retrieve
* @return the player's profile
*/
public static PlayerProfile getOfflineProfile(OfflinePlayer player) {
return getOfflineProfile(player.getName());
}
/**
* Get the profile of an offline player.
*

View File

@@ -0,0 +1,136 @@
package com.gmail.nossr50.api;
import org.bukkit.entity.Player;
import com.gmail.nossr50.Users;
import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.skills.Skills;
public class 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
*/
private void checkXP(Player player, SkillType skillType) {
if (skillType.equals(SkillType.ALL)) {
Skills.XpCheckAll(player);
}
else {
Skills.XpCheckSkill(skillType, player);
}
}
/**
* Adds XP to the player, doesn't calculate for XP Rate or other modifiers.
* </br>
* This function is designed for API usage.
*
* @param player The player to add XP to
* @param skillType The skill to add XP to
* @param XP The amount of XP to add
*/
public void addRawXP(Player player, SkillType skillType, int XP) {
Users.getProfile(player).addXPOverride(skillType, XP);
checkXP(player, skillType);
}
/**
* Adds XP to the player, calculates for XP Rate but not skill modifiers.
* </br>
* This function is designed for API usage.
*
* @param player The player to add XP to
* @param skillType The skill to add XP to
* @param XP The amount of XP to add
*/
public void addMultipliedXP(Player player, SkillType skillType, int XP) {
Users.getProfile(player).addXPOverrideBonus(skillType, XP);
checkXP(player, skillType);
}
/**
* Adds XP to the player, calculates for XP Rate and skill modifiers.
* </br>
* This function is designed for API usage.
*
* @param player The player to add XP to
* @param skillType The skill to add XP to
* @param XP The amount of XP to add
*/
public void addXP(Player player, SkillType skillType, int XP) {
Users.getProfile(player).addXP(skillType, XP);
checkXP(player, skillType);
}
/**
* Get the amount of XP a player has in a specific skill.
* </br>
* This function is designed for API usage.
*
* @param player The player to get XP for
* @param skillType The skill to get XP for
* @return the amount of XP in a given skill
*/
public int getXP(Player player, SkillType skillType) {
return Users.getProfile(player).getSkillXpLevel(skillType);
}
/**
* Get the amount of XP left before leveling up.
* </br>
* This function is designed for API usage.
*
* @param player The player to get the XP amount for
* @param skillType The skill to get the XP amount for
* @return the amount of XP left before leveling up a specifc skill
*/
public int getXPToNextLevel(Player player, SkillType skillType) {
return Users.getProfile(player).getXpToLevel(skillType);
}
/**
* Add levels to a skill.
* </br>
* This function is designed for API usage.
*
* @param player The player to add levels to
* @param skillType Type of skill to add levels to
* @param levels Number of levels to add
* @param notify True if this should fire a level up notification, false otherwise.
*/
public void addLevel(Player player, SkillType skillType, int levels, boolean notify) {
Users.getProfile(player).addLevels(skillType, levels);
if (notify) {
checkXP(player, skillType);
}
}
/**
* Get the level a player has in a specific skill.
* </br>
* This function is designed for API usage.
*
* @param player The player to get the level for
* @param skillType The skill to get the level for
* @return the level of a given skill
*/
public int getLevel(Player player, SkillType skillType) {
return Users.getProfile(player).getSkillLevel(skillType);
}
/**
* Gets the power level of a player.
* </br>
* This function is designed for API usage.
*
* @param player The player to get the power level for
* @return the power level of the player
*/
public int getPowerLevel(Player player) {
return Users.getProfile(player).getPowerLevel();
}
}

View File

@@ -0,0 +1,125 @@
package com.gmail.nossr50.api;
import java.io.BufferedReader;
import java.io.FileReader;
import java.util.ArrayList;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import com.gmail.nossr50.Users;
import com.gmail.nossr50.party.Party;
public class PartyAPI {
/**
* Get the name of the party a player is in.
* </br>
* This function is designed for API usage.
*
* @param player The player to check the party name of
* @return the name of the player's party
*/
public String getPartyName(Player player) {
return Users.getProfile(player).getParty();
}
/**
* Checks if a player is in a party.
* </br>
* This function is designed for API usage.
*
* @param player The player to check
* @return true if the player is in a party, false otherwise
*/
public boolean inParty(Player player) {
return Users.getProfile(player).inParty();
}
/**
* Check if two players are in the same party.
* </br>
* This function is designed for API usage.
*
* @param playera The first player to check
* @param playerb The second player to check
* @return true if the two players are in the same party, false otherwise
*/
public boolean inSameParty(Player playera, Player playerb) {
return Party.getInstance().inSameParty(playera, playerb);
}
/**
* Get a list of all current party names.
* </br>
* This function is designed for API usage.
*
* @return the list of parties.
*/
public ArrayList<String> getParties() {
String location = "plugins/mcMMO/mcmmo.users";
ArrayList<String> parties = new ArrayList<String>();
try {
//Open the users file
FileReader file = new FileReader(location);
BufferedReader in = new BufferedReader(file);
String line = "";
while((line = in.readLine()) != null) {
String[] character = line.split(":");
String theparty = null;
//Party
if (character.length > 3) {
theparty = character[3];
}
if (!parties.contains(theparty)) {
parties.add(theparty);
}
}
in.close();
}
catch (Exception e) {
Bukkit.getLogger().severe("Exception while reading " + location + " (Are you sure you formatted it correctly?)" + e.toString());
}
return parties;
}
/**
* Get a list of all players in this player's party.
* </br>
* This function is designed for API usage.
*
* @param player The player to check
* @return all the players in the player's party
*/
public ArrayList<Player> getPartyMembers(Player player) {
return Party.getInstance().getPartyMembers(player);
}
/**
* Add a player to a party.
* </br>
* This function is designed for API usage.
*
* @param player The player to add to the party
* @param partyName The party to add the player to
*/
public void addToParty(Player player, String partyName) {
Party.getInstance().addToParty(player, Users.getProfile(player), partyName, false, null);
}
/**
* Remove a player from a party.
* </br>
* This function is designed for API usage.
*
* @param player The player to remove
*/
public void removeFromParty(Player player) {
Party.getInstance().removeFromParty(player, Users.getProfile(player));
}
}

View File

@@ -0,0 +1,138 @@
package com.gmail.nossr50.commands;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.gmail.nossr50.Users;
import com.gmail.nossr50.mcPermissions;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.locale.mcLocale;
import com.gmail.nossr50.skills.Skills;
public class CommandHelper {
/**
* Checks for command permissions.
*
* @param sender The command sender
* @param permission The permission to check
* @return true if the sender is a player without permissions, false otherwise
*/
public static boolean noCommandPermissions(CommandSender sender, String permission) {
if (sender instanceof Player) {
Player player = (Player) sender;
if (player != null && !mcPermissions.getInstance().permission(player, permission)) {
player.sendMessage(mcLocale.getString("mcPlayerListener.NoPermission"));
return true;
}
}
return false;
}
/**
* Print out details on Gathering skills. Only for online players.
*
* @param inspect The player to retrieve stats for
* @param display The sender to display stats to
* @param online true if the player to retrieve stats for is online, false otherwise
*/
public static void printGatheringSkills(Player inspect, CommandSender display) {
if (Skills.hasGatheringSkills(inspect)) {
PlayerProfile PP = Users.getProfile(inspect);
display.sendMessage(mcLocale.getString("Stats.GatheringHeader"));
if (mcPermissions.getInstance().excavation(inspect)) {
display.sendMessage(mcLocale.getString("m.SkillStats", new Object[] { mcLocale.getString("mcPlayerListener.ExcavationSkill"), PP.getSkillLevel(SkillType.EXCAVATION), PP.getSkillXpLevel(SkillType.EXCAVATION), PP.getXpToLevel(SkillType.EXCAVATION) }));
}
if (mcPermissions.getInstance().fishing(inspect)) {
display.sendMessage(mcLocale.getString("m.SkillStats", new Object[] { mcLocale.getString("mcPlayerListener.FishingSkill"), PP.getSkillLevel(SkillType.FISHING), PP.getSkillXpLevel(SkillType.FISHING), PP.getXpToLevel(SkillType.FISHING) }));
}
if (mcPermissions.getInstance().herbalism(inspect)) {
display.sendMessage(mcLocale.getString("m.SkillStats", new Object[] { mcLocale.getString("mcPlayerListener.HerbalismSkill"), PP.getSkillLevel(SkillType.HERBALISM), PP.getSkillXpLevel(SkillType.HERBALISM), PP.getXpToLevel(SkillType.HERBALISM) }));
}
if (mcPermissions.getInstance().mining(inspect)) {
display.sendMessage(mcLocale.getString("m.SkillStats", new Object[] { mcLocale.getString("mcPlayerListener.MiningSkill"), PP.getSkillLevel(SkillType.MINING), PP.getSkillXpLevel(SkillType.MINING), PP.getXpToLevel(SkillType.MINING) }));
}
if (mcPermissions.getInstance().woodcutting(inspect)) {
display.sendMessage(mcLocale.getString("m.SkillStats", new Object[] { mcLocale.getString("mcPlayerListener.WoodcuttingSkill"), PP.getSkillLevel(SkillType.WOODCUTTING), PP.getSkillXpLevel(SkillType.WOODCUTTING), PP.getXpToLevel(SkillType.WOODCUTTING) }));
}
}
}
public static void printGatheringSkills(Player player) {
printGatheringSkills(player, player);
}
/**
* Print out details on Combat skills. Only for online players.
*
* @param inspect The player to retrieve stats for
* @param display The sender to display stats to
* @param online true if the player to retrieve stats for is online, false otherwise
*/
public static void printCombatSkills(Player inspect, CommandSender display) {
if (Skills.hasCombatSkills(inspect)) {
PlayerProfile PP = Users.getProfile(inspect);
display.sendMessage(mcLocale.getString("Stats.CombatHeader"));
if (mcPermissions.getInstance().axes(inspect)) {
display.sendMessage(mcLocale.getString("m.SkillStats", new Object[] { mcLocale.getString("mcPlayerListener.AxesSkill"), PP.getSkillLevel(SkillType.AXES), PP.getSkillXpLevel(SkillType.AXES), PP.getXpToLevel(SkillType.AXES) }));
}
if (mcPermissions.getInstance().archery(inspect)) {
display.sendMessage(mcLocale.getString("m.SkillStats", new Object[] { mcLocale.getString("mcPlayerListener.ArcherySkill"), PP.getSkillLevel(SkillType.ARCHERY), PP.getSkillXpLevel(SkillType.ARCHERY), PP.getXpToLevel(SkillType.ARCHERY) }));
}
if (mcPermissions.getInstance().swords(inspect)) {
display.sendMessage(mcLocale.getString("m.SkillStats", new Object[] { mcLocale.getString("mcPlayerListener.SwordsSkill"), PP.getSkillLevel(SkillType.SWORDS), PP.getSkillXpLevel(SkillType.SWORDS), PP.getXpToLevel(SkillType.SWORDS) }));
}
if (mcPermissions.getInstance().taming(inspect)) {
display.sendMessage(mcLocale.getString("m.SkillStats", new Object[] { mcLocale.getString("mcPlayerListener.TamingSkill"), PP.getSkillLevel(SkillType.TAMING), PP.getSkillXpLevel(SkillType.TAMING), PP.getXpToLevel(SkillType.TAMING) }));
}
if (mcPermissions.getInstance().unarmed(inspect)) {
display.sendMessage(mcLocale.getString("m.SkillStats", new Object[] { mcLocale.getString("mcPlayerListener.UnarmedSkill"), PP.getSkillLevel(SkillType.UNARMED), PP.getSkillXpLevel(SkillType.UNARMED), PP.getXpToLevel(SkillType.UNARMED) }));
}
}
}
public static void printCombatSkills(Player player) {
printCombatSkills(player, player);
}
/**
* Print out details on Misc skills. Only for online players.
*
* @param inspect The player to retrieve stats for
* @param display The sender to display stats to
* @param online true if the player to retrieve stats for is online, false otherwise
*/
public static void printMiscSkills(Player inspect, CommandSender display) {
if (Skills.hasMiscSkills(inspect)) {
PlayerProfile PP = Users.getProfile(inspect);
display.sendMessage(mcLocale.getString("Stats.MiscHeader"));
if (mcPermissions.getInstance().acrobatics(inspect)) {
display.sendMessage(mcLocale.getString("m.SkillStats", new Object[] { mcLocale.getString("mcPlayerListener.AcrobaticsSkill"), PP.getSkillLevel(SkillType.ACROBATICS), PP.getSkillXpLevel(SkillType.ACROBATICS), PP.getXpToLevel(SkillType.ACROBATICS) }));
}
if (mcPermissions.getInstance().repair(inspect)) {
display.sendMessage(mcLocale.getString("m.SkillStats", new Object[] { mcLocale.getString("mcPlayerListener.RepairSkill"), PP.getSkillLevel(SkillType.REPAIR), PP.getSkillXpLevel(SkillType.REPAIR), PP.getXpToLevel(SkillType.REPAIR) }));
}
}
}
public static void printMiscSkills(Player player) {
printMiscSkills(player, player);
}
}

View File

@@ -9,73 +9,83 @@ import org.bukkit.entity.Player;
import com.gmail.nossr50.Users;
import com.gmail.nossr50.m;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.mcPermissions;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.locale.mcLocale;
import com.gmail.nossr50.commands.CommandHelper;
import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.skills.Skills;
public class AddlevelsCommand implements CommandExecutor{
private final mcMMO plugin;
private final mcMMO plugin;
public AddlevelsCommand(mcMMO instance) {
this.plugin = instance;
}
public AddlevelsCommand(mcMMO instance) {
this.plugin = instance;
}
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
Player player = null;
if (sender instanceof Player) {
player = (Player) sender;
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
Player modifiedPlayer;
int levels;
SkillType skill;
String skillName;
String usage = ChatColor.RED + "Proper usage is /addlevels <playername> <skillname> <levels>"; //TODO: Needs more locale.
if (CommandHelper.noCommandPermissions(sender, "mcmmo.tools.mmoedit")) {
return true;
}
if (player != null && !mcPermissions.getInstance().mmoedit(player)) {
sender.sendMessage("This command requires permissions.");
return true;
}
if (!(sender instanceof Player)) {
if (args.length < 2) {
System.out.println("Usage is /addlevels playername skillname levels");
return true;
} else if (args.length == 3) {
if ((plugin.getServer().getPlayer(args[0]) != null) && m.isInt(args[2]) && Skills.isSkill(args[1])) {
int levels = Integer.valueOf(args[2]);
Users.getProfile(plugin.getServer().getPlayer(args[0])).addLevels(Skills.getSkillType(args[1]), levels);
System.out.println(args[1] + " has been modified for " + plugin.getServer().getPlayer(args[0]).getName() + ".");
}
} else {
System.out.println("Usage is /addlevels playername skillname levels");
}
switch (args.length) {
case 2:
if (sender instanceof Player) {
if (m.isInt(args[1]) && Skills.isSkill(args[0])) {
modifiedPlayer = (Player) sender;
levels = Integer.valueOf(args[1]);
skill = Skills.getSkillType(args[0]);
return true;
}
if (skill.equals(SkillType.ALL)) {
skillName = "all skills";
}
else {
skillName = m.getCapitalized(skill.toString());
}
PlayerProfile PP = Users.getProfile(player);
Users.getProfile(modifiedPlayer).addLevels(skill, levels);
sender.sendMessage(ChatColor.GREEN + "You were awarded " + levels + " levels in " + skillName + "!"); //TODO: Needs more locale.
}
}
else {
sender.sendMessage(usage);
}
if (!mcPermissions.getInstance().mmoedit(player)) {
player.sendMessage(ChatColor.YELLOW + "[mcMMO] " + ChatColor.DARK_RED + mcLocale.getString("mcPlayerListener.NoPermission"));
return true;
}
if (args.length < 2) {
player.sendMessage(ChatColor.RED + "Usage is /addlevels playername skillname levels");
return true;
}
if (args.length == 3) {
if ((plugin.getServer().getPlayer(args[0]) != null) && m.isInt(args[2]) && Skills.isSkill(args[1])) {
int levels = Integer.valueOf(args[2]);
Users.getProfile(plugin.getServer().getPlayer(args[0])).addLevels(Skills.getSkillType(args[1]), levels);
player.sendMessage(ChatColor.RED + args[1] + " has been modified.");
}
} else if (args.length == 2) {
if (m.isInt(args[1]) && Skills.isSkill(args[0])) {
int levels = Integer.valueOf(args[1]);
PP.addLevels(Skills.getSkillType(args[0]), levels);
player.sendMessage(ChatColor.RED + args[0] + " has been modified.");
}
} else {
player.sendMessage(ChatColor.RED + "Usage is /addlevels playername skillname newvalue");
}
return true;
return true;
}
case 3:
modifiedPlayer = plugin.getServer().getPlayer(args[0]);
String playerName = modifiedPlayer.getName();
if (modifiedPlayer != null && m.isInt(args[2]) && Skills.isSkill(args[1])) {
levels = Integer.valueOf(args[2]);
skill = Skills.getSkillType(args[1]);
String message;
Users.getProfile(modifiedPlayer).addLevels(skill, levels);
if (skill.equals(SkillType.ALL)) {
skillName = "all skills";
message = ChatColor.RED + "All skills have been modified for " + playerName + "."; //TODO: Use locale
}
else {
skillName = m.getCapitalized(skill.toString());
message = ChatColor.RED + skillName + " has been modified for " + playerName + "."; //TODO: Use locale
}
sender.sendMessage(message);
modifiedPlayer.sendMessage(ChatColor.GREEN + "You were awarded " + levels + " levels in " + skillName + "!"); //TODO: Needs more locale.
}
return true;
default:
sender.sendMessage(usage);
return true;
}
}
}

View File

@@ -9,75 +9,98 @@ import org.bukkit.entity.Player;
import com.gmail.nossr50.Users;
import com.gmail.nossr50.m;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.mcPermissions;
import com.gmail.nossr50.locale.mcLocale;
import com.gmail.nossr50.commands.CommandHelper;
import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.skills.Skills;
public class AddxpCommand implements CommandExecutor {
private final mcMMO plugin;
private final mcMMO plugin;
public AddxpCommand(mcMMO instance) {
this.plugin = instance;
}
public AddxpCommand(mcMMO instance) {
this.plugin = instance;
}
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
Player player = null;
if (sender instanceof Player) {
player = (Player) sender;
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
Player modifiedPlayer;
int xp;
SkillType skill;
String skillName;
String usage = ChatColor.RED + "Proper usage is /addxp <playername> <skillname> <xp>"; //TODO: Needs more locale.
if (CommandHelper.noCommandPermissions(sender, "mcmmo.tools.mmoedit")) {
return true;
}
if (player != null && !mcPermissions.getInstance().mmoedit(player)) {
sender.sendMessage("This command requires permissions.");
return true;
}
if (!(sender instanceof Player)) {
if (args.length < 2) {
// No console aliasing yet
// System.out.println("Usage is /"+LoadProperties.addxp+" playername skillname xp");
System.out.println("Usage is /addxp playername skillname xp");
return true;
} else if (args.length == 3) {
if ((plugin.getServer().getPlayer(args[0]) != null) && m.isInt(args[2]) && Skills.isSkill(args[1])) {
int newvalue = Integer.valueOf(args[2]);
Users.getProfile(plugin.getServer().getPlayer(args[0])).addXPOverrideNoBonus(Skills.getSkillType(args[1]), newvalue);
plugin.getServer().getPlayer(args[0]).sendMessage(ChatColor.GREEN + "Experience granted!");
System.out.println(args[1] + " has been modified for " + plugin.getServer().getPlayer(args[0]).getName() + ".");
Skills.XpCheckAll(plugin.getServer().getPlayer(args[0]));
}
} else {
// No console aliasing yet
// System.out.println("Usage is /"+LoadProperties.addxp+" playername skillname xp");
System.out.println("Usage is /addxp playername skillname xp");
}
return true;
}
switch (args.length) {
case 2:
if (sender instanceof Player) {
if (m.isInt(args[1]) && Skills.isSkill(args[0])) {
modifiedPlayer = (Player) sender;
xp = Integer.valueOf(args[1]);
skill = Skills.getSkillType(args[0]);
if (!mcPermissions.getInstance().mmoedit(player)) {
player.sendMessage(ChatColor.YELLOW + "[mcMMO] " + ChatColor.DARK_RED + mcLocale.getString("mcPlayerListener.NoPermission"));
return true;
}
if (args.length < 2) {
player.sendMessage(ChatColor.RED + "Usage is /addxp playername skillname xp");
return true;
}
if (args.length == 3) {
if ((plugin.getServer().getPlayer(args[0]) != null) && m.isInt(args[2]) && Skills.isSkill(args[1])) {
int newvalue = Integer.valueOf(args[2]);
Users.getProfile(plugin.getServer().getPlayer(args[0])).addXP(Skills.getSkillType(args[1]), newvalue, plugin.getServer().getPlayer(args[0]));
plugin.getServer().getPlayer(args[0]).sendMessage(ChatColor.GREEN + "Experience granted!");
player.sendMessage(ChatColor.RED + args[1] + " has been modified.");
Skills.XpCheckAll(plugin.getServer().getPlayer(args[0]));
}
} else if (args.length == 2 && m.isInt(args[1]) && Skills.isSkill(args[0])) {
int newvalue = Integer.valueOf(args[1]);
Users.getProfile(player).addXP(Skills.getSkillType(args[0]), newvalue, player);
player.sendMessage(ChatColor.RED + args[0] + " has been modified.");
} else {
player.sendMessage(ChatColor.RED + "Usage is /addxp playername skillname xp");
}
Users.getProfile(modifiedPlayer).addXPOverride(skill, xp);
return true;
}
if (skill.equals(SkillType.ALL)) {
skillName = "all skills";
}
else {
skillName = m.getCapitalized(skill.toString());
}
modifiedPlayer.sendMessage(ChatColor.GREEN + "You were awarded " + xp + " experience in " + skillName + "!"); //TODO: Needs more locale.
if (skill.equals(SkillType.ALL)) {
Skills.XpCheckAll(modifiedPlayer);
}
else {
Skills.XpCheckSkill(skill, modifiedPlayer);
}
}
}
else {
sender.sendMessage(usage);
}
return true;
case 3:
modifiedPlayer = plugin.getServer().getPlayer(args[0]);
String playerName = modifiedPlayer.getName();
if (modifiedPlayer != null && m.isInt(args[2]) && Skills.isSkill(args[1])) {
xp = Integer.valueOf(args[2]);
skill = Skills.getSkillType(args[1]);
String message;
Users.getProfile(modifiedPlayer).addXPOverride(skill, xp);
if (skill.equals(SkillType.ALL)) {
skillName = "all skills";
message = ChatColor.RED + "All skills have been modified for " + playerName + "."; //TODO: Use locale
}
else {
skillName = m.getCapitalized(skill.toString());
message = ChatColor.RED + skillName + " has been modified for " + playerName + "."; //TODO: Use locale
}
sender.sendMessage(message);
modifiedPlayer.sendMessage(ChatColor.GREEN + "You were awarded " + xp + " experience in " + skillName + "!"); //TODO: Needs more locale.
if (skill.equals(SkillType.ALL)) {
Skills.XpCheckAll(modifiedPlayer);
}
else {
Skills.XpCheckSkill(skill, modifiedPlayer);
}
}
return true;
default:
sender.sendMessage(usage);
return true;
}
}
}

View File

@@ -1,6 +1,5 @@
package com.gmail.nossr50.commands.general;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
@@ -9,11 +8,10 @@ import org.bukkit.entity.Player;
import com.gmail.nossr50.Users;
import com.gmail.nossr50.m;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.mcPermissions;
import com.gmail.nossr50.commands.CommandHelper;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.locale.mcLocale;
import com.gmail.nossr50.skills.Skills;
public class InspectCommand implements CommandExecutor {
private final mcMMO plugin;
@@ -24,103 +22,71 @@ public class InspectCommand implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
Player target;
PlayerProfile PP;
String usage = "Proper usage is /inspect <playername>"; //TODO: Needs more locale.
Player player = null;
if (sender instanceof Player) {
player = (Player) sender;
}
if (sender instanceof Player && !mcPermissions.getInstance().inspect(player)) {
sender.sendMessage(ChatColor.YELLOW + "[mcMMO] " + ChatColor.DARK_RED + mcLocale.getString("mcPlayerListener.NoPermission"));
if (CommandHelper.noCommandPermissions(sender, "mcmmo.commands.inspect")) {
return true;
}
if (args.length < 1) {
sender.sendMessage(ChatColor.RED + "Proper usage is /inspect <playername>");
switch (args.length) {
case 1:
target = plugin.getServer().getPlayer(args[0]);
if (target != null) {
PP = Users.getProfile(target);
if (sender instanceof Player && !sender.isOp() && !m.isNear(((Player) sender).getLocation(), target.getLocation(), 5.0)) {
sender.sendMessage(mcLocale.getString("Inspect.TooFar"));
return true;
}
sender.sendMessage(mcLocale.getString("Inspect.Stats", new Object[] { target.getName() }));
CommandHelper.printGatheringSkills(target, sender);
CommandHelper.printCombatSkills(target, sender);
CommandHelper.printMiscSkills(target, sender);
sender.sendMessage(mcLocale.getString("mcPlayerListener.PowerLevel", new Object[] { PP.getPowerLevel() }));
}
else {
PP = Users.getOfflineProfile(args[0]);
if (sender instanceof Player && !sender.isOp()) {
sender.sendMessage(mcLocale.getString("Inspect.Offline"));
return true;
}
if (!PP.isLoaded()) {
sender.sendMessage(mcLocale.getString("Inspect.DoesNotExist"));
return true;
}
sender.sendMessage(mcLocale.getString("Inspect.OfflineStats", new Object[] { args[0] }));
sender.sendMessage(mcLocale.getString("Stats.GatheringHeader"));
sender.sendMessage(mcLocale.getString("m.SkillStats", new Object[] { mcLocale.getString("mcPlayerListener.ExcavationSkill"), PP.getSkillLevel(SkillType.EXCAVATION), PP.getSkillXpLevel(SkillType.EXCAVATION), PP.getXpToLevel(SkillType.EXCAVATION) }));
sender.sendMessage(mcLocale.getString("m.SkillStats", new Object[] { mcLocale.getString("mcPlayerListener.FishingSkill"), PP.getSkillLevel(SkillType.FISHING), PP.getSkillXpLevel(SkillType.FISHING), PP.getXpToLevel(SkillType.FISHING) }));
sender.sendMessage(mcLocale.getString("m.SkillStats", new Object[] { mcLocale.getString("mcPlayerListener.HerbalismSkill"), PP.getSkillLevel(SkillType.HERBALISM), PP.getSkillXpLevel(SkillType.HERBALISM), PP.getXpToLevel(SkillType.HERBALISM) }));
sender.sendMessage(mcLocale.getString("m.SkillStats", new Object[] { mcLocale.getString("mcPlayerListener.MiningSkill"), PP.getSkillLevel(SkillType.MINING), PP.getSkillXpLevel(SkillType.MINING), PP.getXpToLevel(SkillType.MINING) }));
sender.sendMessage(mcLocale.getString("m.SkillStats", new Object[] { mcLocale.getString("mcPlayerListener.WoodcuttingSkill"), PP.getSkillLevel(SkillType.WOODCUTTING), PP.getSkillXpLevel(SkillType.WOODCUTTING), PP.getXpToLevel(SkillType.WOODCUTTING) }));
sender.sendMessage(mcLocale.getString("Stats.CombatHeader"));
sender.sendMessage(mcLocale.getString("m.SkillStats", new Object[] { mcLocale.getString("mcPlayerListener.AxesSkill"), PP.getSkillLevel(SkillType.AXES), PP.getSkillXpLevel(SkillType.AXES), PP.getXpToLevel(SkillType.AXES) }));
sender.sendMessage(mcLocale.getString("m.SkillStats", new Object[] { mcLocale.getString("mcPlayerListener.ArcherySkill"), PP.getSkillLevel(SkillType.ARCHERY), PP.getSkillXpLevel(SkillType.ARCHERY), PP.getXpToLevel(SkillType.ARCHERY) }));
sender.sendMessage(mcLocale.getString("m.SkillStats", new Object[] { mcLocale.getString("mcPlayerListener.SwordsSkill"), PP.getSkillLevel(SkillType.SWORDS), PP.getSkillXpLevel(SkillType.SWORDS), PP.getXpToLevel(SkillType.SWORDS) }));
sender.sendMessage(mcLocale.getString("m.SkillStats", new Object[] { mcLocale.getString("mcPlayerListener.TamingSkill"), PP.getSkillLevel(SkillType.TAMING), PP.getSkillXpLevel(SkillType.TAMING), PP.getXpToLevel(SkillType.TAMING) }));
sender.sendMessage(mcLocale.getString("m.SkillStats", new Object[] { mcLocale.getString("mcPlayerListener.UnarmedSkill"), PP.getSkillLevel(SkillType.UNARMED), PP.getSkillXpLevel(SkillType.UNARMED), PP.getXpToLevel(SkillType.UNARMED) }));
sender.sendMessage(mcLocale.getString("Stats.MiscHeader"));
sender.sendMessage(mcLocale.getString("m.SkillStats", new Object[] { mcLocale.getString("mcPlayerListener.AcrobaticsSkill"), PP.getSkillLevel(SkillType.ACROBATICS), PP.getSkillXpLevel(SkillType.ACROBATICS), PP.getXpToLevel(SkillType.ACROBATICS) }));
sender.sendMessage(mcLocale.getString("m.SkillStats", new Object[] { mcLocale.getString("mcPlayerListener.RepairSkill"), PP.getSkillLevel(SkillType.REPAIR), PP.getSkillXpLevel(SkillType.REPAIR), PP.getXpToLevel(SkillType.REPAIR) }));
}
return true;
default:
sender.sendMessage(usage);
return true;
}
// if split[1] is an online player
if (plugin.getServer().getPlayer(args[0]) != null)
{
Player target = plugin.getServer().getPlayer(args[0]);
PlayerProfile PPt = Users.getProfile(target);
//If they are not an Op they have to be close
if(sender instanceof Player && !player.isOp() && !m.isNear(player.getLocation(), target.getLocation(), 5))
{
sender.sendMessage("You are too far away to inspect that player!");
}
sender.sendMessage(ChatColor.GREEN + "mcMMO Stats for " + ChatColor.YELLOW + target.getName());
sender.sendMessage(ChatColor.GOLD + "-=GATHERING SKILLS=-");
if (mcPermissions.getInstance().excavation(target))
sender.sendMessage(Skills.getSkillStats(mcLocale.getString("mcPlayerListener.ExcavationSkill"), PPt.getSkillLevel(SkillType.EXCAVATION), PPt.getSkillXpLevel(SkillType.EXCAVATION), PPt.getXpToLevel(SkillType.EXCAVATION)));
if (mcPermissions.getInstance().fishing(target))
sender.sendMessage(Skills.getSkillStats(mcLocale.getString("mcPlayerListener.FishingSkill"), PPt.getSkillLevel(SkillType.FISHING), PPt.getSkillXpLevel(SkillType.FISHING), PPt.getXpToLevel(SkillType.FISHING)));
if (mcPermissions.getInstance().herbalism(target))
sender.sendMessage(Skills.getSkillStats(mcLocale.getString("mcPlayerListener.HerbalismSkill"), PPt.getSkillLevel(SkillType.HERBALISM), PPt.getSkillXpLevel(SkillType.HERBALISM), PPt.getXpToLevel(SkillType.HERBALISM)));
if (mcPermissions.getInstance().mining(target))
sender.sendMessage(Skills.getSkillStats(mcLocale.getString("mcPlayerListener.MiningSkill"), PPt.getSkillLevel(SkillType.MINING), PPt.getSkillXpLevel(SkillType.MINING), PPt.getXpToLevel(SkillType.MINING)));
if (mcPermissions.getInstance().woodcutting(target))
sender.sendMessage(Skills.getSkillStats(mcLocale.getString("mcPlayerListener.WoodcuttingSkill"), PPt.getSkillLevel(SkillType.WOODCUTTING), PPt.getSkillXpLevel(SkillType.WOODCUTTING), PPt.getXpToLevel(SkillType.WOODCUTTING)));
sender.sendMessage(ChatColor.GOLD + "-=COMBAT SKILLS=-");
if (mcPermissions.getInstance().axes(target))
sender.sendMessage(Skills.getSkillStats(mcLocale.getString("mcPlayerListener.AxesSkill"), PPt.getSkillLevel(SkillType.AXES), PPt.getSkillXpLevel(SkillType.AXES), PPt.getXpToLevel(SkillType.AXES)));
if (mcPermissions.getInstance().archery(target))
sender.sendMessage(Skills.getSkillStats(mcLocale.getString("mcPlayerListener.ArcherySkill"), PPt.getSkillLevel(SkillType.ARCHERY), PPt.getSkillXpLevel(SkillType.ARCHERY), PPt.getXpToLevel(SkillType.ARCHERY)));
if (mcPermissions.getInstance().swords(target))
sender.sendMessage(Skills.getSkillStats(mcLocale.getString("mcPlayerListener.SwordsSkill"), PPt.getSkillLevel(SkillType.SWORDS), PPt.getSkillXpLevel(SkillType.SWORDS), PPt.getXpToLevel(SkillType.SWORDS)));
if (mcPermissions.getInstance().taming(target))
sender.sendMessage(Skills.getSkillStats(mcLocale.getString("mcPlayerListener.TamingSkill"), PPt.getSkillLevel(SkillType.TAMING), PPt.getSkillXpLevel(SkillType.TAMING), PPt.getXpToLevel(SkillType.TAMING)));
if (mcPermissions.getInstance().unarmed(target))
sender.sendMessage(Skills.getSkillStats(mcLocale.getString("mcPlayerListener.UnarmedSkill"), PPt.getSkillLevel(SkillType.UNARMED), PPt.getSkillXpLevel(SkillType.UNARMED), PPt.getXpToLevel(SkillType.UNARMED)));
sender.sendMessage(ChatColor.GOLD + "-=MISC SKILLS=-");
if (mcPermissions.getInstance().acrobatics(target))
sender.sendMessage(Skills.getSkillStats(mcLocale.getString("mcPlayerListener.AcrobaticsSkill"), PPt.getSkillLevel(SkillType.ACROBATICS), PPt.getSkillXpLevel(SkillType.ACROBATICS), PPt.getXpToLevel(SkillType.ACROBATICS)));
if (mcPermissions.getInstance().repair(target))
sender.sendMessage(Skills.getSkillStats(mcLocale.getString("mcPlayerListener.RepairSkill"), PPt.getSkillLevel(SkillType.REPAIR), PPt.getSkillXpLevel(SkillType.REPAIR), PPt.getXpToLevel(SkillType.REPAIR)));
sender.sendMessage(mcLocale.getString("mcPlayerListener.PowerLevel") + ChatColor.GREEN + (m.getPowerLevel(target, PPt)));
} else {
if(sender instanceof Player && !player.isOp())
{
sender.sendMessage("That player is offline, inspecting offline players is limited to Ops!");
return true;
}
PlayerProfile PPt = Users.getOfflineProfile(args[0]);
if(!PPt.isLoaded())
{
sender.sendMessage("Player does not exist in the database!");
return true;
}
sender.sendMessage(ChatColor.GREEN + "mcMMO Stats for Offline Player " + ChatColor.YELLOW + args[0]);
sender.sendMessage(ChatColor.GOLD + "-=GATHERING SKILLS=-");
sender.sendMessage(Skills.getSkillStats(mcLocale.getString("mcPlayerListener.ExcavationSkill"), PPt.getSkillLevel(SkillType.EXCAVATION), PPt.getSkillXpLevel(SkillType.EXCAVATION), PPt.getXpToLevel(SkillType.EXCAVATION)));
sender.sendMessage(Skills.getSkillStats(mcLocale.getString("mcPlayerListener.FishingSkill"), PPt.getSkillLevel(SkillType.FISHING), PPt.getSkillXpLevel(SkillType.FISHING), PPt.getXpToLevel(SkillType.FISHING)));
sender.sendMessage(Skills.getSkillStats(mcLocale.getString("mcPlayerListener.HerbalismSkill"), PPt.getSkillLevel(SkillType.HERBALISM), PPt.getSkillXpLevel(SkillType.HERBALISM), PPt.getXpToLevel(SkillType.HERBALISM)));
sender.sendMessage(Skills.getSkillStats(mcLocale.getString("mcPlayerListener.MiningSkill"), PPt.getSkillLevel(SkillType.MINING), PPt.getSkillXpLevel(SkillType.MINING), PPt.getXpToLevel(SkillType.MINING)));
sender.sendMessage(Skills.getSkillStats(mcLocale.getString("mcPlayerListener.WoodcuttingSkill"), PPt.getSkillLevel(SkillType.WOODCUTTING), PPt.getSkillXpLevel(SkillType.WOODCUTTING), PPt.getXpToLevel(SkillType.WOODCUTTING)));
sender.sendMessage(ChatColor.GOLD + "-=COMBAT SKILLS=-");
sender.sendMessage(Skills.getSkillStats(mcLocale.getString("mcPlayerListener.AxesSkill"), PPt.getSkillLevel(SkillType.AXES), PPt.getSkillXpLevel(SkillType.AXES), PPt.getXpToLevel(SkillType.AXES)));
sender.sendMessage(Skills.getSkillStats(mcLocale.getString("mcPlayerListener.ArcherySkill"), PPt.getSkillLevel(SkillType.ARCHERY), PPt.getSkillXpLevel(SkillType.ARCHERY), PPt.getXpToLevel(SkillType.ARCHERY)));
sender.sendMessage(Skills.getSkillStats(mcLocale.getString("mcPlayerListener.SwordsSkill"), PPt.getSkillLevel(SkillType.SWORDS), PPt.getSkillXpLevel(SkillType.SWORDS), PPt.getXpToLevel(SkillType.SWORDS)));
sender.sendMessage(Skills.getSkillStats(mcLocale.getString("mcPlayerListener.TamingSkill"), PPt.getSkillLevel(SkillType.TAMING), PPt.getSkillXpLevel(SkillType.TAMING), PPt.getXpToLevel(SkillType.TAMING)));
sender.sendMessage(Skills.getSkillStats(mcLocale.getString("mcPlayerListener.UnarmedSkill"), PPt.getSkillLevel(SkillType.UNARMED), PPt.getSkillXpLevel(SkillType.UNARMED), PPt.getXpToLevel(SkillType.UNARMED)));
sender.sendMessage(ChatColor.GOLD + "-=MISC SKILLS=-");
sender.sendMessage(Skills.getSkillStats(mcLocale.getString("mcPlayerListener.AcrobaticsSkill"), PPt.getSkillLevel(SkillType.ACROBATICS), PPt.getSkillXpLevel(SkillType.ACROBATICS), PPt.getXpToLevel(SkillType.ACROBATICS)));
sender.sendMessage(Skills.getSkillStats(mcLocale.getString("mcPlayerListener.RepairSkill"), PPt.getSkillLevel(SkillType.REPAIR), PPt.getSkillXpLevel(SkillType.REPAIR), PPt.getXpToLevel(SkillType.REPAIR)));
}
return true;
}
}

View File

@@ -7,7 +7,6 @@ import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.gmail.nossr50.Users;
import com.gmail.nossr50.m;
import com.gmail.nossr50.mcPermissions;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.datatypes.SkillType;
@@ -25,7 +24,7 @@ public class McstatsCommand implements CommandExecutor {
}
if (!(sender instanceof Player)) {
sender.sendMessage("This command does not support console useage.");
sender.sendMessage("This command does not support console useage."); //TODO: Needs more locale.
return true;
}
@@ -38,7 +37,7 @@ public class McstatsCommand implements CommandExecutor {
ChatColor header = ChatColor.GOLD;
if (Skills.hasGatheringSkills(player)) {
player.sendMessage(header + "-=GATHERING SKILLS=-");
player.sendMessage(header + "-=GATHERING SKILLS=-"); //TODO: Needs more locale.
if (mcPermissions.getInstance().excavation(player))
player.sendMessage(Skills.getSkillStats(mcLocale.getString("mcPlayerListener.ExcavationSkill"), PP.getSkillLevel(SkillType.EXCAVATION), PP.getSkillXpLevel(SkillType.EXCAVATION), PP.getXpToLevel(SkillType.EXCAVATION)));
if (mcPermissions.getInstance().fishing(player))
@@ -51,7 +50,7 @@ public class McstatsCommand implements CommandExecutor {
player.sendMessage(Skills.getSkillStats(mcLocale.getString("mcPlayerListener.WoodcuttingSkill"), PP.getSkillLevel(SkillType.WOODCUTTING), PP.getSkillXpLevel(SkillType.WOODCUTTING), PP.getXpToLevel(SkillType.WOODCUTTING)));
}
if (Skills.hasCombatSkills(player)) {
player.sendMessage(header + "-=COMBAT SKILLS=-");
player.sendMessage(header + "-=COMBAT SKILLS=-"); //TODO: Needs more locale.
if (mcPermissions.getInstance().axes(player))
player.sendMessage(Skills.getSkillStats(mcLocale.getString("mcPlayerListener.AxesSkill"), PP.getSkillLevel(SkillType.AXES), PP.getSkillXpLevel(SkillType.AXES), PP.getXpToLevel(SkillType.AXES)));
if (mcPermissions.getInstance().archery(player))
@@ -65,13 +64,13 @@ public class McstatsCommand implements CommandExecutor {
}
if (Skills.hasMiscSkills(player)) {
player.sendMessage(header + "-=MISC SKILLS=-");
player.sendMessage(header + "-=MISC SKILLS=-"); //TODO: Needs more locale.
if (mcPermissions.getInstance().acrobatics(player))
player.sendMessage(Skills.getSkillStats(mcLocale.getString("mcPlayerListener.AcrobaticsSkill"), PP.getSkillLevel(SkillType.ACROBATICS), PP.getSkillXpLevel(SkillType.ACROBATICS), PP.getXpToLevel(SkillType.ACROBATICS)));
if (mcPermissions.getInstance().repair(player))
player.sendMessage(Skills.getSkillStats(mcLocale.getString("mcPlayerListener.RepairSkill"), PP.getSkillLevel(SkillType.REPAIR), PP.getSkillXpLevel(SkillType.REPAIR), PP.getXpToLevel(SkillType.REPAIR)));
}
player.sendMessage(mcLocale.getString("mcPlayerListener.PowerLevel") + ChatColor.GREEN + (m.getPowerLevel(player, PP)));
player.sendMessage(mcLocale.getString("mcPlayerListener.PowerLevel") + ChatColor.GREEN + (PP.getPowerLevel()));
return true;
}

View File

@@ -24,7 +24,7 @@ public class MmoeditCommand implements CommandExecutor {
}
if (player != null && !mcPermissions.getInstance().mmoedit(player)) {
sender.sendMessage("This command requires permissions.");
sender.sendMessage("This command requires permissions."); //TODO: Needs more locale.
return true;
}
@@ -32,7 +32,7 @@ public class MmoeditCommand implements CommandExecutor {
{
if (args.length < 2)
{
System.out.println("Usage is /mmoedit playername skillname newvalue");
System.out.println("Usage is /mmoedit playername skillname newvalue"); //TODO: Needs more locale.
return true;
} else if (args.length == 3)
{
@@ -40,14 +40,12 @@ public class MmoeditCommand implements CommandExecutor {
if(Users.players.containsKey(args[0].toLowerCase())) {
PPt = Users.players.get(args[0].toLowerCase());
}
if(PPt == null)
Users.getOfflineProfile(args[0]); //Only grab offline profile if the above failed
} else
PPt = Users.getOfflineProfile(args[0]); //Only grab offline profile if the above failed
if(!PPt.isLoaded())
{
sender.sendMessage("Player does not exist in the database!");
sender.sendMessage("Player does not exist in the database!"); //TODO: Needs more locale.
return true;
}
@@ -55,11 +53,11 @@ public class MmoeditCommand implements CommandExecutor {
{
int newvalue = Integer.valueOf(args[2]);
Users.getOfflineProfile(args[0]).modifyskill(Skills.getSkillType(args[1]), newvalue);
System.out.println(args[1] + " has been modified for " + args[0] + ".");
System.out.println(args[1] + " has been modified for " + args[0] + "."); //TODO: Needs more locale.
}
} else
{
System.out.println("Usage is /mmoedit playername skillname newvalue");
System.out.println("Usage is /mmoedit playername skillname newvalue"); //TODO: Needs more locale.
}
return true;
@@ -73,7 +71,7 @@ public class MmoeditCommand implements CommandExecutor {
if (args.length < 2)
{
player.sendMessage(ChatColor.RED + "Usage is /mmoedit playername skillname newvalue");
player.sendMessage(ChatColor.RED + "Usage is /mmoedit playername skillname newvalue"); //TODO: Needs more locale.
return true;
}
if (args.length == 3)
@@ -89,7 +87,7 @@ public class MmoeditCommand implements CommandExecutor {
if(!PPt.isLoaded())
{
sender.sendMessage("Player does not exist in the database!");
sender.sendMessage("Player does not exist in the database!"); //TODO: Needs more locale.
return true;
}
@@ -97,7 +95,7 @@ public class MmoeditCommand implements CommandExecutor {
{
int newvalue = Integer.valueOf(args[2]);
PPt.modifyskill(Skills.getSkillType(args[1]), newvalue);
player.sendMessage(ChatColor.RED + args[1] + " has been modified for "+args[0]);
player.sendMessage(ChatColor.RED + args[1] + " has been modified for "+args[0]); //TODO: Needs more locale.
}
} else if (args.length == 2)
{
@@ -106,11 +104,11 @@ public class MmoeditCommand implements CommandExecutor {
PlayerProfile PP = Users.getProfile(player);
int newvalue = Integer.valueOf(args[1]);
PP.modifyskill(Skills.getSkillType(args[0]), newvalue);
player.sendMessage(ChatColor.RED + args[0] + " has been modified.");
player.sendMessage(ChatColor.RED + args[0] + " has been modified."); //TODO: Needs more locale.
}
} else
{
player.sendMessage(ChatColor.RED + "Usage is /mmoedit playername skillname newvalue");
player.sendMessage(ChatColor.RED + "Usage is /mmoedit playername skillname newvalue"); //TODO: Needs more locale.
}
return true;

View File

@@ -17,7 +17,7 @@ public class MmoupdateCommand implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (!(sender instanceof Player)) {
sender.sendMessage("This command does not support console useage.");
sender.sendMessage("This command does not support console useage."); //TODO: Needs more locale.
return true;
}
@@ -27,13 +27,13 @@ public class MmoupdateCommand implements CommandExecutor {
player.sendMessage(ChatColor.YELLOW + "[mcMMO] " + ChatColor.DARK_RED + mcLocale.getString("mcPlayerListener.NoPermission"));
return true;
}
player.sendMessage(ChatColor.GRAY + "Starting conversion...");
player.sendMessage(ChatColor.GRAY + "Starting conversion..."); //TODO: Needs more locale.
Users.clearUsers();
convertToMySQL();
for (Player x : Bukkit.getServer().getOnlinePlayers()) {
Users.addUser(x);
}
player.sendMessage(ChatColor.GREEN + "Conversion finished!");
player.sendMessage(ChatColor.GREEN + "Conversion finished!"); //TODO: Needs more locale.
return true;
}

View File

@@ -60,11 +60,11 @@ public class XprateCommand implements CommandExecutor {
if(xpevent = true)
for(Player x : Bukkit.getServer().getOnlinePlayers())
{
x.sendMessage(ChatColor.GOLD+"XP EVENT FOR mcMMO HAS STARTED!");
x.sendMessage(ChatColor.GOLD+"mcMMO XP RATE IS NOW "+LoadProperties.xpGainMultiplier+"x!!");
x.sendMessage(ChatColor.GOLD+"XP EVENT FOR mcMMO HAS STARTED!"); //TODO: Needs more locale.
x.sendMessage(ChatColor.GOLD+"mcMMO XP RATE IS NOW "+LoadProperties.xpGainMultiplier+"x!!"); //TODO: Needs more locale.
}
System.out.println("The XP RATE was modified to "+LoadProperties.xpGainMultiplier);
System.out.println("The XP RATE was modified to "+LoadProperties.xpGainMultiplier); //TODO: Needs more locale.
}
return true;

View File

@@ -25,7 +25,7 @@ public class McabilityCommand implements CommandExecutor {
}
if (!(sender instanceof Player)) {
sender.sendMessage("This command does not support console useage.");
sender.sendMessage("This command does not support console useage."); //TODO: Needs more locale.
return true;
}

View File

@@ -20,7 +20,7 @@ public class MccCommand implements CommandExecutor {
Player player = (Player) sender;
player.sendMessage(ChatColor.RED + "---[]" + ChatColor.YELLOW + "mcMMO Commands" + ChatColor.RED + "[]---");
player.sendMessage(ChatColor.RED + "---[]" + ChatColor.YELLOW + "mcMMO Commands" + ChatColor.RED + "[]---"); //TODO: Needs more locale.
if (mcPermissions.getInstance().party(player)) {
player.sendMessage(mcLocale.getString("m.mccPartyCommands"));
@@ -37,11 +37,11 @@ public class MccCommand implements CommandExecutor {
player.sendMessage("/ptp " + mcLocale.getString("m.mccPartyTeleport"));
}
player.sendMessage(mcLocale.getString("m.mccOtherCommands"));
player.sendMessage("/mcstats " + ChatColor.RED + " " + mcLocale.getString("m.mccStats"));
player.sendMessage("/mcstats " + ChatColor.RED + mcLocale.getString("m.mccStats"));
player.sendMessage("/mctop <skillname> <page> " + ChatColor.RED + mcLocale.getString("m.mccLeaderboards"));
if (mcPermissions.getInstance().mcAbility(player))
player.sendMessage("/mcability" + ChatColor.RED + " " + mcLocale.getString("m.mccToggleAbility"));
player.sendMessage("/mcability " + ChatColor.RED + mcLocale.getString("m.mccToggleAbility"));
if (mcPermissions.getInstance().adminChat(player))
player.sendMessage("/a " + ChatColor.RED + mcLocale.getString("m.mccAdminToggle"));
@@ -50,10 +50,10 @@ public class MccCommand implements CommandExecutor {
player.sendMessage("/inspect " + mcLocale.getString("m.mccInspect"));
if (mcPermissions.getInstance().mmoedit(player))
player.sendMessage("/mmoedit" + mcLocale.getString("m.mccMmoedit"));
player.sendMessage("/mmoedit " + mcLocale.getString("m.mccMmoedit"));
if (mcPermissions.getInstance().mcgod(player))
player.sendMessage("/mcgod" + ChatColor.RED + " " + mcLocale.getString("m.mccMcGod"));
player.sendMessage("/mcgod " + ChatColor.RED + mcLocale.getString("m.mccMcGod"));
player.sendMessage(mcLocale.getString("m.mccSkillInfo"));
player.sendMessage("/mcmmo " + mcLocale.getString("m.mccModDescription"));

View File

@@ -16,7 +16,7 @@ public class McgodCommand implements CommandExecutor {
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (!(sender instanceof Player)) {
sender.sendMessage("This command does not support console useage.");
sender.sendMessage("This command does not support console useage."); //TODO: Needs more locale.
return true;
}

View File

@@ -16,7 +16,7 @@ public class McmmoCommand implements CommandExecutor {
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (!(sender instanceof Player)) {
sender.sendMessage("This command does not support console useage.");
sender.sendMessage("This command does not support console useage."); //TODO: Needs more locale.
return true;
}
@@ -32,10 +32,10 @@ public class McmmoCommand implements CommandExecutor {
if (LoadProperties.spoutEnabled && player instanceof SpoutPlayer) {
SpoutPlayer sPlayer = (SpoutPlayer) player;
if (LoadProperties.donateMessage)
sPlayer.sendMessage(ChatColor.YELLOW + "[mcMMO]"+ChatColor.GOLD+" Donate! Paypal "+ChatColor.GREEN+"theno1yeti@gmail.com");
sPlayer.sendMessage(ChatColor.YELLOW + "[mcMMO]"+ChatColor.GOLD+" Donate! Paypal "+ChatColor.GREEN+"nossr50@gmail.com"); //Where'd our notification go?
} else {
if (LoadProperties.donateMessage)
player.sendMessage(ChatColor.YELLOW + "[mcMMO]"+ChatColor.GOLD+" Donate! Paypal "+ChatColor.GREEN+"theno1yeti@gmail.com");
player.sendMessage(ChatColor.YELLOW + "[mcMMO]"+ChatColor.GOLD+" Donate! Paypal "+ChatColor.GREEN+"nossr50@gmail.com");
}
return true;

View File

@@ -9,7 +9,9 @@ import org.bukkit.entity.Player;
import com.gmail.nossr50.Users;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.mcPermissions;
import com.gmail.nossr50.datatypes.AbilityType;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.datatypes.ToolType;
import com.gmail.nossr50.locale.mcLocale;
public class McrefreshCommand implements CommandExecutor {
@@ -23,7 +25,7 @@ public class McrefreshCommand implements CommandExecutor {
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (!(sender instanceof Player)) {
sender.sendMessage("This command does not support console useage.");
sender.sendMessage("This command does not support console useage."); //TODO: Needs more locale.
return true;
}
@@ -35,7 +37,7 @@ public class McrefreshCommand implements CommandExecutor {
return true;
}
if (args.length >= 1 && (plugin.getServer().getPlayer(args[0]) != null)) {
player.sendMessage("You have refreshed " + args[0] + "'s cooldowns!");
player.sendMessage("You have refreshed " + args[0] + "'s cooldowns!"); //TODO: Needs more locale.
player = plugin.getServer().getPlayer(args[0]);
}
@@ -44,21 +46,20 @@ public class McrefreshCommand implements CommandExecutor {
*/
PP = Users.getProfile(player);
PP.setRecentlyHurt((long) 0);
PP.setHoePreparationMode(false);
PP.setAxePreparationMode(false);
PP.setFistsPreparationMode(false);
PP.setSwordsPreparationMode(false);
PP.setPickaxePreparationMode(false);
PP.setToolPreparationMode(ToolType.AXE, false);
PP.setToolPreparationMode(ToolType.FISTS, false);
PP.setToolPreparationMode(ToolType.HOE, false);
PP.setToolPreparationMode(ToolType.PICKAXE, false);
PP.setToolPreparationMode(ToolType.SWORD, false);
//RESET COOLDOWNS
PP.resetCooldowns();
PP.setGreenTerraMode(false);
PP.setGigaDrillBreakerMode(false);
PP.setSerratedStrikesMode(false);
PP.setSuperBreakerMode(false);
PP.setTreeFellerMode(false);
PP.setBerserkMode(false);
PP.setAbilityMode(AbilityType.GREEN_TERRA, false);
PP.setAbilityMode(AbilityType.GIGA_DRILL_BREAKER, false);
PP.setAbilityMode(AbilityType.SERRATED_STRIKES, false);
PP.setAbilityMode(AbilityType.SUPER_BREAKER, false);
PP.setAbilityMode(AbilityType.TREE_FELLER, false);
PP.setAbilityMode(AbilityType.BERSERK, false);
player.sendMessage(mcLocale.getString("mcPlayerListener.AbilitiesRefreshed"));

View File

@@ -29,7 +29,7 @@ public class McremoveCommand implements CommandExecutor {
if(args.length == 0)
{
sender.sendMessage("Correct usage is /mcremove [Player Name]");
sender.sendMessage("Correct usage is /mcremove [Player Name]"); //TODO: Needs more locale.
return true;
}
@@ -66,7 +66,7 @@ public class McremoveCommand implements CommandExecutor {
+LoadProperties.MySQLtablePrefix+"experience WHERE "
+LoadProperties.MySQLtablePrefix+"experience.user_id="+userId);
sender.sendMessage("User "+playerName+" removed from MySQL DB!");
sender.sendMessage("User "+playerName+" removed from MySQL DB!"); //TODO: Needs more locale.
} else {
//FlatFile removal
//TODO: Properly remove users from FlatFile, it's going to be a huge bitch with how our FlatFile system works. Let's adopt SQLite support.
@@ -76,13 +76,13 @@ public class McremoveCommand implements CommandExecutor {
if(targetPlayer.isOnline())
{
Users.getProfile(targetPlayer).resetAllData();
sender.sendMessage("User "+playerName+" removed from FlatFile DB!");
sender.sendMessage("User "+playerName+" removed from FlatFile DB!"); //TODO: Needs more locale.
} else {
sender.sendMessage("[mcMMO] This command is not fully functional for FlatFile yet, the player needs to be online.");
sender.sendMessage("[mcMMO] This command is not fully functional for FlatFile yet, the player needs to be online."); //TODO: Needs more locale.
return true;
}
} else {
sender.sendMessage("[mcMMO] This command is not fully functional for FlatFile yet, the player needs to be online.");
sender.sendMessage("[mcMMO] This command is not fully functional for FlatFile yet, the player needs to be online."); //TODO: Needs more locale.
return true;
}
}
@@ -93,7 +93,7 @@ public class McremoveCommand implements CommandExecutor {
Player targetPlayer = Bukkit.getServer().getPlayer(playerName);
if(targetPlayer.isOnline())
{
targetPlayer.kickPlayer("[mcMMO] Stats have been reset! Rejoin!");
targetPlayer.kickPlayer("[mcMMO] Stats have been reset! Rejoin!"); //TODO: Needs more locale.
Users.removeUserByName(playerName);
} else {
Users.removeUser(targetPlayer);
@@ -102,7 +102,7 @@ public class McremoveCommand implements CommandExecutor {
Users.removeUserByName(playerName);
}
sender.sendMessage("[mcMMO] mcremove operation completed.");
sender.sendMessage("[mcMMO] mcremove operation completed."); //TODO: Needs more locale.
return true;
}

View File

@@ -1,5 +1,6 @@
package com.gmail.nossr50.commands.party;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
@@ -9,6 +10,8 @@ import org.bukkit.entity.Player;
import com.gmail.nossr50.Users;
import com.gmail.nossr50.mcPermissions;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.events.party.McMMOPartyChangeEvent;
import com.gmail.nossr50.events.party.McMMOPartyChangeEvent.EventReason;
import com.gmail.nossr50.locale.mcLocale;
import com.gmail.nossr50.party.Party;
@@ -17,7 +20,7 @@ public class AcceptCommand implements CommandExecutor {
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (!(sender instanceof Player)) {
sender.sendMessage("This command does not support console useage.");
sender.sendMessage("This command does not support console useage."); //TODO: Needs more locale.
return true;
}
@@ -33,10 +36,25 @@ public class AcceptCommand implements CommandExecutor {
Party Pinstance = Party.getInstance();
if (PP.inParty()) {
McMMOPartyChangeEvent event = new McMMOPartyChangeEvent(player, PP.getParty(), PP.getInvite(), EventReason.CHANGED_PARTIES);
Bukkit.getPluginManager().callEvent(event);
if (event.isCancelled()) {
return true;
}
Pinstance.removeFromParty(player, PP);
}
PP.acceptInvite();
Pinstance.addToParty(player, PP, PP.getParty(), true);
else {
McMMOPartyChangeEvent event = new McMMOPartyChangeEvent(player, null, PP.getInvite(), EventReason.JOINED_PARTY);
Bukkit.getPluginManager().callEvent(event);
if (event.isCancelled()) {
return true;
}
}
PP.acceptInvite();
Pinstance.addToParty(player, PP, PP.getParty(), true, null);
} else {
player.sendMessage(mcLocale.getString("mcPlayerListener.NoInvites"));

View File

@@ -24,7 +24,7 @@ public class InviteCommand implements CommandExecutor {
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (!(sender instanceof Player)) {
sender.sendMessage("This command does not support console useage.");
sender.sendMessage("This command does not support console useage."); //TODO: Needs more locale.
return true;
}
@@ -43,7 +43,7 @@ public class InviteCommand implements CommandExecutor {
return true;
}
if (args.length < 1) {
player.sendMessage(ChatColor.RED + "Usage is /invite <playername>");
player.sendMessage(ChatColor.RED + "Usage is /invite <playername>"); //TODO: Needs more locale.
return true;
}
if (PP.inParty() && args.length >= 1 && (plugin.getServer().getPlayer(args[0]) != null)) {
@@ -53,10 +53,8 @@ public class InviteCommand implements CommandExecutor {
PPt.modifyInvite(PP.getParty());
player.sendMessage(mcLocale.getString("mcPlayerListener.InviteSuccess"));
// target.sendMessage(ChatColor.RED+"ALERT: "+ChatColor.GREEN+"You have received a party invite for "+PPt.getInvite()+" from "+player.getName());
target.sendMessage(mcLocale.getString("mcPlayerListener.ReceivedInvite1", new Object[] { PPt.getInvite(), player.getName() }));
// target.sendMessage(ChatColor.YELLOW+"Type "+ChatColor.GREEN+LoadProperties.accept+ChatColor.YELLOW+" to accept the invite");
target.sendMessage(mcLocale.getString("mcPlayerListener.ReceivedInvite2", new Object[] { "/accept" }));
target.sendMessage(mcLocale.getString("mcPlayerListener.ReceivedInvite2", new Object[] { "accept" }));
} else {
player.sendMessage(mcLocale.getString("Party.Locked"));
return true;

View File

@@ -10,6 +10,8 @@ import org.bukkit.entity.Player;
import com.gmail.nossr50.Users;
import com.gmail.nossr50.mcPermissions;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.events.party.McMMOPartyChangeEvent;
import com.gmail.nossr50.events.party.McMMOPartyChangeEvent.EventReason;
import com.gmail.nossr50.locale.mcLocale;
import com.gmail.nossr50.party.Party;
@@ -18,7 +20,7 @@ public class PartyCommand implements CommandExecutor {
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (!(sender instanceof Player)) {
sender.sendMessage("This command does not support console useage.");
sender.sendMessage("This command does not support console useage."); //TODO: Needs more locale.
return true;
}
@@ -33,20 +35,20 @@ public class PartyCommand implements CommandExecutor {
Party Pinstance = Party.getInstance();
if (PP.inParty() && (!Pinstance.isParty(PP.getParty()) || !Pinstance.isInParty(player, PP))) {
Pinstance.addToParty(player, PP, PP.getParty(), false);
Pinstance.addToParty(player, PP, PP.getParty(), false, null);
}
if (args.length == 0 && !PP.inParty()) {
player.sendMessage(mcLocale.getString("Party.Help1", new Object[] { "/party "}));
player.sendMessage(mcLocale.getString("Party.Help2", new Object[] { "/party "}));
player.sendMessage(mcLocale.getString("Party.Help3", new Object[] { "/party " }));
player.sendMessage(mcLocale.getString("Party.Help1", new Object[] { "party "}));
player.sendMessage(mcLocale.getString("Party.Help2", new Object[] { "party "}));
player.sendMessage(mcLocale.getString("Party.Help3", new Object[] { "party " }));
return true;
} else if (args.length == 0 && PP.inParty()) {
String tempList = "";
int x = 0;
for (Player p : Bukkit.getServer().getOnlinePlayers()) {
if (PP.getParty().equals(Users.getProfile(p).getParty())) {
if (p != null && x + 1 >= Pinstance.partyCount(player, Bukkit.getServer().getOnlinePlayers())) {
if (p != null && x + 1 >= Pinstance.partyCount(player)) {
if (Pinstance.isPartyLeader(p.getName(), PP.getParty())) {
tempList += ChatColor.GOLD + p.getName();
x++;
@@ -55,7 +57,7 @@ public class PartyCommand implements CommandExecutor {
x++;
}
}
if (p != null && x < Pinstance.partyCount(player, Bukkit.getServer().getOnlinePlayers())) {
if (p != null && x < Pinstance.partyCount(player)) {
if (Pinstance.isPartyLeader(p.getName(), PP.getParty())) {
tempList += ChatColor.GOLD + p.getName() + ", ";
x++;
@@ -109,18 +111,26 @@ public class PartyCommand implements CommandExecutor {
return true;
} else if (args.length == 1) {
if (args[0].equals("q") && PP.inParty()) {
Pinstance.removeFromParty(player, PP);
McMMOPartyChangeEvent event = new McMMOPartyChangeEvent(player, PP.getParty(), null, EventReason.LEFT_PARTY);
Bukkit.getPluginManager().callEvent(event);
if (event.isCancelled()) {
return true;
}
Pinstance.removeFromParty(player, PP);
player.sendMessage(mcLocale.getString("mcPlayerListener.LeftParty"));
return true;
} else if (args[0].equalsIgnoreCase("?")) {
player.sendMessage(mcLocale.getString("Party.Help4", new Object[] { "/party " }));
player.sendMessage(mcLocale.getString("Party.Help2", new Object[] { "/party " }));
player.sendMessage(mcLocale.getString("Party.Help5", new Object[] { "/party " }));
player.sendMessage(mcLocale.getString("Party.Help6", new Object[] { "/party " }));
player.sendMessage(mcLocale.getString("Party.Help7", new Object[] { "/party " }));
player.sendMessage(mcLocale.getString("Party.Help8", new Object[] { "/party " }));
player.sendMessage(mcLocale.getString("Party.Help9", new Object[] { "/party " }));
player.sendMessage(mcLocale.getString("Party.Help4", new Object[] { "party " }));
player.sendMessage(mcLocale.getString("Party.Help2", new Object[] { "party " }));
player.sendMessage(mcLocale.getString("Party.Help5", new Object[] { "party " }));
player.sendMessage(mcLocale.getString("Party.Help6", new Object[] { "party " }));
player.sendMessage(mcLocale.getString("Party.Help7", new Object[] { "party " }));
player.sendMessage(mcLocale.getString("Party.Help8", new Object[] { "party " }));
player.sendMessage(mcLocale.getString("Party.Help9", new Object[] { "party " }));
} else if (args[0].equalsIgnoreCase("lock")) {
if (PP.inParty()) {
if (Pinstance.isPartyLeader(player.getName(), PP.getParty())) {
@@ -148,9 +158,24 @@ public class PartyCommand implements CommandExecutor {
// Pinstance.dump(player);
} else {
if (PP.inParty()) {
McMMOPartyChangeEvent event = new McMMOPartyChangeEvent(player, PP.getParty(), args[0], EventReason.CHANGED_PARTIES);
Bukkit.getPluginManager().callEvent(event);
if (event.isCancelled()) {
return true;
}
Pinstance.removeFromParty(player, PP);
}
Pinstance.addToParty(player, PP, args[0], false);
else {
McMMOPartyChangeEvent event = new McMMOPartyChangeEvent(player, null, args[0], EventReason.JOINED_PARTY);
Bukkit.getPluginManager().callEvent(event);
if (event.isCancelled()) {
return true;
}
}
Pinstance.addToParty(player, PP, args[0], false, null);
return true;
}
} else if (args.length == 2 && PP.inParty()) {
@@ -186,6 +211,13 @@ public class PartyCommand implements CommandExecutor {
}
PlayerProfile tPP = Users.getProfile(tPlayer);
McMMOPartyChangeEvent event = new McMMOPartyChangeEvent(player, tPP.getParty(), null, EventReason.KICKED_FROM_PARTY);
Bukkit.getPluginManager().callEvent(event);
if (event.isCancelled()) {
return true;
}
Pinstance.removeFromParty(tPlayer, tPP);
tPlayer.sendMessage(mcLocale.getString("mcPlayerListener.LeftParty"));
@@ -213,10 +245,22 @@ public class PartyCommand implements CommandExecutor {
player.sendMessage(mcLocale.getString("Party.NotOwner"));
}
} else {
McMMOPartyChangeEvent event = new McMMOPartyChangeEvent(player, PP.getParty(), args[0], EventReason.CHANGED_PARTIES);
Bukkit.getPluginManager().callEvent(event);
if (event.isCancelled()) {
return true;
}
Pinstance.removeFromParty(player, PP);
Pinstance.addToParty(player, PP, args[0], false, args[1]);
}
} else if (args.length == 2 && !PP.inParty()) {
McMMOPartyChangeEvent event = new McMMOPartyChangeEvent(player, null, args[0], EventReason.JOINED_PARTY);
Bukkit.getPluginManager().callEvent(event);
if (event.isCancelled()) {
return true;
}
Pinstance.addToParty(player, PP, args[0], false, args[1]);
}

View File

@@ -1,5 +1,6 @@
package com.gmail.nossr50.commands.party;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
@@ -11,6 +12,7 @@ import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.mcPermissions;
import com.gmail.nossr50.config.LoadProperties;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.events.party.McMMOPartyTeleportEvent;
import com.gmail.nossr50.locale.mcLocale;
import com.gmail.nossr50.party.Party;
@@ -25,7 +27,7 @@ public class PtpCommand implements CommandExecutor {
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (!(sender instanceof Player)) {
sender.sendMessage("This command does not support console useage.");
sender.sendMessage("This command does not support console useage."); //TODO: Needs more locale.
return true;
}
@@ -39,34 +41,45 @@ public class PtpCommand implements CommandExecutor {
if(!Party.getInstance().isParty(PP.getParty()))
{
player.sendMessage(ChatColor.RED+"You are not in a party!");
player.sendMessage(ChatColor.RED+"You are not in a party!"); //TODO: Needs more locale.
return true;
}
if(PP.getRecentlyHurt()+(LoadProperties.ptpCommandCooldown*1000) > System.currentTimeMillis())
{
player.sendMessage(ChatColor.RED+"You've been hurt in the last " + LoadProperties.ptpCommandCooldown + " seconds and cannnot teleport.");
player.sendMessage(ChatColor.RED+"You've been hurt in the last " + LoadProperties.ptpCommandCooldown + " seconds and cannnot teleport."); //TODO: Needs more locale.
return true;
}
if (args.length < 1) {
player.sendMessage(ChatColor.RED + "Usage is /ptp <playername>");
player.sendMessage(ChatColor.RED + "Usage is /ptp <playername>"); //TODO: Needs more locale.
return true;
}
if (plugin.getServer().getPlayer(args[0]) == null) {
player.sendMessage("That is not a valid player");
player.sendMessage("That is not a valid player"); //TODO: Needs more locale.
}
if (plugin.getServer().getPlayer(args[0]) != null) {
Player target = plugin.getServer().getPlayer(args[0]);
PlayerProfile PPt = Users.getProfile(target);
if (target.isDead()) {
player.sendMessage(ChatColor.RED + "You can't teleport to dead players."); //TODO: Needs more locale.
return true;
}
if (PP.getParty().equals(PPt.getParty())) {
player.teleport(target);
player.sendMessage(ChatColor.GREEN + "You have teleported to " + target.getName());
target.sendMessage(ChatColor.GREEN + player.getName() + " has teleported to you.");
McMMOPartyTeleportEvent event = new McMMOPartyTeleportEvent(player, target, PP.getParty());
Bukkit.getPluginManager().callEvent(event);
if (!event.isCancelled()) {
player.teleport(target);
player.sendMessage(ChatColor.GREEN + "You have teleported to " + target.getName()); //TODO: Needs more locale.
target.sendMessage(ChatColor.GREEN + player.getName() + " has teleported to you."); //TODO: Needs more locale.
}
} else {
player.sendMessage(ChatColor.RED + "That player is in a different party than you.");
player.sendMessage(ChatColor.RED + "That player is in a different party than you."); //TODO: Needs more locale.
}
}

View File

@@ -17,7 +17,7 @@ public class AcrobaticsCommand implements CommandExecutor {
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (!(sender instanceof Player))
{
sender.sendMessage("This command does not support console useage.");
sender.sendMessage("This command does not support console useage."); //TODO: Needs more locale.
return true;
}

View File

@@ -16,7 +16,7 @@ public class ArcheryCommand implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (!(sender instanceof Player)) {
sender.sendMessage("This command does not support console useage.");
sender.sendMessage("This command does not support console useage."); //TODO: Needs more locale.
return true;
}
@@ -25,18 +25,14 @@ public class ArcheryCommand implements CommandExecutor {
float skillvalue = (float) PP.getSkillLevel(SkillType.ARCHERY);
String percentage = String.valueOf((skillvalue / 1000) * 100);
int ignition = 20;
if (PP.getSkillLevel(SkillType.ARCHERY) >= 200)
ignition += 20;
if (PP.getSkillLevel(SkillType.ARCHERY) >= 400)
ignition += 20;
if (PP.getSkillLevel(SkillType.ARCHERY) >= 600)
ignition += 20;
if (PP.getSkillLevel(SkillType.ARCHERY) >= 800)
ignition += 20;
if (PP.getSkillLevel(SkillType.ARCHERY) >= 1000)
ignition += 20;
double dmgBonusPercent = ((PP.getSkillLevel(SkillType.ARCHERY) / 50) * 0.1D);
/* Cap maximum bonus at 200% */
if(dmgBonusPercent > 2)
dmgBonusPercent = 2;
dmgBonusPercent = dmgBonusPercent * 100; //Convert to percentage
String percentagedaze;
if (PP.getSkillLevel(SkillType.ARCHERY) < 1000)
@@ -55,9 +51,9 @@ public class ArcheryCommand implements CommandExecutor {
player.sendMessage(mcLocale.getString("m.EffectsTemplate", new Object[] { mcLocale.getString("m.EffectsArchery2_0"), mcLocale.getString("m.EffectsArchery2_1") }));
player.sendMessage(mcLocale.getString("m.EffectsTemplate", new Object[] { mcLocale.getString("m.EffectsArchery4_0"), mcLocale.getString("m.EffectsArchery4_1") }));
player.sendMessage(mcLocale.getString("m.SkillHeader", new Object[] { mcLocale.getString("m.YourStats") }));
player.sendMessage(mcLocale.getString("m.ArcherySkillShot", new Object[] { dmgBonusPercent }));
player.sendMessage(mcLocale.getString("m.ArcheryDazeChance", new Object[] { percentagedaze }));
player.sendMessage(mcLocale.getString("m.ArcheryRetrieveChance", new Object[] { percentage }));
player.sendMessage(mcLocale.getString("m.ArcheryIgnitionLength", new Object[] { (ignition / 20) }));
Page.grabGuidePageForSkill(SkillType.ARCHERY, player, args);

View File

@@ -15,7 +15,7 @@ public class AxesCommand implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (!(sender instanceof Player)) {
sender.sendMessage("This command does not support console useage.");
sender.sendMessage("This command does not support console useage."); //TODO: Needs more locale.
return true;
}

View File

@@ -16,7 +16,7 @@ public class ExcavationCommand implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (!(sender instanceof Player)) {
sender.sendMessage("This command does not support console useage.");
sender.sendMessage("This command does not support console useage."); //TODO: Needs more locale.
return true;
}

View File

@@ -17,7 +17,7 @@ public class FishingCommand implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (!(sender instanceof Player)) {
sender.sendMessage("This command does not support console useage.");
sender.sendMessage("This command does not support console useage."); //TODO: Needs more locale.
return true;
}

View File

@@ -16,7 +16,7 @@ public class HerbalismCommand implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (!(sender instanceof Player)) {
sender.sendMessage("This command does not support console useage.");
sender.sendMessage("This command does not support console useage."); //TODO: Needs more locale.
return true;
}

View File

@@ -16,7 +16,7 @@ public class MiningCommand implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (!(sender instanceof Player)) {
sender.sendMessage("This command does not support console useage.");
sender.sendMessage("This command does not support console useage."); //TODO: Needs more locale.
return true;
}

View File

@@ -18,7 +18,7 @@ public class RepairCommand implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (!(sender instanceof Player)) {
sender.sendMessage("This command does not support console useage.");
sender.sendMessage("This command does not support console useage."); //TODO: Needs more locale.
return true;
}

View File

@@ -16,7 +16,7 @@ public class SwordsCommand implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (!(sender instanceof Player)) {
sender.sendMessage("This command does not support console useage.");
sender.sendMessage("This command does not support console useage."); //TODO: Needs more locale.
return true;
}

View File

@@ -17,7 +17,7 @@ public class TamingCommand implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (!(sender instanceof Player)) {
sender.sendMessage("This command does not support console useage.");
sender.sendMessage("This command does not support console useage."); //TODO: Needs more locale.
return true;
}

View File

@@ -16,7 +16,7 @@ public class UnarmedCommand implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (!(sender instanceof Player)) {
sender.sendMessage("This command does not support console useage.");
sender.sendMessage("This command does not support console useage."); //TODO: Needs more locale.
return true;
}
@@ -58,7 +58,6 @@ public class UnarmedCommand implements CommandExecutor {
player.sendMessage(mcLocale.getString("m.EffectsTemplate", new Object[] { mcLocale.getString("m.EffectsUnarmed1_0"), mcLocale.getString("m.EffectsUnarmed1_1") }));
player.sendMessage(mcLocale.getString("m.EffectsTemplate", new Object[] { mcLocale.getString("m.EffectsUnarmed2_0"), mcLocale.getString("m.EffectsUnarmed2_1") }));
player.sendMessage(mcLocale.getString("m.EffectsTemplate", new Object[] { mcLocale.getString("m.EffectsUnarmed3_0"), mcLocale.getString("m.EffectsUnarmed3_1") }));
//player.sendMessage(mcLocale.getString("m.EffectsTemplate", new Object[] { mcLocale.getString("m.EffectsUnarmed4_0"), mcLocale.getString("m.EffectsUnarmed4_1") }));
player.sendMessage(mcLocale.getString("m.EffectsTemplate", new Object[] { mcLocale.getString("m.EffectsUnarmed5_0"), mcLocale.getString("m.EffectsUnarmed5_1") }));
player.sendMessage(mcLocale.getString("m.SkillHeader", new Object[] { mcLocale.getString("m.YourStats") }));
player.sendMessage(mcLocale.getString("m.UnarmedArrowDeflectChance", new Object[] { arrowpercentage }));

View File

@@ -16,7 +16,7 @@ public class WoodcuttingCommand implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (!(sender instanceof Player)) {
sender.sendMessage("This command does not support console useage.");
sender.sendMessage("This command does not support console useage."); //TODO: Needs more locale.
return true;
}

View File

@@ -16,12 +16,12 @@ public class MchudCommand implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (!LoadProperties.spoutEnabled) {
sender.sendMessage("This command is not enabled.");
sender.sendMessage("This command is not enabled."); //TODO: Needs more locale.
return true;
}
if (!(sender instanceof Player)) {
sender.sendMessage("This command does not support console useage.");
sender.sendMessage("This command does not support console useage."); //TODO: Needs more locale.
return true;
}

View File

@@ -19,12 +19,12 @@ public class XplockCommand implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (!LoadProperties.spoutEnabled || !LoadProperties.xpbar || !LoadProperties.xplockEnable) {
sender.sendMessage("This command is not enabled.");
sender.sendMessage("This command is not enabled."); //TODO: Needs more locale.
return true;
}
if (!(sender instanceof Player)) {
sender.sendMessage("This command does not support console useage.");
sender.sendMessage("This command does not support console useage."); //TODO: Needs more locale.
return true;
}

View File

@@ -88,7 +88,7 @@ public class LoadProperties extends ConfigLoader{
public static Boolean anvilmessages;
public static int rWood, rStone, rIron, rGold, rDiamond, rString, rLeather;
public static int anvilID;
public static int repairStoneLevel, repairIronLevel, repairGoldLevel, repairdiamondlevel;
public static int repairStoneLevel, repairIronLevel, repairGoldLevel, repairdiamondlevel, repairBowLevel;
/* Taming */
public static int mtameWolf, mtameOcelot;
@@ -106,7 +106,8 @@ public class LoadProperties extends ConfigLoader{
/* Level Caps */
public static int levelCapAcrobatics, levelCapArchery, levelCapAxes, levelCapExcavation,
levelCapFishing, levelCapHerbalism, levelCapMining, levelCapRepair,
levelCapSwords, levelCapTaming, levelCapUnarmed, levelCapWoodcutting;
levelCapSwords, levelCapTaming, levelCapUnarmed, levelCapWoodcutting,
powerLevelCap;
/*
* XP SETTINGS
@@ -131,7 +132,8 @@ public class LoadProperties extends ConfigLoader{
* SPOUT SETTINGS
*/
public static Boolean spoutEnabled;
public static boolean spoutEnabled;
public static boolean showPowerLevel;
/* Spout Party HUD */
public static Boolean showDisplayName, showFaces, partybar;
@@ -212,6 +214,8 @@ public class LoadProperties extends ConfigLoader{
showDisplayName = config.getBoolean("Spout.Party.HUD.Show_Display_Name", false);
partybar = config.getBoolean("Spout.Party.HUD.Enabled", true);
showPowerLevel = config.getBoolean("Spout.HUD.Show_Power_Level", true);
acrobatics_r = config.getDouble("Spout.HUD.Retro.Colors.Acrobatics.RED", 0.3);
acrobatics_g = config.getDouble("Spout.HUD.Retro.Colors.Acrobatics.GREEN", 0.3);
acrobatics_b = config.getDouble("Spout.HUD.Retro.Colors.Acrobatics.BLUE", 0.75);
@@ -328,6 +332,7 @@ public class LoadProperties extends ConfigLoader{
statsTracking = config.getBoolean("General.Stats_Tracking", true);
eventCallback = config.getBoolean("General.Event_Callback", true);
perLevelTools = config.getBoolean("General.Per_Level_Tools", false);
powerLevelCap = config.getInt("General.Power_Level_Cap", 0);
enableCobbleToMossy = config.getBoolean("Skills.Herbalism.Green_Thumb.Cobble_To_Mossy", true);
enableSmoothToMossy = config.getBoolean("Skills.Herbalism.Green_Thumb.SmoothBrick_To_MossyBrick", true);
@@ -373,6 +378,7 @@ public class LoadProperties extends ConfigLoader{
repairIronLevel = config.getInt("Skills.Repair.Iron.Level_Required", 0);
repairGoldLevel = config.getInt("Skills.Repair.Gold.Level_Required", 0);
repairStoneLevel = config.getInt("Skills.Repair.Stone.Level_Required", 0);
repairBowLevel = config.getInt("Skills.Repair.String.Level_Required", 0);
tamingxpmodifier = config.getDouble("Experience.Formula.Multiplier.Taming", 1.0);
miningxpmodifier = config.getDouble("Experience.Formula.Multiplier.Mining", 1.0);

View File

@@ -61,163 +61,6 @@ public enum AbilityType {
return this.abilityRefresh;
}
/**
* Get the mode of this ability.
*
* @param PP PlayerProfile of the player using the ability
* @return true if the ability is enabled, false otherwise
*/
public boolean getMode(PlayerProfile PP) {
switch (this) {
case BERSERK:
return PP.getBerserkMode();
case SUPER_BREAKER:
return PP.getSuperBreakerMode();
case GIGA_DRILL_BREAKER:
return PP.getGigaDrillBreakerMode();
case GREEN_TERRA:
return PP.getGreenTerraMode();
case SKULL_SPLIITER:
return PP.getSkullSplitterMode();
case TREE_FELLER:
return PP.getTreeFellerMode();
case SERRATED_STRIKES:
return PP.getSerratedStrikesMode();
default:
return false;
}
}
/**
* Set the mode of this ability.
*
* @param PP PlayerProfile of the player using the ability
* @param bool Mode to set the ability to
*/
public void setMode(PlayerProfile PP, boolean bool) {
switch (this) {
case BERSERK:
PP.setBerserkMode(bool);
break;
case SUPER_BREAKER:
PP.setSuperBreakerMode(bool);
break;
case GIGA_DRILL_BREAKER:
PP.setGigaDrillBreakerMode(bool);
break;
case GREEN_TERRA:
PP.setGreenTerraMode(bool);
break;
case SKULL_SPLIITER:
PP.setSkullSplitterMode(bool);
break;
case TREE_FELLER:
PP.setTreeFellerMode(bool);
break;
case SERRATED_STRIKES:
PP.setSerratedStrikesMode(bool);
break;
default:
break;
}
}
/**
* Get the informed state of this ability
*
* @param PP PlayerProfile of the player using the ability
* @return true if the ability is informed, false otherwise
*/
public boolean getInformed(PlayerProfile PP) {
switch (this) {
case BERSERK:
return PP.getBerserkInformed();
case BLAST_MINING:
return PP.getBlastMiningInformed();
case SUPER_BREAKER:
return PP.getSuperBreakerInformed();
case GIGA_DRILL_BREAKER:
return PP.getGigaDrillBreakerInformed();
case GREEN_TERRA:
return PP.getGreenTerraInformed();
case SKULL_SPLIITER:
return PP.getSkullSplitterInformed();
case TREE_FELLER:
return PP.getTreeFellerInformed();
case SERRATED_STRIKES:
return PP.getSerratedStrikesInformed();
default:
return false;
}
}
/**
* Set the informed state of this ability.
*
* @param PP PlayerProfile of the player using the ability
* @param bool Informed state to set the ability to
*/
public void setInformed(PlayerProfile PP, boolean bool) {
switch (this) {
case BERSERK:
PP.setBerserkInformed(bool);
break;
case BLAST_MINING:
PP.setBlastMiningInformed(bool);
break;
case SUPER_BREAKER:
PP.setSuperBreakerInformed(bool);
break;
case GIGA_DRILL_BREAKER:
PP.setGigaDrillBreakerInformed(bool);
break;
case GREEN_TERRA:
PP.setGreenTerraInformed(bool);
break;
case SKULL_SPLIITER:
PP.setSkullSplitterInformed(bool);
break;
case TREE_FELLER:
PP.setTreeFellerInformed(bool);
break;
case SERRATED_STRIKES:
PP.setSerratedStrikesInformed(bool);
break;
default:
break;
}
}
/**
* Get the permissions for this ability.
*
@@ -288,4 +131,4 @@ public enum AbilityType {
return false;
}
}
}
}

View File

@@ -16,285 +16,353 @@ import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.LoadProperties;
import com.gmail.nossr50.spout.SpoutStuff;
public class HUDmmo
{
int center_x = 427/2;
int center_y = 240/2;
String playerName = null;
Widget xpbar = null;
GenericGradient xpfill = null;
GenericGradient xpbg = null;
GenericGradient xpicon_bg = null;
GenericGradient xpicon_border = null;
GenericTexture xpicon = null;
mcMMO plugin = (mcMMO) Bukkit.getServer().getPluginManager().getPlugin("mcMMO");
public HUDmmo(Player player)
{
playerName = player.getName();
initializeHUD(player);
}
public void initializeHUD(Player player)
{
//PlayerProfile PP = Users.getProfile(player);
HUDType type = Users.getProfile(player).getHUDType();
//if(LoadProperties.partybar && PP.getPartyHUD())
//mmoHelper.initialize(SpoutManager.getPlayer(player), plugin); //PARTY HUD
switch(type)
{
case RETRO:
{
initializeXpBarDisplayRetro(SpoutManager.getPlayer(player));
break;
}
case STANDARD:
{
initializeXpBarDisplayStandard(SpoutManager.getPlayer(player));
break;
}
case SMALL:
{
initializeXpBarDisplaySmall(SpoutManager.getPlayer(player));
break;
}
case DISABLED:
{
//Do nothing.. :)
}
}
}
public void updateXpBarDisplay(HUDType type, Player player)
{
switch(type)
{
case RETRO:
{
updateXpBarRetro(player, Users.getProfile(player));
break;
}
case STANDARD:
{
updateXpBarStandard(player, Users.getProfile(player));
break;
}
case SMALL:
{
updateXpBarStandard(player, Users.getProfile(player));
break;
}
case DISABLED:
{
//Do nothing.. :)
}
}
}
public void resetHUD()
{
SpoutPlayer sPlayer = SpoutStuff.getSpoutPlayer(playerName);
//PlayerProfile PP = Users.getProfile(sPlayer);
if(sPlayer != null)
{
sPlayer.getMainScreen().removeWidgets(plugin);
//Reset the objects
xpbar = null;
xpfill = null;
xpbg = null;
xpicon = null;
//if(LoadProperties.partybar && PP.getPartyHUD())
//mmoHelper.initialize(sPlayer, plugin);
sPlayer.getMainScreen().setDirty(true);
}
}
private void initializeXpBarDisplayRetro(SpoutPlayer sPlayer)
{
Color border = new Color((float)LoadProperties.xpborder_r, (float)LoadProperties.xpborder_g, (float)LoadProperties.xpborder_b, 1f);
Color green = new Color(0, 1f, 0, 1f);
Color background = new Color((float)LoadProperties.xpbackground_r, (float)LoadProperties.xpbackground_g, (float)LoadProperties.xpbackground_b, 1f);
Color darkbg = new Color(0.2f, 0.2f, 0.2f, 1f);
xpicon = new GenericTexture();
xpbar = new GenericGradient();
xpfill = new GenericGradient();
xpbg = new GenericGradient();
xpicon_bg = new GenericGradient();
xpicon_border = new GenericGradient();
xpicon_bg.setBottomColor(darkbg).setTopColor(darkbg).setWidth(4).setHeight(4).setPriority(RenderPriority.High).setX(142).setY(10).setDirty(true);
xpicon_border.setBottomColor(border).setTopColor(border).setWidth(6).setHeight(6).setPriority(RenderPriority.Highest).setX(141).setY(9).setDirty(true);
xpicon.setWidth(6).setHeight(6).setX(141).setY(9).setPriority(RenderPriority.Normal).setDirty(true);
xpicon.setUrl("Icon_r.png");
xpbar.setWidth(128).setHeight(4).setX(149).setY(10);
((GenericGradient) xpbar).setBottomColor(border).setTopColor(border).setPriority(RenderPriority.Highest).setDirty(true);
xpfill.setWidth(0).setHeight(2).setX(150).setY(11);
xpfill.setBottomColor(green).setTopColor(green).setPriority(RenderPriority.Lowest).setDirty(true);
xpbg.setWidth(126).setHeight(2).setX(150).setY(11);
xpbg.setBottomColor(background).setTopColor(background).setPriority(RenderPriority.Low).setDirty(true);
if(LoadProperties.xpbar)
{
sPlayer.getMainScreen().attachWidget(plugin, (GenericGradient)xpbar);
sPlayer.getMainScreen().attachWidget(plugin, (GenericGradient)xpfill);
sPlayer.getMainScreen().attachWidget(plugin, (GenericGradient)xpbg);
if(LoadProperties.xpicon)
{
sPlayer.getMainScreen().attachWidget(plugin, (GenericTexture)xpicon);
sPlayer.getMainScreen().attachWidget(plugin, (GenericGradient)xpicon_bg);
}
sPlayer.getMainScreen().attachWidget(plugin, (GenericGradient)xpicon_border);
}
sPlayer.getMainScreen().setDirty(true);
}
private void initializeXpBarDisplayStandard(SpoutPlayer sPlayer)
{
//Setup xp bar
xpbar = new GenericTexture();
if(LoadProperties.xpbar && LoadProperties.xpicon)
{
xpicon = new GenericTexture();
xpicon.setUrl("Icon.png");
xpicon.setHeight(16).setWidth(32).setX(LoadProperties.xpicon_x).setY(LoadProperties.xpicon_y);
xpicon.setDirty(true);
sPlayer.getMainScreen().attachWidget(plugin, xpicon);
}
if(LoadProperties.xpbar)
{
((GenericTexture)xpbar).setUrl("xpbar_inc000.png");
xpbar.setX(LoadProperties.xpbar_x).setY(LoadProperties.xpbar_y).setHeight(8).setWidth(256);
sPlayer.getMainScreen().attachWidget(plugin, xpbar);
}
sPlayer.getMainScreen().setDirty(true);
}
private void initializeXpBarDisplaySmall(SpoutPlayer sPlayer)
{
//Setup xp bar
xpbar = new GenericTexture();
if(LoadProperties.xpbar && LoadProperties.xpicon)
{
xpicon = new GenericTexture();
xpicon.setUrl("Icon.png");
xpicon.setHeight(8).setWidth(16).setX(center_x-(8+64)).setY(LoadProperties.xpicon_y+2);
xpicon.setDirty(true);
sPlayer.getMainScreen().attachWidget(plugin, xpicon);
}
if(LoadProperties.xpbar)
{
((GenericTexture)xpbar).setUrl("xpbar_inc000.png");
xpbar.setX(center_x-64).setY(LoadProperties.xpbar_y).setHeight(4).setWidth(128);
sPlayer.getMainScreen().attachWidget(plugin, xpbar);
}
sPlayer.getMainScreen().setDirty(true);
}
private void updateXpBarStandard(Player player, PlayerProfile PP)
{
if(!LoadProperties.xpbar)
return;
SkillType theType = null;
if(PP.getXpBarLocked())
theType=PP.getSkillLock();
else
theType=PP.getLastGained();
if(theType == null)
return;
((GenericTexture) xpicon).setUrl(m.getCapitalized(theType.toString())+".png");
xpicon.setDirty(true);
public class HUDmmo {
private int center_x = 427 / 2;
private String playerName = null;
private Widget xpbar = null;
private GenericGradient xpfill = null;
private GenericGradient xpbg = null;
private GenericGradient xpicon_bg = null;
private GenericGradient xpicon_border = null;
private GenericTexture xpicon = null;
private mcMMO plugin = (mcMMO) Bukkit.getServer().getPluginManager().getPlugin("mcMMO");
public HUDmmo(Player player) {
playerName = player.getName();
initializeHUD(player);
}
/**
* Initialize the HUD.
*
* @param player Player whose HUD to initialize
*/
public void initializeHUD(Player player) {
HUDType type = Users.getProfile(player).getHUDType();
SpoutPlayer sPlayer = SpoutManager.getPlayer(player);
switch (type) {
case RETRO:
initializeXpBarDisplayRetro(sPlayer);
break;
case STANDARD:
initializeXpBarDisplayStandard(sPlayer);
break;
case SMALL:
initializeXpBarDisplaySmall(sPlayer);
break;
case DISABLED:
break;
default:
break;
}
}
/**
* Update the XP bar.
*
* @param type Type of XP bar
* @param player Player whose XP bar to update
*/
public void updateXpBarDisplay(HUDType type, Player player) {
PlayerProfile PP = Users.getProfile(player);
switch (type) {
case RETRO:
updateXpBarRetro(player, PP);
break;
case STANDARD:
updateXpBarStandard(player, PP);
break;
case SMALL:
updateXpBarStandard(player, PP);
break;
case DISABLED:
break;
default:
break;
}
}
/**
* Reset a player's HUD.
*/
public void resetHUD() {
SpoutPlayer sPlayer = SpoutStuff.getSpoutPlayer(playerName);
if (sPlayer != null) {
sPlayer.getMainScreen().removeWidgets(plugin);
//Reset the objects
xpbar = null;
xpfill = null;
xpbg = null;
xpicon = null;
sPlayer.getMainScreen().setDirty(true);
}
}
/**
* Initialize Retro XP bar.
*
* @param sPlayer Player to initialize XP bar for
*/
private void initializeXpBarDisplayRetro(SpoutPlayer sPlayer) {
Color border = new Color((float) LoadProperties.xpborder_r, (float) LoadProperties.xpborder_g, (float) LoadProperties.xpborder_b, 1f);
Color green = new Color(0f, 1f, 0f, 1f);
Color background = new Color((float) LoadProperties.xpbackground_r, (float) LoadProperties.xpbackground_g, (float) LoadProperties.xpbackground_b, 1f);
Color darkbg = new Color(0.2f, 0.2f, 0.2f, 1f);
xpicon = new GenericTexture();
xpbar = new GenericGradient();
xpfill = new GenericGradient();
xpbg = new GenericGradient();
xpicon_bg = new GenericGradient();
xpicon_border = new GenericGradient();
xpicon_bg.setBottomColor(darkbg);
xpicon_bg.setTopColor(darkbg);
xpicon_bg.setWidth(4);
xpicon_bg.setHeight(4);
xpicon_bg.setPriority(RenderPriority.High);
xpicon_bg.setX(142);
xpicon_bg.setY(10);
xpicon_bg.setDirty(true);
xpicon_border.setBottomColor(border);
xpicon_border.setTopColor(border);
xpicon_border.setWidth(6);
xpicon_border.setHeight(6);
xpicon_border.setPriority(RenderPriority.Highest);
xpicon_border.setX(141);
xpicon_border.setY(9);
xpicon_border.setDirty(true);
xpicon.setWidth(6);
xpicon.setHeight(6);
xpicon.setX(141);
xpicon.setY(9);
xpicon.setPriority(RenderPriority.Normal);
xpicon.setDirty(true);
xpicon.setUrl("Icon_r.png");
xpbar.setWidth(128);
xpbar.setHeight(4);
xpbar.setX(149);
xpbar.setY(10);
((GenericGradient) xpbar).setBottomColor(border);
((GenericGradient) xpbar).setTopColor(border);
xpbar.setPriority(RenderPriority.Highest);
xpbar.setDirty(true);
xpfill.setWidth(0);
xpfill.setHeight(2);
xpfill.setX(150);
xpfill.setY(11);
xpfill.setBottomColor(green);
xpfill.setTopColor(green);
xpfill.setPriority(RenderPriority.Lowest);
xpfill.setDirty(true);
xpbg.setWidth(126);
xpbg.setHeight(2);
xpbg.setX(150);
xpbg.setY(11);
xpbg.setBottomColor(background);
xpbg.setTopColor(background);
xpbg.setPriority(RenderPriority.Low);
xpbg.setDirty(true);
if (LoadProperties.xpbar) {
sPlayer.getMainScreen().attachWidget(plugin, xpbar);
sPlayer.getMainScreen().attachWidget(plugin, xpfill);
sPlayer.getMainScreen().attachWidget(plugin, xpbg);
if (LoadProperties.xpicon) {
sPlayer.getMainScreen().attachWidget(plugin, xpicon);
sPlayer.getMainScreen().attachWidget(plugin, xpicon_bg);
sPlayer.getMainScreen().attachWidget(plugin, xpicon_border);
}
}
sPlayer.getMainScreen().setDirty(true);
}
/**
* Initialize Standard XP bar.
*
* @param sPlayer Player to initialize XP bar for
*/
public void initializeXpBarDisplayStandard(SpoutPlayer sPlayer) {
if (LoadProperties.xpbar) {
xpbar = new GenericTexture();
((GenericTexture) xpbar).setUrl("xpbar_inc000.png");
xpbar.setX(LoadProperties.xpbar_x);
xpbar.setY(LoadProperties.xpbar_y);
xpbar.setHeight(8);
xpbar.setWidth(256);
sPlayer.getMainScreen().attachWidget(plugin, xpbar);
if (LoadProperties.xpicon) {
xpicon = new GenericTexture();
xpicon.setUrl("Icon.png");
xpicon.setHeight(16);
xpicon.setWidth(32);
xpicon.setX(LoadProperties.xpicon_x);
xpicon.setY(LoadProperties.xpicon_y);
xpicon.setDirty(true);
sPlayer.getMainScreen().attachWidget(plugin, xpicon);
}
}
sPlayer.getMainScreen().setDirty(true);
}
/**
* Initialize Small XP bar.
*
* @param sPlayer Player to initialize XP bar for
*/
private void initializeXpBarDisplaySmall(SpoutPlayer sPlayer) {
if (LoadProperties.xpbar) {
xpbar = new GenericTexture();
((GenericTexture)xpbar).setUrl("xpbar_inc000.png");
xpbar.setX(center_x - 64);
xpbar.setY(LoadProperties.xpbar_y);
xpbar.setHeight(4);
xpbar.setWidth(128);
sPlayer.getMainScreen().attachWidget(plugin, xpbar);
if (LoadProperties.xpicon) {
xpicon = new GenericTexture();
xpicon.setUrl("Icon.png");
xpicon.setHeight(8);
xpicon.setWidth(16);
xpicon.setX(center_x - (8 + 64));
xpicon.setY(LoadProperties.xpicon_y + 2);
xpicon.setDirty(true);
sPlayer.getMainScreen().attachWidget(plugin, xpicon);
}
}
sPlayer.getMainScreen().setDirty(true);
}
/**
* Update XP bar for Standard & Small styles.
*
* @param player Player whose XP bar to update
* @param PP Profile of the given player
*/
private void updateXpBarStandard(Player player, PlayerProfile PP) {
if (!LoadProperties.xpbar) {
return;
}
SkillType theType = getType(PP);
if (theType == null) { //Can this ever actually BE null? (Yes, it's null when the player has just logged in. It's not null when they gain XP in anything)
return;
}
((GenericTexture) xpicon).setUrl(m.getCapitalized(theType.toString()) + ".png");
xpicon.setDirty(true);
((GenericTexture) xpbar).setUrl(getUrlBar(getXpInc(PP.getSkillXpLevel(theType), PP.getXpToLevel(theType), HUDType.STANDARD)));
xpbar.setDirty(true);
SpoutManager.getPlayer(player).getMainScreen().setDirty(true);
}
/**
* Update XP bar for Retro styles.
*
* @param player Player whose XP bar to update
* @param PP Profile of the given player
*/
private void updateXpBarRetro(Player player, PlayerProfile PP) {
if (!LoadProperties.xpbar) {
return;
}
SkillType theType = getType(PP);
if (theType == null) { //Can this ever actually BE null? (Yes, it's null when the player has just logged in. It's not null when they gain XP in anything)
return;
}
Color color = getRetroColor(theType);
xpicon.setUrl(m.getCapitalized(theType.toString()) + "_r.png");
xpfill.setBottomColor(color);
xpfill.setTopColor(color);
xpfill.setWidth(getXpInc(PP.getSkillXpLevel(theType), PP.getXpToLevel(theType), HUDType.RETRO));
xpfill.setDirty(true);
SpoutManager.getPlayer(player).getMainScreen().setDirty(true);
}
((GenericTexture) xpbar).setUrl(getUrlBar(getXpInc(PP.getSkillXpLevel(theType), PP.getXpToLevel(theType), HUDType.STANDARD)));
xpbar.setDirty(true);
SpoutManager.getPlayer(player).getMainScreen().setDirty(true);
}
private void updateXpBarRetro(Player player, PlayerProfile PP)
{
if(!LoadProperties.xpbar)
return;
SkillType theType = null;
if(PP.getXpBarLocked() && PP.getSkillLock() != null)
theType=PP.getSkillLock();
else
theType=PP.getLastGained();
if(theType == null)
return;
Color color = getRetroColor(theType);
if(xpicon != null && theType != null)
xpicon.setUrl(m.getCapitalized(theType.toString())+"_r.png");
if(theType != null)
xpfill.setBottomColor(color).setTopColor(color).setWidth(getXpInc(PP.getSkillXpLevel(theType), PP.getXpToLevel(theType), HUDType.RETRO)).setDirty(true);
else
System.out.println("theType was null!");
SpoutManager.getPlayer(player).getMainScreen().setDirty(true);
}
private static Color getRetroColor(SkillType type) {
switch (type) {
case ACROBATICS:
return new Color((float) LoadProperties.acrobatics_r, (float) LoadProperties.acrobatics_g, (float) LoadProperties.acrobatics_b, 1f);
case ARCHERY:
return new Color((float) LoadProperties.archery_r, (float)LoadProperties.archery_g, (float)LoadProperties.archery_b, 1f);
return new Color((float) LoadProperties.archery_r, (float) LoadProperties.archery_g, (float) LoadProperties.archery_b, 1f);
case AXES:
return new Color((float) LoadProperties.axes_r, (float)LoadProperties.axes_g, (float)LoadProperties.axes_b, 1f);
return new Color((float) LoadProperties.axes_r, (float) LoadProperties.axes_g, (float) LoadProperties.axes_b, 1f);
case EXCAVATION:
return new Color((float)LoadProperties.excavation_r, (float)LoadProperties.excavation_g, (float)LoadProperties.excavation_b, 1f);
return new Color((float) LoadProperties.excavation_r, (float) LoadProperties.excavation_g, (float) LoadProperties.excavation_b, 1f);
case HERBALISM:
return new Color((float)LoadProperties.herbalism_r, (float)LoadProperties.herbalism_g, (float)LoadProperties.herbalism_b, 1f);
return new Color((float) LoadProperties.herbalism_r, (float) LoadProperties.herbalism_g, (float) LoadProperties.herbalism_b, 1f);
case MINING:
return new Color((float)LoadProperties.mining_r, (float)LoadProperties.mining_g, (float)LoadProperties.mining_b, 1f);
return new Color((float) LoadProperties.mining_r, (float) LoadProperties.mining_g, (float) LoadProperties.mining_b, 1f);
case REPAIR:
return new Color((float)LoadProperties.repair_r, (float)LoadProperties.repair_g, (float)LoadProperties.repair_b, 1f);
return new Color((float) LoadProperties.repair_r, (float) LoadProperties.repair_g, (float) LoadProperties.repair_b, 1f);
case SWORDS:
return new Color((float)LoadProperties.swords_r, (float)LoadProperties.swords_g, (float)LoadProperties.swords_b, 1f);
return new Color((float) LoadProperties.swords_r, (float) LoadProperties.swords_g, (float) LoadProperties.swords_b, 1f);
case TAMING:
return new Color((float)LoadProperties.taming_r, (float)LoadProperties.taming_g, (float)LoadProperties.taming_b, 1f);
return new Color((float) LoadProperties.taming_r, (float) LoadProperties.taming_g, (float) LoadProperties.taming_b, 1f);
case UNARMED:
return new Color((float)LoadProperties.unarmed_r, (float)LoadProperties.unarmed_g, (float)LoadProperties.unarmed_b, 1f);
return new Color((float) LoadProperties.unarmed_r, (float) LoadProperties.unarmed_g, (float) LoadProperties.unarmed_b, 1f);
case WOODCUTTING:
return new Color((float)LoadProperties.woodcutting_r, (float)LoadProperties.woodcutting_g, (float)LoadProperties.woodcutting_b, 1f);
return new Color((float) LoadProperties.woodcutting_r, (float) LoadProperties.woodcutting_g, (float) LoadProperties.woodcutting_b, 1f);
case FISHING:
return new Color((float)LoadProperties.fishing_r, (float)LoadProperties.fishing_g, (float)LoadProperties.fishing_b, 1f);
return new Color((float) LoadProperties.fishing_r, (float) LoadProperties.fishing_g, (float) LoadProperties.fishing_b, 1f);
default:
return new Color(0.3f, 0.3f, 0.75f, 1f);
}
@@ -305,13 +373,13 @@ public class HUDmmo
switch (num.length) {
case 1:
return "xpbar_inc00"+number+".png";
return "xpbar_inc00" + number + ".png";
case 2:
return "xpbar_inc0"+number+".png";
return "xpbar_inc0" + number + ".png";
default:
return "xpbar_inc"+number+".png";
return "xpbar_inc" + number + ".png";
}
}
@@ -334,4 +402,13 @@ public class HUDmmo
return (int) (percentage / inc);
}
}
private static SkillType getType(PlayerProfile PP) {
if (PP.getXpBarLocked()) {
return PP.getSkillLock();
}
else {
return PP.getLastGained();
}
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -2,95 +2,130 @@ package com.gmail.nossr50.datatypes;
import org.bukkit.entity.Player;
import com.gmail.nossr50.Users;
import com.gmail.nossr50.mcPermissions;
import com.gmail.nossr50.config.LoadProperties;
public enum SkillType
{
ACROBATICS(LoadProperties.levelCapAcrobatics),
ALL, //This one is just for convenience
ARCHERY(LoadProperties.levelCapArchery),
AXES(AbilityType.SKULL_SPLIITER, LoadProperties.levelCapAxes, ToolType.AXE),
EXCAVATION(AbilityType.GIGA_DRILL_BREAKER, LoadProperties.levelCapExcavation, ToolType.SHOVEL),
FISHING(LoadProperties.levelCapFishing),
HERBALISM(AbilityType.GREEN_TERRA, LoadProperties.levelCapHerbalism, ToolType.HOE),
MINING(AbilityType.SUPER_BREAKER, LoadProperties.levelCapMining, ToolType.PICKAXE),
REPAIR(LoadProperties.levelCapRepair),
SWORDS(AbilityType.SERRATED_STRIKES, LoadProperties.levelCapSwords, ToolType.SWORD),
TAMING(LoadProperties.levelCapTaming),
UNARMED(AbilityType.BERSERK, LoadProperties.levelCapUnarmed, ToolType.FISTS),
WOODCUTTING(AbilityType.TREE_FELLER, LoadProperties.levelCapWoodcutting, ToolType.AXE);
private AbilityType ability;
private int maxLevel;
private ToolType tool;
private SkillType()
{
this.ability = null;
this.maxLevel = 0;
this.tool = null;
}
private SkillType(AbilityType ability, int maxLevel, ToolType tool)
{
this.ability = ability;
this.maxLevel = maxLevel;
this.tool = tool;
}
private SkillType(int maxLevel)
{
this(null, maxLevel, null);
}
public AbilityType getAbility()
{
return this.ability;
}
public int getMaxLevel()
{
if(maxLevel > 0)
return maxLevel;
else
return Integer.MAX_VALUE;
}
public ToolType getTool()
{
return this.tool;
}
public boolean getPermissions(Player player)
{
switch(this)
{
case ACROBATICS:
return mcPermissions.getInstance().acrobatics(player);
case ARCHERY:
return mcPermissions.getInstance().archery(player);
case AXES:
return mcPermissions.getInstance().axes(player);
case EXCAVATION:
return mcPermissions.getInstance().excavation(player);
case FISHING:
return mcPermissions.getInstance().fishing(player);
case HERBALISM:
return mcPermissions.getInstance().herbalism(player);
case MINING:
return mcPermissions.getInstance().mining(player);
case REPAIR:
return mcPermissions.getInstance().repair(player);
case SWORDS:
return mcPermissions.getInstance().swords(player);
case TAMING:
return mcPermissions.getInstance().taming(player);
case UNARMED:
return mcPermissions.getInstance().unarmed(player);
case WOODCUTTING:
return mcPermissions.getInstance().woodcutting(player);
}
return false;
}
public enum SkillType {
ACROBATICS(LoadProperties.levelCapAcrobatics, LoadProperties.acrobaticsxpmodifier),
ALL, //This one is just for convenience
ARCHERY(LoadProperties.levelCapArchery, LoadProperties.archeryxpmodifier),
AXES(AbilityType.SKULL_SPLIITER, LoadProperties.levelCapAxes, ToolType.AXE, LoadProperties.axesxpmodifier),
EXCAVATION(AbilityType.GIGA_DRILL_BREAKER, LoadProperties.levelCapExcavation, ToolType.SHOVEL, LoadProperties.excavationxpmodifier),
FISHING(LoadProperties.levelCapFishing, LoadProperties.fishingxpmodifier),
HERBALISM(AbilityType.GREEN_TERRA, LoadProperties.levelCapHerbalism, ToolType.HOE, LoadProperties.herbalismxpmodifier),
MINING(AbilityType.SUPER_BREAKER, LoadProperties.levelCapMining, ToolType.PICKAXE, LoadProperties.miningxpmodifier),
REPAIR(LoadProperties.levelCapRepair, LoadProperties.repairxpmodifier),
SWORDS(AbilityType.SERRATED_STRIKES, LoadProperties.levelCapSwords, ToolType.SWORD, LoadProperties.swordsxpmodifier),
TAMING(LoadProperties.levelCapTaming, LoadProperties.tamingxpmodifier),
UNARMED(AbilityType.BERSERK, LoadProperties.levelCapUnarmed, ToolType.FISTS, LoadProperties.unarmedxpmodifier),
WOODCUTTING(AbilityType.TREE_FELLER, LoadProperties.levelCapWoodcutting, ToolType.AXE, LoadProperties.woodcuttingxpmodifier);
private AbilityType ability;
private int maxLevel;
private ToolType tool;
private double xpModifier;
private SkillType() {
this.ability = null;
this.maxLevel = 0;
this.tool = null;
this.xpModifier = 0;
}
private SkillType(AbilityType ability, int maxLevel, ToolType tool, double xpModifier) {
this.ability = ability;
this.maxLevel = maxLevel;
this.tool = tool;
this.xpModifier = xpModifier;
}
private SkillType(int maxLevel, double xpModifier) {
this(null, maxLevel, null, xpModifier);
}
public AbilityType getAbility() {
return ability;
}
/**
* Get the max level of this skill.
*
* @return the max level of this skill
*/
public int getMaxLevel() {
if (maxLevel > 0) {
return maxLevel;
}
else {
return Integer.MAX_VALUE;
}
}
public ToolType getTool() {
return tool;
}
/**
* Get the base permissions associated with this skill.
*
* @param player The player to check the permissions for
* @return true if the player has permissions, false otherwise
*/
public boolean getPermissions(Player player) {
switch (this) {
case ACROBATICS:
return mcPermissions.getInstance().acrobatics(player);
case ARCHERY:
return mcPermissions.getInstance().archery(player);
case AXES:
return mcPermissions.getInstance().axes(player);
case EXCAVATION:
return mcPermissions.getInstance().excavation(player);
case FISHING:
return mcPermissions.getInstance().fishing(player);
case HERBALISM:
return mcPermissions.getInstance().herbalism(player);
case MINING:
return mcPermissions.getInstance().mining(player);
case REPAIR:
return mcPermissions.getInstance().repair(player);
case SWORDS:
return mcPermissions.getInstance().swords(player);
case TAMING:
return mcPermissions.getInstance().taming(player);
case UNARMED:
return mcPermissions.getInstance().unarmed(player);
case WOODCUTTING:
return mcPermissions.getInstance().woodcutting(player);
default:
return false;
}
}
public double getXpModifier() {
return xpModifier;
}
/**
* Get the skill level for this skill.
*
* @param player The player to check
* @return
*/
public int getSkillLevel(Player player) {
return Users.getProfile(player).getSkillLevel(this);
}
}

View File

@@ -6,142 +6,58 @@ import org.bukkit.inventory.ItemStack;
import com.gmail.nossr50.ItemChecks;
import com.gmail.nossr50.locale.mcLocale;
public enum ToolType
{
AXE(mcLocale.getString("Skills.LowerAxe"), mcLocale.getString("Skills.ReadyAxe")),
FISTS(mcLocale.getString("Skills.LowerFists"), mcLocale.getString("Skills.ReadyFists")),
HOE(mcLocale.getString("Skills.LowerHoe"), mcLocale.getString("Skills.ReadyHoe")),
PICKAXE(mcLocale.getString("Skills.LowerPickAxe"), mcLocale.getString("Skills.ReadyPickAxe")),
SHOVEL(mcLocale.getString("Skills.LowerShovel"), mcLocale.getString("Skills.ReadyShovel")),
SWORD(mcLocale.getString("Skills.LowerSword"), mcLocale.getString("Skills.ReadySword"));
private String lowerTool;
private String raiseTool;
private ToolType(String lowerTool, String raiseTool)
{
this.lowerTool = lowerTool;
this.raiseTool = raiseTool;
}
public String getLowerTool()
{
return this.lowerTool;
}
public String getRaiseTool()
{
return this.raiseTool;
}
public boolean getToolMode(PlayerProfile PP)
{
switch(this)
{
case AXE:
return PP.getAxePreparationMode();
case FISTS:
return PP.getFistsPreparationMode();
case HOE:
return PP.getHoePreparationMode();
case PICKAXE:
return PP.getPickaxePreparationMode();
case SHOVEL:
return PP.getShovelPreparationMode();
case SWORD:
return PP.getSwordsPreparationMode();
}
return false;
}
public void setToolMode(PlayerProfile PP, boolean bool)
{
switch(this)
{
case AXE:
PP.setAxePreparationMode(bool);
break;
case FISTS:
PP.setFistsPreparationMode(bool);
break;
case HOE:
PP.setHoePreparationMode(bool);
break;
case PICKAXE:
PP.setPickaxePreparationMode(bool);
break;
case SHOVEL:
PP.setShovelPreparationMode(bool);
break;
case SWORD:
PP.setSwordsPreparationMode(bool);
break;
}
}
public long getToolATS(PlayerProfile PP)
{
switch(this)
{
case AXE:
return PP.getAxePreparationATS();
case FISTS:
return PP.getFistsPreparationATS();
case HOE:
return PP.getHoePreparationATS();
case PICKAXE:
return PP.getPickaxePreparationATS();
case SHOVEL:
return PP.getShovelPreparationATS();
case SWORD:
return PP.getSwordsPreparationATS();
}
return 0;
}
public void setToolATS(PlayerProfile PP, long ats)
{
switch(this)
{
case AXE:
PP.setAxePreparationATS(ats);
break;
case FISTS:
PP.setFistsPreparationATS(ats);
break;
case HOE:
PP.setHoePreparationATS(ats);
break;
case PICKAXE:
PP.setPickaxePreparationATS(ats);
break;
case SHOVEL:
PP.setShovelPreparationATS(ats);
break;
case SWORD:
PP.setSwordsPreparationATS(ats);
break;
}
}
public boolean inHand(ItemStack is)
{
switch(this)
{
case AXE:
return ItemChecks.isAxe(is);
case FISTS:
return is.getType().equals(Material.AIR);
case HOE:
return ItemChecks.isHoe(is);
case PICKAXE:
return ItemChecks.isMiningPick(is);
case SHOVEL:
return ItemChecks.isShovel(is);
case SWORD:
return ItemChecks.isSword(is);
}
return false;
}
public enum ToolType {
AXE(mcLocale.getString("Skills.LowerAxe"), mcLocale.getString("Skills.ReadyAxe")),
FISTS(mcLocale.getString("Skills.LowerFists"), mcLocale.getString("Skills.ReadyFists")),
HOE(mcLocale.getString("Skills.LowerHoe"), mcLocale.getString("Skills.ReadyHoe")),
PICKAXE(mcLocale.getString("Skills.LowerPickAxe"), mcLocale.getString("Skills.ReadyPickAxe")),
SHOVEL(mcLocale.getString("Skills.LowerShovel"), mcLocale.getString("Skills.ReadyShovel")),
SWORD(mcLocale.getString("Skills.LowerSword"), mcLocale.getString("Skills.ReadySword"));
private String lowerTool;
private String raiseTool;
private ToolType(String lowerTool, String raiseTool) {
this.lowerTool = lowerTool;
this.raiseTool = raiseTool;
}
public String getLowerTool() {
return lowerTool;
}
public String getRaiseTool() {
return raiseTool;
}
/**
* Check to see if the item is of the appropriate type.
*
* @param is The item to check
* @return true if the item is the right type, false otherwise
*/
public boolean inHand(ItemStack is) {
switch (this) {
case AXE:
return ItemChecks.isAxe(is);
case FISTS:
return is.getType().equals(Material.AIR);
case HOE:
return ItemChecks.isHoe(is);
case PICKAXE:
return ItemChecks.isMiningPick(is);
case SHOVEL:
return ItemChecks.isShovel(is);
case SWORD:
return ItemChecks.isSword(is);
default:
return false;
}
}
}

View File

@@ -8,8 +8,6 @@ public class Tree {
private TreeNode root = null;
public Tree(){}
/**
* Add a node to this tree.
*
@@ -33,12 +31,12 @@ public class Tree {
public PlayerStat[] inOrder() {
if (root != null) {
ArrayList<PlayerStat> order = root.inOrder(new ArrayList<PlayerStat>());
return order.toArray(new PlayerStat[order.size()]);
}
else {
/* Throw some dummy info in case the users file is empty.
/*
* Throw some dummy info in case the users file is empty.
* It's not a good fix but its better than rewriting the whole system.
*/
ArrayList<PlayerStat> x = new ArrayList<PlayerStat>();

View File

@@ -4,46 +4,49 @@ import java.util.ArrayList;
import com.gmail.nossr50.datatypes.PlayerStat;
public class TreeNode
{
TreeNode left = null
, right = null;
PlayerStat ps = new PlayerStat();
public class TreeNode {
TreeNode left = null;
TreeNode right = null;
PlayerStat ps = new PlayerStat();
public TreeNode(String p, int in) {ps.statVal = in; ps.name = p;}
public TreeNode(String p, int in) {
ps.statVal = in;
ps.name = p;
}
public void add (String p, int in)
{
if (in >= ps.statVal)
{
if (left == null)
left = new TreeNode(p,in);
else
left.add(p, in);
}
else if(in < ps.statVal)
{
if (right == null)
right = new TreeNode(p,in);
else
right.add(p, in);
}
}
public ArrayList<PlayerStat> inOrder(ArrayList<PlayerStat> a)
{
//if left node is not null than assign arrayList(a) to left.inOrder()
//GOES THROUGH THE ENTIRE LEFT BRANCH AND GRABS THE GREATEST NUMBER
if(left != null)
a = left.inOrder(a);
a.add(ps);
if(right != null)
a = right.inOrder(a);
return a;
}
public void add (String p, int in) {
if (in >= ps.statVal) {
if (left == null) {
left = new TreeNode(p, in);
}
else {
left.add(p, in);
}
}
else if(in < ps.statVal) {
if (right == null) {
right = new TreeNode(p, in);
}
else {
right.add(p, in);
}
}
}
public ArrayList<PlayerStat> inOrder(ArrayList<PlayerStat> a) {
//if left node is not null than assign arrayList(a) to left.inOrder()
//GOES THROUGH THE ENTIRE LEFT BRANCH AND GRABS THE GREATEST NUMBER
if (left != null) {
a = left.inOrder(a);
}
a.add(ps);
if (right != null) {
a = right.inOrder(a);
}
return a;
}
}

View File

@@ -2,12 +2,12 @@ package com.gmail.nossr50.datatypes.buttons;
import org.getspout.spoutapi.gui.GenericButton;
public class ButtonEscape extends GenericButton
{
public ButtonEscape()
{
this.setText("EXIT");
this.setWidth(60).setHeight(20);
this.setDirty(true);
}
}
public class ButtonEscape extends GenericButton {
public ButtonEscape() {
this.setText("EXIT");
this.setWidth(60);
this.setHeight(20);
this.setDirty(true);
}
}

View File

@@ -1,21 +1,14 @@
package com.gmail.nossr50.datatypes.buttons;
import org.getspout.spoutapi.gui.GenericButton;
import com.gmail.nossr50.datatypes.PlayerProfile;
public class ButtonHUDStyle extends GenericButton
{
public ButtonHUDStyle(PlayerProfile PP)
{
this.setText("HUD Type: "+PP.getHUDType().toString());
this.setTooltip("Change your HUD style!");
this.setWidth(120).setHeight(20);
this.setDirty(true);
}
public void updateText(PlayerProfile PP)
{
this.setText("HUD Type: "+PP.getHUDType().toString());
this.setDirty(true);
}
}
public class ButtonHUDStyle extends ButtonToggle {
public ButtonHUDStyle(PlayerProfile PP) {
super("HUD Type: ", PP.getHUDType().toString(), "Change your HUD style!"); //TODO: Needs more locale
}
public void updateText(PlayerProfile PP) {
super.updateText("HUD Type: ", PP.getHUDType().toString()); //TODO: Needs more locale
}
}

View File

@@ -1,21 +1,14 @@
package com.gmail.nossr50.datatypes.buttons;
import org.getspout.spoutapi.gui.GenericButton;
import com.gmail.nossr50.datatypes.PlayerProfile;
public class ButtonPartyToggle extends GenericButton
{
public ButtonPartyToggle(PlayerProfile PP)
{
this.setText("Party HUD: "+PP.getPartyHUD());
this.setTooltip("Toggle the Party HUD!");
this.setWidth(120).setHeight(20);
this.setDirty(true);
}
public void updateText(PlayerProfile PP)
{
this.setText("Party HUD: "+PP.getPartyHUD());
this.setDirty(true);
}
}
public class ButtonPartyToggle extends ButtonToggle {
public ButtonPartyToggle(PlayerProfile PP) {
super("Party HUD: ", ((Boolean) PP.getPartyHUD()).toString(), "Toggle the Party HUD!"); //TODO: Needs more locale
}
public void updateText(PlayerProfile PP) {
super.updateText("Party HUD: ", ((Boolean) PP.getPartyHUD()).toString()); //TODO: Needs more locale
}
}

View File

@@ -0,0 +1,19 @@
package com.gmail.nossr50.datatypes.buttons;
import org.getspout.spoutapi.gui.GenericButton;
public class ButtonToggle extends GenericButton{
public ButtonToggle(String text1, String text2, String tooltip) {
this.setText(text1 + text2);
this.setTooltip(tooltip);
this.setWidth(120);
this.setHeight(20);
this.setDirty(true);
}
public void updateText(String text1, String text2) {
this.setText(text1 + text2);
this.setDirty(true);
}
}

View File

@@ -11,49 +11,58 @@ import com.gmail.nossr50.datatypes.buttons.ButtonEscape;
import com.gmail.nossr50.datatypes.buttons.ButtonHUDStyle;
import com.gmail.nossr50.datatypes.buttons.ButtonPartyToggle;
public class PopupMMO extends GenericPopup
{
ButtonHUDStyle HUDButton = null;
ButtonPartyToggle PartyButton = null;
ButtonEscape EscapeButton = null;
GenericLabel mcMMO_label = new GenericLabel();
GenericLabel tip_escape = new GenericLabel();
int center_x = 427/2;
int center_y = 240/2;
public PopupMMO(Player player, PlayerProfile PP, mcMMO plugin)
{
//240, 427 are the bottom right
mcMMO_label.setText(ChatColor.GOLD+"~mcMMO Menu~");
mcMMO_label.setX(center_x-35).setY((center_y/2)-20).setDirty(true);
tip_escape.setText(ChatColor.GRAY+"Press ESCAPE to exit!");
tip_escape.setX(mcMMO_label.getX()-15).setY(mcMMO_label.getY()+10).setDirty(true);
HUDButton = new ButtonHUDStyle(PP);
HUDButton.setX(center_x-(HUDButton.getWidth()/2)).setY(center_y/2).setDirty(true);
if(LoadProperties.partybar)
{
PartyButton = new ButtonPartyToggle(PP);
PartyButton.setX(center_x-(PartyButton.getWidth()/2)).setY(center_y/2+PartyButton.getHeight()).setDirty(true);
this.attachWidget(plugin, PartyButton);
}
EscapeButton = new ButtonEscape();
EscapeButton.setX(center_x-(EscapeButton.getWidth()/2)).setY((center_y/2)+(HUDButton.getHeight()*2)+5).setDirty(true);
this.attachWidget(plugin, HUDButton);
this.attachWidget(plugin, mcMMO_label);
this.attachWidget(plugin, tip_escape);
this.attachWidget(plugin, EscapeButton);
this.setDirty(true);
}
public void updateButtons(PlayerProfile PP)
{
HUDButton.updateText(PP);
this.setDirty(true);
}
public class PopupMMO extends GenericPopup {
private ButtonHUDStyle HUDButton = null;
private ButtonPartyToggle PartyButton = null;
private ButtonEscape EscapeButton = null;
private GenericLabel mcMMO_label = new GenericLabel();
private GenericLabel tip_escape = new GenericLabel();
private int center_x = 427 / 2;
private int center_y = 240 / 2;
public PopupMMO(Player player, PlayerProfile PP, mcMMO plugin) {
//240, 427 are the bottom right
mcMMO_label.setText(ChatColor.GOLD + "~mcMMO Menu~"); //TODO: Needs more locale
mcMMO_label.setX(center_x - 35);
mcMMO_label.setY((center_y / 2) - 20);
mcMMO_label.setDirty(true);
tip_escape.setText(ChatColor.GRAY + "Press ESCAPE to exit!"); //TODO: Needs more locale
tip_escape.setX(mcMMO_label.getX() - 15);
tip_escape.setY(mcMMO_label.getY() + 10);
tip_escape.setDirty(true);
HUDButton = new ButtonHUDStyle(PP);
HUDButton.setX(center_x - (HUDButton.getWidth() / 2));
HUDButton.setY(center_y / 2);
HUDButton.setDirty(true);
if (LoadProperties.partybar) {
PartyButton = new ButtonPartyToggle(PP);
PartyButton.setX(center_x - (PartyButton.getWidth() / 2));
PartyButton.setY((center_y / 2) + PartyButton.getHeight());
PartyButton.setDirty(true);
this.attachWidget(plugin, PartyButton);
}
EscapeButton = new ButtonEscape();
EscapeButton.setX(center_x - (EscapeButton.getWidth() / 2));
EscapeButton.setY((center_y / 2) + (HUDButton.getHeight() * 2) + 5);
EscapeButton.setDirty(true);
this.attachWidget(plugin, HUDButton);
this.attachWidget(plugin, mcMMO_label);
this.attachWidget(plugin, tip_escape);
this.attachWidget(plugin, EscapeButton);
this.setDirty(true);
}
public void updateButtons(PlayerProfile PP) {
HUDButton.updateText(PP);
PartyButton.updateText(PP);
this.setDirty(true);
}
}

View File

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

View File

@@ -3,18 +3,18 @@ package com.gmail.nossr50.datatypes.treasure;
import org.bukkit.inventory.ItemStack;
public class FishingTreasure extends Treasure {
private int maxLevel;
private int maxLevel;
public FishingTreasure(ItemStack drop, int xp, Double dropChance, int dropLevel, int maxLevel) {
super(drop, xp, dropChance, dropLevel);
this.setMaxLevel(maxLevel);
}
public FishingTreasure(ItemStack drop, int xp, Double dropChance, int dropLevel, int maxLevel) {
super(drop, xp, dropChance, dropLevel);
this.setMaxLevel(maxLevel);
}
public int getMaxLevel() {
return maxLevel;
}
public int getMaxLevel() {
return maxLevel;
}
public void setMaxLevel(int maxLevel) {
this.maxLevel = maxLevel;
}
public void setMaxLevel(int maxLevel) {
this.maxLevel = maxLevel;
}
}

View File

@@ -3,48 +3,47 @@ package com.gmail.nossr50.datatypes.treasure;
import org.bukkit.inventory.ItemStack;
public abstract class Treasure {
private int xp;
private Double dropChance;
private int dropLevel;
private int xp;
private Double dropChance;
private int dropLevel;
private ItemStack drop;
private ItemStack drop;
public Treasure(ItemStack drop, int xp, Double dropChance, int dropLevel) {
this.drop = drop;
this.xp = xp;
this.dropChance = dropChance;
this.dropLevel = dropLevel;
}
public Treasure(ItemStack drop, int xp, Double dropChance, int dropLevel) {
this.drop = drop;
this.xp = xp;
this.dropChance = dropChance;
this.dropLevel = dropLevel;
}
public ItemStack getDrop() {
return drop;
}
public ItemStack getDrop() {
return drop;
}
public void setDrop(ItemStack drop) {
this.drop = drop;
}
public void setDrop(ItemStack drop) {
this.drop = drop;
}
public int getXp() {
return xp;
}
public int getXp() {
return xp;
}
public void setXp(int xp) {
this.xp = xp;
}
public void setXp(int xp) {
this.xp = xp;
}
public Double getDropChance() {
return dropChance;
}
public Double getDropChance() {
return dropChance;
}
public void setDropChance(Double dropChance) {
this.dropChance = dropChance;
}
public void setDropChance(Double dropChance) {
this.dropChance = dropChance;
}
public int getDropLevel() {
return dropLevel;
}
public int getDropLevel() {
return dropLevel;
}
public void setDropLevel(int dropLevel) {
this.dropLevel = dropLevel;
}
public void setDropLevel(int dropLevel) {
this.dropLevel = dropLevel;
}
}

View File

@@ -1,15 +0,0 @@
package com.gmail.nossr50.events;
import java.util.ArrayList;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.inventory.ItemStack;
public class FakeBlockBreakEvent extends BlockBreakEvent {
public FakeBlockBreakEvent(Block theBlock, Player player) {
super(theBlock, player, new ArrayList<ItemStack>(theBlock.getDrops()));
}
}

View File

@@ -1,10 +0,0 @@
package com.gmail.nossr50.events;
import org.bukkit.entity.Entity;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
public class FakeEntityDamageByEntityEvent extends EntityDamageByEntityEvent {
public FakeEntityDamageByEntityEvent(Entity damager, Entity damagee, DamageCause cause, int damage) {
super(damager, damagee, cause, damage);
}
}

View File

@@ -1,72 +0,0 @@
package com.gmail.nossr50.events;
import org.bukkit.Location;
import org.bukkit.event.Cancellable;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
import org.bukkit.inventory.ItemStack;
/**
* Called when mcMMO is preparing to drop an item
*/
public class McMMOItemSpawnEvent extends Event implements Cancellable {
private Location location;
private ItemStack itemStack;
private boolean cancelled;
public McMMOItemSpawnEvent(Location location, ItemStack itemStack) {
this.location = location;
this.itemStack = itemStack;
this.cancelled = false;
}
/**
* @return Location where the item will be dropped
*/
public Location getLocation() {
return location;
}
/**
* @param location Location where to drop the item
*/
public void setLocation(Location location) {
this.location = location;
}
/**
* @return ItemStack that will be dropped
*/
public ItemStack getItemStack() {
return itemStack;
}
/**
* @param itemStack ItemStack to drop
*/
public void setItemStack(ItemStack itemStack) {
this.itemStack = itemStack;
}
/** Following are required for Cancellable **/
@Override
public boolean isCancelled() {
return cancelled;
}
@Override
public void setCancelled(boolean cancelled) {
this.cancelled = cancelled;
}
/** Rest of file is required boilerplate for custom events **/
private static final HandlerList handlers = new HandlerList();
public HandlerList getHandlers() {
return handlers;
}
public static HandlerList getHandlerList() {
return handlers;
}
}

View File

@@ -1,54 +0,0 @@
package com.gmail.nossr50.events;
import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
import com.gmail.nossr50.datatypes.SkillType;
/**
* Called when a user levels up in a skill
*/
public class McMMOPlayerLevelUpEvent extends Event {
private Player player;
private SkillType skill;
private int levelsGained;
public McMMOPlayerLevelUpEvent(Player player, SkillType skill) {
this.player = player;
this.skill = skill;
this.levelsGained = 1; // Always 1 for now as we call in the loop where the levelups are calculated, could change later!
}
/**
* @return Player leveling up
*/
public Player getPlayer() {
return player;
}
/**
* @return SkillType that is being leveled up
*/
public SkillType getSkill() {
return skill;
}
/**
* @return The number of levels gained in this event
*/
public int getLevelsGained() {
return levelsGained;
}
/** Rest of file is required boilerplate for custom events **/
private static final HandlerList handlers = new HandlerList();
public HandlerList getHandlers() {
return handlers;
}
public static HandlerList getHandlerList() {
return handlers;
}
}

View File

@@ -1,51 +0,0 @@
package com.gmail.nossr50.events;
import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
import com.gmail.nossr50.datatypes.SkillType;
public class McMMOPlayerXpGainEvent extends Event {
private Player player;
private SkillType skill;
private int xpGained;
public McMMOPlayerXpGainEvent(Player player, SkillType skill, int xpGained) {
this.player = player;
this.skill = skill;
this.xpGained = xpGained;
}
/**
* @return Player gaining experience (can be null)
*/
public Player getPlayer() {
return player;
}
/**
* @return SkillType that is gaining experience
*/
public SkillType getSkill() {
return skill;
}
/**
* @return The number experience gained in this event
*/
public int getXpGained() {
return xpGained;
}
/** Rest of file is required boilerplate for custom events **/
private static final HandlerList handlers = new HandlerList();
public HandlerList getHandlers() {
return handlers;
}
public static HandlerList getHandlerList() {
return handlers;
}
}

View File

@@ -0,0 +1,47 @@
package com.gmail.nossr50.events.experience;
import org.bukkit.entity.Player;
import org.bukkit.event.HandlerList;
import org.bukkit.event.player.PlayerEvent;
import com.gmail.nossr50.datatypes.SkillType;
/**
* Generic event for mcMMO experience events.
*/
public class McMMOPlayerExperienceEvent extends PlayerEvent {
protected SkillType skill;
protected int skillLevel;
public McMMOPlayerExperienceEvent(Player player, SkillType skill) {
super(player);
this.skill = skill;
this.skillLevel = skill.getSkillLevel(player);
}
/**
* @return The skill involved in this event
*/
public SkillType getSkill() {
return skill;
}
/**
* @return The skill level of the skill involved in this event
*/
public int getSkillLevel() {
return skillLevel;
}
/** Rest of file is required boilerplate for custom events **/
private static final HandlerList handlers = new HandlerList();
@Override
public HandlerList getHandlers() {
return handlers;
}
public static HandlerList getHandlerList() {
return handlers;
}
}

View File

@@ -0,0 +1,24 @@
package com.gmail.nossr50.events.experience;
import org.bukkit.entity.Player;
import com.gmail.nossr50.datatypes.SkillType;
/**
* Called when a user levels up in a skill
*/
public class McMMOPlayerLevelUpEvent extends McMMOPlayerExperienceEvent {
private int levelsGained;
public McMMOPlayerLevelUpEvent(Player player, SkillType skill) {
super(player, skill);
this.levelsGained = 1; // Always 1 for now as we call in the loop where the levelups are calculated, could change later!
}
/**
* @return The number of levels gained in this event
*/
public int getLevelsGained() {
return levelsGained;
}
}

View File

@@ -0,0 +1,24 @@
package com.gmail.nossr50.events.experience;
import org.bukkit.entity.Player;
import com.gmail.nossr50.datatypes.SkillType;
/**
* Called when a player gains XP in a skill
*/
public class McMMOPlayerXpGainEvent extends McMMOPlayerExperienceEvent {
private int xpGained;
public McMMOPlayerXpGainEvent(Player player, SkillType skill, int xpGained) {
super(player, skill);
this.xpGained = xpGained;
}
/**
* @return The amount of experience gained in this event
*/
public int getXpGained() {
return xpGained;
}
}

View File

@@ -0,0 +1,15 @@
package com.gmail.nossr50.events.fake;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.event.block.BlockBreakEvent;
/**
* Called when mcMMO breaks a block due to a special ability.
*/
public class FakeBlockBreakEvent extends BlockBreakEvent {
public FakeBlockBreakEvent(Block theBlock, Player player) {
super(theBlock, player);
}
}

View File

@@ -0,0 +1,14 @@
package com.gmail.nossr50.events.fake;
import org.bukkit.entity.Entity;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
/**
* Called when mcMMO applies damage from an entity due to special abilities.
*/
public class FakeEntityDamageByEntityEvent extends EntityDamageByEntityEvent {
public FakeEntityDamageByEntityEvent(Entity damager, Entity damagee, DamageCause cause, int damage) {
super(damager, damagee, cause, damage);
}
}

View File

@@ -1,10 +1,14 @@
package com.gmail.nossr50.events;
package com.gmail.nossr50.events.fake;
import org.bukkit.entity.Entity;
import org.bukkit.event.entity.EntityDamageEvent;
public class FakeEntityDamageEvent extends EntityDamageEvent{
/**
* Called when mcMMO applies damage due to special abilities.
*/
public class FakeEntityDamageEvent extends EntityDamageEvent {
public FakeEntityDamageEvent(Entity damagee, DamageCause cause, int damage) {
super(damagee, cause, damage);
}
}
}

View File

@@ -0,0 +1,14 @@
package com.gmail.nossr50.events.fake;
import org.bukkit.entity.Player;
import org.bukkit.event.player.PlayerAnimationEvent;
/**
* Called when handling extra drops to avoid issues with NoCheat.
*/
public class FakePlayerAnimationEvent extends PlayerAnimationEvent {
public FakePlayerAnimationEvent(Player player) {
super(player);
}
}

View File

@@ -0,0 +1,72 @@
package com.gmail.nossr50.events.items;
import org.bukkit.Location;
import org.bukkit.event.Cancellable;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
import org.bukkit.inventory.ItemStack;
/**
* Called when mcMMO is preparing to drop an item.
*/
public class McMMOItemSpawnEvent extends Event implements Cancellable {
private Location location;
private ItemStack itemStack;
private boolean cancelled;
public McMMOItemSpawnEvent(Location location, ItemStack itemStack) {
this.location = location;
this.itemStack = itemStack;
this.cancelled = false;
}
/**
* @return Location where the item will be dropped
*/
public Location getLocation() {
return location;
}
/**
* @param location Location where to drop the item
*/
public void setLocation(Location location) {
this.location = location;
}
/**
* @return ItemStack that will be dropped
*/
public ItemStack getItemStack() {
return itemStack;
}
/**
* @param itemStack ItemStack to drop
*/
public void setItemStack(ItemStack itemStack) {
this.itemStack = itemStack;
}
/** Following are required for Cancellable **/
@Override
public boolean isCancelled() {
return cancelled;
}
@Override
public void setCancelled(boolean cancelled) {
this.cancelled = cancelled;
}
/** Rest of file is required boilerplate for custom events **/
private static final HandlerList handlers = new HandlerList();
public HandlerList getHandlers() {
return handlers;
}
public static HandlerList getHandlerList() {
return handlers;
}
}

View File

@@ -0,0 +1,104 @@
package com.gmail.nossr50.events.party;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
import org.bukkit.event.player.PlayerEvent;
/**
* Called when a player attempts to join, leave, or change parties.
*/
public class McMMOPartyChangeEvent extends PlayerEvent implements Cancellable{
protected String oldParty;
protected String newParty;
protected EventReason reason;
protected boolean cancelled;
public McMMOPartyChangeEvent(Player player, String oldParty, String newParty, EventReason reason) {
super(player);
if (newParty != null) {
newParty = newParty.replace(":", ".");
}
this.oldParty = oldParty;
this.newParty = newParty;
this.reason = reason;
this.cancelled = false;
}
/**
* @return The party being left, or null if the player was not in a party
*/
public String getOldParty() {
return oldParty;
}
/**
* @return The party being joined, or null if the player is not joining a new party
*/
public String getNewParty() {
return newParty;
}
/**
* @return The reason for the event being fired
*/
public EventReason getReason() {
return reason;
}
/**
* A list of reasons why the event may have been fired
*/
public enum EventReason{
/**
* Joined a party for the first time.
*/
JOINED_PARTY,
/**
* Left a party and did not join a new one.
*/
LEFT_PARTY,
/**
* Was kicked from a party.
*/
KICKED_FROM_PARTY,
/**
* Left one party to join another.
*/
CHANGED_PARTIES,
/**
* Any reason that doesn't fit elsewhere.
*/
CUSTOM;
}
/** Rest of file is required boilerplate for custom events **/
private static final HandlerList handlers = new HandlerList();
@Override
public HandlerList getHandlers() {
return handlers;
}
public static HandlerList getHandlerList() {
return handlers;
}
/** Following are required for Cancellable **/
@Override
public boolean isCancelled() {
return cancelled;
}
@Override
public void setCancelled(boolean cancelled) {
this.cancelled = cancelled;
}
}

View File

@@ -0,0 +1,45 @@
package com.gmail.nossr50.events.party;
import org.bukkit.entity.Player;
import org.bukkit.event.HandlerList;
import org.bukkit.event.player.PlayerTeleportEvent;
/**
* Called just before a player teleports using the /ptp command.
*/
public class McMMOPartyTeleportEvent extends PlayerTeleportEvent{
private String party;
private Player target;
public McMMOPartyTeleportEvent(Player player, Player target, String party) {
super(player, player.getLocation(), target.getLocation(), TeleportCause.COMMAND);
this.party = party;
this.target = target;
}
/**
* @return The party the teleporting player is in
*/
public String getParty() {
return party;
}
/**
* @return The player being teleported to
*/
public Player getTarget() {
return target;
}
/** Rest of file is required boilerplate for custom events **/
private static final HandlerList handlers = new HandlerList();
@Override
public HandlerList getHandlers() {
return handlers;
}
public static HandlerList getHandlerList() {
return handlers;
}
}

View File

@@ -0,0 +1,57 @@
package com.gmail.nossr50.events.skills;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import org.bukkit.inventory.ItemStack;
import com.gmail.nossr50.datatypes.SkillType;
/**
* Called just before a player repairs an object with mcMMO.
*/
public class McMMOPlayerRepairCheckEvent extends McMMOPlayerSkillEvent implements Cancellable{
private short repairAmount;
private ItemStack repairMaterial;
private ItemStack repairedObject;
private boolean cancelled;
public McMMOPlayerRepairCheckEvent(Player player, short repairAmount, ItemStack repairMaterial, ItemStack repairedObject) {
super(player, SkillType.REPAIR);
this.repairAmount = repairAmount;
this.repairMaterial = repairMaterial;
this.repairedObject = repairedObject;
this.cancelled = false;
}
/**
* @return The amount this item will be repaired.
*/
public short getRepairAmount() {
return repairAmount;
}
/**
* @return The material used to repair this item
*/
public ItemStack getRepairMaterial() {
return repairMaterial;
}
/**
* @return The item that was repaired
*/
public ItemStack getRepairedObject() {
return repairedObject;
}
/** Following are required for Cancellable **/
@Override
public boolean isCancelled() {
return cancelled;
}
@Override
public void setCancelled(boolean cancelled) {
this.cancelled = cancelled;
}
}

View File

@@ -0,0 +1,47 @@
package com.gmail.nossr50.events.skills;
import org.bukkit.entity.Player;
import org.bukkit.event.HandlerList;
import org.bukkit.event.player.PlayerEvent;
import com.gmail.nossr50.datatypes.SkillType;
/**
* Generic event for mcMMO skill handling.
*/
public class McMMOPlayerSkillEvent extends PlayerEvent {
protected SkillType skill;
protected int skillLevel;
public McMMOPlayerSkillEvent(Player player, SkillType skill) {
super(player);
this.skill = skill;
this.skillLevel = skill.getSkillLevel(player);
}
/**
* @return The skill involved in this event
*/
public SkillType getSkill() {
return skill;
}
/**
* @return The level of the skill involved in this event
*/
public int getSkillLevel() {
return skillLevel;
}
/** Rest of file is required boilerplate for custom events **/
private static final HandlerList handlers = new HandlerList();
@Override
public HandlerList getHandlers() {
return handlers;
}
public static HandlerList getHandlerList() {
return handlers;
}
}

View File

@@ -11,12 +11,16 @@ import com.gmail.nossr50.config.LoadProperties;
import com.gmail.nossr50.datatypes.AbilityType;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.datatypes.ToolType;
import com.gmail.nossr50.skills.Excavation;
import com.gmail.nossr50.skills.Herbalism;
import com.gmail.nossr50.skills.Mining;
import com.gmail.nossr50.skills.Repair;
import com.gmail.nossr50.skills.Skills;
import com.gmail.nossr50.skills.WoodCutting;
import com.gmail.nossr50.spout.SpoutSounds;
import com.gmail.nossr50.events.fake.FakeBlockBreakEvent;
import com.gmail.nossr50.events.fake.FakePlayerAnimationEvent;
import org.bukkit.Bukkit;
import org.bukkit.CropState;
@@ -32,17 +36,11 @@ import org.bukkit.event.block.BlockDamageEvent;
import org.bukkit.event.block.BlockPistonExtendEvent;
import org.bukkit.event.block.BlockPistonRetractEvent;
import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.player.PlayerAnimationEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.metadata.FixedMetadataValue;
import org.getspout.spoutapi.SpoutManager;
import org.getspout.spoutapi.player.SpoutPlayer;
import org.getspout.spoutapi.sound.SoundEffect;
import com.gmail.nossr50.locale.mcLocale;
import com.gmail.nossr50.events.FakeBlockBreakEvent;
public class mcBlockListener implements Listener {
private final mcMMO plugin;
@@ -97,17 +95,8 @@ public class mcBlockListener implements Listener {
*/
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onBlockPlace(BlockPlaceEvent event) {
Block block;
Block block = event.getBlock();
Player player = event.getPlayer();
//When blocks are placed on snow this event reports the wrong block.
if (event.getBlockReplacedState() != null && event.getBlockReplacedState().getType().equals(Material.SNOW)) {
block = event.getBlockAgainst();
}
else {
block = event.getBlock();
}
int id = block.getTypeId();
Material mat = block.getType();
@@ -118,7 +107,7 @@ public class mcBlockListener implements Listener {
continue;
}
else {
Block newLocation = block.getRelative(0, y+1, 0);
Block newLocation = block.getRelative(0, y + 1, 0);
newLocation.setMetadata("mcmmoPlacedBlock", new FixedMetadataValue(plugin, true));
break;
}
@@ -131,22 +120,7 @@ public class mcBlockListener implements Listener {
}
if (id == LoadProperties.anvilID && LoadProperties.anvilmessages) {
PlayerProfile PP = Users.getProfile(player);
if (!PP.getPlacedAnvil()) {
if (LoadProperties.spoutEnabled) {
SpoutPlayer sPlayer = SpoutManager.getPlayer(player);
if (sPlayer.isSpoutCraftEnabled()) {
sPlayer.sendNotification("[mcMMO] Anvil Placed", "Right click to repair!", Material.getMaterial(id));
}
}
else {
event.getPlayer().sendMessage(mcLocale.getString("mcBlockListener.PlacedAnvil"));
}
PP.togglePlacedAnvil();
}
Repair.placedAnvilCheck(player, id);
}
}
@@ -163,7 +137,7 @@ public class mcBlockListener implements Listener {
Material mat = block.getType();
ItemStack inhand = player.getItemInHand();
if(event instanceof FakeBlockBreakEvent) {
if (event instanceof FakeBlockBreakEvent) {
return;
}
@@ -172,14 +146,13 @@ public class mcBlockListener implements Listener {
*/
/* Green Terra */
if (PP.getHoePreparationMode() && mcPermissions.getInstance().greenTerra(player) && ((mat.equals(Material.CROPS) && block.getData() == CropState.RIPE.getData()) || Herbalism.canBeGreenTerra(mat))) {
if (PP.getToolPreparationMode(ToolType.HOE) && mcPermissions.getInstance().greenTerra(player) && ((mat.equals(Material.CROPS) && block.getData() == CropState.RIPE.getData()) || Herbalism.canBeGreenTerra(mat))) {
Skills.abilityCheck(player, SkillType.HERBALISM);
}
/* Triple drops */
if (PP.getGreenTerraMode() && Herbalism.canBeGreenTerra(mat)) {
if (PP.getAbilityMode(AbilityType.GREEN_TERRA) && Herbalism.canBeGreenTerra(mat)) {
Herbalism.herbalismProcCheck(block, player, event, plugin);
Herbalism.herbalismProcCheck(block, player, event, plugin); //Called twice for triple drop functionality
}
if (mcPermissions.getInstance().herbalismDoubleDrops(player) && Herbalism.canBeGreenTerra(mat)) {
@@ -212,7 +185,7 @@ public class mcBlockListener implements Listener {
}
}
if (PP.getTreeFellerMode() && mcPermissions.getInstance().treeFeller(player)) {
if (PP.getAbilityMode(AbilityType.TREE_FELLER) && mcPermissions.getInstance().treeFeller(player)) {
WoodCutting.treeFeller(event);
}
@@ -254,35 +227,35 @@ public class mcBlockListener implements Listener {
* ABILITY PREPARATION CHECKS
*/
if (BlockChecks.abilityBlockCheck(mat)) {
if (PP.getHoePreparationMode() && (Herbalism.canBeGreenTerra(mat) || Herbalism.makeMossy(mat))) {
if (PP.getToolPreparationMode(ToolType.HOE) && (Herbalism.canBeGreenTerra(mat) || Herbalism.makeMossy(mat))) {
Skills.abilityCheck(player, SkillType.HERBALISM);
}
else if (PP.getAxePreparationMode() && mat.equals(Material.LOG) && mcPermissions.getInstance().treeFeller(player)) { //Why are we checking the permissions here?
else if (PP.getToolPreparationMode(ToolType.AXE) && mat.equals(Material.LOG) && mcPermissions.getInstance().treeFeller(player)) { //Why are we checking the permissions here?
Skills.abilityCheck(player, SkillType.WOODCUTTING);
}
else if (PP.getPickaxePreparationMode() && Mining.canBeSuperBroken(mat)) {
else if (PP.getToolPreparationMode(ToolType.PICKAXE) && Mining.canBeSuperBroken(mat)) {
Skills.abilityCheck(player, SkillType.MINING);
}
else if (PP.getShovelPreparationMode() && Excavation.canBeGigaDrillBroken(mat)) {
else if (PP.getToolPreparationMode(ToolType.SHOVEL) && Excavation.canBeGigaDrillBroken(mat)) {
Skills.abilityCheck(player, SkillType.EXCAVATION);
}
else if (PP.getFistsPreparationMode() && (Excavation.canBeGigaDrillBroken(mat) || mat.equals(Material.SNOW))) {
else if (PP.getToolPreparationMode(ToolType.FISTS) && (Excavation.canBeGigaDrillBroken(mat) || mat.equals(Material.SNOW))) {
Skills.abilityCheck(player, SkillType.UNARMED);
}
}
/* TREE FELLER SOUNDS */
if (LoadProperties.spoutEnabled && mat.equals(Material.LOG) && PP.getTreeFellerMode()) {
if (LoadProperties.spoutEnabled && mat.equals(Material.LOG) && PP.getAbilityMode(AbilityType.TREE_FELLER)) {
SpoutSounds.playSoundForPlayer(SoundEffect.FIZZ, player, block.getLocation());
}
/*
* ABILITY TRIGGER CHECKS
*/
if (PP.getGreenTerraMode() && mcPermissions.getInstance().greenTerra(player) && Herbalism.makeMossy(mat)) {
if (PP.getAbilityMode(AbilityType.GREEN_TERRA) && mcPermissions.getInstance().greenTerra(player) && Herbalism.makeMossy(mat)) {
Herbalism.greenTerra(player, block);
}
else if (PP.getGigaDrillBreakerMode() && Skills.triggerCheck(player, block, AbilityType.GIGA_DRILL_BREAKER)) {
else if (PP.getAbilityMode(AbilityType.GIGA_DRILL_BREAKER) && Skills.triggerCheck(player, block, AbilityType.GIGA_DRILL_BREAKER)) {
if (LoadProperties.excavationRequiresShovel && ItemChecks.isShovel(inhand)) {
event.setInstaBreak(true);
Excavation.gigaDrillBreaker(player, block);
@@ -292,9 +265,9 @@ public class mcBlockListener implements Listener {
Excavation.gigaDrillBreaker(player, block);
}
}
else if (PP.getBerserkMode() && Skills.triggerCheck(player, block, AbilityType.BERSERK)) {
else if (PP.getAbilityMode(AbilityType.BERSERK) && Skills.triggerCheck(player, block, AbilityType.BERSERK)) {
if (inhand.getType().equals(Material.AIR)) {
PlayerAnimationEvent armswing = new PlayerAnimationEvent(player);
FakePlayerAnimationEvent armswing = new FakePlayerAnimationEvent(player);
Bukkit.getPluginManager().callEvent(armswing);
event.setInstaBreak(true);
@@ -304,7 +277,7 @@ public class mcBlockListener implements Listener {
SpoutSounds.playSoundForPlayer(SoundEffect.POP, player, block.getLocation());
}
}
else if (PP.getSuperBreakerMode() && Skills.triggerCheck(player, block, AbilityType.SUPER_BREAKER)) {
else if (PP.getAbilityMode(AbilityType.SUPER_BREAKER) && Skills.triggerCheck(player, block, AbilityType.SUPER_BREAKER)) {
if (LoadProperties.miningrequirespickaxe && ItemChecks.isMiningPick(inhand)) {
event.setInstaBreak(true);
Mining.SuperBreakerBlockCheck(player, block);

View File

@@ -30,8 +30,8 @@ import com.gmail.nossr50.mcPermissions;
import com.gmail.nossr50.config.LoadProperties;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.events.FakeEntityDamageByEntityEvent;
import com.gmail.nossr50.events.FakeEntityDamageEvent;
import com.gmail.nossr50.events.fake.FakeEntityDamageByEntityEvent;
import com.gmail.nossr50.events.fake.FakeEntityDamageEvent;
import com.gmail.nossr50.party.Party;
import com.gmail.nossr50.runnables.mcBleedTimer;
import com.gmail.nossr50.skills.Acrobatics;
@@ -152,7 +152,7 @@ public class mcEntityListener implements Listener {
Archery.arrowRetrievalCheck(x, plugin);
if (x instanceof Player) {
Users.getProfile((Player)x).setBleedTicks(0);
Users.getProfile((Player)x).resetBleedTicks();
}
}
@@ -163,7 +163,9 @@ public class mcEntityListener implements Listener {
*/
@EventHandler (priority = EventPriority.MONITOR)
public void onCreatureSpawn(CreatureSpawnEvent event) {
if (event.getSpawnReason().equals(SpawnReason.SPAWNER) && !LoadProperties.xpGainsMobSpawners) {
SpawnReason reason = event.getSpawnReason();
if ((reason.equals(SpawnReason.SPAWNER) || reason.equals(SpawnReason.SPAWNER_EGG)) && !LoadProperties.xpGainsMobSpawners) {
event.getEntity().setMetadata("mcmmoFromMobSpawner", new FixedMetadataValue(plugin, true));
}
}
@@ -173,7 +175,7 @@ public class mcEntityListener implements Listener {
*
* @param event The event to monitor
*/
@EventHandler (priority = EventPriority.LOW)
@EventHandler (priority = EventPriority.HIGH, ignoreCancelled = true)
public void onExplosionPrime(ExplosionPrimeEvent event) {
Entity entity = event.getEntity();
@@ -195,7 +197,7 @@ public class mcEntityListener implements Listener {
*
* @param event The event to monitor
*/
@EventHandler (priority = EventPriority.LOW)
@EventHandler (priority = EventPriority.HIGH, ignoreCancelled = true)
public void onEnitityExplode(EntityExplodeEvent event) {
Entity entity = event.getEntity();
@@ -307,7 +309,7 @@ public class mcEntityListener implements Listener {
break;
}
PP.addXP(SkillType.TAMING, xp, player);
PP.addXP(SkillType.TAMING, xp);
Skills.XpCheckSkill(SkillType.TAMING, player);
}
}

View File

@@ -33,6 +33,7 @@ import com.gmail.nossr50.commands.general.XprateCommand;
import com.gmail.nossr50.config.LoadProperties;
import com.gmail.nossr50.runnables.RemoveProfileFromMemoryTask;
import com.gmail.nossr50.spout.SpoutStuff;
import com.gmail.nossr50.datatypes.AbilityType;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.locale.mcLocale;
@@ -112,7 +113,7 @@ public class mcPlayerListener implements Listener {
*/
@EventHandler(ignoreCancelled = true)
public void onPlayerPickupItem(PlayerPickupItemEvent event) {
if (Users.getProfile(event.getPlayer()).getBerserkMode()) {
if (Users.getProfile(event.getPlayer()).getAbilityMode(AbilityType.BERSERK)) {
event.setCancelled(true);
}
}
@@ -140,7 +141,7 @@ public class mcPlayerListener implements Listener {
/* GARBAGE COLLECTION */
//Remove Spout Stuff
if(LoadProperties.spoutEnabled && SpoutStuff.playerHUDs.containsKey(player)) {
if (LoadProperties.spoutEnabled && SpoutStuff.playerHUDs.containsKey(player)) {
SpoutStuff.playerHUDs.remove(player);
}
@@ -326,7 +327,7 @@ public class mcPlayerListener implements Listener {
String format = color + "(" + ChatColor.WHITE + name + color + ") " + event.getMessage();
for (Player x : Bukkit.getServer().getOnlinePlayers()) {
for (Player x : plugin.getServer().getOnlinePlayers()) {
if (partyChat && Party.getInstance().inSameParty(player, x))
x.sendMessage(format);
else if (adminChat && (x.isOp() || mcPermissions.getInstance().adminChat(x))) {
@@ -357,7 +358,7 @@ public class mcPlayerListener implements Listener {
String command = message.substring(1).split(" ")[0];
if (plugin.aliasMap.containsKey(command)) {
if(command.equalsIgnoreCase(plugin.aliasMap.get(command))) {
if (command.equalsIgnoreCase(plugin.aliasMap.get(command))) {
return;
}
event.getPlayer().chat(message.replaceFirst(command, plugin.aliasMap.get(command)));

View File

@@ -3,7 +3,7 @@ package com.gmail.nossr50.listeners;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import com.gmail.nossr50.events.McMMOPlayerXpGainEvent;
import com.gmail.nossr50.events.experience.McMMOPlayerXpGainEvent;
/**
* Listener for listening to our own events, only really useful for catching errors

View File

@@ -1,14 +1,16 @@
package com.gmail.nossr50.listeners;
import org.bukkit.ChatColor;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.getspout.spoutapi.event.spout.SpoutCraftEnableEvent;
import org.getspout.spoutapi.player.SpoutPlayer;
import com.gmail.nossr50.Users;
import com.gmail.nossr50.m;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.LoadProperties;
import com.gmail.nossr50.datatypes.HUDmmo;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.spout.SpoutStuff;
public class mcSpoutListener implements Listener {
@@ -27,11 +29,18 @@ public class mcSpoutListener implements Listener {
@EventHandler
public void onSpoutCraftEnable(SpoutCraftEnableEvent event) {
SpoutPlayer sPlayer = event.getPlayer();
PlayerProfile PPs = Users.getProfile(sPlayer);
//TODO: Add custom titles based on skills
if (LoadProperties.showPowerLevel) {
sPlayer.setTitle(sPlayer.getName()+ "\n" + ChatColor.YELLOW + "P" + ChatColor.GOLD + "lvl"
+ ChatColor.WHITE+"." + ChatColor.GREEN + String.valueOf(PPs.getPowerLevel()));
}
if (sPlayer.isSpoutCraftEnabled()) {
SpoutStuff.playerHUDs.put(sPlayer, new HUDmmo(sPlayer)); //Setup Party HUD stuff
Users.getProfile(sPlayer).toggleSpoutEnabled();
sPlayer.setTitle(String.valueOf(m.getPowerLevel(sPlayer, Users.getProfile(sPlayer))));
PPs.toggleSpoutEnabled();
}
}
}

View File

@@ -9,67 +9,69 @@ import org.bukkit.ChatColor;
import com.gmail.nossr50.config.LoadProperties;
public class mcLocale
{
private static final String BUNDLE_NAME = "com.gmail.nossr50.locale.locale"; //$NON-NLS-1$
public class mcLocale {
private static final String BUNDLE_NAME = "com.gmail.nossr50.locale.locale";
private static ResourceBundle RESOURCE_BUNDLE = null;
private static ResourceBundle RESOURCE_BUNDLE = null;
public static String getString(String key) {
return getString(key, null);
}
public static String getString(String key)
{
return getString(key, null);
}
/**
* Gets the appropriate string from the Locale files.
*
* @param key The key to look up the string with
* @param messageArguments Any arguements to be added to the string
* @return The properly formatted locale string
*/
public static String getString(String key, Object[] messageArguments) {
try {
if (RESOURCE_BUNDLE == null) {
String myLocale = LoadProperties.locale.toLowerCase();
try {
//attempt to get the locale denoted
RESOURCE_BUNDLE = ResourceBundle.getBundle(BUNDLE_NAME, new Locale(myLocale));
}
catch (MissingResourceException e) {
RESOURCE_BUNDLE = ResourceBundle.getBundle(BUNDLE_NAME, new Locale("en_us"));
}
}
public static String getString(String key, Object[] messageArguments)
{
try {
if (RESOURCE_BUNDLE == null)
{
String myLocale = LoadProperties.locale.toLowerCase();
try {
//attempt to get the locale denoted
RESOURCE_BUNDLE = ResourceBundle.getBundle(BUNDLE_NAME, new Locale(myLocale));
} catch (MissingResourceException e) {
//System.out.println("Failed to load locale specified by mcmmo.properties '"+myLocale+"', defaulting to en_us");
RESOURCE_BUNDLE = ResourceBundle.getBundle(BUNDLE_NAME, new Locale("en_us"));
}
}
String output = RESOURCE_BUNDLE.getString(key);
String output = RESOURCE_BUNDLE.getString(key);
if (messageArguments != null)
{
MessageFormat formatter = new MessageFormat("");
formatter.applyPattern(output);
output = formatter.format(messageArguments);
}
output = addColors(output);
return output;
} catch (MissingResourceException e) {
return '!' + key + '!';
}
}
private static String addColors(String input) {
input = input.replaceAll("\\Q[[BLACK]]\\E", ChatColor.BLACK.toString());
input = input.replaceAll("\\Q[[DARK_BLUE]]\\E", ChatColor.DARK_BLUE.toString());
input = input.replaceAll("\\Q[[DARK_GREEN]]\\E", ChatColor.DARK_GREEN.toString());
input = input.replaceAll("\\Q[[DARK_AQUA]]\\E", ChatColor.DARK_AQUA.toString());
input = input.replaceAll("\\Q[[DARK_RED]]\\E", ChatColor.DARK_RED.toString());
input = input.replaceAll("\\Q[[DARK_PURPLE]]\\E", ChatColor.DARK_PURPLE.toString());
input = input.replaceAll("\\Q[[GOLD]]\\E", ChatColor.GOLD.toString());
input = input.replaceAll("\\Q[[GRAY]]\\E", ChatColor.GRAY.toString());
input = input.replaceAll("\\Q[[DARK_GRAY]]\\E", ChatColor.DARK_GRAY.toString());
input = input.replaceAll("\\Q[[BLUE]]\\E", ChatColor.BLUE.toString());
input = input.replaceAll("\\Q[[GREEN]]\\E", ChatColor.GREEN.toString());
input = input.replaceAll("\\Q[[AQUA]]\\E", ChatColor.AQUA.toString());
input = input.replaceAll("\\Q[[RED]]\\E", ChatColor.RED.toString());
input = input.replaceAll("\\Q[[LIGHT_PURPLE]]\\E", ChatColor.LIGHT_PURPLE.toString());
input = input.replaceAll("\\Q[[YELLOW]]\\E", ChatColor.YELLOW.toString());
input = input.replaceAll("\\Q[[WHITE]]\\E", ChatColor.WHITE.toString());
return input;
}
if (messageArguments != null) {
MessageFormat formatter = new MessageFormat("");
formatter.applyPattern(output);
output = formatter.format(messageArguments);
}
output = addColors(output);
return output;
}
catch (MissingResourceException e) {
return '!' + key + '!';
}
}
private static String addColors(String input) {
input = input.replaceAll("\\Q[[BLACK]]\\E", ChatColor.BLACK.toString());
input = input.replaceAll("\\Q[[DARK_BLUE]]\\E", ChatColor.DARK_BLUE.toString());
input = input.replaceAll("\\Q[[DARK_GREEN]]\\E", ChatColor.DARK_GREEN.toString());
input = input.replaceAll("\\Q[[DARK_AQUA]]\\E", ChatColor.DARK_AQUA.toString());
input = input.replaceAll("\\Q[[DARK_RED]]\\E", ChatColor.DARK_RED.toString());
input = input.replaceAll("\\Q[[DARK_PURPLE]]\\E", ChatColor.DARK_PURPLE.toString());
input = input.replaceAll("\\Q[[GOLD]]\\E", ChatColor.GOLD.toString());
input = input.replaceAll("\\Q[[GRAY]]\\E", ChatColor.GRAY.toString());
input = input.replaceAll("\\Q[[DARK_GRAY]]\\E", ChatColor.DARK_GRAY.toString());
input = input.replaceAll("\\Q[[BLUE]]\\E", ChatColor.BLUE.toString());
input = input.replaceAll("\\Q[[GREEN]]\\E", ChatColor.GREEN.toString());
input = input.replaceAll("\\Q[[AQUA]]\\E", ChatColor.AQUA.toString());
input = input.replaceAll("\\Q[[RED]]\\E", ChatColor.RED.toString());
input = input.replaceAll("\\Q[[LIGHT_PURPLE]]\\E", ChatColor.LIGHT_PURPLE.toString());
input = input.replaceAll("\\Q[[YELLOW]]\\E", ChatColor.YELLOW.toString());
input = input.replaceAll("\\Q[[WHITE]]\\E", ChatColor.WHITE.toString());
return input;
}
}

View File

@@ -1,5 +1,7 @@
package com.gmail.nossr50;
import java.util.Random;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
@@ -7,16 +9,17 @@ import org.bukkit.block.Block;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.player.PlayerAnimationEvent;
import org.bukkit.inventory.ItemStack;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.events.FakeBlockBreakEvent;
import com.gmail.nossr50.events.McMMOItemSpawnEvent;
import com.gmail.nossr50.config.LoadProperties;
import com.gmail.nossr50.events.fake.FakeBlockBreakEvent;
import com.gmail.nossr50.events.fake.FakePlayerAnimationEvent;
import com.gmail.nossr50.events.items.McMMOItemSpawnEvent;
public class m {
private static Random random = new Random();
/**
* Gets a capitalized version of the target string.
*
@@ -92,25 +95,6 @@ public class m {
}
}
/**
* Gets the power level of a player.
*
* @param player The player to get the power level of
* @param PP The profile of the player
* @return the power level of the player
*/
public static int getPowerLevel(Player player, PlayerProfile PP) {
int powerLevel = 0;
for (SkillType type : SkillType.values()) {
if (type.getPermissions(player)) {
powerLevel += PP.getSkillLevel(type);
}
}
return powerLevel;
}
/**
* Simulate a block break event.
*
@@ -123,7 +107,7 @@ public class m {
//Support for NoCheat
if (shouldArmSwing) {
PlayerAnimationEvent armswing = new PlayerAnimationEvent(player);
FakePlayerAnimationEvent armswing = new FakePlayerAnimationEvent(player);
Bukkit.getPluginManager().callEvent(armswing);
}
@@ -144,7 +128,7 @@ public class m {
* @param inHand The item to check the tier of
* @return the tier of the item
*/
public static Integer getTier(ItemStack inHand) {
public static int getTier(ItemStack inHand) {
int tier = 0;
if (ItemChecks.isWoodTool(inHand)) {
@@ -173,13 +157,12 @@ public class m {
* @param maxDistance The max distance apart
* @return true if the distance between <code>first</code> and <code>second</code> is less than <code>maxDistance</code>, false otherwise
*/
public static boolean isNear(Location first, Location second, int maxDistance) {
double relX = first.getX() - second.getX();
double relY = first.getY() - second.getY();
double relZ = first.getZ() - second.getZ();
double dist = (relX * relX) + (relY * relY) + (relZ * relZ);
public static boolean isNear(Location first, Location second, double maxDistance) {
if (!first.getWorld().equals(second.getWorld())) {
return false;
}
if (dist < maxDistance * maxDistance) {
if (first.distanceSquared(second) < (maxDistance * maxDistance)) {
return true;
}
else {
@@ -224,7 +207,7 @@ public class m {
* @param chance The percentage chance for the item to drop
*/
public static void mcRandomDropItem(Location location, ItemStack is, double chance) {
if (Math.random() * 100 < chance) {
if (random.nextInt(100) < chance) {
mcDropItem(location, is);
}
}
@@ -258,9 +241,8 @@ public class m {
if (event.isCancelled()) {
return;
}
else {
location.getWorld().dropItemNaturally(location, itemStack);
}
location.getWorld().dropItemNaturally(location, itemStack);
}
/**
@@ -278,4 +260,13 @@ public class m {
return skillLevel;
}
}
public static int getPowerLevelCap() {
if (LoadProperties.powerLevelCap > 0) {
return LoadProperties.powerLevelCap;
}
else {
return Integer.MAX_VALUE;
}
}
}

View File

@@ -1,7 +1,6 @@
package com.gmail.nossr50;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.commands.skills.*;
import com.gmail.nossr50.commands.spout.*;
import com.gmail.nossr50.commands.mc.*;
@@ -9,8 +8,6 @@ import com.gmail.nossr50.commands.party.*;
import com.gmail.nossr50.commands.general.*;
import com.gmail.nossr50.config.*;
import com.gmail.nossr50.runnables.*;
import com.gmail.nossr50.skills.Skills;
import com.gmail.nossr50.spout.SpoutStuff;
import com.gmail.nossr50.listeners.mcBlockListener;
import com.gmail.nossr50.listeners.mcEntityListener;
import com.gmail.nossr50.listeners.mcPlayerListener;
@@ -18,16 +15,13 @@ import com.gmail.nossr50.locale.mcLocale;
import com.gmail.nossr50.party.Party;
import java.io.BufferedInputStream;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.HashMap;
import org.bukkit.Bukkit;
@@ -40,8 +34,6 @@ import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.getspout.spoutapi.SpoutManager;
import org.getspout.spoutapi.player.FileManager;
public class mcMMO extends JavaPlugin {
@@ -109,12 +101,7 @@ public class mcMMO extends JavaPlugin {
PluginManager pm = getServer().getPluginManager();
if (pm.getPlugin("Spout") != null) {
LoadProperties.spoutEnabled = true;
}
else {
LoadProperties.spoutEnabled = false;
}
Bukkit.getScheduler().scheduleSyncDelayedTask(this, new SpoutStart(this), 20); //Schedule Spout Activation 1 second after start-up
//Register events
pm.registerEvents(playerListener, this);
@@ -149,16 +136,6 @@ public class mcMMO extends JavaPlugin {
registerCommands();
//Spout Stuff
if (LoadProperties.spoutEnabled) {
SpoutStuff.setupSpoutConfigs();
SpoutStuff.registerCustomEvent();
SpoutStuff.extractFiles(); //Extract source materials
FileManager FM = SpoutManager.getFileManager();
FM.addToPreLoginCache(this, SpoutStuff.getFiles());
}
if (LoadProperties.statsTracking) {
//Plugin Metrics running in a new thread
new Thread(new Runnable() {
@@ -190,111 +167,6 @@ public class mcMMO extends JavaPlugin {
return Users.getProfile(player);
}
/**
* Check the XP of a player.
* </br>
* This function is designed for API usage.
*
* @param player
* @param skillType
*/
public void checkXp(Player player, SkillType skillType) {
if (skillType == SkillType.ALL) {
Skills.XpCheckAll(player);
}
else {
Skills.XpCheckSkill(skillType, player);
}
}
/**
* Check if two players are in the same party.
* </br>
* This function is designed for API usage.
*
* @param playera The first player to check
* @param playerb The second player to check
* @return true if the two players are in the same party, false otherwise
*/
public boolean inSameParty(Player playera, Player playerb) {
if (Users.getProfile(playera).inParty() && Users.getProfile(playerb).inParty()) {
if (Users.getProfile(playera).getParty().equals(Users.getProfile(playerb).getParty())) {
return true;
}
else {
return false;
}
}
else {
return false;
}
}
/**
* Get a list of all current party names.
* </br>
* This function is designed for API usage.
*
* @return the list of parties.
*/
public ArrayList<String> getParties() {
String location = "plugins/mcMMO/mcmmo.users";
ArrayList<String> parties = new ArrayList<String>();
try {
//Open the users file
FileReader file = new FileReader(location);
BufferedReader in = new BufferedReader(file);
String line = "";
while((line = in.readLine()) != null) {
String[] character = line.split(":");
String theparty = null;
//Party
if (character.length > 3) {
theparty = character[3];
}
if (!parties.contains(theparty)) {
parties.add(theparty);
}
}
in.close();
}
catch (Exception e) {
Bukkit.getLogger().severe("Exception while reading " + location + " (Are you sure you formatted it correctly?)" + e.toString());
}
return parties;
}
/**
* Get the name of the party a player is in.
* </br>
* This function is designed for API usage.
*
* @param player The player to check the party name of
* @return the name of the player's party
*/
public static String getPartyName(Player player) {
PlayerProfile PP = Users.getProfile(player);
return PP.getParty();
}
/**
* Checks if a player is in a party.
* </br>
* This function is designed for API usage.
*
* @param player The player to check
* @return true if the player is in a party, false otherwise
*/
public static boolean inParty(Player player) {
PlayerProfile PP = Users.getProfile(player);
return PP.inParty();
}
/**
* Things to be run when the plugin is disabled.
*/

View File

@@ -30,7 +30,7 @@ public class mcPermissions {
}
public boolean arcaneBypass(Player player) {
return player.hasPermission(("mcmmo.repair.arcanebypass"));
return player.hasPermission(("mcmmo.bypass.arcanebypass"));
}
/*
@@ -137,10 +137,18 @@ public class mcPermissions {
return player.hasPermission("mcmmo.ability.repair.arcaneforging");
}
public boolean woodRepair(Player player) {
return player.hasPermission("mcmmo.ability.repair.woodrepair");
}
public boolean stoneRepair(Player player) {
return player.hasPermission("mcmmo.ability.repair.stonerepair");
}
public boolean leatherRepair(Player player) {
return player.hasPermission("mcmmo.ability.repair.leatherrepair");
}
public boolean ironRepair(Player player) {
return player.hasPermission("mcmmo.ability.repair.ironrepair");
}
@@ -161,6 +169,10 @@ public class mcPermissions {
return player.hasPermission("mcmmo.ability.repair.toolrepair");
}
public boolean bowRepair(Player player) {
return player.hasPermission("mcmmo.ability.repair.bowrepair");
}
/*
* MCMMO.ABILITY.UNARMED.*
*/

View File

@@ -10,8 +10,6 @@ import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
@@ -20,244 +18,235 @@ import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.locale.mcLocale;
public class Party {
/*
* This file is part of mmoMinecraft (http://code.google.com/p/mmo-minecraft/).
*
* mmoMinecraft is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
public static String partyPlayersFile = mcMMO.maindirectory + File.separator + "FlatFileStuff" + File.separator + "partyPlayers";
public static String partyLocksFile = mcMMO.maindirectory + File.separator + "FlatFileStuff" + File.separator + "partyLocks";
public static String partyPasswordsFile = mcMMO.maindirectory + File.separator + "FlatFileStuff" + File.separator + "partyPasswords";
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
public static String partyPlayersFile = mcMMO.maindirectory + File.separator + "FlatFileStuff" + File.separator + "partyPlayers";
public static String partyLocksFile = mcMMO.maindirectory + File.separator + "FlatFileStuff" + File.separator + "partyLocks";
public static String partyPasswordsFile = mcMMO.maindirectory + File.separator + "FlatFileStuff" + File.separator + "partyPasswords";
HashMap<String, HashMap<String, Boolean>> partyPlayers = new HashMap<String, HashMap<String, Boolean>>();
HashMap<String, Boolean> partyLocks = new HashMap<String, Boolean>();
HashMap<String, String> partyPasswords = new HashMap<String, String>();
HashMap<String, HashMap<String, Boolean>> partyPlayers = new HashMap<String, HashMap<String, Boolean>>();
HashMap<String, Boolean> partyLocks = new HashMap<String, Boolean>();
HashMap<String, String> partyPasswords = new HashMap<String, String>();
private static mcMMO plugin;
public Party(mcMMO instance) {
new File(mcMMO.maindirectory + File.separator + "FlatFileStuff").mkdir();
plugin = instance;
private static mcMMO plugin;
private static volatile Party instance;
public Party(mcMMO instance) {
new File(mcMMO.maindirectory + File.separator + "FlatFileStuff").mkdir();
plugin = instance;
}
private static volatile Party instance;
public static Party getInstance()
{
if (instance == null) {
instance = new Party(plugin);
}
return instance;
public static Party getInstance() {
if (instance == null) {
instance = new Party(plugin);
}
return instance;
}
/**
* Check if two players are in the same party.
*
* @param playera The first player
* @param playerb The second player
* @return true if they are in the same party, false otherwise
*/
public boolean inSameParty(Player playera, Player playerb){
if(Users.getProfile(playera).inParty() && Users.getProfile(playerb).inParty())
{
if(Users.getProfile(playera).getParty().equals(Users.getProfile(playerb).getParty()))
{
return true;
} else
{
return false;
}
} else
{
return false;
}
}
public int partyCount(Player player, Player[] players)
{
int x = 0;
for(Player hurrdurr : players)
{
if(player != null && hurrdurr != null)
{
if(Users.getProfile(player).getParty().equals(Users.getProfile(hurrdurr).getParty()))
x++;
}
PlayerProfile PPa = Users.getProfile(playera);
PlayerProfile PPb = Users.getProfile(playerb);
if ((PPa.inParty() && PPb.inParty()) && (PPa.getParty().equals(PPb.getParty()))) {
return true;
}
else {
return false;
}
return x;
}
public void informPartyMembers(Player player)
{
informPartyMembers(player, Bukkit.getServer().getOnlinePlayers());
/**
* Get the number of players in this player's party.
*
* @param player The player to check
* @param players A list of players to
* @return the number of players in this player's party
*/
public int partyCount(Player player) {
PlayerProfile PP = Users.getProfile(player);
int partyMembers = 0;
for (Player p : Bukkit.getServer().getOnlinePlayers()) {
if (player != null && p != null) { //Is this even possible?
if (PP.getParty().equals(Users.getProfile(p).getParty())) {
partyMembers++;
}
}
}
return partyMembers;
}
public void informPartyMembers(Player player, Player[] players)
{
for(Player p : players)
{
if(player != null && p != null)
{
if(inSameParty(player, p) && !p.getName().equals(player.getName()))
{
p.sendMessage(mcLocale.getString("Party.InformedOnJoin", new Object[] {player.getName()}));
private void informPartyMembers(Player player) {
String playerName = player.getName();
for (Player p : Bukkit.getServer().getOnlinePlayers()) {
if (player != null && p != null) {
if (inSameParty(player, p) && !p.getName().equals(playerName)) {
p.sendMessage(mcLocale.getString("Party.InformedOnJoin", new Object[] {playerName}));
}
}
}
}
public ArrayList<Player> getPartyMembers(Player player)
{
ArrayList<Player> players = new ArrayList<Player>();
for(Player p : Bukkit.getServer().getOnlinePlayers())
{
if(p.isOnline() && player != null && p != null)
{
if(inSameParty(player, p) && !p.getName().equals(player.getName()))
{
players.add(p);
/**
* Get a list of all players in this player's party.
*
* @param player The player to check
* @return all the players in the player's party
*/
public ArrayList<Player> getPartyMembers(Player player) {
ArrayList<Player> players = new ArrayList<Player>();
for (Player p : Bukkit.getServer().getOnlinePlayers()) {
if (p.isOnline() && player != null && p != null) {
if (inSameParty(player, p) && !p.getName().equals(player.getName())) {
players.add(p);
}
}
}
return players;
}
public void informPartyMembersOwnerChange(String newOwner) {
Player newOwnerPlayer = plugin.getServer().getPlayer(newOwner);
informPartyMembersOwnerChange(newOwnerPlayer, Bukkit.getServer().getOnlinePlayers());
}
public void informPartyMembersOwnerChange(Player newOwner, Player[] players) {
for(Player p : players){
if(newOwner != null && p != null){
if(inSameParty(newOwner, p))
{
//TODO: Needs more locale.
p.sendMessage(newOwner.getName()+" is the new party owner.");
}
}
}
}
public void informPartyMembersQuit(Player player)
{
informPartyMembersQuit(player, Bukkit.getServer().getOnlinePlayers());
}
public void informPartyMembersQuit(Player player, Player[] players)
{
for(Player p : players){
if(player != null && p != null){
if(inSameParty(player, p) && !p.getName().equals(player.getName()))
{
p.sendMessage(mcLocale.getString("Party.InformedOnQuit", new Object[] {player.getName()}));
}
}
}
}
public void removeFromParty(Player player, PlayerProfile PP)
{
//Stop NPE... hopefully
if(!isParty(PP.getParty()) || !isInParty(player, PP))
addToParty(player, PP, PP.getParty(), false);
informPartyMembersQuit(player);
String party = PP.getParty();
if(isPartyLeader(player.getName(), party))
{
if(isPartyLocked(party)) {
unlockParty(party);
}
}
this.partyPlayers.get(party).remove(player.getName());
if(isPartyEmpty(party)) deleteParty(party);
PP.removeParty();
savePartyPlayers();
}
public void addToParty(Player player, PlayerProfile PP, String newParty, Boolean invite) {
newParty = newParty.replace(":", ".");
addToParty(player, PP, newParty, invite, null);
return players;
}
public void addToParty(Player player, PlayerProfile PP, String newParty, Boolean invite, String password)
{
//Fix for FFS
newParty = newParty.replace(":", ".");
//Don't care about passwords on invites
if(!invite)
{
//Don't care about passwords if it isn't locked
if(isPartyLocked(newParty))
{
if(isPartyPasswordProtected(newParty))
{
if(password == null)
{
//TODO: Needs more locale.
player.sendMessage("This party requires a password. Use /party <party> <password> to join it.");
return;
} else if(!password.equalsIgnoreCase(getPartyPassword(newParty)))
{
//TODO: Needs more locale.
player.sendMessage("Party password incorrect.");
return;
}
} else
{
//TODO: Needs more locale.
player.sendMessage("Party is locked.");
return;
}
}
} else
{
PP.acceptInvite();
}
//New party?
if(!isParty(newParty))
{
putNestedEntry(this.partyPlayers, newParty, player.getName(), true);
//Get default locking behavior from config?
this.partyLocks.put(newParty, false);
this.partyPasswords.put(newParty, null);
saveParties();
} else
{
putNestedEntry(this.partyPlayers, newParty, player.getName(), false);
/**
* Notify party members when the party owner changes.
*
* @param newOwnerName The name of the new party owner
*/
private void informPartyMembersOwnerChange(String newOwnerName) {
Player newOwner = plugin.getServer().getPlayer(newOwnerName);
savePartyPlayers();
}
PP.setParty(newParty);
informPartyMembers(player);
if(!invite)
{
player.sendMessage(mcLocale.getString("mcPlayerListener.JoinedParty", new Object[] { newParty }));
} else
{
player.sendMessage(mcLocale.getString("mcPlayerListener.InviteAccepted", new Object[]{ PP.getParty() }));
}
for (Player p : Bukkit.getServer().getOnlinePlayers()){
if (newOwner != null && p != null) {
if (inSameParty(newOwner, p)) {
p.sendMessage(newOwnerName + " is the new party owner."); //TODO: Needs more locale
}
}
}
}
private static <U,V,W> W putNestedEntry(
HashMap<U,HashMap<V,W>> nest,
U nestKey,
V nestedKey,
W nestedValue)
{
/**
* Notify party members when the a party member quits.
*
* @param player The player that quit
*/
private void informPartyMembersQuit(Player player) {
String playerName = player.getName();
for (Player p : Bukkit.getServer().getOnlinePlayers()){
if (player != null && p != null){
if (inSameParty(player, p) && !p.getName().equals(playerName)) {
p.sendMessage(mcLocale.getString("Party.InformedOnQuit", new Object[] {playerName}));
}
}
}
}
/**
* Remove a player from a party.
*
* @param player The player to remove
* @param PP The profile of the player to remove
*/
public void removeFromParty(Player player, PlayerProfile PP) {
String party = PP.getParty();
String playerName = player.getName();
//Stop NPE... hopefully
if (!isParty(party) || !isInParty(player, PP)) {
addToParty(player, PP, party, false, null);
}
informPartyMembersQuit(player);
if (isPartyLeader(playerName, party)) {
if (isPartyLocked(party)) {
unlockParty(party);
}
}
partyPlayers.get(party).remove(playerName);
if (isPartyEmpty(party)) {
deleteParty(party);
}
PP.removeParty();
savePartyFile(partyPlayersFile, partyPlayers);
}
/**
* Add a player to a party.
*
* @param player The player to add to the party
* @param PP The profile of the player to add to the party
* @param newParty The party to add the player to
* @param invite true if the player was invited to this party, false otherwise
* @param password the password for this party, null if there was no password
*/
public void addToParty(Player player, PlayerProfile PP, String newParty, Boolean invite, String password) {
String playerName = player.getName();
//Fix for FFS
newParty = newParty.replace(":", ".");
//Don't care about passwords on invites
if (!invite) {
//Don't care about passwords if it isn't locked
if (isPartyLocked(newParty)) {
if (isPartyPasswordProtected(newParty)) {
if (password == null) {
player.sendMessage("This party requires a password. Use /party <party> <password> to join it."); //TODO: Needs more locale.
return;
}
else if(!password.equalsIgnoreCase(getPartyPassword(newParty))) {
player.sendMessage("Party password incorrect."); //TODO: Needs more locale.
return;
}
}
else {
player.sendMessage("Party is locked."); //TODO: Needs more locale.
return;
}
}
}
else {
PP.acceptInvite();
}
//New party?
if (!isParty(newParty)) {
putNestedEntry(partyPlayers, newParty, playerName, true);
//Get default locking behavior from config?
partyLocks.put(newParty, false);
partyPasswords.put(newParty, null);
saveParties();
}
else {
putNestedEntry(partyPlayers, newParty, playerName, false);
savePartyFile(partyPlayersFile, partyPlayers);
}
PP.setParty(newParty);
informPartyMembers(player);
if (!invite) {
player.sendMessage(mcLocale.getString("mcPlayerListener.JoinedParty", new Object[]{ newParty }));
}
else {
player.sendMessage(mcLocale.getString("mcPlayerListener.InviteAccepted", new Object[]{ PP.getParty() }));
}
}
private static <U,V,W> W putNestedEntry(HashMap<U, HashMap<V, W>> nest, U nestKey, V nestedKey, W nestedValue) {
HashMap<V,W> nested = nest.get(nestKey);
if (nested == null) {
@@ -265,177 +254,286 @@ public class Party {
nest.put(nestKey, nested);
}
return nested.put(nestedKey, nestedValue);
return nested.put(nestedKey, nestedValue);
}
public void dump(Player player) {
player.sendMessage(partyPlayers.toString());
player.sendMessage(partyLocks.toString());
player.sendMessage(partyPasswords.toString());
Iterator<String> i = partyPlayers.keySet().iterator();
while(i.hasNext()) {
String nestkey = i.next();
player.sendMessage(nestkey);
Iterator<String> j = partyPlayers.get(nestkey).keySet().iterator();
while(j.hasNext()) {
String nestedkey = j.next();
player.sendMessage("."+nestedkey);
if(partyPlayers.get(nestkey).get(nestedkey)) {
player.sendMessage("..True");
} else {
player.sendMessage("..False");
}
}
}
}
/**
* Lock a party.
*
* @param partyName The party to lock
*/
public void lockParty(String partyName) {
this.partyLocks.put(partyName, true);
savePartyLocks();
partyLocks.put(partyName, true);
savePartyFile(partyLocksFile, partyLocks);
}
/**
* Unlock a party.
*
* @param partyName The party to unlock
*/
public void unlockParty(String partyName) {
this.partyLocks.put(partyName, false);
savePartyLocks();
partyLocks.put(partyName, false);
savePartyFile(partyLocksFile, partyLocks);
}
public void deleteParty(String partyName) {
this.partyPlayers.remove(partyName);
this.partyLocks.remove(partyName);
this.partyPasswords.remove(partyName);
saveParties();
/**
* Delete a party.
*
* @param partyName The party to delete
*/
private void deleteParty(String partyName) {
partyPlayers.remove(partyName);
partyLocks.remove(partyName);
partyPasswords.remove(partyName);
saveParties();
}
/**
* Set the password for a party.
*
* @param partyName The party name
* @param password The new party password
*/
public void setPartyPassword(String partyName, String password) {
if(password.equalsIgnoreCase("\"\"")) password = null;
this.partyPasswords.put(partyName, password);
savePartyPasswords();
if (password.equalsIgnoreCase("\"\"")) { //What's with that password string?
password = null;
}
partyPasswords.put(partyName, password);
savePartyFile(partyPasswordsFile, partyPasswords);
}
/**
* Set the leader of a party.
*
* @param partyName The party name
* @param playerName The name of the player to set as leader
*/
public void setPartyLeader(String partyName, String playerName) {
Iterator<String> i = partyPlayers.get(partyName).keySet().iterator();
while(i.hasNext()) {
String playerKey = i.next();
if(playerKey.equalsIgnoreCase(playerName)) {
partyPlayers.get(partyName).put(playerName, true);
informPartyMembersOwnerChange(playerName);
//TODO: Needs more locale.
plugin.getServer().getPlayer(playerName).sendMessage("You are now the party owner.");
continue;
}
if(partyPlayers.get(partyName).get(playerKey)) {
//TODO: Needs more locale.
plugin.getServer().getPlayer(playerKey).sendMessage("You are no longer party owner.");
partyPlayers.get(partyName).put(playerKey, false);
}
}
for (String name : partyPlayers.get(partyName).keySet()) {
if (name.equalsIgnoreCase(playerName)) {
partyPlayers.get(partyName).put(playerName, true);
informPartyMembersOwnerChange(playerName);
plugin.getServer().getPlayer(playerName).sendMessage("You are now the party owner."); //TODO: Needs more locale.
continue;
}
if (partyPlayers.get(partyName).get(name)) {
plugin.getServer().getPlayer(name).sendMessage("You are no longer party owner."); //TODO: Needs more locale.
partyPlayers.get(partyName).put(name, false);
}
}
}
/**
* Get the password of a party.
*
* @param partyName The party name
* @return The password of this party
*/
public String getPartyPassword(String partyName) {
return this.partyPasswords.get(partyName);
return partyPasswords.get(partyName);
}
/**
* Check if a player can invite others to their party.
*
* @param player The player to check
* @param PP The profile of the given player
* @return true if the player can invite, false otherwise
*/
public boolean canInvite(Player player, PlayerProfile PP) {
return (isPartyLocked(PP.getParty()) && !isPartyLeader(player.getName(), PP.getParty())) ? false : true;
String party = PP.getParty();
if (isPartyLocked(party) && !isPartyLeader(player.getName(), party)) {
return false;
}
else {
return true;
}
}
/**
* Check if a string is a valid party name.
*
* @param partyName The party name to check
* @return true if this is a valid party, false otherwise
*/
public boolean isParty(String partyName) {
return this.partyPlayers.containsKey(partyName);
return partyPlayers.containsKey(partyName);
}
/**
* Check if a party is empty.
*
* @param partyName The party to check
* @return true if this party is empty, false otherwise
*/
public boolean isPartyEmpty(String partyName) {
return this.partyPlayers.get(partyName).isEmpty();
return partyPlayers.get(partyName).isEmpty();
}
/**
* Check if a player is the party leader.
*
* @param playerName The player name to check
* @param partyName The party name to check
* @return true if the player is the party leader, false otherwise
*/
public boolean isPartyLeader(String playerName, String partyName) {
if(this.partyPlayers.get(partyName) != null)
{
if(this.partyPlayers.get(partyName).get(playerName) == null) return false;
return this.partyPlayers.get(partyName).get(playerName);
}
else
return false;
HashMap<String, Boolean> partyMembers = partyPlayers.get(partyName);
if (partyMembers != null) {
Boolean isLeader = partyMembers.get(playerName);
if (isLeader == null) {
return false;
}
else {
return isLeader;
}
}
else {
return false;
}
}
/**
* Check if this party is locked.
*
* @param partyName The party to check
* @return true if this party is locked, false otherwise
*/
public boolean isPartyLocked(String partyName) {
if(this.partyLocks.get(partyName) == null) return false;
return this.partyLocks.get(partyName);
Boolean isLocked = partyLocks.get(partyName);
if (isLocked == null) {
return false;
}
else {
return isLocked;
}
}
/**
* Check if this party is password protected.
*
* @param partyName The party to check
* @return true if this party is password protected, false otherwise
*/
public boolean isPartyPasswordProtected(String partyName) {
return !(this.partyPasswords.get(partyName) == null);
String password = partyPasswords.get(partyName);
if (password == null) {
return false;
}
else {
return true;
}
}
/**
* Check if a player is in the party reflected by their profile.
*
* @param player The player to check
* @param PP The profile of the player
* @return true if this player is in the right party, false otherwise
*/
public boolean isInParty(Player player, PlayerProfile PP) {
return partyPlayers.get(PP.getParty()).containsKey(player.getName());
return partyPlayers.get(PP.getParty()).containsKey(player.getName());
}
/**
* Load all party related files.
*/
@SuppressWarnings("unchecked")
public void loadParties() {
if(new File(partyPlayersFile).exists()) {
try {
ObjectInputStream obj = new ObjectInputStream(new FileInputStream(partyPlayersFile));
this.partyPlayers = (HashMap<String, HashMap<String, Boolean>>)obj.readObject();
} catch (FileNotFoundException e) { e.printStackTrace();
} catch (EOFException e) { Bukkit.getLogger().info("partyPlayersFile empty.");
} catch (IOException e) { e.printStackTrace();
} catch (ClassNotFoundException e) { e.printStackTrace(); }
}
public void loadParties() {
if (new File(partyPlayersFile).exists()) {
try {
ObjectInputStream obj = new ObjectInputStream(new FileInputStream(partyPlayersFile));
partyPlayers = (HashMap<String, HashMap<String, Boolean>>) obj.readObject();
}
catch (FileNotFoundException e) {
e.printStackTrace();
}
catch (EOFException e) {
Bukkit.getLogger().info("partyPlayersFile empty.");
}
catch (IOException e) {
e.printStackTrace();
}
catch (ClassNotFoundException e) {
e.printStackTrace();
}
}
if(new File(partyLocksFile).exists()) {
try {
ObjectInputStream obj = new ObjectInputStream(new FileInputStream(partyLocksFile));
this.partyLocks = (HashMap<String, Boolean>)obj.readObject();
} catch (FileNotFoundException e) { e.printStackTrace();
} catch (EOFException e) { Bukkit.getLogger().info("partyLocksFile empty.");
} catch (IOException e) { e.printStackTrace();
} catch (ClassNotFoundException e) { e.printStackTrace(); }
}
if (new File(partyLocksFile).exists()) {
try {
ObjectInputStream obj = new ObjectInputStream(new FileInputStream(partyLocksFile));
partyLocks = (HashMap<String, Boolean>) obj.readObject();
}
catch (FileNotFoundException e) {
e.printStackTrace();
}
catch (EOFException e) {
Bukkit.getLogger().info("partyLocksFile empty.");
}
catch (IOException e) {
e.printStackTrace();
}
catch (ClassNotFoundException e) {
e.printStackTrace();
}
}
if(new File(partyPasswordsFile).exists()) {
try {
ObjectInputStream obj = new ObjectInputStream(new FileInputStream(partyPasswordsFile));
this.partyPasswords = (HashMap<String, String>)obj.readObject();
} catch (FileNotFoundException e) { e.printStackTrace();
} catch (EOFException e) { Bukkit.getLogger().info("partyPasswordsFile empty.");
} catch (IOException e) { e.printStackTrace();
} catch (ClassNotFoundException e) { e.printStackTrace(); }
}
if (new File(partyPasswordsFile).exists()) {
try {
ObjectInputStream obj = new ObjectInputStream(new FileInputStream(partyPasswordsFile));
this.partyPasswords = (HashMap<String, String>) obj.readObject();
}
catch (FileNotFoundException e) {
e.printStackTrace();
}
catch (EOFException e) {
Bukkit.getLogger().info("partyPasswordsFile empty.");
}
catch (IOException e) {
e.printStackTrace();
}
catch (ClassNotFoundException e) {
e.printStackTrace();
}
}
}
public void saveParties() {
savePartyPlayers();
savePartyLocks();
savePartyPasswords();
/**
* Save all party-related files.
*/
private void saveParties() {
savePartyFile(partyPlayersFile, partyPlayers);
savePartyFile(partyLocksFile, partyLocks);
savePartyFile(partyPasswordsFile, partyPasswords);
}
public void savePartyPlayers() {
try {
new File(partyPlayersFile).createNewFile();
ObjectOutputStream obj = new ObjectOutputStream(new FileOutputStream(partyPlayersFile));
obj.writeObject(this.partyPlayers);
obj.close();
} catch (FileNotFoundException e) { e.printStackTrace();
} catch (IOException e) { e.printStackTrace(); }
}
public void savePartyLocks() {
try {
new File(partyLocksFile).createNewFile();
ObjectOutputStream obj = new ObjectOutputStream(new FileOutputStream(partyLocksFile));
obj.writeObject(this.partyLocks);
obj.close();
} catch (FileNotFoundException e) { e.printStackTrace();
} catch (IOException e) { e.printStackTrace(); }
}
public void savePartyPasswords() {
try {
new File(partyPasswordsFile).createNewFile();
ObjectOutputStream obj = new ObjectOutputStream(new FileOutputStream(partyPasswordsFile));
obj.writeObject(this.partyPasswords);
obj.close();
} catch (FileNotFoundException e) { e.printStackTrace();
} catch (IOException e) { e.printStackTrace(); }
/**
* Save a party-related file.
*
* @param fileName The filename to save as
* @param partyData The Hashmap with the party data
*/
private void savePartyFile(String fileName, Object partyData) {
try {
new File(fileName).createNewFile();
ObjectOutputStream obj = new ObjectOutputStream(new FileOutputStream(fileName));
obj.writeObject(partyData);
obj.close();
}
catch (FileNotFoundException e) {
e.printStackTrace();
}
catch (IOException e) {
e.printStackTrace();
}
}
}

View File

@@ -39,7 +39,7 @@ public class GainXp implements Runnable {
damage += health;
}
PP.addXP(skillType, (int) (damage * baseXp), player);
PP.addXP(skillType, (int) (damage * baseXp));
Skills.XpCheckSkill(skillType, player);
}
}

View File

@@ -4,6 +4,7 @@ import org.bukkit.CropState;
import org.bukkit.Material;
import org.bukkit.block.Block;
import com.gmail.nossr50.datatypes.AbilityType;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.datatypes.SkillType;
@@ -21,7 +22,7 @@ public class GreenThumbTimer implements Runnable {
block.setType(Material.CROPS);
//This replants the wheat at a certain stage in development based on Herbalism Skill
if (!PP.getGreenTerraMode()) {
if (!PP.getAbilityMode(AbilityType.GREEN_TERRA)) {
if (PP.getSkillLevel(SkillType.HERBALISM) >= 600) {
block.setData(CropState.MEDIUM.getData());
}

View File

@@ -5,15 +5,19 @@ import org.bukkit.entity.Player;
import com.gmail.nossr50.Users;
public class RemoveProfileFromMemoryTask implements Runnable {
private Player player;
private Player player;
public RemoveProfileFromMemoryTask(Player player) {
this.player = player;
}
public RemoveProfileFromMemoryTask(Player player) {
this.player = player;
}
@Override
public void run() {
Users.getProfile(player.getName()).save(); //We save here so players don't quit/reconnect to cause lag
Users.removeUserByName(player.getName());
}
@Override
public void run() {
String playerName = player.getName();
//Check if the profile still exists (stuff like MySQL reconnection removes profiles)
if (Users.players.containsKey(playerName.toLowerCase())) {
Users.getProfile(playerName).save(); //We save here so players don't quit/reconnect to cause lag
Users.removeUserByName(playerName);
}
}
}

View File

@@ -10,7 +10,6 @@ import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.LoadProperties;
public class SQLConversionTask implements Runnable {
public SQLConversionTask() {}
@Override
public void run() {
@@ -175,40 +174,36 @@ public class SQLConversionTask implements Runnable {
+ " WHERE id = " + id);
mcMMO.database.write("UPDATE "
+ LoadProperties.MySQLtablePrefix
+ "skills SET " + " taming = taming+"
+ m.getInt(taming) + ", mining = mining+"
+ m.getInt(mining) + ", repair = repair+"
+ m.getInt(repair)
+ ", woodcutting = woodcutting+"
+ m.getInt(woodcutting)
+ "skills SET "
+ " taming = taming+" + m.getInt(taming)
+ ", mining = mining+" + m.getInt(mining)
+ ", repair = repair+" + m.getInt(repair)
+ ", woodcutting = woodcutting+" + m.getInt(woodcutting)
+ ", unarmed = unarmed+" + m.getInt(unarmed)
+ ", herbalism = herbalism+"
+ m.getInt(herbalism)
+ ", excavation = excavation+"
+ m.getInt(excavation)
+ ", herbalism = herbalism+" + m.getInt(herbalism)
+ ", excavation = excavation+" + m.getInt(excavation)
+ ", archery = archery+" + m.getInt(archery)
+ ", swords = swords+" + m.getInt(swords)
+ ", axes = axes+" + m.getInt(axes)
+ ", acrobatics = acrobatics+"
+ m.getInt(acrobatics)
+ ", acrobatics = acrobatics+" + m.getInt(acrobatics)
+ ", fishing = fishing+" + m.getInt(fishing)
+ " WHERE user_id = " + id);
mcMMO.database.write("UPDATE "
+ LoadProperties.MySQLtablePrefix
+ "experience SET " + " taming = "
+ m.getInt(tamingXP) + ", mining = "
+ m.getInt(miningXP) + ", repair = "
+ m.getInt(repairXP) + ", woodcutting = "
+ m.getInt(woodCuttingXP) + ", unarmed = "
+ m.getInt(unarmedXP) + ", herbalism = "
+ m.getInt(herbalismXP) + ", excavation = "
+ m.getInt(excavationXP) + ", archery = "
+ m.getInt(archeryXP) + ", swords = "
+ m.getInt(swordsXP) + ", axes = "
+ m.getInt(axesXP) + ", acrobatics = "
+ m.getInt(acrobaticsXP) + ", fishing = "
+ m.getInt(fishingXP) + " WHERE user_id = "
+ id);
+ "experience SET "
+ " taming = " + m.getInt(tamingXP)
+ ", mining = " + m.getInt(miningXP)
+ ", repair = " + m.getInt(repairXP)
+ ", woodcutting = " + m.getInt(woodCuttingXP)
+ ", unarmed = " + m.getInt(unarmedXP)
+ ", herbalism = " + m.getInt(herbalismXP)
+ ", excavation = " + m.getInt(excavationXP)
+ ", archery = " + m.getInt(archeryXP)
+ ", swords = " + m.getInt(swordsXP)
+ ", axes = " + m.getInt(axesXP)
+ ", acrobatics = " + m.getInt(acrobaticsXP)
+ ", fishing = " + m.getInt(fishingXP)
+ " WHERE user_id = " + id);
}
else {
theCount++;
@@ -241,40 +236,40 @@ public class SQLConversionTask implements Runnable {
+ "' WHERE id = " + id);
mcMMO.database.write("UPDATE "
+ LoadProperties.MySQLtablePrefix
+ "skills SET " + " taming = "
+ m.getInt(taming) + ", mining = "
+ m.getInt(mining) + ", repair = "
+ m.getInt(repair) + ", woodcutting = "
+ m.getInt(woodcutting) + ", unarmed = "
+ m.getInt(unarmed) + ", herbalism = "
+ m.getInt(herbalism) + ", excavation = "
+ m.getInt(excavation) + ", archery = "
+ m.getInt(archery) + ", swords = "
+ m.getInt(swords) + ", axes = "
+ m.getInt(axes) + ", acrobatics = "
+ m.getInt(acrobatics) + ", fishing = "
+ m.getInt(fishing) + " WHERE user_id = "
+ id);
+ "skills SET "
+ " taming = taming+" + m.getInt(taming)
+ ", mining = mining+" + m.getInt(mining)
+ ", repair = repair+" + m.getInt(repair)
+ ", woodcutting = woodcutting+" + m.getInt(woodcutting)
+ ", unarmed = unarmed+" + m.getInt(unarmed)
+ ", herbalism = herbalism+" + m.getInt(herbalism)
+ ", excavation = excavation+" + m.getInt(excavation)
+ ", archery = archery+" + m.getInt(archery)
+ ", swords = swords+" + m.getInt(swords)
+ ", axes = axes+" + m.getInt(axes)
+ ", acrobatics = acrobatics+" + m.getInt(acrobatics)
+ ", fishing = fishing+" + m.getInt(fishing)
+ " WHERE user_id = " + id);
mcMMO.database.write("UPDATE "
+ LoadProperties.MySQLtablePrefix
+ "experience SET " + " taming = "
+ m.getInt(tamingXP) + ", mining = "
+ m.getInt(miningXP) + ", repair = "
+ m.getInt(repairXP) + ", woodcutting = "
+ m.getInt(woodCuttingXP) + ", unarmed = "
+ m.getInt(unarmedXP) + ", herbalism = "
+ m.getInt(herbalismXP) + ", excavation = "
+ m.getInt(excavationXP) + ", archery = "
+ m.getInt(archeryXP) + ", swords = "
+ m.getInt(swordsXP) + ", axes = "
+ m.getInt(axesXP) + ", acrobatics = "
+ m.getInt(acrobaticsXP) + ", fishing = "
+ m.getInt(fishingXP) + " WHERE user_id = "
+ id);
+ "experience SET "
+ " taming = " + m.getInt(tamingXP)
+ ", mining = " + m.getInt(miningXP)
+ ", repair = " + m.getInt(repairXP)
+ ", woodcutting = " + m.getInt(woodCuttingXP)
+ ", unarmed = " + m.getInt(unarmedXP)
+ ", herbalism = " + m.getInt(herbalismXP)
+ ", excavation = " + m.getInt(excavationXP)
+ ", archery = " + m.getInt(archeryXP)
+ ", swords = " + m.getInt(swordsXP)
+ ", axes = " + m.getInt(axesXP)
+ ", acrobatics = " + m.getInt(acrobaticsXP)
+ ", fishing = " + m.getInt(fishingXP)
+ " WHERE user_id = " + id);
}
}
System.out.println("[mcMMO] MySQL Updated from users file, " + theCount + " items added/updated to MySQL DB");
System.out.println("[mcMMO] MySQL Updated from users file, " + theCount + " items added/updated to MySQL DB"); //TODO: Locale
in.close();
}
catch (Exception e) {

View File

@@ -0,0 +1,37 @@
package com.gmail.nossr50.runnables;
import org.bukkit.Bukkit;
import org.getspout.spoutapi.SpoutManager;
import org.getspout.spoutapi.player.FileManager;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.LoadProperties;
import com.gmail.nossr50.spout.SpoutStuff;
public class SpoutStart implements Runnable{
private final mcMMO plugin;
public SpoutStart(mcMMO m) {
this.plugin = m;
}
@Override
public void run() {
if (Bukkit.getPluginManager().getPlugin("Spout") != null) {
LoadProperties.spoutEnabled = true;
}
else {
LoadProperties.spoutEnabled = false;
}
//Spout Stuff
if (LoadProperties.spoutEnabled) {
SpoutStuff.setupSpoutConfigs();
SpoutStuff.registerCustomEvent();
SpoutStuff.extractFiles(); //Extract source materials
FileManager FM = SpoutManager.getFileManager();
FM.addToPreLoginCache(plugin, SpoutStuff.getFiles());
}
}
}

View File

@@ -52,7 +52,7 @@ public class mcBleedTimer implements Runnable {
}
PP.decreaseBleedTicks();
if (PP.getBleedTicks() == 0) {
player.sendMessage(mcLocale.getString("Swords.StoppedBleeding"));
}

View File

@@ -7,19 +7,16 @@ import com.gmail.nossr50.mcMMO;
public class mcSaveTimer implements Runnable {
private final mcMMO plugin;
public mcSaveTimer(final mcMMO plugin)
{
public mcSaveTimer(final mcMMO plugin) {
this.plugin = plugin;
}
@Override
public void run()
{
public void run() {
//All player data will be saved periodically through this
for(Player player : plugin.getServer().getOnlinePlayers())
{
for (Player player : plugin.getServer().getOnlinePlayers()) {
Users.getProfile(player).save();
}
}
}
}

View File

@@ -1,6 +1,6 @@
package com.gmail.nossr50.runnables;
import org.bukkit.entity.*;
import org.bukkit.entity.Player;
import com.gmail.nossr50.Users;
import com.gmail.nossr50.mcMMO;
@@ -9,49 +9,50 @@ import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.skills.Skills;
public class mcTimer implements Runnable
{
private final mcMMO plugin;
public class mcTimer implements Runnable {
private final mcMMO plugin;
public mcTimer(final mcMMO plugin)
{
public mcTimer(final mcMMO plugin) {
this.plugin = plugin;
}
public void run()
{
long curTime = System.currentTimeMillis();
for(Player player : plugin.getServer().getOnlinePlayers())
{
if(player == null)
continue;
PlayerProfile PP = Users.getProfile(player);
if(PP == null)
continue;
/*
* MONITOR SKILLS
*/
Skills.monitorSkill(player, PP, curTime, SkillType.AXES);
Skills.monitorSkill(player, PP, curTime, SkillType.EXCAVATION);
Skills.monitorSkill(player, PP, curTime, SkillType.HERBALISM);
Skills.monitorSkill(player, PP, curTime, SkillType.MINING);
Skills.monitorSkill(player, PP, curTime, SkillType.SWORDS);
Skills.monitorSkill(player, PP, curTime, SkillType.UNARMED);
Skills.monitorSkill(player, PP, curTime, SkillType.WOODCUTTING);
/*
* COOLDOWN MONITORING
*/
Skills.watchCooldown(player, PP, curTime, AbilityType.SKULL_SPLIITER);
Skills.watchCooldown(player, PP, curTime, AbilityType.GIGA_DRILL_BREAKER);
Skills.watchCooldown(player, PP, curTime, AbilityType.GREEN_TERRA);
Skills.watchCooldown(player, PP, curTime, AbilityType.SUPER_BREAKER);
Skills.watchCooldown(player, PP, curTime, AbilityType.SERRATED_STRIKES);
Skills.watchCooldown(player, PP, curTime, AbilityType.BERSERK);
Skills.watchCooldown(player, PP, curTime, AbilityType.TREE_FELLER);
Skills.watchCooldown(player, PP, curTime, AbilityType.BLAST_MINING);
}
}
@Override
public void run() {
long curTime = System.currentTimeMillis();
for (Player player : plugin.getServer().getOnlinePlayers()) {
if (player == null) { //Is this even possible?
continue;
}
PlayerProfile PP = Users.getProfile(player);
if (PP == null) { //Is this even possible?
continue;
}
/*
* MONITOR SKILLS
*/
Skills.monitorSkill(player, PP, curTime, SkillType.AXES);
Skills.monitorSkill(player, PP, curTime, SkillType.EXCAVATION);
Skills.monitorSkill(player, PP, curTime, SkillType.HERBALISM);
Skills.monitorSkill(player, PP, curTime, SkillType.MINING);
Skills.monitorSkill(player, PP, curTime, SkillType.SWORDS);
Skills.monitorSkill(player, PP, curTime, SkillType.UNARMED);
Skills.monitorSkill(player, PP, curTime, SkillType.WOODCUTTING);
/*
* COOLDOWN MONITORING
*/
Skills.watchCooldown(player, PP, curTime, AbilityType.SKULL_SPLIITER);
Skills.watchCooldown(player, PP, curTime, AbilityType.GIGA_DRILL_BREAKER);
Skills.watchCooldown(player, PP, curTime, AbilityType.GREEN_TERRA);
Skills.watchCooldown(player, PP, curTime, AbilityType.SUPER_BREAKER);
Skills.watchCooldown(player, PP, curTime, AbilityType.SERRATED_STRIKES);
Skills.watchCooldown(player, PP, curTime, AbilityType.BERSERK);
Skills.watchCooldown(player, PP, curTime, AbilityType.TREE_FELLER);
Skills.watchCooldown(player, PP, curTime, AbilityType.BLAST_MINING);
}
}
}

View File

@@ -1,5 +1,7 @@
package com.gmail.nossr50.skills;
import java.util.Random;
import org.bukkit.entity.Player;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityDamageEvent;
@@ -14,6 +16,8 @@ import com.gmail.nossr50.party.Party;
public class Acrobatics {
private static Random random = new Random();
/**
* Check for fall damage reduction.
*
@@ -39,7 +43,7 @@ public class Acrobatics {
acrovar = acrovar * 2;
}
if ((acrovar > MAX_BONUS_LEVEL || Math.random() * 1000 <= acrovar) && mcPermissions.getInstance().roll(player)) {
if ((acrovar > MAX_BONUS_LEVEL || random.nextInt(1000) <= acrovar) && mcPermissions.getInstance().roll(player)) {
int threshold = 7;
if (gracefulRoll) {
@@ -54,7 +58,7 @@ public class Acrobatics {
/* Check for death */
if (health - damage >= 1) {
PP.addXP(SkillType.ACROBATICS, damage * ROLL_XP_MODIFIER, player);
PP.addXP(SkillType.ACROBATICS, damage * ROLL_XP_MODIFIER);
Skills.XpCheckSkill(SkillType.ACROBATICS, player);
event.setDamage(newDamage);
@@ -72,7 +76,7 @@ public class Acrobatics {
}
}
else if (health - damage >= 1) {
PP.addXP(SkillType.ACROBATICS, event.getDamage() * FALL_XP_MODIFIER, player);
PP.addXP(SkillType.ACROBATICS, event.getDamage() * FALL_XP_MODIFIER);
Skills.XpCheckSkill(SkillType.ACROBATICS, player);
}
}
@@ -103,11 +107,11 @@ public class Acrobatics {
int skillLevel = PPd.getSkillLevel(SkillType.ACROBATICS);
int skillCheck = m.skillCheck(skillLevel, MAX_BONUS_LEVEL);
if (Math.random() * 4000 <= skillCheck && mcPermissions.getInstance().dodge(defender)) {
if (random.nextInt(4000) <= skillCheck && mcPermissions.getInstance().dodge(defender)) {
defender.sendMessage(mcLocale.getString("Acrobatics.Dodge"));
if (System.currentTimeMillis() >= (5000 + PPd.getRespawnATS()) && defender.getHealth() >= 1) {
PPd.addXP(SkillType.ACROBATICS, damage * DODGE_MODIFIER, defender);
PPd.addXP(SkillType.ACROBATICS, damage * DODGE_MODIFIER);
Skills.XpCheckSkill(SkillType.ACROBATICS, defender);
}

View File

@@ -1,5 +1,7 @@
package com.gmail.nossr50.skills;
import java.util.Random;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.entity.Entity;
@@ -13,10 +15,11 @@ import com.gmail.nossr50.mcPermissions;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.locale.mcLocale;
import com.gmail.nossr50.party.Party;
public class Archery {
private static Random random = new Random();
/**
* Track arrows fired for later retrieval.
*
@@ -32,55 +35,11 @@ public class Archery {
plugin.arrowTracker.put(entity, 0);
}
if (skillLevel > MAX_BONUS_LEVEL || (Math.random() * 1000 <= skillLevel)) {
if (skillLevel > MAX_BONUS_LEVEL || (random.nextInt(1000) <= skillLevel)) {
plugin.arrowTracker.put(entity, 1);
}
}
/**
* Check for ignition on arrow hit.
*
* @param entity Entity damaged by the arrow
* @param attacker Player who fired the arrow
*/
public static void ignitionCheck(Entity entity, Player attacker) {
//Check to see if PVP for this world is disabled before executing
if (!entity.getWorld().getPVP()) {
return;
}
final int IGNITION_CHANCE = 25;
final int MAX_IGNITION_TICKS = 120;
PlayerProfile PPa = Users.getProfile(attacker);
if (Math.random() * 100 <= IGNITION_CHANCE) {
int ignition = 20;
/* Add 20 ticks for every 200 skill levels */
ignition += (PPa.getSkillLevel(SkillType.ARCHERY) / 200) * 20;
if (ignition > MAX_IGNITION_TICKS) {
ignition = MAX_IGNITION_TICKS;
}
if (entity instanceof Player) {
Player defender = (Player) entity;
if (!Party.getInstance().inSameParty(attacker, defender)) {
defender.setFireTicks(defender.getFireTicks() + ignition);
attacker.sendMessage(mcLocale.getString("Combat.Ignition"));
defender.sendMessage(mcLocale.getString("Combat.BurningArrowHit"));
}
}
else {
entity.setFireTicks(entity.getFireTicks() + ignition);
attacker.sendMessage(mcLocale.getString("Combat.Ignition"));
}
}
}
/**
* Check for Daze.
*
@@ -94,14 +53,14 @@ public class Archery {
Location loc = defender.getLocation();
int skillCheck = m.skillCheck(skillLevel, MAX_BONUS_LEVEL);
if (Math.random() * 10 > 5) {
if (random.nextInt(10) > 5) {
loc.setPitch(90);
}
else {
loc.setPitch(-90);
}
if (Math.random() * 2000 <= skillCheck && mcPermissions.getInstance().daze(attacker)) {
if (random.nextInt(2000) <= skillCheck && mcPermissions.getInstance().daze(attacker)) {
defender.teleport(loc);
defender.sendMessage(mcLocale.getString("Combat.TouchedFuzzy"));
attacker.sendMessage(mcLocale.getString("Combat.TargetDazed"));

View File

@@ -1,5 +1,7 @@
package com.gmail.nossr50.skills;
import java.util.Random;
import org.bukkit.entity.AnimalTamer;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
@@ -18,6 +20,8 @@ import com.gmail.nossr50.party.Party;
public class Axes {
private static Random random = new Random();
/**
* Apply bonus to damage done by axes.
*
@@ -72,7 +76,7 @@ public class Axes {
int skillLevel = PPa.getSkillLevel(SkillType.AXES);
int skillCheck = m.skillCheck(skillLevel, MAX_BONUS_LEVEL);
if (Math.random() * 2000 <= skillCheck && !entity.isDead()){
if (random.nextInt(2000) <= skillCheck && !entity.isDead()){
int damage = event.getDamage();
if (entity instanceof Player){
@@ -133,7 +137,7 @@ public class Axes {
final int GREATER_IMPACT_CHANCE = 25;
final double GREATER_IMPACT_MULTIPLIER = 1.5;
if (Math.random() * 100 <= GREATER_IMPACT_CHANCE) {
if (random.nextInt(100) <= GREATER_IMPACT_CHANCE) {
event.setDamage(event.getDamage() + 2);
target.setVelocity(attacker.getLocation().getDirection().normalize().multiply(GREATER_IMPACT_MULTIPLIER));
attacker.sendMessage(mcLocale.getString("Axes.GreaterImpactOnEnemy"));

View File

@@ -4,6 +4,7 @@ import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Random;
import org.bukkit.ChatColor;
import org.bukkit.Material;
@@ -25,6 +26,8 @@ import com.gmail.nossr50.locale.mcLocale;
public class BlastMining {
private static Random random = new Random();
/**
* Handler for what blocks drop from the explosion.
*
@@ -43,7 +46,7 @@ public class BlastMining {
while (iterator2.hasNext()) {
Block temp = iterator2.next();
if ((float) Math.random() < (yield + oreBonus)) {
if (random.nextFloat() < (yield + oreBonus)) {
blocksDropped.add(temp);
Mining.miningDrops(temp);
@@ -66,7 +69,7 @@ public class BlastMining {
while (iterator3.hasNext()) {
Block temp = iterator3.next();
if ((float) Math.random() < (yield - debrisReduction))
if (random.nextFloat() < (yield - debrisReduction))
Mining.miningDrops(temp);
}
}
@@ -254,7 +257,7 @@ public class BlastMining {
Block block = player.getTargetBlock(transparent, BLOCKS_AWAY);
if (block.getType().equals(Material.TNT) && m.blockBreakSimulate(block, player, true) && PP.getSkillLevel(SkillType.MINING) >= 125) {
final int MAX_DISTANCE_AWAY = 10;
final double MAX_DISTANCE_AWAY = 10.0;
AbilityType ability = AbilityType.BLAST_MINING;
/* Check Cooldown */
@@ -279,7 +282,7 @@ public class BlastMining {
tnt.setFuseTicks(0);
PP.setSkillDATS(ability, System.currentTimeMillis()); //Save DATS for Blast Mining
PP.setBlastMiningInformed(false);
PP.setAbilityInformed(ability, false);
}
}
}

View File

@@ -2,6 +2,7 @@ package com.gmail.nossr50.skills;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import org.bukkit.Bukkit;
import org.bukkit.Location;
@@ -9,7 +10,6 @@ import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.event.player.PlayerAnimationEvent;
import com.gmail.nossr50.spout.SpoutSounds;
import com.gmail.nossr50.Users;
@@ -20,11 +20,14 @@ import com.gmail.nossr50.config.LoadTreasures;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.datatypes.treasure.ExcavationTreasure;
import com.gmail.nossr50.events.fake.FakePlayerAnimationEvent;
import org.getspout.spoutapi.sound.SoundEffect;
public class Excavation {
private static Random random = new Random();
/**
* Check to see if a block can be broken by Giga Drill Breaker.
*
@@ -101,7 +104,7 @@ public class Excavation {
for (ExcavationTreasure treasure : treasures) {
if (skillLevel >= treasure.getDropLevel()) {
if (Math.random() * 100 <= treasure.getDropChance()) {
if (random.nextDouble() * 100 <= treasure.getDropChance()) {
xp += treasure.getXp();
is.add(treasure.getDrop());
}
@@ -117,7 +120,7 @@ public class Excavation {
}
//Handle XP related tasks
PP.addXP(SkillType.EXCAVATION, xp, player);
PP.addXP(SkillType.EXCAVATION, xp);
Skills.XpCheckSkill(SkillType.EXCAVATION, player);
}
@@ -131,7 +134,7 @@ public class Excavation {
Skills.abilityDurabilityLoss(player.getItemInHand(), LoadProperties.abilityDurabilityLoss);
if (!block.hasMetadata("mcmmoPlacedBlock")) {
PlayerAnimationEvent armswing = new PlayerAnimationEvent(player);
FakePlayerAnimationEvent armswing = new FakePlayerAnimationEvent(player);
Bukkit.getPluginManager().callEvent(armswing);
Excavation.excavationProcCheck(block, player);

View File

@@ -3,8 +3,8 @@ package com.gmail.nossr50.skills;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Random;
import org.bukkit.DyeColor;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.enchantments.Enchantment;
@@ -30,6 +30,8 @@ import com.gmail.nossr50.locale.mcLocale;
public class Fishing {
private static Random random = new Random();
/**
* Get the player's current fishing loot tier.
*
@@ -96,10 +98,10 @@ public class Fishing {
}
if (LoadProperties.fishingDrops) {
FishingTreasure treasure = rewards.get((int) (Math.random() * rewards.size()));
FishingTreasure treasure = rewards.get(random.nextInt(rewards.size()));
if (Math.random() * 100 <= treasure.getDropChance()) {
Users.getProfile(player).addXP(SkillType.FISHING, treasure.getXp(), player);
if (random.nextDouble() * 100 <= treasure.getDropChance()) {
Users.getProfile(player).addXP(SkillType.FISHING, treasure.getXp());
theCatch.setItemStack(treasure.getDrop());
}
}
@@ -107,10 +109,14 @@ public class Fishing {
theCatch.setItemStack(new ItemStack(Material.RAW_FISH));
}
theCatch.getItemStack().setDurability((short) (Math.random() * theCatch.getItemStack().getType().getMaxDurability())); //Change durability to random value
short maxDurability = theCatch.getItemStack().getType().getMaxDurability();
if (maxDurability > 0) {
theCatch.getItemStack().setDurability((short) (random.nextInt(maxDurability))); //Change durability to random value
}
m.mcDropItem(player.getLocation(), new ItemStack(Material.RAW_FISH)); //Always drop a fish
PP.addXP(SkillType.FISHING, LoadProperties.mfishing, player);
PP.addXP(SkillType.FISHING, LoadProperties.mfishing);
Skills.XpCheckSkill(SkillType.FISHING, player);
}
@@ -133,7 +139,7 @@ public class Fishing {
player.sendMessage(mcLocale.getString("Fishing.ItemFound"));
if (ItemChecks.isArmor(fishingResults) || ItemChecks.isTool(fishingResults)) {
if (Math.random() * 100 <= ENCHANTMENT_CHANCE) {
if (random.nextInt(100) <= ENCHANTMENT_CHANCE) {
for (Enchantment newEnchant : Enchantment.values()) {
if (newEnchant.canEnchantItem(fishingResults)) {
Map<Enchantment, Integer> resultEnchantments = fishingResults.getEnchantments();
@@ -145,9 +151,9 @@ public class Fishing {
}
/* Actual chance to have an enchantment is related to your fishing skill */
if (Math.random() * 15 < Fishing.getFishingLootTier(PP)) {
if (random.nextInt(15) < Fishing.getFishingLootTier(PP)) {
enchanted = true;
int randomEnchantLevel = (int) (Math.random() * newEnchant.getMaxLevel()) + 1;
int randomEnchantLevel = random.nextInt(newEnchant.getMaxLevel()) + 1;
if (randomEnchantLevel < newEnchant.getStartLevel()) {
randomEnchantLevel = newEnchant.getStartLevel();
@@ -172,7 +178,7 @@ public class Fishing {
* @param event The event to modify
*/
public static void shakeMob(PlayerFishEvent event) {
final int DROP_NUMBER = (int) (Math.random() * 101);
final int DROP_NUMBER = random.nextInt(100);
LivingEntity le = (LivingEntity) event.getCaught();
EntityType type = le.getType();
@@ -276,7 +282,7 @@ public class Fishing {
wool.setColor(sheep.getColor());
ItemStack theWool = wool.toItemStack();
theWool.setAmount((int)(Math.random() * 6));
theWool.setAmount(1 + random.nextInt(6));
m.mcDropItem(loc, theWool);
sheep.setSheared(true);
@@ -315,7 +321,7 @@ public class Fishing {
break;
case SQUID:
m.mcDropItem(loc, new ItemStack(Material.INK_SACK, 1, (short) 0, DyeColor.BLACK.getData()));
m.mcDropItem(loc, new ItemStack(Material.INK_SACK, 1, (short) 0, (byte) 0x0));
break;
case ZOMBIE:

View File

@@ -1,5 +1,7 @@
package com.gmail.nossr50.skills;
import java.util.Random;
import org.bukkit.Bukkit;
import org.bukkit.CropState;
import org.bukkit.Location;
@@ -15,6 +17,7 @@ import com.gmail.nossr50.m;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.mcPermissions;
import com.gmail.nossr50.config.LoadProperties;
import com.gmail.nossr50.datatypes.AbilityType;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.locale.mcLocale;
@@ -22,6 +25,8 @@ import com.gmail.nossr50.runnables.GreenThumbTimer;
public class Herbalism {
private static Random random = new Random();
/**
* Activate the Green Terra ability.
*
@@ -34,7 +39,7 @@ public class Herbalism {
Material type = block.getType();
if (!hasSeeds) {
player.sendMessage("You need more seeds to spread Green Terra");
player.sendMessage("You need more seeds to spread Green Terra"); //TODO: Needs more locale.
}
else if (hasSeeds && !block.getType().equals(Material.WHEAT)) {
inventory.removeItem(new ItemStack(Material.SEEDS));
@@ -137,7 +142,7 @@ public class Herbalism {
if (b.getType().equals(Material.CACTUS)) {
mat = Material.CACTUS;
if (!b.hasMetadata("mcmmoPlacedBlock")) {
if(herbLevel > MAX_BONUS_LEVEL || (Math.random() * 1000 <= herbLevel)) {
if (herbLevel > MAX_BONUS_LEVEL || random.nextInt(1000) <= herbLevel) {
catciDrops++;
}
xp += LoadProperties.mcactus;
@@ -193,7 +198,7 @@ public class Herbalism {
if (b.getType().equals(Material.SUGAR_CANE_BLOCK)) {
mat = Material.SUGAR_CANE;
if (!b.hasMetadata("mcmmoPlacedBlock")) {
if(herbLevel > MAX_BONUS_LEVEL || (Math.random() * 1000 <= herbLevel)) {
if (herbLevel > MAX_BONUS_LEVEL || random.nextInt(1000) <= herbLevel) {
caneDrops++;
}
xp += LoadProperties.msugar;
@@ -226,7 +231,7 @@ public class Herbalism {
else {
ItemStack is = new ItemStack(mat);
if (herbLevel > MAX_BONUS_LEVEL || (Math.random() * 1000 <= herbLevel)) {
if (herbLevel > MAX_BONUS_LEVEL || random.nextInt(1000) <= herbLevel) {
if (type.equals(Material.CACTUS)) {
m.mcDropItems(loc, is, catciDrops);
}
@@ -246,7 +251,7 @@ public class Herbalism {
}
}
PP.addXP(SkillType.HERBALISM, xp, player);
PP.addXP(SkillType.HERBALISM, xp);
Skills.XpCheckSkill(SkillType.HERBALISM, player);
}
}
@@ -268,7 +273,7 @@ public class Herbalism {
boolean hasSeeds = inventory.contains(Material.SEEDS);
Location loc = block.getLocation();
if (hasSeeds && PP.getGreenTerraMode() || hasSeeds && (herbLevel > MAX_BONUS_LEVEL || (Math.random() * 1500 <= herbLevel))) {
if (hasSeeds && PP.getAbilityMode(AbilityType.GREEN_TERRA) || hasSeeds && (herbLevel > MAX_BONUS_LEVEL || random.nextInt(1500) <= herbLevel)) {
event.setCancelled(true);
m.mcDropItem(loc, new ItemStack(Material.WHEAT));
@@ -297,7 +302,7 @@ public class Herbalism {
player.setItemInHand(new ItemStack(Material.SEEDS, seeds - 1));
if (skillLevel > MAX_BONUS_LEVEL || Math.random() * 1500 <= skillLevel) {
if (skillLevel > MAX_BONUS_LEVEL || random.nextInt(1500) <= skillLevel) {
greenTerra(player, block);
}
else {

View File

@@ -1,5 +1,7 @@
package com.gmail.nossr50.skills;
import java.util.Random;
import org.bukkit.Bukkit;
import org.bukkit.CoalType;
import org.bukkit.Location;
@@ -9,7 +11,6 @@ import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.getspout.spoutapi.sound.SoundEffect;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.event.player.PlayerAnimationEvent;
import com.gmail.nossr50.Users;
import com.gmail.nossr50.m;
@@ -18,10 +19,11 @@ import com.gmail.nossr50.config.LoadProperties;
import com.gmail.nossr50.spout.SpoutSounds;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.events.fake.FakePlayerAnimationEvent;
public class Mining {
public class Mining
{
private static Random random = new Random();
/**
* Drop items from Mining & Blast Mining skills.
@@ -143,7 +145,7 @@ public class Mining
break;
}
PP.addXP(SkillType.MINING, xp, player);
PP.addXP(SkillType.MINING, xp);
Skills.XpCheckSkill(SkillType.MINING, player);
}
@@ -165,7 +167,7 @@ public class Mining
int skillLevel = Users.getProfile(player).getSkillLevel(SkillType.MINING);
if ((MAX_BONUS_LEVEL > 1000 || (Math.random() * 1000 <= skillLevel)) && mcPermissions.getInstance().miningDoubleDrops(player)) {
if ((skillLevel > MAX_BONUS_LEVEL || random.nextInt(1000) <= skillLevel) && mcPermissions.getInstance().miningDoubleDrops(player)) {
if (player.getItemInHand().containsEnchantment(Enchantment.SILK_TOUCH)) {
m.mcDropItem(block.getLocation(), new ItemStack(block.getType()));
}
@@ -215,7 +217,7 @@ public class Mining
Material type = block.getType();
int tier = m.getTier(player.getItemInHand());
int durabilityLoss = LoadProperties.abilityDurabilityLoss;
PlayerAnimationEvent armswing = new PlayerAnimationEvent(player);
FakePlayerAnimationEvent armswing = new FakePlayerAnimationEvent(player);
switch (type) {
case OBSIDIAN:
@@ -255,7 +257,6 @@ public class Mining
Bukkit.getPluginManager().callEvent(armswing);
Skills.abilityDurabilityLoss(player.getItemInHand(), durabilityLoss);
miningBlockCheck(player, block);
miningBlockCheck(player, block);
if (LoadProperties.spoutEnabled) {

View File

@@ -1,14 +1,18 @@
package com.gmail.nossr50.skills;
import java.util.Map;
import java.util.Random;
import java.util.Map.Entry;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.PlayerInventory;
import org.getspout.spoutapi.SpoutManager;
import org.getspout.spoutapi.player.SpoutPlayer;
import com.gmail.nossr50.ItemChecks;
import com.gmail.nossr50.Users;
@@ -18,10 +22,13 @@ import com.gmail.nossr50.config.LoadProperties;
import com.gmail.nossr50.spout.SpoutSounds;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.events.skills.McMMOPlayerRepairCheckEvent;
import com.gmail.nossr50.locale.mcLocale;
public class Repair {
private static Random random = new Random();
/**
* Handle all the item repair checks.
*
@@ -41,23 +48,19 @@ public class Repair {
*/
if (ItemChecks.isArmor(is) && LoadProperties.repairArmor && mcPermissions.getInstance().armorRepair(player)) {
if (ItemChecks.isDiamondArmor(is) && inventory.contains(LoadProperties.rDiamond) && skillLevel >= LoadProperties.repairdiamondlevel && mcPermissions.getInstance().diamondRepair(player)) {
inventory.removeItem(new ItemStack(LoadProperties.rDiamond));
repairItem(player, is);
repairItem(player, is, new ItemStack(LoadProperties.rDiamond));
xpHandler(player, PP, is, durabilityBefore, 6, true);
}
else if (ItemChecks.isIronArmor(is) && inventory.contains(LoadProperties.rIron) && skillLevel >= LoadProperties.repairIronLevel && mcPermissions.getInstance().ironRepair(player)) {
inventory.removeItem(new ItemStack(LoadProperties.rIron));
repairItem(player, is);
repairItem(player, is, new ItemStack(LoadProperties.rIron));
xpHandler(player, PP, is, durabilityBefore, 2, true);
}
else if (ItemChecks.isGoldArmor(is) && inventory.contains(LoadProperties.rGold) && skillLevel >= LoadProperties.repairGoldLevel && mcPermissions.getInstance().goldRepair(player)) {
inventory.removeItem(new ItemStack(LoadProperties.rGold));
repairItem(player, is);
repairItem(player, is, new ItemStack(LoadProperties.rGold));
xpHandler(player, PP, is, durabilityBefore, 4, true);
}
else if (ItemChecks.isLeatherArmor(is) && inventory.contains(LoadProperties.rLeather)) {
inventory.removeItem(new ItemStack(LoadProperties.rLeather));
repairItem(player, is);
else if (ItemChecks.isLeatherArmor(is) && inventory.contains(LoadProperties.rLeather) && mcPermissions.getInstance().leatherRepair(player)) {
repairItem(player, is, new ItemStack(LoadProperties.rLeather));
xpHandler(player, PP, is, durabilityBefore, 1, true);
}
else {
@@ -70,33 +73,27 @@ public class Repair {
*/
else if (ItemChecks.isTool(is) && LoadProperties.repairTools && mcPermissions.getInstance().toolRepair(player)) {
if (ItemChecks.isStoneTool(is) && inventory.contains(LoadProperties.rStone) && skillLevel >= LoadProperties.repairStoneLevel && mcPermissions.getInstance().stoneRepair(player)) {
inventory.removeItem(new ItemStack(LoadProperties.rStone));
repairItem(player, is);
repairItem(player, is, new ItemStack(LoadProperties.rStone));
xpHandler(player, PP, is, durabilityBefore, 2, false);
}
else if (ItemChecks.isWoodTool(is) && inventory.contains(LoadProperties.rWood)) {
inventory.removeItem(new ItemStack(LoadProperties.rWood));
repairItem(player, is);
else if (ItemChecks.isWoodTool(is) && inventory.contains(LoadProperties.rWood) && mcPermissions.getInstance().woodRepair(player)) {
repairItem(player, is, new ItemStack(LoadProperties.rWood));
xpHandler(player, PP, is, durabilityBefore, 2, false);
}
else if (ItemChecks.isIronTool(is) && inventory.contains(LoadProperties.rIron) && skillLevel >= LoadProperties.repairIronLevel && mcPermissions.getInstance().ironRepair(player)) {
inventory.removeItem(new ItemStack(LoadProperties.rIron));
repairItem(player, is);
repairItem(player, is, new ItemStack(LoadProperties.rIron));
xpHandler(player, PP, is, durabilityBefore, 1, true);
}
else if (ItemChecks.isDiamondTool(is) && inventory.contains(LoadProperties.rDiamond) && skillLevel >= LoadProperties.repairdiamondlevel && mcPermissions.getInstance().diamondRepair(player)) {
inventory.removeItem(new ItemStack(LoadProperties.rDiamond));
repairItem(player, is);
repairItem(player, is, new ItemStack(LoadProperties.rDiamond));
xpHandler(player, PP, is, durabilityBefore, 1, true);
}
else if (ItemChecks.isGoldTool(is) && inventory.contains(LoadProperties.rGold) && skillLevel >= LoadProperties.repairGoldLevel && mcPermissions.getInstance().goldRepair(player)) {
inventory.removeItem(new ItemStack(LoadProperties.rGold));
repairItem(player, is);
repairItem(player, is, new ItemStack(LoadProperties.rGold));
xpHandler(player, PP, is, durabilityBefore, 8, true);
}
else if (is.getType().equals(Material.BOW) && inventory.contains(LoadProperties.rString)){
inventory.removeItem(new ItemStack(LoadProperties.rString));
repairItem(player, is);
else if (is.getType().equals(Material.BOW) && inventory.contains(LoadProperties.rString) && skillLevel >= LoadProperties.repairBowLevel && mcPermissions.getInstance().bowRepair(player)){
repairItem(player, is, new ItemStack(LoadProperties.rString));
xpHandler(player, PP, is, durabilityBefore, 2, false);
}
else {
@@ -140,7 +137,7 @@ public class Repair {
dif = (short) (dif / 2);
}
PP.addXP(SkillType.REPAIR, dif*10, player);
PP.addXP(SkillType.REPAIR, dif * 10);
Skills.XpCheckSkill(SkillType.REPAIR, player);
//CLANG CLANG
@@ -201,11 +198,11 @@ public class Repair {
for (Entry<Enchantment, Integer> enchant : enchants.entrySet()) {
Enchantment enchantment = enchant.getKey();
if (Math.random() * 100 <= getEnchantChance(rank)) {
if (random.nextInt(100) <= getEnchantChance(rank)) {
int enchantLevel = enchant.getValue();
if (LoadProperties.mayDowngradeEnchants && enchantLevel > 1) {
if (Math.random() * 100 <= getDowngradeChance(rank)) {
if (random.nextInt(100) <= getDowngradeChance(rank)) {
is.addEnchantment(enchantment, enchantLevel--);
downgraded = true;
}
@@ -410,7 +407,7 @@ public class Repair {
int skillLevel = Users.getProfile(player).getSkillLevel(SkillType.REPAIR);
if ((skillLevel > MAX_BONUS_LEVEL || (Math.random() * 1000 <= skillLevel)) && mcPermissions.getInstance().repairBonus(player)) {
if ((skillLevel > MAX_BONUS_LEVEL || random.nextInt(1000) <= skillLevel) && mcPermissions.getInstance().repairBonus(player)) {
player.sendMessage(mcLocale.getString("Skills.FeltEasy"));
return true;
}
@@ -422,16 +419,70 @@ public class Repair {
* Repairs an item.
*
* @param player The player repairing an item
* @param enchants The enchantments on the item
* @param enchantsLevel The level of the enchantments on the item
* @param item The item being repaired
* @param repairMaterial The repair reagent
*/
public static void repairItem(Player player, ItemStack is) {
public static void repairItem(Player player, ItemStack item, ItemStack repairMaterial) {
short initialDurability = item.getDurability();
short newDurability = getRepairAmount(item, player);
PlayerInventory inventory = player.getInventory();
McMMOPlayerRepairCheckEvent event = new McMMOPlayerRepairCheckEvent(player, (short) (initialDurability - newDurability), repairMaterial, item);
Bukkit.getPluginManager().callEvent(event);
if (event.isCancelled()) {
return;
}
if (repairMaterial.getType().equals(Material.WOOD)) {
removeWood(inventory);
}
else {
inventory.removeItem(repairMaterial);
}
/* Handle the enchants */
if (LoadProperties.mayLoseEnchants && !mcPermissions.getInstance().arcaneBypass(player)) {
addEnchants(player, is);
addEnchants(player, item);
}
is.setDurability(getRepairAmount(is, player));
item.setDurability(newDurability);
}
/**
* Handles notifications for placing an anvil.
*
* @param player The player placing the anvil
* @param anvilID The item ID of the anvil block
*/
public static void placedAnvilCheck(Player player, int anvilID) {
PlayerProfile PP = Users.getProfile(player);
if (!PP.getPlacedAnvil()) {
if (LoadProperties.spoutEnabled) {
SpoutPlayer sPlayer = SpoutManager.getPlayer(player);
if (sPlayer.isSpoutCraftEnabled()) {
sPlayer.sendNotification("[mcMMO] Anvil Placed", "Right click to repair!", Material.getMaterial(anvilID)); //TODO: Use Locale
}
}
else {
player.sendMessage(mcLocale.getString("mcBlockListener.PlacedAnvil"));
}
PP.togglePlacedAnvil();
}
}
/**
* Removes wood from a player's inventory on repair. Needed due to wood having multiple possible data values.
*
* @param inventory The inventory to remove wood from
*/
private static void removeWood(PlayerInventory inventory) {
//TODO: Make this less hackish once there's a better way to do it...
int slot = inventory.first(Material.WOOD);
ItemStack item = inventory.getItem(slot);
item.setAmount(item.getAmount() - 1);
}
}

View File

@@ -20,13 +20,13 @@ import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.datatypes.PlayerStat;
import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.datatypes.ToolType;
import com.gmail.nossr50.events.McMMOPlayerLevelUpEvent;
import com.gmail.nossr50.events.experience.McMMOPlayerLevelUpEvent;
import com.gmail.nossr50.locale.mcLocale;
public class Skills {
private final static int TIME_CONVERSION_FACTOR = 1000;
private final static int MAX_DISTANCE_AWAY = 10;
private final static double MAX_DISTANCE_AWAY = 10.0;
/**
* Checks to see if the cooldown for an item or ability is expired.
@@ -66,8 +66,8 @@ public class Skills {
* @param ability The ability to watch cooldowns for
*/
public static void watchCooldown(Player player, PlayerProfile PP, long curTime, AbilityType ability) {
if (!ability.getInformed(PP) && curTime - (PP.getSkillDATS(ability) * TIME_CONVERSION_FACTOR) >= (ability.getCooldown() * TIME_CONVERSION_FACTOR)) {
ability.setInformed(PP, true);
if (!PP.getAbilityInformed(ability) && curTime - (PP.getSkillDATS(ability) * TIME_CONVERSION_FACTOR) >= (ability.getCooldown() * TIME_CONVERSION_FACTOR)) {
PP.setAbilityInformed(ability, true);
player.sendMessage(ability.getAbilityRefresh());
}
}
@@ -89,25 +89,31 @@ public class Skills {
ItemStack inHand = player.getItemInHand();
/* Check if any abilities are active */
if (!PP.getAbilityUse() || PP.getSuperBreakerMode() || PP.getSerratedStrikesMode() || PP.getTreeFellerMode() || PP.getGreenTerraMode() || PP.getBerserkMode() || PP.getGigaDrillBreakerMode()) {
if (!PP.getAbilityUse()) {
return;
}
for (AbilityType x : AbilityType.values()) {
if (PP.getAbilityMode(x)) {
return;
}
}
/* Woodcutting & Axes need to be treated differently.
* Basically the tool always needs to ready and we check to see if the cooldown is over when the user takes action
*/
if (skill == SkillType.WOODCUTTING || skill == SkillType.AXES) {
if (tool.inHand(inHand) && !tool.getToolMode(PP)) {
if (tool.inHand(inHand) && !PP.getToolPreparationMode(tool)) {
if (LoadProperties.enableAbilityMessages) {
player.sendMessage(tool.getRaiseTool());
}
tool.setToolATS(PP, System.currentTimeMillis());
tool.setToolMode(PP, true);
PP.setToolPreparationATS(tool, System.currentTimeMillis());
PP.setToolPreparationMode(tool, true);
}
}
else if (ability.getPermissions(player) && tool.inHand(inHand) && !tool.getToolMode(PP)) {
if (!ability.getMode(PP) && !cooldownOver(PP.getSkillDATS(ability) * TIME_CONVERSION_FACTOR, ability.getCooldown())) {
else if (ability.getPermissions(player) && tool.inHand(inHand) && !PP.getToolPreparationMode(tool)) {
if (!PP.getAbilityMode(ability) && !cooldownOver(PP.getSkillDATS(ability) * TIME_CONVERSION_FACTOR, ability.getCooldown())) {
player.sendMessage(mcLocale.getString("Skills.TooTired") + ChatColor.YELLOW + " (" + calculateTimeLeft(PP.getSkillDATS(ability) * TIME_CONVERSION_FACTOR, ability.getCooldown()) + "s)");
return;
}
@@ -116,8 +122,8 @@ public class Skills {
player.sendMessage(tool.getRaiseTool());
}
tool.setToolATS(PP, System.currentTimeMillis());
tool.setToolMode(PP, true);
PP.setToolPreparationATS(tool, System.currentTimeMillis());
PP.setToolPreparationMode(tool, true);
}
}
@@ -135,15 +141,15 @@ public class Skills {
ToolType tool = skill.getTool();
AbilityType ability = skill.getAbility();
if (tool.getToolMode(PP) && curTime - (tool.getToolATS(PP) * TIME_CONVERSION_FACTOR) >= FOUR_SECONDS) {
tool.setToolMode(PP, false);
if (PP.getToolPreparationMode(tool) && curTime - (PP.getToolPreparationATS(tool) * TIME_CONVERSION_FACTOR) >= FOUR_SECONDS) {
PP.setToolPreparationMode(tool, false);
player.sendMessage(tool.getLowerTool());
}
if (ability.getPermissions(player)) {
if (ability.getMode(PP) && (PP.getSkillDATS(ability) * TIME_CONVERSION_FACTOR) <= curTime) {
ability.setMode(PP, false);
ability.setInformed(PP, false);
if (PP.getAbilityMode(ability) && (PP.getSkillDATS(ability) * TIME_CONVERSION_FACTOR) <= curTime) {
PP.setAbilityMode(ability, false);
PP.setAbilityInformed(ability, false);
player.sendMessage(ability.getAbilityOff());
for (Player y : player.getWorld().getPlayers()) {
@@ -169,7 +175,7 @@ public class Skills {
ps.statVal = PP.getSkillLevel(skillType);
}
else {
ps.statVal = m.getPowerLevel(player, PP);
ps.statVal = PP.getPowerLevel();
}
ps.name = player.getName();
@@ -184,21 +190,20 @@ public class Skills {
*/
public static void XpCheckSkill(SkillType skillType, Player player) {
PlayerProfile PP = Users.getProfile(player);
int skillups = 0;
if (PP.getSkillXpLevel(skillType) >= PP.getXpToLevel(skillType)) {
int skillups = 0;
while (PP.getSkillXpLevel(skillType) >= PP.getXpToLevel(skillType)) {
if (skillType.getMaxLevel() >= PP.getSkillLevel(skillType) + 1) {
if ((skillType.getMaxLevel() >= PP.getSkillLevel(skillType) + 1) && (m.getPowerLevelCap() >= PP.getPowerLevel() + 1)) {
skillups++;
PP.removeXP(skillType, PP.getXpToLevel(skillType));
PP.skillUp(skillType, 1);
PP.addLevels(skillType, 1);
McMMOPlayerLevelUpEvent eventToFire = new McMMOPlayerLevelUpEvent(player, skillType);
Bukkit.getPluginManager().callEvent(eventToFire);
}
else {
PP.removeXP(skillType, PP.getXpToLevel(skillType));
PP.addLevels(skillType, 0);
}
}
@@ -219,6 +224,12 @@ public class Skills {
}
SpoutStuff.levelUpNotification(skillType, sPlayer);
/* Update custom titles */
if(LoadProperties.showPowerLevel) {
sPlayer.setTitle(sPlayer.getName()+ "\n" + ChatColor.YELLOW + "P" + ChatColor.GOLD + "lvl"
+ ChatColor.WHITE+"." + ChatColor.GREEN + String.valueOf(PP.getPowerLevel()));
}
}
else {
player.sendMessage(mcLocale.getString("Skills."+capitalized+"Up", new Object[] {String.valueOf(skillups), PP.getSkillLevel(skillType)}));
@@ -228,6 +239,16 @@ public class Skills {
player.sendMessage(mcLocale.getString("Skills."+capitalized+"Up", new Object[] {String.valueOf(skillups), PP.getSkillLevel(skillType)}));
}
}
/* Always update XP Bar (Check if no levels were gained first to remove redundancy) */
if (skillups == 0 && LoadProperties.spoutEnabled && player instanceof SpoutPlayer) {
SpoutPlayer sPlayer = (SpoutPlayer) player;
if (sPlayer.isSpoutCraftEnabled()) {
if (LoadProperties.xpbar) {
SpoutStuff.updateXpBar(sPlayer);
}
}
}
}
/**
@@ -370,17 +391,18 @@ public class Skills {
public static void abilityCheck(Player player, SkillType type) {
PlayerProfile PP = Users.getProfile(player);
AbilityType ability = type.getAbility();
ToolType tool = type.getTool();
if (type.getTool().inHand(player.getItemInHand())) {
if (type.getTool().getToolMode(PP)) {
type.getTool().setToolMode(PP, false);
if (PP.getToolPreparationMode(tool)) {
PP.setToolPreparationMode(tool, false);
}
/* Axes and Woodcutting are odd because they share the same tool.
* We show them the too tired message when they take action.
*/
if (type == SkillType.WOODCUTTING || type == SkillType.AXES) {
if (!ability.getMode(PP) && !cooldownOver(PP.getSkillDATS(ability) * TIME_CONVERSION_FACTOR, ability.getCooldown())) {
if (!PP.getAbilityMode(ability) && !cooldownOver(PP.getSkillDATS(ability) * TIME_CONVERSION_FACTOR, ability.getCooldown())) {
player.sendMessage(mcLocale.getString("Skills.TooTired") + ChatColor.YELLOW + " (" + calculateTimeLeft(PP.getSkillDATS(ability) * TIME_CONVERSION_FACTOR, ability.getCooldown()) + "s)");
return;
}
@@ -388,7 +410,7 @@ public class Skills {
int ticks = 2 + (PP.getSkillLevel(type) / 50);
if (!ability.getMode(PP) && cooldownOver(PP.getSkillDATS(ability), ability.getCooldown())) {
if (!PP.getAbilityMode(ability) && cooldownOver(PP.getSkillDATS(ability), ability.getCooldown())) {
player.sendMessage(ability.getAbilityOn());
for (Player y : player.getWorld().getPlayers()) {
@@ -398,7 +420,7 @@ public class Skills {
}
PP.setSkillDATS(ability, System.currentTimeMillis()+(ticks * TIME_CONVERSION_FACTOR));
ability.setMode(PP, true);
PP.setAbilityMode(ability, true);
}
}
}

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